An applet processing method and apparatus, and an electronic device

By identifying the differences between the source code and the target form and performing adaptive compilation, products with different mini-program forms are generated, solving the problem of maintaining multiple sets of code for the same mini-program on different platforms, and achieving efficient iteration and low-cost maintenance.

CN116243923BActive Publication Date: 2026-06-26RAJAX NETWORK &TECHNOLOGY (SHANGHAI) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
RAJAX NETWORK &TECHNOLOGY (SHANGHAI) CO LTD
Filing Date
2023-02-15
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In existing technologies, mini-programs with the same function need to maintain multiple sets of code for different platforms, which leads to high difficulty and cost in iteration and maintenance.

Method used

By obtaining the source code of the target product to be generated, the differences between the source form and the target form are determined, and the source code is adapted and compiled based on these differences to generate mini-program products of different forms, including independent mini-programs, mini-program plugins and mini-program sub-packages.

Benefits of technology

It eliminates the differences between different mini-program formats, reduces the difficulty and cost of iteration and maintenance, provides integrated mini-program format capabilities, and supports the efficient deployment of the same source code on different platforms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116243923B_ABST
    Figure CN116243923B_ABST
Patent Text Reader

Abstract

The application discloses a mini-program processing method and device and electronic equipment. The method comprises the following steps: obtaining source code of a target product to be generated; wherein the target product is used for realizing a target mini-program function; taking a mini-program form corresponding to the source code as a source form, taking a mini-program form corresponding to the target product as a target form, and determining form differences between the source form and the target form; and performing adaptive compilation on the source code based on the form differences to generate the target product. By using the method, the problem of high iteration and maintenance difficulty of mini-programs in different mini-program forms is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to methods, apparatus, electronic devices, and storage media for processing small programs. Background Technology

[0002] Mini-programs are applications that can be obtained and used immediately without installation, and their convenience has led to their widespread adoption. Currently, more and more companies are developing and deploying mini-programs on different platforms to attract traffic. Mini-programs providing the same functionality may be hosted on different platforms in different forms, which places higher demands on the iteration and maintenance of mini-programs with the same function.

[0003] In existing technologies, a set of source code is maintained for each platform according to the corresponding mini-program format, and a corresponding product is generated for each platform's source code. This product is used to generate mini-programs for the corresponding platform. This has the following drawbacks: it requires maintaining multiple sets of code for the same function, which not only results in a long synchronous iteration cycle for the function, but also has many bugs, making it difficult to iterate and maintain, which makes the development process difficult and the development cost high.

[0004] Therefore, how to generate products for different types of mini-programs based on the same set of source code is a problem that needs to be solved.

[0005] The information disclosed in the background section is only intended to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0006] The mini-program processing method provided in this application solves the problem of high difficulty in iterating and maintaining mini-programs of different forms.

[0007] This application provides a method for processing mini-programs, including: obtaining the source code of a target product to be generated; wherein the target product is used to implement the function of a target mini-program; taking the mini-program form corresponding to the source code as the source form and the mini-program form corresponding to the target product as the target form, determining the form difference between the source form and the target form; and performing adaptive compilation on the source code based on the form difference to generate the target product.

[0008] Optionally, the source form includes one of the following mini-program forms: independent mini-program, mini-program plugin, mini-program sub-package; the target form is a mini-program form different from the source form.

[0009] Optionally, the step of adapting the source code based on the morphological differences to generate the target product includes: responding to the morphological differences including a first difference, injecting code data for adapting to the target morphology into the source code according to the first difference, and generating the target product based on the injection; wherein, the first difference includes differences between the source morphology and the target morphology related to the global application instance of the mini-program.

[0010] Optionally, the source form is an independent mini-program; the target form is a mini-program plugin or a mini-program sub-package; the source code before form conversion includes first global logic code, first page code, and / or first component code; the step of injecting code data to the source code to adapt to the target form according to the first difference, and generating the target product based on the injection, includes: injecting application instance difference smoothing code to the source code to simulate the application instance lifecycle and simulate application instance calls; modifying the first global logic code based on the application instance difference smoothing code to obtain the second global logic code after form conversion; modifying the first page code and / or first component code based on the application instance difference smoothing code to obtain the second page code and / or second component code after form conversion; obtaining the modified code corresponding to the source code based on the application instance difference smoothing code, the second global logic code, the second page code, and / or the second component code; and compiling the modified code to obtain the target product.

[0011] Optionally, the step of modifying the first global logic code based on the application instance difference smoothing code to obtain the second global logic code after morphological transformation includes: adding code to the first global logic code to obtain the exported data of the application instance difference smoothing code; modifying the initialization of the listening applet in the first global logic code to call the simulated listening applet initialization method included in the application instance difference smoothing code; wherein, the simulated listening applet initialization method is the method executed during the initialization of the lifecycle in the simulated application instance lifecycle; and obtaining the second global logic code based on the above modification.

[0012] Optionally, the step of modifying the first page code and / or the first component code based on the application instance difference smoothing code to obtain the second page code and / or the second component code after morphological transformation includes: adding references to the second global logic code and adding code for obtaining exported data of the application instance difference smoothing code in the first page code and / or the first component code; injecting the simulated application instance calling method included in the application instance difference smoothing code into the first page code and / or the first component code to obtain the second page code and / or the second component code after morphological transformation.

[0013] Optionally, the application instance difference smoothing code includes: code for exporting a simulated application instance calling method; code for implementing the simulated application instance calling method; wherein the simulated application instance calling method achieves data isolation and sharing based on closures and prototype chains; code for exporting a simulated listening mini-program initialization method; and code for implementing the simulated listening mini-program initialization method.

[0014] Optionally, the step of adapting the source code based on the morphological differences to generate the target product includes: the source code before morphological conversion includes first page code and / or first component code; in response to the morphological differences including a second difference, injecting the global style file in the source code into the first page code and / or first component code to obtain second page code and / or second component code after morphological conversion, obtaining the modified code corresponding to the source code based on the second page code and / or second component code, and compiling the modified code to obtain the target product; wherein, the second difference includes: when the source form is an independent mini-program and the target form is a mini-program plugin or mini-program sub-package, the differences between the source form and the target form related to the mini-program's global style.

[0015] Optionally, injecting the global style file from the source code into the first page code and / or the first component code includes: adding an import statement at the beginning of the code file of the first page code and / or the first component code to inject the global style file.

[0016] Optionally, the step of adapting the source code based on the morphological differences to generate the target product includes: in response to the morphological differences including a third difference, based on pre-defined specifications to be followed in generating the target product, during the compilation process of generating the target product, uniformly packaging the JS dependencies of each morphological product such as independent mini-programs, mini-program plugins, and mini-program subpackages, and extracting the component libraries that the target product depends on into a specific component dependency folder; wherein, the third difference includes differences between the source morphology and the target morphology related to the NPM component library.

[0017] Optionally, during the compilation process of generating the target product, the JS dependencies of the independent mini-program, mini-program plugin, and mini-program sub-package are packaged in a unified manner, and the component library dependent on the target product is extracted into a specific component dependency folder. This includes: performing dependency analysis based on the entry configuration, compiling components and JS based on the results of the dependency analysis, grouping components after compilation, extracting components based on the component grouping results, merging and packaging mini-program sub-packages or independent mini-programs according to the target form, replacing the referenced components with the corresponding components under the target form, and outputting the target product.

[0018] Optionally, the pre-defined specifications for generating the target artifact include at least one of the following: directory structure specifications, multi-terminal component library specifications, and JS dependency library specifications.

[0019] Optionally, the step of adapting the source code based on the morphological differences to generate the target product includes: in response to a developer triggering a compilation command of a specified compilation type, loading an entry configuration file corresponding to the target morphology from the source code; wherein the compilation type is specified based on the target morphology, and the entry configuration file includes the specified compilation type.

[0020] Optionally, the source form is an independent mini-program, and the target form is a mini-program subpackage; the method further includes: responding to a subpackage configuration file creation command input by the developer, generating a subpackage configuration file in the root directory of the mini-program project corresponding to the source code, wherein the subpackage configuration file is the entry configuration file corresponding to the target form being a mini-program subpackage; adding a specific page identifier input by the developer to be compiled into the target subpackage to the page configuration information included in the subpackage configuration file, wherein the specific page identifier corresponds to the specific page code included in the source code, and the page path of the specific page corresponding to the specific page identifier is composed of the subpackage identifier and its path of the target subpackage; obtaining the subpackage compilation configuration of the target subpackage, and adding the subpackage compilation configuration to the configuration file of the development framework or compiler applying the mini-program processing method; generating the target product based on the injection includes: compiling the specific page code into the target subpackage according to the subpackage compilation configuration included in the entry configuration file and the configuration file of the development framework or compiler; wherein, the target subpackage is the target product, and the folder corresponding to the target product can provide the target mini-program functionality after being stored in the corresponding host.

[0021] Optionally, it also includes: the application instance obtained by executing the application instance call method at runtime based on the target product is a hybrid product of the corresponding host and the target subpackage; wherein, the attributes and methods of the host can be obtained through the host variables of the application instance.

[0022] Optionally, the source form is an independent mini-program, and the target form is a mini-program plugin; the method further includes: responding to a plugin configuration file creation command input by the developer, generating a plugin configuration file in the root directory of the mini-program project corresponding to the source code, wherein the plugin configuration file is the entry configuration file corresponding to the target form being a mini-program plugin; if the global configuration file of the source code includes sub-package configuration, then adding the page information of the sub-package configuration in the global configuration file to the page information of the plugin configuration file, wherein the page path of the added page information consists of the corresponding sub-package identifier and the path of the sub-package; if it is determined that the target plugin obtained by compiling the source code includes an open page, then adding the information of the open page to the open page variable in the plugin configuration file; obtaining the plugin compilation configuration of the target plugin, and adding the plugin compilation configuration to the configuration file of the development framework or compiler applying the mini-program processing method; the plugin compilation configuration includes at least: specifying the compilation type as a plugin; responding to the compilation command, performing injection on the source code according to the first difference between the source form and the target form to obtain the corresponding modified code, and compiling the modified code into the target plugin according to the plugin configuration file and the plugin compilation configuration; wherein, the target plugin is the target product.

[0023] Optionally, it also includes: implementing the target plugin's external output of attributes and methods by calling the parent class of the application instance's call method in the page logic file of the mini-program project.

[0024] Optionally, the source form is a mini-program plugin; the target form is a mini-program subpackage; the method further includes: in response to a subpackage configuration file creation command input by the developer, generating a subpackage configuration file in the root directory of the mini-program project corresponding to the source code, wherein the subpackage configuration file is the entry configuration file corresponding to the target form of the mini-program subpackage; converting the information of the plugin configuration file included in the source code into a subpackage configuration and adding it to the subpackage configuration file; obtaining the subpackage compilation configuration and adding the subpackage compilation configuration to the configuration file of the development framework or compiler applying the mini-program processing method; in response to the compilation command, compiling the source code into the target product according to the subpackage configuration file and the subpackage compilation configuration.

[0025] Optionally, it also includes: the source form is a mini-program plugin or a mini-program sub-package; the target form is an independent mini-program; the adaptation compilation of the source code based on the form difference to generate the target product includes: obtaining a global configuration file for the mini-program written by the developer; receiving a specific configuration file modification by the developer for the development framework, such that the specific configuration file contains compilation configuration information for compiling and generating an independent mini-program, wherein the compilation configuration information contains a compilation type of an independent mini-program; and compiling the source code according to the written global configuration file for the mini-program and the specific configuration file to obtain the target product.

[0026] This application also provides a mini-program processing device, comprising: a source code acquisition unit, used to acquire the source code of a target product to be generated; wherein the target product is used to implement the function of a target mini-program; a morphological difference unit, used to take the mini-program morphology corresponding to the source code as the source morphology and the mini-program morphology corresponding to the target product as the target morphology, and determine the morphological difference between the source morphology and the target morphology; and a compilation unit, used to perform adaptive compilation of the source code based on the morphological difference to generate the target product.

[0027] This application also provides an electronic device, including: a memory and a processor; the memory is used to store a computer program, which, when run by the processor, executes the method provided in this application.

[0028] This application also provides a computer storage medium storing computer execution instructions, which, when executed by a processor, are used to implement the method provided in this application.

[0029] Compared with the prior art, this application has the following advantages:

[0030] This application provides a method, apparatus, electronic device, and storage medium for processing mini-programs. The method involves acquiring the source code of a target product to be generated; the target product is used to implement the functions of a target mini-program; the mini-program form corresponding to the source code is taken as the source form, and the mini-program form corresponding to the target product is taken as the target form; the form differences between the source form and the target form are determined; and the source code is adapted and compiled based on the form differences to generate the target product. This adaptation and compilation of the source code based on form differences provides at least some ability to smooth out differences between different forms, compiling the source code into target products of different forms (i.e., different mini-program forms). Each form of target product can be deployed to corresponding channels, thereby supporting different form conversions, providing integrated mini-program form capabilities, and reducing the difficulty and cost of iterative maintenance. Attached Figure Description

[0031] Figure 1 This is a schematic diagram illustrating the processing procedure of a mini-program provided in this application;

[0032] Figure 2 This is a flowchart of a mini-program processing method provided in the first embodiment of this application;

[0033] Figure 3 This is a schematic diagram of a mini-program compilation process provided in the first embodiment of this application;

[0034] Figure 4 This is a schematic diagram of a mini-program processing device provided in the second embodiment of this application;

[0035] Figure 5 This is a schematic diagram of the electronic device provided in this application. Detailed Implementation

[0036] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.

[0037] This application provides a method, apparatus, electronic device, and storage medium for processing mini-programs. These are described in detail in the following embodiments.

[0038] To facilitate understanding, relevant concepts and an application scenario of a mini-program processing method are first introduced. This application scenario is merely one embodiment of the mini-program processing method, provided to facilitate understanding of the mini-program processing method offered in this application, and is not intended to limit the application of the mini-program processing method.

[0039] Mini-programs are applications that can be used immediately without installation. Mini-program developers use a mini-program development framework to develop mini-programs. Mini-program development includes creating a mini-program project, writing mini-program code, and compiling. Compilation refers to building and packaging the source code of the mini-program into an artifact supported by the mini-program at runtime. This can refer to code conversion and packaging based on different syntaxes, or it can refer to compiling into executable code.

[0040] The form of a mini-program refers to the form of the mini-program project and its corresponding deliverables. For example, the deliverables may be a standalone mini-program, a mini-program sub-package, or a mini-program plugin.

[0041] An independent mini-program is a mini-program entity with an appID (mini-program identifier). It has full permissions for mini-programs, can use plugins and sub-packages, and can provide shared data and methods for different plugins and sub-packages.

[0042] Mini-program sub-packages refer to the process of splitting a single mini-program into different sub-packages for development based on requirements. Each sub-package is built and packaged into a separate sub-package, which can be loaded as needed by the user. Mini-program sub-packages can apply for mini-program permissions, providing a user experience similar to independent mini-programs. This application includes sub-packages in the conventional sense and main packages. A main package is a type of mini-program sub-package; each mini-program has only one main package, used to house the default launch page / tab bar page, as well as some common resources and scripts needed by all sub-packages. Mini-program sub-packages can be divided into ordinary sub-packages and independent sub-packages based on their configuration items, such as configuring whether it is an independent sub-package through the `indepent` field in the `app.json` configuration file. An independent sub-package is a special type of sub-package that can run independently of the main package and other sub-packages. Accessing a mini-program from a page in an independent sub-package does not require downloading the main package, while accessing a page within a ordinary sub-package or the main package does require downloading the main package.

[0043] Mini-program plugins are independently published functional components that can be nested within independent mini-programs and can be subscribed to.

[0044] A development framework refers to a mini-program development framework. Developers can use the abstract components and instance interaction methods provided by the development framework to develop mini-program projects to achieve corresponding business functions according to their needs.

[0045] A compiler is a tool for compiling mini-programs, used to convert source code into target artifacts, which can then be provided to the corresponding platform to implement the functionality of the target mini-program. Compilers can also be integrated into development frameworks.

[0046] The development framework and / or compiler can be deployed on electronic devices used by the developer, such as computers, or on servers on a network. When deployed on a server, the developer uses the compilation services provided by the server via the network, and the server obtains the source code provided by the developer via the network, performs compilation, and generates the target artifact.

[0047] With the increasing number of platforms providing runtime environments for mini-programs, mini-programs with the same functionality may be deployed in different forms on different platforms. For example, mini-program 1 might be deployed as an independent mini-program on platform A, but its corresponding functionality might need to be integrated as a sub-package into an independent mini-program on platform B; similarly, mini-program plugin 1 on platform A might need to be integrated as a sub-package into an independent mini-program on platform B; furthermore, mini-program plugin 1 on platform A might need to be a mini-program plugin on platform C; and still others, mini-program plugin 1 on platform A might need to be an independent mini-program on platforms D or E. If the same functionality maintains the same set of source code, deployment on different platforms can maintain a consistent user experience, while reducing the difficulty of iteration and maintenance, and lowering development costs. This leads to the following requirement: to generate deliverables for the same project (i.e., the same mini-program project) for deployment on different platforms, where the same project is a mini-program project created for the same functionality. Please refer to [reference needed]. Figure 1 The diagram schematically illustrates a mini-program processing flow to control the generation of different types of deliverables for the same project, which can then be deployed on corresponding platforms. These deliverables include: source code 101, a compiler or an open framework containing a compiler 102, a target deliverable in the form of an independent mini-program 103, separate target deliverables in the form of individual mini-programs 104, and a target deliverable in the form of a mini-program plugin 105. The source code refers to a package of source code files developed by the developer for the same project to implement the functions of the target mini-program, including one or more source code files. The compiler or open framework containing a compiler compiles the source code according to the compilation type and corresponding compilation configuration specified by the developer to generate the corresponding target deliverables. When the compilation type is an independent mini-program, the target deliverable in the form of an independent mini-program is obtained; when the compilation type is separate mini-programs, the target deliverable in the form of separate mini-programs, i.e., target packages, is obtained; when the compilation type is a mini-program plugin, the target deliverable in the form of a mini-program plugin, i.e., target plugin, is obtained.

[0048] It should be noted that the information disclosed above is only for the purpose of helping to understand this application and does not constitute prior art known to those skilled in the art.

[0049] It should be understood that the method provided in the embodiments of this application can be applied to processing any applet code written in a programming language. For ease of description, the following embodiments use an applet written in JavaScript as an example to illustrate the method provided in this application.

[0050] As one possible implementation, the method provided in this application embodiment can be applied to a compiler or a development framework that integrates a compiler; the execution subject of the method can be a device configured as the compiler or the development framework, which can be a medium storing or executing relevant execution code, or it can be an entity device that integrates or installs the relevant execution code of the compiler or the open framework, such as a computer.

[0051] The following combination Figure 2 and Figure 3 The applet processing method provided in the first embodiment of this application will be described. Figure 2 The mini-program processing methods shown include:

[0052] Step S201: Obtain the source code of the target product to be generated; wherein, the target product is used to implement the functions of the target applet;

[0053] Step S202: Take the mini-program form corresponding to the source code as the source form, take the mini-program form corresponding to the target product as the target form, and determine the form difference between the source form and the target form.

[0054] Step S203: Based on the morphological differences, the source code is adapted and compiled to generate the target product.

[0055] In practical applications, mini-programs can take the form of an independent mini-program, a mini-program package, or a mini-program plugin. Developers often generate a mini-program project based on a predetermined mini-program form and write source code (also called source code); the predetermined mini-program form is used as the mini-program form corresponding to the source code. For example, in step S201, the source code is the code file of the mini-program written by the developer in a certain high-level programming language, generally in text format, especially the file that implements the business logic function of the target mini-program. The target product is the product obtained by compiling the source code, which can be provided to the host of the corresponding platform to realize the target mini-program function. Obtaining the source code to be used to generate the target product includes: obtaining access permissions to the developer's code repository, determining the specific mini-program project to be compiled into the target product to provide the target mini-program function, and obtaining the code of the specific mini-program project as the source code.

[0056] In this embodiment, developers can trigger a compiler or development framework to compile the source code via a command line. This embodiment uses a development framework as an example for illustrative purposes. The development framework provides compilation commands, and the compilation commands input by the developer can specify the compilation type. The development framework obtains the entry configuration file corresponding to different mini-program forms based on the compilation type and compiles it. Specifically, the adaptive compilation of the source code based on the form differences to generate the target product includes: in response to the developer triggering a compilation command of the specified compilation type, loading the entry configuration file corresponding to the target form from the source code; wherein, the compilation type is specified based on the target form, and the entry configuration file includes the specified compilation type.

[0057] Example 1: The `compileType` parameter in the compilation command can take the values: `miniprogram`, `plugin`, or `subpackage`. `miniprogram` indicates compilation as a standalone mini-program, with the entry configuration file `app.json`; `plugin` indicates compilation as a plugin, with the entry configuration file `plugin.json`; and `subpackage` indicates compilation as a subpackage, with the entry configuration file `subpackage.json`. Another example is a configuration example for a subpackage.json file used for mini-program subpackaging:

[0058]

[0059] In this configuration example, the `type` field identifies whether the subpackage is "subpackage" or "main". When it is a `subpackage`, the compiled target subpackage (i.e., the target artifact) is automatically loaded into the `subpackages` field of the `app.json` file; while the "main" type subpackage is automatically merged into the `pages` field of the `app.json` file, i.e., merged into the main package. The `root` field is used to determine the root directory when merging the target artifact into the host mini-program. The information in the `Pages` field is parsed as the actual path of the compiled subpackage. The subpackage field in the `app.json` of the independent mini-program can be either `subpackages` or `subPackages`. The development framework described in this embodiment provides configuration specifications for the independent mini-program's `app.json` and the mini-program plugin's `plugin.json`. Furthermore, the entry configuration files corresponding to different compilation types can be loaded from the source code directories specified by `srcPath` and `srcPaths`, or obtained according to customized path configurations.

[0060] As described in step S202, the mini-program form corresponding to the source code is the source form, and the mini-program form corresponding to the target product is the target form. The mini-program processing method provided in this embodiment is particularly suitable for scenarios where there are form differences between the source form and the target form. Preferably, the source form includes one of the following mini-program forms: independent mini-program, mini-program plugin, or mini-program sub-package; the target form is a mini-program form different from the source form. Form differences refer to the differences in the running methods of the three different forms of mini-programs (independent mini-program, mini-program sub-package, and mini-program plugin) and the differences arising after converting the source code of one mini-program form into other mini-program forms. By smoothing out these form differences through the compiler or development framework executing the mini-program processing method, the source code can be compiled into a target product of a different form than the source form, achieving form conversion between different mini-program forms. The source form can be understood as the mini-program form before form conversion, and the target form can be understood as the mini-program form after form conversion. Furthermore, since the same set of source code can be compiled into target products of different forms with minimal modification to business code, it provides the capability of unified mini-program form. The so-called integrated capability of mini-program forms refers to supporting the same project to be deployed on different platforms in different mini-program forms (such as independent mini-programs, mini-program plugins, and mini-program sub-packages) in a homogeneous manner. In other words, it is to iteratively maintain the same set of source code and compile it into different target products according to deployment needs.

[0061] In this embodiment, the differences between different forms of the mini-program include, but are not limited to: differences related to the global application instance of the mini-program, differences related to the global style of the mini-program, and differences related to the NPM (JavaScript package management) component library.

[0062] The differences related to the global application instance of the mini-program include: differences related to application instance invocation, which include differences in how different forms invoke the mini-program application instance, i.e., differences in getApp under different forms; and differences related to the application instance lifecycle, which include differences in the lifecycle of the mini-program application instance under different forms, i.e., differences in the App lifecycle under different forms. The application instance lifecycle of a mini-program includes processes such as mini-program initialization (onLaunch), launch (onShow), and switching to the background (onHide). Among them, the differences in getApp for different mini-program forms are as follows: independent mini-programs can call getApp() to obtain the global App instance and the attributes or methods attached to the instance; mini-program plugins cannot call getApp(); mini-program subpackages can call getApp() to obtain the global App instance and the attributes or methods attached to the instance, but when the target product converted from the source form is an independent mini-program is a mini-program subpackage, the getApp() originally called by the subpackage will be invalid and replaced by the getApp() of the host mini-program corresponding to the target product. The differences in the lifecycle of different mini-program forms are as follows: standalone mini-programs execute the onLaunch, onShow, and onHide lifecycles; in contrast, mini-program plugins and mini-program sub-packages do not have an application lifecycle.

[0063] The differences related to global styles in mini-programs are as follows: standalone mini-programs can declare global styles in public style files (such as app.wxss or app.acss); while mini-program plugins and sub-packages do not have global styles. Global style files (app.acss or app.wxss, etc.) can be automatically injected into the style files of each page and component during compilation as references, thus achieving compatibility of global styles across different formats.

[0064] The differences related to NPM component libraries refer to the potential variations in usage restrictions for different types of NPM components across different mini-program platforms. To mitigate these issues, the compilation process can be optimized by automatically packaging the JS dependencies of independent mini-programs, mini-program plugins, and mini-program sub-packages together, and automatically extracting the used component libraries into the `npm_components` folder, based on the development framework's bundle pattern, multi-platform component library specifications, and JS dependency library specifications.

[0065] To address the aforementioned differences, this embodiment provides corresponding smoothing methods, such as injecting difference-smoothing code to simulate the application instance lifecycle and simulate `getApp`; injecting global styles into each page; and uniformly packaging dependent libraries to avoid usage restrictions. Alternatively, differences can be made compatible within the source code, or compatibility across different platforms and formats can be achieved through file-level or code-level conditional compilation provided by the development framework. Furthermore, combining source code compatibility with the development framework's automatic smoothing of at least some differences can realize the multi-format integration capability of the mini-program.

[0066] Preferably, determining the morphological difference between the source form and the target form includes: scanning the source code directory to determine the source form corresponding to the source code; obtaining the compilation type specified by the developer through compilation options to determine the target form corresponding to the target product, and obtaining the difference between the source form and the target form.

[0067] As described in step S203, the source code is adapted and compiled based on the morphological differences to generate the target product. Specifically, this step involves performing corresponding adaptation processing during the compilation of the source code based on the analysis of morphological differences described above. This allows for the creation of target products in different forms from the source code of the same project, enabling deployment on corresponding mini-program platforms. This achieves homogeneous support for the same project to be deployed in different forms on different channels, providing the capability of unified mini-program forms.

[0068] In this step, the first difference, including the morphological differences, is addressed through automatic code injection during compilation for adaptive compilation. Specifically, the adaptive compilation of the source code based on the morphological differences to generate the target product includes: responding to the morphological differences including the first difference, injecting code data for adapting to the target morphological form into the source code according to the first difference, and generating the target product based on the injection; wherein, the first difference includes differences between the source morphological form and the target morphological form related to the global application instance of the mini-program. That is, the first difference includes the differences related to the global application instance of the mini-program given above, for example, specifically including differences in getApp and differences in App lifecycle. In implementation, when the source morphological form is a plugin or sub-package, and the target morphological form is an independent mini-program, the developer can add code related to the independent mini-program, which can be achieved by modifying the configuration file of the independent mini-program to declare plugins or add configurations related to sub-packages. When the first difference arises from the source morphological form being an independent mini-program and the target morphological form being a mini-program plugin or mini-program sub-package, the approach to smoothing it out is to smooth out the differences in getApp calls and App lifecycle under different morphological forms by injecting code during compilation. Specifically, the source code before the form conversion includes first global logic code, first page code, and / or first component code; correspondingly, the step of injecting code data into the source code to adapt to the target form based on the first difference, and generating the target product based on the injection, includes: injecting application instance difference smoothing code into the source code to simulate the application instance lifecycle and simulate application instance calls; modifying the first global logic code based on the application instance difference smoothing code to obtain the second global logic code after form conversion; modifying the first page code and / or first component code based on the application instance difference smoothing code to obtain the second page code and / or second component code after form conversion; obtaining the modified code corresponding to the source code based on the application instance difference smoothing code, the second global logic code, the second page code, and / or the second component code; and compiling the modified code to obtain the target product.

[0069] The step of modifying the first global logic code based on the application instance difference smoothing code to obtain the second global logic code after form conversion includes: adding code to the first global logic code to obtain the exported data of the application instance difference smoothing code; modifying the initialization of the listening applet in the first global logic code to call the simulated listening applet initialization method included in the application instance difference smoothing code; wherein, the simulated listening applet initialization method is the method executed during the initialization of the lifecycle in the simulated application instance lifecycle; and obtaining the second global logic code based on the above modification. The step of modifying the first page code and / or the first component code based on the application instance difference smoothing code to obtain the second page code and / or the second component code after form conversion includes: adding a reference to the second global logic code and adding code for obtaining the exported data of the application instance difference smoothing code to the first page code and / or the first component code; injecting the simulated application instance calling method included in the application instance difference smoothing code into the first page code and / or the first component code to obtain the second page code and / or the second component code after form conversion. The exported data of the application instance difference smoothing code refers to data exported from the application instance difference smoothing code that can be used by other modules. For example, it can be the method of exporting variables in the application instance difference smoothing code and the values ​​of the internal variables contained within those variables. After export, it can be used in other files and / or modules that reference the application instance difference smoothing code (e.g., through require or import). The code used to obtain the exported data of the application instance difference smoothing code can be the code that references the application instance difference smoothing code through require or import. Preferably, the application instance difference smoothing code includes: code for exporting simulated application instance call methods; code for implementing the simulated application instance call methods; wherein the simulated application instance call methods achieve data isolation and sharing based on closures and prototype chains; code for exporting simulated listening mini-program initialization methods; and code for implementing the simulated listening mini-program initialization methods. The above processing can be understood as: achieving the first difference smoothing by adding support for the app.js entry file in the mini-program plugin and mini-program sub-package forms, simulating App lifecycle calls, and injecting the getApp method into each page and component.

[0070] Example 2 is as follows: The source code of the independent mini-program is compiled into the target product in the form of mini-program subpackage or mini-program plugin, and the form transformation occurs. Table 1 and Table 2 show the comparison of app.js before and after the transformation, and the comparison of the pages of the subpackage and plugin, respectively. Table 3 shows the simulated App's onLaunch lifecycle call and getApp call in the injected subpackage.global.js file.

[0071] Table 1 Comparison of app.js files before and after converting a standalone mini-program to a mini-program subpackage or plugin.

[0072]

[0073]

[0074] Table 2 Comparison of page.js files before and after converting a standalone mini-program to a mini-program package or plugin.

[0075]

[0076] Table 3 shows the conversion of standalone mini-programs into mini-program subpackages or plugins, injected into the subpackage.global.js file.

[0077]

[0078] It should be understood that this example is merely illustrative. The code in the table represents exemplary code differences and does not represent all injected code or differences, nor does it limit the processing method of the mini-program. In Tables 1 and 2, methods and data exported from other files are obtained through the `require()` function, and the paths passed to `require()` are relative paths. In Table 3, methods and data are exported through `module.exports`. `module.exports.init` exports the simulated `onLaunch` lifecycle method implemented in `subpackage.global.js`. Other lifecycle methods such as `onLoad`, `onShow`, and `onError` can be implemented as needed. Of course, similar difference smoothing functionality can also be achieved using other coding languages / other functions / other coding standards. A closure is a function that can read variables inside other functions. For example, if the inner function `fun2` of function `fun1` is referenced by a variable outside function `fun1`, a closure is created. A prototype chain uses built-in prototype properties to allow one reference type to inherit the properties and methods of another reference type. A prototype is a prototype object, whose built-in property `__proto__` (a pointer) points to the object pointed to by the `prototype` (prototype) of its constructor function.

[0079] In this embodiment, as in step S203, the source code can also be adapted for compilation based on the second difference. The adaptation compilation of the source code based on the morphological difference to generate the target product includes: responding to the morphological difference including the second difference, injecting the global style file from the source code into the first page code and / or the first component code to obtain the morphologically transformed second page code and / or the second component code; obtaining the modified code corresponding to the source code based on the second page code and / or the second component code; and compiling the modified code to obtain the target product. The second difference includes: when the source form is an independent mini-program and the target form is a mini-program plugin or a mini-program sub-package, the differences between the source form and the target form related to the mini-program's global style. Preferably, injecting the global style file from the source code into the first page code and / or the first component code includes: adding an import statement at the beginning of the code file of the first page code and / or the first component code to inject the global style file.

[0080] Example 3 is shown below. Table 4 compares the style files of pages and components that are converted from independent mini-programs to mini-program subpackages or plugins and injected with global styles.

[0081] Table 4 Comparison of style files before and after converting a standalone mini-program to a mini-program package or plugin.

[0082]

[0083] It should be understood that the tables provided in this embodiment are only for better understanding of the exemplary code data given in this solution, and are not intended to limit file names, variable names, function names, method calls, etc.

[0084] In this embodiment, the development framework automatically injects global styles into the top of the style files of each page and component, thereby achieving compatibility of global styles under different conditions.

[0085] In this embodiment, in step S203, the source code can also be adapted for compilation based on the third difference. The adaptation compilation of the source code based on the morphological difference to generate the target product includes: responding to the morphological difference including the third difference, and based on pre-defined specifications to be followed in generating the target product, during the compilation process of generating the target product, uniformly packaging the JS dependencies of each type of product—independent mini-program, mini-program plugin, and mini-program sub-package—and extracting the component libraries that the target product depends on into a specific component dependency folder; wherein, the third difference includes differences between the source form and the target form related to the NPM component library. The pre-defined specifications to be followed in generating the target product include at least one of the following: directory structure specifications, multi-platform component library specifications, and JS dependency library specifications. The directory structure specifications define the directory structure of the target product, including but not limited to directory division and directory naming principles. The multi-platform component library specifications define the component libraries that need to be included to adapt to different platforms when compiling the target product for different mini-program platforms. The JS dependency library specifications define the JS modular dependency processing mode to be compatible with different platforms. The compilation process for generating the target artifact involves uniformly packaging the JS dependencies of various artifact types—independent mini-programs, mini-program plugins, and mini-program sub-packages—and extracting the component libraries that the target artifact depends on into a specific component dependency folder. This includes: performing dependency analysis based on the entry configuration; compiling components and JS (i.e., JavaScript) based on the results of the dependency analysis; grouping components after compilation; extracting components based on the grouping results; merging and packaging mini-program sub-packages or independent mini-programs according to the target artifact type; replacing referenced components with the corresponding components for the target artifact type; and outputting the target artifact. This avoids dependency issues across different artifact types and the differences in NPM support across different mini-program platforms. Please refer to [reference needed]. Figure 3 The diagram illustrates a WeChat Mini Program compilation process, including: entry point configuration, dependency analysis, component compilation and JS compilation, dynamic grouping, component extraction, merging and packaging, reference replacement, and artifact output; these are performed step-by-step according to the arrows in the diagram. Entry point configuration can be achieved by configuring an entry point configuration file, such as generating or editing the entry point configuration file; dependency analysis includes determining the reference relationships of JavaScript files, only requiring the files used to be packaged into the target artifact, and can perform single-file dependency analysis, nested dependency analysis, circular dependency analysis, etc.; based on the results of dependency analysis, component compilation and JS (i.e., JavaScript) compilation are performed, followed by component grouping, extraction of used components based on the component grouping results, merging and packaging, and replacement of referenced components with the corresponding components under the target form, outputting the target artifact.

[0086] Preferably, the morphological differences may include one or more of the first, second, and third differences mentioned above, and the adaptation compilation of the source code based on the morphological differences includes: performing corresponding adaptation compilation for each difference included in the morphological differences.

[0087] This embodiment also includes configuration related to the form conversion. In one embodiment, the source form is an independent mini-program, and the target form is a mini-program subpackage; that is, the independent mini-program is converted into a mini-program subpackage, and the mini-program processing method further includes the following processing: in response to the subpackage configuration file creation command input by the developer, a subpackage configuration file is generated in the root directory of the mini-program project corresponding to the source code, and the subpackage configuration file is the entry configuration file corresponding to the target form being a mini-program subpackage; the specific page identifier to be compiled into the target subpackage input by the developer is added to the page configuration information included in the subpackage configuration file, and the specific page identifier corresponds to the specific page code included in the source code. The page path of a specific page corresponding to a defined page identifier is composed of the sub-package identifier and its path of the target sub-package; the sub-package compilation configuration of the target sub-package is obtained, and the sub-package compilation configuration is added to the configuration file of the development framework or compiler applying the mini-program processing method; correspondingly, generating the target artifact based on the injection includes: compiling the specific page code into the target sub-package according to the sub-package compilation configuration included in the entry configuration file and the configuration file of the development framework or compiler; wherein, the target sub-package is the target artifact, and the folder corresponding to the target artifact can provide the target mini-program functionality after being stored in the corresponding host. The application instance obtained by executing the application instance call method at runtime based on the target artifact is a hybrid artifact of the corresponding host and the target sub-package; wherein, the attributes and methods of the host can be obtained through the host variables of the application instance.

[0088] Example 4 illustrates the configuration for converting a standalone mini-program into a mini-program subpackage. This requires the development framework to provide configuration capabilities, which can be either command-line or an interactive interface. In the other examples above, subpackages have been specified using `compileType` (the compilation type parameter), so the entry configuration file name defaults to `subpackage.json`. In this example, a `subpackage.json` file is created in the root directory of the mini-program project. The pages that need to be compiled and converted into subpackages are added to this file as follows:

[0089]

[0090] Furthermore, add the following information to the specific configuration file of the development framework, such as the config.js file, regarding the sub-package compilation configuration:

[0091]

[0092] After completing the above configuration, the corresponding subpackage compilation can be executed. After compilation, the target subpackage is obtained. The folder containing the target subpackage is then placed in the corresponding host to provide the target mini-program functionality. In the mini-program subpackage form, the App obtained through the `getApp` call is a hybrid product of the host and the subpackage. The host's properties and methods can be obtained through the `app.$host` property. If at least some business logic in the subpackage depends on global styles, `app.acss` is injected into the styles of each page and component as a reference. If the subpackage's business logic needs to use an npm package provided by the host, the corresponding package name can be added to `externals` in the above configuration example, allowing it to be referenced normally in the project. Alternatively, a separate JS file can be abstracted, supporting different platforms through conditional compilation at the file or source code level. During framework compilation, an initialization file can also be included at the top of the JS file of each page and component to ensure the subpackage's initialization.

[0093] In one implementation, the source form is an independent mini-program, and the target form is a mini-program plugin; that is, an independent mini-program is converted into a mini-program plugin. The mini-program processing method further includes: responding to a plugin configuration file creation command input by the developer, generating a plugin configuration file in the root directory of the mini-program project corresponding to the source code, wherein the plugin configuration file is the entry configuration file corresponding to the target form of the mini-program plugin; if the global configuration file of the source code includes sub-package configuration, then adding the page information of the sub-package configuration in the global configuration file to the page information of the plugin configuration file, wherein the page path of the added page information consists of the corresponding sub-package identifier and the path of the sub-package; if the source... If the target plugin obtained from code compilation includes an open page, then the information of the open page is added to the open page variable in the plugin configuration file; the plugin compilation configuration of the target plugin is obtained, and the plugin compilation configuration is added to the configuration file of the development framework or compiler applying the mini-program processing method; the plugin compilation configuration includes at least: specifying the compilation type as plugin; responding to the compilation command, injecting the source code according to the first difference between the source form and the target form to obtain the corresponding modified code, and compiling the modified code into the target plugin according to the plugin configuration file and the plugin compilation configuration; wherein, the target plugin is the target artifact. Further, in the page logic file of the mini-program project, the target plugin outputs attributes and methods by calling the parent class of the application instance calling method.

[0094] Example 5 illustrates the configuration related to converting a standalone mini-program into a mini-program plugin. This requires the development framework to provide configuration capabilities, which can be either command-line or an interactive interface. In the other examples above, the plugin was specified using `compileType` (the compilation type parameter), so the default name of the entry configuration file is `plugin.json`. In this example, a `plugin.json` file is created in the root directory of the mini-program project. The pages that need to be compiled and converted into plugins are added to this file as follows:

[0095]

[0096] This includes adding pages from the subpackages to the `pages` section of `plugin.json`, with the page path consisting of the subpackage name and path. Pages that the plugin needs to expose to the public should be added to the corresponding `publicPages` section. It also includes adding the plugin compilation configuration to the development framework's configuration file as follows.

[0097]

[0098] After completing the above configuration, you can execute the corresponding plugin compilation. Once compiled, you can debug it in the corresponding mini-program developer tools. The plugin can output its capabilities in the index.js file. The host application can access the plugin's output capabilities using getApp().$plugin.instances.[plugin name] at runtime. The index.js configuration is as follows:

[0099]

[0100] This example can also configure app.js or other logic files to call the plugin. After the host integrates the plugin SDK, it can inject host methods into the plugin. In one implementation, the source form is a mini-program plugin; the target form is a mini-program subpackage; that is, the mini-program plugin is converted into a mini-program subpackage. The mini-program processing method further includes: in response to the subpackage configuration file creation command input by the developer, generating a subpackage configuration file in the root directory of the mini-program project corresponding to the source code, wherein the subpackage configuration file is the entry configuration file corresponding to the target form of the mini-program subpackage; converting the information of the plugin configuration file included in the source code into a subpackage configuration and adding it to the subpackage configuration file; obtaining the subpackage compilation configuration and adding the subpackage compilation configuration to the configuration file of the development framework or compiler that applies the mini-program processing method; in response to the compilation command, compiling the source code into the target product according to the subpackage configuration file and the subpackage compilation configuration.

[0101] Example 6 illustrates the process of converting a mini-program plugin into a mini-program subpackage. This requires configuration capabilities from the development framework, which can be either command-line or interactive. Create a `subpackage.json` file in the project root directory, convert the plugin's `plugin.json` into the subpackage configuration, and add the subpackage compilation configuration to the development framework's configuration file. The configuration content and format are similar to those in Example 4. After configuration, the corresponding subpackage compilation can be executed. Once compiled, the folder containing the target output will be placed in the corresponding host environment. The configuration approach for converting a mini-program subpackage into a mini-program plugin is similar to that for converting a mini-program plugin into a mini-program subpackage.

[0102] The configuration method involved in this embodiment can be either command-line or interactive interface configuration, without limitation. Before configuration, it is necessary to determine the version information and tool dependencies of the development framework.

[0103] The method provided in this embodiment can be applied to the mutual compilation and conversion between independent mini-programs, mini-program plugins, and mini-program sub-packages, including: converting an independent mini-program to a mini-program sub-package or mini-program plugin; converting a mini-program plugin to an independent mini-program or mini-program sub-package; and converting a mini-program sub-package to an independent mini-program or mini-program plugin. Configuration examples four to six above provide configuration ideas for four conversion scenarios: converting an independent mini-program to a mini-program sub-package or plugin, and mutual conversion between mini-program plugins and mini-program sub-packages. Furthermore, this embodiment also includes processing for converting a mini-program plugin or mini-program sub-package to an independent mini-program. Specifically, the method further includes: the source form is a mini-program plugin or mini-program sub-package; the target form is an independent mini-program; and the adaptation compilation of the source code based on the form difference to generate the target product includes: obtaining a global configuration file for the mini-program written by the developer; receiving modifications made by the developer to a specific configuration file for the development framework, such that the specific configuration file contains compilation configuration information for compiling and generating an independent mini-program, wherein the compilation configuration information includes a compilation type of independent mini-program; and compiling the source code according to the written global configuration file and the specific configuration file to obtain the target product. For example, in scenarios where mini-program plugins or sub-packages are converted into independent mini-programs, the development framework obtains the app.json configuration file (i.e., the global configuration file for the mini-program) written by the developer, receives relevant configuration information modified or added by the developer (modifying the config.js file to add or modify the compilation configuration information for compiling the independent mini-program), and specifies the compileType in the compilation configuration information as miniprogram, thereby compiling the source code into the corresponding target product. Because the development framework provides at least some of the ability to smooth out differences between different forms, it can compile the source code of the same project into target products of different forms (i.e., different mini-program forms), or, by combining a small amount of source code adaptation, compile the source code of the same project into target products of different forms. Each form of target product can be deployed to corresponding channels, thus supporting different form conversions in a homogeneous manner, providing integrated mini-program form capabilities, and reducing the difficulty and cost of iteration and maintenance.

[0104] It should be noted that, unless otherwise specified, the features given in this embodiment and other embodiments of this application can be combined with each other, and the various forms of processes described above can be reordered, steps can be added or deleted. For example, steps S201 and S202 or similar terms do not limit the steps to be executed in a specific order. As long as the desired results of the technical solution disclosed in this application can be achieved, no limitations are imposed herein.

[0105] This concludes the description of the method provided in this embodiment. The method provides at least some of the ability to smooth out differences between different forms, compiles the source code of the same project into target products of different forms (i.e., different mini-program forms), and the target products of each form can be deployed to corresponding channels, thereby supporting the conversion of different forms in a homogeneous manner, providing the integrated capability of mini-program forms, and reducing the difficulty and cost of iterative maintenance.

[0106] Corresponding to the first embodiment, the second embodiment of this application provides a mini-program processing device; for relevant parts, please refer to the description of the corresponding method embodiment. Figure 4 The mini-program processing device shown in the figure includes:

[0107] The source code acquisition unit 401 is used to acquire the source code of the target product to be generated; wherein the target product is used to implement the function of the target mini-program.

[0108] The morphological difference unit 402 is used to take the mini-program form corresponding to the source code as the source form and the mini-program form corresponding to the target product as the target form, and determine the morphological difference between the source form and the target form.

[0109] The compilation unit 403 is used to perform adaptive compilation of the source code based on the morphological differences to generate the target product.

[0110] Optionally, the source form includes one of the following mini-program forms: independent mini-program, mini-program plugin, mini-program sub-package; the target form is a mini-program form different from the source form.

[0111] Optionally, the compilation unit 403 is specifically configured to: in response to the morphological difference including a first difference, inject code data for adapting to the target morphology into the source code according to the first difference, and generate the target product based on the injection; wherein, the first difference includes differences between the source morphology and the target morphology related to the global application instance of the mini-program.

[0112] Optionally, the source form is an independent mini-program; the target form is a mini-program plugin or a mini-program sub-package; the source code before form conversion includes first global logic code, first page code, and / or first component code; the compilation unit 403 is specifically used for: injecting application instance difference smoothing code into the source code to simulate the application instance lifecycle and simulate application instance calls; modifying the first global logic code based on the application instance difference smoothing code to obtain the second global logic code after form conversion; modifying the first page code and / or first component code based on the application instance difference smoothing code to obtain the second page code and / or second component code after form conversion; obtaining the modified code corresponding to the source code according to the application instance difference smoothing code, the second global logic code, the second page code, and / or the second component code; and compiling the modified code to obtain the target product.

[0113] Optionally, the compilation unit 403 is specifically used to: add code to the first global logic code to obtain the exported data of the application instance difference smoothing code; modify the initialization of the listening applet in the first global logic code to call the simulated listening applet initialization method included in the application instance difference smoothing code; wherein, the simulated listening applet initialization method is the method executed to initialize the life cycle in the simulated application instance life cycle; and obtain the second global logic code based on the above modifications.

[0114] Optionally, the compilation unit 403 is specifically used to: add code referencing the second global logic code and code for obtaining exported data of the application instance difference smoothing code in the first page code and / or the first component code; inject the simulated application instance calling method included in the application instance difference smoothing code into the first page code and / or the first component code to obtain the second page code and / or the second component code after morphological transformation.

[0115] Optionally, the application instance difference smoothing code includes: code for exporting a simulated application instance calling method; code for implementing the simulated application instance calling method; wherein the simulated application instance calling method achieves data isolation and sharing based on closures and prototype chains; code for exporting a simulated listening mini-program initialization method; and code for implementing the simulated listening mini-program initialization method.

[0116] Optionally, the compilation unit 403 is specifically used for: the source code before the form conversion includes first page code and / or first component code; in response to the form difference including a second difference, injecting the global style file in the source code into the first page code and / or first component code to obtain the form-converted second page code and / or second component code, obtaining the modified code corresponding to the source code based on the second page code and / or second component code, and compiling the modified code to obtain the target product; wherein, the second difference includes: when the source form is an independent mini-program and the target form is a mini-program plugin or mini-program sub-package, the difference between the source form and the target form related to the mini-program global style.

[0117] Optionally, the compilation unit 403 is specifically used to: add an import statement to inject the global style file at the beginning of the code file of the first page code and / or the first component code.

[0118] Optionally, the compilation unit 403 is specifically used to: determine whether the morphological difference includes a third difference; if so, based on the pre-set specifications that must be followed in generating the target product, during the compilation process of generating the target product, uniformly package the JS dependencies of each morphological product, including independent mini-programs, mini-program plugins, and mini-program subpackages, and extract the component library that the target product depends on into a specific component dependency folder; wherein, the third difference includes the differences between the source morphological form and the target morphological form related to the NPM component library.

[0119] Optionally, the compilation unit 403 is specifically used for: performing dependency analysis based on the entry configuration, compiling components and JS according to the results of the dependency analysis, grouping components after compilation, extracting components according to the component grouping results, merging and packaging mini-programs or independent mini-programs according to the target form, replacing the referenced components with the corresponding components under the target form, and outputting the target product.

[0120] Optionally, the pre-defined specifications for generating the target artifact include at least one of the following: directory structure specifications, multi-terminal component library specifications, and JS dependency library specifications.

[0121] Optionally, the compilation unit 403 is specifically used to: in response to a developer triggering a compilation command for a specified compilation type, load an entry configuration file corresponding to the target form from the source code; wherein the compilation type is specified based on the target form, and the entry configuration file includes the specified compilation type.

[0122] Optionally, the source form is an independent mini-program, and the target form is a mini-program subpackage; the compilation unit 403 is specifically used for: responding to the subpackage configuration file creation command input by the developer, generating a subpackage configuration file in the root directory of the mini-program project corresponding to the source code, wherein the subpackage configuration file is the entry configuration file corresponding to the target form of the mini-program subpackage; adding the specific page identifier to be compiled into the target subpackage input by the developer to the page configuration information included in the subpackage configuration file, wherein the specific page identifier corresponds to the specific page code included in the source code, and the page path of the specific page corresponding to the specific page identifier is composed of the subpackage identifier and its path of the target subpackage; obtaining the subpackage compilation configuration of the target subpackage, and adding the subpackage compilation configuration to the configuration file of the development framework or compiler applying the mini-program processing method; compiling the specific page code into the target subpackage according to the entry configuration file and the subpackage compilation configuration included in the configuration file of the development framework or compiler; wherein, the target subpackage is the target product, and the folder corresponding to the target product can provide the target mini-program function after being stored in the corresponding host.

[0123] Optionally, the device further includes a running unit, which is configured to: execute the application instance invocation method at runtime based on the target product to obtain the application instance as a hybrid product of the corresponding host and the target subpackage; wherein the attributes and methods of the host can be obtained through the host variables of the application instance.

[0124] Optionally, the source form is an independent mini-program, and the target form is a mini-program plugin; the compilation unit is further configured to: in response to a plugin configuration file creation command input by the developer, generate a plugin configuration file in the root directory of the mini-program project corresponding to the source code, wherein the plugin configuration file is the entry configuration file corresponding to the target form being a mini-program plugin; if the global configuration file of the source code includes sub-package configuration, add the page information of the sub-package configuration in the global configuration file to the page information of the plugin configuration file, wherein the page path of the added page information consists of the corresponding sub-package identifier and the path of the sub-package; if it is determined that the target plugin obtained by compiling the source code includes an open page, add the information of the open page to the open page variable in the plugin configuration file; obtain the plugin compilation configuration of the target plugin, and add the plugin compilation configuration to the configuration file of the development framework or compiler applying the mini-program processing method; the plugin compilation configuration includes at least: specifying the compilation type as a plugin; in response to the compilation command, perform injection on the source code according to the first difference between the source form and the target form to obtain the corresponding modified code, and compile the modified code into the target plugin according to the plugin configuration file and the plugin compilation configuration; wherein, the target plugin is the target product.

[0125] Optionally, the running unit is further configured to: implement the target plugin's external output of attributes and methods by calling the parent class of the application instance's calling method in the page logic file of the mini-program project.

[0126] Optionally, the source form is a mini-program plugin; the target form is a mini-program subpackage; the compilation unit 403 is further configured to: in response to a subpackage configuration file creation command input by the developer, generate a subpackage configuration file in the root directory of the mini-program project corresponding to the source code, wherein the subpackage configuration file is the entry configuration file corresponding to the target form of the mini-program subpackage; convert the information of the plugin configuration file included in the source code into a subpackage configuration and add it to the subpackage configuration file; obtain the subpackage compilation configuration and add the subpackage compilation configuration to the configuration file of the development framework or compiler that applies the mini-program processing method; in response to the compilation command, compile the source code into the target product according to the subpackage configuration file and the subpackage compilation configuration.

[0127] Optionally, the source form is a mini-program plugin or a mini-program sub-package; the target form is an independent mini-program; the compilation unit 403 is further configured to: obtain a global configuration file for the mini-program written by the developer; receive a specific configuration file modification by the developer for the development framework, such that the specific configuration file contains compilation configuration information for compiling and generating an independent mini-program, wherein the compilation configuration information contains a compilation type of an independent mini-program; and compile the source code according to the written global configuration file for the mini-program and the specific configuration file to obtain the target product.

[0128] Based on the above embodiments, the third embodiment of this application provides an electronic device. For relevant parts, please refer to the corresponding descriptions in the above embodiments. Figure 5 The electronic device shown in the figure includes a memory 501 and a processor 502; the memory is used to store a computer program, which, after being run by the processor, executes the method provided in the embodiments of this application.

[0129] Based on the above embodiments, the fourth embodiment of this application provides a computer storage medium. For relevant parts, please refer to the corresponding descriptions in the above embodiments. The schematic diagram of the computer storage medium is similar. Figure 5 The memory in the figure can be understood as the storage medium. The computer storage medium stores computer execution instructions, which, when executed by a processor, are used to implement the method provided in the embodiments of this application.

[0130] In a typical configuration, an electronic device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory. Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0131] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0132] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

Claims

1. A method for processing mini-programs, characterized in that, include: Obtain the source code of the target product to be generated; wherein, the target product is used to implement the functions of the target mini-program; The source code corresponds to the mini-program form as the source form, and the target product corresponds to the mini-program form as the target form. The form difference between the source form and the target form is determined. The source form includes one of the following mini-program forms: independent mini-program, mini-program plugin, mini-program sub-package; the target form is a mini-program form that is different from the source form. Based on the aforementioned morphological differences, the source code is adapted for compilation to generate the target product; including: when the source form is an independent mini-program and the target form is a mini-program plugin or mini-program sub-package, application instance difference smoothing code is injected during the compilation process; the application instance difference smoothing code is used to simulate the application instance lifecycle of the independent mini-program in the runtime environment of the target form, including simulating global application instance calling methods and simulating application startup lifecycle functions. The application instance difference smoothing code includes: code for exporting simulated application instance call methods; code for implementing the simulated application instance call methods; wherein the simulated application instance call methods achieve data isolation and sharing based on closures and prototype chains; code for exporting simulated listening mini-program initialization methods; and code for implementing the simulated listening mini-program initialization methods.

2. The method according to claim 1, characterized in that, The process of adapting the source code based on the morphological differences to generate the target product includes: In response to the morphological differences, including a first difference, code data for adapting to the target morphology is injected into the source code based on the first difference, and the target product is generated based on the injection; wherein, the first difference includes differences between the source morphology and the target morphology related to the global application instance of the mini-program.

3. The method according to claim 2, characterized in that, The source code before the transformation includes first global logic code, first page code, and / or first component code; The step of injecting code data to the source code to adapt to the target form according to the first difference, and generating the target product based on the injection, includes: Based on the application instance difference smoothing code, the first global logic code is modified to obtain the second global logic code after morphological transformation; Based on the application instance difference smoothing code, modify the first page code and / or the first component code to obtain the second page code and / or the second component code after morphological transformation; Based on the application instance difference smoothing code, the second global logic code, the second page code, and / or the second component code, the modified code corresponding to the source code is obtained; The modified code is compiled to obtain the target product.

4. The method according to claim 3, characterized in that, The modification of the first global logic code based on the application instance difference smoothing code to obtain the second global logic code after morphological transformation includes: Add code to the first global logic code to obtain the exported data of the application instance difference smoothing code; The initialization of the listening applet in the first global logic code is modified to call the simulated listening applet initialization method included in the application instance difference smoothing code; wherein, the simulated listening applet initialization method is the method executed during the initialization of the lifecycle in the simulated application instance lifecycle; The second global logic code is obtained based on the above modifications.

5. The method according to claim 4, characterized in that, The modification of the first page code and / or the first component code based on the application instance difference smoothing code to obtain the second page code and / or the second component code after morphological transformation includes: Add a reference to the second global logic code and add code for obtaining the exported data of the application instance difference smoothing code to the first page code and / or the first component code; Inject the simulated application instance call method, which is included in the application instance difference smoothing code, into the first page code and / or the first component code to obtain the second page code and / or the second component code after morphological transformation.

6. The method according to claim 1, characterized in that, The process of adapting the source code based on the morphological differences to generate the target product includes: The source code before the format conversion includes the first page code and / or the first component code; In response to the morphological difference including a second difference, the global style file in the source code is injected into the first page code and / or the first component code to obtain the morphologically transformed second page code and / or the second component code. Based on the second page code and / or the second component code, the modified code corresponding to the source code is obtained, and the modified code is compiled to obtain the target product. The second difference includes: when the source form is an independent mini-program and the target form is a mini-program plugin or mini-program sub-package, the differences between the source form and the target form related to the global style of the mini-program.

7. The method according to claim 6, characterized in that, The step of injecting the global style file from the source code into the first page code and / or the first component code includes: Add an import statement at the beginning of the code file for the first page and / or the first component to inject the global style file.

8. The method according to claim 1, characterized in that, The process of adapting the source code based on the morphological differences to generate the target product includes: In response to the aforementioned morphological differences, including the third difference, based on the pre-defined specifications that must be followed in generating the target product, during the compilation process of generating the target product, the JS dependencies of each morphological product, including independent mini-programs, mini-program plugins, and mini-program subpackages, are packaged in a unified manner, and the component libraries that the target product depends on are extracted into a specific component dependency folder. The third difference includes differences between the source form and the target form related to the NPM component library.

9. The method according to claim 8, characterized in that, During the compilation process of generating the target product, the JS dependencies of the independent mini-program, mini-program plugin, and mini-program sub-packages are packaged together, and the component libraries that the target product depends on are extracted into a specific component dependency folder, including: Dependency analysis is performed based on the entry configuration. Components and JS are compiled according to the results of the dependency analysis. After compilation, components are grouped and extracted according to the component grouping results. Mini-programs are split into packages or independent mini-programs are merged and packaged according to the target form. The referenced components are replaced with the corresponding components under the target form, and the target product is output.

10. The method according to claim 8, characterized in that, The pre-defined specifications that must be followed to generate the target artifact include at least one of the following: directory structure specifications, multi-terminal component library specifications, and JS dependency library specifications.

11. The method according to claim 1, characterized in that, The process of adapting the source code based on the morphological differences to generate the target product includes: In response to a developer triggering a compilation command for a specified compilation type, an entry configuration file corresponding to the target form is loaded from the source code; wherein the compilation type is specified based on the target form, and the entry configuration file includes the specified compilation type.

12. The method according to claim 11, characterized in that, The source form is an independent mini-program, and the target form is a mini-program sub-package; The method further includes: In response to the developer's command to create a subpackage configuration file, a subpackage configuration file is generated in the root directory of the mini-program project corresponding to the source code. The subpackage configuration file is the entry configuration file corresponding to the mini-program subpackage in the target form. The specific page identifier input by the developer to be compiled into the target subpackage is added to the page configuration information included in the subpackage configuration file. The specific page identifier corresponds to the specific page code included in the source code. The page path of the specific page corresponding to the specific page identifier is composed of the subpackage identifier of the target subpackage and its path. Obtain the subpackage compilation configuration of the target subpackage, and add the subpackage compilation configuration to the configuration file of the development framework or compiler that applies the mini-program processing method; The generation of the target product based on the injection includes: Based on the sub-package compilation configuration included in the entry configuration file and the configuration file of the development framework or compiler, the specific page code is compiled into the target sub-package; wherein, the target sub-package is the target product, and the folder corresponding to the target product can provide the target mini-program function after being stored in the corresponding host.

13. The method according to claim 12, characterized in that, Also includes: The application instance obtained by executing the application instance call method at runtime based on the target product is a hybrid product of the corresponding host and the target subpackage; wherein, the attributes and methods of the host can be obtained through the host variables of the application instance.

14. The method according to claim 11, characterized in that, The source form is an independent mini-program, and the target form is a mini-program plugin; The method further includes: In response to the plugin configuration file creation command input by the developer, a plugin configuration file is generated in the root directory of the mini-program project corresponding to the source code. The plugin configuration file is the entry configuration file corresponding to the target form of a mini-program plugin. If the global configuration file of the source code includes subpackage configuration, then the page information of the subpackage configuration in the global configuration file is added to the page information of the plugin configuration file. The page path of the added page information consists of the corresponding subpackage identifier and the path of the subpackage. If it is determined that the target plugin obtained by compiling the source code includes an open page, then the information of the open page is added to the open page variable in the plugin configuration file; Obtain the plugin compilation configuration of the target plugin, and add the plugin compilation configuration to the configuration file of the development framework or compiler that applies the mini-program processing method; the plugin compilation configuration includes at least: specifying the compilation type as plugin; In response to the compilation command, the source code is injected according to the first difference between the source form and the target form to obtain the corresponding modified code. The modified code is then compiled into the target plugin according to the plugin configuration file and the plugin compilation configuration; wherein the target plugin is the target artifact.

15. The method according to claim 14, characterized in that, Also includes: In the page logic file of the mini-program project, the target plugin outputs attributes and methods by calling the parent class of the application instance's calling method.

16. The method according to claim 11, characterized in that, The source form is a mini-program plugin; The target form is a mini-program subpackage; The method further includes: In response to the developer's command to create a subpackage configuration file, a subpackage configuration file is generated in the root directory of the mini-program project corresponding to the source code. The subpackage configuration file is the entry configuration file corresponding to the mini-program subpackage in the target form. The information in the plugin configuration file included in the source code is converted into a sub-package configuration and added to the sub-package configuration file; Obtain the subpackage compilation configuration and add the subpackage compilation configuration to the configuration file of the development framework or compiler that applies the mini-program processing method; In response to the compilation command, the source code is compiled into the target artifact according to the subpackage configuration file and the subpackage compilation configuration.

17. The method according to claim 1, characterized in that, Also includes: The source form is a mini-program plugin or a mini-program subpackage; The target format is an independent mini-program; The process of adapting the source code based on the morphological differences to generate the target product includes: Obtain the global configuration file of the mini-program written by the developer; The system receives modifications made by developers to a specific configuration file for the development framework, such that the specific configuration file contains compilation configuration information for compiling and generating an independent mini-program, wherein the compilation configuration information contains a compilation type of an independent mini-program. The target product is obtained by compiling the source code based on the global configuration file of the mini-program and the specific configuration file.

18. A mini-program processing device, characterized in that, include: The source code acquisition unit is used to acquire the source code of the target product to be generated; wherein the target product is used to implement the functions of the target mini-program. A morphological difference unit is used to take the mini-program form corresponding to the source code as the source form and the mini-program form corresponding to the target product as the target form, and determine the morphological difference between the source form and the target form; wherein, the source form includes one of the following mini-program forms: independent mini-program, mini-program plugin, mini-program sub-package; the target form is a mini-program form that is different from the source form; A compilation unit is used to adapt the source code based on the morphological differences to generate the target product; including: when the source form is an independent mini-program and the target form is a mini-program plugin or mini-program sub-package, injecting application instance difference smoothing code during the compilation process; the application instance difference smoothing code is used to simulate the application instance lifecycle of the independent mini-program in the runtime environment of the target form, including simulating global application instance call methods and simulating application startup lifecycle functions; wherein, the application instance difference smoothing code includes: code for deriving the simulated application instance call method; code for implementing the simulated application instance call method; wherein, the simulated application instance call method achieves data isolation and sharing based on closures and prototype chains; code for deriving the simulated listening mini-program initialization method; and code for implementing the simulated listening mini-program initialization method.

19. An electronic device, characterized in that, include: A memory and a processor; the memory is used to store a computer program, which, when executed by the processor, performs the method according to any one of claims 1-17.

20. A computer storage medium, characterized in that, The device stores computer execution instructions, which, when executed by a processor, are used to implement the method described in any one of claims 1-17.