CN116243923A - Applet processing method and device and electronic equipment - Google Patents

Applet processing method and device and electronic equipment Download PDF

Info

Publication number
CN116243923A
CN116243923A CN202310123330.9A CN202310123330A CN116243923A CN 116243923 A CN116243923 A CN 116243923A CN 202310123330 A CN202310123330 A CN 202310123330A CN 116243923 A CN116243923 A CN 116243923A
Authority
CN
China
Prior art keywords
code
applet
difference
target
source
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310123330.9A
Other languages
Chinese (zh)
Inventor
刘宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lazas Network Technology Shanghai Co Ltd
Original Assignee
Lazas Network Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Lazas Network Technology Shanghai Co Ltd filed Critical Lazas Network Technology Shanghai Co Ltd
Priority to CN202310123330.9A priority Critical patent/CN116243923A/en
Publication of CN116243923A publication Critical patent/CN116243923A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses an applet processing method, an applet processing device and electronic equipment. The method comprises the following steps: acquiring a source code of a target product to be generated; the target product is used for realizing a target applet function; taking the applet form corresponding to the source code as a source form, taking the applet form corresponding to the target product as a target form, and determining a form difference between the source form and the target form; and performing adaptive compiling on the source code based on the morphological difference to generate the target product. By adopting the method, the problem of large difficulty in small program iteration and maintenance of different small program forms is solved.

Description

Applet processing method and device and electronic equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for processing an applet, an electronic device, and a storage medium.
Background
The applet is an installation-free, i.e. ready-to-use application, which is increasingly being used because of its convenience. Currently, more and more enterprises develop applets put on different platforms to fully attract traffic. Applets providing the same functionality may be loaded on different platforms in different applet forms, which places higher demands on iteration and maintenance of the same functionality applet.
In the prior art, a set of source codes are maintained for different platforms according to the applet forms corresponding to the platforms, and products with corresponding forms are generated for the source codes corresponding to the platforms, and are used for providing the products for the corresponding platforms to generate the applet, so that the following defects exist: multiple sets of codes with the same function are required to be maintained, so that the function synchronization iteration period is long, the bug is more, the iteration maintenance difficulty is high, the research and development process is difficult, and the research and development cost is high.
Thus, how to generate products for different forms of applets based on the same set of source code is a problem to be solved.
The above information disclosed in the background section is only for enhancement of understanding of the background of the application and therefore it may contain information that does not form the prior art that is already known to a person of ordinary skill in the art.
Disclosure of Invention
The applet processing method solves the problems of large difficulty in applet iteration and maintenance of different applet forms.
The embodiment of the application provides an applet processing method, which comprises the following steps: acquiring a source code of a target product to be generated; the target product is used for realizing a target applet function; taking the applet form corresponding to the source code as a source form, taking the applet form corresponding to the target product as a target form, and determining a form difference between the source form and the target form; and performing adaptive compiling on the source code based on the morphological difference to generate the target product.
Optionally, the source modality includes one of the following applet modalities: independent applet, applet plug-in, applet sub-package; the target modality is an applet modality that is different from the source modality.
Optionally, the adaptively compiling the source code based on the morphological difference to generate the target product includes: in response to the morphology differences including a first difference, injecting code data for adapting the target morphology for the source code according to the first difference, generating the target product based on the injection; wherein the first difference comprises a difference between the source modality and the target modality that is related to an application instance of an applet global.
Optionally, the source modality is a stand-alone applet; the target form is an applet plug-in or applet package; the source code form comprises a first global logic code, a first page code and/or a first component code before conversion; the injecting code data for adapting the target modality for the source code according to the first difference, generating the target product based on the injecting, comprises: injecting application instance difference trowelling codes for simulating application instance lifecycle and simulating application instance call aiming at the source codes; modifying the first global logic code based on the application instance difference trowelling code to obtain a second global logic code after morphological conversion; modifying the first page code and/or the first component code based on the application instance difference trowelling code to obtain a second page code and/or a second component code after morphological transformation; obtaining modified codes corresponding to the source codes according to the application instance difference trowelling codes, the second global logic codes, the second page codes and/or the second component codes; and compiling the modified code to obtain the target product.
Optionally, modifying the first global logic code based on the application instance difference trowelling code to obtain a second global logic code after morphological transformation includes: adding codes in the first global logic code to obtain derived data of the application instance difference trowelling codes; modifying the initialization of the interception applet in the first global logic code into a simulated interception applet initialization method included in the application instance difference trowelling code; the simulation monitoring applet initializing method is a method executed by the initialization life cycle in the life cycle of the simulation application instance; the second global logic code is derived based on the modification.
Optionally, the modifying the first page code and/or the first component code based on the application instance difference trowelling code to obtain a second page code and/or a second component code after morphological transformation includes: adding code in the first page code and/or first component code that references the second global logic code and adds export data for obtaining the application instance difference screeding code; and injecting a simulation application instance calling method included in the application instance difference trowelling code into the first page code and/or the first component code to obtain a second page code and/or a second component code after morphological conversion.
Optionally, the application instance difference trowelling code includes: code for exporting a simulated application instance invocation method; code for implementing the simulated application instance invocation method; the simulation application instance calling method realizes data isolation and sharing based on the closure and the prototype chain; an initialization method for exporting the simulated listening applet; code for implementing the simulated listening applet initialization method.
Optionally, the adaptively compiling the source code based on the morphological difference to generate the target product includes: the source code form comprises a first page code and/or a first component code before conversion; responding to the morphological difference comprising a second difference, injecting a global style file in the source code into the first page code and/or the first component code to obtain a second page code and/or a second component code after morphological conversion, obtaining a modified code corresponding to the source code according to the second page code and/or the second component code, and compiling the modified code to obtain the target product; wherein the second difference comprises: when the source modality is an independent applet, the target modality is an applet plug-in or applet package, the source modality and the target modality are different relative to an applet global style.
Optionally, the injecting the global style file in the source code into the first page code and/or the first component code includes: at the beginning of the code file of the first page code and/or the first component code, adding an import statement to the global style file.
Optionally, the adaptively compiling the source code based on the morphological difference to generate the target product includes: responding to the morphological difference comprising a third difference, based on a preset specification to be complied with for generating the target product, uniformly packaging JS dependencies of independent applets, applet plug-ins and applet sub-package morphological products in the compiling process for generating the target product, and extracting a component library of the target product dependency to a specific component dependency folder; wherein the third difference comprises a difference between the source modality and the target modality that is related to a library of NPM components.
Optionally, the uniformly packaging JS dependencies of each form product of the independent applet, applet plug-in, applet package in the compiling process of generating the target product, and extracting the component library of the target product dependency to a specific component dependency folder includes: and performing dependency analysis based on the inlet configuration, performing component compiling and JS compiling according to the result of the dependency analysis, performing component grouping after compiling, performing component extraction according to the component grouping result, respectively merging and packaging the applet sub-packages or independent applets according to a target form, replacing the referenced component with a corresponding component under the target form, and outputting the target product.
Optionally, the preset specification to be complied with for generating the target product includes at least one of a directory structure specification, a multi-terminal component library specification and a JS-dependent library specification.
Optionally, the adaptively compiling the source code based on the morphological difference to generate the target product includes: responding to a compiling command triggered by a developer to execute a designated compiling type, and uploading an entry configuration file corresponding to the target form from the source code; wherein the compilation type is specified based on the target modality, and the portal configuration file includes the specified compilation type.
Optionally, the source form is an independent applet, and the target form is an applet package; the method further comprises the steps of: responding to a subcontracting configuration file creation command input by a developer, and generating a subcontracting configuration file under the root directory of the applet item corresponding to the source code, wherein the subcontracting configuration file is an entry configuration file corresponding to the applet subcontracting in a target form; adding a specific page identifier which is input by a developer and is to be compiled into a target sub-packet to page configuration information included in the sub-packet configuration file, wherein the specific page identifier corresponds to a specific page code included in the source code, and a page path of the specific page corresponding to the specific page identifier is formed by the sub-packet identifier of the target sub-packet and a path thereof; acquiring sub-package compiling configuration of the target sub-package, and adding the sub-package compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; the generating the target product based on the injecting includes: compiling the specific page code into the target subcontracting according to the subcontracting compiling configuration included in the entry configuration file and the configuration file of the development framework or the compiler; the target sub-package is the target product, and the folders corresponding to the target product can provide the function of the target applet after being stored in the corresponding hosts.
Optionally, the method further comprises: the application instance obtained by executing the application instance calling method when the target applet realized based on the target product runs is a mixed product of the corresponding host and the target package; the attributes and methods of the host can be obtained through the host variables of the application instance.
Optionally, the source form is an independent applet, and the target form is an applet plug-in; the method further comprises the steps of: responding to a plug-in configuration file creation command input by a developer, generating a plug-in configuration file under the root directory of the applet item corresponding to the source code, wherein the plug-in configuration file is an entry configuration file corresponding to the applet plug-in target form; if the global configuration file of the source code comprises sub-package configuration, adding page information of the sub-package configuration in the global configuration file to the page information of the plug-in configuration file, wherein a page path of the added page information consists of a corresponding sub-package identifier and a path of the sub-package; if the target plug-in obtained by compiling the source code comprises an open page, adding information of the open page to an open page variable in the plug-in configuration file; obtaining plug-in compiling configuration of the target plug-in, and adding the plug-in compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; the plug-in compiling configuration at least comprises: designating the compiling type as a plug-in; responding to the compiling command, performing injection on the source code according to a first difference between the source form and the target form to obtain a corresponding modified code, and compiling the modified code into the target plugin according to the plugin configuration file and the plugin compiling configuration; wherein the target insert is the target product.
Optionally, the method further comprises: and the external output attribute and the method of the target plug-in are realized in the page logic file of the applet item by calling the parent class of the application instance calling method.
Optionally, the source form is a applet plug-in; the target form is small program subpackage; the method further comprises the steps of: responding to a subcontracting configuration file creation command input by a developer, and generating a subcontracting configuration file under the root directory of the applet item corresponding to the source code, wherein the subcontracting configuration file is an entry configuration file corresponding to the applet subcontracting in a target form; converting information of a plug-in configuration file included in the source code into a sub-package configuration, and adding the sub-package configuration file; acquiring sub-package compiling configuration, and adding the sub-package compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; and in response to the compiling command, compiling the source code into the target product according to the subcontracting configuration file and the subcontracting compiling configuration.
Optionally, the method further comprises: the source form is an applet plug-in or applet package; the target form is an independent applet; performing adaptive compiling on the source code based on the morphological difference to generate the target product, including: acquiring an applet global configuration file written by a developer; receiving a specific configuration file modification of a developer aiming at a development framework, so that the specific configuration file contains compiling configuration information for compiling and generating independent applets, wherein the compiling configuration information contains compiling types which are independent applets; and compiling the source code according to the written global configuration file of the small program and the specific configuration file to obtain the target product.
The application also provides an applet processing apparatus comprising: the source code acquisition unit is used for acquiring a source code of a target product to be generated; the target product is used for realizing a target applet function; a morphology difference unit, configured to determine a morphology difference between the source morphology and the target morphology by using an applet morphology corresponding to the source code as a source morphology and an applet morphology corresponding to the target product as a target morphology; and the compiling unit is used for adaptively compiling the source code based on the morphological difference to generate the target product.
The embodiment of the application also provides electronic equipment, which comprises: a memory, and a processor; the memory is used for storing a computer program, and the computer program is executed by the processor to execute the method provided by the embodiment of the application.
The embodiment of the application also provides a computer storage medium, which stores computer-executable instructions for implementing the method provided in the embodiment of the application when the computer-executable instructions are executed by a processor.
Compared with the prior art, the application has the following advantages:
the embodiment of the application provides an applet processing method, an applet processing device, electronic equipment and a storage medium, wherein a source code of a target product to be generated is obtained; the target product is used for realizing a target applet function; taking the applet form corresponding to the source code as a source form, taking the applet form corresponding to the target product as a target form, and determining a form difference between the source form and the target form; and performing adaptive compiling on the source code based on the morphological difference to generate the target product. The source codes are compiled into target products in different forms (namely different applet forms) by adaptively compiling the source codes based on the form differences to provide difference trowelling capability between at least part of different forms, and the target products in each form can be put into corresponding channels, so that different form conversion is supported, applet form integration capability is provided, and iteration maintenance difficulty and cost are reduced.
Drawings
FIG. 1 is a schematic illustration of the processing of an applet provided herein;
FIG. 2 is a process flow diagram of an applet processing method provided in a first embodiment of the present application;
FIG. 3 is a schematic diagram of an applet compiling process according to a first embodiment of the present application;
FIG. 4 is a schematic diagram of an applet processing apparatus according to a second embodiment of the present application;
fig. 5 is a schematic diagram of an electronic device provided in the present application.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is, however, susceptible of embodiment in many other ways than those herein described and similar generalizations can be made by those skilled in the art without departing from the spirit of the application and the application is therefore not limited to the specific embodiments disclosed below.
The embodiment of the application provides an applet processing method, an applet processing device, electronic equipment and a storage medium. The following examples are described in detail.
For ease of understanding, first, related concepts and an application scenario of an applet processing method are presented. The application scenario is merely one embodiment of an application applet processing method, and this embodiment of the scenario is provided for the purpose of facilitating understanding of the applet processing method provided in the present application, and is not intended to limit the application of the applet processing method.
The applet is an installation-free, i.e., ready-to-use application. The development of the applet comprises the links of creating an applet project, writing applet codes, compiling and the like. Compilation refers to the process of constructing and packaging source code of an applet written by a developer into a product supported by the applet runtime, and may refer to transcoding, packaging, and other processes based on different grammars, or may refer to compilation into executable code.
The applet morphology refers to the morphology of the applet item and the corresponding product. For example, the product is in the form of an independent applet or applet package or applet plug-in.
The independent applet is an applet body with an app id (applet identification), has complete rights of the applet, can use plug-ins and sub-packages, and can provide shared data and methods for different plug-ins and sub-packages.
The small program sub-package means that the same small program is split into different sub-package developments according to the requirement, each sub-package is packaged into different sub-packages when being constructed, and the user terminal can load according to the requirement when in use. The applet package can apply for applet rights, and the sense of use is close to that of an independent applet. In this application, applet packetization includes packetization and main packetization in the conventional sense, so-called main packetization is one kind of applet, and each applet has only one main packetization for placing default startup page/tab (TabBar) pages, and some common resources and scripts that all packetization needs to use. The applet sub-packets can be divided into normal sub-packets and independent sub-packets according to their configuration items, e.g. whether the configuration is independent sub-packets or not by an index field in the configuration file app. Independent packetization is a special type of packetization that can be run independently of main packets and other packetization. The page entering applet from the independent sub-package does not need to download the main package, while the page entering the common sub-package or the main package needs to download the main package.
The applet plug-in is independently published, and the functional components which can be nested in the independent applet can be subscribed for use.
The development framework is an applet development framework, and a developer can apply abstract components and instance interaction methods provided by the development framework according to requirements to develop applet projects so as to realize corresponding business functions.
The compiler refers to an applet compiling device, and is used for converting source codes into target products, and the target products can be provided for a corresponding platform to realize target applet functions. The compiler may also be integrated into the development framework.
The development framework and/or compiler may be deployed on an electronic device, such as a computer, used by a developer, or on a server on a network. When the system is deployed on a server, a developer uses compiling service provided by the server through a network, and the server obtains source codes provided by the developer through the network, performs compiling and generates a target product.
As more platforms provide applet running environments, applets of the same function may be deployed in different forms on different platforms. For example, applet 1 is launched in a stand-alone applet on platform a, whose corresponding function may be required as a stand-alone applet subcontracted to platform B; for another example, applet plug-in 1 of platform a may need to be accessed as a separate applet to platform B in a subcontracting; for another example, applet plug-in 1 of platform A may be required as applet plug-in for platform C; for another example, applet plug-in 1 of platform A may need to be a stand-alone applet for either platform D or E. If the same function maintains the same set of source codes, the same function is put on different platforms, so that consistent use experience can be maintained, and meanwhile, the difficulty of iteration and maintenance is reduced, and the development cost is reduced. Thus creating the following requirements: the same item (namely the same applet item) is generated into products put on different platforms, and the same item is the applet item created for the same function. Referring to fig. 1, a process of an applet is schematically shown to control the generation of products with different forms for the same item, so as to be capable of being launched on a corresponding platform, including: source code 101, a compiler or open framework 102 containing a compiler, target products 103 in the form of separate applets, target products 104 in the form of separate applets, and target products 105 in the form of applet plug-ins. The source code refers to a source code file package which is developed by a developer aiming at the same project and used for realizing the function of the target applet, and comprises one or more source code files. And compiling the source code according to the compiling type specified by the developer and the corresponding compiling configuration to generate a corresponding target product. When the compiling type is an independent applet, obtaining a target product in the form of the independent applet; when the compiling types are respectively the applets, target products in the form of the applets are respectively obtained, namely target subcontracting; and when the compiling type is the applet plug-in, obtaining a target product in the form of the applet plug-in, namely the target plug-in.
It should be noted that the above disclosed information is only used to aid in understanding the present application, and is not meant to constitute prior art known to those of ordinary skill in the art.
It should be understood that the method provided in the embodiments of the present application may be suitable for processing any applet code written in a programming language, and for convenience of description, the method provided in the present application is exemplified by an applet written in JavaScript.
As a possible implementation manner, the method provided by the embodiment of the application can be applied to a compiler and also can be applied to a development framework integrated with the compiler; the execution subject of the method may be a device configured as the compiler or the development framework, the device may be a medium storing or executing related execution code, or may be a physical device integrating or installing related execution code of the compiler or the development framework, such as a computer, or the like.
The following describes an applet processing method provided in the first embodiment of the present application with reference to fig. 2 and 3. The applet processing method shown in fig. 2 includes:
step S201, obtaining a source code of a target product to be generated; the target product is used for realizing a target applet function;
Step S202, taking the applet form corresponding to the source code as a source form, taking the applet form corresponding to the target product as a target form, and determining a form difference between the source form and the target form;
and step S203, performing adaptive compiling on the source code based on the morphological difference to generate the target product.
In practical application, the applet is one of independent applet, applet package and applet plug-in. Often, a developer generates an applet item according to a predetermined applet form, and writes source code (also called a source program); and taking the predetermined applet form as the applet form corresponding to the source code. In step S201, the source code is a code file of an applet written by a developer according to a certain high-level programming language, typically in a text format, and especially a file for implementing a business logic function of the target applet. The target product is compiled aiming at the source code, and can be provided to a host of a corresponding platform so as to realize the function of a target applet. The obtaining the source code of the target product to be generated comprises the following steps: and acquiring a code warehouse access authority corresponding to a developer, determining a specific applet item to be compiled into a target product to provide a target applet function, and acquiring a code of the specific applet item as the source code.
In this embodiment, the developer may trigger the compiler or the development framework to compile the source code through a command line, and this embodiment is exemplified by the development framework. The development framework provides a compiling command, the compiling command input by a developer can specify a compiling type, and the development framework obtains the entry configuration files corresponding to different applet forms through the compiling type to compile. Specifically, the adaptively compiling the source code based on the morphological difference to generate the target product includes: responding to a compiling command triggered by a developer to execute a designated compiling type, and uploading an entry configuration file corresponding to the target form from the source code; wherein the compilation type is specified based on the target modality, and the portal configuration file includes the specified compilation type.
For example, a parameter compileType of the compiling command may be: miniprogram, plugin or subsubackage; miniprogram means compiled in a separate applet, with an entry profile of app.json; the plugin is compiled in a plug-in mode, and the inlet configuration file is plugin. Json; the sub-bpackage is compiled in a packetized manner, and the entry configuration file is sub-bpackage. For another example, the applet sub-package. Json configuration example:
Figure BDA0004081106250000091
In this configuration example, the type field is used to identify that the packet is "sub-packet" or "main", and when the packet is a sub-packet, the target packet (i.e. the target product) obtained by compiling is automatically sent to the sub-packets field of the app. Json file; and the "main" type of subcontracting is automatically incorporated into the pages field of the app.json file, i.e., into the main package. The root field is used to determine the root directory when the target product is incorporated into the host applet. The information in the Pages field resolves to the actual path of the compiled subpacket. The subcontracting field in the app.json of the independent applet may be either subpackges or subpackges. The development framework of the embodiment provides the configuration specification of the independent applet app. Json and the configuration specification of the applet plug in. Json, and the entry configuration files corresponding to different compiling types can be loaded from source code catalogues specified by srcPath and srcpathis, and can also be obtained according to the customized path configuration.
In step S202, the applet form corresponding to the source code is a source form, and the applet form corresponding to the target product is a target form. The applet processing method provided by the embodiment is particularly suitable for scenes with morphological differences between source morphology and target morphology. Preferably, the source modality includes one of the following applet modalities: independent applet, applet plug-in, applet sub-package; the target modality is an applet modality that is different from the source modality. The form difference refers to the difference of the running modes of the applets in three different forms of independent applets, applet packages and applet plug-ins and the difference generated after the source code of one applet form is converted into other applet forms. The method has the advantages that the source codes can be compiled into target products with other forms different from the source forms by a compiler or a development framework for executing the applet processing method aiming at different form differences, the form conversion among different applet forms is realized, the source forms can be understood as applet forms before the form conversion, and the target forms can be understood as applet forms after the form conversion. Moreover, the same set of source codes can be compiled into target products with different forms on the premise of fewer service code modifications, so that the capability of integrating the applet forms is provided. The applet form integration capability means that the same project is supported in an isomorphic mode to be put on different platforms in different applet forms (such as independent applets, applet plug-ins and applet sub-packages), namely, the same set of source codes are maintained in an iterative mode, and the source codes are compiled into target products in different forms according to the putting requirement.
In this embodiment, differences between different forms of the applet include, but are not limited to: differences related to application instances of applet global, differences related to applet global styles, differences related to NPM (package management of JavaScript) component library.
The differences related to the application instance of the applet global include: differences related to application instance invocation, including differences in different forms for invoking applet application instances, i.e., getApp differences in different forms; and, differences related to application instance lifecycle, including differences in application instance lifecycle for applets in different forms, i.e., app lifecycle differences in different forms. The application instance lifecycle of the applet includes processes of applet initialization (onLaunch), call-out (onShow), cut-to-background (onHide), etc. Wherein, the getApp differences of different applet forms are: the independent applet can call getApp () to acquire the attribute or method of the global App instance and the instance mount; the applet plug-in cannot call getApp (); the applet package can call the getApp () to obtain the global App instance and the attribute or method mounted on the instance, but when the source form is that the target product converted by the independent applet is the applet package, the originally called getApp () of the package will be invalid and replaced by the getApp () of the corresponding host applet of the target product. App lifecycle differences for different applet morphologies are: app application execution onLaunch, onShow, onHide of the independent applet and other life cycles; in contrast, neither the applet plug-in nor applet package has an application lifecycle.
The differences related to the applet global style are: the independent applet may declare a global style in a common style file (e.g., app. Wxss or app. Acss); and the small program plug-in and the small program package have no global patterns. The compatibility of global styles in different forms can be achieved at compile time by automatically injecting a global style file (app. Acss or app. Wxss, etc.) into the style file of each page and component as a reference.
The differences related to the NPM component library mean that the applet platforms may have different usage restrictions for NPM components of different modalities. According to the bundle mode, the multi-terminal component library specification and the JS dependency library specification of the development framework, independent applets, applet plug-ins and JS dependency of applet sub-packages can be automatically packaged in a unified manner in the compiling process, and the used component library is automatically extracted to a NPM _components folder to avoid dependency problems under different forms and NPM support difference problems of different applet platforms.
Aiming at the differences, a corresponding trowelling mode is provided in the processing method provided by the embodiment, such as injecting a difference trowelling code to simulate the life cycle of an application instance and simulate a getApp; injecting global patterns into each page; and (5) uniformly packaging and avoiding use restrictions aiming at the dependency library. Of course, the difference can be self-compatible in the source code, or different platforms and different forms can be compatible based on file latitude condition compiling or code latitude condition compiling provided by the development framework. Of course, the compatibility difference in the source code and at least part of the difference can be automatically smoothed by the development framework, so that the multi-form integration capability of the applet is realized.
Preferably, the determining the morphology difference between the source morphology and the target morphology includes: scanning a source code catalog and determining a source form corresponding to a source code; and acquiring a compiling type appointed by a developer through compiling options, determining a target form corresponding to the target product, and obtaining the difference between the source form and the target form.
In step S203, the source code is adaptively compiled based on the morphological differences to generate the target product. In the step, the corresponding suitability processing is carried out in the compiling process of the source code based on the analysis of the morphological difference, so that the target products with different morphologies are constructed based on the source code of the same item and are put on corresponding applet platforms, the purpose of supporting the same item to be put on different channels in different morphologies in an isomorphic mode is achieved, and the applet morphology integration capability is provided.
In this step, adaptive compiling is implemented by means of automatic code injection during compiling for the first differences included in the morphological differences. Specifically, the adaptively compiling the source code based on the morphological difference to generate the target product includes: in response to the morphology differences including a first difference, injecting code data for adapting the target morphology for the source code according to the first difference, generating the target product based on the injection; wherein the first difference comprises a difference between the source modality and the target modality that is related to an application instance of an applet global. I.e. the first differences comprise the differences given above in relation to the application instance of the applet global, e.g. specifically the getApp differences and App lifecycle differences. In practice, when the source modality is plug-in or subcontracting and the target modality is independent applet, the developer can add independent applet related code, which can be achieved by modifying the configuration file of the independent applet to declare plug-in or add subcontracting related configuration. When the source form is an independent applet, the target form is an applet plug-in or an applet packet, the trowelling thought is as follows: the difference of the getApp call and the App life cycle under different forms is smoothed by injecting codes in the compiling process. Specifically, the source code form includes a first global logic code, a first page code and/or a first component code before conversion; correspondingly, the injecting code data for adapting the target morphology into the source code according to the first difference, generating the target product based on the injecting, includes: injecting application instance difference trowelling codes for simulating application instance lifecycle and simulating application instance call aiming at the source codes; modifying the first global logic code based on the application instance difference trowelling code to obtain a second global logic code after morphological conversion; modifying the first page code and/or the first component code based on the application instance difference trowelling code to obtain a second page code and/or a second component code after morphological transformation; obtaining modified codes corresponding to the source codes according to the application instance difference trowelling codes, the second global logic codes, the second page codes and/or the second component codes; and compiling the modified code to obtain the target product.
The modifying the first global logic code based on the application instance difference trowelling code to obtain a second global logic code after morphological transformation includes: adding codes in the first global logic code to obtain derived data of the application instance difference trowelling codes; modifying the initialization of the interception applet in the first global logic code into a simulated interception applet initialization method included in the application instance difference trowelling code; the simulation monitoring applet initializing method is a method executed by the initialization life cycle in the life cycle of the simulation application instance; the second global logic code is derived based on the modification. The modifying the first page code and/or the first component code based on the application instance difference trowelling code to obtain a second page code and/or a second component code after morphological transformation includes: adding code in the first page code and/or first component code that references the second global logic code and adds export data for obtaining the application instance difference screeding code; and injecting a simulation application instance calling method included in the application instance difference trowelling code into the first page code and/or the first component code to obtain a second page code and/or a second component code after morphological conversion. The derived data of the application instance difference trowelling code refers to data derived from the application instance difference trowelling code and used by other modules, such as a method for deriving a variable in the application instance difference trowelling code by using export and a value of an internal variable contained in the variable, and the derived data can be used in other references (for example, references by a request or an import mode) of a file and/or a module of the application instance difference trowelling code. The code for obtaining the derived data of the application instance difference screeding code may be a code referencing the application instance difference screeding code by a request or an import manner. Preferably, the application instance difference trowelling code includes: code for exporting a simulated application instance invocation method; code for implementing the simulated application instance invocation method; the simulation application instance calling method realizes data isolation and sharing based on the closure and the prototype chain; an initialization method for exporting the simulated listening applet; code for implementing the simulated listening applet initialization method. The above process can be understood as: the first difference trowelling is achieved by adding the support of app.js entry files in the form of applet plug-ins and applet packages, and simulating App lifecycle calls and injecting the getApp method for each page and component.
For example, the source code in the form of an independent applet is compiled into the target product in the form of an applet package or applet plug-in, the form conversion is performed, the app.js comparison before and after the conversion, the package and the page comparison of the plug-in are shown in table 1 and table 2, and the onLaunch lifecycle call and the getApp call of the simulated App in the injected sub-bpackage.global.js file are shown in table 3.
Table 1 comparison of app.js files before and after conversion of independent applets into applet packages or plug-ins
Figure BDA0004081106250000121
/>
Figure BDA0004081106250000131
TABLE 2 comparison of page. Js files before and after conversion of independent applet into applet package or plug-in
Figure BDA0004081106250000132
TABLE 3 conversion of independent applet into applet package or plug-in injection of a sub-bpackage. Global. Js file
Figure BDA0004081106250000133
It should be understood that this example is merely exemplary, and that the codes in the table are exemplary code differences, not all injected codes and differences, nor are the applet processing methods limited. In tables 1 and 2, other file export methods and data are obtained through a request () function, and the path transmitted to the request () is a relative path; in table 3, the onLaunch lifecycle method implemented by simulation is derived through modules, init, and sub-bpackage, global js, and other lifecycle methods such as onLoad, onShow, onError may be implemented as needed. Of course, similar difference trowelling functions may also be implemented with other coding languages/other functions/other coding specifications, and the like. The closure is a function capable of reading internal variables of other functions, for example, an internal function fun2 of a function fun1, and when the internal function fun2 is referred to by a variable outside the function fun1, a closure is created. A prototype chain is an attribute and method that uses built-in attributes of a prototype to make a reference type inherit the attributes of another reference type. By prototype, we mean a prototype object, which is the object pointed to by the prototype of the build function of which the built-in attribute __ proto __ (pointer) points to.
In this embodiment, as in step S203, the source code may be adaptively compiled according to the second difference. The adaptively compiling the source code based on the morphological difference to generate the target product includes: responding to the morphological difference comprising a second difference, injecting a global style file in the source code into the first page code and/or the first component code to obtain a second page code and/or a second component code after morphological conversion, obtaining a modified code corresponding to the source code according to the second page code and/or the second component code, and compiling the modified code to obtain the target product; wherein the second difference comprises: when the source modality is an independent applet, the target modality is an applet plug-in or applet package, the source modality and the target modality are different relative to an applet global style. Preferably, the injecting the global style file in the source code into the first page code and/or the first component code includes: at the beginning of the code file of the first page code and/or the first component code, adding an import statement to the global style file.
For example three, table 4 below shows a comparison of style files for a page and component that have been converted from an independent applet to a applet package or plug-in conversion injection global style.
TABLE 4 comparison of style files before and after conversion of independent applets into applet packages or plug-ins
Figure BDA0004081106250000141
It should be understood that the tables provided by examples in this embodiment are only for better understanding of exemplary code data given in this embodiment, and are not limited to file names, variable names, function names, method calls, and the like.
In this embodiment, the development framework automatically injects the global style into the top of each page and component style file, so as to realize compatibility of the global style in different forms.
In this embodiment, in step S203, the source code may be adaptively compiled according to the third difference. The adaptively compiling the source code based on the morphological difference to generate the target product includes: responding to the morphological difference comprising a third difference, based on a preset specification to be complied with for generating the target product, uniformly packaging JS dependencies of each morphological product of independent applets, applet plug-ins and applet sub-packages in the compiling process for generating the target product, and extracting a component library dependent on the target product to a specific component dependency folder; wherein the third difference comprises a difference between the source modality and the target modality that is related to a library of NPM components. The preset specification to be complied with for generating the target product includes at least one of a directory structure specification, a multi-terminal component library specification and a JS-dependent library specification. The directory structure specification specifies the directory structure of the target product, including but not limited to directory partitioning, directory naming principles, and the like. The multi-terminal component library specification specifies that the component library to be included is adapted to component specifications of different platforms for compiling target products for different applet platforms. The JS dependency library specification specifies that the JS modularized dependency processing mode is compatible with different platforms. The method for uniformly packaging JS dependencies of each form product of independent applet, applet plug-in and applet package in the compiling process of generating the target product, and extracting the component library of the target product dependency to a specific component dependency folder comprises the following steps: and performing dependency analysis based on the inlet configuration, performing component compiling and JS (namely JavaScript) compiling according to the result of the dependency analysis, grouping the components after compiling, performing component extraction according to the component grouping result, respectively merging and packaging the applet sub-packages or independent applets according to a target form, replacing the referenced components with corresponding components under the target form, and outputting the target product. Thus, the problem of dependence under different forms is avoided, and the problem of difference of different applet platforms on NPM support is avoided. Referring to fig. 3, a schematic diagram of an applet compiling process is shown, including: portal configuration, dependency analysis, component compilation and JS compilation, dynamic grouping, component extraction, merging and packaging, reference replacement and product output; wherein the pointing is stepwise according to the arrow shown. Portal configuration may be implemented by configuring a portal configuration file, such as generating or editing a portal configuration file; the dependency analysis comprises determining the reference relation of JavaScript files, only the used files are required to be packed into target products, and single file dependency analysis, nested dependency analysis, cyclic dependency analysis and the like can be performed; and compiling the components according to the result of the dependency analysis and JS (namely JavaScript), grouping the components after compiling, extracting the components according to the grouping result of the components, merging and packaging, replacing the referenced components with the corresponding components in the target form, and outputting the target product.
Preferably, the morphological difference may include one or more of the first difference, the second difference, and the third difference, and the adaptively compiling the source code based on the morphological difference includes: and respectively carrying out corresponding suitability compiling aiming at each difference included in the morphological differences.
In this embodiment, the method further includes performing relevant configuration for morphological transformation. In one embodiment, the source modality is an independent applet and the target modality is an applet package; that is, the independent applet is converted into applet package, and the applet processing method further comprises the following steps: responding to a subcontracting configuration file creation command input by a developer, and generating a subcontracting configuration file under the root directory of the applet item corresponding to the source code, wherein the subcontracting configuration file is an entry configuration file corresponding to the applet subcontracting in a target form; adding a specific page identifier which is input by a developer and is to be compiled into a target sub-packet to page configuration information included in the sub-packet configuration file, wherein the specific page identifier corresponds to a specific page code included in the source code, and a page path of the specific page corresponding to the specific page identifier is formed by the sub-packet identifier of the target sub-packet and a path thereof; acquiring sub-package compiling configuration of the target sub-package, and adding the sub-package compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; correspondingly, the generating the target product based on the injection comprises: compiling the specific page code into the target subcontracting according to the subcontracting compiling configuration included in the entry configuration file and the configuration file of the development framework or the compiler; the target sub-package is the target product, and the folders corresponding to the target product can provide the function of the target applet after being stored in the corresponding hosts. The application instance obtained by executing the application instance calling method in the running process of the target applet realized based on the target product is a mixed product of a corresponding host and the target package; the attributes and methods of the host can be obtained through the host variables of the application instance.
For example, as follows, the development framework is required to provide configuration capability for converting independent applets into applet packages, which can be command lines or interactive interfaces. Other examples above have been designated as packetization by compileType parameter, then the entry profile name defaults to sub-package. In this example, a sub-page is created in the applet project root directory, and the pages to be compiled into sub-packets are added to this file as follows,
Figure BDA0004081106250000161
further, adding information of subcontracting compilation configuration in a specific configuration file of a development framework, such as a config. Js file,
Figure BDA0004081106250000162
and after the configuration is finished, corresponding sub-package compiling can be executed, the target sub-package is obtained after the compiling is finished, and the folder of the corresponding target sub-package is put into a corresponding host for providing the function of the target applet. The App obtained through getApp call in applet form is a mixed product of a host and a package, and the attribute and method of the host can be obtained through the App $ host attribute. If the sub-package depends at least in part on the global style, the app.acss is injected into the style of each page and component as a reference. If the packetized service needs to use the npm package provided by the host, the corresponding packet name may be added to the externals in the configuration example, and may be normally referred to in the item. Of course, separate js files can be abstracted, and different platforms can be supported through conditional compilation of file or source code latitude. The development framework compilation time may also introduce an initialization file at the top of the JS file for each page and component to ensure subcontracting initialization.
In one embodiment, the source modality is an independent applet and the target modality is an applet plug-in; i.e. the individual applet is converted into an applet plug-in, the applet processing method further comprises: responding to a plug-in configuration file creation command input by a developer, generating a plug-in configuration file under the root directory of the applet item corresponding to the source code, wherein the plug-in configuration file is an entry configuration file corresponding to the applet plug-in target form; if the global configuration file of the source code comprises sub-package configuration, adding page information of the sub-package configuration in the global configuration file to the page information of the plug-in configuration file, wherein a page path of the added page information consists of a corresponding sub-package identifier and a path of the sub-package; if the target plug-in obtained by compiling the source code comprises an open page, adding information of the open page to an open page variable in the plug-in configuration file; obtaining plug-in compiling configuration of the target plug-in, and adding the plug-in compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; the plug-in compiling configuration at least comprises: designating the compiling type as a plug-in; responding to the compiling command, performing injection on the source code according to a first difference between the source form and the target form to obtain a corresponding modified code, and compiling the modified code into the target plugin according to the plugin configuration file and the plugin compiling configuration; wherein the target insert is the target product. Further, the target plug-in is implemented to output the attribute and the method to the outside by calling the parent class of the application instance calling method in the page logic file of the applet item.
For example five, the development framework is required to provide configuration capabilities, either command lines or interactive interfaces, for configuration related to the conversion of individual applets into applet plug-ins. Other examples above have been designated as plug-ins by compileType parameter, then the entry profile name defaults to plugin. In this example, a plugin. Json file is created in the applet project root directory, and the pages to be compiled and converted into plugins are added in this file as follows,
Figure BDA0004081106250000171
the method comprises the steps that a page in a sub-package is added to pages of a plugin. Json, a page path is composed of a sub-package name and a path, and the plugin needs to add a page which is open to the outside to the corresponding publicPages; further comprising adding plug-in compilation configurations to the configuration file of the development framework as follows,
Figure BDA0004081106250000181
after the configuration is completed, corresponding plug-in compiling can be executed, and after the compiling is completed, debugging can be carried out in a corresponding applet developer tool. The plug-in can output the capability in an index. Js file, and the host accesses the capability of the plug-in output through getApp () $plug in. Instance, [ plug-in name ], when using the plug-in to run. The index. Js is configured as follows,
Figure BDA0004081106250000182
an app.js or other logical file call plug-in may also be configured in this example. The hosting method may be injected into the plug-in after the hosting access plug-in SDK. In one embodiment, the source modality is a applet plug-in; the target form is small program subpackage; i.e. the applet plug-in is converted into applet packages, the applet processing method further comprises: responding to a subcontracting configuration file creation command input by a developer, and generating a subcontracting configuration file under the root directory of the applet item corresponding to the source code, wherein the subcontracting configuration file is an entry configuration file corresponding to the applet subcontracting in a target form; converting information of a plug-in configuration file included in the source code into a sub-package configuration, and adding the sub-package configuration file; acquiring sub-package compiling configuration, and adding the sub-package compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; and in response to the compiling command, compiling the source code into the target product according to the subcontracting configuration file and the subcontracting compiling configuration.
For example, the development framework is required to provide configuration capability for converting the applet plug-in into applet packages, which can be a command line or an interactive interface. Creating a sub package file in the project root directory, converting the plugin/json of the plugin into sub package configuration, and adding the sub package compiling configuration in the development framework configuration file. The configuration content and format are similar to those in example four. After the configuration is completed, corresponding sub-package compiling can be executed, and after the compiling is completed, the folders corresponding to the target products are placed in the corresponding hosts. The configuration concept of converting applet packages into applet plug-ins is similar to converting applet plug-ins into applet packages.
The configuration mode in this embodiment may be a command line or interface interactive configuration, and is not limited. Version information and tool dependencies of the development framework need to be determined before configuration can take place.
The method provided by the embodiment can be applied to the mutual compiling conversion among independent applets, applet plug-ins and applet sub-packages, and comprises the following steps: the independent applet is converted into applet package or applet plug-in; the applet plug-in is converted into an independent applet or applet package; the applet package is converted into a separate applet or applet plug-in. The above configuration examples four to six provide four configuration ideas for converting the independent applet into applet packages or plug-ins and converting the applet plug-ins and applet packages into each other. Further, the present embodiment further includes a process for converting the applet plug-in or applet package into an independent applet, and specifically, the method further includes: the source form is an applet plug-in or applet package; the target form is an independent applet; performing adaptive compiling on the source code based on the morphological difference to generate the target product, including: acquiring an applet global configuration file written by a developer; receiving a specific configuration file modification of a developer aiming at a development framework, so that the specific configuration file contains compiling configuration information for compiling and generating independent applets, wherein the compiling configuration information contains compiling types which are independent applets; and compiling the source code according to the written global configuration file of the small program and the specific configuration file to obtain the target product. For example, in a scenario where applet plug-ins or applet packages are converted into separate applets, a development framework obtains an app.json configuration file (i.e., an applet global configuration file) written by a developer, receives modification or new addition related configuration information (modification of a config.js file, new addition or modification results in compiling configuration information for compiling the separate applet) and designates a compileType in the compiling configuration information as a miniprogram, thereby compiling source code into a corresponding target product. Because the development framework provides at least partial difference trowelling capability among different forms, the source codes of the same item can be compiled into target products with different forms (namely different applet forms), or the source codes of the same item can be compiled into target products with different forms by combining a small amount of source code adaptation, and the target products with different forms can be put in corresponding channels, so that different form conversion is supported in an isomorphic mode, applet form integration capability is provided, and iteration maintenance difficulty and cost are reduced.
It should be noted that, in the case of no conflict, the features shown in the present embodiment and other embodiments of the present application may be combined with each other, and the various flows described above may reorder, add or delete steps, for example, steps S201 and S202 or similar terms do not limit that the steps must be performed sequentially. The present disclosure is not limited herein so long as the desired results of the presently disclosed technology are achieved.
Thus, the method provided by the embodiment is described, the method provides at least partial difference trowelling capability between different forms, the source code of the same item is compiled into target products with different forms (i.e. different applet forms), and the target products with different forms can be put in corresponding channels, so that different form conversion is supported in a isomorphic manner, applet form integration capability is provided, and iteration maintenance difficulty and cost are reduced.
Corresponding to the first embodiment, the second embodiment of the present application provides an applet processing device, and the relevant parts only need to refer to the description of the corresponding method embodiments. Referring to fig. four, the applet processing apparatus shown in the figure includes:
a source code obtaining unit 401, configured to obtain a source code of a target product to be generated; the target product is used for realizing a target applet function;
A morphology difference unit 402, configured to determine a morphology difference between the source morphology and the target morphology by using an applet morphology corresponding to the source code as a source morphology and an applet morphology corresponding to the target product as a target morphology;
and the compiling unit 403 is configured to adaptively compile the source code based on the morphological difference, and generate the target product.
Optionally, the source modality includes one of the following applet modalities: independent applet, applet plug-in, applet sub-package; the target modality is an applet modality that is different from the source modality.
Optionally, the compiling unit 403 is specifically configured to: in response to the morphology differences including a first difference, injecting code data for adapting the target morphology for the source code according to the first difference, generating the target product based on the injection; wherein the first difference comprises a difference between the source modality and the target modality that is related to an application instance of an applet global.
Optionally, the source modality is a stand-alone applet; the target form is an applet plug-in or applet package; the source code form comprises a first global logic code, a first page code and/or a first component code before conversion; the compiling unit 403 is specifically configured to: injecting application instance difference trowelling codes for simulating application instance lifecycle and simulating application instance call aiming at the source codes; modifying the first global logic code based on the application instance difference trowelling code to obtain a second global logic code after morphological conversion; modifying the first page code and/or the first component code based on the application instance difference trowelling code to obtain a second page code and/or a second component code after morphological transformation; obtaining modified codes corresponding to the source codes according to the application instance difference trowelling codes, the second global logic codes, the second page codes and/or the second component codes; and compiling the modified code to obtain the target product.
Optionally, the compiling unit 403 is specifically configured to: adding codes in the first global logic code to obtain derived data of the application instance difference trowelling codes; modifying the initialization of the interception applet in the first global logic code into a simulated interception applet initialization method included in the application instance difference trowelling code; the simulation monitoring applet initializing method is a method executed by the initialization life cycle in the life cycle of the simulation application instance; the second global logic code is derived based on the modification.
Optionally, the compiling unit 403 is specifically configured to: adding code in the first page code and/or first component code that references the second global logic code and adds export data for obtaining the application instance difference screeding code; and injecting a simulation application instance calling method included in the application instance difference trowelling code into the first page code and/or the first component code to obtain a second page code and/or a second component code after morphological conversion.
Optionally, the application instance difference trowelling code includes: code for exporting a simulated application instance invocation method; code for implementing the simulated application instance invocation method; the simulation application instance calling method realizes data isolation and sharing based on the closure and the prototype chain; an initialization method for exporting the simulated listening applet; code for implementing the simulated listening applet initialization method.
Optionally, the compiling unit 403 is specifically configured to: the source code form comprises a first page code and/or a first component code before conversion; responding to the morphological difference comprising a second difference, injecting a global style file in the source code into the first page code and/or the first component code to obtain a second page code and/or a second component code after morphological conversion, obtaining a modified code corresponding to the source code according to the second page code and/or the second component code, and compiling the modified code to obtain the target product; wherein the second difference comprises: when the source modality is an independent applet, the target modality is an applet plug-in or applet package, the source modality and the target modality are different relative to an applet global style.
Optionally, the compiling unit 403 is specifically configured to: at the beginning of the code file of the first page code and/or the first component code, adding an import statement to the global style file.
Optionally, the compiling unit 403 is specifically configured to: judging whether the morphological difference comprises a third difference, if so, based on a preset specification to be complied with for generating the target product, uniformly packaging JS dependencies of each morphological product of independent applet, applet plug-in package and applet package in the compiling process for generating the target product, and extracting a component library dependent on the target product to a specific component dependency folder; wherein the third difference comprises a difference between the source modality and the target modality that is related to a library of NPM components.
Optionally, the compiling unit 403 is specifically configured to: and performing dependency analysis based on the inlet configuration, performing component compiling and JS compiling according to the result of the dependency analysis, performing component grouping after compiling, performing component extraction according to the component grouping result, respectively merging and packaging the applet sub-packages or independent applets according to a target form, replacing the referenced component with a corresponding component under the target form, and outputting the target product.
Optionally, the preset specification to be complied with for generating the target product includes at least one of a directory structure specification, a multi-terminal component library specification and a JS-dependent library specification.
Optionally, the compiling unit 403 is specifically configured to: responding to a compiling command triggered by a developer to execute a designated compiling type, and uploading an entry configuration file corresponding to the target form from the source code; wherein the compilation type is specified based on the target modality, and the portal configuration file includes the specified compilation type.
Optionally, the source form is an independent applet, and the target form is an applet package; the compiling unit 403 is specifically configured to: responding to a subcontracting configuration file creation command input by a developer, and generating a subcontracting configuration file under the root directory of the applet item corresponding to the source code, wherein the subcontracting configuration file is an entry configuration file corresponding to the applet subcontracting in a target form; adding a specific page identifier which is input by a developer and is to be compiled into a target sub-packet to page configuration information included in the sub-packet configuration file, wherein the specific page identifier corresponds to a specific page code included in the source code, and a page path of the specific page corresponding to the specific page identifier is formed by the sub-packet identifier of the target sub-packet and a path thereof; acquiring sub-package compiling configuration of the target sub-package, and adding the sub-package compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; compiling the specific page code into the target subcontracting according to the subcontracting compiling configuration included in the entry configuration file and the configuration file of the development framework or the compiler; the target sub-package is the target product, and the folders corresponding to the target product can provide the function of the target applet after being stored in the corresponding hosts.
Optionally, the device further includes an operation unit, where the operation unit is configured to: the application instance obtained by executing the application instance calling method when the target applet realized based on the target product runs is a mixed product of the corresponding host and the target package; the attributes and methods of the host can be obtained through the host variables of the application instance.
Optionally, the source form is an independent applet, and the target form is an applet plug-in; the compiling unit is further configured to: responding to a plug-in configuration file creation command input by a developer, generating a plug-in configuration file under the root directory of the applet item corresponding to the source code, wherein the plug-in configuration file is an entry configuration file corresponding to the applet plug-in target form; if the global configuration file of the source code comprises sub-package configuration, adding page information of the sub-package configuration in the global configuration file to the page information of the plug-in configuration file, wherein a page path of the added page information consists of a corresponding sub-package identifier and a path of the sub-package; if the target plug-in obtained by compiling the source code comprises an open page, adding information of the open page to an open page variable in the plug-in configuration file; obtaining plug-in compiling configuration of the target plug-in, and adding the plug-in compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; the plug-in compiling configuration at least comprises: designating the compiling type as a plug-in; responding to the compiling command, performing injection on the source code according to a first difference between the source form and the target form to obtain a corresponding modified code, and compiling the modified code into the target plugin according to the plugin configuration file and the plugin compiling configuration; wherein the target insert is the target product.
Optionally, the running unit is further configured to: and the external output attribute and the method of the target plug-in are realized in the page logic file of the applet item by calling the parent class of the application instance calling method.
Optionally, the source form is a applet plug-in; the target form is small program subpackage; the compiling unit 403 is further configured to: responding to a subcontracting configuration file creation command input by a developer, and generating a subcontracting configuration file under the root directory of the applet item corresponding to the source code, wherein the subcontracting configuration file is an entry configuration file corresponding to the applet subcontracting in a target form; converting information of a plug-in configuration file included in the source code into a sub-package configuration, and adding the sub-package configuration file; acquiring sub-package compiling configuration, and adding the sub-package compiling configuration to a development framework or a configuration file of a compiler applying the applet processing method; and in response to the compiling command, compiling the source code into the target product according to the subcontracting configuration file and the subcontracting compiling configuration.
Optionally, the source form is a small program plug-in or a small program package; the target form is an independent applet; the compiling unit 403 is further configured to: acquiring an applet global configuration file written by a developer; receiving a specific configuration file modification of a developer aiming at a development framework, so that the specific configuration file contains compiling configuration information for compiling and generating independent applets, wherein the compiling configuration information contains compiling types which are independent applets; and compiling the source code according to the written global configuration file of the small program and the specific configuration file to obtain the target product.
Based on the foregoing embodiments, a third embodiment of the present application provides an electronic device, and relevant portions may be referred to the corresponding descriptions of the foregoing embodiments. Referring to fig. 5, the electronic device shown in the figure includes: a memory 501 and a processor 502; the memory is used for storing a computer program, and the computer program is executed by the processor to execute the method provided by the embodiment of the application.
Based on the foregoing embodiments, a fourth embodiment of the present application provides a computer storage medium, and relevant portions may be referred to the corresponding descriptions of the foregoing embodiments. The schematic diagram of the computer storage medium is similar to fig. 5, where the memory can be understood as the storage medium. The computer storage medium stores computer-executable instructions that, when executed by a processor, are configured to implement the methods provided by embodiments of the present application.
In one typical configuration, the electronic device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory. The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
While the preferred embodiment has been described, it is not intended to limit the invention thereto, and any person skilled in the art may make variations and modifications without departing from the spirit and scope of the present invention, so that the scope of the present invention shall be defined by the claims of the present application.

Claims (10)

1. A method of applet processing, comprising:
acquiring a source code of a target product to be generated; the target product is used for realizing a target applet function;
taking the applet form corresponding to the source code as a source form, taking the applet form corresponding to the target product as a target form, and determining a form difference between the source form and the target form;
And performing adaptive compiling on the source code based on the morphological difference to generate the target product.
2. The method of claim 1, wherein the source modality comprises one of the following applet modalities: independent applet, applet plug-in, applet sub-package; the target modality is an applet modality that is different from the source modality.
3. The method of claim 1, wherein adaptively compiling the source code based on the morphological differences to generate the target product comprises:
in response to the morphology differences including a first difference, injecting code data for adapting the target morphology for the source code according to the first difference, generating the target product based on the injection; wherein the first difference comprises a difference between the source modality and the target modality that is related to an application instance of an applet global.
4. The method of claim 3, wherein the source modality is a stand-alone applet; the target form is an applet plug-in or applet package;
the source code form comprises a first global logic code, a first page code and/or a first component code before conversion;
The injecting code data for adapting the target modality for the source code according to the first difference, generating the target product based on the injecting, comprises:
injecting application instance difference trowelling codes for simulating application instance lifecycle and simulating application instance call aiming at the source codes;
modifying the first global logic code based on the application instance difference trowelling code to obtain a second global logic code after morphological conversion;
modifying the first page code and/or the first component code based on the application instance difference trowelling code to obtain a second page code and/or a second component code after morphological transformation;
obtaining modified codes corresponding to the source codes according to the application instance difference trowelling codes, the second global logic codes, the second page codes and/or the second component codes;
and compiling the modified code to obtain the target product.
5. The method of claim 4, wherein modifying the first global logic code based on the application instance difference trowelling code to obtain a morphed transformed second global logic code comprises:
adding codes in the first global logic code to obtain derived data of the application instance difference trowelling codes;
Modifying the initialization of the interception applet in the first global logic code into a simulated interception applet initialization method included in the application instance difference trowelling code; the simulation monitoring applet initializing method is a method executed by the initialization life cycle in the life cycle of the simulation application instance;
the second global logic code is derived based on the modification.
6. The method of claim 5, wherein modifying the first page code and/or first component code based on the application instance difference trowelling code results in morphed second page code and/or second component code, comprising:
adding code in the first page code and/or first component code that references the second global logic code and adds export data for obtaining the application instance difference screeding code;
and injecting a simulation application instance calling method included in the application instance difference trowelling code into the first page code and/or the first component code to obtain a second page code and/or a second component code after morphological conversion.
7. The method of claim 6, wherein the application instance difference screeding code comprises:
Code for exporting a simulated application instance invocation method;
code for implementing the simulated application instance invocation method; the simulation application instance calling method realizes data isolation and sharing based on the closure and the prototype chain;
an initialization method for exporting the simulated listening applet;
code for implementing the simulated listening applet initialization method.
8. The method of claim 1, wherein adaptively compiling the source code based on the morphological differences to generate the target product comprises:
the source code form comprises a first page code and/or a first component code before conversion;
responding to the morphological difference comprising a second difference, injecting a global style file in the source code into the first page code and/or the first component code to obtain a second page code and/or a second component code after morphological conversion, obtaining a modified code corresponding to the source code according to the second page code and/or the second component code, and compiling the modified code to obtain the target product;
wherein the second difference comprises: when the source modality is an independent applet, the target modality is an applet plug-in or applet package, the source modality and the target modality are different relative to an applet global style.
9. The method according to claim 8, wherein the injecting the global style file in the source code into the first page code and/or first component code comprises:
at the beginning of the code file of the first page code and/or the first component code, adding an import statement to the global style file.
10. The method of claim 1, wherein adaptively compiling the source code based on the morphological differences to generate the target product comprises:
responding to the morphological difference comprising a third difference, based on a preset specification to be complied with for generating the target product, uniformly packaging JS dependencies of each morphological product of independent applets, applet plug-ins and applet sub-packages in the compiling process for generating the target product, and extracting a component library dependent on the target product to a specific component dependency folder;
wherein the third difference comprises a difference between the source modality and the target modality that is related to a library of NPM components.
CN202310123330.9A 2023-02-15 2023-02-15 Applet processing method and device and electronic equipment Pending CN116243923A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310123330.9A CN116243923A (en) 2023-02-15 2023-02-15 Applet processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310123330.9A CN116243923A (en) 2023-02-15 2023-02-15 Applet processing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN116243923A true CN116243923A (en) 2023-06-09

Family

ID=86630782

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310123330.9A Pending CN116243923A (en) 2023-02-15 2023-02-15 Applet processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN116243923A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116954571A (en) * 2023-09-21 2023-10-27 深圳凡泰极客科技有限责任公司 Development processing method and device for applet plug-in and computer readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116954571A (en) * 2023-09-21 2023-10-27 深圳凡泰极客科技有限责任公司 Development processing method and device for applet plug-in and computer readable storage medium
CN116954571B (en) * 2023-09-21 2023-12-22 深圳凡泰极客科技有限责任公司 Development processing method and device for applet plug-in and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN109976761B (en) Software development kit generation method and device and terminal equipment
Gamblin et al. The Spack package manager: bringing order to HPC software chaos
US10146515B1 (en) Live code updates
US8707263B2 (en) Using a DSL for calling APIS to test software
US9965259B2 (en) System for translating diverse programming languages
US10452369B2 (en) Code profiling of executable library for pipeline parallelization
CN112835584B (en) Method for realizing component expansion and management based on REACTNATIVE
CN111078229A (en) Application processing method and device, storage medium and electronic equipment
CN113407362A (en) SOMEIP communication intermediate layer implementation method and system based on SOA architecture of vehicle-mounted Android system
CN111985055A (en) Model packaging method and device and electronic equipment
CN111506314A (en) Project development method, device, server and medium
CN111290740B (en) Application program development method and device, computer equipment and storage medium
CN114588638A (en) Method for developing game based on Lua language and program development device
CN116243923A (en) Applet processing method and device and electronic equipment
CN112306539B (en) Development method, system, terminal and medium for SCM application layer
Chakravarthy et al. Edicts: implementing features with flexible binding times
CN103150161A (en) Task encapsulation method and device based on MapReduce computation module
CN110659022B (en) Method for automatically calling Python script based on Java
CN115390846A (en) Compiling construction method and device, electronic equipment and storage medium
CN115098158A (en) SDK packaging method and device, computer equipment and storage medium
CN109542447A (en) A kind of OTX program file execution method and device
Golemon Extending and Embedding PHP
CN111708543A (en) Method for reducing repetition degree of Android project codes
US7861233B2 (en) Transparent context switching for software code
CN113535566B (en) Android application verification method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination