A method, device and storage medium for reducing applet package size

CN116257296BActive Publication Date: 2026-10-27RAJAX NETWORK &TECHNOLOGY (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310121664.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-15
Publication Date
2026-10-27
Estimated Expiration
2043-02-15

AI Technical Summary

Technical Problem

那么,如何降低小程序的代码包的大小,避免小程序的代码包超体积的问题,是当前亟需要解决的难题

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116257296B_ABST
    Figure CN116257296B_ABST
Patent Text Reader

Abstract

The application provides a method, device and storage medium for reducing the size of a small program package, the method being applied to the field of electronic technology, the method comprising: obtaining source code of the small program; determining running configuration information of the small program according to the source code, the running configuration information being used for indicating a first runtime library associated in the process of running the small program and a first auxiliary function in the first runtime library; when a preset condition is met, determining a second auxiliary function associated with the first auxiliary function according to a preset mapping relationship; and calling and compiling the second auxiliary function to obtain the small program package, so that the size of the small program package can be reduced and the code package of the small program can be prevented from being oversized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic technology, and in particular to a method, apparatus and storage medium for reducing the size of a mini-program package. Background Technology

[0002] During the loading process of a mini-program, the client runs the mini-program's code package to initialize the mini-program and display its homepage to the user. The mini-program's code package is generally divided into one "main package" and multiple "sub-packages". The "main package" contains the code and related resources for the page that will open immediately when the mini-program starts, while the multiple "sub-packages" contain the remaining code and resources.

[0003] Currently, mini-programs have strict limits on code package size. Generally, the main package or a single sub-package cannot exceed 2MB, and the total size of all sub-packages in the entire mini-program cannot exceed 16MB. Therefore, how to reduce the size of the mini-program's code package and avoid exceeding the size limit is a pressing problem that needs to be solved. Summary of the Invention

[0004] This application provides a method, apparatus, and storage medium for reducing the size of a mini-program package. The method can reduce the size of the mini-program package and prevent the mini-program's code package from exceeding its size limit.

[0005] In a first aspect, a method for reducing the size of a mini-program package is provided, characterized in that the method includes: obtaining the source code of the mini-program; determining the runtime configuration information of the mini-program based on the source code, the runtime configuration information indicating a first runtime library associated with the mini-program during runtime and a first auxiliary function in the first runtime library; when a preset condition is met, determining a second auxiliary function associated with the first auxiliary function according to a preset mapping relationship; calling and compiling the second auxiliary function to obtain the mini-program package.

[0006] The above technical solution rewrites the introduced helper functions by trimming runtime helper functions, compressing unnecessary and redundant content, such as the description information of the helper functions; and extracts the useful parts of the helper functions, such as functional information. Furthermore, the functional information corresponding to the helper functions is compressed in a more optimized and compressed manner. Leveraging the mapping relationship between the native and new helper functions, the native parts are replaced with the optimized new helper functions. This reduces the size of the main package of the mini-program during the compilation of the new helper functions, solving the problem of the main package exceeding its size limit.

[0007] Optionally, this process can compress the functional content of the auxiliary function, such as its name, format, constants, variables, and processing methods, and delete the non-functional content related to the auxiliary function, such as function declarations and configurations.

[0008] In conjunction with the first aspect, in some implementations of the first aspect, when the preset conditions are met, the method further includes: replacing the first auxiliary function in the first runtime library with the second auxiliary function to obtain the updated second runtime library; deleting the first runtime library and injecting the second runtime library into the file header of the applet's source code.

[0009] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the method further includes: determining, based on the runtime configuration information, whether the first runtime library and the first auxiliary function satisfy the preset condition; when the first runtime library is any one of the preset runtime libraries, and / or the first auxiliary function is any one of the preset function list, determining that the preset condition is satisfied; when the first runtime library is not any one of the preset runtime libraries, and / or the first auxiliary function is not any one of the preset function list, determining that the preset condition is not satisfied.

[0010] In combination with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the method further includes: when the preset condition is not met, calling and compiling the first auxiliary function to obtain the applet package.

[0011] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the runtime configuration information is also used to indicate the working status of the application experiment feature plugin of the source code. The method further includes: determining whether the first runtime library and the first auxiliary function meet the preset condition based on the working status of the application experiment feature plugin of the source code; determining that the preset condition is met when the application experiment feature plugin of the source code is in the open state; and determining that the preset condition is not met when the application experiment feature plugin of the source code is in the closed state.

[0012] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the method further includes: determining whether the first auxiliary function satisfies the preset condition based on the preset function characteristics; when the first auxiliary function satisfies the preset function characteristics, determining that the preset condition is satisfied; when the first auxiliary function does not satisfy the preset function characteristics, determining that the preset condition is not satisfied.

[0013] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, when the first runtime library includes multiple first auxiliary functions, the method further includes: retaining the first first auxiliary function in the first runtime library and deleting the other first auxiliary functions.

[0014] In combination with the first aspect and the above implementation methods, in some implementation methods of the first aspect, when the source code of the applet includes a file that has already been processed by the first auxiliary function, the method further includes: ignoring the file that has already been processed by the first auxiliary function, so that the file is no longer processed.

[0015] Optionally, the first runtime library includes either tslib or babel / runtime.

[0016] Optionally, the functional information corresponding to the first auxiliary function includes one or more of the following: the name, format, constants, variables, and processing method of the first auxiliary function; and the descriptive information corresponding to the first auxiliary function includes one or more of the following: the function declaration and extended configuration of the first auxiliary function.

[0017] By using the method of this application embodiment, when running the code, the functions in the tslib runtime library and the @babel / runtime runtime library will no longer be run according to the path in the existing solution, that is, there will be no redundant parts; furthermore, the auxiliary functions required for running are compressed, and the size of the code package is reduced by referencing newly created objects.

[0018] Secondly, a method for running a mini-program is provided, the method comprising: obtaining the source code of the mini-program; running the mini-program according to the source code, wherein the running of the mini-program depends on a second runtime library associated with the source code and a second auxiliary function in the second runtime library.

[0019] In conjunction with the second aspect, in some implementations of the second aspect, the second runtime library is obtained by updating the first runtime library after replacing the first auxiliary function in the first runtime library with the second auxiliary function, and the second auxiliary function is obtained by trimming the first auxiliary function in the first runtime library.

[0020] In combination with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the first auxiliary function and the second auxiliary function have a preset mapping relationship.

[0021] In combination with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the first auxiliary function includes corresponding functional information and descriptive information, and the second auxiliary function is obtained by compressing the functional information corresponding to the first auxiliary function.

[0022] In combination with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the first runtime library is any one of the preset runtime libraries; or, the first auxiliary function is any one of the preset function lists; or, the first auxiliary function conforms to the preset function characteristics.

[0023] In combination with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the application experiment feature plugin in the source code is enabled.

[0024] In combination with the second aspect and the above implementation methods, in some implementation methods of the second aspect, when the first runtime library includes multiple first auxiliary functions, during the process of replacing the first auxiliary function in the first runtime library with the second auxiliary function, one second auxiliary function is retained in the second runtime library.

[0025] In combination with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the first runtime library includes either tslib or babel / runtime.

[0026] In conjunction with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the functional information corresponding to the first auxiliary function includes one or more of the following: the name, format, constants, variables, and processing method of the first auxiliary function; and the descriptive information corresponding to the first auxiliary function includes one or more of the following: the function declaration and extended configuration of the first auxiliary function. A third aspect provides an apparatus for reducing the size of a mini-program package, characterized by comprising: an acquisition module, which, in response to an instruction to run the mini-program, acquires the source code of the mini-program; a processing module, configured to determine the runtime configuration information of the mini-program based on the source code, the runtime configuration information indicating a first runtime library associated with the mini-program during runtime and a first auxiliary function in the first runtime library, the first auxiliary function including corresponding functional information and descriptive information; the processing module is further configured to, when a preset condition is met, determine a second auxiliary function associated with the first auxiliary function according to a preset mapping relationship, the second auxiliary function being obtained by compression processing based on the functional information corresponding to the first auxiliary function; and a compilation module, configured to call and compile the second auxiliary function to obtain the mini-program package.

[0027] In conjunction with the third aspect, in some implementations of the third aspect, the apparatus further includes: a replacement module for replacing the first auxiliary function in the first runtime library with the second auxiliary function to obtain an updated second runtime library; and a deletion module for deleting the first runtime library and injecting the second runtime library into the file header of the applet's source code.

[0028] In conjunction with the third aspect and the above implementation methods, in some implementation methods of the third aspect, the processing module is further configured to: determine whether the first runtime library and the first auxiliary function satisfy the preset condition based on the runtime configuration information; when the first runtime library is any one of the preset runtime libraries, and / or the first auxiliary function is any one of the preset function list, determine that the preset condition is satisfied; when the first runtime library is not any one of the preset runtime libraries, and / or the first auxiliary function is not any one of the preset function list, determine that the preset condition is not satisfied.

[0029] In combination with the third aspect and the above implementation methods, in some implementation methods of the third aspect, the processing module is also used to call and compile the first auxiliary function to obtain the applet package when the preset condition is not met.

[0030] In conjunction with the third aspect and the above implementation methods, in some implementation methods of the third aspect, the runtime configuration information is also used to indicate the working status of the application experiment feature plugin of the source code, and the processing module is also used to: determine whether the first runtime library and the first auxiliary function meet the preset conditions based on the working status of the application experiment feature plugin of the source code; when the application experiment feature plugin of the source code is in the open state, determine that the preset conditions are met; when the application experiment feature plugin of the source code is in the closed state, determine that the preset conditions are not met.

[0031] In conjunction with the third aspect and the above implementation methods, in some implementation methods of the third aspect, the processing module is further configured to: determine whether the first auxiliary function satisfies the preset condition based on the preset function characteristics; when the first auxiliary function satisfies the preset function characteristics, determine that the preset condition is satisfied; when the first auxiliary function does not satisfy the preset function characteristics, determine that the preset condition is not satisfied.

[0032] In conjunction with the third aspect and the above implementation methods, in some implementation methods of the third aspect, when the first runtime library includes multiple first auxiliary functions, the processing module is further configured to: retain the first first auxiliary function in the first runtime library and delete the other first auxiliary functions.

[0033] In conjunction with the third aspect and the above implementation methods, in some implementation methods of the third aspect, the processing module is also used to: when the source code of the applet includes a file that has already been processed by the first auxiliary function, ignore the file that has already been processed by the first auxiliary function, so that the file is no longer processed.

[0034] Combining the third aspect and the above implementation methods, in some implementations of the third aspect, the first runtime library includes either tslib or babel / runtime.

[0035] In combination with the third aspect and the above implementation methods, in some implementation methods of the third aspect, the functional information corresponding to the first auxiliary function includes one or more of the following: the name, format, constants, variables, and processing method of the first auxiliary function; and the descriptive information corresponding to the first auxiliary function includes one or more of the following: the function declaration and extended configuration of the first auxiliary function.

[0036] Fourthly, a device for running a mini-program is provided, the device comprising: an acquisition module for acquiring the source code of the mini-program; and a running module for running the mini-program according to the source code, wherein the running of the mini-program depends on a second runtime library associated with the source code and a second auxiliary function in the second runtime library.

[0037] In conjunction with the fourth aspect, in some implementations of the fourth aspect, the second runtime library is obtained by updating the first runtime library after replacing the first auxiliary function in the first runtime library with the second auxiliary function, and the second auxiliary function is obtained by trimming the first auxiliary function in the first runtime library.

[0038] Combining the fourth aspect and the above implementation methods, in some implementation methods of the fourth aspect, the first auxiliary function and the second auxiliary function have a preset mapping relationship.

[0039] In combination with the fourth aspect and the above implementation methods, in some implementation methods of the fourth aspect, the first auxiliary function includes corresponding functional information and descriptive information, and the second auxiliary function is obtained by compressing the functional information corresponding to the first auxiliary function.

[0040] In combination with the fourth aspect and the above implementation methods, in some implementation methods of the fourth aspect, the first runtime library is any one of the preset runtime libraries; or, the first auxiliary function is any one of the preset function lists; or, the first auxiliary function conforms to the preset function characteristics.

[0041] Combining the fourth aspect and the above implementation methods, in some implementation methods of the fourth aspect, the application experiment feature plugin in the source code is enabled.

[0042] In combination with the fourth aspect and the above implementation methods, in some implementation methods of the fourth aspect, when the first runtime library includes multiple first auxiliary functions, during the process of replacing the first auxiliary function in the first runtime library with the second auxiliary function, one second auxiliary function is retained in the second runtime library.

[0043] Combining the fourth aspect and the above implementation methods, in some implementations of the fourth aspect, the first runtime library includes either tslib or babel / runtime.

[0044] In conjunction with the fourth aspect and the above implementation methods, in some implementation methods of the fourth aspect, the functional information corresponding to the first auxiliary function includes one or more of the following: the name, format, constants, variables, and processing method of the first auxiliary function; the descriptive information corresponding to the first auxiliary function includes one or more of the following: the function declaration and extended configuration of the first auxiliary function. Fifth aspect: An electronic device is provided, characterized in that it includes: one or more processors; one or more memories; a module with multiple applications installed; the memories store one or more programs, which, when executed by the processor, cause the electronic device to perform the method of the first aspect and any one of the first aspects, or to perform the method of the second aspect and any one of the second aspects.

[0045] A sixth aspect provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the method of the first aspect and any one of the first aspects, or to perform the method of the second aspect and any one of the second aspects.

[0046] In a seventh aspect, a computer program product is provided, characterized in that, when the computer program product is run on a computer, it causes the computer to perform the method of the first aspect and any one of the first aspects, or to perform the method of the second aspect and any one of the second aspects. Attached Figure Description

[0047] Figure 1 This is a flowchart of a method for reducing the size of a mini-program package provided in an embodiment of this application.

[0048] Figure 2 This is a schematic flowchart illustrating the pre-check process of a plug-in provided in an embodiment of this application.

[0049] Figure 3 This is a schematic flowchart illustrating an example of a trimming auxiliary function provided in an embodiment of this application.

[0050] Figure 4 This is a flowchart of an example of a mini-program operation method provided in this application embodiment.

[0051] Figure 5 This is a schematic diagram of an apparatus for reducing the size of a mini-program package provided in an embodiment of this application.

[0052] Figure 6 This is a schematic diagram of an example of a mini-program running device provided in an embodiment of this application.

[0053] Figure 7 This is a schematic diagram of the physical structure of an electronic device capable of installing mini-programs. Detailed Implementation

[0054] To facilitate understanding, the following will describe in detail, with reference to the accompanying drawings, a method for reducing the size of a mini-program package provided in this application.

[0055] During the process of running the code package of a mini-program, tslib and @babel / runtime are commonly used runtime libraries. After compiling and transforming the functions in tslib and @babel / runtime, some function declarations can be injected into the code, which we call "helper functions".

[0056] For example, the "tslib helper functions (ts helpers)" compiled from the tslib runtime library, and the "@babel / runtime helper functions (@babel / runtimehelpers)" compiled from the @babel / runtime runtime library.

[0057] It should be understood that "tslib" is the runtime library for TypeScript, which contains commonly used TypeScript helper functions and is one of the commonly used runtime dependency libraries. "@babel / runtime" is the runtime library for Babel syntax transformations, which integrates helper functions used in common syntax transformations and is also one of the commonly used runtime dependency libraries.

[0058] For example, Table 1 is a list of names of tslib helper functions listed in this application, and Table 2 is a list of names of @babel / runtime helper functions listed in this application.

[0059] It should be noted that Tables 1 and 2 are merely examples. Different runtime libraries provided in this application embodiment may include more or fewer auxiliary functions, which will not be elaborated here.

[0060] Table 1

[0061]

[0062] Table 2

[0063]

[0064] It should be understood that the above process of compiling and converting runtime library functions ensures that even if our TypeScript and Babel conversion uses certain ES6 features, the final generated code will be compatible with them, thus guaranteeing the normal operation of the mini-program.

[0065] However, the helper functions imported from the tslib runtime library and the @babel / runtime runtime library will result in a larger output size, i.e. a larger program package size, which will lead to the problem of the mini-program's code package exceeding the size limit.

[0066] Therefore, this application provides a method for reducing the size of a mini-program package, which can effectively reduce the size of the package and improve the runtime performance of the mini-program code package.

[0067] It should be noted that the method for reducing the size of a mini-program package provided in this application embodiment can be applied to any application (APP) that can load mini-programs. In other words, the method for reducing the size of a mini-program package provided in this application embodiment can be applied to any electronic device that can load mini-programs, such as mobile phones, tablets, and in-vehicle devices. This application embodiment does not limit the type of application or the type of electronic device.

[0068] Specifically, this application can remove redundant parts of runtime helper functions by trimming them.

[0069] Optionally, the auxiliary function information may include corresponding functional information and descriptive information. The functional information may include one or more of the following: the name, format, constants, variables, and processing method of the auxiliary function. The descriptive information of the auxiliary function may include one or more of the following: the function declaration and extended configuration of the auxiliary function.

[0070] In this embodiment, redundant content such as function declarations and extended configurations in the auxiliary function can be removed, and then one or more pieces of information from the auxiliary function's function name, format, constants, variables, and processing method can be compressed to generate a new auxiliary function, namely a "new object". The mini-program package can be obtained by referencing and compiling the new auxiliary function ("new object"), thereby reducing the size of the code package after the mini-program runs.

[0071] Figure 1 This is a flowchart illustrating a method for reducing the size of a mini-program package according to an embodiment of this application. For example, as shown... Figure 1 As shown, the method includes:

[0072] S110, obtain the source code of the mini-program.

[0073] Optionally, the "instruction to run the mini-program" can be a process initiated by the developer during the development process, such as the compilation process, and the "source code of the mini-program" can be understood as the essential running program in the process of starting the mini-program. This application embodiment will not elaborate on this further.

[0074] S120, Based on the source code, determine the runtime configuration information of the mini-program. The runtime configuration information is used to indicate the first runtime library associated with the mini-program and the first auxiliary function in the first runtime library.

[0075] Optionally, the first auxiliary function includes corresponding functional information and descriptive information.

[0076] Optionally, the "running configuration information" in this application embodiment can be obtained from the source code of the applet.

[0077] For example, "Runtime Configuration Information" can indicate the runtime libraries that need to be called during the operation of the applet, such as the tslib runtime library and the @babel / runtime runtime library mentioned above, as well as the helper functions imported in the tslib runtime library and the @babel / runtime runtime library. This application embodiment does not limit this.

[0078] Optionally, the first runtime library may include either tslib or babel / runtime.

[0079] For example, when the first runtime library is the tslib runtime library, the first auxiliary function can be any one of the functions in Table 1 above; when the first runtime library is the babel / runtime runtime library, the first auxiliary function can be any one of the functions in Table 2 above. This application embodiment does not limit this.

[0080] Optionally, the functional information corresponding to the first auxiliary function may include one or more of the following: the name, format, constants, variables, and processing method of the first auxiliary function; and the descriptive information corresponding to the first auxiliary function may include one or more of the following: the function declaration and extended configuration of the first auxiliary function.

[0081] It should be understood that in the embodiments of this application, the "first auxiliary function" can be understood as a native auxiliary function in the native runtime library. The first auxiliary function may include functional information of multiple statements and descriptive information of multiple statements, or "non-functional content".

[0082] S130, when the preset conditions are met, determine the second auxiliary function associated with the first auxiliary function according to the preset mapping relationship.

[0083] Optionally, the second auxiliary function is obtained by compressing the functional information corresponding to the first auxiliary function.

[0084] It should be understood that the second auxiliary function is a new auxiliary function generated based on some statements of the first auxiliary function, such as the name, format, constants, variables, processing methods, or other functional information of the first auxiliary function. In other words, the second auxiliary function does not include the function declaration, extended configuration, or other non-functional information of the auxiliary function.

[0085] Optionally, the name of the second auxiliary function may be different from the name of the first auxiliary function. For example, the name of the second auxiliary function may be generated by compressing or otherwise processing the name of the first auxiliary function.

[0086] S140, call and compile the second helper function to obtain the small program package.

[0087] In one possible implementation, the method further includes: determining, based on the runtime configuration information, whether the first runtime library and the first auxiliary function satisfy the preset condition; when the first runtime library is any one of the preset runtime libraries, and / or the first auxiliary function is any one of the preset function list, determining that the preset condition is satisfied; when the first runtime library is not any one of the preset runtime libraries, and / or the first auxiliary function is not any one of the preset function list, determining that the preset condition is not satisfied.

[0088] In another possible implementation, the method also includes: when the preset condition is not met, calling and compiling the first auxiliary function to obtain the applet package.

[0089] In another possible implementation, the runtime configuration information is also used to indicate the working status of the application experiment feature plugin of the source code. The method further includes: determining whether the first runtime library and the first auxiliary function meet the preset condition based on the working status of the application experiment feature plugin of the source code; determining that the preset condition is met when the application experiment feature plugin of the source code is in the open state; and determining that the preset condition is not met when the application experiment feature plugin of the source code is in the closed state.

[0090] In another possible implementation, the method further includes: determining whether the first auxiliary function satisfies the preset condition based on the preset function characteristics; when the first auxiliary function satisfies the preset function characteristics, determining that the preset condition is satisfied; when the first auxiliary function does not satisfy the preset function characteristics, determining that the preset condition is not satisfied.

[0091] For example, experimental feature plugins can be applied to the constructor of a class method whose compilation functionality is extracted separately. The pruning helper function plugin needs to undergo some pre-checks. Only if the checks pass can the relevant webpack configuration be added and the pruning helper function be used.

[0092] Therefore, before introducing the process of the trimming auxiliary function provided in the embodiments of this application, it is necessary to perform a pre-check on the plugin of the code package. It should be understood that the pre-check process of the plugin can be understood as the process of determining whether the preset conditions are met in the aforementioned S130.

[0093] Figure 2 This is a schematic flowchart illustrating the pre-check process of an example plugin provided in an embodiment of this application. For example, as shown... Figure 2 As shown, the pre-check process for the plugin includes:

[0094] S201, entering the compilation process.

[0095] It should be understood that, in addition to the “compilation process” involved in the embodiments of this application, the operation of the mini program may also involve “non-compilation processes” such as initialization process, packaging process, and integration process.

[0096] The "non-compilation process" can be used to process related data, but it does not involve the final product of code compilation. In other words, the "non-compilation process" does not involve the process of compiling the mini-program source code into the mini-program main package. Therefore, the process of triggering the trimming auxiliary function provided in the embodiments of this application will only be involved in the "compilation process".

[0097] S202, determine whether the experimental feature plugin has been applied.

[0098] In one possible implementation, the application of the experimental feature plugin can be determined through the runtime configuration information in the source code. It should be understood that the experimental feature plugin indicates whether the code has enabled the automatic pruning helper function. In other words, S202 is the process of determining whether the code has configured the experimental feature plugin that enables the automatic pruning helper function.

[0099] It should be understood that in the embodiments of this application, "experiments" may be features that include automatic cropping auxiliary functions.

[0100] It should also be understood that the experimental feature plugin in S202 can be understood as a master switch, which can include the control of various function switches, which will not be elaborated here.

[0101] Optionally, the "experimental feature" can be configured as a switch in the named line of code. Users can determine whether the current "experimental feature" is on or off by reading and judging the named line of code as needed.

[0102]

Scenario 1

[0103] When the configuration switch of the "experimental feature" is determined to be in the "on" state, for example, the configuration switch of the "experimental feature" is "true", that is, the function of automatic trimming auxiliary function is enabled, and the process of automatic trimming auxiliary function described in S203-S208 can be further executed to compress the size of the main package product.

[0104] S203 determines whether the command is a compilation command.

[0105] It should be understood that before receiving a command to start running the code, it can first check whether the command is a compile command. For non-compile commands, it can be skipped directly. When the command is a compile command, the S204 process can be further executed.

[0106] S204 determines whether the automatic cropping auxiliary function is enabled. It should be understood that "determining whether the automatic cropping auxiliary function is enabled" in S204 can be considered a sub-switch under the main switch of S202.

[0107] S205 determines whether there are dependencies associated with tslib helper functions or @babel / runtime helper functions.

[0108] Procedures S206-S207 can be executed when the code contains dependencies (exterals) associated with tslib helper functions or @babel / runtime helper functions.

[0109] S206, added the ability to use trimming helper functions for mounting related configurations.

[0110] S207 returns the plugin result and executes the subsequent compilation process.

[0111] In other words, it determines whether the current project uses the tslib runtime library or the @babel / runtime runtime library. When it detects that the code contains dependencies (exterals) associated with tslib helper functions or @babel / runtime helper functions, it can add the functionality to mount the relevant webpack configuration to use automatic trimming of helper functions (trimRuntimeHelpers). After the helper functions are trimmed, the subsequent compilation process is executed according to the newly generated helper functions.

[0112] Procedures S208 and S207 can be executed when the code does not contain any dependencies (exterals) associated with tslib helper functions or @babel / runtime helper functions.

[0113] S208 issues a warning for missing dependencies.

[0114] S207 returns the plugin result and executes the subsequent compilation process.

[0115] When it is detected that the current project does not use the tslib runtime library or the @babel / runtime runtime library involved in the embodiments of this application, the current trimming process can be skipped and the compilation process can be directly entered. At the same time, a warning will be issued for the lack of relevant dependencies.

[0116] Scenario 2

[0117] When the configuration switch for the "experimental feature" is detected to be off, for example, if the configuration switch for the "experimental feature" is "false", it can be understood that some development processes do not need to involve the size of the main package's output, and this solution can be skipped directly, proceeding to process S109:

[0118] S209 calls the native helper function.

[0119] It should be understood that "native helper functions" refers to the commonly used tslib runtime library and @babel / runtime runtime library in the original code without any modification. In other words, the program can be run by calling the helper functions of the native runtime library according to the existing scheme, which will not be elaborated here.

[0120] After the plugin's pre-check process is complete, and webpack mounts the functionality using the trimming helper function (trimRuntimeHelpers), it provides a relevant loader method. This method ultimately returns the processed fileContent content. The process of the trimming helper function in S206 of this embodiment is described in detail below with reference to the accompanying drawings.

[0121] Figure 3 This is a schematic flowchart illustrating the process of a trimming auxiliary function provided in an embodiment of this application. For example, as shown... Figure 3 As shown, the method 300 includes:

[0122] S301, load support.

[0123] This process can be understood as a built-in capability of webpack. Or, in other words, it involves... Figure 2 After the plugin's pre-check, it meets the preset conditions of this application, namely, it has the ability to automatically trim auxiliary functions.

[0124] S302 ignores the native tslib runtime library and the @babel / runtime runtime library based on the loaded path (resourcePath).

[0125] In one possible implementation, when the first runtime library includes multiple first helper functions, the method further includes: retaining the first first helper function in the first runtime library and deleting the other first helper functions.

[0126] Here, "loaded path (resourcePath)" can be understood as the path of the files in the current project that need to use the tslib runtime library and the helper functions in the @babel / runtime runtime library; "ignore" can be understood as deletion, that is, deleting the path of the native helper function files, and will no longer call the native tslib runtime library and the helper functions in the @babel / runtime runtime library.

[0127] One possible implementation is to configure an ignore setting in the code, for example, by setting the ignore switch to "true". In this case, it's equivalent to removing the paths in the code that call native helper functions in the original tslib runtime library and the @babel / runtime runtime library. In other words, when running this code, it will no longer execute functions in the tslib and @babel / runtime runtime libraries according to the paths in the existing solution.

[0128] For example, this can be achieved using the following code:

[0129] if( / (@babel.runtime|tslib)(\ / |\\) / .test(resourcePath))returnfileContent

[0130] It should be understood that when compiling native helper functions, the compiled code will inject redundant parts such as function declarations. In this embodiment, the redundant parts such as function declarations and extended configurations are referred to as "description information" or "non-functional information." It should be noted that in the process of creating new objects for helper functions with different names, this embodiment can trim or delete the description information (non-functional information) in each helper function, and then compress the functional information to obtain a newly generated helper function for each helper function.

[0131] In one possible implementation, when preset conditions are met, the description information (i.e., non-functional information) of the first auxiliary function in the native first runtime library can be deleted, and the second auxiliary function can be generated based on the first auxiliary function after the description information has been deleted.

[0132] Optionally, this application can compress a first auxiliary function (after deleting the descriptive information) to generate a second auxiliary function. Alternatively, it can compress the functional information corresponding to the first auxiliary function to obtain the second auxiliary function.

[0133] It should be understood that the "compression processing" in the embodiments of this application may include shortening function names, simplifying variable definitions, etc., and the embodiments of this application do not limit this.

[0134] Optionally, the functional information corresponding to the first auxiliary function may include one or more information such as the name, format, constants, variables, and processing method of the first auxiliary function, and the descriptive information corresponding to the first auxiliary function may include one or more information such as the function declaration and extended configuration of the first auxiliary function. This application embodiment does not limit this.

[0135] Optionally, this application can establish a mapping relationship between the first auxiliary function and the newly generated second auxiliary function, and based on this mapping relationship, replace the first auxiliary function with the newly generated second auxiliary function without changing the source code, so that the second auxiliary function can participate in the running process of the mini-program.

[0136] Through the above implementation process, this application embodiment will no longer call functions in the tslib runtime library and the @babel / runtime runtime library according to the path in the existing solution. Specifically, this application embodiment can first delete "non-functional information" such as function declarations in the native helper functions, then compress the helper functions after deleting the non-functional information, and establish a mapping relationship between the native helper functions and the newly obtained compressed helper functions. By referencing, the newly obtained compressed helper functions are called, thereby running the mini-program and reducing the size of the mini-program's code package.

[0137] For example, Table 3 shows the newly created objects corresponding to tslib helper functions with different names. Table 3 can also represent the mapping relationship between tslib helper functions with different names and newly created objects.

[0138] Similarly, Table 4 shows the newly created objects corresponding to different names of @babel / runtime helper functions. Table 4 can also represent the mapping relationship between different names of @babel / runtime helper functions and newly created objects.

[0139] For example, when the first runtime library is the tslib runtime library, the first auxiliary function can be any function in Table 3 above, and the second auxiliary function is the corresponding associated object in Table 3; when the first runtime library is the babel / runtime runtime library, the first auxiliary function can be any function in Table 4 above, and the second auxiliary function is the corresponding associated object in Table 4. This application embodiment does not limit this.

[0140] Optionally, the second helper function of the newly created object may include only functional information and no longer include descriptive information (non-functional information).

[0141] For example, taking the tslib helper function 'extend' in Table 3 as an example, the function declaration, extended configuration and other descriptive information in 'extend' are deleted, and one or more functional information such as name, format, constant, variable, processing method, etc. in 'extend' are compressed to obtain function "a", thereby reducing the size of the mini program's code package after running the mini program.

[0142] It should be understood that a mapping relationship is established between 'extend' and 'a', and the functional characteristics of 'extend' can be marked, while 'a' has the same functional characteristics as 'extend'.

[0143] For example, this process can be implemented using the following code:

[0144] Const TSLIB_REGEXP=new RegExp(`var_(${TSLIB_HELPERS.join('1')})=`,'g')

[0145] Table 3

[0146] 'extend' a 'rest' g 'decorate' b 'metadata' h 'exportStar' c 'read' i 'spreadArray' d 'await' j 'asyncDelegator' e 'makeTemplateObject' k 'importDefault' f 'classPrivateFieldSet' l … … … …

[0147] Table 4

[0148] 'inheristLoose' m 'intializerWarningHelper' n 'arrayWithHoles' o 'isNativeReflectConstruct' p 'asyncToGenerator' q 'initializerDefineProperty' r 'arraylikeToArray' s 'interopRequireWildcard' t 'asyncIterator' u 'iterableToArrayLimit' v … …

[0149] Similarly, the @babel / runtime helper functions in Table 4 can also have a similar processing procedure, which will not be elaborated here for the sake of simplicity.

[0150] During the process of trimming auxiliary functions, the auxiliary functions can be determined from the source code in the following ways. For example:

[0151] (1) Get the starting string traversal position of the source code; if not found, exit this method.

[0152] (2) The condition for determining the starting point of the auxiliary function is the position of the first left curly brace "{". The length of the entire auxiliary function is obtained. The ending condition is: the number of curly brace pairs and the number of parentheses pairs are both 0; or, the last character of the ts auxiliary function is ";"; or, the last character of the @babel / runtime auxiliary function is a right curly brace "}".

[0153] It should be noted that if the number of pairs of curly braces and the number of pairs of parentheses are negative, it indicates a logic error in the check, and the subsequent replacement logic should be skipped.

[0154] Through the above process, by creating a new object that has been trimmed and compressed, and associating the new object with the native helper function, the foundation is laid for replacing the larger native helper function with the new object.

[0155] S303 ignores files that have already been processed by webpack based on the build requirements (webpack_require).

[0156] It should be understood that after the S303 process, the helper function files in the tslib runtime library and the @babel / runtime runtime library have been completely removed. The S203 process is mainly used to filter out non-business class files that have been processed by the native tslib runtime library and the helper functions in the @babel / runtime runtime library. In other words, webpack files that have already been processed do not need to be processed again.

[0157] For example, this can be achieved using the following code:

[0158] if( / __webpack_require__ / .test(fileContent))return fileContent

[0159] S304: Based on the characteristics of tslib auxiliary functions, check the auxiliary functions. Those that are matched by regenerator will directly proceed to the processing steps S305-S308:

[0160] S305, deduplication. For example: if multiple functions with the same name appear, only the first function is processed. The execution code can be as follows: matchResult = Array.from(new Set(matchResult)).

[0161] In one possible implementation, the method can replace the first auxiliary function in the first runtime library with a second auxiliary function to obtain an updated second runtime library; then delete the first runtime library and inject the second runtime library into the file header of the applet's source code. This corresponds to processes S306-S307.

[0162] S306: Iterate through the matched auxiliary functions and trim or replace them.

[0163] It should be understood that the S306 process can be understood as a process of trimming and replacing all auxiliary functions in the runtime library that meet the preset conditions.

[0164] Optionally, referring to the description of the foregoing embodiments, one or more non-functional information in the function declaration and extended configuration of the first auxiliary function can be deleted, and one or more functional information such as the name, format, constants, variables, and processing methods corresponding to the first auxiliary function can be compressed to generate a new second auxiliary function. The second auxiliary function can then replace the first auxiliary function to obtain a new second runtime library.

[0165] S307, inject tslib into the file header.

[0166] It should be understood that after generating the new helper functions, a new second runtime library can be generated and injected as a whole into the file header, thus replacing the original first runtime library.

[0167] S308, returns the processed filecontent.

[0168] In S304, when checking the ts helpers features based on the tslib helper function features, if the features were not processed by the regenerator, further processing steps S309-S314 can be performed:

[0169] S309 checks if the `@babel / runtime` helper function is matched based on its characteristics. Functions that are matched via regenerator are directly processed according to steps S310-S313.

[0170] S310, deduplication. For example: if multiple functions with the same name appear, only the first function is processed. The execution code can be as follows: matchResult = Array.from(new Set(matchResult)).

[0171] S311: Iterate through the matched auxiliary functions and trim or replace them.

[0172] S312, inject @babel / runtime in the file header. It should be understood that this involves trimming helper functions for each method and replacing the methods in the native helper functions with references to tslib and @babel / runtime.

[0173] S313 returns the processed filecontent.

[0174] It should be understood that Babel's replacement is handled in reverse, because Babel references are all inserted at the beginning of the code, which can be achieved with the following code:

[0175] if(helperType===HELPER_TYPE.BABEL)matchResult=matchResult.reverse()

[0176] For example, several variables can be defined in the source code for use by the trimming helper function flow. For instance:

[0177] (1) isESModule is used to determine whether it is an ES module.

[0178] (2) MAPPERS, used to select mappers.

[0179] (3) END_CHAR, used by ts helper to use ";" as the end, and babel runtime helper to use "}" as the end.

[0180] (4) DEFAULT_PARENTHESIS_PAIR_COUNT is used to confirm that the babel feature contains OPEN_PARENTHESIS.

[0181] It should be noted that, Figure 3 In the method shown, S304 and S309 can be performed simultaneously or sequentially, and this application embodiment does not limit this.

[0182] also, Figure 3 In the method shown, processes S305-S308 and S309-S313 can be performed simultaneously or sequentially, and this application embodiment does not limit this.

[0183] Figure 4 This is a flowchart of an example of a mini-program operation method provided in this application embodiment.

[0184] It should be understood that Figure 4 The process of executing the embodiments of this application is described from the perspective of the user loading the mini-program through an electronic device or an application. For example, as shown below... Figure 4 As shown, the method includes:

[0185] S410, retrieve the source code of the mini-program.

[0186] S420, Based on the source code, run the applet, the operation of the applet depends on the second runtime library associated with the source code and the second auxiliary function in the second runtime library.

[0187] In one possible implementation, the second runtime library is obtained by updating the first runtime library after replacing the first auxiliary function in the first runtime library with the second auxiliary function, and the second auxiliary function is obtained by trimming the first auxiliary function in the first runtime library.

[0188] In another possible implementation, the first auxiliary function and the second auxiliary function have a preset mapping relationship.

[0189] In another possible implementation, the first auxiliary function includes corresponding functional information and descriptive information, and the second auxiliary function is obtained by compressing the functional information corresponding to the first auxiliary function.

[0190] Optionally, the first runtime library is any one of the preset runtime libraries; or, the first auxiliary function is any one of the preset function lists; or, the first auxiliary function conforms to the preset function characteristics.

[0191] Optionally, the first runtime library includes either tslib or babel / runtime.

[0192] In another possible implementation, the application experiment feature plugin in the source code is enabled.

[0193] Optionally, when the first runtime library includes multiple first auxiliary functions, during the process of replacing the first auxiliary functions in the first runtime library with the second auxiliary functions, one second auxiliary function is retained in the second runtime library.

[0194] Optionally, the functional information corresponding to the first auxiliary function includes one or more of the following: the name, format, constants, variables, and processing method of the first auxiliary function; and the descriptive information corresponding to the first auxiliary function includes one or more of the following: the function declaration and extended configuration of the first auxiliary function.

[0195] It should be noted here that the above regarding Figure 4 The steps, definitions, and implementation processes can all be referred to in the foregoing. Figures 1 to 3For the sake of simplicity, the process will not be described in detail in the embodiments of this application.

[0196] In summary, the method for reducing the size of a mini-program package provided in this application embodiment can provide runtime dependency replacement for a first auxiliary function that meets preset conditions based on the characteristics of the auxiliary function. Specifically, during the processing, redundant non-functional information such as function declarations and extended configurations in the node_modules of the first auxiliary function can be removed. Then, the auxiliary function after removing the non-functional information is compressed, and a mapping relationship is established between the original auxiliary function and the compressed new auxiliary function. The compressed new auxiliary function is called by reference, thereby running the mini-program and reducing the size of the mini-program's code package.

[0197] The above technical solution rewrites the introduced helper functions by trimming runtime helper functions, compressing unnecessary and redundant content, such as the description information of the helper functions; and extracts the useful parts of the helper functions, such as functional information. Furthermore, the functional information corresponding to the helper functions is compressed in a more optimized and compressed manner. Leveraging the mapping relationship between the native and new helper functions, the native parts are replaced with the optimized new helper functions. This reduces the size of the main package of the mini-program during the compilation of the new helper functions, solving the problem of the main package exceeding its size limit.

[0198] Figure 5 This is a schematic diagram of an apparatus for reducing the size of a mini-program package provided in an embodiment of this application. Figure 5 As shown, the device 500 for reducing the size of the mini-program package includes:

[0199] The acquisition module 510 is used to acquire the source code of the mini-program in response to the command to run the mini-program;

[0200] The processing module 520 is used to determine the running configuration information of the mini-program based on the source code. The running configuration information is used to indicate the first runtime library associated with the mini-program and the first auxiliary function in the first runtime library. The first auxiliary function includes corresponding functional information and descriptive information.

[0201] The processing module 520 is further configured to determine, when a preset condition is met, a second auxiliary function associated with the first auxiliary function according to a preset mapping relationship, wherein the second auxiliary function is obtained by compressing the functional information corresponding to the first auxiliary function;

[0202] The compilation module 530 is used to call and compile the second auxiliary function to obtain the applet package.

[0203] In one possible implementation, the device 500 further includes a replacement module for replacing the first auxiliary function in the first runtime library with the second auxiliary function to obtain an updated second runtime library; and a deletion module for deleting the first runtime library and injecting the second runtime library into the file header of the applet's source code.

[0204] In another possible implementation, the processing module 520 is further configured to: determine whether the first runtime library and the first auxiliary function satisfy the preset condition based on the runtime configuration information; when the first runtime library is any one of the preset runtime libraries, and / or the first auxiliary function is any one of the preset function list, determine that the preset condition is satisfied; when the first runtime library is not any one of the preset runtime libraries, and / or the first auxiliary function is not any one of the preset function list, determine that the preset condition is not satisfied.

[0205] In another possible implementation, the processing module 520 is also used to: call and compile the first auxiliary function to obtain the applet package when the preset condition is not met.

[0206] In another possible implementation, the runtime configuration information is also used to indicate the working status of the application experiment feature plugin of the source code. The processing module 520 is also used to: determine whether the first runtime library and the first auxiliary function meet the preset conditions based on the working status of the application experiment feature plugin of the source code; when the application experiment feature plugin of the source code is in the open state, it is determined that the preset conditions are met; when the application experiment feature plugin of the source code is in the closed state, it is determined that the preset conditions are not met.

[0207] In another possible implementation, the processing module 520 is further configured to: determine whether the first auxiliary function satisfies the preset condition based on the preset function characteristics; when the first auxiliary function satisfies the preset function characteristics, determine that the preset condition is satisfied; when the first auxiliary function does not satisfy the preset function characteristics, determine that the preset condition is not satisfied.

[0208] In another possible implementation, when the first runtime library includes multiple first auxiliary functions, the processing module 520 is further configured to: retain the first first auxiliary function in the first runtime library and delete the other first auxiliary functions.

[0209] In another possible implementation, the processing module 520 is also used to: when the source code of the applet includes a file that has already been processed by the first auxiliary function, ignore the file that has already been processed by the first auxiliary function, so that the file is no longer processed.

[0210] Optionally, the runtime configuration information is used to indicate the working status of the application experiment feature plugin of the source code, and the satisfaction of the preset conditions specifically includes: the runtime configuration information indicating that the application experiment feature plugin of the source code is in an enabled state; and / or, the first auxiliary function is a preset function.

[0211] Optionally, the functional information corresponding to the first auxiliary function includes one or more of the following: the name, format, constants, variables, and processing method of the first auxiliary function; and the descriptive information corresponding to the first auxiliary function includes one or more of the following: the function declaration and extended configuration of the first auxiliary function.

[0212] Figure 6 This is a schematic diagram of the device for running a mini-program provided in an embodiment of this application. For example... Figure 6 As shown, the device 600 for reducing the size of the mini-program package includes:

[0213] Module 610 is used to obtain the source code of the mini-program;

[0214] The runtime module 620 is used to run the applet based on the source code, wherein the operation of the applet depends on the second runtime library associated with the source code and the second auxiliary function in the second runtime library.

[0215] In one possible implementation, the second runtime library is obtained by updating the first runtime library after replacing the first auxiliary function in the first runtime library with the second auxiliary function, and the second auxiliary function is obtained by trimming the first auxiliary function in the first runtime library.

[0216] In another possible implementation, the first auxiliary function and the second auxiliary function have a pre-defined mapping relationship.

[0217] In another possible implementation, the first auxiliary function includes corresponding functional information and descriptive information, and the second auxiliary function is obtained by compressing the functional information corresponding to the first auxiliary function.

[0218] Optionally, the first runtime library is any one of the preset runtime libraries; or, the first auxiliary function is any one of the preset function lists; or, the first auxiliary function conforms to the preset function characteristics.

[0219] Optionally, the application experiment feature plugin in the source code is enabled.

[0220] In another possible implementation, when the first runtime library includes multiple first auxiliary functions, during the process of replacing the first auxiliary function in the first runtime library with the second auxiliary function, one second auxiliary function is retained in the second runtime library.

[0221] Optionally, the first runtime library includes either tslib or babel / runtime.

[0222] Optionally, the functional information corresponding to the first auxiliary function includes one or more of the following: the name, format, constants, variables, and processing method of the first auxiliary function; and the descriptive information corresponding to the first auxiliary function includes one or more of the following: the function declaration and extended configuration of the first auxiliary function.

[0223] Figure 7 This is a schematic diagram of the physical structure of an electronic device capable of installing mini-programs.

[0224] It should be understood that the electronic devices capable of installing the applet in the embodiments of this application may include Figure 7 The embodiments shown may include some or all of the structures, or may include other structures not shown, but this application does not limit this.

[0225] For example, such as Figure 7 As shown, an electronic device capable of installing a mini-program may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a camera 193, and a display screen 194.

[0226] The sensor module 180 can be a fingerprint sensor 180A, a touch sensor 180B, etc.

[0227] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 0. In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0228] The processor 110 may include one or more processing units. These processing units may be independent devices or integrated within one or more processors. The controller may serve as the nerve center and command center of the electronic device. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. The processor 110 may also include a memory for storing instructions and data.

[0229] In some embodiments, processor 110 may include one or more interfaces.

[0230] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a limitation on the structure of the electronic device. In other embodiments of this application, the electronic device may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0231] The charging management module 140 is used to receive charging input from the charger. The charger can be a wireless charger or a wired charger.

[0232] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, internal memory 121, external memory, display 194, camera 193, and wireless communication module 160, etc.

[0233] The wireless communication function of electronic devices can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.

[0234] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in an electronic device can be used to cover one or more communication frequency bands.

[0235] The mobile communication module 150 can provide solutions for wireless communication applications, including 2G / 3G / 4G / 5G / 6G, in electronic devices. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the same device as at least some modules of the processor 110.

[0236] The wireless communication module 160 can provide solutions for wireless communication applications in electronic devices, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0237] In this embodiment, the electronic device can communicate with the server via the mobile communication module 150 or the wireless communication module 160. For example, the electronic device uploads the user's identification information to the server, and the server returns information of one or more encapsulated video segments to the electronic device. Further details are omitted here.

[0238] In some embodiments, antenna 1 of the electronic device is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling the electronic device to communicate with networks and other devices via wireless communication technology.

[0239] Electronic devices implement display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0240] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. In some embodiments, an electronic device may include one or N displays screens 194, where N is a positive integer greater than 1.

[0241] In this embodiment of the application, the electronic device (e.g., a mobile phone) can display an application interface on the screen, for example... Figures 1 to 7 The process of a user using application A, and the running interface of application A displayed on the phone, are shown below and will not be described in detail here.

[0242] Electronic devices can achieve shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.

[0243] The ISP is used to process the data fed back by the camera 193.

[0244] Camera 193 is used to capture still images or videos. In some embodiments, the electronic device may include one or N cameras 193, where N is a positive integer greater than 1.

[0245] Video codecs are used to compress or decompress digital video. Electronic devices can support one or more video codecs. This allows the electronic device to play or record video in various encoded formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0246] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0247] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area.

[0248] Electronic devices can implement audio functions such as music playback and recording through audio modules 170, speakers 170A, receivers 170B, microphones 170C, headphone jacks 170D, and application processors.

[0249] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.

[0250] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. Electronic devices can listen to music or make hands-free calls through the speaker 170A.

[0251] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic devices can have at least one microphone 170C. In some embodiments, electronic devices can have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic devices can have three, four, or more microphones 170C, enabling sound signal collection, noise reduction, sound source identification, and directional recording, among other functions.

[0252] The 170D headphone jack is used to connect wired headphones.

[0253] Sensor module 180 may include Figure 7 The fingerprint sensor 180A and touch sensor 180B are shown.

[0254] The fingerprint sensor 180A is used to collect fingerprints. Electronic devices can utilize the collected fingerprint characteristics to achieve fingerprint unlocking, app access locks, fingerprint photography, fingerprint answering of calls, etc.

[0255] Touch sensor 180B can also be referred to as a "touch panel". Touch sensor 180B can be disposed on display screen 194, and the touch sensor 180B and display screen 194 together form a touchscreen, also called a "touch screen". Touch sensor 180B is used to detect touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180B may also be disposed on the surface of the electronic device, in a different location than display screen 194.

[0256] Optionally, in this embodiment of the application, the touch sensor 180B can detect user click operations, swipe operations, etc., generate operation events, and transmit the operation events to the processor 110, which determines the operation events and responds accordingly.

[0257] In addition, electronic devices may include more sensors, such as pressure sensors, temperature sensors, bone conduction sensors, etc., which are not limited in this application.

[0258] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic devices can receive button inputs and generate key signal inputs related to user settings and function control of the electronic device.

[0259] The software system of electronic devices can adopt layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture, etc. This application embodiment takes a mobile phone as an example, and the mobile phone can have a layered architecture... The software structure of the electronic device is not limited in this application embodiment.

[0260] It should be noted that, in the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; the "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.

[0261] It should be understood that the methods, situations, categories, and classifications of embodiments in this application are for the convenience of description only and should not constitute a special limitation. Various methods, categories, situations, and features in embodiments can be combined without contradiction.

[0262] It should also be understood that the terms "first," "second," and "third" in the embodiments of this application are for distinction only and should not constitute any limitation on this application.

[0263] It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0264] It should also be noted that in the embodiments of this application, "preset", "fixed value", etc. can be implemented by pre-storing the corresponding code, table or other means that can be used to indicate relevant information in the electronic device (such as the transmitting end device and the receiving end device, etc.). This application does not limit the specific implementation method.

[0265] It is understood that, in order to achieve the above-mentioned functions, electronic devices include hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.

[0266] This embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0267] With each functional module corresponding to its respective function, the above embodiments illustrate a possible configuration of the electronic device, which may include a display unit, a detection unit, and a processing unit. The display unit, detection unit, and processing unit cooperate to support the electronic device in performing the aforementioned steps and / or other processes related to the technology described herein.

[0268] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0269] The electronic device provided in this embodiment is used to execute the above method, and therefore can achieve the same effect as the above implementation method.

[0270] When using integrated units, the electronic device may include a processing module, a storage module, and a communication module. The processing module can be used to control and manage the operation of the electronic device; for example, it can support the electronic device in executing the steps performed by the display unit, detection unit, and processing unit. The storage module can support the electronic device in executing stored program code and data. The communication module can support communication between the electronic device and other devices.

[0271] The processing module can be a processor or a controller. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, or other devices that interact with other electronic devices.

[0272] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in this embodiment can be a device having... Figure 4 The device with the structure shown.

[0273] This embodiment also provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the methods described in the above embodiments.

[0274] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the methods described in the above embodiments.

[0275] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the methods in the above-described method embodiments.

[0276] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.

[0277] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0278] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0279] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0280] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0281] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0282] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for reducing the size of a mini-program package, characterized in that, The method includes: Obtain the source code of the mini-program; Based on the source code, the running configuration information of the mini-program is determined. The running configuration information indicates the first runtime library associated with the mini-program and the first auxiliary function in the first runtime library. The first auxiliary function is a native auxiliary function in the native runtime library. The first auxiliary function includes corresponding functional information and descriptive information. The functional information corresponding to the first auxiliary function includes one or more of the following: name, format, constants, variables, and processing method of the first auxiliary function. When the preset conditions are met, the second auxiliary function associated with the first auxiliary function is determined according to the preset mapping relationship. The second auxiliary function is a new auxiliary function obtained by compressing one or more of the information of the name, format, constants, variables, and processing method of the first auxiliary function. The second auxiliary function does not include descriptive information. The second auxiliary function is called and compiled to obtain the mini-program package.

2. The method according to claim 1, characterized in that, When the preset conditions are met, the method further includes: The first auxiliary function in the first runtime library is replaced with the second auxiliary function to obtain the updated second runtime library; Delete the first runtime library and inject the second runtime library into the file header of the applet's source code.

3. The method according to any one of claims 1 to 2, characterized in that, The method further includes: Based on the runtime configuration information, determine whether the first runtime library and the first auxiliary function meet the preset conditions; When the first runtime library is any one of the preset runtime libraries, and / or the first auxiliary function is any one of the preset function list, it is determined that the preset condition is met; If the first runtime library is not any of the preset runtime libraries, and / or the first auxiliary function is not any of the preset function list, then the preset condition is determined not to be met.

4. The method according to any one of claims 1 to 2, characterized in that, The method further includes: When the preset conditions are not met, the first auxiliary function is called and compiled to obtain the mini-program package.

5. The method according to any one of claims 1 to 2, characterized in that, The runtime configuration information is also used to indicate the working status of the application experiment feature plugin of the source code, and the method further includes: Based on the working status of the application test feature plugin in the source code, determine whether the first runtime library and the first auxiliary function meet the preset conditions; When the application test feature plugin of the source code is enabled, it is determined that the preset condition is met; When the application test feature plugin of the source code is in a closed state, it is determined that the preset condition is not met.

6. The method according to any one of claims 1 to 2, characterized in that, The method further includes: Based on the preset function characteristics, determine whether the first auxiliary function satisfies the preset condition; When the first auxiliary function conforms to the preset function characteristics, it is determined that the preset condition is met; When the first auxiliary function does not conform to the preset function characteristics, it is determined that the preset condition is not met.

7. The method according to any one of claims 1 to 2, characterized in that, When the first runtime library includes multiple of the first helper functions, the method further includes: The first first helper function in the first runtime library is retained, and the other first helper functions are deleted.

8. The method according to any one of claims 1 to 2, characterized in that, When the source code of the mini-program includes content that has already been processed by the first helper function, the method further includes: Ignore the content that has already been processed by the first auxiliary function, so that the content is no longer processed by the first auxiliary function.

9. The method according to any one of claims 1 to 2, characterized in that, The first runtime library includes either tslib or babel / runtime.

10. The method according to any one of claims 1 to 2, characterized in that, The description information corresponding to the first auxiliary function includes one or more pieces of information from the function declaration and extended configuration of the first auxiliary function.

11. A method for running a mini-program, characterized in that, The method includes: Obtain the source code of the aforementioned mini-program; The applet is run according to the source code, and the operation of the applet depends on the second runtime library associated with the source code and the second helper function in the second runtime library; The second auxiliary function is a new auxiliary function obtained by compressing one or more of the information of the first auxiliary function, such as its name, format, constants, variables, and processing method. The second auxiliary function does not include descriptive information. The first auxiliary function is a native auxiliary function in the native runtime library. The first auxiliary function includes corresponding functional information and descriptive information. The functional information corresponding to the first auxiliary function includes one or more of the information of the first auxiliary function, such as its name, format, constants, variables, and processing method.

12. The method according to claim 11, characterized in that, The second runtime library is obtained by updating the first runtime library after replacing the first auxiliary function in the first runtime library with the second auxiliary function. The second auxiliary function is obtained by trimming the first auxiliary function in the first runtime library.

13. The method according to claim 12, characterized in that, The first auxiliary function and the second auxiliary function have a preset mapping relationship.

14. The method according to claim 12 or 13, characterized in that, The first runtime library is any one of the preset runtime libraries; or, The first auxiliary function is any one of the preset function lists; or, The first auxiliary function conforms to the preset function characteristics.

15. The method according to claim 12 or 13, characterized in that, The application testing feature plugin in the source code is enabled.

16. The method according to claim 12 or 13, characterized in that, When the first runtime library includes multiple first auxiliary functions, during the process of replacing the first auxiliary functions in the first runtime library with the second auxiliary functions, one second auxiliary function is retained in the second runtime library.

17. The method according to claim 12 or 13, characterized in that, The first runtime library includes either tslib or babel / runtime.

18. The method according to claim 12 or 13, characterized in that, The description information corresponding to the first auxiliary function includes one or more pieces of information from the function declaration and extended configuration of the first auxiliary function.

19. An apparatus for reducing the size of a mini-program package, characterized in that, The device includes: The acquisition module is used to obtain the source code of the mini-program; The processing module is used to determine the running configuration information of the mini-program based on the source code. The running configuration information indicates the first runtime library associated with the mini-program and the first auxiliary function in the first runtime library. The first auxiliary function is a native auxiliary function in the native runtime library. The first auxiliary function includes corresponding functional information and descriptive information. The functional information corresponding to the first auxiliary function includes one or more of the following: name, format, constants, variables, and processing method of the first auxiliary function. The processing module is further configured to determine, when a preset condition is met, a second auxiliary function associated with the first auxiliary function according to a preset mapping relationship. The second auxiliary function is a new auxiliary function obtained by compressing one or more pieces of information from the name, format, constants, variables, and processing method of the first auxiliary function. The second auxiliary function does not include descriptive information. The compilation module is used to call and compile the second auxiliary function to obtain the mini-program package.

20. A device for running a mini-program, characterized in that, The device includes: The acquisition module is used to acquire the source code of the mini-program; The processing module is used to run the applet based on the source code, wherein the operation of the applet depends on the second runtime library associated with the source code and the second auxiliary function in the second runtime library; The second auxiliary function is a new auxiliary function obtained by compressing one or more of the information of the first auxiliary function, such as its name, format, constants, variables, and processing method. The second auxiliary function does not include descriptive information. The first auxiliary function is a native auxiliary function in the native runtime library. The first auxiliary function includes corresponding functional information and descriptive information. The functional information corresponding to the first auxiliary function includes one or more of the information of the first auxiliary function, such as its name, format, constants, variables, and processing method.

21. An electronic device, characterized in that, include: One or more processors; One or more memory units; A module with multiple applications installed; The memory stores one or more programs that, when executed by the processor, cause the electronic device to perform the method as described in any one of claims 1 to 18.

22. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1 to 18.

23. A computer program product, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1 to 18.

Citation Information

Patent Citations

  • Applet compiling method and device, equipment and readable storage medium

    CN112379885A

  • Code processing method and device

    CN113835686A