build(deps): bump lodash, grunt-legacy-log and grunt-legacy-util (#312)
Bumps lodash, grunt-legacy-log and grunt-legacy-util. These dependencies needed to be updated together.
Updates
lodashfrom 4.17.23 to 4.18.1Updates
grunt-legacy-logfrom 3.0.0 to 3.0.1Updates
grunt-legacy-utilfrom 2.0.1 to 2.0.2
updated-dependencies:
- dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect
- dependency-name: grunt-legacy-log dependency-version: 3.0.1 dependency-type: indirect
- dependency-name: grunt-legacy-util dependency-version: 2.0.2 dependency-type: indirect …
Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
cordova-js
A unified JavaScript layer for Apache Cordova projects.
Project Structure
How It Works
The
build-tools/build.jsprocess is a Node.js script that concatenates all of the core Cordova plugins in this repository into acordova.<platform>.jsfile under thepkg/folder. It also wraps the plugins with a RequireJS-compatible module syntax that works in both browser and node environments. We end up with acordova.jsfile that wraps each Cordova plugin into its own module.Cordova defines a
channelmodule undersrc/common/channel.js, which is a publish/subscribe implementation that the project uses for event management.The Cordova native-to-webview bridge is initialized in
src/scripts/bootstrap.js. This file attaches thebootfunction to thechannel.onNativeReadyevent - fired by native with a call to:The
bootmethod does all the work. First, it grabs the common platform definition (undersrc/common/common.js) and injects all of the objects defined there ontowindowand other global namespaces. Next, it grabs all of the platform-specific object definitions (as defined undersrc/<platform>/platform.js) and overrides those ontowindow.Finally, it calls the platform-specific
initializefunction (located in the platform definition). At this point, Cordova is fully initialized and ready to roll. Last thing we do is wait for theDOMContentLoadedevent to fire to make sure the page has loaded properly. Once that is done, Cordova fires thedevicereadyevent where you can safely attach functions that consume the Cordova APIs.Testing
Tests run in a bundled headless Chromium instance. They can be run with:
Final testing should always be done with the Mobile Spec test application.
Creating a New Platform
In your platform repository:
Create the
cordova-js-srcdirectory.Write a module that encapsulates your platform’s
execmethod and call itexec.js. This file should be added into the<platform-repo>/cordova-js-srcdirectory which was created from step 1.The
execmethod is a JavaScript function that enables communication from the platform’s JavaScript environment into the platform’s native environment. Each platform uses a different mechanism to enable this bridge. We recommend you check out the other platformexecdefinitions for inspiration.The
execmethod has the following method signature:function(success, fail, service, action, args)Methods Arguments:
success: a success function callbackfail: a failure function callbackservice: a string identifier that the platform can resolve to a native classaction: a string identifier that the platform can resolve to a specific method inside the class pointed to byserviceargs: an array of parameters to pass to the native method invoked by theexeccallIt is required that new platform additions be as consistent as possible with the existing
serviceandactionlabels.Define your platform definition object and name it
platform.js. This file should be added into the<platform-repo>/cordova-js-srcdirectory which was created from step 1.This file should export an object with the following properties:
id: a string representing the platform. This should match the name of the.jsfile.bootstrap: A function that sets up the platform. Must fire theonNativeReadychannel when done.initialize: an optional function that is called after the global scope setup is done (i.e. Cordova and all plugins are ready)The following is a simple example of a platform definition:
Bundle the modules from
cordova-js/srcand<platform-repo>/cordova-js-srcinto a file that ends up in<platform-project>/platform_www/cordova.js. This can be done in various ways. The following is recommended:cordova-jsas adevDependency:npm i -D cordova-jscordova.jswhen preparing your platform’s npm package. You can do that by adding the NPMpreparehook script to yourpackage.json:cordova.jsfile created by thepreparescript ends up where your platform expects it