Sub-application page processing method and apparatus, computer device, and computer program
The sub-application page processing method enhances rendering speed by creating a page node tree and converting it into an interface call format, addressing the inefficiencies of the DOM interface in mini program page processing.
Patent Information
- Application Number
- JP2025518928
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-11-25
- Filing Date
- 2023-10-18
- Publication Date
- 2025-10-22
- Estimated Expiration
- 2043-10-18
AI Technical Summary
Conventional mini program page processing methods suffer from low page rendering speed due to the use of the Document Object Model (DOM) interface, which includes too many components.
A sub-application page processing method and apparatus that retrieves the page code, creates a page node tree, establishes a binding relationship with a first instance object, and converts the node tree into an interface call format to perform page drawing, bypassing the DOM interface.
Improves page rendering speed by directly converting the page node tree into an interface call format without using the DOM interface as an intermediate bridge.
Smart Images

Figure 2025535022000001_ABST
Abstract
Description
[Technical Field]
[0001] Related Applications This application claims priority to Chinese Patent Application No. 2022114898700, entitled "Sub-application page processing method and apparatus, computer device, and storage medium," filed on November 25, 2022, the entire contents of which are incorporated herein by reference.
[0002] The present application relates to the field of page processing technology, and in particular to a sub-application page processing method and apparatus, a computer device, a storage medium, and a computer program product. [Background technology]
[0003] With the rapid development of computer technology, page processing technology is also constantly evolving, gradually evolving from only web-based (World Wide Web, WWW) page processing (i.e., web page) processing to non-web-based page processing, such as mini program page processing. Mini programs are lightweight applications that can be run and used within a parent application without downloading or installation.
[0004] In the conventional method, the mini program page processing method is as follows: when a mini program page needs to be opened, the page code corresponding to the page is obtained, the page code is parsed to obtain the page parsing result, and the Document Object Model (DOM) interface is called based on the page parsing result to execute the drawing command for page drawing and generate the mini program page.
[0005] However, in the conventional method, in the way of calling the DOM interface to execute the drawing command for page drawing, the DOM interface includes too many components, resulting in a low page rendering speed. Summary of the Invention
[0006] According to the embodiments provided in the present application, a sub-application page processing method and apparatus, a computer device, a computer-readable storage medium, and a computer program product are provided.
[0007] According to one aspect, the present application provides a sub-application page processing method executed by a computing device, the sub-application page processing method comprising: retrieving a page code of a sub-application page when an event is detected that requests retrieving a sub-application page, the sub-application page being a page displayed in the sub-application; Parsing the page code to obtain a page parsing result, and traversing the code set in the page parsing result to create a page node tree corresponding to the sub-application page, the page node tree being a tree structure generated based on the page nodes of the sub-application page; Creating a first instance object for converting a page node tree and establishing a binding relationship between the first instance object and the sub-application page; If the binding relationship is established, converting the page node tree into an interface call format using the first instance object and obtaining interface call information corresponding to the page node tree; and performing page drawing based on the interface invocation information to generate a sub-application page.
[0008] According to another aspect, the present application further provides a sub-application page processing device, the sub-application page processing device comprising: a code retrieval module configured to retrieve a page code of a sub-application page when an event requesting retrieval of the sub-application page is detected, the sub-application page being a page displayed in the sub-application; a node tree generation module configured to parse the page code to obtain a page parsing result, and traverse a code set in the page parsing result to create a page node tree corresponding to the sub-application page, the page node tree being a tree structure generated based on the page nodes of the sub-application page; a page initialization module configured to create a first instance object for transforming the page node tree and establish a binding relationship between the first instance object and the sub-application page; a node tree conversion module configured to convert the page node tree into an interface call format using the first instance object when the binding relationship is established, and obtain interface call information corresponding to the page node tree; a page rendering module configured to perform page rendering based on the interface invocation information to generate a sub-application page.
[0009] According to another aspect, the present application further provides a computing device, the computing device including a memory and a processor, the memory storing computer-readable instructions, and the operations in the method embodiments of the present application are performed when the processor executes the computer-readable instructions.
[0010] According to another aspect, the present application further provides a computer-readable storage medium having computer-readable instructions stored therein, and wherein operations in the method embodiments of the present application are performed when the computer-readable instructions are executed by a processor.
[0011] According to another aspect, the present application further provides a computer program product, the computer program product including computer-readable instructions, wherein operations in the method embodiments of the present application are performed when the computer-readable instructions are executed by a processor.
[0012] The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below. Other features and advantages of the application will become apparent with reference to the description, accompanying drawings, and claims.
[0013] In order to more clearly describe the technical solutions in the embodiments of the present application or related technologies, the following briefly describes the accompanying drawings necessary for describing the embodiments or related technologies. Obviously, the accompanying drawings in the following description merely illustrate the embodiments of the present application, and those skilled in the art can derive other drawings from the disclosed accompanying drawings without creative efforts. [Brief explanation of the drawings]
[0014] [Figure 1] 1 illustrates an application environment of a sub-application page processing method according to an embodiment. [Figure 2] 1 is a schematic flowchart of a sub-application page processing method according to one embodiment; [Figure 3] FIG. 1 is a schematic diagram of converting a page node tree into an interface call format, according to one embodiment. [Figure 4] 10 illustrates creating a first instance object for transforming a page node tree according to one embodiment. [Figure 5] 10 is a schematic flowchart of a sub-application page processing method according to another embodiment; [Figure 6] FIG. 1 is a schematic diagram of a developer's coding to draw and display a sub-application page, according to one embodiment. [Figure 7]FIG. 10 is a schematic diagram of a developer writing code to draw and display a sub-application page according to another embodiment. [Figure 8] FIG. 2 is a schematic diagram of an instance invocation relationship according to one embodiment. [Figure 9] 10 is a schematic flowchart of a sub-application page processing method according to yet another embodiment; [Figure 10] 10 is a schematic flowchart of obtaining first invocation information of a component node according to an embodiment; [Figure 11] FIG. 2 is a structural block diagram of a sub-application page processing device according to one embodiment. [Figure 12] FIG. 2 illustrates the internal structure of a computing device according to one embodiment. DETAILED DESCRIPTION OF THE INVENTION
[0015] The technical solutions in the embodiments of the present application are clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. It is clear that the described embodiments are only a part, not all, of the embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0016] The sub-application page processing method provided in the embodiment of the present application can be applied to the application environment shown in Fig. 1. A user 102 using a terminal can perform operations on the terminal 104, and the terminal 104 communicates with a server 106 via a network. A data storage system can store data that the server 106 needs to process. The data storage system may be integrated into the server 106 or deployed on a cloud or other server.
[0017] User 102 can perform an operation to acquire a sub-application page on terminal 104. Upon detecting an event requesting acquisition of a sub-application page, which is a page displayed in a sub-application, terminal 104 acquires the page code of the sub-application page from server 106, parses the page code to acquire a page parsing result, traverses the code set in the page parsing result to create a page node tree corresponding to the sub-application page, which is a tree structure generated based on the page nodes of the sub-application page, creates a first instance object for converting the page node tree, establishes a binding relationship between the first instance object and the sub-application page, and, if the binding relationship is established, converts the page node tree into an interface call format using the first instance object, acquires interface call information corresponding to the page node tree, performs page drawing based on the interface call information, and generates the sub-application page.
[0018] The terminal 104 may be, but is not limited to, a desktop computer, a notebook computer, a smartphone, a tablet computer, an Internet of Things device, and a portable wearable device. The Internet of Things device may be a smart speaker, a smart TV, a smart air conditioner, a smart car device, etc. The portable wearable device may be a smart watch, a smart band, a head-mounted device, etc. The server 106 may be implemented using an independent server or a server cluster including multiple servers.
[0019] In one embodiment, a sub-application page processing method is provided, as shown in Figure 2. The method may be performed independently by a terminal or a server, or may be performed jointly by a terminal and a server. In this embodiment of the present application, the method is described using an example in which the method is applied to a terminal. The method includes the following operations:
[0020] Operation 202: When an event is detected that requires retrieving a sub-application page, which is a page displayed in a sub-application, the page code of the sub-application page is retrieved.
[0021] A sub-application is an application that can be executed in an environment provided by a parent application. A parent application is an application that includes a sub-application and provides an environment for the sub-application to be executed. A parent application is a native application. A native application is an application that can be executed directly on an operating system. A sub-application is a lightweight application that can be executed based on a parent application without downloading. Sub-applications can include sub-applications for various scenarios, such as an instant messaging sub-application, a mobile payment sub-application, or a game sub-application. If an application meets the characteristics of being a lightweight application that can be executed based on a parent application without downloading or installation, the application can be called a sub-application.
[0022] The event requesting acquisition of a sub-application page is configured to acquire the sub-application page. For example, the event requesting acquisition of a sub-application page may specifically be an event requesting acquisition of an initial page of the sub-application when the sub-application is accessed. As another example, the event requesting acquisition of a sub-application page may specifically be an event requesting acquisition of another page when the initial page is displayed in the sub-application, i.e., an event switching from the initial page to displaying another page.
[0023] The page code is code that conforms to the page code structure of the sub-application and represents a sub-application page. The page code structure of the sub-application is the structure of the page code supported by the sub-application. Specifically, only page code that conforms to the page code structure of the sub-application is supported by the sub-application, and the page can be executed within the sub-application. For example, the page code may be code generated based on a markup language supported by the sub-application. For example, the markup language supported by the sub-application may be WeiXin Markup Language (WXML). WXML is a set of markup languages designed for mini-program frameworks. The page structure can be constructed by combining basic components and an event system.
[0024] Specifically, when an event requesting retrieval of a sub-application page is detected, the terminal retrieves the page code of the sub-application page. In a specific application, when a sub-application is opened, an event requesting retrieval of a sub-application page can be detected. If a sub-application code corresponding to the sub-application is stored in the terminal, the page code of the sub-application page can be retrieved directly from the sub-application code. If a sub-application code corresponding to the sub-application is not stored in the terminal, the sub-application code needs to be retrieved from a server that stores the sub-application code corresponding to the sub-application, and then the page code of the sub-application page is retrieved from the sub-application code.
[0025] In a particular application, when a sub-application corresponding to a sub-application page is opened for the first time, the sub-application code corresponding to the sub-application may not be stored in the terminal, and the sub-application code needs to be retrieved from a server storing the sub-application code corresponding to the sub-application based on the application identifier of the sub-application.When a sub-application corresponding to a sub-application page is opened for a non-first time, the sub-application code corresponding to the sub-application is stored in the terminal.
[0026] In a specific application, the sub-application code includes page codes of all sub-application pages that can be displayed in the sub-application, and the page code of each sub-application page has a corresponding page identifier. The terminal can query the sub-application code based on the page identifier of the sub-application page that needs to be opened, and obtain the page code of the sub-application page.
[0027] Operation 204: Parse the page code to obtain a page parsing result, and traverse the code set in the page parsing result to create a page node tree corresponding to the sub-application page, which is a tree structure generated based on the page nodes of the sub-application page.
[0028] The page parsing result is the result obtained by parsing the page code. The page code is typically generated based on a markup language supported by the sub-application. However, the runtime environment of the sub-application rendering layer on the device typically cannot directly interpret the page code. Therefore, the page code must be parsed to obtain the page parsing result. For example, the page parsing result may specifically be code obtained by parsing the page code and directly interpretable by the runtime environment of the sub-application rendering layer. For example, the page parsing result may specifically be JavaScript code obtained by parsing the page code. JavaScript is a lightweight interpreted or JIT-compiled programming language with first-class functions. While JavaScript is well known as a scripting language for developing web pages, it is also used in many environments other than browsers. JavaScript is a prototype-based programming language and a multi-paradigm dynamic scripting language that supports object-oriented, imperative, declarative, and functional programming paradigms.
[0029] A page node tree is a tree structure generated based on the page nodes of a sub-application page, and is obtained by combining all the page nodes of the sub-application page. Specifically, the page node tree is obtained by splicing the page nodes of the sub-application page, and contains information such as the names, attribute values, and event callback functions of all the page nodes of the sub-application page. A page node is a node that appears on a sub-application page. All page content of a sub-application page can be represented by a page node. A page node is the most basic component of a sub-application page, and each part of a sub-application page is sometimes called a node.
[0030] Specifically, the terminal uses a pre-configured parsing tool to parse the page code to obtain a page parsing result, and then traverses the code set in the page parsing result to create a page node tree corresponding to the sub-application page. The pre-configured parsing tool can be configured based on an actual application scenario. This embodiment is not limited thereto. For example, the pre-configured parsing tool may be a pre-configured markup language compiler. The markup language compiler can compile the page code and output a compilation result, i.e., a page parsing result. In a specific application, the markup language may be WXML. In this case, the pre-configured markup language compiler may be a binary WXML compiler. The WXML compiler receives a WXML code file, parses the WXML code file, and outputs JavaScript code.
[0031] Operation 206: Create a first instance object for converting the page node tree, and establish a binding relationship between the first instance object and the sub-application page.
[0032] In object-oriented programming, a "class" is called an "instance" after it is instantiated. A "class" is static and does not occupy process memory, while an "instance" has dynamic memory. An instance represents a collection of several programs. In this embodiment, the first instance object is a custom instance object for converting a page node tree and includes a collection of programs for converting a page node tree. Establishing a binding relationship means binding the first instance object to a sub-application page so that the first instance object can be used to generate the sub-application page.
[0033] Specifically, since the first instance object is also obtained by instantiation, the terminal first creates a first interface class for converting the page node tree, and then creates a first instance object for converting the page node tree based on the first interface class. The first interface class includes a logical method for converting the page node tree. When the first instance object is obtained by instantiation and a binding relationship between the first instance object and the sub-application page is established, the logical method for converting the page node tree can be used to convert the page node tree into an interface call format.
[0034] Establishing a binding relationship between the first instance object and the sub-application page means binding the first instance object to the sub-application page during the initialization of the sub-application page. In a specific application, a root component instance corresponding to the sub-application page is created during the initialization of the sub-application page. Therefore, when the root component instance is created, if the root component instance is bound to the first instance object, the binding relationship between the first instance object and the sub-application page can be established.
[0035] Operation 208: If a binding relationship is established, use the first instance object to convert the page node tree into an interface call format and obtain interface call information corresponding to the page node tree.
[0036] The interface invocation information is a set of invocation information capable of implementing a page node tree. For example, as shown in Figure 3, if the substructure of the page node tree includes a view node and a text node whose content is text, as shown in (a) of Figure 3, and the text node is a child node of the view node, the interface invocation information corresponding to the substructure may be shown in (b) of Figure 3. The interface invocation information includes invocation information for creating a view node, invocation information for creating a text node whose content is text, and invocation information for setting the text node as a child node of the view node.
[0037] Specifically, when the binding relationship is established, a logical method for converting a page node tree in the first instance object can be used to convert the page node tree into an interface call format and obtain interface call information corresponding to the page node tree. In a specific application, the first instance object provides first interface configuration information for converting the page node tree. The first interface configuration information includes a callable interface provided by the first instance object and a description of the interface. Using the first instance object to convert the page node tree into an interface call format and obtain the interface call information corresponding to the page node tree involves determining an interface for implementing the page node tree from the callable interface provided by the first instance object based on the first interface configuration information, and using the interface to implement the page node tree as the interface call information corresponding to the page node tree.
[0038] Operation 210: Execute page drawing based on the interface call information to generate a sub-application page.
[0039] Specifically, the terminal can execute corresponding drawing commands based on the interface calling information to perform page drawing and generate a sub-application page. In a specific application, the interface calling information is obtained by converting the page node tree into an interface calling format, and then an interface call can be made based on the interface calling information to execute corresponding drawing commands to perform page drawing. The sub-application page can be generated after the page drawing is completed.
[0040] In the above-described sub-application page processing method, when an event requesting retrieval of a sub-application page is detected, the retrieved page code of the sub-application page is parsed to obtain a page parsing result, and the code set in the page parsing result is traversed to create a page node tree representing the page structure of the sub-application page so that the sub-application page can be represented in the form of a page node tree. A first instance object for converting the page node tree is created, and a binding relationship between the first instance object and the sub-application page is established so that the created first instance object can be used during generation of the sub-application page. In this way, the first instance object can directly convert the page node tree into an interface call format and obtain interface call information corresponding to the page node tree. Page drawing is performed based on the interface call information to generate the sub-application page. In the entire process, the page node tree is directly converted into the interface call format without using a DOM interface as an intermediate bridge for page rendering, thereby improving page rendering speed.
[0041] In one embodiment, creating a first instance object for transforming a page node tree and establishing a binding relationship between the first instance object and the sub-application page includes: Obtaining a first interface class for transforming a page node tree, the first interface class including a logical method for transforming the page node tree based on a protocol mode of a preconfigured interface protocol; creating a first instance object for converting a page node tree based on a first interface class; creating a root component instance corresponding to the sub-application page using the first instance object as a creation parameter and establishing a binding relationship between the first instance object and the sub-application page.
[0042] The interface protocol is an intermediate bridge linking the sub-application component organization framework and page rendering and is the basis for converting the page node tree into an interface call format. The interface protocol provides at least one protocol mode for use, defining logical methods for converting the page node tree. The protocol mode is the mode provided by the interface protocol for converting the page node tree and can be configured based on actual application scenarios. Each protocol mode has a corresponding interface and provides different protocol content. Specifically, various logical methods for converting the page node tree are defined in the protocol mode. For example, the protocol mode may specifically be a composite mode. The composite mode is a preferred mode, is easy to use, and indicates that the protocol works with both shadow trees and page node trees. As another example, the protocol mode may be a shadow mode. The shadow mode is a mode based on a shadow tree and has good performance. However, the protocol is complex, and this mode indicates that the protocol only works with a shadow tree. In the shadow mode, when converting a page node tree into an interface call format, typically, the shadow tree needs to be converted into the interface call format first, and then the conversion from the shadow tree to the page node tree is performed. As yet another example, the protocol mode may specifically be DOM-like (similar to the DOM interface mode), which is applicable to the DOM protocol and is typically configured to accommodate the DOM interface.
[0043] The first interface class is an interface corresponding to the protocol mode and contains logical methods for transforming the page node tree. The root component instance is an instance of the page root component. Each sub-application page has a corresponding component, which is called the page root component of the sub-application page. During the initialization of the sub-application page, an instance of the page root component, i.e., the root component instance, needs to be created.
[0044] Specifically, the terminal obtains, based on a protocol mode of the pre-configured interface protocol, a first interface class corresponding to the protocol mode and configured to convert a page node tree, the first interface class including a logical method for converting the page node tree. After the first interface class is created, the terminal implements the first interface class, then creates a first instance object for converting the page node tree based on the first interface class, and finally creates a root component instance corresponding to the sub-application page using the first instance object as a creation parameter, and establishes a binding relationship between the first instance object and the sub-application page.
[0045] In a specific application, different protocol modes correspond to different first interface classes, and a first interface class corresponding to the protocol mode and configured to transform the page node tree can be obtained based on the protocol mode. A logic method included in the first interface class and configured to transform the page node tree is pre-configured. In a specific application, the first interface class may specifically be a TypeScript interface. TypeScript is an open-source programming language based on JavaScript with added static type definitions and is a superset of JavaScript types. TypeScript supports the ECMAScript 6 standard (a standard for the JavaScript language) and can be compiled to pure JavaScript. For example, the correspondence between protocol modes and TypeScript interfaces is as shown in Table 1. TIFF2025535022000002.tif41170
[0046] In a specific application, the terminal creates a root component instance by passing the first instance object as a creation parameter to a function for creating a root component instance. In a specific application, if the function for creating a root component instance is in the form of glassEasel.Component.createWithContext() and the first instance object is represented by myCustomBackend, the root component instance can be created using the code segment "const rootComponent = glassEasel.Component.createWithContext(X, myCustomBackend)". const rootComponent indicates the root component instance, and X is another parameter that needs to be passed when creating the root component instance. For example, X may specifically include a body tag. The body tag is a tag used in web pages and represents the main body of a web page, specifically the content visible from an object viewing the web page, and can include various types of content, such as text, images, audio, and video.
[0047] In this embodiment, a first interface class for converting the page node tree is obtained based on a protocol mode of a pre-configured interface protocol to obtain a logical method for converting the page node tree. In this manner, a first instance object for converting the page node tree can be created based on the first interface class, and a root component instance corresponding to the sub-application page can be created using the first instance object as a creation parameter, thereby establishing a binding relationship between the first instance object and the sub-application page and using the logical method for converting the page node tree.
[0048] In one embodiment, creating a first instance object for converting a page node tree based on a first interface class includes: creating a first implementation class corresponding to the first interface class using a first keyword for class-based interface implementation, the first implementation class being configured to implement a logical method for transforming a page node tree in the first interface class; and instantiating the first implementation class using a second keyword for creating an instance object based on the class, and creating a first instance object corresponding to the first implementation class.
[0049] Implementing an interface based on a class means creating an implementation class based on the interface class. A logical method is defined in the interface class, and an implementation class corresponding to the interface class is created, so that the logical methods defined in the corresponding interface class can be implemented using the implementation class; in other words, the corresponding interface class is implemented. The first keyword is a keyword used to implement an interface based on a class. For example, the first keyword may specifically be "implements." Creating an instance object based on a class means instantiating the implementation class to obtain an instance object corresponding to the implementation class. The implementation class does not occupy process memory and is static. Therefore, the implementation class needs to be further instantiated to use the logical methods defined in the interface class implemented by the implementation class. The second keyword is a keyword used to create a corresponding instance object based on the class. For example, the second keyword may specifically be "new." The first implementation class is a class for implementing the first interface class. The first instance object is an instance object obtained by instantiating the first implementation class.
[0050] Specifically, the first interface class includes a logical method for converting a page node tree, but does not include a method body. Therefore, the logical method for converting a page node tree in the first interface class can only be implemented using a specific class. In this embodiment, the first interface class is implemented by creating a first implementation class corresponding to the first interface class. If the first interface class includes a logical method for converting a page node tree, the first implementation class is configured to implement the logical method for converting a page node tree. After the first implementation class is created, the first implementation class does not occupy process memory and is static. Therefore, the terminal needs to further instantiate the first implementation class to use the logical method for converting a page node tree. In this case, the terminal can create a first instance object corresponding to the first implementation class using a second keyword for creating an instance object.
[0051] In a specific application, assuming the first keyword is "implements" and the second keyword is "new", the process of creating the first instance object can be expressed as follows: The first implementation class implements the first interface class, and the first instance object = new FirstImplementationClass(). In a specific application, assuming the first interface class is glassEasel.composedBackend.Context, the first implementation class is class MyCustomBackend, and the first instance object is const myCustomBackend, the process of creating the first instance object can be expressed as follows: class MyCustomBackend implements glassEasel.composedBackend.Context{ / / Logical method for transforming the page node tree }; const myCustomBackend = new MyCustomBackend ().
[0052] In a specific application, a process of creating a first instance object for converting a page node tree based on a first interface class is shown in Figure 4. The terminal uses a first keyword for class-based interface implementation to create a first implementation class corresponding to the first interface class, and after the first implementation class is created, uses a second keyword for instance object creation to create a first instance object corresponding to the first implementation class.
[0053] In this embodiment, a first implementation class corresponding to the first interface class can be created using a first keyword for class-based interface implementation to implement the first interface class, and a second keyword for instance object creation can be used to create a first instance object corresponding to the first implementation class, and the first implementation class can be instantiated to use a logical method for transforming the page node tree.
[0054] In one embodiment, using the first instance object to convert the page node tree into an interface call format and obtain interface call information corresponding to the page node tree includes: Starting from the root node of the page node tree, sequentially traverse the page nodes in the page node tree according to the first interface configuration information provided by the first instance object, respectively determine first call information corresponding to each page node, and obtain second call information corresponding to the page configuration information of the page node tree; Obtaining interface invocation information corresponding to the page node tree based on the first invocation information and the second invocation information.
[0055] The first call information is call information for implementing a page node, where the page node is a node that appears on the sub-application page. The second call information is call information for implementing page configuration information. The page configuration information is information related to configuring and generating the sub-application page. For example, the page configuration information may be information related to the display area of the sub-application page, such as the width, height, and pixel ratio of the display area. As another example, the page configuration information may be the theme of the sub-application page. For example, the theme of the sub-application page may be "light." As another example, the theme of the sub-application page may be "dark." As yet another example, the page configuration information may be the style sheet of the sub-application page. As yet another example, the page configuration information may be the focus on the sub-application page. The focus may be a cursor or a blinking line on the sub-application page. For example, the focus may be a small blinking vertical line on the sub-application page.
[0056] Specifically, the first interface configuration information includes a plurality of invokable interfaces provided by the first instance object, and the plurality of invokable interfaces includes interfaces corresponding to various page nodes, including interfaces corresponding to the page configuration information. Therefore, when converting the page node tree into an interface invocation format, the terminal can start from the root node of the page node tree and sequentially traverse the page nodes in the page node tree based on the first interface configuration information provided by the first instance object, respectively determine first invocation information corresponding to each page node from the plurality of invokable interfaces, and obtain second invocation information corresponding to the page configuration information of the page node tree. The interface invocation information corresponding to the page node tree can be obtained by combining the first invocation information and the second invocation information.
[0057] In a specific application, in addition to interfaces corresponding to various page nodes and interfaces corresponding to page configuration information, the first interface configuration information may further include an interface for obtaining a protocol mode, an interface for destroying a first instance object, an interface for waiting for a callback upon completion of the next rendering, an interface for setting a global event callback function, and an interface for obtaining a node based on coordinates. For the interface for obtaining a protocol mode, the interface may be used to determine the operating mode. For the interface for destroying a first instance object, the interface may be used to destroy the first instance object. For the interface for waiting for a callback upon completion of the next rendering, if a new attribute is set during the callback, a Cascading Style Sheet (CSS) transition animation may be triggered. For the interface for setting a global event callback function, there may be only one corresponding callback function, which may indicate a bubbling state, no special operation, or disabling the default operation. For the interface for obtaining a node based on coordinates, the interface may be configured to obtain a node at a coordinate position based on the coordinates.
[0058] Corresponding to the interface for destroying the first instance object, there are also an interface for creating a first instance object and an interface for obtaining the first instance object. The first instance object can be created by calling the interface for creating a first instance object, and the created first instance object can be obtained through the interface for obtaining a first instance object. In a specific application, a terminal can create a first instance object by calling the interface for creating a first instance object, and when creating a root component instance, can further call the interface for obtaining a first instance object to obtain the created first instance object and establish a binding relationship between the first instance object and the sub-application page.
[0059] In a specific application, with respect to values such as the width, height, or pixel ratio of the display area of the sub-application page, the first interface configuration information includes a corresponding interface for obtaining the value such as the width, height, or pixel ratio of the display area, and the value is a return value of the corresponding interface. With respect to a theme of the sub-application page, the first interface configuration information provides an interface for obtaining a string representing the theme. The return value of the interface for obtaining a string representing the theme is the string representing the theme.
[0060] In a particular application, for a style sheet of a sub-application page, the first interface configuration information includes interfaces corresponding to registering a style sheet, inserting a style sheet entry, and disabling an inserted style sheet, respectively. In a particular application, for an interface corresponding to registering a style sheet, the interface can use a style sheet path and a CSS corresponding to the style sheet path as parameters. The CSS must be in an interpretable format. If the CSS includes reference logic such as an interface call, the content corresponding to the CSS path may also be registered by another style sheet registration call, and the registration time may be earlier or later than the current registration. For an interface for inserting a style sheet entry, the interface can use a style sheet path as a parameter. Specifically, the content of the interface comes from the specified style sheet path. In addition, the interface for inserting a style sheet entry further includes an optional style range identifier. The style range identifier is configured to return a new style sheet index. If the style range identifier is not a positive integer, the style range identifier is considered to be empty. If the style range identifier is empty, the style sheet is considered to be a globally valid style sheet.
[0061] In a specific application, for a focus on a sub-application page, the first interface configuration information includes corresponding interfaces for setting a page node on which the focus is located and for obtaining a page node on which the focus is located. If the node cannot be focused, that is, if the focus does not exist on the sub-application page, the focus needs to be removed.
[0062] In this embodiment, starting from the root node of the page node tree, the page nodes in the page node tree can be sequentially traversed based on the first interface configuration information provided by the first instance object, the first call information corresponding to each page node can be respectively determined, and the second call information corresponding to the page configuration information in the page node tree can be obtained. Then, the interface call information corresponding to the page node tree can be obtained by combining the first call information and the second call information.
[0063] In one embodiment, starting from a root node of the page node tree, sequentially traversing page nodes in the page node tree based on the first interface configuration information provided by the first instance object, and respectively determining first invocation information corresponding to each page node, includes: For each page node in the page node tree, determining first interface information matching a page node type of the page node from first interface configuration information provided by the first instance object, and determining first invocation information corresponding to the page node based on the first interface information.
[0064] The page node type is the type of page node that appears on the sub-application page, and includes normal nodes, text nodes, fragment nodes, component nodes, and virtual nodes. A text node is a node that holds only text and has no child nodes. A fragment node is a node that temporarily holds a node tree fragment and is configured to represent a node array to facilitate bulk insertion and removal of nodes. Component nodes and virtual nodes are nodes that exist only in shadow mode. A component node has its own shadow tree and can be either a virtual node or a non-virtual node. A normal node is a node other than a text node or a fragment node in composite mode. The first interface information is contained in the first interface configuration information and is interface information corresponding to the page node.
[0065] Specifically, the first interface configuration information includes a plurality of invokable interfaces provided by the first instance object, and the plurality of invokable interfaces includes interfaces matching various page nodes. For each page node in the page node tree, the terminal determines first interface information matching the page node type of the page node from the plurality of invokable interfaces included in the first interface configuration information provided by the first instance object, and determines first invocation information corresponding to the page node based on the first interface information. In a specific application, the terminal can convert the node configuration information of the page node into an interface invocation format based on the first interface information, and then obtain the first invocation information corresponding to the page node.
[0066] In a specific application, for a root node, the first interface configuration information includes a corresponding interface for obtaining the root node. In a shadow mode, the root node needs to be a component node. In a composite mode, the root node needs to be a normal node. For page nodes such as a normal node, a text node, and a fragment node, the first interface configuration information includes corresponding interfaces for creating various page nodes, respectively.
[0067] In this embodiment, the first interface information of the page node is determined from the first interface configuration information based on the page node type, and then the first call information of the page node is determined based on the first interface information.
[0068] In one embodiment, determining the first invocation information corresponding to the page node based on the first interface information includes: Obtaining a second instance object that provides second interface configuration information for transforming the page node tree based on the first interface information; Obtaining second interface information corresponding to the page node using second interface configuration information provided by the second instance object; and obtaining first invocation information corresponding to the page node based on the first interface information and the second interface information.
[0069] The second instance object is a custom instance object for converting the page node and includes a set of programs for converting the page node. The second interface configuration information includes a callable interface provided by the second instance object and a description of the interface. The second interface information is included in the second interface configuration information and is interface information corresponding to the page node.
[0070] Specifically, when a page node needs to be converted into an interface call format, the terminal obtains a second instance object based on the first interface information, and the second instance object provides second interface configuration information for converting the page node tree. After the second instance object is obtained, the second interface configuration information provided by the second instance object can be used to obtain second interface information corresponding to the page node. Then, the first interface information and the second interface information can be combined to obtain first call information corresponding to the page node. The created second instance object is the return value of the first interface information. Therefore, the terminal can directly obtain the second instance object based on the first interface information.
[0071] In a specific application, the second interface configuration information includes a callable interface provided by the second instance object and a description of the interface. Obtaining second interface information corresponding to the page node using the second interface configuration information provided by the second instance object is to determine an interface for implementing the page node from the callable interface provided by the second instance object based on the second interface configuration information, and convert the page node into an interface call format.
[0072] In this embodiment, based on obtaining a second instance object based on the first interface information, the second interface configuration information provided by the second instance object is used to obtain second interface information corresponding to a page node, and the first interface information and the second interface information can be combined to obtain first call information corresponding to the page node.
[0073] In one embodiment, the sub-application page processing method includes: creating a second interface class for transforming the page node using the first instance object, the second interface class including a logical method for transforming the page node; creating a second implementation class corresponding to the second interface class using the first keyword for class-based interface implementation, the second implementation class being configured to implement a logical method for transforming a page node in the second interface class; and instantiating a second implementation class using a second keyword for creating an instance object based on the class, and creating a second instance object corresponding to the second implementation class.
[0074] Specifically, before determining the first interface information of the page node, the terminal needs to first create a second instance object using the first instance object. When creating the second instance object using the first instance object, the terminal can first create a second interface class for converting the page node, then use a first keyword for class-based interface implementation to create a second implementation class corresponding to the second interface class, implement a logic method for converting the page node in the second interface class, and finally use a second keyword for class-based instance object creation to instantiate the second implementation class and create a second instance object corresponding to the second implementation class.
[0075] Although the second interface class includes a logical method for converting page nodes, the second interface class does not include a method body. Therefore, the logical method for converting page nodes in the second interface class can only be implemented using a specific class. In this embodiment, the second interface class is implemented by creating a second implementation class corresponding to the second interface class. Specifically, the second implementation class is configured to implement the logical method for converting page nodes. After the second implementation class is created, the second implementation class does not occupy process memory and is static. Therefore, the terminal only needs to instantiate the second implementation class to use the logical method for converting page nodes. In this case, the terminal can create a second instance object corresponding to the second implementation class using a second keyword for creating an instance object based on a class.
[0076] In this embodiment, a second implementation class corresponding to the second interface class can be created using a second keyword for class-based interface implementation, and the second interface class can be implemented. Then, a second instance object corresponding to the second implementation class can be created using a second keyword for class-based instance object creation, and the second implementation class can be instantiated and a logic method for converting the page node can be used. In one embodiment, obtaining second interface information corresponding to the page node using second interface configuration information provided by the second instance object includes: and obtaining, based on the node configuration information of the page node, second interface information corresponding to the page node from second interface configuration information provided by the second instance object.
[0077] The node configuration information is relevant information for configuring and generating a page node. For example, the node configuration information may specifically be node attribute information such as a node identifier, a range identifier, a node style, a node pattern, text content, a bounding rectangle area of a node, and an internal scroll position of a node. As another example, the node configuration information may specifically be an association relationship between a node and another node in a page node tree. As yet another example, the node configuration information may specifically be node environment information, which is configured to indicate whether a node is a component node.
[0078] Specifically, the second interface configuration information includes a plurality of callable interfaces provided by the second instance object, and the plurality of callable interfaces includes an interface corresponding to the node configuration information. Therefore, the terminal can obtain second interface information corresponding to the page node from the plurality of callable interfaces based on the second interface configuration information provided by the second instance object.
[0079] In a specific application, in addition to the interface corresponding to the node configuration information, the second interface configuration information further includes an interface for releasing the node and an interface for indicating that the node relationship information has been created. The interface for releasing the node may be configured to release the node. The interface for indicating that the node relationship information has been created is configured to indicate that the node relationship information has been created and to set a value associated with the node. For nodes other than text nodes, the interface for indicating that the node relationship information has been created is called once to indicate that the node relationship information has been created and that further nodes may be created.
[0080] In a specific application, for node attribute information such as a node identifier, a range identifier, a node style, a node pattern, text content, a bounding rectangle area of a node, and an internal scroll position of a node, the second interface configuration information includes an interface corresponding to setting each node attribute. In addition, the second interface configuration information further provides other interfaces for setting other node attributes and removing other node attributes to facilitate setting the node attributes.
[0081] In a specific application, the interface corresponding to the setting of each node attribute includes an interface for setting the node as a slot node and an interface for setting the target slot of the node. The slot node is configured to hold child nodes that are provided when a component is referenced. Furthermore, a node may be set as a slot inheritance node through the interface for setting the target slot of the node. In a slot inheritance node, the child nodes of the slot inheritance node are not considered child nodes in the page node tree, but are considered sibling nodes following the slot inheritance node. In this way, these child nodes have different target slots. A node is set as a slot inheritance node only when it is in the initialization phase and has no child nodes. After a node is set as a slot inheritance node, it cannot be set as a non-slot inheritance node.
[0082] In certain applications, in the interface for setting the range identifier of a node, the interface is called at most once for the same node. In other words, the range identifier of a node is set at most once. When this interface is used, if the passed parameter is not a positive integer, it is considered to be empty. When matching against a style rule, if a node selector other than a class (such as a tag name selector or ID selector) is used to match against a node, the range identifier of the style sheet must be empty or equal to the range identifier of the node. In shadow mode, the interface is called only for regular nodes and non-virtual component nodes. In composition mode, the interface is called only for regular nodes.
[0083] In certain applications, in the interface for setting node styles, in shadow mode the interface is called only for normal nodes and non-virtual component nodes, and in composition mode the interface is called only for normal nodes. In the interface for adding node style categories, if the style category identifier is not a non-negative integer, the style category identifier is considered to be empty. When matching against a style rule, if a style category is used to match against a node, the style sheet's scope identifier must be empty or equal to the style category identifier of the style category. In shadow mode, the interface is called only for normal nodes and non-virtual component nodes. In composition mode, the interface is called only for normal nodes.
[0084] In certain applications, both the name and the style category identifier must match in the interface to remove a specified style category. If the style category identifier is not a non-negative integer, the style category identifier is considered to be empty. In shadow mode, the interface is called only for regular nodes and non-virtual component nodes. In composition mode, the interface is called only for regular nodes.
[0085] In certain applications, interfaces for getting the bounding rectangle of a node may need to calculate the node's minimum bounding rectangle if the node is not a regular rectangle (for example, if the node is inline text or a rotated rectangle). If the node has no layout information, an all-0 value is returned. Interfaces for getting the internal scroll position of a node may return a position value of 0 and the node's size value if the node is not scrollable.
[0086] In a specific application, for an association relationship between a node and another node in the page node tree, the second interface configuration information includes an interface corresponding to each association relationship setting, for example, the association relationship may specifically be adding a child node, removing a child node, inserting a child node, deleting a node, adding multiple nodes, or deleting and inserting a node.
[0087] In certain applications, the interface for removing a child node may allow the removed child node to be reused at a later time. If a node index number is provided when a child node is removed, the node index number must be equal to the sequence number of the child node in the child node list. If the node index number is not a non-negative integer, the node index number is considered to have no value assigned.
[0088] In a specific application, the second interface configuration information for an interface for inserting a child node provides multiple interfaces for selection, each with different behavior based on different parameters. Specifically, in an interface that takes a previous child node identifier and a node index number as parameters, if neither the previous child node identifier nor the node index number is provided, the child node is equivalently added. If the previous child node identifier or the node index number is provided, the child node is equivalently inserted before the child node corresponding to the previous child node identifier or the child node corresponding to the node index number. If both the previous child node identifier and the node index number are provided, the node index number must be equal to the sequence number of the child node corresponding to the previous child node identifier in the child node list. If the node index number is not a non-negative integer, the node index number is considered to be unassigned, ensuring that the inserted child node does not have a parent node.
[0089] In an interface that takes the next child node identifier and node index number as parameters, if neither the next child node identifier nor the node index number is provided, a child node is added equivalently; if the next child node identifier or node index number is provided, the child node corresponding to the next child node identifier or the child node corresponding to the node index number is replaced; if both the next child node identifier and node index number are provided, the node index number must be equal to the sequence number of the node corresponding to the next child node identifier in the child node list; if the node index number is not a non-negative integer, the node index number is considered to be unassigned, and it can be guaranteed that the inserted child node does not have a parent node.
[0090] In a specific application, when a node identifier and a node number are given in an interface for deleting a node, nodes corresponding to the node number starting from the node identifier are deleted. When an interface for adding multiple nodes is used, all nodes included in the segment node used as a parameter can be added. The segment node is cleared after being added, but can be reused. When an interface for deleting and inserting a node is used, when a node identifier and a node number are given, nodes corresponding to the node number starting from the node identifier are deleted, and all nodes included in the segment node used as a parameter are added.
[0091] In this embodiment, based on the node configuration information of the page node, the second interface information corresponding to the page node can be obtained from the second interface configuration information provided by the second instance object to implement the interface call conversion of the page node.
[0092] In one embodiment, obtaining first invocation information corresponding to the page node based on the first interface information and the second interface information includes: If the page node is a component node, obtaining a third instance object that is created in advance based on the second interface information, the third instance object being an instance object for converting the component node; Using the third instance object, obtain third interface information corresponding to the component node; and obtaining first invocation information corresponding to the component node based on the first interface information, the second interface information, and the third interface information corresponding to the component node.
[0093] A component node is a node of a component type. Based on the concept of components, a sub-application page can be divided into reusable modules, and each module is a component. A sub-application page can be obtained by combining several components, and a complex component can also be obtained by combining several simple components. In this embodiment, a component node mainly appears in shadow mode and has its own component node tree. A third instance object is a pre-created instance for converting a component node and includes a set of programs for converting the component node. The third interface information is contained in the interface configuration information provided by the third instance object and is interface information corresponding to the component node.
[0094] Specifically, if the page node is a component node, the terminal obtains a pre-created third instance object based on the interface information for obtaining node environment information in the second interface information, obtains third interface information corresponding to the component node using the shadow tree environment instance, and combines the first interface information, the second interface information, and the third interface information corresponding to the component node to obtain first call information corresponding to the component node. The generated third instance object is a return value of the interface information for obtaining node environment information. Therefore, if the page node is a component node, the terminal can obtain the generated third instance object based on the interface information for obtaining node environment information.
[0095] In certain applications, the third instance object may need to be created before it is used. To create the third instance object, a component interface class including a logical method for converting a component node may be created first, a component implementation class may be created using a first keyword for class-based interface implementation, and a third instance object may be created by instantiating the component implementation class using a second keyword for class-based instance object creation.
[0096] In this embodiment, if the page node is a component node, a pre-created third instance object can be obtained based on the second interface information, so that the third interface information corresponding to the component node can be obtained by using the third instance object, and the first interface information, the second interface information, and the third interface information corresponding to the component node can be combined to obtain the first call information corresponding to the component node.
[0097] In one embodiment, using the third instance object to obtain the third interface information corresponding to the component node includes: Starting from the root node of the component node, sequentially traverse child nodes in the component node according to third interface configuration information provided by the third instance object, and respectively determine child node invocation information corresponding to each child node; and obtaining third interface information corresponding to the component node based on the child node invocation information corresponding to each child node.
[0098] The third interface configuration information includes a callable interface provided by the third instance object and a description of the interface. The third interface information is interface information corresponding to a component node in the third interface configuration information. The child node invocation information is invocation information for implementing the child node.
[0099] Specifically, the third interface configuration information includes a plurality of invokable interfaces provided by the third instance object, and the plurality of invokable interfaces includes interfaces corresponding to child nodes in the component node. Therefore, when converting the component node into an interface invocation format, the terminal can start from the root node of the component node tree, sequentially traverse the child nodes in the component node based on the third interface configuration information provided by the third instance object, respectively determine child node invocation information corresponding to each child node from the plurality of invokable interfaces, and combine the child node invocation information corresponding to all child nodes to obtain the third interface information corresponding to the component node.
[0100] In this embodiment, starting from the root node of the component node, the child nodes in the component node can be sequentially traversed based on the third interface configuration information provided by the third instance object to respectively determine the child node call information corresponding to each child node, and then the third interface information corresponding to the component node can be obtained by combining the child node call information corresponding to all the child nodes.
[0101] In one embodiment, starting from the root node of the component node, and sequentially traversing child nodes in the component node according to the third interface configuration information provided by the third instance object, respectively determining child node invocation information corresponding to each child node, includes: For each child node in the component node, determine child node interface information that matches a child node type of the child node from third interface configuration information provided by the third instance object; Obtaining a second instance object based on the child node interface information, and using the second instance object to obtain child node invocation information corresponding to the child node.
[0102] Child node types are the types of child nodes that may appear in a component node, including normal nodes, text nodes, component nodes, external component nodes, virtual nodes, etc. External component nodes are pre-built node trees that can be directly spliced with another part.
[0103] Specifically, the third interface configuration information includes a plurality of invokable interfaces provided by the third instance object, and the plurality of invokable interfaces includes interfaces matching various child nodes. For each child node in the component node, the terminal determines child node interface information matching the child node type of the child node from the plurality of invokable interfaces included in the third interface configuration information provided by the third instance object, obtains a second instance object based on the child node interface information, and uses the second instance object to obtain child node invocation information corresponding to the child node. The created second instance object is a return value of the child node interface information. Therefore, the terminal can obtain the created second instance object based on the child node interface information.
[0104] In a specific application, the second instance object provides second interface configuration information for converting the child node, where the second interface configuration information includes a callable interface provided by the second instance object and a description of the interface. Using the second instance object to obtain child node call information corresponding to the child node is to determine an interface for implementing the child node from the callable interface provided by the second instance object based on the second interface configuration information and convert the child node into an interface call format. The child node is also a page node. Therefore, in this embodiment, the manner in which the child node call information corresponding to the child node is obtained using the node instance is similar to the manner in which the second interface information corresponding to the page node is obtained using the second instance object. Details of this embodiment will not be described again here.
[0105] In this embodiment, the child node interface information of the child node may be determined from the third interface configuration information based on the child node type, a second instance object may be obtained based on the child node interface information, and the second instance object may be used to obtain the child node invocation information corresponding to the child node.
[0106] In one embodiment, using the second instance object to obtain child node invocation information corresponding to the child node includes: and obtaining, based on the child node configuration information of the child node, child node invocation information corresponding to the child node from second interface configuration information provided by the second instance object.
[0107] The child node configuration information is related information for configuring and generating a child node. For example, the child node configuration information may specifically be child node attribute information such as a node identifier, a range identifier, a node style, a node pattern, text content, a bounding rectangle area of a node, and an internal scroll position of a node. As another example, the child node configuration information may specifically be an association relationship between a child node and another child node within a component node. As yet another example, the child node configuration information may specifically be child node environment information, and the child node environment information is configured to indicate whether the child node is a component node.
[0108] Specifically, the second interface configuration information includes a plurality of callable interfaces provided by the second instance object, and the plurality of callable interfaces includes an interface corresponding to the child node configuration information. Therefore, the terminal can obtain child node call information corresponding to the child node from the plurality of callable interfaces based on the second interface configuration information provided by the second instance object. The child node is also a page node. Therefore, in this embodiment, the manner in which the child node call information corresponding to the child node is obtained based on the child node configuration information is similar to the manner in which the second interface information corresponding to the page node is obtained based on the node configuration information. Details of this embodiment will not be described again here.
[0109] In this embodiment, the child node invocation information corresponding to the child node can be obtained based on the child node configuration information of the child node.
[0110] In one embodiment, parsing the page code to obtain a page parsing result comprises: The method includes determining a markup language used to write the page code, and compiling the page code using a markup language compiler corresponding to the markup language to obtain a page parsing result.
[0111] Specifically, a markup language compiler is a set of programs for compiling code written in a markup language. Code written in a markup language is compiled so that the code written in the markup language can be converted into code in another programming language. Therefore, when parsing page code, the terminal first determines the markup language used to write the page code, and then compiles the page code using a markup language compiler corresponding to the markup language to obtain a page parsing result, specifically, code that can be directly interpreted by a runtime environment of a sub-application rendering layer on the terminal.
[0112] In this embodiment, the markup language used to write the page code is first determined, so that the page code can be compiled using a markup language compiler corresponding to the markup language to obtain the page parsing result.
[0113] In one embodiment, the sub-application page processing method in this application is described using a schematic flow chart, as shown in Figure 5. The sub-application page processing method specifically includes the following operations:
[0114] When a sub-application page is opened (specifically, when an event requesting retrieval of the sub-application page is detected), the page code of the sub-application page is retrieved (in other words, the page code of the sub-application page is retrieved). The page code is parsed to obtain a page parsing result, and a code set in the page parsing result is traversed to create a page node tree corresponding to the sub-application page. A first instance object for converting the page node tree is created, and a binding relationship between the first instance object and the sub-application page is established. When the binding relationship is established, the first instance object is used to convert the page node tree into an interface call format, and interface call information corresponding to the page node tree is obtained. Based on the interface call information, underlying drawing and display are performed; that is, page drawing is performed based on the interface call information, and the sub-application page is generated.
[0115] A first instance object is created based on a pre-configured interface protocol. The interface protocol in this application is an intermediate bridge that links the sub-application component organization framework and the page rendering, and is the basis for converting the page node tree into an interface call format. The page node tree can be converted into the underlying interface calls through the interface protocol and passed to the underlying rendering for interface display.
[0116] To better explain the sub-application page processing method in this application, we will first describe the process of a developer writing code to draw and display a sub-application page. As shown in FIG. 6, this process specifically includes the following operations: a developer writes page code for the sub-application page. When the sub-application page is opened, a sub-application component organization framework on the terminal retrieves the page code. After the page code is obtained, the page code is parsed to obtain a page parsing result. The code set in the page parsing result is traversed to create a page node tree corresponding to the sub-application page, which is a tree structure generated based on the page nodes of the sub-application page. A first instance object is created to convert the page node tree, and a binding relationship between the first instance object and the sub-application page is established. After the binding relationship is established, the first instance object is used to convert the page node tree into an interface call format, and interface call information corresponding to the page node tree is obtained. The interface call information is output to a graphics processing unit (GPU) in the terminal. The GPU performs underlying drawing and display based on the interface call information; in other words, it performs page drawing based on the interface call information and generates the sub-application page.
[0117] The sub-application component orchestration framework is embedded in the sub-application base library and provides basic support for sub-application components. All components within the sub-application, including built-in and custom components, are organized and managed by the sub-application component orchestration framework. For example, the sub-application component orchestration framework may be specifically GlassEasel, a general-purpose component-based interface framework.
[0118] In one embodiment, a first instance object for converting a page node tree is created, a binding relationship between the first instance object and the sub-application page is established, and when the binding relationship is established, the page node tree is converted into an interface call format using the first instance object, and interface call information corresponding to the page node tree is obtained. This can be understood as follows: the page node tree is converted into an interface call format using a custom backend. The custom backend may also be referred to as a rendering backend. The sub-application component organization framework may pass the page node tree generated by the sub-application component organization framework to a rendering backend. The rendering backend converts the received page node tree into an interface call format, obtains interface call information corresponding to the page node tree, and outputs the interface call information to the GPU of the terminal.
[0119] In one embodiment, in an example where the page code is WXML component code and the page parsing result is JavaScript code, the process from developer code writing to rendering and display can be shown in FIG. 7. The developer writes the WXML component code. When a sub-application page is opened, the sub-application component orchestration framework on the device retrieves the WXML component code. After obtaining the WXML component code, the page code is parsed to obtain the JavaScript code. The page node tree is converted into an interface call format through a custom backend based on the JavaScript code, and interface call information corresponding to the page node tree is obtained. The interface call information is output to the GPU in the device. The GPU performs the underlying rendering and display based on the interface call information; in other words, it performs page rendering based on the interface call information and generates the sub-application page.
[0120] Before the sub-application page processing method in this application was introduced, sub-application pages used the web DOM as a rendering backend. However, the web DOM needed to be provided by a browser or web view. Due to the heavy overhead of the web DOM and the excessive number of DOM interface components, the sub-application page rendering performance was not as good as that of native frameworks. In light of this, the inventors propose a sub-application page processing method in this application, which replaces the original web DOM rendering backend with the rendering backend in the sub-application page processing method. The page node tree is directly converted into an interface call format without using a DOM interface as an intermediate bridge for page rendering, thereby improving page rendering speed.
[0121] In one embodiment, the rendering backend of the present application has two main modes: shadow mode and composite mode. In shadow mode, the sub-application component orchestration framework operates only on the component node tree, and the rendering backend completes the conversion from the component node tree to the page node tree. In composite mode, the sub-application component orchestration framework operates on the component node tree and the page node tree. The interfaces required for these two modes are slightly different. The rendering backend needs to provide an interface to the sub-application component orchestration framework so that the sub-application component orchestration framework can correctly output the information required by the rendering backend.
[0122] The interface protocol of the rendering backend may be a protocol based on TypeScript, and the corresponding interface format may be an object-oriented format. For example, the interface provided by the rendering backend may be in the format of Context#mode:ContextMode or Context#registerStyleSheetContent(path:string,content:any). The interfaces provided by the rendering backend are mainly classified into two categories. Among the interfaces, interfaces expressed in the format of Class#method(...) represent the interface method corresponding to a class, specifically Class.prototype.method(...). Interfaces marked as async are unified in the format of a callback function. Specifically, async Class#method(...):T is actually Class.prototype.method(...,(T)=>void).
[0123] The rendering backend of the present application mainly provides three types of instances: first instance objects, second instance objects, and third instance objects. Different types of instances provide different interfaces for the sub-application component orchestration framework to call. Regarding the first instance objects, each first instance object can display a node tree on the interface. Second instance objects can be created based on the first instance object. After the third instance object is created, it can be obtained through the second instance object. Specifically, the component node tree environment of a component can be obtained through the second instance object. For child nodes of the component node tree, the child nodes can also be converted into an interface call format using the second instance object. Therefore, the call relationship between the three types of instances provided by the rendering backend is as shown in Figure 8. The first instance object can call the second instance object, the second instance object can call the third instance object, and the third instance object can call the second instance object.
[0124] The inventors believe that the sub-application page processing method of the present application provides necessary backend interfaces, supports more functions while discarding unused functions, and supports both operations in the component node tree and adaptation to the DOM interface, thereby improving the sub-application page rendering speed compared to the rendering speed in the web DOM rendering backend. The unused functions are functions of the DOM interface that are not used in rendering the sub-application page.
[0125] In one embodiment, the sub-application page processing method in this application is described using a schematic flow chart, as shown in Figure 9. The sub-application page processing method specifically includes the following operations:
[0126] When detecting an event requesting to retrieve a sub-application page, the terminal retrieves a page code of the sub-application page, parses the page code to retrieve a page parsing result, traverses a code set in the page parsing result to create a page node tree corresponding to the sub-application page, retrieves a first interface class for transforming the page node tree based on a protocol mode of the preconfigured interface protocol, the first interface class including a logical method for transforming the page node tree, creates a first implementation class corresponding to the first interface class using a first keyword for class-based interface implementation, the first implementation class being configured to implement the logical method for transforming the page node tree in the first interface class, creates a first instance object corresponding to the first implementation class using a second keyword for class-based instance object creation, creates a root component instance corresponding to the sub-application page using the first instance object as a creation parameter, and establishes a binding relationship between the first instance object and the sub-application page.
[0127] If the binding relationship is established, a second instance object is created using the first instance object, and the second instance object provides second interface configuration information for converting the page node tree. For each page node in the page node tree, first interface information matching the page node type of the page node is determined from the first interface configuration information provided by the first instance object, and a second instance object is obtained based on the first interface information. Second interface information corresponding to the page node is obtained from the second interface configuration information provided by the second instance object based on the node configuration information of the page node. First invocation information corresponding to the page node is obtained based on the first interface information and the second interface information, and second invocation information corresponding to the page configuration information of the page node tree is obtained based on the first interface configuration information provided by the first instance object. Interface invocation information corresponding to the page node tree is obtained based on the first invocation information and the second invocation information. Page rendering is performed based on the interface invocation information, and a sub-application page is generated.
[0128] In a specific application, after a sub-application page is generated, if it is necessary to switch to display another sub-application page, the terminal obtains the page code of the other sub-application page and generates the other sub-application page according to the sub-application page processing method in the above embodiment.
[0129] In one embodiment, if the protocol mode of the preconfigured interface protocol is shadow mode, the page node may be a component node. When the page node is a component node, a process for obtaining first call information corresponding to the component node may be shown in FIG. 10 . The terminal obtains a pre-created third instance object based on the second interface information, and for each child node in the component node, determines child node interface information matching the child node type of the child node from the third interface configuration information provided by the third instance object. The terminal obtains a second instance object based on the child node interface information, obtains child node call information corresponding to the child node from the second interface configuration information provided by the second instance object based on the child node configuration information of the child node, obtains third interface information corresponding to the component node based on the child node call information corresponding to each child node, and obtains the first call information corresponding to the component node based on the first interface information, second interface information, and third interface information corresponding to the component node.
[0130] In the flowcharts of the foregoing embodiments, operations are shown sequentially as indicated by the arrows, but the operations are not necessarily performed sequentially in the order indicated by the arrows. Unless otherwise specified in this application, the order in which operations are performed is not strictly limited and may be performed in other orders. Furthermore, at least some of the operations in the flowcharts of the foregoing embodiments may include multiple operations or multiple steps. The operations or steps do not necessarily occur at the same moment, but may occur at different moments. The operations or steps do not necessarily occur sequentially, but may be interleaved with other operations or at least some operations or steps of other operations.
[0131] Based on the same inventive concept, the embodiments of the present application further provide a sub-application page processing device for implementing the aforementioned sub-application page processing method. The implementation solutions provided by the device for solving the problem are similar to the implementation solutions described in the aforementioned methods. Therefore, for specific limitations in the embodiments of one or more sub-application page processing devices provided below, please refer to the limitations regarding the sub-application page processing method in the preceding description. The details will not be described again here.
[0132] In one embodiment, as shown in FIG. 11, a sub-application page processing unit is provided that includes a code acquisition module 1102, a node tree generation module 1104, a page initialization module 1106, a node tree transformation module 1108, and a page rendering module 1110.
[0133] The code acquisition module 1102 is configured to acquire a page code of a sub-application page, which is a page displayed in the sub-application, upon detecting an event that requests retrieval of the sub-application page.
[0134] The node tree generation module 1104 is configured to parse the page code to obtain a page parsing result, traverse the code set in the page parsing result, and create a page node tree corresponding to the sub-application page, the page node tree being a tree structure generated based on the page nodes of the sub-application page.
[0135] The page initialization module 1106 is configured to create a first instance object for converting the page node tree, and establish a binding relationship between the first instance object and the sub-application page.
[0136] The node tree conversion module 1108 is configured to use the first instance object to convert the page node tree into an interface call format when a binding relationship is established, and obtain interface call information corresponding to the page node tree.
[0137] The page rendering module 1110 is configured to perform page rendering based on the interface calling information to generate a sub-application page.
[0138] In the above-mentioned sub-application page processing device, when an event requesting retrieval of a sub-application page is detected, the retrieved page code of the sub-application page is parsed to obtain a page parsing result, and the code set in the page parsing result is traversed to create a page node tree representing the page structure of the sub-application page so that the sub-application page can be represented in the form of a page node tree. A first instance object for converting the page node tree is created, and a binding relationship between the first instance object and the sub-application page is established so that the created first instance object can be used during generation of the sub-application page. In this way, the first instance object can be directly used to convert the page node tree into an interface call format and obtain interface call information corresponding to the page node tree. Page drawing is performed based on the interface call information to generate the sub-application page. In the entire process, the page node tree is directly converted into the interface call format without using a DOM interface as an intermediate bridge for page rendering, thereby improving page rendering speed.
[0139] In one embodiment, the page initialization module is further configured to: obtain a first interface class for transforming a page node tree, the first interface class including a logical method for transforming the page node tree, based on a protocol mode of the pre-configured interface protocol; create a first instance object for transforming the page node tree based on the first interface class; create a root component instance corresponding to the sub-application page using the first instance object as a creation parameter; and establish a binding relationship between the first instance object and the sub-application page.
[0140] In one embodiment, the page initialization module is further configured to: use a first keyword for class-based interface implementation to create a first implementation class corresponding to the first interface class, the first implementation class being configured to implement a logical method for transforming a page node tree in the first interface class; and use a second keyword for class-based instance object creation to instantiate the first implementation class to create a first instance object corresponding to the first implementation class.
[0141] In one embodiment, the node tree conversion module is further configured to: start from the root node of the page node tree, and sequentially traverse the page nodes in the page node tree based on the first interface configuration information provided by the first instance object, respectively determine first call information corresponding to each page node, obtain second call information corresponding to the page configuration information of the page node tree, and obtain interface call information corresponding to the page node tree based on the first call information and the second call information.
[0142] In one embodiment, the node tree conversion module is further configured to: determine, for each page node in the page node tree, first interface information matching a page node type of the page node from the first interface configuration information provided by the first instance object; and determine first invocation information corresponding to the page node based on the first interface information.
[0143] In one embodiment, the node tree transformation module is further configured to: obtain, based on the first interface information, a second instance object providing second interface configuration information for transforming the page node tree; obtain, using the second interface configuration information provided by the second instance object, second interface information corresponding to the page node; and obtain, based on the first interface information and the second interface information, first invocation information corresponding to the page node.
[0144] In one embodiment, the node tree transformation module is further configured to: use the first instance object to create a second interface class for transforming a page node, the second interface class including a logical method for transforming the page node; use the first keyword for class-based interface implementation to create a second implementation class corresponding to the second interface class, the second implementation class configured to implement the logical method for transforming the page node in the second interface class; and use the second keyword for class-based instance object creation to instantiate the second implementation class to create the second instance object corresponding to the second implementation class.
[0145] In one embodiment, the node tree conversion module is further configured to obtain, based on the node configuration information of the page node, second interface information corresponding to the page node from second interface configuration information provided by the second instance object.
[0146] In one embodiment, the node tree transformation module is further configured: if the page node is a component node, based on the second interface information, to obtain a pre-created third instance object, the third instance object being an instance object for transforming the component node; to obtain third interface information corresponding to the component node using the third instance object; and to obtain first invocation information corresponding to the component node based on the first interface information, the second interface information, and the third interface information corresponding to the component node.
[0147] In one embodiment, the node tree conversion module is further configured to: start from the root node of the component node, and sequentially traverse child nodes in the component node based on the third interface configuration information provided by the third instance object, respectively determine child node invocation information corresponding to each child node, and obtain third interface information corresponding to the component node based on the child node invocation information corresponding to each child node.
[0148] In one embodiment, the node tree transformation module is further configured to: determine, for each child node in the component node, child node interface information matching a child node type of the child node from third interface configuration information provided by the third instance object; obtain a second instance object based on the child node interface information; and obtain child node invocation information corresponding to the child node using the second instance object.
[0149] In one embodiment, the node tree conversion module is further configured to obtain, based on the child node configuration information of the child node, child node invocation information corresponding to the child node from second interface configuration information provided by the second instance object.
[0150] In one embodiment, the node tree generation module is further configured to determine a markup language used to write the page code, and compile the page code using a markup language compiler corresponding to the markup language to obtain a page parsing result.
[0151] All or part of the modules in the sub-application page processing unit can be implemented by software, hardware, or a combination thereof. The aforementioned modules may be integrated into the processor of the computer device in the form of hardware, may be independent, or may be stored in the memory of the computer device in the form of software, so that the processor can call the modules and perform the operations corresponding to the modules.
[0152] In one embodiment, a computing device is provided. The computing device may be a terminal, and FIG. 12 shows a diagram of the internal structure of the computing device. The computing device includes a processor, a memory, an input / output interface, a communication interface, a display device, and an input device. The processor, memory, and input / output interface are connected via a system bus. The communication interface, display device, and input device are connected to the system bus via the input / output interface. The processor of the computing device is configured to provide computational and control functions. The memory of the computing device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer-readable instructions. The internal memory provides an operating environment for the operating system and computer-readable instructions in the non-volatile storage medium. The input / output interface of the computing device is configured to exchange information between the processor and an external device. The communication interface of the computing device is configured for wired or wireless communication with an external terminal. The wireless mode may be implemented via Wi-Fi, a mobile cellular network, near-field communication (NFC), or other technologies. The computer-readable instructions are executed by the processor to implement a sub-application page processing method. The display device of the computing device is configured to form a visible image and may be a display screen, a projection device, or a virtual reality imaging device. The display screen may be a liquid crystal display screen or an electronic ink display screen. The input device of the computing device may be a touch layer covering the display screen, buttons, a trackball, a touchpad located on the housing of the computing device, or an external keyboard, touchpad, mouse, etc.
[0153] Those skilled in the art will understand that the structure shown in Figure 12 is merely a block diagram of a partial structure related to the solution of the present application, and does not limit the computer device to which the solution of the present application is applied. In particular, the computer device may include more or fewer components than those shown in the figure, may combine some components, or may use a different component arrangement.
[0154] In one embodiment, there is further provided a computing device including a memory and a processor, the memory having computer-readable instructions stored therein that, when executed by the processor, perform the operations of the method embodiments described above.
[0155] In one embodiment, a computer-readable storage medium is provided having computer-readable instructions stored therein that, when executed by a processor, perform the operations in the method embodiments described above.
[0156] In one embodiment, a computer program product is provided that includes computer-readable instructions that, when executed by a processor, perform the operations in the method embodiments described above.
[0157] Those skilled in the art will understand that all or part of the process of the method in the above-described embodiments can be implemented by computer-readable instructions instructing associated hardware. The computer-readable instructions can be stored in a non-volatile computer-readable storage medium. When the computer-readable instructions are executed, the process in the above-described method embodiments can be implemented. References to memory, database, or other medium used in the embodiments provided herein can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase-change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM), external cache memory, etc. By way of example and not limitation, RAM can have multiple forms, such as static random access memory (SRAM) and dynamic random access memory (DRAM). Databases in the embodiments provided herein can include at least one of relational and non-relational databases. Non-relational databases include, but are not limited to, blockchain-based distributed databases, etc. The processor in the embodiments provided herein may be, but is not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc.
[0158] The technical features of the above-described embodiments can be combined in any manner. For the sake of brevity, not all possible combinations of the technical features in the above-described embodiments are described. However, these combinations of technical features are deemed to be within the scope of the present specification unless there is a contradiction.
[0159] The above-described embodiments merely describe some embodiments of the present application in more specific and more detailed terms, but cannot be understood as limiting the patent scope of the present disclosure. Those skilled in the art may make some modifications and improvements without departing from the concept of the present application. All such modifications and improvements are included in the scope of protection of the present application. Therefore, the patent scope of the present application shall be governed by the appended claims.
Claims
1. 1. A sub-application page processing method executed by a computing device, comprising: When an event requesting retrieval of a sub-application page, which is a page displayed in the sub-application, is detected, retrieving a page code of the sub-application page; parsing the page code to obtain a page parsing result, and traversing a code set in the page parsing result to create a page node tree corresponding to the sub-application page, the page node tree being a tree structure generated based on the page nodes of the sub-application page; creating a first instance object for transforming the page node tree and establishing a binding relationship between the first instance object and the sub-application page; If the binding relationship is established, converting the page node tree into an interface call format using the first instance object and obtaining interface call information corresponding to the page node tree; performing page drawing based on the interface invocation information to generate the sub-application page; A method comprising:
2. The step of creating a first instance object for converting the page node tree and establishing a binding relationship between the first instance object and the sub-application page includes: obtaining a first interface class for transforming the page node tree, the first interface class including a logical method for transforming the page node tree, based on a protocol mode of a preconfigured interface protocol; creating the first instance object for converting the page node tree based on the first interface class; creating a root component instance corresponding to the sub-application page using the first instance object as a creation parameter and establishing a binding relationship between the first instance object and the sub-application page; The method of claim 1 , comprising:
3. The step of creating the first instance object for converting the page node tree based on the first interface class includes: creating a first implementation class corresponding to the first interface class using a first keyword for class-based interface implementation, the first implementation class being configured to implement the logical method for transforming the page node tree in the first interface class; instantiating the first implementation class using a second keyword for creating an instance object based on the class to create a first instance object corresponding to the first implementation class; The method of claim 2 , comprising:
4. The step of converting the page node tree into an interface call format using the first instance object and obtaining interface call information corresponding to the page node tree includes: According to first interface configuration information provided by the first instance object, starting from the root node of the page node tree, sequentially traversing page nodes in the page node tree, respectively determining first call information corresponding to each page node, and obtaining second call information corresponding to page configuration information of the page node tree; obtaining the interface invocation information corresponding to the page node tree based on the first invocation information and the second invocation information; 4. The method of claim 1, comprising:
5. The step of determining first invocation information corresponding to each page node, starting from a root node of the page node tree and sequentially traversing page nodes in the page node tree based on first interface configuration information provided by the first instance object, respectively, includes:
5. The method of claim 4, further comprising: for each page node in the page node tree, determining first interface information matching a page node type of the page node from the first interface configuration information provided by the first instance object; and determining first invocation information corresponding to the page node based on the first interface information.
6. The step of determining first call information corresponding to the page node based on the first interface information includes: obtaining a second instance object that provides second interface configuration information for converting the page node tree based on the first interface information; obtaining second interface information corresponding to the page node using the second interface configuration information provided by the second instance object; obtaining the first call information corresponding to the page node based on the first interface information and the second interface information; The method of claim 5 , comprising:
7. The method comprises: creating a second interface class for transforming a page node using the first instance object, the second interface class including a logical method for transforming a page node; creating a second implementation class corresponding to the second interface class using a first keyword for class-based interface implementation, the second implementation class being configured to implement the logical method for transforming page nodes in the second interface class; instantiating the second implementation class using a second keyword for creating an instance object based on the class to create a second instance object corresponding to the second implementation class; The method of claim 6 further comprising:
8. The step of obtaining second interface information corresponding to the page node using the second interface configuration information provided by the second instance object includes:
7. The method of claim 6, further comprising: obtaining the second interface information corresponding to the page node from the second interface configuration information provided by the second instance object based on node configuration information of the page node.
9. The step of obtaining the first call information corresponding to the page node based on the first interface information and the second interface information includes: If the page node is a component node, obtaining a third instance object that is created in advance and is an instance object for converting the component node based on the second interface information; obtaining third interface information corresponding to the component node using the third instance object; obtaining first invocation information corresponding to the component node based on the first interface information, the second interface information, and the third interface information corresponding to the component node; The method of claim 6, comprising:
10. The step of obtaining third interface information corresponding to the component node using the third instance object includes: According to third interface configuration information provided by the third instance object, starting from the root node of the component node, sequentially traversing child nodes in the component node to respectively determine child node invocation information corresponding to each child node; obtaining the third interface information corresponding to the component node based on the child node invocation information corresponding to each child node; 10. The method of claim 9, comprising:
11. The step of determining child node invocation information corresponding to each child node, starting from the root node of the component node and sequentially traversing child nodes in the component node according to third interface configuration information provided by the third instance object, respectively, includes: For each child node in the component node, determining child node interface information that matches a child node type of the child node from the third interface configuration information provided by the third instance object; obtaining a second instance object based on the child node interface information, and using the second instance object to obtain child node invocation information corresponding to the child node; 10. The method of claim 9, comprising:
12. The step of obtaining child node invocation information corresponding to the child node using the second instance object includes:
12. The method of claim 11, further comprising: obtaining the child node invocation information corresponding to the child node from second interface configuration information provided by the second instance object based on child node configuration information of the child node.
13. The step of parsing the page code to obtain a page parsing result includes:
13. The method of claim 1, further comprising determining a markup language used to write the page code, and compiling the page code using a markup language compiler corresponding to the markup language to obtain the page parsing result.
14. a code retrieval module configured to retrieve a page code of a sub-application page, the sub-application page being a page displayed in the sub-application, when an event requesting retrieval of the sub-application page is detected; a node tree generation module configured to parse the page code to obtain a page parsing result, and to traverse a code set in the page parsing result to create a page node tree corresponding to the sub-application page, the page node tree being a tree structure generated based on the page nodes of the sub-application page; a page initialization module configured to create a first instance object for transforming the page node tree and establish a binding relationship between the first instance object and the sub-application page; a node tree conversion module configured to convert the page node tree into an interface call format using the first instance object when the binding relationship is established, and obtain interface call information corresponding to the page node tree; and a page rendering module configured to perform page rendering based on the interface call information to generate the sub-application page. A sub-application page processing device comprising:
15. 14. A computing device comprising a memory and a processor, wherein the memory stores computer-readable instructions, and wherein the operations of the method of any one of claims 1 to 13 are performed when the processor executes the computer-readable instructions.
16. 14. A computer-readable storage medium having computer-readable instructions stored therein, wherein the operations of the method of any one of claims 1 to 13 are performed when the computer-readable instructions are executed by a processor.
17. A computer program product comprising computer readable instructions, which when executed by a processor perform the operations of the method of any one of claims 1 to 13.
Citation Information
Patent Citations
Sub-application page processing method and device and computer equipment
CN113312046A
A machine learning method for identifying independent tasks related to parallel layouts in web browsers.
JP2014514634A
Message processing method, storage medium, and computer device
JP2020511711A
Mini-program processing method, server, equipment, storage medium, and program
JP2021121972A
Micro-frontend system, sub-application loading method, electronic device, computer program product, and computer readable storage medium
WO2022135178A1