Decoding method and device

By decoding the file header and decoding the content block of the integrated file, and using verification codes and version numbers to ensure file integrity and compatibility, the problem of low efficiency in packaging and downloading of various types of resource files is solved in the front-end development, and efficient decoding and rendering process is achieved.

CN115118385BActive Publication Date: 2025-05-16ALIBABA (SHENZHEN) TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210576475.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-25
Publication Date
2025-05-16
Estimated Expiration
2042-05-25

AI Technical Summary

Technical Problem

In the prior art, the packaging and downloading of various types of resource files generated by front-end development is inefficient, the number of downloads and download overhead is large, and the compatibility and integrity of resource files cannot be guaranteed.

Method used

By decoding the file header of the integrated file, obtaining identification information and attribute information, determining whether the integrated file meets the decoding conditions, and decoding the target encoding file in the content block, different types of data structures are obtained, and the file integrity and compatibility are ensured using verification codes and version numbers.

Benefits of technology

Reduces the number of downloads and download overhead, improves decoding efficiency and interface rendering efficiency, and ensures file integrity and compatibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115118385B_ABST
    Figure CN115118385B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification provide a decoding method and device, wherein the decoding method comprises: decoding a file header of an integrated file to obtain identification information and attribute information of the integrated file; judging whether the integrated file meets decoding conditions according to the identification information and attribute information of the integrated file; if so, decoding a target encoded file contained in at least two content blocks of the integrated file to obtain at least two different types of data structures, wherein the data structure is obtained by performing syntax parsing on a source file corresponding to the target encoded file during the encoding stage of the integrated file, thereby reducing decoding overhead and improving decoding efficiency and interface rendering efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of front-end development technology, and in particular to decoding methods and devices. Background Art

[0002] With the continuous development of Internet technology, higher requirements are placed on the front-end development technology of web pages. The pages generated by front-end development are published to different CDN addresses in the form of code files.

[0003] In the prior art, a single type of code file is usually compressed and packaged. Users need to download the compressed file, decompress it and execute the code file to obtain the web page interface. The download times and download overhead are large, which leads to a decrease in download efficiency and rendering efficiency in the process of generating the web page interface. A more reliable solution is needed. Summary of the invention

[0004] In view of this, an embodiment of the present specification provides a decoding method. One or more embodiments of the present specification also relate to a decoding device, an encoding method, an encoding device, another encoding method, another encoding device, a file processing method, a computing device, a computer-readable storage medium, and a computer program to solve the technical defects existing in the prior art.

[0005] According to a first aspect of an embodiment of this specification, a decoding method is provided, including:

[0006] Decoding the file header of the integrated file to obtain identification information and attribute information of the integrated file;

[0007] Determining whether the integrated file meets the decoding condition according to the identification information and attribute information of the integrated file;

[0008] If so, the target encoded files contained in at least two content blocks of the integrated file are decoded to obtain at least two different types of data structures, wherein the data structures are obtained by performing syntax parsing on the source files corresponding to the target encoded files during the encoding stage of the integrated file.

[0009] According to a second aspect of an embodiment of this specification, a decoding device is provided, including:

[0010] A first decoding module is configured to decode the file header of the integrated file to obtain identification information and attribute information of the integrated file;

[0011] A judgment module, configured to judge whether the integrated file meets the decoding condition according to the identification information and attribute information of the integrated file;

[0012] The second decoding module is configured to, if yes, decode the target encoded file contained in at least two content blocks of the integrated file to obtain at least two different types of data structures, wherein the data structure is obtained by performing syntax parsing on the source file corresponding to the target encoded file during the encoding stage of the integrated file.

[0013] According to a third aspect of the embodiments of this specification, there is provided a coding method, including:

[0014] Based on at least two different types of source files, determining identification information of an integrated file corresponding to the at least two different types of source files, and writing the identification information of the integrated file into a file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file;

[0015] Encoding the at least two different types of source files respectively to obtain a first type of target encoded file and a second type of target encoded file;

[0016] The first type target encoding file and the second type target encoding file are written into the first content block and the second content block of the integrated file respectively.

[0017] According to a fourth aspect of the embodiments of this specification, there is provided an encoding device, including:

[0018] A first writing module is configured to determine identification information of an integrated file corresponding to the at least two different types of source files based on at least two different types of source files, and write the identification information of the integrated file into a file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file;

[0019] An encoding module is configured to respectively encode the at least two different types of source files to obtain a first type of target encoded file and a second type of target encoded file;

[0020] The second writing module is configured to write the first type target coding file and the second type target coding file into the first content block and the second content block of the integrated file respectively.

[0021] According to a fifth aspect of the embodiments of this specification, there is provided an encoding method, including:

[0022] Based on at least two different types of source files, determining identification information of an integrated file corresponding to the at least two different types of source files, and writing the identification information of the integrated file into a file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file;

[0023] Encoding the at least two different types of source files respectively to obtain target encoded files of each type;

[0024] Each type of target coded file is written into the content block of the integrated file respectively, wherein each content block stores one type of target coded file.

[0025] According to a sixth aspect of the embodiments of this specification, there is provided an encoding device, including:

[0026] A first writing module is configured to determine identification information of an integrated file corresponding to the at least two different types of source files based on at least two different types of source files, and write the identification information of the integrated file into a file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file;

[0027] An encoding module, configured to respectively encode the at least two different types of source files to obtain target encoded files of each type;

[0028] The second writing module is configured to write each type of target coded file into the content block of the integrated file respectively, wherein each content block stores one type of target coded file.

[0029] According to a seventh aspect of the embodiments of this specification, a file processing method is provided, including:

[0030] The encoding module writes identification information and attribute information of the integrated file corresponding to the at least two different types of source files into a file header of the integrated file, performs encoding processing on the at least two different types of source files respectively to obtain a first type of target encoded file and a second type of target encoded file, and writes the first type of target encoded file and the second type of target encoded file into a first content block and a second content block of the integrated file respectively to obtain a target integrated file;

[0031] The decoding module decodes the file header of the target integrated file to obtain the identification information and attribute information of the target integrated file, and when determining that the target integrated file meets the decoding conditions based on the identification information and attribute information of the target integrated file, decodes the first type of target encoded file to obtain a first type of data structure, and decodes the second type of target encoded file to obtain a second type of data structure.

[0032] According to the eighth aspect of the embodiments of this specification, a computing device is provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the encoding method or the decoding method when executing the computer instructions.

[0033] According to a ninth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer instructions, and when the computer instructions are executed by a processor, the steps of the encoding method or the decoding method are implemented.

[0034] According to the tenth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned encoding method or decoding method.

[0035] A decoding method provided by an embodiment of the present specification decodes the file header of an integrated file to obtain identification information and attribute information of the integrated file; based on the identification information and attribute information of the integrated file, it is determined whether the integrated file meets the decoding conditions, providing a self-checking capability for the integrated file, thereby facilitating the inspection of whether the integrated file is damaged during transmission and storage, providing conditions for determining the integrity of the integrated file, and also providing conditions for verifying the compatibility of the integrated file, thereby ensuring the decoding efficiency and decoding success rate of the integrated file; if so, the target encoded files contained in at least two content blocks of the integrated file are decoded to obtain at least two different types of data structures, wherein the data structure is obtained by performing syntax parsing on the source file corresponding to the target encoded file during the encoding stage of the integrated file, and since the data structure has been obtained by syntax parsing during the encoding stage of the integrated file, the decoding overhead is reduced, and the decoding efficiency and interface rendering efficiency are improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is a structural schematic diagram of a decoding method provided by an embodiment of this specification;

[0037] Figure 2 is a flowchart of a decoding method provided by an embodiment of this specification;

[0038] Figure 3 is a schematic diagram of the structure of a decoding device provided by an embodiment of this specification;

[0039] Figure 4 It is a schematic diagram of a coding method provided by an embodiment of this specification;

[0040] Figure 5 is a flow chart of an encoding method provided by an embodiment of this specification;

[0041] Figure 6 is a schematic diagram of the structure of an encoding device provided by an embodiment of this specification;

[0042] Figure 7 is a flow chart of an encoding method provided by an embodiment of this specification;

[0043] Figure 8 is a schematic diagram of the structure of an encoding device provided by an embodiment of this specification;

[0044] Fig. 9 It is a schematic diagram of the processing structure of an encoding + decoding method provided by an embodiment of this specification;

[0045] Fig.10 is a processing flow chart of an encoding + decoding method provided by an embodiment of this specification;

[0046] Fig.11 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0047] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0048] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to any or all possible combinations of one or more associated listed items.

[0049] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0050] First, the terms involved in one or more embodiments of this specification are explained.

[0051] JS, or JavaScript, is a lightweight, interpreted or just-in-time compiled programming language with function-first approach.

[0052] CSS, the full name of which is Cascading Style Sheets, is a cascading style sheet, a computer language used to express the style of files such as HTML (an application of Standard Generalized Markup Language) or XML (a subset of Standard Generalized Markup Language).

[0053] Weex is a dynamic rendering engine for building high-performance cross-platform mobile UI. Weex enables developers to build iOS, Android, and Web UIs with a single code base using web-like syntax.

[0054] WLM is a file format used in Weex.

[0055] The integrated file is a file obtained by encoding and merging multiple source files, and its file format is WLM.

[0056] The content block is a file composition structure in the integrated file, which stores the target encoded file obtained after the source file is encoded.

[0057] Bytecode is a binary file that contains an executable program.

[0058] Magic number is a magic number used to mark and identify the format of integrated files.

[0059] In this specification, a decoding method is provided. This specification also involves a decoding device, an encoding method, an encoding device, another encoding method, another encoding device, a file processing method, a computing device, a computer-readable storage medium and a computer program, which are described in detail one by one in the following embodiments.

[0060] In actual applications, when packaging resource files generated by front-end development, it is usually supported to package a single type of resource files, that is, to merge and compress a certain type of resource files to obtain a resource package.

[0061] However, with the development of Internet technology, front-end development technology is also being updated. When multiple types of resource files generated by front-end development are packaged and downloaded, each type of resource file is packaged and downloaded separately, which increases the number of downloads and download overhead. At the same time, the compatibility and integrity of the downloaded resource files cannot be guaranteed. Therefore, an effective solution is urgently needed to solve the above problems.

[0062] In view of this, an embodiment of this specification provides a decoding method. Figure 1 A schematic diagram of a decoding method according to an embodiment of the present specification is shown. Figure 1 As shown, in the process of decoding the integrated file, the file header is decoded to obtain the identification information and attribute information stored in the file header, and whether the integrated file meets the decoding conditions is determined based on the identification information and attribute information. If so, the first type of target encoded file stored in the first content block is decoded to obtain a first type of data structure; the second type of target encoded file stored in the second content block is decoded to obtain a second type of data structure.

[0063] Figure 2 A flowchart of a decoding method provided according to an embodiment of the present specification is shown, which specifically includes the following steps 202 to 206.

[0064] Step 202: decode the file header of the integrated file to obtain identification information and attribute information of the integrated file.

[0065] Specifically, the identification information of the integrated file includes a checksum and a version number of the integrated file, and the attribute information of the integrated file is used to define the file format of the integrated file.

[0066] In one embodiment of the present specification, the identification information and attribute information of the integrated file can be directly read from the information recorded in the file header. The identification information and attribute information of the integrated file are obtained by decoding the file header, which facilitates the subsequent determination of whether the integrated file meets the decoding conditions.

[0067] Step 204: judging whether the integrated file meets the decoding condition according to the identification information and attribute information of the integrated file.

[0068] Specifically, based on the identification information and attribute information obtained by decoding the file header of the integrated file, further, considering that the client-related content needs to be updated according to the files included in the integrated file, and different operations will cause the integrated file to integrate different types of source files, before decoding, it is also necessary to detect whether the integrated file meets the decoding conditions in the current scenario, so that it can support the use in the current scenario. Based on this, after determining the identification information and attribute information of the integrated file, it can be determined whether the integrated file meets the decoding conditions according to the identification information and attribute information. If so, the following step 206 is executed. If not, the error information of the integrated file is determined, and a report is generated according to the error information.

[0069] When the identification information of the integrated file meets the preset identification information, the integrated file meets the decoding condition; correspondingly, when the attribute information of the integrated file meets the preset attribute information, the integrated file meets the decoding condition.

[0070] Furthermore, in order to ensure the security of the integrated file and the high efficiency of decoding, the integrated file's checksum, version number and attribute information can be used to determine whether the integrated file meets the decoding conditions. The specific implementation method is as follows.

[0071] Determine the attribute information of the integrated file; if the attribute information matches the preset attribute information, determine the version number in the identification information; if the version number belongs to a historical version number, determine the check code in the identification information; if the check code matches the preset check code, perform the step of decoding the target encoded file contained in at least two content blocks of the integrated file to obtain at least two different types of data structures.

[0072] Specifically, whether the integrated file meets the decoding conditions can be judged in turn based on the attribute information, version number and check code of the integrated file, among which the attribute information of the integrated file is used to judge the format attributes of the integrated file, the version number is used to judge the compatibility of the integrated file, and the check code is used to judge the integrity of the integrated file. When the integrated file meets these three decoding conditions, the integrated file can be decoded.

[0073] Among them, judging whether the integrated file meets the decoding conditions does not need to be performed in the order of first judging the attribute information, then judging the version number, and finally judging the check code. In other words, the integrated file can be judged whether it meets the decoding conditions according to the attribute information, version number and check code in any order.

[0074] In addition, the integrated file may be judged based on any one of the attribute information, the version number and the check code.

[0075] For example, first, determine whether the integrated file is a wlm file based on the attribute information of the integrated file. Specifically, the magic number of the integrated file can be read from the file header. When the magic number matches the preset attribute information, the integrated file is a wlm file. Then determine the version number of the integrated file. When the version number is a historical version number, determine the checksum of the integrated file. When the checksum matches the preset checksum, the result of the judgment is that the integrated file meets the decoding conditions, and the decoding step is executed. Specifically, the checksum of the integrated file can be calculated by the checksum algorithm, and the data in the integrated file is summed according to int32. When the calculation result is 0, it means that the integrated file maintains integrity and is not damaged during storage and transmission, and meets the decoding conditions.

[0076] In summary, in the process of judging whether the integrated file meets the decoding conditions, the calculation and verification of the check code provides the integrated file with self-verification capability, thereby facilitating the inspection of whether the integrated file is damaged during the transmission and storage process, providing conditions for judging the integrity of the integrated file, and also providing conditions for verifying the compatibility of the integrated file, thereby ensuring the decoding efficiency and decoding success rate of the integrated file.

[0077] Furthermore, in one embodiment of the present specification, the version number may also include a sub-version number, which records the extended functions in the integrated file. By reading the sub-version number, it can be used to determine whether there are functions in the integrated file that cannot be parsed by the decoding terminal.

[0078] Step 206: If yes, decode the target coded files contained in the at least two content blocks of the integrated file to obtain at least two different types of data structures.

[0079] Specifically, when the judgment result is that the integrated file meets the decoding conditions, the target encoding files contained in the at least two content blocks are decoded respectively, that is, the first type of target encoding file contained in the first content block of the at least two content blocks is decoded to obtain a first type of data structure, and correspondingly, the second type of target encoding file contained in the second content block of the at least two content blocks is decoded to obtain a second type of data structure.

[0080] It should be noted that the first type of data structure includes the first type of operating data required when the first type of source file is running, as well as duplicate data in the first type of operating data and location information of the duplicate data. Correspondingly, the second type of data structure includes the second type of operating data required when the second type of source file is running, as well as duplicate data in the second type of operating data and location information of the duplicate data.

[0081] Based on this, firstly, the first type of target encoding file contained in the first content block of at least two content blocks is decoded to obtain a first type of data structure. Then, the offset information in the first content block is read. At this time, the offset information is a preset value. It is determined that there is a second content block. Then, the second type of target encoding file contained in the second content block is decoded to obtain a second type of data structure.

[0082] Using the above example, in the process of decoding the integrated file, the JS type target coded file in the first content block is decoded to obtain a JS type data structure. Then, the offset information in the first content block is read. At this time, the offset information is a preset value X, indicating that there is a second content block. Then, the CSS type target coded file in the second content block is decoded to obtain a CSS type data structure. Then, the offset information in the second content block is read. At this time, the offset information is 0, indicating that there is no third content block. At this point, the decoding of the integrated file is completed. The integrated file is generated based on the merger of the JS type source file and the CSS type source file.

[0083] In summary, since the source file has been parsed and the data structure has been obtained during the encoding process of the integrated file, the data structure can be directly obtained when the target encoded file in the integrated file is decoded in the decoding stage, which provides conditions for the subsequent efficient execution of the data structure, simplifies the decoding process, and reduces the loading overhead of the client during the decoding process.

[0084] Furthermore, after obtaining at least two different types of data structures, in order to generate a rendering interface associated with the target encoding file in the integrated file, the data structure needs to be processed by a processing engine, and the specific implementation method is as follows.

[0085] The first type of data structure is processed by a first type of processing engine, and the second type of data structure is processed by a second type of processing engine to generate a rendering interface associating the first type of data structure and the second type of data structure; wherein the operating rules of the first type of processing engine and the second type of processing engine are different.

[0086] Based on this, after obtaining the first type of data structure and the second type of data structure, the first type of data structure is processed by the first type of processing engine, and the second type of data structure is processed by the second type of processing engine, and then a rendering interface associating the first type of data structure and the second type of data structure can be generated in the interface rendering engine.

[0087] It is understandable that the interface rendering engine is provided with a first type of processing engine and a second type of processing engine, and other types of processing engines may also be provided according to the requirements of downloading and decoding source files.

[0088] Continuing with the above example, the Weex engine is equipped with a JS type processing engine and a CSS type processing engine. The JS type processing engine is used to process the JS type data structure. The JS type processing engine can execute the JS type source file corresponding to the JS type data structure, so that the dom interface can be operated in the Weex engine for interface rendering. The CSS type processing engine is used to process the CSS type data structure, so that the content in the CSS type source file corresponding to the CSS type data structure becomes the parameter in the dom data in the Weex engine, which is used to control the layout, drawing and other behaviors in the interface rendering process, and then generate the rendering interface associated with the JS type data structure and the CSS type data structure in the Weex engine.

[0089] In summary, since the data structure is obtained by parsing the source file in the encoding stage, the syntax parsing step can be saved in the decoding process, thereby improving the decoding efficiency and interface rendering efficiency.

[0090] Furthermore, in the process of decoding the target encoded file contained in the content block, in order to quickly find the starting position of the content block and thus improve the decoding speed and decoding efficiency, the starting position of the content block can be determined first. The specific implementation method is as follows: decode the first type of target encoded file contained in the first content block of the integrated file to obtain a first type of data structure; determine the offset information in the first content block; determine the starting position of the second content block in the integrated file based on the offset information, and decode the second type of target encoded file contained in the second content block at the starting position to obtain a second type of data structure.

[0091] Specifically, the offset information is used to identify the starting position of the content block. The offset information in the first content block can identify the next content block, that is, the starting position of the second content block. The second content block can be found at this starting position, thereby decoding the second type of target encoding file contained in the second content block.

[0092] Based on this, when determining the starting position of the second content block in the integrated file, it can be determined by the offset information in the first content block. In one embodiment of the present specification, the offset information in the first content block may refer to the offset of the first content block, and at the starting position of the first content block, the starting position of the second content block is reached after passing the offset. Alternatively, the offset information in the first content block may refer to the offset between the first content block and the second content block, and at the end position of the first content block, the starting position of the second content block is reached after passing the offset.

[0093] For example, the offset in the first content block is determined to be L, and the position reached after the length L at the start position of the first content block is the start position of the second content block. Alternatively, the offset in the first content block is determined to be L, and the position reached after the length L at the end position of the first content block is the start position of the second content block.

[0094] In addition, the method of detecting the offset information is used to determine whether there is a next content block. For example, after the target coded file in the second content block is decoded, the second offset information can be determined from the second content block, and it can be detected whether it is 0. If the second offset information is 0, it means that there is no next content block, that is, there is no third content block, which further indicates that only two types of target coded files are stored in the integrated file, and the number of types of source files to be combined and packaged is determined. If the second offset information is not 0, it means that there is a next content block, that is, there is a third content block, which further indicates that at least three types of target coded files are stored in the integrated file.

[0095] The above embodiment illustrates how to determine the next content block, i.e., the starting position of the second content block, based on the offset information in the first content block. Based on this, in order to further improve the decoding speed and decoding efficiency, it is also necessary to determine the starting position of the first content block. The specific method is as follows: determine the file composition structure of the integrated file, wherein the file composition structure includes a file header and a content block, and the file header and the content block are arranged in sequence; determine the starting position of the first content block in the file composition structure according to the length of the file header.

[0096] Specifically, the file composition structure refers to the structure that constitutes the integrated file. In this embodiment, the composition structure of the integrated file includes a file header and a content block.

[0097] According to one embodiment of the present specification, the length of the file header is fixed. Since the file header and content blocks of the integrated file are arranged in sequence, the starting position of the first content block can be determined based on the length of the file header, thereby providing conditions for decoding the file stored in the first content block at the starting position of the first content block.

[0098] For example, in the attribute information of the integrated file, it is defined that the length of the file header is 32 bits. After the length of 32 bits, the starting position of the first content block can be reached.

[0099] In summary, by determining the starting position of each content block, the decoder can quickly find the starting position and decode each content block at the starting position, thereby improving the decoding speed and decoding efficiency.

[0100] Further, according to an embodiment of the present specification, in order to respectively decode the target encoded files in at least two content blocks, the first type of target encoded files can be decoded by a first type of decoder, and the second type of target encoded files can be decoded by a second type of decoder; wherein the decoding rules of the first type of decoder and the second type of decoder are different.

[0101] Specifically, the first type of target coding file is applicable to the decoding rules of the first type of decoder, and the second type of target coding file is applicable to the decoding rules of the second type of decoder.

[0102] Based on this, when decoding the integrated file, there is no restriction on the type of decoder. When the target encoded file stored in the content block is a first type of target encoded file, the first type of encoder is selected. This can support decoding of multiple different types of target encoded files, providing conditions for decoding the integrated file.

[0103] Continuing with the above example, after determining that the type of the target encoded file stored in the first content block is the JS type, select a JS type decoder to decode the JS type target encoded file. Correspondingly, after determining that the target encoded file stored in the second content block is the CSS type, select a CSS type decoder to decode the CSS type target encoded file.

[0104] Furthermore, since the rules of the decoders applicable to each type of target coded file are different, in order to improve the decoding speed and decoding efficiency, the type of the target coded file stored in the content block is determined, and then a decoder is quickly selected to decode it. The specific implementation method is as follows: the block types of the first content block and the second content block are determined respectively; based on the block type of the first content block, the type information of the first type of target coded file is determined, and, based on the block type of the second content block, the type information of the second type of target coded file is determined; based on the type information of the first type of target coded file, a first type of decoder is selected, and, based on the type information of the second type of target coded file, a second type of decoder is selected.

[0105] Specifically, the block type can be used to indicate the type of the target encoded file stored in the content block.

[0106] It can be understood that the block type of the first content block is the same as the type of the first type target coded file stored in the first content block, therefore, by determining the block type of the first content block, the type of the first type target coded file can be determined, and then the first type of decoder can be selected to decode the first type target coded file. Correspondingly, the block type of the second content block is also the same as the type of the second type target coded file stored in the second content block.

[0107] Based on this, after determining the starting position of the first content block, the block type of the first content block is read, and the type of the target encoding file in the first content block is determined according to the block type.

[0108] Continuing with the above example, after determining the starting position of the first content block, the block type of the first content block is read as the JS type. At this time, the type of the target encoding file in the first content block is determined to be the JS type. After decoding the JS type target encoding file, the starting position of the second content block is determined, and the block type of the second content block is read as the CSS type. At this time, the type of the target encoding file in the second content block is determined to be the CSS type.

[0109] In summary, determining the type of the target coded file by the block type provides convenient conditions for quickly selecting a decoder of the same type, thereby improving decoding efficiency.

[0110] Further, according to an embodiment of the present specification, when the result of judgment in step 404 is that the integrated file does not meet the decoding conditions, the error information of the integrated file is determined, and a report is generated based on the error information. The specific technical scheme is as follows: when the attribute information does not match the preset attribute information, the result of judgment is that the integrated file does not meet the decoding conditions, and the step of determining the error information of the integrated file and generating a report based on the error information is executed; correspondingly, when the version number is not less than the version number of the client, the result of judgment is that the integrated file does not meet the decoding conditions, and the step of determining the error information of the integrated file and generating a report based on the error information is executed; correspondingly, when the check code does not match the preset value, the result of judgment is that the integrated file does not meet the decoding conditions, and the step of determining the error information of the integrated file and generating a report based on the error information is executed.

[0111] Specifically, when one of the attribute information, version number and check code of the integrated file does not meet the decoding condition, error information of the integrated file is determined, and a report is generated according to the error information.

[0112] For example, judging whether the integrated file is a wlm file according to the attribute information of the integrated file, specifically, the magic number of the integrated file can be read from the file header. When the magic number does not match the preset attribute information, the integrated file is not a wlm file and does not meet the decoding conditions. At this time, the error information of the integrated file is determined, and a report is generated according to the error information. Alternatively, when the version number of the integrated file does not belong to the historical version number, the integrated file is incompatible with the parsing terminal and does not meet the decoding conditions. At this time, the error information of the integrated file is determined, and a report is generated according to the error information. Alternatively, when the checksum does not match the preset checksum, the integrated file is in a damaged state, the integrity of the integrated file cannot be guaranteed, and the decoding conditions are not met. At this time, the error information of the integrated file is determined, and a report is generated according to the error information. Specifically, the checksum algorithm can be used to calculate the checksum of the integrated file, and the data in the integrated file is summed according to int32. When the calculation result is not 0, it means that the integrated file is damaged during storage and transmission and does not meet the decoding conditions.

[0113] In summary, a judgment step is set before decoding, and an error report is generated for integrated files that do not meet the decoding conditions, thereby saving the decoding time for decoding integrated files that cannot be decoded, reducing decoding overhead, and improving decoding efficiency. In addition, the integrated file is judged based on various information such as the attribute information, checksum, and version number of the integrated file, and the integrated file can be judged from multiple angles, thereby improving judgment efficiency.

[0114] Corresponding to the above decoding method embodiment, this specification also provides a decoding device embodiment. Figure 3 FIG. 2 shows a schematic diagram of the structure of a decoding device provided in an embodiment of the present specification. Figure 3 As shown, the device includes: a first decoding module 302, configured to decode the file header of the integrated file to obtain identification information and attribute information of the integrated file; a judgment module 304, configured to judge whether the integrated file meets the decoding conditions based on the identification information and attribute information of the integrated file; a second decoding module 306, configured to, if so, decode the target encoded file contained in at least two content blocks of the integrated file to obtain at least two different types of data structures.

[0115] In an optional embodiment, the second decoding module 306 is further configured to: decode the first type of target encoding file contained in the first content block of the integrated file to obtain a first type of data structure; determine the offset information in the first content block; determine the starting position of the second content block in the integrated file based on the offset information, and decode the second type of target encoding file contained in the second content block at the starting position to obtain a second type of data structure.

[0116] In an optional embodiment, the second decoding module 306 is further configured to: decode the first type target encoded file through a first type decoder, and decode the second type target encoded file through a second type decoder; wherein the decoding rules of the first type decoder and the second type decoder are different.

[0117] In an optional embodiment, the judgment module 304 is further configured to: determine the attribute information of the integrated file; when the attribute information matches the preset attribute information, determine the version number in the identification information; when the version number belongs to a historical version number, determine the check code in the identification information; when the check code matches the preset check code, execute the step of decoding the target encoded file contained in at least two content blocks of the integrated file to obtain at least two different types of data structures.

[0118] The above is a schematic scheme of a decoding device of this embodiment. It should be noted that the technical scheme of the decoding device and the technical scheme of the above decoding method belong to the same concept, and the details not described in detail in the technical scheme of the decoding device can be referred to the description of the technical scheme of the above decoding method.

[0119] Corresponding to the above decoding method, an embodiment of this specification also provides an encoding method, which can be used in the development end or in the cloud. Figure 4 A schematic diagram of a coding method according to an embodiment of the present specification is shown. Figure 4As shown, based on at least two different types of source files, identification information of an integrated file corresponding to the two different types of source files is determined, and the identification information is written into a file header, wherein the identification information includes a checksum and a version number of the integrated file; then, the two different types of source files are encoded respectively to obtain a first type of target encoded file and a second type of target encoded file; finally, the first type of target encoded file is written into a first content block, and the second type of target encoded file is written into a second content block, thereby completing the process of merging the two source files into the integrated file. When downloading, the user only needs to download one integrated file, which reduces the number of downloads and download overhead. In addition, determining the checksum of the integrated file provides a self-checking capability for the integrated file, which can check the integrity of the integrated file based on the checksum. Accordingly, determining the version number of the integrated file provides the integrated file with the ability to identify compatibility.

[0120] It is understandable that, in an embodiment of the present specification, it is also possible to perform encoding processing on two different types of source files while determining the identification information of the integrated file corresponding to the two different types of source files.

[0121] Figure 5 A flowchart of an encoding method provided according to an embodiment of the present specification is shown, including steps 502 to 506.

[0122] Step 502: Based on at least two different types of source files, determine identification information of an integrated file corresponding to the at least two different types of source files, and write the identification information of the integrated file into a file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file.

[0123] Specifically, a source file is a resource file from which resources required by the user can be read, such as picture resources, audio resources, video resources, text resources, code resources and other contents. Identification information refers to information used to identify an integrated file. It can be understood that the identification information of the integrated file corresponding to different source files is different. For example, the identification information of the integrated file corresponding to the source file of type A and the source file of type B is different from the identification information of the integrated file corresponding to the source file of type A and the source file of type C. In other words, the integrated file generated by merging different source files has different expression contents of the corresponding identification information, which can be used to identify the type of target coded file included in the integrated file according to the identification information in the decoding stage of the integrated file, thereby providing conditions for decoding of multiple types of target coded files. The file header refers to the header of the integrated file, in which the identification information of the integrated file is stored. The checksum is one of the identification information of the integrated file, which is used to verify the integrity of the integrated file. The version number is one of the identification information of the integrated file, which is used to enable the user to identify the version of the integrated file and the functions provided.

[0124] Furthermore, the checksum algorithm can be used to calculate the checksum of the integrated file. For example, the sum of the numbers in the at least two different types of source files can be calculated according to int32, and then the checksum is obtained by bit inversion and written into the text header. It can be understood that the calculation method of the checksum in the embodiments of this specification is not limited to this, and the embodiments of this specification can also use other algorithms to calculate the checksum of the integrated file.

[0125] Furthermore, the version number of the integrated file corresponding to the at least two different types of source files may be determined according to the version information of the at least two different types of source files.

[0126] The identification information of the integrated file is written into the file header, which is used to identify the integrity and compatibility of the integrated file according to the identification information in the file header during the decoding stage. When the identification information of the integrated file is written into the file header, only a part of the integrated file is generated, and the complete integrated file is not generated. After the target encoded file is written into the content block, the information stored in the file header and the file stored in the content block together constitute the integrated file, thereby completing the merging and packaging of multiple source files.

[0127] In actual applications, in order to enrich the content displayed on the web page and increase the types of content displayed on the web page, it is usually necessary to download multiple types of source files to support it. The download and transmission of multiple types of source files are usually completed separately, that is, each type of source file is compressed and packaged separately, and then the compressed and packaged files are transmitted to the client separately. This packaging method makes the download efficiency low. When multiple types of source files are needed, multiple downloads are required, which increases the download overhead, and each type of source file needs to be decoded separately. The process is cumbersome and occupies more network resources. In view of this, this embodiment combines and packages multiple different types of source files into the same integrated file, which reduces the number of downloads and download overhead, and can meet the file requirements for enriching the web page display.

[0128] This embodiment illustrates the encoding method by taking the scenario of merging and packaging JS type source files and CSS type source files developed on the front end as an example. The description contents related to other scenarios can be referred to in this embodiment, and the same or corresponding description contents will not be elaborated in detail here.

[0129] In summary, by determining the verification code and version number of the integrated file, the integrated file can be provided with a self-verification capability for verifying integrity and compatibility, which enables the integrated file to implement a self-verification function in the decoding stage to ensure the integrity and compatibility of the integrated file entering the decoding stage, thereby improving decoding efficiency and saving decoding resources.

[0130] Step 504: Encode the at least two different types of source files respectively to obtain a first type of target encoded file and a second type of target encoded file.

[0131] Specifically, the first type of target coded file is obtained by encoding a first type of source file among at least two different types of source files, and the second type of target coded file is obtained by encoding a second type of source file among at least two different types of source files. The first type of target coded file and the second type of target coded file refer to files that can be recognized by a computer, and the target coded file is encoded by encoding a plurality of source files selected by a user, and the target coded file is transmitted to a client, and the target coded file is decoded to achieve format conversion, so that the client can display the content selected by the user through a web page, and the displayed content corresponds to the instruction submitted by the user, so as to meet the user's display requirements for the web page. In one embodiment of the present specification, the target coded file can be in binary format or in other formats.

[0132] In summary, encoding the at least two different types of source files separately is to achieve encryption protection of the content of the source files, thereby avoiding content leakage problems caused when the source files are directly transmitted and downloaded, and improving the security and confidentiality of file transmission.

[0133] In addition, in one embodiment of the present specification, three different types of source files can be encoded respectively to obtain a first type of target encoded file, a second type of target encoded file, and a third type of target encoded file. It can be understood that the first type of target encoded file is obtained by encoding the first type of source file among the three types of source files, the second type of target encoded file is obtained by encoding the second type of source file among the three types of source files, and the third type of target encoded file is obtained by encoding the third type of source file among the three types of source files. It can be understood that in this embodiment, the number of types of source files to be encoded can be set according to user needs, and users can select any number of different types of source files for combined downloading based on the needs of web page display. This embodiment does not limit the number of types of source files.

[0134] This embodiment is described by taking the merging of two source files as an example, and other situations can be referred to.

[0135] Furthermore, in order to improve the decoding efficiency of the integrated file in the decoding stage and thus reduce the resource usage in the decoding stage, in the process of encoding at least two different types of source files, the syntax of the source files is parsed, and the specific implementation method is as follows:

[0136] The syntax of the at least two different types of source files are parsed respectively to obtain a first type of operating data and a second type of operating data; the first type of operating data and the second type of operating data are written into a first type of data structure and a second type of data structure respectively; the first type of data structure and the second type of data structure are encoded respectively to obtain the first type of target encoding file and the second type of target encoding file.

[0137] Specifically, the first type of operating data refers to the data needed when the first type of source file is running. For example, the first type of operating data may include the syntax, functions, strings, word decoding, data interface, etc. needed when the first type of source file is running. Correspondingly, the second type of operating data refers to the data needed when the second type of source file is running. For example, the second type of operating data may include the syntax, functions, strings, word decoding, data interface, etc. needed when the second type of source file is running.

[0138] Based on this, in the process of encoding the first type of source file, the syntax of the first type of source file is first parsed to obtain the syntax, function, string, word decoding, data interface and other first type operation data required when the first type of source file is running, and then the above-mentioned first type of operation data is written into the first type of data structure, and the syntax parsing is completed in the encoding stage, so that the integrated file does not need to be parsed in the decoding stage, reducing the resource occupation of the decoding stage and improving the decoding efficiency. Correspondingly, the process of encoding the second type of source file is the same as the above-mentioned process of encoding the first type of source file, and will not be repeated here. Further, in one embodiment of the present specification, when the first type of operation data is written into the first type of data structure, the logical structure between the first type of operation data is also written into the first type of data structure, wherein the logical structure refers to the function call relationship between the first type of operation data, and it can be understood that the content in the source file can be determined according to the logical structure between the first type of operation data and the first type of operation data. Correspondingly, when the second type of operation data is written into the second type of data structure, the logical structure between the second type of operation data is also written into the second type of data structure.

[0139] In summary, in the encoding stage, the syntax of the at least two different types of source files are parsed separately to obtain the first type of operating data and its logical structure and the second type of operating data and its logical structure. This can avoid the user downloading the integrated file to the client and then parsing it, and can reduce the overhead of loading the source file in the decoding stage, thereby improving the decoding efficiency.

[0140] Furthermore, during the encoding process, in order to reduce the size of the first type target encoding file and the second type target encoding file, the first type running data and the second type running data are deduplicated respectively, and the specific implementation method is as follows.

[0141] The syntax of the at least two different types of source files are parsed respectively to obtain initial first type running data and initial second type running data; the initial first type running data is deduplicated to obtain intermediate first type running data, and the initial second type running data is deduplicated to obtain intermediate second type running data; the first type attribute information of repeated data in the initial first type running data is recorded, and the second type attribute information of repeated data in the initial second type running data is recorded, wherein the first type attribute information includes the first type position information of repeated data in the first type running data, and the second type attribute information includes the second type position information of repeated data in the second type running data; the first type running data is generated according to the first type attribute information and the intermediate first type running data, and the second type running data is generated according to the second type attribute information and the intermediate second type running data.

[0142] Specifically, the first type of attribute information includes a first type of data identifier and a first type of position information of repeated data in the first type of operating data, wherein the first type of data identifier can be used to determine the repeated data in the first type of operating data, and correspondingly, the second type of attribute information includes a second type of data identifier and a second type of position information of repeated data in the second type of operating data, wherein the second type of data identifier can be used to determine the repeated data in the second type of operating data.

[0143] Furthermore, the initial first type operating data is deduplicated, specifically, it refers to deleting duplicate data in the initial first type operating data, and the number of duplicate data in the initial first type operating data is reduced from multiple to one, and correspondingly, the initial second type operating data is deduplicated, specifically, it refers to deleting duplicate data in the initial second type operating data, and the number of duplicate data in the initial second type operating data is reduced from multiple to one.

[0144] In summary, by removing duplicate data, duplicate data can be prevented from appearing repeatedly in the integrated file, thereby reducing the size of the integrated file and improving download efficiency. In addition, by identifying duplicate data and recording the location information of duplicate data, the integrated file can restore the content of the source file more quickly and efficiently during the decoding stage.

[0145] This embodiment is described by taking encoding of JS type source files and CSS type source files as examples. For the encoding methods of at least two other different types of source files, please refer to the corresponding description content of this embodiment, and no further details will be given here.

[0146] For example, in order to support the display of information required by users on the web page interface, the front end generates JS type source files and CSS type source files in the development stage. Users need to download JS type source files and CSS type source files to the client, and the information can be displayed on the web page after decoding on the client. According to the encoding method provided in the embodiment of this specification, JS type source files and CSS type source files can be combined and packaged for download to improve download efficiency.

[0147] When merging a JS type source file and a CSS type source file, first, based on the JS type source file and the CSS type source file, determine the identification information of the integrated file corresponding to the JS type source file and the CSS type source file, and write the identification information including the verification code and version number of the integrated file into the file header of the integrated file; then, encode the JS type source file and the CSS type source file respectively to obtain a JS type target encoded file and a CSS type target encoded file.

[0148] Specifically, the syntax of the JS type source file is parsed to obtain the initial JS type running data such as strings and functions required when the JS type source file is running, and the duplicate data in the initial JS type running data is removed to obtain the intermediate JS type running data, and the data identifier and location information of the duplicate data in the initial JS type running data are determined, and the data identifier and location information of the intermediate JS type running data and the duplicate data are written into the JS type data structure, and then the JS type data structure is encoded and converted into the target format to obtain a JS type binary encoding file. Similarly, the processing process of the CSS type source file is similar to that of the JS type source file, and the CSS type binary encoding file can be obtained according to the processing results.

[0149] Further, according to an embodiment of the present specification, when encoding a first type of data structure and a second type of data structure, respectively, the first type of data structure is encoded by a first type of encoder, and the second type of data structure is encoded by a second type of encoder; wherein the encoding rules of the first type of encoder and the second type of encoder are different.

[0150] Specifically, the first type of data structure is applicable to the encoding rule of the first type of encoder, and the second type of data structure is applicable to the encoding rule of the second type of encoder.

[0151] Continuing with the above example, in the process of encoding JS type source files and CSS type source files, a JS type encoder is selected to encode the JS type data structure, and correspondingly, a CSS type encoder is selected to encode the CSS type data structure. It can be understood that the encoding rules of the JS type encoder and the CSS type encoder are different.

[0152] In the above embodiment, the type of encoder is not limited, that is, the type of encoder is determined according to the type of source file that needs to be encoded. Therefore, encoding processing of multiple types of source files can be implemented, and then the merging and packaging of multiple types of source files can be implemented.

[0153] Step 506: Write the first type target coded file and the second type target coded file into the first content block and the second content block of the integrated file respectively.

[0154] Specifically, after encoding the first type of source file to obtain the first type of target encoded file and encoding the second type of source file to obtain the second type of target encoded file, the first type of target encoded file is written into the first content block of the integrated file, and the second type of target encoded file is written into the second content block of the integrated file. The first content block is used to store the first type of target encoded file, and the second content block is used to store the second type of target encoded file. The first content block and the second content block are arranged in sequence in the integrated file. Among them, the integrated file already includes the identification information in the file header and the target encoded file in the content block. At this point, an integrated file containing the information of the two source files and the target encoded file is obtained, and the merging and packaging of the two source files is realized.

[0155] Further, according to an embodiment of the present specification, the file format of the integrated file is written into the file header of the integrated file, wherein the file format of the integrated file is used to define the attribute information of the integrated file.

[0156] Specifically, a file format refers to a special encoding method used to store information, and is used to identify the internally stored data. For example, file formats include formats for storing pictures, formats for storing programs, formats for storing text information, etc.

[0157] In one embodiment of the present specification, the file format of the integrated file may be a custom file format, which includes information such as the file composition structure of the integrated file and the length of the file composition structure. Specifically, the file composition structure may include a file header and a content block, which are arranged in sequence, wherein the number of content blocks may be determined according to the number of source files to be merged and packaged, for example, when there are two source files to be merged, two content blocks are provided in the corresponding integrated file, and when there are three source files to be merged, three content blocks are provided in the corresponding integrated file, and each content block is arranged in sequence.

[0158] In addition, in one embodiment of the present specification, the length of the file header may be fixed, and in this case, the starting position of the content block may be determined based on the length of the file header.

[0159] For example, the file format of the integrated file can be a custom wlm file format, in which a magic number belonging to the wlm file is defined to identify the attribute information of the integrated file. Specifically, the magic number can be used to identify whether the integrated file is in the wlm file format. In addition, the length of the file header and the length of the content block are also defined. It can be understood that the length of the content block can be pre-set or determined according to the size of the file stored in the content block.

[0160] In summary, writing the file format of the integrated file into the file header makes it easier to identify the format attributes of the integrated file. In addition, defining this file format can facilitate writing multiple different types of files into content blocks separately, so that multiple files can be partitioned and stored in the integrated file, which facilitates the decoding of a single file and reduces loading overhead.

[0161] In summary, an encoding method provided by an embodiment of the present specification determines identification information of an integrated file corresponding to at least two different types of source files based on at least two different types of source files, and writes the identification information into a file header of the integrated file. At this time, the file header of the integrated file stores the identification information of the integrated file, and the identification information can be used to identify the source files merged and packaged into the integrated file; then, encoding is performed on at least two different types of source files respectively to obtain a first type of target encoded file and a second type of target encoded file, and encryption protection of the source file content is achieved in the process of merging and packaging the source files; finally, the first type of target encoded file and the second type of target encoded file are written into the first content block and the second content block of the integrated file respectively, so that different types of source files can be packaged into the same integrated file, providing an extended function of multi-type file packaging, reducing download overhead and download times, and improving download efficiency.

[0162] Corresponding to the above encoding method embodiment, this specification also provides an encoding device embodiment, Figure 6 FIG. 1 shows a schematic diagram of the structure of a coding device provided in an embodiment of this specification. Figure 6 As shown, the device includes: a first writing module 602, which is configured to determine the identification information of the integrated file corresponding to the at least two different types of source files based on at least two different types of source files, and write the identification information of the integrated file into the file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file; an encoding module 604, which is configured to encode the at least two different types of source files respectively to obtain a first type of target encoded file and a second type of target encoded file; a second writing module 606, which is also configured to write the first type of target encoded file and the second type of target encoded file into the first content block and the second content block of the integrated file respectively.

[0163] In an optional embodiment, the encoding module 604 is further configured to: parse the syntax of the at least two different types of source files respectively to obtain first type running data and second type running data; write the first type running data and the second type running data into a first type data structure and a second type data structure respectively; encode the first type data structure and the second type data structure respectively to obtain the first type target encoding file and the second type target encoding file.

[0164] In an optional embodiment, the encoding module 604 is further configured to: parse the syntax of the at least two different types of source files respectively to obtain initial first type running data and initial second type running data; deduplicate the initial first type running data to obtain intermediate first type running data, and deduplicate the initial second type running data to obtain intermediate second type running data; record first type attribute information of repeated data in the initial first type running data, and record second type attribute information of repeated data in the initial second type running data, wherein the first type attribute information includes first type position information of repeated data in the first type running data, and the second type attribute information includes second type position information of repeated data in the second type running data; generate the first type running data according to the first type attribute information and the intermediate first type running data, and generate the second type running data according to the second type attribute information and the intermediate second type running data.

[0165] In an optional embodiment, the encoding module 604 is further configured to: encode the first type of data structure through a first type of encoder, and encode the second type of data structure through a second type of encoder; wherein the encoding rules of the first type of encoder and the second type of encoder are different.

[0166] In an optional embodiment, the first writing module 602 is further configured to: write the file format of the integrated file into the file header of the integrated file, wherein the file format of the integrated file is used to define attribute information of the integrated file.

[0167] In summary, in an encoding device provided by an embodiment of the present specification, a first writing module determines identification information of an integrated file corresponding to at least two different types of source files based on at least two different types of source files, and writes the identification information into a file header of the integrated file. At this time, the file header of the integrated file stores the identification information of the integrated file, and the identification information can be used to identify the source files merged and packaged into the integrated file; then, the at least two different types of source files are encoded by the encoding module respectively to obtain a first type of target encoded file and a second type of target encoded file, and encryption protection of the source file content is achieved in the process of merging and packaging the source files; finally, the second writing module writes the first type of target encoded file and the second type of target encoded file into the first content block and the second content block of the integrated file respectively, so that different types of source files can be packaged into the same integrated file, providing an extended function of multi-type file packaging, reducing download overhead and download times, and improving download efficiency.

[0168] The above is a schematic scheme of a coding device of this embodiment. It should be noted that the technical scheme of the coding device and the technical scheme of the above coding method belong to the same concept, and the details of the technical scheme of the coding device that are not described in detail can all be referred to the description of the technical scheme of the above coding method.

[0169] The embodiment of this specification also provides an encoding method, Figure 7 A flowchart of an encoding method provided according to an embodiment of the present specification is shown, which specifically includes the following steps 702 to 706.

[0170] Step 702: Based on at least two different types of source files, determine identification information of an integrated file corresponding to the at least two different types of source files, and write the identification information of the integrated file into a file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file.

[0171] Step 704: Encode the at least two different types of source files respectively to obtain target encoded files of each type.

[0172] Step 706: Write each type of target coded file into the content block of the integrated file respectively, wherein each content block stores one type of target coded file.

[0173] The encoding method provided in the above embodiment belongs to the same technical concept as the encoding method in the aforementioned embodiment, and will not be repeated here.

[0174] Corresponding to the above-mentioned encoding method embodiment, this specification also provides a decoding method embodiment, which is the same as the decoding method in the above-mentioned embodiment, and the decoding method includes: decoding the file header of the integrated file to obtain the identification information and attribute information of the integrated file; judging whether the integrated file meets the decoding conditions according to the identification information and attribute information of the integrated file; if so, decoding the target encoded files contained in at least two content blocks of the integrated file to obtain at least two different types of data structures.

[0175] Corresponding to the above encoding method embodiment, this specification also provides an encoding device embodiment, Figure 8 FIG. 1 shows a schematic diagram of the structure of a coding device provided in an embodiment of this specification. Figure 8 As shown, the device includes: a first writing module 802, which is configured to determine the identification information of the integrated file corresponding to the at least two different types of source files based on at least two different types of source files, and write the identification information of the integrated file into the file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file; an encoding module 804, which is configured to encode the at least two different types of source files respectively to obtain target encoded files of each type; a second writing module 806, which is also configured to write the target encoded files of each type into the content blocks of the integrated file respectively, wherein each of the content blocks stores a type of target encoded file.

[0176] The above is a schematic scheme of a coding device of this embodiment. It should be noted that the technical scheme of the coding device and the technical scheme of the above coding method belong to the same concept, and the details of the technical scheme of the coding device that are not described in detail can all be referred to the description of the technical scheme of the above coding method.

[0177] Corresponding to the above-mentioned decoding method and encoding method, an embodiment of the present specification also provides a file processing method, including: the encoding module writes the identification information and attribute information of the integrated file corresponding to the at least two different types of source files into the file header of the integrated file, encodes the at least two different types of source files respectively to obtain a first type of target encoded file and a second type of target encoded file, writes the first type of target encoded file and the second type of target encoded file into the first content block and the second content block of the integrated file respectively to obtain a target integrated file; the decoding module decodes the file header of the target integrated file to obtain the identification information and attribute information of the target integrated file, and when it is determined that the target integrated file meets the decoding conditions based on the identification information and attribute information of the target integrated file, decodes the first type of target encoded file to obtain a first type of data structure, and decodes the second type of target encoded file to obtain a second type of data structure.

[0178] Specifically, the encoding module can be used to execute the above encoding method, and the encoding module can be a development front end. The decoding module is used to execute the above decoding method, and the decoding module can be a client.

[0179] The file processing method provided in the above embodiment corresponds to the above encoding method and decoding method, and belongs to a unified technical concept, which will not be described in detail here.

[0180] The following combination Fig. 9 and Fig.10 , taking the encoding + decoding method provided by this application for merging and packaging JS type source files and CSS type source files developed by the front-end as an example, the encoding + decoding method is further explained. Among them, Fig. 9 A schematic diagram of the processing structure of an encoding + decoding method provided according to an embodiment of this specification is shown, such as Fig. 9 As shown, the encoding method can be executed on the front end, and the integrated file after encoding is published to the CDN address. The user can download the integrated file to the client from the CDN address, and the decoding method is executed on the client. Fig.10 A processing flow chart of an encoding+decoding method provided according to an embodiment of this specification is shown, and the specific steps are as follows.

[0181] Step 1002: write the version number and the checksum determined based on the JS type source file and the CSS type source file into the file header of the integrated file.

[0182] Specifically, the checksum algorithm is used to calculate the data sum of the JS type source file and the CSS type source file, and the calculation result is inverted to obtain a check code.

[0183] Step 1004, respectively parse the syntax of the JS type source file and the CSS type source file to obtain JS type running data and CSS type running data.

[0184] Specifically, the syntax of the JS type source file is parsed by a JS type parser to obtain JS type running data such as strings and functions required when the JS type source file is running. The syntax of the CSS type source file is parsed by a CSS type parser to obtain CSS type running data such as strings and functions required when the CSS type source file is running.

[0185] Step 1006, deduplicate the JS type running data and the CSS type running data respectively, and write them into the JS type data structure and the CSS type data structure.

[0186] Specifically, determine the duplicate data in the JS type running data, and record the location information of the duplicate data, delete the duplicate data until only one is retained, determine the logical structure between the JS type running data, and write into the JS type data structure. Accordingly, perform similar operations on the CSS type running data, which will not be repeated here.

[0187] Step 1008, encoding the JS type data structure and the CSS type data structure respectively to obtain a JS type target encoding file and a CSS type target encoding file.

[0188] Step 1010: Write the JS type target encoding file and the CSS target encoding file into the first content block and the second content block respectively.

[0189] Step 1012, decoding the file header of the integrated file to obtain the checksum, version number and attribute information of the integrated file.

[0190] Step 1014, judging whether the integrated file meets the decoding condition according to the check code, version number and attribute information.

[0191] Specifically, the attribute information includes a magic number of the integrated file. When the magic number matches the preset attribute information, the decoding condition is met and the decoding step is executed. When the magic number does not match the preset attribute information, the decoding condition is not met. At this time, error information of the integrated file is determined and a report is generated based on the error information.

[0192] Alternatively, when the version number is a historical version number, the result of the judgment is that the integrated file meets the decoding conditions, and the decoding step is executed. When the version number of the integrated file does not belong to the historical version number, the integrated file is incompatible with the parsing terminal and does not meet the decoding conditions. At this time, the error information of the integrated file is determined, and a report is generated based on the error information.

[0193] Alternatively, when the checksum matches the preset checksum, the result of the judgment is that the integrated file meets the decoding conditions, and the decoding step is executed. When the checksum does not match the preset checksum, the integrated file is in a damaged state, the integrity of the integrated file cannot be guaranteed, and the decoding conditions are not met. At this time, the error information of the integrated file is determined, and a report is generated based on the error information. Specifically, the checksum of the integrated file can be calculated by the checksum algorithm, and the data in the integrated file is summed according to int32. When the calculation result is not 0, it means that the integrated file is damaged during storage and transmission and does not meet the decoding conditions. When the calculation result is 0, it means that the integrated file maintains integrity and is not damaged during storage and transmission, and meets the decoding conditions.

[0194] Step 1016: If yes, decode the JS type target encoding file and the CSS type target encoding file stored in the content block in the integrated file to obtain a JS type data structure and a CSS type data structure.

[0195] Specifically, first determine the first content block, read the block type of the first content block as JS type, determine that a JS type target encoding file is stored in the first content block, use a JS type decoder to decode the JS type target encoding file to obtain a JS type data structure, read the offset information in the first content block, the offset information at this time is a preset value, determine that there is a second content block, read the block type of the second content block as CSS type, determine that a CSS type target encoding file is stored in the second content block, use a CSS type decoder to decode the CSS type target encoding file to obtain a CSS type data structure.

[0196] Afterwards, the second offset information in the second content block is read. At this time, the second offset information is 0, and the third content block does not exist. The decoding is now completed.

[0197] Step 1018, execute the JS type data structure through the JS engine, execute the CSS type data structure through the CSS engine, write the execution results of the JS engine and the CSS engine into the Weex engine for interface rendering to generate a web page.

[0198] In summary, through the above encoding + decoding method, it is possible to realize the combined package download of multiple different types of source files for front-end development, reduce the number of downloads and download overhead, reduce the resource usage of the client, and improve the efficiency of web page generation.

[0199] It should be noted that the encoding process and the decoding process can occur continuously. That is to say, after the source files developed on the front-end are merged and packaged into an integrated file and the integrated file is downloaded to the client, the user can decode it immediately or after a period of time. In other words, the encoding process and the decoding process of the integrated file can be continuous or discontinuous.

[0200] Fig.11 The block diagram of a computing device according to an embodiment of the present specification is shown. The components of the computing device 1100 include but are not limited to a memory 1110 and a processor 1120. The processor 1120 is connected to the memory 1110 via a bus 1130, and the database 1150 is used to store data.

[0201] The computing device 1100 also includes an access device 1140 that enables the computing device 1100 to communicate via one or more networks 1160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1040 may include one or more of any type of network interface (e.g., a network interface card (NIC)) wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0202] In one embodiment of the present specification, the above components of the computing device 1100 and Fig.11 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.11 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0203] The computing device 1100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 1100 may also be a mobile or stationary server.

[0204] Among them, when the processor 1120 executes the computer instructions, the steps of the encoding method or the decoding method are implemented.

[0205] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above encoding method or decoding method belong to the same concept, and the details of the technical scheme of the computing device that are not described in detail can be referred to the description of the technical scheme of the above encoding method or decoding method.

[0206] An embodiment of the present specification further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the encoding method or decoding method as described above.

[0207] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above encoding method or decoding method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above encoding method or decoding method.

[0208] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above encoding method or decoding method.

[0209] The above is an illustrative solution of a computer program of this embodiment. It should be noted that the technical solution of the computer program and the technical solution of the above encoding method or decoding method belong to the same concept, and the details not described in detail in the technical solution of the computer program can be referred to the description of the technical solution of the above encoding method or decoding method.

[0210] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0211] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0212] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0213] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0214] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A decoding method, comprising: Decoding the file header of the integrated file to obtain identification information and attribute information of the integrated file; Determining whether the integrated file meets the decoding condition according to the identification information and attribute information of the integrated file, wherein the identification information includes a checksum and a version number of the integrated file, and the attribute information is used to define the file format of the integrated file; If so, the target coded files included in the at least two content blocks of the integrated file are decoded to obtain at least two different types of data structures, wherein the data structures are obtained by parsing the source files corresponding to the target coded files during the encoding stage of the integrated file, wherein the target coded files included in the at least two content blocks include a first type of target coded files and a second type of target coded files; The steps of obtaining the first type target coded file and the second type target coded file include: Parsing the syntax of the at least two different types of source files respectively to obtain first type of operation data and second type of operation data; Writing the first type of operation data and the logical structure between the first type of operation data, and the second type of operation data and the logical structure between the second type of operation data into the first type of data structure and the second type of data structure, respectively; The first type data structure and the second type data structure are respectively encoded to obtain the first type target encoded file and the second type target encoded file.

2. The decoding method according to claim 1, wherein the step of decoding the target coded file contained in at least two content blocks of the integrated file to obtain at least two different types of data structures comprises: Decoding a first type of target coded file contained in a first content block of the integrated file to obtain a first type of data structure; Determining offset information in the first content block; The starting position of the second content block in the integrated file is determined according to the offset information, and the second type target encoding file contained in the second content block is decoded at the starting position to obtain a second type data structure.

3. The decoding method according to claim 2, after obtaining at least two different types of data structures, further comprising: Processing the first type of data structure by a first type of processing engine, and processing the second type of data structure by a second type of processing engine to generate a rendering interface associating the first type of data structure and the second type of data structure; The operation rules of the first type processing engine and the second type processing engine are different.

4. The decoding method according to claim 2, wherein the step of decoding the target coded file contained in at least two content blocks of the integrated file to obtain at least two different types of data structures comprises: Decoding the first type of target coded file by a first type of decoder, and decoding the second type of target coded file by a second type of decoder; The decoding rules of the first type decoder and the second type decoder are different.

5. The decoding method according to claim 1, wherein judging whether the integrated file meets the decoding condition according to the identification information and attribute information of the integrated file comprises: Determining attribute information of the integrated file; In the case where the attribute information matches the preset attribute information, determining the version number in the identification information; If the version number is a historical version number, determining a checksum in the identification information; In the case where the verification code matches the preset verification code, the step of decoding the target coded file included in the at least two content blocks of the integrated file to obtain at least two different types of data structures is performed.

6. A coding method comprising: Based on at least two different types of source files, determining identification information of an integrated file corresponding to the at least two different types of source files, and writing the identification information of the integrated file into a file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file; Parsing the syntax of the at least two different types of source files respectively to obtain first type of operation data and second type of operation data; Writing the first type of operation data and the logical structure between the first type of operation data, and the second type of operation data and the logical structure between the second type of operation data into the first type of data structure and the second type of data structure, respectively; Encoding the first type of data structure and the second type of data structure respectively to obtain the first type of target encoded file and the second type of target encoded file; The first type target encoding file and the second type target encoding file are written into the first content block and the second content block of the integrated file respectively, wherein the file format of the integrated file includes the file composition structure of the integrated file, the file composition structure includes the file header and content blocks, and the number of the content blocks is determined according to the number of the source files.

7. The encoding method according to claim 6, characterized in that: The step of respectively parsing the syntax of the at least two different types of source files to obtain the first type of operating data and the second type of operating data comprises: Parsing the syntax of the at least two different types of source files respectively to obtain initial first type running data and initial second type running data; Deduplication is performed on the initial first type operation data to obtain intermediate first type operation data, and deduplication is performed on the initial second type operation data to obtain intermediate second type operation data; Recording first type attribute information of repeated data in the initial first type running data, and recording second type attribute information of repeated data in the initial second type running data, wherein the first type attribute information includes first type position information of repeated data in the first type running data, and the second type attribute information includes second type position information of repeated data in the second type running data; The first type of operation data is generated according to the first type of attribute information and the intermediate first type of operation data, and the second type of operation data is generated according to the second type of attribute information and the intermediate second type of operation data.

8. The encoding method according to claim 6, wherein the step of encoding the first type of data structure and the second type of data structure respectively comprises: Encoding the first type of data structure by a first type of encoder, and encoding the second type of data structure by a second type of encoder; The encoding rules of the first type encoder and the second type encoder are different.

9. The encoding method according to claim 6, further comprising: The file format of the integrated file is written into the file header of the integrated file, wherein the file format of the integrated file is used to define the attribute information of the integrated file.

10. A coding method comprising: Based on at least two different types of source files, determining identification information of an integrated file corresponding to the at least two different types of source files, and writing the identification information of the integrated file into a file header of the integrated file, wherein the identification information of the integrated file includes a checksum and a version number of the integrated file; Parsing the syntax of the at least two different types of source files respectively to obtain first type of operation data and second type of operation data; Writing the first type of operation data and the logical structure between the first type of operation data, and the second type of operation data and the logical structure between the second type of operation data into the first type of data structure and the second type of data structure, respectively; Encoding the first type of data structure and the second type of data structure respectively to obtain the first type of target encoded file and the second type of target encoded file; Each type of target coded file is written into the content block of the integrated file respectively, wherein each content block stores one type of target coded file, the file format of the integrated file includes the file composition structure of the integrated file, the file composition structure includes the file header and content blocks, and the number of the content blocks is determined according to the number of the source files.

11. A file processing method, comprising: The encoding module writes identification information and attribute information of the integrated file corresponding to at least two different types of source files into the file header of the integrated file, parses the syntax of the at least two different types of source files respectively to obtain first type running data and second type running data; writes the first type running data and the logical structure between the first type running data and the logical structure between the second type running data and the second type running data into the first type data structure and the second type data structure respectively; encodes the first type data structure and the second type data structure respectively to obtain the first type target encoding file and the second type target encoding file, writes the first type target encoding file and the second type target encoding file into the first content block and the second content block of the integrated file respectively to obtain the target integrated file, wherein the file format of the integrated file includes the file composition structure of the integrated file, the file composition structure includes the file header and content blocks, and the number of the content blocks is determined according to the number of the source files; The decoding module decodes the file header of the target integrated file to obtain identification information and attribute information of the target integrated file, and when determining that the target integrated file meets the decoding conditions based on the identification information and attribute information of the target integrated file, decodes the first type of target encoded file to obtain a first type of data structure, and decodes the second type of target encoded file to obtain a second type of data structure, wherein the identification information includes a checksum and a version number of the integrated file, and the attribute information is used to define the file format of the integrated file.

12. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of claims 1-5, 6-9, 10 or 11 when executing the computer instructions.

13. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the method described in any one of claims 1-5, 6-9, 10 or 11.

Citation Information

Patent Citations

  • Information encoding method, device and apparatus for detection report, and storage medium

    CN110675931A