Method, device, medium and electronic equipment for creating DOM sandbox environment
Technical Field
The invention relates to the technical field of computers, in particular to a method, a device, a medium and electronic equipment for creating a DOM sandbox environment.
Background
If a front-end service is integrated at a site, the packet size becomes too large as the complexity increases. The release is frequent. If there are n services, each service has a certain update frequency, and the combination of the services causes the update to be distributed very frequently, and each service allows all the items to be upgraded together.
Especially when a plurality of services are combined, which version corresponds to which change is difficult to trace.
The old iframe solution can solve this problem to some extent. Specifically, a site page is divided into N frames, and each frame runs an independent domain name independently.
But since a complete project contains a large number of common functions and codes, such as login identity, station credit, the service module is only one of the parts. This is quite time and labor intensive to implement with cross-window communications and iframe effects are much less effective after a single page is exposed using reach or similar loading techniques.
Even if the iframe adopts a similar scheme, the technical details of soft route synchronization, window size synchronization and the like should be achieved. It is unacceptable to drop a module into an iframe to self-kill.
The micro-service of the server side mainly realizes the bottom support of virtualization through a docker technology, so that a service developer can not experience the difference of the environment and the difference of the floating operation. Before the docker is generally applied, the micro-service is very complicated to use at a server side, and the maintenance cost is greatly increased; this expanded cost problem has not been solved until with the docker's sandbox system; this environment does not exist while running within the front-end browser. Due to the characteristics of microservices, locally developed modules are only a part of projects, and horizontal modules (other project groups) and vertical modules (site architecture) are managed and combined outside the projects. Different modules need to be loaded flexibly during running, and systems which are not known to each other are integrated into one page to run.
Because module developers do not know each other, if strict isolation cannot be achieved, local development and online environment codes are inconsistent, running results are different, and debugging cannot be carried out and maintenance cannot be carried out. Local development of modules requires very tight operational isolation, prevents mutual interference, cannot be contaminated, and cannot be constrained only by engagement of such unreliable non-deterministic means. If the sandbox is not made, the micro service is the micro developed monolithic service, and the real micro service cannot be realized.
Therefore, in long-term research and development, the inventor has conducted a great deal of research and development on a method for creating a DOM sandbox environment, and proposes a method for creating a DOM sandbox environment to solve one of the above technical problems.
Disclosure of Invention
The invention aims to provide a method, a device, a medium and an electronic device for creating a DOM sandbox environment, which can solve at least one technical problem mentioned above. The specific scheme is as follows:
according to the specific implementation manner of the invention, in a first aspect, the invention provides a method for creating a DOM sandbox environment, which comprises the following steps:
configuring the DOM sandbox to comprise a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for shooting the snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits;
adding a starting program into the DOM sandbox;
and integrating the DOM sandbox into a development environment.
According to a second aspect, the invention provides a method for creating a DOM sandbox environment, which includes:
the configuration unit is used for configuring the DOM sandbox to comprise a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for shooting the snapshot and recording the corresponding child node and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits;
the adding unit is used for adding a starting program into the DOM sandbox configured by the configuration unit;
and the integration unit is used for integrating the DOM sandbox added by the adding unit into a development environment.
According to a third aspect, the present invention provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements the method of creating a DOM sandbox environment as described in any one of the above.
According to a fourth aspect of the present invention, there is provided an electronic apparatus including: one or more processors; storage means for storing one or more programs that, when executed by the one or more processors, cause the one or more processors to implement a method of creating a DOM sandbox environment as described in any one of the above.
Compared with the prior art, the scheme of the embodiment of the invention at least has the following beneficial effects: the invention provides a method, a device, a medium and electronic equipment for creating a DOM sandbox environment, wherein the DOM sandbox is configured to comprise a first DOM sandbox subunit responsible for inserting or removing a corresponding child node, a second DOM sandbox subunit responsible for shooting a snapshot and recording the corresponding child node and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits, so that effective isolation of independently developed modules is realized, and the problem of mutual interference of on-line modules in a mixed loading process is avoided.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention. It is obvious that the drawings in the following description are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort. In the drawings:
FIG. 1 is a flow chart of a method for creating a DOM sandbox environment in accordance with an embodiment of the present invention;
FIG. 2 shows a schematic diagram of a creating device structure of a DOM sandbox environment in accordance with an embodiment of the invention;
fig. 3 shows a schematic diagram of an electronic device connection structure according to an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, and "a plurality" typically includes at least two.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
It should be understood that although the terms first, second, third, etc. may be used to describe … … in embodiments of the present invention, these … … should not be limited to these terms. These terms are used only to distinguish … …. For example, the first … … can also be referred to as the second … … and similarly the second … … can also be referred to as the first … … without departing from the scope of embodiments of the present invention.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
It is also noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that an article or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such article or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in the article or device in which the element is included.
Alternative embodiments of the present invention are described in detail below with reference to the accompanying drawings.
Example 1
As shown in fig. 1, according to a specific embodiment of the present disclosure, in a first aspect, the present disclosure provides a method for creating a DOM sandbox environment, which specifically includes the following method steps:
s102: configuring the DOM sandbox to comprise a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for shooting the snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits;
executing S102 to configure the DOM sandbox to include a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits, specifically includes the following steps:
configuring a first DOM sandbox subunit responsible for inserting or removing the corresponding child node;
configuring a second DOM sandbox subunit which is responsible for taking a snapshot and recording the corresponding child nodes; and
and a third DOM sandbox subunit configured to be responsible for calculating the difference between any two of the second DOM sandbox subunits.
In this step, the DOM sandbox may be implemented by the guard of HTML children nodes:
in a specific application scenario, the first DOM sandbox subunit responsible for inserting or removing the corresponding child node is an interpolator, which is responsible for inserting or removing the corresponding child node.
In a specific application scene, the second DOM sandbox subunit responsible for taking a Snapshot and recording the corresponding child node is a Snapshot, and the Snapshot is responsible for taking the Snapshot and recording the current child node.
In a specific application scenario, a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits is snapshot.
Diff is responsible for calculating the difference between two snapshots, as follows:
tip (); // taking a snapshot
This is a dosmnapshoverted (dommnapshorthoff. diff) (this. dommnapshotororinal); calculating diff, finding the change
Interrupt (this. domssnapshopkotchanged); // remove changes.
S104: adding a starting program into the DOM sandbox;
in this step, adding a startup program to the DOM sandbox in S102, where the DOM sandbox includes a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating a difference between any two second DOM sandbox subunits; the description of each DOM sandbox subunit is specifically as the related description in S102, and is not repeated here, for details, see the related description above.
Optionally, before executing S104 to add the launcher to the DOM sandbox, the method further includes the following steps:
and compiling the source code to obtain a corresponding starting program.
Specifically, the process of compiling the source code includes the steps of:
the source code is compiled into modules with different functions through compiling by a compiler. In practical applications, the type of compiler is not limited, but the compiler needs to compile with a compiler matching the source code, so that the source code is compiled into modules with different functions through the compilation of the compiler.
Optionally, before compiling the source code to obtain the corresponding boot program, the method further includes the following steps:
the source code is extracted. Specifically, the method for extracting the source code is matched with the type of the source code, the extraction method is different for different source codes, and the extraction method can be preset according to the preference of the user, which is not described herein again.
Optionally, in addition to executing S104 to add the launcher to the DOM sandbox, the method for creating the DOM sandbox environment provided by the present disclosure further includes the following steps:
and adding the original module library, the third party library and the external link library file into the DOM sandbox.
It should be noted that the original module library is formed by assembling modules with different functions, the third-party library is a third-party resource library with functional modules required by the user, and the external link library file is an external file with resources required by the user and provides a uniform resource locator linked to the resources required by the user.
S106: the DOM sandbox is integrated into the development environment.
In this step, the DOM sandbox in S102 is integrated into the development environment, where the DOM sandbox includes a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating a difference between any two second DOM sandbox subunits; the description of each DOM sandbox subunit is specifically as the related description in S102, and is not repeated here, for details, see the related description above.
Specifically, executing S106 to integrate the DOM sandbox into the development environment includes the following steps:
packaging the DOM sandbox, and giving corresponding read-write permission;
and installing the DOM sandbox.
In this step, installing the DOM sandbox in S102, where the DOM sandbox includes a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating a difference between any two second DOM sandbox subunits; the description of each DOM sandbox subunit is specifically as the related description in S102, and is not repeated here, for details, see the related description above.
In addition, the method for installing the DOM sandbox is not particularly limited, and the DOM sandbox may be installed by means of hot update, for example.
In this step, the development environment is a Windows system.
It should be noted that, the creating method of the DOM sandbox environment provided by the present disclosure preferentially selects the development environment of the Windows system, but is not limited to the development environment of the Windows system, and may also be applied to other development environments, which are not listed here.
The invention provides a method for creating a DOM sandbox environment, wherein the DOM sandbox is configured to comprise a first DOM sandbox subunit responsible for inserting or removing a corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits, so that effective isolation of independently developed modules is realized, and the problem of mutual interference of on-line modules in a mixed loading process is avoided.
Example 2
Referring to fig. 2, according to a second aspect of the embodiment of the present invention, the present invention provides an apparatus for creating a DOM sandbox environment, which specifically includes a configuration unit 202, an adding unit 204, and an integrating unit 206, and specifically as follows:
the configuration unit 202 is used for configuring the DOM sandbox to comprise a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits;
an adding unit 204, configured to add the startup program to the DOM sandbox configured by the configuration unit 202;
and an integrating unit 206, configured to integrate the DOM sandbox added by the adding unit 204 into the development environment.
Optionally, the apparatus further comprises:
and the compiling unit (not shown in fig. 2) is configured to compile the source code to obtain a corresponding startup program before the adding unit 204 adds the startup program to the DOM sandbox.
Optionally, the compiling unit is specifically configured to:
the source code is compiled into modules with different functions through compiling by a compiler.
Optionally, the apparatus further comprises:
and the extracting unit is used for extracting the source code before the compiling unit compiles the source code to obtain the corresponding starting program.
Optionally, the adding unit 204 is further configured to:
and adding the original module library, the third-party library and the external link library file to the DOM sandbox configured by the configuration unit 202.
Optionally, the integration unit 206 is specifically configured to:
packaging the DOM sandbox configured by the configuration unit 202, and giving corresponding read-write permission;
and installing the DOM sandbox configured by the configuration unit 202.
Optionally, the development environment of the integration unit 206 for integration is a Windows system.
The same or related contents of the creating apparatus in embodiment 2 of the present invention and the creating method in embodiment 1 of the present invention are not repeated herein, and please refer to the related description of the creating method in embodiment 1.
The invention provides a device for creating a DOM sandbox environment, wherein the configuration unit is used for configuring the DOM sandbox to comprise a first DOM sandbox subunit responsible for inserting or removing a corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits, so that effective isolation of each independently developed module is realized, and the problem of mutual interference of on-line modules in a mixed loading process is avoided.
Example 3
As shown in fig. 3, the present embodiment provides an electronic device, which is used in a method for creating a DOM sandbox environment, and the electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the one processor to cause the at least one processor to: by configuring the DOM sandbox to comprise a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits, effective isolation of each independently developed module is achieved, and the problem of mutual interference of online modules in the mixed loading process is avoided.
Example 4
Embodiments of the present disclosure provide a non-volatile computer storage medium, where computer-executable instructions are stored, and the computer-executable instructions may execute the method for creating the DOM sandbox environment in any of the above method embodiments.
Example 5
Referring now to FIG. 3, shown is a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 3, the electronic device may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 301 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)302 or a program loaded from a storage device 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device to communicate wirelessly or by wire with other devices to exchange data. While fig. 3 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 309, or installed from the storage means 308, or installed from the ROM 302. The computer program, when executed by the processing device 301, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: by configuring the DOM sandbox to comprise a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits, effective isolation of each independently developed module is achieved, and the problem of mutual interference of online modules in the mixed loading process is avoided.
Alternatively, the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: by configuring the DOM sandbox to comprise a first DOM sandbox subunit responsible for inserting or removing the corresponding child node, a second DOM sandbox subunit responsible for taking a snapshot and recording the corresponding child node, and a third DOM sandbox subunit responsible for calculating the difference between any two second DOM sandbox subunits, effective isolation of each independently developed module is achieved, and the problem of mutual interference of online modules in the mixed loading process is avoided.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.