Method and device for running program through web browser, electronic equipment and medium

By building a web browser program container and compiling the target program data package, the problem of small programs and small games being unable to run independently is solved, enabling flexible operation in the web browser and improving their independence.

CN118796294APending Publication Date: 2024-10-18BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310390116.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-12
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

Mini programs or games in existing applications cannot run independently outside the embedded application and lack flexibility.

Method used

By building a web browser-based program container, obtain and compile the original data package of the target program, generate a compiled program data package that can be run in the program container, and load the program container through the web browser to deploy and execute the program script, Call resource files.

Benefits of technology

It enables small programs and small games to run independently in web browsers, improving their flexibility and making them no longer strongly dependent on the original application environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796294A_ABST
    Figure CN118796294A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for running a program through a web browser, electronic equipment and a medium, and belongs to the technical field of computers. The method for running the program through the web browser comprises the steps of obtaining an original data packet of a target program; constructing a program container, wherein the program container can be loaded by the web browser; the original data packet is compiled, a compiled program data packet is obtained, the program data packet comprises a program script of the target program and a resource file of the target program, and the program script can run in a program container; loading the program container through a web browser; deploying the program data packet in the program container to execute the program script through the program container, and calling the resource file according to the program script.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a method, device, electronic device and medium for running a program through a web browser. Background Art

[0002] In the related art, in some applications, in addition to the main functions of the program, mini-program or mini-game functions are also provided.

[0003] The operation of the above-mentioned mini-programs or mini-games is strongly dependent on the environment of the embedded application program, and cannot be run outside the embedded application program, which is not flexible enough. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a method, device, electronic device and medium for running a program through a web browser, which can at least partially solve the above-mentioned problems.

[0005] In a first aspect, an embodiment of the present application provides a method for running a program through a web browser, comprising:

[0006] Get the original data packet of the target program;

[0007] Build a program container that can be loaded by a web browser;

[0008] Compiling the original data package to obtain a compiled program data package, the program data package including a program script of the target program and a resource file of the target program, wherein the program script can be run in a program container;

[0009] Load the application container through a web browser;

[0010] The program data package is deployed in the program container to execute the program script through the program container and call the resource file according to the program script.

[0011] In a second aspect, an embodiment of the present application provides a device for running a program through a web browser, comprising:

[0012] An acquisition module, including acquiring the original data packet of the target program;

[0013] A construction module is used to build a program container, which can be loaded by a web browser;

[0014] A compiling module, used to compile the original data packet to obtain a compiled program data packet, the program data packet including a program script of a target program and a resource file of the target program, wherein the program script can be run in a program container;

[0015] Loading module, used to load the program container through a web browser;

[0016] The running module is used to deploy the program data package in the program container to execute the program script through the program container and call the resource file according to the program script.

[0017] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, wherein the memory stores programs or instructions that can be executed on the processor, and when the programs or instructions are executed by the processor, the steps of the method of the first aspect are implemented.

[0018] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method of the first aspect are implemented.

[0019] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the steps of the method of the first aspect.

[0020] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method of the first aspect.

[0021] In an embodiment of the present application, a program container based on a web browser is constructed, and the original data packet of the target program embedded in other applications is compiled, and a program data packet that can be loaded and run in the program container after compilation is output. When the target program needs to be run externally, the program container can be loaded through a web browser, and the compiled program data packet can be deployed in the program container to run the target program originally embedded in other programs through a web browser, so that the target program originally embedded in a certain application is no longer strongly dependent on the environment of the embedded application, thereby improving flexibility. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A flowchart showing a method for running a program through a web browser according to an embodiment of the present application is shown;

[0023] Figure 2 A schematic diagram of a framework of a web browser according to an embodiment of the present application is shown;

[0024] Figure 3 A schematic diagram of a functional module of a program container according to an embodiment of the present application is shown;

[0025] Figure 4 A structural block diagram of a device for running a program through a web browser according to an embodiment of the present application is shown;

[0026] Figure 5 A structural block diagram of an electronic device according to an embodiment of the present application is shown;

[0027] Figure 6 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0029] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0030] In conjunction with the accompanying drawings, the method, device, electronic device and medium for running a program through a web browser provided in the embodiments of the present application are described in detail through specific embodiments and their application scenarios.

[0031] In some embodiments of the present application, a method for running a program through a web browser is provided. Figure 1 A flowchart of a method for running a program through a web browser according to an embodiment of the present application is shown. Figure 1 As shown, the method of running a program through a web browser includes:

[0032] Step 102, obtaining the original data packet of the target program;

[0033] Step 104, building a program container;

[0034] In step 104, the program container can be loaded by a web browser;

[0035] Step 106, compile the original data packet to obtain a compiled program data packet;

[0036] In step 106, the program data package includes a program script of the target program and a resource file of the target program, wherein the program script can be run in the program container;

[0037] Step 108, loading the program container through a web browser;

[0038] Step 110, deploying a program data package in a program container, so as to execute a program script through the program container, and calling a resource file according to the program script.

[0039] In the embodiment of the present application, the target program is a program embedded in a certain program. The target program may be a "mini game" or a "mini program" that implements a certain function. The following example is taken as an example in which the target program is originally embedded in program A.

[0040] Define program A as the host of the target program, and program A and the SDK (Software Development Kit) embedded in program A for running the target program as the host environment of the target program.

[0041] The embodiment of the present application is to simulate the array environment of the target program in the application end of Program A through the standard capabilities of the web browser, so as to build a program container of the web browser, and the program container is also a web application, so as to provide the target program with the same or similar technical standards as the host environment, and realize the running of the target program originally embedded in Program A in the web browser.

[0042] Specifically, first, the original data packet of the target program is obtained, and the original data packet includes data required for the target program to run in the environment of program A. Then, a program container is constructed according to the environment and capabilities required for the target program to run.

[0043] The program container is specifically a program that can be loaded in a web browser environment or in a webview embedded in some other program. The program container can be loaded by setting up the program container on the web side and accessing the web side through a web browser.

[0044] According to the environment of the program container, the original data packet of the target program is further compiled, and the compiled program package is output. The compiled program package can be deployed in the program container, and the program container can run the program script of the program data packet, and call the resource file in the program data packet through the program script to realize the program running in the web browser.

[0045] Figure 2 A schematic diagram of a web browser framework according to an embodiment of the present application is shown. Figure 2As shown, the web browser itself has standard capabilities, including rendering, loading pictures, playing audio, user operation interaction, executing scripts, accessing the network, and calling standard function APIs (Application Programming Interfaces), etc. By supporting and running existing target programs through web browsers, the flexibility of the target programs can be significantly improved.

[0046] Among them, the small programs and small games embedded in the external programs, that is, the target programs generally follow the JS (JavaScript, a scripting language) scripting language, and the web browser generally also has a built-in JavaScript engine, that is, it has the ability to parse JavaScript scripts. Therefore, the original data packet of the target program can be directly run in the program container after automated tool chain processing.

[0047] The embodiment of the present application constructs a program container based on a web browser, compiles the original data packet of the target program embedded in other applications, and outputs a program data packet that can be loaded and run in the program container after compilation. When the target program needs to be run externally, the program container can be loaded through a web browser, and the compiled program data packet can be deployed in the program container to run the target program originally embedded in other programs through a web browser, so that the target program originally embedded in a certain application is no longer strongly dependent on the environment of the embedded application, thereby improving the flexibility of "mini games" and "mini programs".

[0048] In some embodiments of the present application, the step of constructing a program container specifically includes: determining the target capabilities required for the target program to run according to the original data packet; and constructing the program container according to the target capabilities.

[0049] In this technical solution, by combing the host capabilities that the target program depends on (that is, the environment capabilities of program A), the corresponding target capabilities are determined, and based on the target capabilities required for the target program to run, a program container is hypothetically constructed on the web side. The above method can simulate the host environment required for the target program to run, and embed the SDK that the target program depends on, which can ensure that the program container has all the capabilities required for the target program to run, and ensure that the target program can run normally in the web browser through the program container.

[0050] In some embodiments of the present application, after the step of building the program container, the method further includes:

[0051] Encapsulate the program container to obtain a container data packet;

[0052] Deploy the container data package to the target server;

[0053] The steps to load the application container through a web browser include:

[0054] Accessing a first network address of a target server through a web browser to obtain a container data packet; wherein the first network address is associated with the program data packet;

[0055] Load the application container via the container package.

[0056] In the embodiment of the present application, after the program container is constructed, the program container is deployed on the web side. Specifically, the constructed program container is packaged, compressed, and other packaging processes are performed, and then output as a container data packet that can be deployed online.

[0057] The output container data packet is deployed to the corresponding web server, that is, the target server. In some implementations, a domain name can be configured for the container data packet, and the web browser can obtain the container data packet from the web server by accessing the domain name.

[0058] Specifically, after the container data packet is deployed to the target server, the target server generates a first network address corresponding to the container data packet and distributes it to the web browser. When the target program needs to be run through the web browser, the web browser accesses the first network address, and the target server responds to the web browser's access to the first network address and sends the container data packet of the program container to the web browser. The web browser unpacks the container data packet to obtain the resources required to load the program container, thereby completing the loading of the program container.

[0059] Among them, the loading entry of the target program can be defined by the host environment of the target program. For example, assuming that the target program is a small game program, the game.js file of the target program can be defined, and the environment for running the target program can be pre-built in the program container, including container interface rendering, object injection required for the target program to run, capability initialization required for the target program to run, etc. The (game.js) file is loaded through dynamic script loading to run the program script content in the program data package.

[0060] The embodiment of the present application deploys a container data packet of a program container online, and the web browser completes the online loading of the program container by accessing the first network address of the container data packet, and runs the target program on the web browser side through the loaded program container, thereby improving the flexibility of the target program running.

[0061] In some embodiments of the present application, after the step of compiling the original data packet to obtain a compiled program data packet, the method further includes:

[0062] Uploading the program data package to a content distribution network, wherein the second network address of the program data package in the content distribution network is associated with the program container;

[0063] Before the step of deploying the program data package in the program container, the method further includes:

[0064] Access the second network address through a web browser to obtain the program data package.

[0065] In this technical solution, for a target program embedded in program A, the original data package of the target program is compiled to obtain a compiled program data package. After obtaining the program data package, the program data package is sent to a content delivery network (Content Delivery Network CDN).

[0066] The content distribution network will store the received program data packets accordingly, and configure a corresponding second network address for these program data packets according to the program name or program identifier of each target program. The second network address is associated with the program container, thereby ensuring that after the web browser accesses the second network address to obtain the program data packet, the program container loaded by the web browser can run the target program normally through the program data packet.

[0067] Specifically, after the web browser loads the program container, the web browser obtains and accesses the second network address according to the target program to be run. In response to the web browser's access to the second network address, the content distribution network sends the program data packet corresponding to the second network address to the web browser.

[0068] After receiving the program data packet, the web browser deploys the program data packet into the program container, and the program container runs the target program based on the program data packet.

[0069] The embodiment of the present application stores the program data packet of the target program through a content distribution network, and the web browser can obtain the program data packet by accessing the content distribution network, thereby realizing the running of the application program through the web browser through the loaded program container target program, thereby improving the flexibility of the target program.

[0070] In some embodiments of the present application, the steps of deploying a program data package in a program container to execute a program script through the program container specifically include:

[0071] Searching for the loading status of the program script in the target reference table, where the target reference table is a reference table in the stack of the program container;

[0072] When the loading state is not loaded, performing the step of accessing the second network address through a web browser to obtain a program data packet;

[0073] After the step of deploying the program data package in the program container to execute the program script through the program container, the method for running the program through the web browser further includes:

[0074] Add a loading record of the program script in the target reference table; wherein the loading record includes path information of the program script, content information of the program script, and information of functions to be executed of the program script.

[0075] In an embodiment of the present application, taking a web browser running a JS script as an example, a target reference table is stored in the stack of the program container when running the JS script. When deploying a program data package, the loading status of the program script in the program data package of the target program is first searched in the target reference table.

[0076] If the search result shows that the program script has been loaded, it means that the program script of the target program has started to run. At this time, the export content of the program script is dynamically obtained. The export content is the output content when the target program is running.

[0077] If the search result shows that the program script is not loaded, it is determined that the program data package of the target program has not been downloaded or the download has failed. At this time, the web browser is controlled to access the second network address and obtain the program data package of the target program. At this time, if the program data package is successfully obtained, a loading record of the program script is added to the target reference table, and the loading record specifically includes a script path, a script content, and a record of a function to be executed, and the loading record can reflect that the program script has been loaded.

[0078] If the program data package cannot be successfully obtained at this time, a feedback is given that the program data package loading failed, and a corresponding failure log is generated.

[0079] The embodiment of the present application determines the loading status of the program data packet of the target program by reusing the reference table in the stack of the program container at runtime, thereby improving the reliability and stability of running the target program through the web browser.

[0080] In some embodiments of the present application, the program container includes a sandbox storage space, a canvas rendering component, and an interactive event processing component;

[0081] Among them, the sandbox storage space is used to store resource files; the canvas rendering component is used to render the program interface of the target program; the interactive event processing component is used to receive user input, call the target function in the program script according to the user input, and execute the program function corresponding to the user input through the target function.

[0082] In the embodiment of the present application, the program container can set a local storage space in which the resource files of the target program are stored. Specifically, the stack storage space of the program container js can be used to simulate the sandbox storage space, and the mapping of the local file directory and the file content can be saved through the sandbox storage space.

[0083] Exemplarily, the file content can be saved in the form of a string or ArrayBuffer (a data format natively supported by the browser), encoded and mapped when the data is written, and decoded and restored to the original data content when the data is read.

[0084] The program container can also call the canvas rendering component (Canvas) in the web browser environment. The main canvas of the canvas rendering component is used to simulate the rendering entry of the host environment of the target program, and render the program interface of the target program, such as the application interface or the game screen, through the rendering entry consistent with the host environment.

[0085] Figure 3 A schematic diagram of the functional modules of a program container according to an embodiment of the present application is shown. Figure 3 As shown, the program container implements the calling of JavaScript engine, canvas rendering, image rendering, audio playback, network access and other web API functions by calling the underlying capabilities of the web browser.

[0086] The program container itself has the core capabilities of running the target program and the specific capabilities of the host of the target program. The core capabilities of the target program include language support, parsing and execution, dependency management mechanism, etc. for JavaScript scripts, as well as rendering interaction capabilities and resource management systems, including file sandbox storage space and media resource proxy mechanism capabilities.

[0087] The specific capabilities of the host can be implemented by calling the web API.

[0088] In some embodiments, when the target program is running, when the target program needs to access specific program resources, the network access function of the web browser can be used to directly access the resource files on the content distribution network CDN, download and save them to the local sandbox storage space through the network interface of the web browser, and access the required program resources through the file path of the local sandbox storage space, such as the program container requests the program resources, encodes them and writes them to the file system stack storage.

[0089] In other implementations, the program container may simulate the interface of the host environment file system of the target program, and de-decode and read and return the data stored in the stack of the program resources according to the encoding format corresponding to the host environment file system interface.

[0090] In some other embodiments, the target program accesses resources by calling the image and audio capabilities of the web browser and setting the src attribute of the capability object. This operation is standard for web browsers. In the target program, src can be an online CDN connection or a local file.

[0091] The program container globally takes over the prototypes of two types of media objects (image and audio), obtains the src attributes of all objects, and when the src attribute value is set, proxies the resource access. Online resources can be accessed by web browsers, and local resources can be read from the file system and passed to the program container in Base64 (the image and audio resource encoding format natively supported by browsers) encoding format.

[0092] The embodiment of the present application realizes downloading, referencing and running of the target program in a web browser environment, realizes seamless switching of the target program from a host environment to a web environment, and improves the flexibility of the target program.

[0093] In some embodiments of the present application, the web browser includes a browser plug-in embedded in the application;

[0094] The steps to load the application container through a web browser include:

[0095] In the application, load the program container through the browser plug-in;

[0096] The steps of deploying a program data package in a program container, executing a program script through the program container, and calling a resource file according to the program script include:

[0097] The program data package is deployed in the program container loaded by the browser plug-in, the program script is executed through the program container, and the resource file is called according to the program script to run the target program in the application.

[0098] In an embodiment of the present application, the web browser may also be a browser plug-in embedded in an application, such as a browser plug-in embedded in a shopping software, a browser plug-in embedded in a short video software, etc.

[0099] The browser plug-in embedded in the application can also load the program container and deploy the program data packet of the target program to be run in the program container, and run the target program in the application through the same execution program script and the method of calling the resource file through the program script. This allows small programs and small games originally embedded in other applications to run in other applications, thereby improving the flexibility of "small games" and "small programs".

[0100] The method for running a program through a web browser provided in the embodiment of the present application can be performed by a device for running a program through a web browser. In the embodiment of the present application, the device for running a program through a web browser is used as an example to illustrate the device for running a program through a web browser provided in the embodiment of the present application.

[0101] In some embodiments of the present application, a device for running a program through a web browser is provided. Figure 4 A structural block diagram of a device for running a program through a web browser according to an embodiment of the present application is shown. Figure 4 As shown, the device 400 for running a program through a web browser includes:

[0102] The acquisition module 402 is used to acquire the original data packet of the target program;

[0103] A construction module 404 is used to construct a program container, and the program container can be loaded by a web browser;

[0104] A compiling module 406 is used to compile the original data packet to obtain a compiled program data packet, where the program data packet includes a program script of the target program and a resource file of the target program, wherein the program script can be run in a program container;

[0105] A loading module 408, used to load the program container through a web browser;

[0106] The running module 410 is used to deploy the program data package in the program container, to execute the program script through the program container, and to call the resource file according to the program script.

[0107] In the embodiment of the present application, the target program is a program embedded in a certain program. The target program may be a "mini game" or a "mini program" that implements a certain function. The following example is taken as an example in which the target program is originally embedded in program A.

[0108] Define program A as the host of the target program, and program A and the SDK (Software Development Kit) embedded in program A for running the target program as the host environment of the target program.

[0109] The embodiment of the present application is to simulate the array environment of the target program in the application end of Program A through the standard capabilities of the web browser, so as to build a program container of the web browser, and the program container is also a web application, so as to provide the target program with the same or similar technical standards as the host environment, and realize the running of the target program originally embedded in Program A in the web browser.

[0110] Specifically, first, the original data packet of the target program is obtained, and the original data packet includes data required for the target program to run in the environment of program A. Then, a program container is constructed according to the environment and capabilities required for the target program to run.

[0111] The program container is specifically a program that can be loaded in a web browser environment or in a webview embedded in some other program. The program container can be loaded by setting up the program container on the web side and accessing the web side through a web browser.

[0112] According to the environment of the program container, the original data packet of the target program is further compiled, and the compiled program package is output. The compiled program package can be deployed in the program container, and the program container can run the program script of the program data packet, and call the resource file in the program data packet through the program script to realize the program running in the web browser.

[0113] Figure 2 A schematic diagram of a web browser framework according to an embodiment of the present application is shown. Figure 2 As shown, the web browser itself has standard capabilities, including rendering, loading pictures, playing audio, user operation interaction, executing scripts, accessing the network, and calling standard function APIs (Application Programming Interfaces), etc. By supporting and running existing target programs through web browsers, the flexibility of the target programs can be significantly improved.

[0114] Among them, the small programs and small games embedded in the external programs, that is, the target programs generally follow the JS (JavaScript, a scripting language) scripting language, and the web browser generally also has a built-in JavaScript engine, that is, it has the ability to parse JavaScript scripts. Therefore, the original data packet of the target program can be directly run in the program container after automated tool chain processing.

[0115] The embodiment of the present application constructs a program container based on a web browser, compiles the original data packet of the target program embedded in other applications, and outputs a program data packet that can be loaded and run in the program container after compilation. When the target program needs to be run externally, the program container can be loaded through a web browser, and the compiled program data packet can be deployed in the program container to run the target program originally embedded in other programs through a web browser, so that the target program originally embedded in a certain application is no longer strongly dependent on the environment of the embedded application, thereby improving the flexibility of "mini games" and "mini programs".

[0116] In some embodiments of the present application, the construction module is specifically used to: determine the target capability required for the target program to run according to the original data packet; and construct a program container according to the target capability.

[0117] In this technical solution, by combing the host capabilities that the target program depends on (that is, the environment capabilities of program A), the corresponding target capabilities are determined, and based on the target capabilities required for the target program to run, a program container is hypothetically constructed on the web side. The above method can simulate the host environment required for the target program to run, and embed the SDK that the target program depends on, which can ensure that the program container has all the capabilities required for the target program to run, and ensure that the target program can run normally in the web browser through the program container.

[0118] In some embodiments of the present application, the device for running the program through a web browser further includes:

[0119] The encapsulation module is used to encapsulate the program container to obtain a container data packet;

[0120] A deployment module, used to deploy container data packages to the target server;

[0121] An access module, configured to access a first network address of a target server through a web browser to obtain a container data packet; wherein the first network address is associated with a program data packet;

[0122] Load module, also used to load program containers via container data packages.

[0123] In the embodiment of the present application, after the program container is constructed, the program container is deployed on the web side. Specifically, the constructed program container is packaged, compressed, and other packaging processes are performed, and then output as a container data packet that can be deployed online.

[0124] The output container data packet is deployed to the corresponding web server, that is, the target server. In some implementations, a public external domain name can be configured for the container data packet, and the web browser can obtain the container data packet from the web server by accessing the external domain name.

[0125] Specifically, after the container data packet is deployed to the target server, the target server generates a first network address corresponding to the container data packet and distributes it to the web browser. When the target program needs to be run through the web browser, the web browser accesses the first network address, and the target server responds to the web browser's access to the first network address and sends the container data packet of the program container to the web browser. The web browser unpacks the container data packet to obtain the resources required to load the program container, thereby completing the loading of the program container.

[0126] Among them, the loading entry of the target program can be defined by the host environment of the target program. For example, assuming that the target program is a small game program, the game.js file of the target program can be defined, and the environment for running the target program can be pre-built in the program container, including container interface rendering, object injection required for the target program to run, capability initialization required for the target program to run, etc. The (game.js) file is loaded through dynamic script loading to run the program script content in the program data package.

[0127] The embodiment of the present application deploys a container data packet of a program container online, and the web browser completes the online loading of the program container by accessing the first network address of the container data packet, and runs the target program on the web browser side through the loaded program container, thereby improving the flexibility of the target program running.

[0128] In some embodiments of the present application, the device for running the program through a web browser further includes:

[0129] An uploading module, used for uploading a program data package to a content distribution network, wherein a second network address of the program data package in the content distribution network is associated with the program container;

[0130] The access module is also used to access the second network address through a web browser to obtain the program data packet.

[0131] In this technical solution, for a target program embedded in program A, the original data package of the target program is compiled to obtain a compiled program data package. After obtaining the program data package, the program data package is sent to a content delivery network (Content Delivery Network CDN).

[0132] The content distribution network will store the received program data packets accordingly, and configure a corresponding second network address for these program data packets according to the program name or program identifier of each target program. The second network address is associated with the program container, thereby ensuring that after the web browser accesses the second network address to obtain the program data packet, the program container loaded by the web browser can run the target program normally through the program data packet.

[0133] Specifically, after the web browser loads the program container, the web browser obtains and accesses the second network address according to the target program to be run. In response to the web browser's access to the second network address, the content distribution network sends the program data packet corresponding to the second network address to the web browser.

[0134] After receiving the program data packet, the web browser deploys the program data packet into the program container, and the program container runs the target program based on the program data packet.

[0135] The embodiment of the present application stores the program data packet of the target program through a content distribution network, and the web browser can obtain the program data packet by accessing the content distribution network, thereby realizing the running of the application program through the web browser through the loaded program container target program, thereby improving the flexibility of the target program.

[0136] In some embodiments of the present application, the device for running the program through a web browser further includes:

[0137] A search module, used for searching the loading status of the program script in a target reference table, where the target reference table is a reference table in the stack of the program container;

[0138] The access module is further used to execute the step of accessing the second network address through a web browser to obtain a program data packet when the loading state is not loaded;

[0139] The recording module is used to add a loading record of a program script in a target reference table; wherein the loading record includes path information of the program script, content information of the program script and information of a function to be executed of the program script.

[0140] In an embodiment of the present application, taking a web browser running a JS script as an example, a target reference table is stored in the stack of the program container when running the JS script. When deploying a program data package, the loading status of the program script in the program data package of the target program is first searched in the target reference table.

[0141] If the search result shows that the program script has been loaded, it means that the program script of the target program has started to run. At this time, the export content of the program script is dynamically obtained. The export content is the output content when the target program is running.

[0142] If the search result shows that the program script is not loaded, it is determined that the program data package of the target program has not been downloaded or the download has failed. At this time, the web browser is controlled to access the second network address and obtain the program data package of the target program. At this time, if the program data package is successfully obtained, a loading record of the program script is added to the target reference table, and the loading record specifically includes a script path, a script content, and a record of a function to be executed, and the loading record can reflect that the program script has been loaded.

[0143] If the program data package cannot be successfully obtained at this time, a feedback is given that the program data package loading failed, and a corresponding failure log is generated.

[0144] The embodiment of the present application determines the loading status of the program data packet of the target program by reusing the reference table in the stack of the program container at runtime, thereby improving the reliability and stability of running the target program through the web browser.

[0145] In some embodiments of the present application, the program container includes a sandbox storage space, a canvas rendering component, and an interactive event processing component;

[0146] Among them, the sandbox storage space is used to store resource files; the canvas rendering component is used to render the program interface of the target program; the interactive event processing component is used to receive user input, call the target function in the program script according to the user input, and execute the program function corresponding to the user input through the target function.

[0147] In the embodiment of the present application, the program container can set a local storage space in which the resource files of the target program are stored. Specifically, the stack storage space of the program container js can be used to simulate the sandbox storage space, and the mapping of the local file directory and the file content can be saved through the sandbox storage space.

[0148] Exemplarily, the file content can be saved in the form of a string or ArrayBuffer (a data format natively supported by the browser), encoded and mapped when the data is written, and decoded and restored to the original data content when the data is read.

[0149] The program container can also call the canvas rendering component (Canvas) in the web browser environment. The main canvas of the canvas rendering component is used to simulate the rendering entry of the host environment of the target program, and render the program interface of the target program, such as the application interface or the game screen, through the rendering entry consistent with the host environment.

[0150] Figure 3 A schematic diagram of the functional modules of a program container according to an embodiment of the present application is shown. Figure 3As shown, the program container implements the calling of JavaScript engine, canvas rendering, image rendering, audio playback, network access and other web API functions by calling the underlying capabilities of the web browser.

[0151] The program container itself has the core capabilities of running the target program and the specific capabilities of the host of the target program. The core capabilities of the target program include language support, parsing and execution, dependency management mechanism, etc. for JavaScript scripts, as well as rendering interaction capabilities and resource management systems, including file sandbox storage space and media resource proxy mechanism capabilities.

[0152] The specific capabilities of the host can be implemented by calling the web API, including host capability simulation alignment and program entry process adaptation.

[0153] In some embodiments, when the target program is running, when the target program needs to access specific program resources, the network access function of the web browser can be used to directly access the resource files on the content distribution network CDN, download and save them to the local sandbox storage space through the network interface of the web browser, and access the required program resources through the file path of the local sandbox storage space, such as the program container requests the program resources, encodes them and writes them to the file system stack storage.

[0154] In other implementations, the program container may simulate the interface of the host environment file system of the target program, and de-decode and read and return the data stored in the stack of the program resources according to the encoding format corresponding to the host environment file system interface.

[0155] In some other embodiments, the target program accesses resources by calling the image and audio capabilities of the web browser and setting the src attribute of the capability object. This operation is standard for web browsers. In the target program, src can be an online CDN connection or a local file.

[0156] The program container globally takes over the prototypes of two types of media objects (image and audio), obtains the src attributes of all objects, and when the src attribute value is set, proxies the resource access. Online resources can be accessed by web browsers, and local resources can be read from the file system and passed to the program container in Base64 (the image and audio resource encoding format natively supported by browsers) encoding format.

[0157] The embodiment of the present application realizes downloading, referencing and running of the target program in a web browser environment, realizes seamless switching of the target program from a host environment to a web environment, and improves the flexibility of the target program.

[0158] In some embodiments of the present application, the web browser includes a browser plug-in embedded in the application;

[0159] The loading module is specifically used to load the program container through the browser plug-in in the application;

[0160] The running module is specifically used to deploy a program data package in a program container loaded by a browser plug-in, execute a program script through the program container, and call a resource file according to the program script to run a target program within the application.

[0161] In an embodiment of the present application, the web browser may also be a browser plug-in embedded in an application, such as a browser plug-in embedded in a shopping software, a browser plug-in embedded in a short video software, etc.

[0162] The browser plug-in embedded in the application can also load the program container and deploy the program data packet of the target program to be run in the program container, and run the target program in the application through the same execution program script and the method of calling the resource file through the program script. This allows small programs and small games originally embedded in other applications to run in other applications, thereby improving the flexibility of "small games" and "small programs".

[0163] The device for running a program through a web browser in the embodiment of the present application can be an electronic device, or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a car-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0164] The device for running a program through a web browser in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0165] The device for running a program through a web browser provided in the embodiment of the present application can implement each process implemented in the above method embodiment, and will not be described again here to avoid repetition.

[0166] Optionally, an embodiment of the present application further provides an electronic device, Figure 5 A structural block diagram of an electronic device according to an embodiment of the present application is shown. Figure 5 As shown, the electronic device 500 includes a processor 502, a memory 504, and a program or instruction stored in the memory 504 and executable on the processor 502. When the program or instruction is executed by the processor 502, each process of the above-mentioned method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0167] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0168] Figure 6 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0169] The electronic device 600 includes but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, a processor 610 and other components.

[0170] Those skilled in the art will appreciate that the electronic device 600 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 610 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0171] Among them, the processor 610 is used to obtain the original data packet of the target program; build a program container, which can be loaded by a web browser; compile the original data packet to obtain a compiled program data packet, which includes a program script of the target program and a resource file of the target program, wherein the program script can run in the program container; load the program container through a web browser; deploy the program data packet in the program container to execute the program script through the program container, and call the resource file according to the program script.

[0172] The embodiment of the present application constructs a program container based on a web browser, compiles the original data packet of the target program embedded in other applications, and outputs a program data packet that can be loaded and run in the program container after compilation. When the target program needs to be run externally, the program container can be loaded through a web browser, and the compiled program data packet can be deployed in the program container to run the target program originally embedded in other programs through a web browser, so that the target program originally embedded in a certain application is no longer strongly dependent on the environment of the embedded application, thereby improving the flexibility of "mini games" and "mini programs".

[0173] Optionally, the processor 610 is further configured to determine target capabilities required for the target program to run according to the original data packet; and construct a program container according to the target capabilities.

[0174] In this technical solution, by combing the host capabilities that the target program depends on (that is, the environment capabilities of program A), the corresponding target capabilities are determined, and based on the target capabilities required for the target program to run, a program container is hypothetically constructed on the web side. The above method can simulate the host environment required for the target program to run, and embed the SDK that the target program depends on, which can ensure that the program container has all the capabilities required for the target program to run, and ensure that the target program can run normally in the web browser through the program container.

[0175] Optionally, the processor 610 is further used to encapsulate the program container to obtain a container data packet; deploy the container data packet to a target server; access a first network address of the target server through a web browser to obtain the container data packet; wherein the first network address is associated with the program data packet; and load the program container through the container data packet.

[0176] The embodiment of the present application deploys a container data packet of a program container online, and the web browser completes the online loading of the program container by accessing the first network address of the container data packet, and runs the target program on the web browser side through the loaded program container, thereby improving the flexibility of the target program running.

[0177] Optionally, the processor 610 is further configured to upload the program data package to a content distribution network, wherein a second network address of the program data package in the content distribution network is associated with the program container; and the second network address is accessed through a web browser to obtain the program data package.

[0178] The embodiment of the present application stores the program data packet of the target program through a content distribution network, and the web browser can obtain the program data packet by accessing the content distribution network, thereby realizing the running of the application program through the web browser through the loaded program container target program, thereby improving the flexibility of the target program.

[0179] Optionally, the processor 610 is also used to search for the loading status of the program script in the target reference table, which is a reference table in the stack of the program container; when the loading status is loaded, obtain the export content of the program script; when the loading status is not loaded, execute the step of accessing the second network address through a web browser to obtain a program data packet; when the program data packet is obtained, add a loading record of the program script to the target reference table; wherein the loading record includes path information of the program script, content information of the program script and information of functions to be executed of the program script.

[0180] The embodiment of the present application determines the loading status of the program data packet of the target program by reusing the reference table in the stack of the program container at runtime, thereby improving the reliability and stability of running the target program through the web browser.

[0181] Optionally, processor 610 is also used for a program container including a sandbox storage space, a canvas rendering component and an interactive event processing component; wherein the sandbox storage space is used to store resource files; the canvas rendering component is used to render the program interface of the target program; the interactive event processing component is used to receive user input, and call the target function in the program script according to the user input, so as to execute the program function corresponding to the user input through the target function.

[0182] The embodiment of the present application realizes downloading, referencing and running of the target program in a web browser environment, realizes seamless switching of the target program from a host environment to a web environment, and improves the flexibility of the target program.

[0183] It should be understood that in the embodiment of the present application, the input unit 604 may include a graphics processor (GPU) 6041 and a microphone 6042, and the graphics processor 6041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 606 may include a display panel 6061, and the display panel 6061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 607 includes a touch panel 6071 and at least one of other input devices 6072. The touch panel 6071 is also called a touch screen. The touch panel 6071 may include two parts: a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0184] The memory 609 can be used to store software programs and various data. The memory 609 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 609 may include a volatile memory or a non-volatile memory, or the memory 609 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 609 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0185] The processor 610 may include one or more processing units; optionally, the processor 610 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 610.

[0186] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0187] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0188] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0189] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0190] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0191] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0192] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present application.

[0193] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for running a program through a web browser, characterized in that: include: Get the original data packet of the target program; Building a program container, wherein the program container can be loaded by a web browser; Compiling the original data packet to obtain a compiled program data packet, wherein the program data packet includes a program script of the target program and a resource file of the target program, wherein the program script can be run in the program container; Loading the program container through the web browser; The program data package is deployed in the program container to execute the program script through the program container, and the resource file is called according to the program script.

2. The method according to claim 1, characterized in that The steps of constructing the program container specifically include: Determining the target capability required for the target program to run according to the original data packet; The program container is constructed according to the target capability.

3. The method according to claim 2, characterized in that After the step of building the program container, the method further includes: Encapsulating the program container to obtain a container data packet; Deploy the container data package to a target server; The step of loading the program container through the web browser specifically includes: Accessing a first network address of the target server through the web browser to obtain the container data packet; wherein the first network address is associated with the program data packet; The program container is loaded through the container data packet.

4. The method according to claim 1, characterized in that: After the step of compiling the original data packet to obtain a compiled program data packet, the method further includes: Uploading the program data package to a content distribution network, wherein a second network address of the program data package in the content distribution network is associated with the program container; Before the step of deploying the program data package in the program container, the method further includes: The second network address is accessed through the web browser to obtain the program data package.

5. The method according to claim 4, characterized in that The step of deploying the program data package in the program container to execute the program script through the program container specifically includes: Searching for a loading status of the program script in a target reference table, where the target reference table is a reference table in a stack of the program container; When the loading state is not loaded, performing the step of accessing the second network address through the web browser to obtain the program data package; After the step of deploying the program data package in the program container to execute the program script through the program container, the method further includes: Adding a loading record of the program script in the target reference table; wherein the loading record includes path information of the program script, content information of the program script and information of functions to be executed of the program script.

6. The method according to claim 1, characterized in that The program container includes a sandbox storage space, a canvas rendering component and an interactive event processing component; Among them, the sandbox storage space is used to store the resource file; the canvas rendering component is used to render the program interface of the target program; the interactive event processing component is used to receive user input, and call the target function in the program script according to the user input, so as to execute the program function corresponding to the user input through the target function.

7. The method according to any one of claims 1 to 6, characterized in that The web browser includes a browser plug-in embedded in the application; The step of loading the program container through the web browser comprises: In the application, loading the program container through the browser plug-in; The steps of deploying the program data package in the program container, executing the program script through the program container, and calling the resource file according to the program script include: The program data package is deployed in the program container loaded by the browser plug-in, the program script is executed through the program container, and the resource file is called according to the program script to run the target program in the application program.

8. A device for running a program through a web browser, characterized in that: include: An acquisition module, including acquiring the original data packet of the target program; A construction module, used to construct a program container, wherein the program container can be loaded by a web browser; A compiling module, used to compile the original data packet to obtain a compiled program data packet, wherein the program data packet includes a program script of the target program and a resource file of the target program, wherein the program script can be run in the program container; A loading module, used to load the program container through the web browser; The running module is used to deploy the program data package in the program container, to execute the program script through the program container, and to call the resource file according to the program script.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

11. A computer program product, the computer program product being stored in a storage medium, characterized in that: When the computer program product is executed by at least one processor, the steps of the method according to any one of claims 1 to 7 are implemented.