CN-121996281-A - Front-end application updating method, device and equipment
Abstract
The embodiment of the application provides a method, a device and equipment for updating a front-end application, relates to the technical field of computers, and aims to realize real non-perception updating, improve user experience, save resources and improve updating efficiency. The method comprises the steps of obtaining a state snapshot of a target application in the current running process, carrying out semantic analysis and dependency analysis on application files of a new version application of the target application and application files of an old version application of the target application, calculating a minimum difference set between the new version application and the old version application of the target application, generating a differential packet, carrying out compatibility detection on the new version application and the old version application to obtain a compatibility detection result, and carrying out hot update on the target application based on the state snapshot and the differential packet when the compatibility detection result represents that the new version application is completely compatible with the old version application, so as to obtain an update result of the target application, wherein user interface operation is not interrupted in the hot update process.
Inventors
- XIN TONG
- ZHAO RUNAN
- XU JIAN
Assignees
- 度小满科技(北京)有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260323
Claims (10)
- 1. A method for updating a front-end application, comprising: Acquiring a state snapshot of a target application in the current running process, wherein the state snapshot comprises a multidimensional application state; Carrying out semantic analysis and dependency analysis on application files of the new version application of the target application and application files of the old version application of the target application, and calculating a minimum difference set between the new version application and the old version application of the target application to generate a difference packet, wherein the minimum difference set is a minimum code unit set which needs to be updated; performing compatibility detection on the new version application and the old version application to obtain a compatibility detection result; And when the compatibility detection result represents that the new version application is completely compatible with the old version application, performing hot update on the target application based on the state snapshot and the difference packet to obtain an update result of the target application, wherein user interface operation is not interrupted in the hot update process.
- 2. The method of claim 1, wherein the multi-dimensional application state comprises a frame state, a component state, a routing state, a user interaction state, a business data state, and wherein the obtaining a state snapshot of the target application when currently running comprises: capturing a multidimensional application state corresponding to the current timestamp when the target application runs; And carrying out structural compression and de-duplication on the multi-dimensional application state to obtain the state snapshot.
- 3. The method of claim 2, wherein the performing semantic analysis and dependency analysis on the application file of the new version application of the target application and the application file of the old version application of the target application, calculating a minimum set of differences between the new version application and the old version application of the target application, generating a delta package, comprises: Performing file classification on the application file of the new version application and the application file of the old version application to obtain a new JS file, a new CSS file and a new resource file of the new version application, and an old JS file, an old CSS file and an old resource file of the old version application; Performing semantic analysis and code unit dependency analysis on the new JS file and the old JS file, calculating the minimum difference set, and generating a JS patch, wherein the JS patch comprises differential patches of all code units in the minimum difference set; Generating a CSS patch based on the new CSS file and the old CSS file; generating a resource change list based on the new resource file and the old resource file; and generating a delta packet based on the JS patch, the CSS patch and the resource change list.
- 4. The method of claim 3, wherein the performing semantic analysis and code unit dependency analysis on the new JS file and the old JS file, calculating the minimum set of differences, and generating a JS patch, includes: performing semantic analysis on the new JS file and the old JS file to obtain JS change information corresponding to the version update task; Constructing a dependency graph based on the application file of the new version application, wherein the dependency graph is used for describing the dependency relationship among all code units in the new version application; Based on the JS change information and the dependency graph, determining an affected code unit set corresponding to the version updating task, and performing redundancy removal on the affected code unit set to obtain the minimum difference set; and generating a JS patch based on the minimum difference set and the JS change information.
- 5. The method of claim 4, wherein performing semantic analysis on the new JS file and the old JS file to obtain JS change information corresponding to the current version update task includes: Respectively analyzing the new JS file and the old JS file to generate a first abstract syntax tree corresponding to the new JS file and a second abstract syntax tree corresponding to the old JS file; And carrying out semantic difference on the first abstract syntax tree and the second abstract syntax tree to obtain JS change information corresponding to the version update task.
- 6. The method of claim 1, wherein the performing compatibility detection on the new version application and the old version application to obtain a compatibility detection result comprises: Analyzing the application file of the new version application and the application file of the old version application, and determining whether a compatibility evaluation element of the current version update task is compatible or not, wherein the compatibility evaluation element comprises an API, data and a component interface; Carrying out semantic analysis on the version number of the new version application and the version number of the old version application, carrying out semantic analysis on the application file of the new version application and the application file of the old version application, and determining a destructive change detection result of the current version update task; and if the compatibility evaluation element is compatible and the destructive change detection result is that the destructive change is not generated, determining that the compatibility detection result is that the new version application is completely compatible with the old version application.
- 7. The method of claim 1, wherein the performing a thermal update on the target application based on the state snapshot and the delta package to obtain an updated result for the target application comprises: Dividing the current version update task into update tasks of different types, and determining the scheduling priority of each update task; And executing the update tasks in sequence according to the scheduling priority of the update tasks, wherein executing one update task comprises the steps of performing topological ordering on the dependency relationship in the difference packet, determining a module replacement sequence, and performing module hot replacement on each module corresponding to the target application based on the state snapshot and the difference packet according to the module replacement sequence.
- 8. The method of claim 7, wherein performing module hot-replacement on each module corresponding to the target application based on the state snapshot and the delta package comprises: loading a new code of a target module from the delta packet, and configuring a new version of the target module, wherein the target module is any one of the modules; migrating the state corresponding to the target module in the state snapshot to the target module of the new version; And performing function verification on the target module with the new version, and executing module hot replacement of the next module when the function verification is passed.
- 9. An update apparatus for a front-end application, comprising: The acquisition module is used for acquiring a state snapshot of the target application when running currently, wherein the state snapshot comprises a multidimensional application state; The generation module is used for carrying out semantic analysis and dependency analysis on the application file of the new version application of the target application and the application file of the old version application of the target application, calculating a minimum difference set between the new version application and the old version application of the target application, and generating a difference packet, wherein the minimum difference set is a minimum code unit set which needs to be updated; the detection module is used for carrying out compatibility detection on the new version application and the old version application to obtain a compatibility detection result; And the thermal updating module is used for carrying out thermal updating on the target application based on the state snapshot and the difference packet to obtain an updating result of the target application when the compatibility detection result represents that the new version application is completely compatible with the old version application, wherein user interface operation is not interrupted in the thermal updating process.
- 10. An electronic device, comprising: processor, and A memory in which a program is stored, Wherein the program comprises instructions which, when executed by the processor, cause the processor to perform the method of any of claims 1-8.
Description
Front-end application updating method, device and equipment Technical Field The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, and a device for updating a front-end application. Background A progressive Web application (Progressive Web App, PWA) as an application program built by modern Web technology can provide a user experience, reliability and installability similar to native applications while retaining the broad accessibility and frictionless distribution characteristics of Web applications. However, the existing PWA updating method has significant defects, which affect the user experience and the resource efficiency. In the prior art, a traditional Service workbench updating mechanism is generally adopted, and in particular, a traditional strategy of downloading, waiting and activating is adopted, wherein the updating flow comprises the steps of detecting a new version, downloading all resources, waiting for closing all pages and activating a new Service workbench. However, the above manner has a forced refresh mode (i.e. the pop-up prompt requires the user to refresh the page to perform application update), the operation performed by the user is forced to be interrupted, resulting in interruption of the user experience, and the refresh of the page may cause the application state such as user input, scroll position, etc. to be lost, resulting in failure of maintaining the application state in the update process, and the user may see the new and old version interfaces at the same time, resulting in operation confusion and poor experience. In addition, the method needs to download the whole application package in a full amount for the new version application package, and even small modifications need to download the complete application package, so that bandwidth and storage waste are caused. Disclosure of Invention The embodiment of the application provides a method, a device and equipment for updating a front-end application, which are used for realizing real non-perception updating, improving user experience, realizing an accurate difference updating algorithm, only transmitting codes and resources of the application, which are really changed, saving the resources and improving efficiency. In a first aspect, an embodiment of the present application provides a method for updating a front-end application, where the method includes: Acquiring a state snapshot of the target application in the current running process, wherein the state snapshot comprises a multidimensional application state; carrying out semantic analysis and dependency analysis on application files of the new version application of the target application and application files of the old version application of the target application, and calculating a minimum difference set between the new version application and the old version application of the target application to generate a difference packet, wherein the minimum difference set is a minimum code unit set which needs to be updated; detecting compatibility of the new version application and the old version application to obtain a compatibility detection result; And when the compatibility detection result represents that the new version application is completely compatible with the old version application, performing hot update on the target application based on the state snapshot and the delta package to obtain an update result of the target application, wherein the user interface operation is not interrupted in the hot update process. In an alternative embodiment, the multidimensional application state comprises a frame state, a component state, a routing state, a user interaction state and a service data state, and the step of obtaining the state snapshot of the target application when the target application is currently running comprises the following steps: capturing a multidimensional application state corresponding to the current timestamp when the target application runs; And carrying out structural compression and de-duplication on the multi-dimensional application state to obtain a state snapshot. In an alternative embodiment, semantic analysis and dependency analysis are performed on application files of a new version application of the target application and application files of an old version application of the target application, a minimum difference set between the new version application and the old version application of the target application is calculated, and a delta package is generated, including: The method comprises the steps of classifying the application files of the new version application and the old version application to obtain a new JS file, a new CSS file and a new resource file of the new version application, and an old JS file, an old CSS file and an old resource file of the old version application; Performing semantic analysis and code unit dependency analysis on the new JS file and the