You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/07/30 20:58:14 UTC
[07/13] js commit: [CB-4418] Delete loadMatchingModules() and move
modulemapping call into bootstrap.js (from platform.js)
[CB-4418] Delete loadMatchingModules() and move modulemapping call into bootstrap.js (from platform.js)
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/6e4bd92f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/6e4bd92f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/6e4bd92f
Branch: refs/heads/master
Commit: 6e4bd92f45c02972b3a59cd0f115f31fdda9f2cc
Parents: d82ed34
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 10:32:13 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 10:34:02 2013 -0400
----------------------------------------------------------------------
lib/android/platform.js | 8 +-------
lib/blackberry10/platform.js | 7 +------
lib/common/modulemapper.js | 8 --------
lib/ios/platform.js | 6 ------
lib/osx/platform.js | 6 ------
lib/scripts/bootstrap-android.js | 5 +++++
lib/scripts/bootstrap-windows8.js | 2 ++
lib/scripts/bootstrap.js | 2 ++
lib/test/platform.js | 1 -
lib/windows8/platform.js | 15 +--------------
lib/windowsphone/platform.js | 8 --------
test/test.modulemapper.js | 23 -----------------------
12 files changed, 12 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/android/platform.js
----------------------------------------------------------------------
diff --git a/lib/android/platform.js b/lib/android/platform.js
index 0b2c411..231df7a 100644
--- a/lib/android/platform.js
+++ b/lib/android/platform.js
@@ -24,13 +24,7 @@ module.exports = {
initialize:function() {
var channel = require("cordova/channel"),
cordova = require('cordova'),
- exec = require('cordova/exec'),
- modulemapper = require('cordova/modulemapper');
-
- modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
- modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
-
- modulemapper.mapModules(window);
+ exec = require('cordova/exec');
// Inject a listener for the backbutton on the document.
var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index 007c06e..eb7fd12 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -22,14 +22,9 @@
module.exports = {
id: "blackberry10",
initialize: function() {
- var modulemapper = require('cordova/modulemapper'),
- cordova = require('cordova'),
+ var cordova = require('cordova'),
addDocumentEventListener = document.addEventListener;
- modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
- modulemapper.loadMatchingModules(new RegExp('cordova/blackberry10/.*bbsymbols$'));
- modulemapper.mapModules(window);
-
//override to pass online/offline events to window
document.addEventListener = function (type) {
if (type === "online" || type === "offline") {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/common/modulemapper.js
----------------------------------------------------------------------
diff --git a/lib/common/modulemapper.js b/lib/common/modulemapper.js
index 208fbcb..ea14c2a 100644
--- a/lib/common/modulemapper.js
+++ b/lib/common/modulemapper.js
@@ -111,13 +111,5 @@ exports.getOriginalSymbol = function(context, symbolPath) {
return obj;
};
-exports.loadMatchingModules = function(matchingRegExp) {
- for (var k in moduleMap) {
- if (matchingRegExp.exec(k)) {
- require(k);
- }
- }
-};
-
exports.reset();
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/ios/platform.js
----------------------------------------------------------------------
diff --git a/lib/ios/platform.js b/lib/ios/platform.js
index 83c02cf..7d6216f 100644
--- a/lib/ios/platform.js
+++ b/lib/ios/platform.js
@@ -22,12 +22,6 @@
module.exports = {
id: "ios",
initialize:function() {
- var modulemapper = require('cordova/modulemapper');
-
- modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
- modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
- modulemapper.mapModules(window);
}
};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/osx/platform.js
----------------------------------------------------------------------
diff --git a/lib/osx/platform.js b/lib/osx/platform.js
index be40bf5..c74c2be 100644
--- a/lib/osx/platform.js
+++ b/lib/osx/platform.js
@@ -22,12 +22,6 @@
module.exports = {
id: "osx",
initialize:function() {
- var modulemapper = require('cordova/modulemapper');
-
- modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
- modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
- modulemapper.mapModules(window);
}
};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/scripts/bootstrap-android.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-android.js b/lib/scripts/bootstrap-android.js
index aa1ef0a..6cf1d80 100644
--- a/lib/scripts/bootstrap-android.js
+++ b/lib/scripts/bootstrap-android.js
@@ -19,6 +19,11 @@
*
*/
+// Wire up the "App" plugin.
+// TODO: Extract this as a proper plugin.
+require('cordova/modulemapper').clobbers('cordova/plugin/android/app', 'navigator.app');
// Tell the native code that a page change has occurred.
require('cordova/exec')(null, null, 'PluginManager', 'startup', []);
+// Tell the JS that the native side is ready.
require('cordova/channel').onNativeReady.fire();
+
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/scripts/bootstrap-windows8.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-windows8.js b/lib/scripts/bootstrap-windows8.js
index 91a6f71..5606b36 100644
--- a/lib/scripts/bootstrap-windows8.js
+++ b/lib/scripts/bootstrap-windows8.js
@@ -19,4 +19,6 @@
*
*/
+require('cordova/modulemapper').clobbers('cordova/windows8/commandProxy', 'cordova.commandProxy');
require('cordova/channel').onNativeReady.fire();
+
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 3a2481e..4a8bb87 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -27,6 +27,7 @@
var channel = require('cordova/channel');
var cordova = require('cordova');
+ var modulemapper = require('cordova/modulemapper');
var pluginloader = require('cordova/pluginloader');
var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
@@ -114,6 +115,7 @@
channel.join(function() {
// Call the platform-specific initialization
require('cordova/platform').initialize();
+ modulemapper.mapModules(window);
// Fire event to notify that all objects are created
channel.onCordovaReady.fire();
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/test/platform.js
----------------------------------------------------------------------
diff --git a/lib/test/platform.js b/lib/test/platform.js
index 4315d8a..da71794 100644
--- a/lib/test/platform.js
+++ b/lib/test/platform.js
@@ -21,6 +21,5 @@
module.exports = {
id: "test platform",
- runtime: function () {},
initialize: function () {}
};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/windows8/platform.js
----------------------------------------------------------------------
diff --git a/lib/windows8/platform.js b/lib/windows8/platform.js
index 7e3766f..11dce28 100755
--- a/lib/windows8/platform.js
+++ b/lib/windows8/platform.js
@@ -21,25 +21,12 @@
var cordova = require('cordova'),
exec = require('cordova/exec'),
- channel = cordova.require("cordova/channel"),
- modulemapper = require('cordova/modulemapper');
-
-/*
- * Define native implementations ( there is no native layer, so need to make sure the proxies are there )
- */
-modulemapper.loadMatchingModules(/cordova.*\/windows8\/.*Proxy$/);
+ channel = cordova.require("cordova/channel");
module.exports = {
id: "windows8",
initialize:function() {
- modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
- modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
- modulemapper.clobbers('cordova/windows8/commandProxy', 'cordova.commandProxy');
-
- modulemapper.mapModules(window);
-
var onWinJSReady = function () {
var app = WinJS.Application;
var checkpointHandler = function checkpointHandler() {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/windowsphone/platform.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/platform.js b/lib/windowsphone/platform.js
index 851ef09..c3725dc 100644
--- a/lib/windowsphone/platform.js
+++ b/lib/windowsphone/platform.js
@@ -25,14 +25,6 @@ var cordova = require('cordova'),
module.exports = {
id: "windowsphone",
initialize:function() {
- var modulemapper = require('cordova/modulemapper');
-
- modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
- modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-
- modulemapper.mapModules(window);
-
// Inject a listener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
backButtonChannel.onHasSubscribersChange = function() {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/test/test.modulemapper.js
----------------------------------------------------------------------
diff --git a/test/test.modulemapper.js b/test/test.modulemapper.js
index 726b6eb..d4c2806 100644
--- a/test/test.modulemapper.js
+++ b/test/test.modulemapper.js
@@ -166,29 +166,6 @@ describe('modulemapper', function() {
expect(modulemapper.getOriginalSymbol(context, 'obj')).toBe(context.obj);
expect(modulemapper.getOriginalSymbol(context, 'obj.str')).toBe(context.obj.str);
});
- it('should load modules with loadMatchingModules', function() {
- var spyModules = {};
- this.after(function() {
- Object.keys(spyModules).forEach(define.remove);
- });
- function addModule(name) {
- spyModules[name] = jasmine.createSpy(name);
- define(name, spyModules[name]);
- }
- function expectCalled(names) {
- for (var k in spyModules) {
- expect(spyModules[k].wasCalled).toBe(names.indexOf(k) != -1, 'for module:' + k);
- }
- }
- addModule('foo/a');
- addModule('foo/b');
- addModule('foo/symbols1');
- addModule('foo/symbols');
- addModule('foo/bar/symbols');
- addModule('baz/symbols');
- modulemapper.loadMatchingModules(/^foo.*\/symbols$/);
- expectCalled(['foo/symbols', 'foo/bar/symbols']);
- });
it('should log about deprecated property access', function() {
var origConsoleLog = console.log;
console.log = jasmine.createSpy('console.log');