A file package acquisition method and device, computer device and storage medium

By sending file package dependency information to the server through the browser, the server generates and merges the file packages, and the browser receives and stores the target file package information, the problem of low efficiency in obtaining Node.js file packages by the browser is solved, and more efficient file package retrieval is achieved.

CN114722002BActive Publication Date: 2026-06-16DOUYIN VISION CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DOUYIN VISION CO LTD
Filing Date
2022-04-11
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Due to the limitations of JavaScript's single-threaded model, browsers have a limited number of concurrent requests when retrieving Node.js file packages. Network requests are time-consuming, and unpacking operations are also time-consuming, reducing the efficiency of file package retrieval.

Method used

The browser sends file package dependency information to the server. The server generates the target dependency tree and merges the file packages. The browser only receives and stores the target file package information and dependency tree, omitting the unpacking operation.

🎯Benefits of technology

By reducing browser network I/O and unpacking operations, the efficiency of file package retrieval is improved, thus increasing the speed and efficiency of file package retrieval.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114722002B_ABST
    Figure CN114722002B_ABST
Patent Text Reader

Abstract

The present disclosure provides a file package acquisition method and device, computer equipment and a storage medium, wherein the method comprises: based on the file package dependency information corresponding to the target service, sending a file package acquisition request carrying the file package dependency information to the server; receiving the target file package information and the target dependency tree fed back by the server; the target dependency tree is generated by the server based on the file package dependency information, the target file package information is generated by the server after content merging of a plurality of initial file packages obtained from a node package manager (NPM) platform, and the initial file package is obtained from the NPM platform according to the download address information corresponding to the node in the target dependency tree; and storing the target file package information and the target dependency tree to a target storage location, wherein the stored target file package information and target dependency tree are used for running the target service.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more specifically, to a method, apparatus, computer device, and storage medium for obtaining file packages. Background Technology

[0002] Node.js, as a JavaScript runtime environment, allows different development modules to correspond to different Node.js packages during code development. The Node Package Manager (NPM) platform, as a management tool for various Node.js packages, can run on machines that support Node.js.

[0003] As a machine that supports JavaScript execution, browsers inevitably need to retrieve Node.js packages during actual development. To retrieve these packages, the browser typically needs to send numerous network requests to the NPM platform, and after obtaining the Node.js packages returned by NPM, the browser also needs to perform unpacking operations.

[0004] However, since browsers are based on a single-threaded JavaScript model, they have concurrency limitations and can only make a limited number of requests. Making a large number of network requests takes a lot of time, reducing the efficiency of obtaining Node.js file packages. Furthermore, the browser also needs time to perform unpacking operations, which further reduces the efficiency of obtaining the packages. Summary of the Invention

[0005] This disclosure provides at least one method, apparatus, computer device, and storage medium for obtaining file packages.

[0006] In a first aspect, embodiments of this disclosure provide a method for obtaining a file package, applied to a browser, including:

[0007] Based on the file package dependency information corresponding to the target business, a file package retrieval request carrying the file package dependency information is sent to the server;

[0008] The server receives target file package information and target dependency tree from the server. The target dependency tree is generated by the server based on the file package dependency information. The target file package information is generated by the server after merging the contents of multiple initial file packages obtained from the NPM platform. The initial file packages are obtained from the NPM platform according to the download address information corresponding to the nodes in the target dependency tree.

[0009] The target file package information and the target dependency tree are stored in the target storage location, wherein the stored target file package information and the target dependency tree are used for the operation of the target service.

[0010] In one possible implementation, storing the target file package information and the target dependency tree to the target storage location includes:

[0011] Store the target file package information and convert the target dependency tree into a directory structure tree;

[0012] In the file system corresponding to the browser, each file path indicated by the directory structure tree is marked and stored; wherein, when a marked file path is accessed, the file content corresponding to the initial file package at that file path needs to be obtained from the stored target file package information using a file processing service.

[0013] In one possible implementation, after marking and storing each file path indicated by the directory structure tree, the method further includes:

[0014] In response to a file content retrieval request, if the file system is used to determine that the request path carried in the file content retrieval request matches the target file path marked as complete, the file processing service in the browser is invoked.

[0015] Using the file processing service, the target merged file package containing the target file content corresponding to the target file path is determined from the target metadata carried by the target file package information, as well as the target position of the target file content in the target merged file package;

[0016] Read the contents of the target file from the target location in the target merged file package.

[0017] In one possible implementation, the method further includes:

[0018] If it is determined that there is no target file path that matches the request path carried in the file content retrieval request, the file content retrieval request is sent to the NPM platform;

[0019] Receive the target file content from the NPM platform in response to the file content acquisition requirement.

[0020] Secondly, this disclosure also provides a method for obtaining a file package, applied to a server, including:

[0021] The system receives a file package retrieval request from the browser and uses the NPM service module to determine the target dependency tree corresponding to the file package dependency information carried in the file package retrieval request. The file package retrieval request is generated and sent by the browser after determining that it needs to retrieve the initial file package corresponding to the target service.

[0022] Based on the download address information of the initial file package corresponding to each node in the target dependency tree, obtain multiple initial file packages corresponding to the target service from the NPM platform;

[0023] A file package content merging operation is performed on multiple initial file packages to obtain target file package information corresponding to the target dependency tree; the target file package information includes target metadata and a preset number of merged file packages; the target metadata is used to characterize the position and basic attribute information of each initial file package in the merged file package.

[0024] The target file package information and the target dependency tree are sent to the browser.

[0025] In one possible implementation, the step of using the NPM service module to obtain the file package dependency information carried in the file package request and determining the target dependency tree corresponding to the file package dependency information includes:

[0026] The NPM service module is used to parse the file package dependency information to determine each sub-dependency package in the file package dependency information; each sub-dependency package corresponds to a node in the target dependency tree;

[0027] Based on the version condition information and file package name information in the sub-dependency package, a node meta information retrieval request is generated and sent to the NPM platform;

[0028] Obtain the node metadata information returned by the NPM platform in response to the node metadata acquisition request; the node metadata information includes the download address information of the initial file package;

[0029] The target dependency tree is generated based on the acquired metadata of each node.

[0030] In one possible implementation, the step of performing a file package content merging operation on multiple initial file packages to obtain target file package information corresponding to the target dependency tree includes:

[0031] The multiple initial file packages are divided into a preset number of file groups, and the contents of each initial file package in each file group are merged to obtain a merged file package corresponding to each file group; wherein the sum of the sizes of each initial file package in each file group is within a preset range.

[0032] The target metadata is generated based on the basic attribute information of each initial file package included in each merged file package and the position of each initial file package in the merged file package;

[0033] The target metadata and the merged file package corresponding to each file group are used as the target file package information.

[0034] In one possible implementation, before dividing the plurality of initial file packages into a preset number of file groups, the method further includes:

[0035] For each of the acquired initial file packages, the content of the target type files in the initial file package is deleted to reduce the size of each initial file package; wherein, the target type is a content type corresponding to the pre-determined file content that the browser does not need to use.

[0036] In one possible implementation, after sending the target file package information and the target dependency tree to the browser, the method further includes:

[0037] Receive new file package retrieval requests sent by the browser;

[0038] If it is determined that the new file package acquisition request includes the target dependency tree, multiple new initial file packages corresponding to the target service are obtained from the NPM platform according to the download address information corresponding to each node in the target dependency tree;

[0039] Perform a file package content merging operation on multiple new initial file packages to obtain new target file package information corresponding to the target dependency tree, and send the new target file package information to the browser.

[0040] Thirdly, embodiments of this disclosure also provide a file package acquisition device, applied to a browser, comprising:

[0041] The first sending module is used to send a file package acquisition request carrying the file package dependency information to the server based on the file package dependency information corresponding to the target service.

[0042] The first receiving module is used to receive target file package information and target dependency tree fed back by the server; the target dependency tree is generated by the server based on the file package dependency information, the target file package information is generated by the server after merging the contents of multiple initial file packages obtained from the node package manager NPM platform, and the initial file packages are obtained from the NPM platform according to the download address information corresponding to the nodes in the target dependency tree;

[0043] A storage module is used to store the target file package information and the target dependency tree to a target storage location, wherein the stored target file package information and the target dependency tree are used for the operation of the target service.

[0044] In one possible implementation, the storage module, when storing the target file package information and the target dependency tree to the target storage location, is used to store the target file package information and convert the target dependency tree into a directory structure tree;

[0045] In the file system corresponding to the browser, each file path indicated by the directory structure tree is marked and stored; wherein, when a marked file path is accessed, the file content corresponding to the initial file package at that file path needs to be obtained from the stored target file package information using a file processing service.

[0046] In one possible implementation, the device further includes:

[0047] The reading module is configured to, after marking and storing each file path indicated by the directory structure tree, invoke the file processing service in the browser in response to a file content retrieval request, provided that the request path carried in the file content retrieval request matches the marked target file path, using the file system.

[0048] Using the file processing service, the target merged file package containing the target file content corresponding to the target file path is determined from the target metadata carried by the target file package information, as well as the target position of the target file content in the target merged file package;

[0049] Read the contents of the target file from the target location in the target merged file package.

[0050] In one possible implementation, the reading module is further configured to send the file content acquisition request to the NPM platform if it is determined that there is no target file path that matches the request path carried in the file content acquisition request.

[0051] Receive the target file content from the NPM platform in response to the file content acquisition requirement.

[0052] Fourthly, embodiments of this disclosure also provide a file package acquisition device, applied to a server, comprising:

[0053] The second receiving module is used to receive a file package retrieval request sent by the browser, and to use the NPM service module to determine the target dependency tree corresponding to the file package dependency information carried in the file package retrieval request; the file package retrieval request is generated and sent by the browser after determining that it needs to retrieve the initial file package corresponding to the target service.

[0054] The acquisition module is used to acquire multiple initial file packages corresponding to the target service from the NPM platform based on the download address information of the initial file packages corresponding to each node in the target dependency tree.

[0055] The merging module is used to perform a file package content merging operation on multiple initial file packages to obtain target file package information corresponding to the target dependency tree; the target file package information includes target metadata and a preset number of merged file packages; the target metadata is used to characterize the position and basic attribute information of each initial file package in the merged file package.

[0056] The second sending module is used to send the target file package information and the target dependency tree to the browser.

[0057] In one possible implementation, the second receiving module, when using the NPM service module to obtain the file package dependency information carried in the file package request and determine the target dependency tree corresponding to the file package dependency information, is used to use the NPM service module to parse the file package dependency information and determine each sub-dependency package in the file package dependency information; each sub-dependency package corresponds to a node in the target dependency tree;

[0058] Based on the version condition information and file package name information in the sub-dependency package, a node meta information retrieval request is generated and sent to the NPM platform;

[0059] Obtain the node metadata information returned by the NPM platform in response to the node metadata acquisition request; the node metadata information includes the download address information of the initial file package;

[0060] The target dependency tree is generated based on the acquired metadata of each node.

[0061] In one possible implementation, when the merging module performs a file package content merging operation on the multiple initial file packages to obtain the target file package information corresponding to the target dependency tree, it is used to divide the multiple initial file packages into a preset number of file groups, and merge each initial file package included in each file group to obtain a merged file package corresponding to each file group; wherein the sum of the volumes of the initial file packages included in each file group differs within a preset range;

[0062] The target metadata is generated based on the basic attribute information of each initial file package included in each merged file package and the position of each initial file package in the merged file package;

[0063] The target metadata and the merged file package corresponding to each file group are used as the target file package information.

[0064] In one possible implementation, the device further includes:

[0065] The deletion module is used to delete the content of files of a target type in each of the acquired initial file packages before dividing the plurality of initial file packages into a preset number of file groups, so as to reduce the size of each initial file package; wherein the target type is a content type corresponding to file content that is predetermined and not needed by the browser.

[0066] In one possible implementation, the device further includes:

[0067] The third receiving module is used to receive a new file package retrieval request sent by the browser after the target file package information and the target dependency tree are sent to the browser;

[0068] If it is determined that the new file package acquisition request includes the target dependency tree, multiple new initial file packages corresponding to the target service are obtained from the NPM platform according to the download address information corresponding to each node in the target dependency tree;

[0069] Perform a file package content merging operation on multiple new initial file packages to obtain new target file package information corresponding to the target dependency tree, and send the new target file package information to the browser.

[0070] Fifthly, an optional implementation of this disclosure also provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is configured to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the steps of the first aspect above, or any possible implementation of the first aspect, are performed.

[0071] In a sixth aspect, an optional implementation of this disclosure also provides a computer-readable storage medium storing a computer program that, when run, performs the steps of the first aspect or any possible implementation of the first aspect.

[0072] For a description of the effects of the aforementioned file package acquisition device, computer equipment, and computer-readable storage medium, please refer to the description of the file package acquisition method above; it will not be repeated here.

[0073] The file package acquisition method, apparatus, computer device, and storage medium provided in this disclosure allow a browser to receive target file package information and a target dependency tree from a server after sending a file package acquisition request carrying file package dependency information corresponding to a target service. Compared to existing technologies where the browser needs to actively send numerous network requests to obtain target file package information and a target dependency tree, reducing acquisition efficiency, this disclosure utilizes the server's use of file package dependency information to generate the target dependency tree and obtain the initial file package from the NPM platform. The browser only needs to send one file package acquisition request to obtain the required target file package information and target dependency tree, effectively reducing network I / O and improving acquisition efficiency. Furthermore, the target file package information is generated by the server merging the contents of the obtained initial file packages. The browser can store the target file package information immediately after acquisition, eliminating the need to unpack the acquired file packages, further improving acquisition efficiency.

[0074] The file package acquisition method, apparatus, computer device, and storage medium provided in this disclosure allow the server to obtain a preset number of merged file packages by merging the contents of multiple initial file packages after acquiring multiple initial file packages. Since the target file package information contains a preset number of merged file packages and target metadata, sending the target file package information to the browser can circumvent the browser's concurrency limitations. The browser can also directly store the target file package information, omitting the process of the browser performing unpacking operations on the acquired file packages, thereby improving the efficiency of the browser in acquiring file packages.

[0075] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0076] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.

[0077] Figure 1 This illustration shows a schematic diagram of an existing browser method for obtaining file packages managed by the NPM platform, provided by an embodiment of this disclosure;

[0078] Figure 2 A flowchart illustrating a method for obtaining file packages in a browser, provided by an embodiment of this disclosure, is shown.

[0079] Figure 3 A schematic diagram illustrating the composition of complete code corresponding to a target service provided in an embodiment of this disclosure is shown;

[0080] Figure 4 This diagram illustrates a target file package information provided in an embodiment of the present disclosure;

[0081] Figure 5 A schematic diagram illustrating the implementation flow of a file package acquisition method provided in an embodiment of this disclosure is shown;

[0082] Figure 6 This illustration shows a flowchart of a browser obtaining the content of a target file according to an embodiment of the present disclosure;

[0083] Figure 7 A flowchart illustrating a method for obtaining file packages applied to a server, provided by an embodiment of this disclosure, is shown.

[0084] Figure 8 This illustration shows an interaction diagram between a browser and a server provided in an embodiment of this disclosure;

[0085] Figure 9 This illustration shows a schematic diagram of an apparatus for obtaining file packages in a browser, provided by an embodiment of the present disclosure.

[0086] Figure 10 This illustration shows a schematic diagram of an apparatus for obtaining file packages on a server, provided by an embodiment of the present disclosure.

[0087] Figure 11 A schematic diagram of the structure of a computer device provided in an embodiment of this disclosure is shown. Detailed Implementation

[0088] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown herein can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0089] Furthermore, the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein.

[0090] In this article, "multiple or several" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0091] Research has found that existing browsers can obtain file packages managed by the NPM platform in ways such as... Figure 1 As shown in the process, the browser first executes the first stage (resolving stage), in which it sends multiple network requests to the NPM platform using the file package dependency information to obtain the target dependency tree. Then, the second stage (Fetching stage) is executed, in which multiple network requests are used to retrieve the initial file package corresponding to each node in the target dependency tree from the NPM platform. Next, the third stage (Writing stage) is executed, in which each initial file package is decompressed and the compressed file package is stored. Finally, the fourth stage (Scriping stage) is executed to install the dependency information related to each initial file package. This process involves unpacking operations, file I / O (input / output), and a large number of network requests. Since the browser, as a JavaScript single-threaded model, has concurrency limitations, the large number of network requests will take a significant amount of time, reducing the efficiency of file package retrieval. Furthermore, the browser's unpacking operation also takes time, further reducing efficiency.

[0092] Based on the above research, this disclosure provides a method, apparatus, computer device, and storage medium for obtaining file packages. After a browser sends a file package acquisition request carrying file package dependency information corresponding to a target service to a server, it can receive the target file package information and target dependency tree returned by the server. Compared to the prior art, which requires the browser to actively send a large number of network requests to obtain the target file package information and target dependency tree, thus reducing the efficiency of file package acquisition, the process of generating the target dependency tree based on the file package dependency information and obtaining the initial file package from the NPM platform in this disclosure is completed by the server using the file package dependency information. The browser only needs to send one file package acquisition request to obtain the required target file package information and target dependency tree, effectively reducing the browser's network I / O and thus improving the efficiency of file package acquisition. In addition, the target file package information is generated by the server after merging the contents of each obtained initial file package. The browser can store the target file package information after obtaining it, omitting the process of performing unpacking operations on the obtained file package, thereby further improving the efficiency of file package acquisition.

[0093] The shortcomings of the above solutions are the result of the inventor's practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed in this disclosure below should be considered as the inventor's contribution to this disclosure.

[0094] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0095] It should be noted that the specific terms mentioned in the embodiments of this disclosure include:

[0096] TCP / IP: Transmission Control Protocol / Internet Protocol, refers to a suite of protocols that enables information transmission between multiple different networks.

[0097] To facilitate understanding of this embodiment, a file package acquisition method disclosed in this disclosure will first be described in detail. The execution subject of the file package acquisition method provided in this disclosure is generally a terminal device or other processing device with certain computing power. The following uses a browser as an example to illustrate the file package acquisition method provided in this disclosure.

[0098] like Figure 2The flowchart shown is a method for obtaining file packages in a browser according to an embodiment of this disclosure, which may include the following steps:

[0099] S201: Based on the file package dependency information corresponding to the target business, send a file package retrieval request carrying the file package dependency information to the server.

[0100] Here, the target business function can be any code task that needs to run in a browser. The normal operation of a target business function depends on its corresponding complete code, which typically includes the target business function's own code and the code corresponding to one or more third-party packages managed by the NPM platform. A third-party package can correspond to a Node module. For example... Figure 3 The diagram shown is a complete code composition diagram of a target service provided in an embodiment of this disclosure. It includes the code of the target service itself and the code corresponding to three third-party file packages. Each third-party file package is an initial file package. The three third-party file packages include third-party file package 1, third-party file package 2 and third-party file package 3.

[0101] Package dependency information, also known as package.json, is used to represent the initial packages required by the target business and the dependency relationships between these initial packages. For example, package dependency information could be that initial package A depends on initial packages B and C, and initial package B depends on initial packages C and D. Package dependency information is generated and stored when the target business is created.

[0102] The initial file package is a tar type file package, which can correspond to a business module. The initial file package can include a certain amount of binary data used to represent the code of the business module.

[0103] The package retrieval request is used to retrieve the initial package managed by the NPM platform. After retrieving the initial package, the browser can install it locally.

[0104] In practice, the browser can generate a file package retrieval request carrying the package.json file according to the package.json file corresponding to the target business, and send the file package retrieval request to the backend server through the communication network.

[0105] S202: Receive target file package information and target dependency tree from the server; the target dependency tree is generated by the server based on the file package dependency information, and the target file package information is generated by the server after merging the contents of multiple initial file packages obtained from the node package manager NPM platform. The initial file packages are obtained from the NPM platform according to the download address information corresponding to the nodes in the target dependency tree.

[0106] Here, the target dependency tree includes multiple nodes, each node corresponding to an initial file package that the target business needs to depend on. The position of each node in the target dependency tree can represent the dependency relationship of each initial file package. Specifically, the node can include the metadata of its corresponding initial file package. For example, the metadata can include the download address information of the initial file package, the name of the initial file package, the developer name, etc. The download address information can be used to download the corresponding initial file package from the NPM platform.

[0107] Specifically, upon receiving a file package retrieval request, the server can respond by using the NPM service module to parse the `package.json` file carried in the request, identifying each sub-dependency package within it. Each sub-dependency package corresponds to a node in a target dependency tree. Then, for each sub-dependency package, the NPM service module generates a request to retrieve the corresponding node metadata, and sends this request (metainfo request) to the NPM platform via the communication network to obtain the node metadata for that sub-dependency package. The node metadata of a node is the metadata of the initial file package corresponding to that node.

[0108] Furthermore, the NPM service module and communication network can be used to send metainfo requests corresponding to each sub-dependency package to the NPM platform. In this way, the NPM service module can obtain the node meta information corresponding to each node, and the server obtains the target dependency tree.

[0109] After obtaining the target dependency tree, the server can utilize the NPM service to generate download requests for each node based on the download address information in the node metadata of each node in the target dependency tree. Each download request is then sent to the NPM platform via the communication network to download the initial file package corresponding to each node. Subsequently, the server can merge the obtained initial file packages according to a preset number, obtaining a preset number of merged file packages and the target metadata corresponding to the target dependency tree. A merged file package can be called a chunk, and the target metadata corresponding to the target dependency tree can also be referred to as the target metadata corresponding to the preset number of merged file packages.

[0110] The target metadata is used to characterize the location, basic attribute information (such as name, hasher, developer name, etc.), and dependency information of each initial file package in the merged file package. It is generated after all the merged file packages are obtained. For example, the target metadata may include the name of each initial file package, the merged file package in which the file content of each initial file package is located, its specific location in the merged file package, the hasher corresponding to each initial file package, and the metadata path generated based on the dependency information of each initial file package. For example, the metadata path can be "node_module / lodash / index.js", where "node_module", "lodash", and "index.js" can all be the names of the initial file packages. The preset number can be determined based on the maximum number of TCP / IP requests that the browser can handle concurrently. The preset number can be less than 10, for example, the preset number can be 6.

[0111] Then, the server can use the target metadata and a preset number of merged file packages as the target file package information. For example... Figure 4 The diagram shown is a schematic representation of target file package information provided in an embodiment of this disclosure. Figure 4 In the target metadata, there are hashes corresponding to multiple initial file packages, the name of each merged file package (chunk), the dependency information (deps) of the initial file packages, multiple metadata path files, the name of the merged file package corresponding to each metadata path (chunk_no), and the position of the file content corresponding to each metadata path in the merged file package (including the start and end positions). Furthermore, Figure 4 The document also shows partial merged file packages, as well as the file contents of each file package within those partial packages. The partial merged file packages shown are chunk_1.tar, chunk_2.tar, and chunk_n.tar.

[0112] Afterwards, the server can send the target file package information and the generated target dependency tree back to the browser. Here, regarding the step of sending the target metadata and target dependency tree back to the browser, each merged file package, target metadata, and target dependency tree can be sent to the browser synchronously.

[0113] Based on this, the browser can receive the target file package information and target dependency tree returned by the server.

[0114] S203: Store the target file package information and target dependency tree in the target storage location, wherein the stored target file package information and target dependency tree are used for the operation of the target business.

[0115] Here, the target storage location can be the browser's local database. Since the server merges the initial file packages, each merged file package includes the file content of its corresponding initial file packages. Therefore, after obtaining the target metadata, the browser can directly store the merged file packages and the target metadata itself, eliminating the need for depackaging and improving file package retrieval efficiency.

[0116] The process of storing the target file package information and the target dependency tree to the target storage location may specifically include storing each merged file package in the target file package information to the local database, storing the target metadata in the target file package information to the local database, and storing the target dependency tree to the local database.

[0117] After storing the target file package information and the target dependency tree in the target storage location, when the browser subsequently needs to retrieve the file content from any of the merged file packages included in the target file package information, it can determine whether the required file content exists based on the target dependency tree. If it does, it can use the target metadata to determine the location of the required file content and retrieve it from that location. Then, the target business logic can be executed based on the file content.

[0118] like Figure 5 The diagram illustrates the implementation flow of a file package acquisition method provided in this embodiment. After the browser sends a file package acquisition request carrying file package dependency information to the server, the server can execute the process described above. Figure 1 The first stage (resolving stage) shown involves determining the target dependency tree based on package.json. Then, the server can be used to execute the process described above. Figure 1 The second stage (Fetching stage) involves retrieving the initial file package corresponding to each node in the target dependency tree from the NPM platform. Simultaneously, the server can be used to merge the content of multiple retrieved initial file packages, resulting in a preset number of merged file packages and target metadata corresponding to the target dependency tree. The preset number of merged file packages and target metadata are then used as the target file package information. Next, the target file package information and target dependency tree can be fed back to the browser in this stage. Finally, the browser can execute the above... Figure 1 The third stage (Writing stage) is shown, and in this stage, the browser only needs to store the target file package information and the target dependency tree in the local database, without performing unpacking operations.

[0119] Based on the embodiments of this disclosure, after the browser sends a file package retrieval request carrying file package dependency information corresponding to the target service to the server, it can receive the target file package information and target dependency tree returned by the server. Compared with the prior art, which requires the browser to actively send a large number of network requests to obtain the target file package information and target dependency tree, thus reducing the efficiency of file package retrieval, the processes of generating the target dependency tree based on the file package dependency information and obtaining the initial file package from the NPM platform in the embodiments of this disclosure are all completed by the server using the file package dependency information. The browser only needs to send a file package retrieval request to obtain the required target file package information and target dependency tree, effectively reducing the browser's network I / O and thus improving the efficiency of file package retrieval. In addition, the target file package information is generated by the server after merging the contents of each obtained initial file package. The browser can store the target file package information after obtaining it, omitting the process of performing unpacking operations on the obtained file package, thereby further improving the efficiency of file package retrieval.

[0120] In one embodiment, for S103, the following steps can be performed:

[0121] S203-1: Store target file package information and convert the target dependency tree into a directory structure tree.

[0122] Here, the target dependency tree represents each initial file package and its dependencies in a tree structure. The directory structure tree represents each initial file package and its dependencies in a directory structure. Specifically, the directory structure tree can include multiple file paths generated based on the target dependency tree, and the file paths can consist of the names of the initial file packages. For example, in the target dependency tree, node 'a' depends on node 'b', and node 'b' depends on node 'c'. After converting the target dependency tree into a directory structure tree, we get paths in the form of "a / b / c". By converting the target dependency tree into a directory structure tree, it is easier to retrieve the file content corresponding to the file content retrieval request from the local data based on the request path carried in the file content retrieval request initiated by the browser.

[0123] S203-2: In the file system corresponding to the browser, mark and store each file path indicated by the directory structure tree; wherein, when the marked file path is accessed, the file content corresponding to the initial file package at the file path needs to be obtained from the stored target file package information using the file processing service.

[0124] Here, the file processing service (i.e., the tar service) is a service deployed in the browser used to retrieve file content from the target file package information. It can store the file content corresponding to each merged file package. The file system is used to manage and store local files in the browser. The browser's file data is stored partly in the file system and partly in the file processing service.

[0125] In practice, after determining the directory structure tree, each file path indicated by the directory structure tree can be marked and stored in the browser's corresponding file system. The purpose of marking file paths is that if the request path carried in the browser's file content retrieval request matches a marked file path, the file content retrieval request needs to be sent to the file processing service. The file processing service then retrieves the file content corresponding to the merged file package at the requested path from the stored target file package information.

[0126] In one embodiment, after marking and storing each file path indicated by the directory structure tree, the browser can also generate a request to retrieve the file content from any merged file bundle, and retrieve the required file content based on that request. Specifically, the required file content can be retrieved according to the following steps:

[0127] Step 1: In response to the request to retrieve file content, if the request path carried in the file content retrieval request matches the target file path marked as complete, the file processing service in the browser is invoked.

[0128] Here, the file content retrieval request can be a browser-generated require request to retrieve the file content from any merged file package. The require request can include a request path, which consists of the name of the initial file package being requested. The target file path is the file path that matches the request path among a list of marked file paths.

[0129] For example, a browser can generate a require request to retrieve the contents of files in merged file package A, where the request path could be "node_module / lodash / index.js". Then, the file system can be used to determine if any of the marked file paths match the request path "node_module / lodash / index.js". If so, the browser's tar service can be invoked, and the require request can be forwarded to the tar service.

[0130] Step 2: Using the file processing service, determine the target merged file package containing the target file content corresponding to the target file path, and the target position of the target file content within the target merged file package, from the target metadata carried in the target file package information.

[0131] Here, the target metadata may include multiple metadata paths. For example, a metadata path could be "node_module / lodash / index.js".

[0132] In practice, file processing services can be used to determine the target merged file package and its name containing the target file content corresponding to the target file path from the names of multiple initial file packages included in the target metadata. Simultaneously, the position of the target file content corresponding to the target file path within the target merged file package can also be determined. For example, the position of the target file content within the target merged file package could be starting at position aaa and ending at position bbb.

[0133] Step 3: Read the contents of the target file from the target location in the target merged file package.

[0134] Here, after reading the contents of the target file, the browser can use those contents to run the target business logic.

[0135] In another embodiment, if the file system determines that no target file path matches the request path carried in the file content retrieval request, i.e., when it is determined that multiple marked file paths do not match the request path, the file content retrieval request can be sent to the NPM platform via a communication network. Furthermore, after receiving the request, the NPM platform can return the target file content at the requested path carried in the request to the browser. In this way, the browser can receive the target file content returned by the NPM platform in response to the file content retrieval request.

[0136] like Figure 6 The diagram illustrates a process for a browser to obtain target file content according to an embodiment of this disclosure. After generating a require request carrying the requested path, the browser utilizes the file system to determine if a target file path matching the requested path exists among multiple marked file paths. If so, the require request is forwarded to the tar service. The tar service determines the target merged file package containing the target file content corresponding to the target file path, as well as the target location of the target file content. The tar service then reads the target file content from the target location and returns it to the file system. Furthermore, the file system can return the target file content to the browser.

[0137] If the file system determines that there is no target file path that matches the requested path, the file system can use the communication network to send the require request to the NPM platform. The file system can then obtain the target file content from the NPM platform and send the target file content back to the browser.

[0138] Furthermore, this disclosure also provides a method for obtaining file packages on a server. By combining the server-side file package obtaining method with the browser-side file package obtaining method, the browser can obtain file packages managed on the NPM platform with higher efficiency. Figure 7 The flowchart shown is a method for obtaining file packages applied to a server according to an embodiment of this disclosure, which may include the following steps:

[0139] S701: Receives a file package retrieval request sent by the browser, and uses the NPM service module to determine the target dependency tree corresponding to the file package dependency information based on the file package dependency information carried in the file package retrieval request; the file package retrieval request is generated and sent by the browser after determining the initial file package corresponding to the target business.

[0140] Here, the NPM service module is a server-deployed service used to retrieve initial file packages managed by the NPM platform. These initial file packages can all be Node.js-based. The file package retrieval request is generated by the browser after determining that it needs to retrieve the various initial file packages corresponding to the target business logic, and then sent to the server.

[0141] Package dependency information, also known as package.json, is used to represent the initial packages that the target business needs to depend on, as well as the dependency relationships between the initial packages.

[0142] Specifically, after receiving a file package retrieval request, the server can respond by using the NPM service module to generate a metainfo retrieval request (i.e., a metadata request) based on the retrieved package.json file. This metainfo request is then sent to the NPM platform via the communication network to retrieve the corresponding node metadata for that sub-dependency package. After obtaining the node metadata for each node, a target dependency tree, including the node metadata for each node, can be generated based on the dependency relationships between the initial file packages corresponding to each node.

[0143] In one embodiment, the step in S701, which uses the NPM service module to obtain the file package dependency information carried in the request based on the file package and determines the target dependency tree corresponding to the file package dependency information, can be implemented according to the following steps:

[0144] S701-1: Using the NPM service module, the dependency information of the file package is parsed to determine each sub-dependency package in the file package dependency information; each sub-dependency package corresponds to a node in the target dependency tree.

[0145] Here, each sub-dependency package corresponds to a node in the target dependency tree.

[0146] In practice, the NPM service module can be used to parse the package.json file carried in the file package retrieval request to determine each sub-dependency package in package.json.

[0147] S701-2: Generate a node metadata retrieval request based on the version condition information and file package name information in the sub-dependency package, and send the node metadata retrieval request to the NPM platform.

[0148] Here, each sub-dependency package includes version condition information and file package name information. The version condition information represents version restrictions, which limit the version of the initial file package to be obtained. For example, the version condition information included in a sub-dependency package could be: obtain an initial file package with a version higher than 1.0.0. The file package name information is the name of the initial file package to be obtained at the node corresponding to the sub-dependency package.

[0149] For example, sub-dependency package A corresponds to node A. The version information included in sub-dependency package A can be: obtain an initial file package with a version higher than 1.0.0; the file package name information included in sub-dependency package A is: initial file package A. Based on these two pieces of information, it can be determined that an initial file package A with a version higher than 1.0.0 needs to be obtained from the NPM platform. Then, the initial file package A with a version higher than 1.0.0 is used as the initial file package corresponding to node A.

[0150] In practice, for each sub-dependency package, the NPM service module can be used to generate a metainfo request corresponding to that sub-dependency package based on its version information and package name. Optionally, a metainfo request carrying the sub-dependency package can also be generated directly. The number of generated metainfo requests can be N, where N equals the number of sub-dependency packages.

[0151] Afterwards, a metainfo request corresponding to the sub-dependency package can be sent to the NPM platform using the communication network.

[0152] S701-3: Obtain node metadata from the NPM platform in response to the node metadata retrieval request; the node metadata includes the download address information of the initial file package.

[0153] Here, the node metadata may include basic attribute information of the initial file package corresponding to the node. The basic attribute information may include, but is not limited to, the download address information of the initial file package, the name of the initial file package, the version information, the developer name, and the hasher corresponding to the initial file package.

[0154] For each sub-dependency package, after sending the corresponding metainfo request to the NPM platform via the communication network, the NPM platform can respond to the metainfo request and, based on the version condition information and package name information in the metainfo request, determine the initial package that matches the version condition information and package name information from the multiple initial packages it manages. Then, it can feed back the node meta information corresponding to the initial package to the NPM service module.

[0155] S701-4: Generate the target dependency tree based on the acquired node metadata.

[0156] In practice, the NPM service module can be used to generate a target dependency tree that includes the node metadata of each node, based on the node metadata of each node and the dependencies between each node.

[0157] S702: Based on the download address information of the initial file package corresponding to each node in the target dependency tree, obtain multiple initial file packages corresponding to the target business from the NPM platform.

[0158] In practice, for each node, the NPM service module can generate a download request based on the download address information in the node's metadata. This request is then sent to the NPM platform via a communication network, whereby the NPM service module receives the initial file package from the platform. The number of generated download requests can be N, where N equals the number of nodes.

[0159] Thus, based on the download requests generated for each node, the initial file package corresponding to each node can be obtained from the NPM platform, which means obtaining the initial file packages corresponding to the target business.

[0160] S703: Perform a file package content merging operation on multiple initial file packages to obtain target file package information corresponding to the target dependency tree; the target file package information includes target metadata and a preset number of merged file packages; the target metadata is used to characterize the position and basic attribute information of each initial file package in the merged file package.

[0161] In practice, based on a pre-set number of merged file packages, the file contents corresponding to each initial file package can be merged into one, resulting in a pre-set number of merged file packages. Each merged file package contains only the file contents. For example, each merged file package contains only the binary data of the multiple initial file packages corresponding to that merged file package. The sum of the file contents included in the pre-set number of merged file packages is equal to the sum of the file contents of all the initial file packages.

[0162] Furthermore, upon obtaining a preset number of merged file packages, a target metadata information is also generated. This target metadata information records the basic attribute information of each initial file package, the merged file package containing the file content of each initial file package, the specific location of the file content within that merged file package, and the metadata path generated based on the dependency information corresponding to each initial file package. The dependency information is used to characterize the dependency relationships between the initial file packages.

[0163] Then, a preset number of merged file packages and target metadata can be merged into target file package information.

[0164] In one embodiment, S703 can be implemented according to the following steps:

[0165] S703-1: Divide multiple initial file packages into a preset number of file groups, and merge the contents of each initial file package included in each file group to obtain a merged file package corresponding to each file group; wherein the sum of the sizes of each initial file package included in each file group is within a preset range.

[0166] In practice, the file group division principle can be followed, where the sum of the sizes of the initial file packages included in each file group is within a preset range. Based on the size of each initial file package, the multiple initial file packages corresponding to the target business can be divided into a preset number of file groups.

[0167] Optionally, the file group partitioning principle can also be to minimize the difference in the sum of the sizes of the corresponding file packages in the resulting file groups. For example, consider file groups A, B, and C, where the sum of the sizes of the initial file packages in file group A is size 1, the sum of the sizes of the initial file packages in file group B is size 2, and the sum of the sizes of the initial file packages in file group C is size 3. The difference between size 1 and size 2 and size 3 is minimal.

[0168] S703-2: Generate target metadata based on the basic attribute information of each initial file package included in each merged file package and the position of each initial file package in the merged file package.

[0169] In practice, when a preset number of merged file packages are obtained, a target metadata can also be obtained. The target metadata is used to record the basic attribute information of each initial file package, the merged file package in which the file content of each initial file package is located, the specific location of the file content in the merged file package, and the metadata path generated based on the dependency information corresponding to each initial file package.

[0170] S703-3: Use the target metadata and the merged file package corresponding to each file group as the target file package information.

[0171] In practice, the target metadata and the merged file package corresponding to each file group can be merged to obtain the target file package information.

[0172] In one embodiment, before dividing multiple initial file packages into a preset number of file groups, the target type file content in each acquired initial file package can be deleted to reduce the size of each initial file package; wherein, the target type is a pre-determined content type corresponding to file content that the browser does not need to use.

[0173] Here, the file content of the target type in the initial file package to be deleted can be file content that is predetermined to have no practical use in the browser. For example, the content of readme type files, license type files, etc., can be deleted.

[0174] After deleting the content of the target file type, a smaller initial file package is obtained, thus simplifying the initial file package. Then, the contents of the simplified initial file packages can be merged to obtain multiple merged file packages.

[0175] Furthermore, the reason why there might be no matching target file path after the browser initiates a file content retrieval request could be because the initial file package was pre-compacted, and the target file content at the requested path was removed. In this case, this disclosure also provides a method for sending the file content retrieval request to the NPM platform to obtain the target file content.

[0176] S704: Send the target file package information and target dependency tree to the browser.

[0177] For example, the various merged file packages in the target file package information, the target metadata in the target file package information, and the target dependency tree can be fed back to the browser in sequence; alternatively, the target file package information and the target dependency tree can be fed back to the browser together, which is not limited here.

[0178] After receiving the target file package information and the target dependency tree, the browser can store the target file package information and the target dependency tree in a local database.

[0179] In this way, after the server obtains multiple initial file packages, it can obtain a preset number of merged file packages by merging the contents of the multiple initial file packages. Since the target file package information contains the preset number of merged file packages and target metadata, by sending the target file package information to the browser, it can not only avoid the browser's concurrency limit, but the browser can also directly store the target file package information, omitting the process of the browser performing unpacking operations on the obtained file packages, thereby improving the efficiency of the browser in obtaining file packages.

[0180] like Figure 8 The diagram illustrates an interaction between a browser and a server according to an embodiment of this disclosure. Based on this interaction, the browser can obtain the initial file package corresponding to the target service with higher file package retrieval efficiency. Figure 8 When a browser needs to install the initial file packages corresponding to a target business function locally, it can send a file package retrieval request, carrying the package.json file, to the backend server based on the package dependency information for the target business function. Upon receiving the file package retrieval request, the server can respond by calculating the target dependency tree. Specifically, the NPM service module can be used to generate metainfo requests for each node, and these metainfo requests can be sent to the NPM platform via a communication network. This communication network is based on the TCP / IP protocol.

[0181] Furthermore, the NPM service module can obtain the node metadata corresponding to each node fed back by the NPM platform, thus the server obtains the target dependency tree. Further, the server can execute the operation of requesting initial file packages. Specifically, it can utilize the NPM service to generate download requests for each node based on the download address information in the node metadata corresponding to each node in the target dependency tree, and send each download request to the NPM platform via the communication network. Subsequently, the NPM service module can receive the initial file packages fed back by the NPM platform, thus the server obtains the initial file packages corresponding to each node.

[0182] Then, the server performs an initial file package reduction operation, that is, for each initial file package obtained, the content of the target type files in the initial file package is deleted to reduce the size of each initial file package.

[0183] Furthermore, the server performs a file package merging operation on the multiple simplified initial file packages to obtain the target file package information corresponding to the target dependency tree. This target file package information includes target metadata and a preset number of merged file packages. Finally, the server can send the target file package information and the target dependency tree to the browser.

[0184] The browser can receive the target file package information and target dependency tree from the server and store the target file package information and target dependency tree in the local database.

[0185] In one embodiment, after sending the target file package information and the target dependency tree to the browser, a new file package retrieval request can also be received from the browser. Here, the new file package retrieval request can be a request to re-retrieve the initial file package corresponding to the target service, or a request to retrieve the initial file package corresponding to a new target service.

[0186] Upon receiving a new file package retrieval request, the server can first determine whether the request includes the target dependency tree. If so, the server can determine that the new file package retrieval request is a request to re-retrieve the initial file package corresponding to the target service. If not, the server can determine that the new file package retrieval request is a request to retrieve the initial file package corresponding to a new target service.

[0187] Specifically, if it is determined that the new file package retrieval request includes not only the file package dependency information package.json but also package-lock.json, then it can be determined that the new file package retrieval request includes the target dependency tree. Among these, package-lock.json carries the target dependency tree corresponding to the target business.

[0188] Furthermore, if the target dependency tree is determined, multiple new initial file packages corresponding to the target business can be obtained from the NPM platform based on the download address information corresponding to each node in the target dependency tree.

[0189] Here, the new initial file package can be the updated initial file package at the download address indicated by the download address information. For example, the initial file package at download address A is initial file package 1, which can be updated to obtain the updated initial file package 1. Thus, after obtaining a new file package retrieval request, the updated initial file package 1 can be downloaded according to download address 1 indicated by the target dependency tree.

[0190] In practice, assuming a target dependency tree is included, the download address information corresponding to each node in the target dependency tree can be sent to the server, or the target dependency tree can be sent directly to the server. The server can then generate download requests for each node based on the download address information. The server can then use the communication network to send multiple generated download requests to the NPM platform to obtain new initial file packages for each node. Afterward, the server can perform a file package content merging operation on the multiple new initial file packages to obtain new target file package information corresponding to the target dependency tree. This new target file package information and the target dependency tree are then sent to the browser, allowing the browser to store the new target file package information, thereby updating the initial file packages stored locally.

[0191] In addition, if it is determined that the new file package acquisition request does not include the target dependency tree, the server can determine the new target dependency tree corresponding to the new file package acquisition request and the target file package information corresponding to the new target dependency tree according to the file package acquisition methods in the above embodiments, and feed back the new target dependency tree and the target file package information corresponding to the new target dependency tree to the browser so that the browser stores the new target dependency tree and the target file package information corresponding to the new target dependency tree.

[0192] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0193] Based on the same inventive concept, this disclosure also provides a file package acquisition device corresponding to the file package acquisition method applied to a browser. Since the principle of the device in this disclosure for solving the problem is similar to the file package acquisition method applied to a browser described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0194] like Figure 9 The diagram shown is a schematic of a file package acquisition method apparatus for a browser provided in an embodiment of this disclosure, including:

[0195] The first sending module 901 is used to send a file package acquisition request carrying the file package dependency information to the server based on the file package dependency information corresponding to the target service.

[0196] The first receiving module 902 is used to receive target file package information and target dependency tree fed back by the server; the target dependency tree is generated by the server based on the file package dependency information, the target file package information is generated by the server after merging the contents of multiple initial file packages obtained from the node package manager NPM platform, and the initial file packages are obtained from the NPM platform according to the download address information corresponding to the nodes in the target dependency tree;

[0197] Storage module 903 is used to store the target file package information and the target dependency tree to the target storage location, wherein the stored target file package information and the target dependency tree are used for the operation of the target service.

[0198] In one possible implementation, the storage module 903, when storing the target file package information and the target dependency tree to the target storage location, is used to store the target file package information and convert the target dependency tree into a directory structure tree;

[0199] In the file system corresponding to the browser, each file path indicated by the directory structure tree is marked and stored; wherein, when a marked file path is accessed, the file content corresponding to the initial file package at that file path needs to be obtained from the stored target file package information using a file processing service.

[0200] In one possible implementation, the device further includes:

[0201] The reading module 904 is configured to, after marking and storing each file path indicated by the directory structure tree, in response to a file content retrieval request, invoke the file processing service in the browser if, using the file system, it is determined that the requested path carried in the file content retrieval request matches the marked target file path.

[0202] Using the file processing service, the target merged file package containing the target file content corresponding to the target file path is determined from the target metadata carried by the target file package information, as well as the target position of the target file content in the target merged file package;

[0203] Read the contents of the target file from the target location in the target merged file package.

[0204] In one possible implementation, the reading module 904 is further configured to send the file content acquisition request to the NPM platform if it is determined that there is no target file path that matches the request path carried in the file content acquisition request.

[0205] Receive the target file content from the NPM platform in response to the file content acquisition requirement.

[0206] Based on the same inventive concept, this disclosure also provides a file package acquisition device corresponding to the file package acquisition method applied to a server. Since the principle of the device in this disclosure for solving the problem is similar to the file package acquisition method applied to a server described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0207] like Figure 10 The diagram shown is a schematic representation of a file package acquisition method apparatus for a server provided in this disclosure, comprising:

[0208] The second receiving module 1001 is used to receive a file package acquisition request sent by the browser, and to use the NPM service module to determine the target dependency tree corresponding to the file package dependency information carried in the file package acquisition request; the file package acquisition request is generated and sent by the browser after determining that the initial file package corresponding to the target service is to be acquired.

[0209] The acquisition module 1002 is used to acquire multiple initial file packages corresponding to the target service from the NPM platform based on the download address information of the initial file packages corresponding to each node in the target dependency tree.

[0210] The merging module 1003 is used to perform a file package content merging operation on multiple initial file packages to obtain target file package information corresponding to the target dependency tree; the target file package information includes target metadata and a preset number of merged file packages; the target metadata is used to characterize the position and basic attribute information of each initial file package in the merged file package.

[0211] The second sending module 1004 is used to send the target file package information and the target dependency tree to the browser.

[0212] In one possible implementation, the second receiving module 1001, when using the NPM service module to obtain the file package dependency information carried in the file package acquisition request and determine the target dependency tree corresponding to the file package dependency information, is used to use the NPM service module to parse the file package dependency information and determine each sub-dependency package in the file package dependency information; each sub-dependency package corresponds to a node in the target dependency tree;

[0213] Based on the version condition information and file package name information in the sub-dependency package, a node meta information retrieval request is generated and sent to the NPM platform;

[0214] Obtain the node metadata information returned by the NPM platform in response to the node metadata acquisition request; the node metadata information includes the download address information of the initial file package;

[0215] The target dependency tree is generated based on the acquired metadata of each node.

[0216] In one possible implementation, when the merging module 1003 performs a file package content merging operation on the multiple initial file packages to obtain the target file package information corresponding to the target dependency tree, it is used to divide the multiple initial file packages into a preset number of file groups, and merge each initial file package included in each file group to obtain a merged file package corresponding to each file group; wherein the sum of the volumes of the initial file packages included in each file group differs within a preset range;

[0217] The target metadata is generated based on the basic attribute information of each initial file package included in each merged file package and the position of each initial file package in the merged file package;

[0218] The target metadata and the merged file package corresponding to each file group are used as the target file package information.

[0219] In one possible implementation, the device further includes:

[0220] The deletion module 1005 is used to delete the content of a target type in each of the acquired initial file packages before dividing the plurality of initial file packages into a preset number of file groups, so as to reduce the size of each initial file package; wherein the target type is a content type corresponding to the file content that the browser does not need to use, which is predetermined.

[0221] In one possible implementation, the device further includes:

[0222] The third receiving module 1006 is used to receive a new file package acquisition request sent by the browser after the target file package information and the target dependency tree are sent to the browser;

[0223] If it is determined that the new file package acquisition request includes the target dependency tree, multiple new initial file packages corresponding to the target service are obtained from the NPM platform according to the download address information corresponding to each node in the target dependency tree;

[0224] Perform a file package content merging operation on multiple new initial file packages to obtain new target file package information corresponding to the target dependency tree, and send the new target file package information to the browser.

[0225] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.

[0226] Based on the same technical concept, embodiments of this application also provide a computer device. (Refer to...) Figure 11 The diagram shown is a structural schematic of a computer device provided in an embodiment of this application, comprising:

[0227] The system comprises a processor 1101, a memory 1102, and a bus 1103. The memory 1102 stores machine-readable instructions executable by the processor 1101. The processor 1101 executes these machine-readable instructions, and when executed, performs the following steps: S201: Based on the file package dependency information corresponding to the target service, the processor sends a file package retrieval request carrying the file package dependency information to the server; S202: Receives target file package information and a target dependency tree from the server; the target dependency tree is generated by the server based on the file package dependency information, and the target file package information is generated by the server after merging the contents of multiple initial file packages obtained from the NPM (Node Package Manager) platform; the initial file packages are obtained from the NPM platform according to the download address information corresponding to the nodes in the target dependency tree; and S203: Stores the target file package information and the target dependency tree in a target storage location, wherein the stored target file package information and dependency tree are used for the operation of the target service; or...

[0228] Processor 1101 is used to execute machine-readable instructions stored in memory 1102. When the machine-readable instructions are executed by processor 1101, processor 1101 performs the following steps: S701: Receives a file package retrieval request sent by the browser, and uses the NPM service module to determine the target dependency tree corresponding to the file package dependency information based on the file package dependency information carried in the file package retrieval request; the file package retrieval request is generated and sent by the browser after determining that it needs to retrieve the initial file package corresponding to the target service; S702: According to the download address information of the initial file package corresponding to each node in the target dependency tree, retrieves multiple initial file packages corresponding to the target service from the NPM platform; S703: Performs a file package content merging operation on the multiple initial file packages to obtain target file package information corresponding to the target dependency tree; the target file package information includes target metadata and a preset number of merged file packages; the target metadata is used to characterize the position and basic attribute information of each initial file package in the merged file package; and S704: Sends the target file package information and the target dependency tree to the browser.

[0229] The aforementioned memory 1102 includes a main memory 1121 and an external memory 1122. The main memory 1121, also known as internal memory, is used to temporarily store the computational data in the processor 1101 and the data exchanged with external memory such as a hard disk. The processor 1101 exchanges data with the external memory 1122 through the main memory 1121. When the computer device is running, the processor 1101 and the memory 1102 communicate through the bus 1103, so that the processor 1101 executes the execution instructions mentioned in the above method embodiments.

[0230] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the file package acquisition method described in the above method embodiments. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0231] The computer program product of the file package acquisition method provided in this disclosure includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the steps of the file package acquisition method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.

[0232] The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0233] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0234] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0235] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0236] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0237] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the user through pop-up information or by asking the user to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.

[0238] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A method for obtaining a file package, characterized in that, Applied to browsers, including: Based on the file package dependency information corresponding to the target service, a file package retrieval request carrying the file package dependency information is sent to the server. The file package dependency information is used to characterize each initial file package that the target service needs to depend on, as well as the dependency relationship between each initial file package. The server receives target file package information and target dependency tree from the server. The target dependency tree is generated by the server based on the file package dependency information. The position of each node in the target dependency tree represents the dependency relationship between each initial file package. The target file package information is generated by the server after merging the content of multiple initial file packages obtained from the node package manager NPM platform. The initial file packages are obtained from the NPM platform according to the download address information corresponding to the nodes in the target dependency tree. The target file package information and the target dependency tree are stored in the target storage location without unpacking. The stored target file package information and the target dependency tree are used for the operation of the target business. The target storage location is the local database corresponding to the browser.

2. The method according to claim 1, characterized in that, The step of storing the target file package information and the target dependency tree to the target storage location includes: Store the target file package information and convert the target dependency tree into a directory structure tree; In the file system corresponding to the browser, each file path indicated by the directory structure tree is marked and stored; wherein, when a marked file path is accessed, the file content corresponding to the initial file package at that file path needs to be obtained from the stored target file package information using a file processing service.

3. The method according to claim 2, characterized in that, Following the marking and storage of each file path indicated by the directory structure tree, the following is also included: In response to a file content retrieval request, if the file system is used to determine that the request path carried in the file content retrieval request matches the target file path marked as complete, the file processing service in the browser is invoked. Using the file processing service, the target merged file package containing the target file content corresponding to the target file path is determined from the target metadata carried by the target file package information, as well as the target position of the target file content in the target merged file package; Read the contents of the target file from the target location in the target merged file package.

4. The method according to claim 3, characterized in that, The method further includes: If it is determined that there is no target file path that matches the request path carried in the file content retrieval request, the file content retrieval request is sent to the NPM platform; Receive the target file content from the NPM platform in response to the file content acquisition requirement.

5. A method for obtaining a file package, characterized in that, Applied to servers, including: The system receives a file package retrieval request from the browser and uses the NPM service module to determine the target dependency tree corresponding to the file package dependency information carried in the file package retrieval request. The position of each node in the target dependency tree represents the dependency relationship between each initial file package. The file package retrieval request is generated and sent by the browser after determining that it needs to retrieve the initial file package corresponding to the target service. The file package dependency information is used to represent each initial file package that the target service needs to depend on, as well as the dependency relationship between each initial file package. Based on the download address information of the initial file package corresponding to each node in the target dependency tree, obtain multiple initial file packages corresponding to the target service from the NPM platform; A file package content merging operation is performed on multiple initial file packages to obtain target file package information corresponding to the target dependency tree; the target file package information includes target metadata and a preset number of merged file packages; the target metadata is used to characterize the position and basic attribute information of each initial file package in the merged file package. The target file package information and the target dependency tree are sent to the browser so that the browser stores the target file package information and the target dependency tree in the target storage location without unpacking. The target storage location is the browser's local database.

6. The method according to claim 5, characterized in that, The step of using the NPM service module to obtain the file package dependency information carried in the request based on the file package, and determining the target dependency tree corresponding to the file package dependency information, includes: The NPM service module is used to parse the file package dependency information to determine each sub-dependency package in the file package dependency information; each sub-dependency package corresponds to a node in the target dependency tree; Based on the version condition information and file package name information in the sub-dependency package, a node meta information retrieval request is generated and sent to the NPM platform; Obtain the node metadata information returned by the NPM platform in response to the node metadata acquisition request; the node metadata information includes the download address information of the initial file package; The target dependency tree is generated based on the acquired metadata of each node.

7. The method according to claim 5, characterized in that, The step of performing a file package content merging operation on multiple initial file packages to obtain target file package information corresponding to the target dependency tree includes: The initial file packages are divided into a preset number of file groups, and the contents of each initial file package in each file group are merged to obtain a merged file package corresponding to each file group; wherein the sum of the sizes of the initial file packages in each file group is within a preset range. The target metadata is generated based on the basic attribute information of each initial file package included in each merged file package and the position of each initial file package in the merged file package; The target metadata and the merged file package corresponding to each file group are used as the target file package information.

8. The method according to claim 7, characterized in that, Before dividing the plurality of initial file packages into a preset number of file groups, the method further includes: For each of the acquired initial file packages, the content of the target type files in the initial file package is deleted to reduce the size of each initial file package; wherein, the target type is a content type corresponding to the pre-determined file content that the browser does not need to use.

9. The method according to claim 5, characterized in that, After sending the target file package information and the target dependency tree to the browser, the method further includes: Receive new file package retrieval requests sent by the browser; If it is determined that the new file package acquisition request includes the target dependency tree, multiple new initial file packages corresponding to the target service are obtained from the NPM platform according to the download address information corresponding to each node in the target dependency tree; Perform a file package content merging operation on multiple new initial file packages to obtain new target file package information corresponding to the target dependency tree, and send the new target file package information to the browser.

10. A file package acquisition device, characterized in that, Applied to browsers, including: The first sending module is used to send a file package acquisition request carrying the file package dependency information to the server based on the file package dependency information corresponding to the target service. The file package dependency information is used to characterize each initial file package that the target service needs to depend on, as well as the dependency relationship between each initial file package. The first receiving module is used to receive target file package information and target dependency tree fed back by the server; the target dependency tree is generated by the server based on the file package dependency information, and the position of each node in the target dependency tree represents the dependency relationship between each initial file package; the target file package information is generated by the server after merging the contents of multiple initial file packages obtained from the node package manager NPM platform; the initial file packages are obtained from the NPM platform according to the download address information corresponding to the nodes in the target dependency tree. The storage module is used to store the target file package information and the target dependency tree to the target storage location without unpacking. The stored target file package information and the target dependency tree are used for the operation of the target business. The target storage location is the local database corresponding to the browser.

11. A file package acquisition device, characterized in that, Applied to servers, including: The second receiving module is used to receive a file package retrieval request sent by the browser, and to use the NPM service module to determine the target dependency tree corresponding to the file package dependency information carried in the file package retrieval request. The position of each node in the target dependency tree represents the dependency relationship between each initial file package. The file package retrieval request is generated and sent by the browser after determining that it needs to retrieve the initial file package corresponding to the target service. The file package dependency information is used to represent each initial file package that the target service needs to depend on, as well as the dependency relationship between each initial file package. The acquisition module is used to acquire multiple initial file packages corresponding to the target service from the NPM platform based on the download address information of the initial file packages corresponding to each node in the target dependency tree. The merging module is used to perform a file package content merging operation on multiple initial file packages to obtain target file package information corresponding to the target dependency tree; the target file package information includes target metadata and a preset number of merged file packages; the target metadata is used to characterize the position and basic attribute information of each initial file package in the merged file package. The second sending module is used to send the target file package information and the target dependency tree to the browser, so that the browser stores the target file package information and the target dependency tree in the target storage location without performing unpacking operations, wherein the target storage location is the browser's local database.

12. A computer device, characterized in that, include: A processor and a memory, the memory storing machine-readable instructions executable by the processor, the processor executing the machine-readable instructions stored in the memory, wherein when the machine-readable instructions are executed by the processor, the processor performs the steps of the file package acquisition method as described in any one of claims 1 to 9.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a computer device, performs the steps of the file package acquisition method as described in any one of claims 1 to 9.