You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/05/19 01:21:02 UTC
[4/8] js commit: CB-8441 grunt compile now uses platform dependencies
cordova-js-src for platform specific exec files
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/osx/platform.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/osx/platform.js b/src/legacy-exec/osx/platform.js
new file mode 100644
index 0000000..c74c2be
--- /dev/null
+++ b/src/legacy-exec/osx/platform.js
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+module.exports = {
+ id: "osx",
+ initialize:function() {
+ }
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/osx/plugin/osx/.gitignore
----------------------------------------------------------------------
diff --git a/src/legacy-exec/osx/plugin/osx/.gitignore b/src/legacy-exec/osx/plugin/osx/.gitignore
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/ubuntu/exec.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/ubuntu/exec.js b/src/legacy-exec/ubuntu/exec.js
new file mode 100644
index 0000000..1c3e04c
--- /dev/null
+++ b/src/legacy-exec/ubuntu/exec.js
@@ -0,0 +1,85 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var cordova = require('cordova'),
+ utils = require('cordova/utils');
+
+var callbackId = 1;
+cordova.callbacks = [];
+
+cordova.callback = function() {
+ var scId = arguments[0];
+ var callbackRef = null;
+
+ var parameters = [];
+ for (var i = 1; i < arguments.length; i++) {
+ parameters[i-1] = arguments[i];
+ }
+ callbackRef = cordova.callbacks[scId];
+
+ // Even IDs are success-, odd are error-callbacks - make sure we remove both
+ if ((scId % 2) !== 0) {
+ scId = scId - 1;
+ }
+ // Remove both the success as well as the error callback from the stack
+ delete cordova.callbacks[scId];
+ delete cordova.callbacks[scId + 1];
+
+ if (typeof callbackRef == "function") callbackRef.apply(this, parameters);
+};
+
+cordova.callbackWithoutRemove = function() {
+ var scId = arguments[0];
+ var callbackRef = null;
+
+ var parameters = [];
+ for (var i = 1; i < arguments.length; i++) {
+ parameters[i-1] = arguments[i];
+ }
+ callbackRef = cordova.callbacks[scId];
+
+ if (typeof(callbackRef) == "function") callbackRef.apply(this, parameters);
+};
+
+var _initialized = false;
+function ubuntuExec(success, fail, service, action, args) {
+ if (callbackId % 2) {
+ callbackId++;
+ }
+
+ var scId = callbackId++;
+ var ecId = callbackId++;
+ cordova.callbacks[scId] = success;
+ cordova.callbacks[ecId] = fail;
+
+ args.unshift(ecId);
+ args.unshift(scId);
+
+ if (!_initialized) {
+ _initialized = true;
+ window.oxide.addMessageHandler("EXECUTE", function (msg) {
+ eval(msg.args.code);
+ });
+ }
+
+ window.oxide.sendMessage("from-cordova", {messageType: "callPluginFunction", plugin: service, func: action, params: args});
+}
+module.exports = ubuntuExec;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/ubuntu/platform.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/ubuntu/platform.js b/src/legacy-exec/ubuntu/platform.js
new file mode 100644
index 0000000..cf792a2
--- /dev/null
+++ b/src/legacy-exec/ubuntu/platform.js
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+module.exports = {
+ id: "ubuntu",
+ bootstrap: function() {
+ var channel = require("cordova/channel"),
+ cordova = require('cordova'),
+ exec = require('cordova/exec'),
+ modulemapper = require('cordova/modulemapper');
+
+ modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
+ require('cordova/channel').onNativeReady.fire();
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/webos/exec.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/webos/exec.js b/src/legacy-exec/webos/exec.js
new file mode 100644
index 0000000..2a0e0d8
--- /dev/null
+++ b/src/legacy-exec/webos/exec.js
@@ -0,0 +1,35 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var execProxy = require('cordova/exec/proxy');
+
+module.exports = function(success, fail, service, action, args) {
+ var proxy = execProxy.get(service,action);
+ if(proxy) {
+ try {
+ proxy(success, fail, args);
+ } catch(e) {
+ console.log("Exception calling exec with command :: " + service + " :: " + action + " ::exception=" + e);
+ }
+ } else {
+ fail && fail("Missing Command Error");
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/webos/platform.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/webos/platform.js b/src/legacy-exec/webos/platform.js
new file mode 100644
index 0000000..965a6ad
--- /dev/null
+++ b/src/legacy-exec/webos/platform.js
@@ -0,0 +1,86 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+module.exports = {
+ id: 'webos',
+ bootstrap: function() {
+ var channel = require('cordova/channel');
+ var isLegacy = ((navigator.userAgent.indexOf("webOS")>-1) || (navigator.userAgent.indexOf("hpwOS")>-1));
+ var webOSjsLib = (window.webOS!==undefined);
+ if(!webOSjsLib && window.PalmSystem && window.PalmSystem.stageReady && isLegacy) {
+ window.PalmSystem.stageReady();
+ }
+
+ // create global legacy Mojo object if it does not exist
+ window.Mojo = window.Mojo || {};
+
+ // Check for support for page visibility api
+ if(typeof document.webkitHidden !== "undefined") {
+ document.addEventListener("webkitvisibilitychange", function(e) {
+ if(document.webkitHidden) {
+ channel.onPause.fire();
+ } else {
+ channel.onResume.fire();
+ }
+ });
+ } else { //backward compatability with webOS devices that don't support Page Visibility API
+ // LunaSysMgr calls this when the windows is maximized or opened.
+ window.Mojo.stageActivated = function() {
+ channel.onResume.fire();
+ };
+ // LunaSysMgr calls this when the windows is minimized or closed.
+ window.Mojo.stageDeactivated = function() {
+ channel.onPause.fire();
+ };
+ }
+
+ if(isLegacy && !webOSjsLib) {
+ var lp = JSON.parse(PalmSystem.launchParams || "{}") || {};
+ window.cordova.fireDocumentEvent("webOSLaunch", {type:"webOSLaunch", detail:lp});
+ // LunaSysMgr calls this whenever an app is "launched;"
+ window.Mojo.relaunch = function(e) {
+ var lp = JSON.parse(PalmSystem.launchParams || "{}") || {};
+ if(lp['palm-command'] && lp['palm-command'] == 'open-app-menu') {
+ window.cordova.fireDocumentEvent("menubutton");
+ return true;
+ } else {
+ window.cordova.fireDocumentEvent("webOSRelaunch", {type:"webOSRelaunch", detail:lp});
+ }
+ };
+ }
+ document.addEventListener("keydown", function(e) {
+ // back gesture/button varies by version and build
+ if(e.keyCode == 27 || e.keyIdentifier == "U+1200001" ||
+ e.keyIdentifier == "U+001B" || e.keyIdentifier == "Back") {
+ window.cordova.fireDocumentEvent("backbutton", e);
+ }
+ });
+ // SmartTV webOS uses HTML5 History API, so bind to that
+ // Leave freedom upto developers to enforce History states as they please
+ // rather than enforcing particular states
+ window.addEventListener("popstate", function(e) {
+ window.cordova.fireDocumentEvent("backbutton", e);
+ });
+
+ require('cordova/modulemapper').clobbers('cordova/webos/service', 'navigator.service');
+ channel.onNativeReady.fire();
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/webos/webos/service.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/webos/webos/service.js b/src/legacy-exec/webos/webos/service.js
new file mode 100644
index 0000000..0e4b111
--- /dev/null
+++ b/src/legacy-exec/webos/webos/service.js
@@ -0,0 +1,118 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var isLegacy = ((navigator.userAgent.indexOf("webOS")>-1) || (navigator.userAgent.indexOf("hpwOS")>-1));
+
+function LS2Request(uri, params) {
+ this.uri = uri;
+ params = params || {};
+ if(params.method) {
+ if(this.uri.charAt(this.uri.length-1) != "/") {
+ this.uri += "/";
+ }
+ this.uri += params.method;
+ }
+ if(typeof params.onSuccess === 'function') {
+ this.onSuccess = params.onSuccess;
+ }
+ if(typeof params.onFailure === 'function') {
+ this.onFailure = params.onFailure;
+ }
+ if(typeof params.onComplete === 'function') {
+ this.onComplete = params.onComplete;
+ }
+ this.params = (typeof params.parameters === 'object') ? params.parameters : {};
+ this.subscribe = params.subscribe || false;
+ if(this.subscribe) {
+ this.params.subscribe = params.subscribe;
+ }
+ if(this.params.subscribe) {
+ this.subscribe = this.params.subscribe;
+ }
+ this.resubscribe = params.resubscribe || false;
+ this.send();
+}
+
+LS2Request.prototype.send = function() {
+ if(!window.PalmServiceBridge) {
+ console.error("PalmServiceBridge not found.");
+ return;
+ }
+ this.bridge = new PalmServiceBridge();
+ var self = this;
+ this.bridge.onservicecallback = this.callback = function(msg) {
+ var parsedMsg;
+ if(self.cancelled) {
+ return;
+ }
+ try {
+ parsedMsg = JSON.parse(msg);
+ } catch(e) {
+ parsedMsg = {
+ errorCode: -1,
+ errorText: msg
+ };
+ }
+ if((parsedMsg.errorCode || parsedMsg.returnValue===false) && self.onFailure) {
+ self.onFailure(parsedMsg);
+ if(self.resubscribe && self.subscribe) {
+ self.delayID = setTimeout(function() {
+ self.send();
+ }, LS2Request.resubscribeDelay);
+ }
+ } else if(self.onSuccess) {
+ self.onSuccess(parsedMsg);
+ }
+ if(self.onComplete) {
+ self.onComplete(parsedMsg);
+ }
+ if(!self.subscribe) {
+ self.cancel();
+ }
+ };
+ this.bridge.call(this.uri, JSON.stringify(this.params));
+};
+
+LS2Request.prototype.cancel = function() {
+ this.cancelled = true;
+ if(this.resubscribeJob) {
+ clearTimeout(this.delayID);
+ }
+ if(this.bridge) {
+ this.bridge.cancel();
+ this.bridge = undefined;
+ }
+};
+
+LS2Request.prototype.toString = function() {
+ return "[LS2Request]";
+};
+
+LS2Request.resubscribeDelay = 10000;
+
+module.exports = {
+ request: function (uri, params) {
+ var req = new LS2Request(uri, params);
+ return req;
+ },
+ systemPrefix: ((isLegacy) ? "com.palm." : "com.webos."),
+ protocol: "luna://"
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/windows/exec.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/windows/exec.js b/src/legacy-exec/windows/exec.js
new file mode 100644
index 0000000..18f559a
--- /dev/null
+++ b/src/legacy-exec/windows/exec.js
@@ -0,0 +1,111 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+/*jslint sloppy:true, plusplus:true*/
+/*global require, module, console */
+
+var cordova = require('cordova');
+var execProxy = require('cordova/exec/proxy');
+
+/**
+ * Execute a cordova command. It is up to the native side whether this action
+ * is synchronous or asynchronous. The native side can return:
+ * Synchronous: PluginResult object as a JSON string
+ * Asynchronous: Empty string ""
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
+ * depending upon the result of the action.
+ *
+ * @param {Function} success The success callback
+ * @param {Function} fail The fail callback
+ * @param {String} service The name of the service to use
+ * @param {String} action Action to be run in cordova
+ * @param {String[]} [args] Zero or more arguments to pass to the method
+ */
+module.exports = function (success, fail, service, action, args) {
+
+ var proxy = execProxy.get(service, action),
+ callbackId,
+ onSuccess,
+ onError;
+
+ args = args || [];
+
+ if (proxy) {
+ callbackId = service + cordova.callbackId++;
+ // console.log("EXEC:" + service + " : " + action);
+ if (typeof success === "function" || typeof fail === "function") {
+ cordova.callbacks[callbackId] = {success: success, fail: fail};
+ }
+ try {
+ // callbackOptions param represents additional optional parameters command could pass back, like keepCallback or
+ // custom callbackId, for example {callbackId: id, keepCallback: true, status: cordova.callbackStatus.JSON_EXCEPTION }
+ // CB-5806 [Windows8] Add keepCallback support to proxy
+ onSuccess = function (result, callbackOptions) {
+ callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ // covering both undefined and null.
+ // strict null comparison was causing callbackStatus to be undefined
+ // and then no callback was called because of the check in cordova.callbackFromNative
+ // see CB-8996 Mobilespec app hang on windows
+ if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
+ callbackStatus = callbackOptions.status;
+ }
+ else {
+ callbackStatus = cordova.callbackStatus.OK;
+ }
+ cordova.callbackSuccess(callbackOptions.callbackId || callbackId,
+ {
+ status: callbackStatus,
+ message: result,
+ keepCallback: callbackOptions.keepCallback || false
+ });
+ };
+ onError = function (err, callbackOptions) {
+ callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ // covering both undefined and null.
+ // strict null comparison was causing callbackStatus to be undefined
+ // and then no callback was called because of the check in cordova.callbackFromNative
+ // see CB-8996 Mobilespec app hang on windows
+ if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
+ callbackStatus = callbackOptions.status;
+ }
+ else {
+ callbackStatus = cordova.callbackStatus.OK;
+ }
+ cordova.callbackError(callbackOptions.callbackId || callbackId,
+ {
+ status: callbackStatus,
+ message: err,
+ keepCallback: callbackOptions.keepCallback || false
+ });
+ };
+ proxy(onSuccess, onError, args);
+
+ } catch (e) {
+ console.log("Exception calling native with command :: " + service + " :: " + action + " ::exception=" + e);
+ }
+ } else {
+ if (typeof fail === "function") {
+ fail("Missing Command Error");
+ }
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/windows/platform.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/windows/platform.js b/src/legacy-exec/windows/platform.js
new file mode 100644
index 0000000..defb8fa
--- /dev/null
+++ b/src/legacy-exec/windows/platform.js
@@ -0,0 +1,73 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+module.exports = {
+ // for backward compatibility we report 'windows8' when run on Windows 8.0 and
+ // 'windows' for Windows 8.1 and Windows Phone 8.1
+ id: (navigator.appVersion.indexOf("MSAppHost/1.0") !== -1) ? 'windows8' : 'windows',
+ bootstrap:function() {
+ var cordova = require('cordova'),
+ exec = require('cordova/exec'),
+ channel = cordova.require('cordova/channel'),
+ modulemapper = require('cordova/modulemapper');
+
+ modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
+ channel.onNativeReady.fire();
+
+ var onWinJSReady = function () {
+ var app = WinJS.Application;
+ var checkpointHandler = function checkpointHandler() {
+ cordova.fireDocumentEvent('pause',null,true);
+ };
+
+ var resumingHandler = function resumingHandler() {
+ cordova.fireDocumentEvent('resume',null,true);
+ };
+
+ app.addEventListener("checkpoint", checkpointHandler);
+ Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
+ app.start();
+ };
+
+ if (!window.WinJS) {
+ var scriptElem = document.createElement("script");
+
+ if (navigator.appVersion.indexOf('MSAppHost/3.0') !== -1) {
+ // Windows 10 UWP
+ scriptElem.src = '/WinJS/js/WinJS.js';
+ } else if (navigator.appVersion.indexOf("Windows Phone 8.1;") !== -1) {
+ // windows phone 8.1 + Mobile IE 11
+ scriptElem.src = "//Microsoft.Phone.WinJS.2.1/js/base.js";
+ } else if (navigator.appVersion.indexOf("MSAppHost/2.0;") !== -1) {
+ // windows 8.1 + IE 11
+ scriptElem.src = "//Microsoft.WinJS.2.0/js/base.js";
+ } else {
+ // windows 8.0 + IE 10
+ scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
+ }
+ scriptElem.addEventListener("load", onWinJSReady);
+ document.head.appendChild(scriptElem);
+ }
+ else {
+ onWinJSReady();
+ }
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/wp8/exec.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/wp8/exec.js b/src/legacy-exec/wp8/exec.js
new file mode 100644
index 0000000..25fcf5c
--- /dev/null
+++ b/src/legacy-exec/wp8/exec.js
@@ -0,0 +1,76 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var cordova = require('cordova'),
+ base64 = require('cordova/base64');
+
+/**
+ * Execute a cordova command. It is up to the native side whether this action
+ * is synchronous or asynchronous. The native side can return:
+ * Synchronous: PluginResult object as a JSON string
+ * Asynchronous: Empty string ""
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
+ * depending upon the result of the action.
+ *
+ * @param {Function} success The success callback
+ * @param {Function} fail The fail callback
+ * @param {String} service The name of the service to use
+ * @param {String} action Action to be run in cordova
+ * @param {String[]} [args] Zero or more arguments to pass to the method
+
+ */
+
+module.exports = function(success, fail, service, action, args) {
+
+ var callbackId = service + cordova.callbackId++;
+ if (typeof success == "function" || typeof fail == "function") {
+ cordova.callbacks[callbackId] = {success:success, fail:fail};
+ }
+ args = args || [];
+ // generate a new command string, ex. DebugConsole/log/DebugConsole23/["wtf dude?"]
+ for(var n = 0; n < args.length; n++)
+ {
+ // special case for ArrayBuffer which could not be stringified out of the box
+ if(typeof ArrayBuffer !== "undefined" && args[n] instanceof ArrayBuffer)
+ {
+ args[n] = base64.fromArrayBuffer(args[n]);
+ }
+
+ if(typeof args[n] !== "string")
+ {
+ args[n] = JSON.stringify(args[n]);
+ }
+ }
+ var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
+ // pass it on to Notify
+ try {
+ if(window.external) {
+ window.external.Notify(command);
+ }
+ else {
+ console.log("window.external not available :: command=" + command);
+ }
+ }
+ catch(e) {
+ console.log("Exception calling native with command :: " + command + " :: exception=" + e);
+ }
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/legacy-exec/wp8/platform.js
----------------------------------------------------------------------
diff --git a/src/legacy-exec/wp8/platform.js b/src/legacy-exec/wp8/platform.js
new file mode 100644
index 0000000..237d4f5
--- /dev/null
+++ b/src/legacy-exec/wp8/platform.js
@@ -0,0 +1,34 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+module.exports = {
+ id: 'windowsphone',
+ bootstrap: function() {
+ var cordova = require('cordova'),
+ exec = require('cordova/exec');
+
+ // 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() {
+ exec(null, null, "CoreEvents", "overridebackbutton", [this.numHandlers == 1]);
+ };
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/osx/exec.js
----------------------------------------------------------------------
diff --git a/src/osx/exec.js b/src/osx/exec.js
deleted file mode 100644
index ff52009..0000000
--- a/src/osx/exec.js
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * Creates a gap bridge used to notify the native code about commands.
-
- * @private
- */
-var cordova = require('cordova'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils'),
- base64 = require('cordova/base64');
-
-
-function massageMessageNativeToJs(message) {
- if (message.CDVType == 'ArrayBuffer') {
- var stringToArrayBuffer = function(str) {
- var ret = new Uint8Array(str.length);
- for (var i = 0; i < str.length; i++) {
- ret[i] = str.charCodeAt(i);
- }
- return ret.buffer;
- };
- var base64ToArrayBuffer = function(b64) {
- return stringToArrayBuffer(atob(b64));
- };
- message = base64ToArrayBuffer(message.data);
- }
- return message;
-}
-
-function convertMessageToArgsNativeToJs(message) {
- var args = [];
- if (!message || !message.hasOwnProperty('CDVType')) {
- args.push(message);
- } else if (message.CDVType == 'MultiPart') {
- message.messages.forEach(function(e) {
- args.push(massageMessageNativeToJs(e));
- });
- } else {
- args.push(massageMessageNativeToJs(message));
- }
- return args;
-}
-
-function massageArgsJsToNative(args) {
- if (!args || utils.typeName(args) != 'Array') {
- return args;
- }
- var ret = [];
- args.forEach(function(arg, i) {
- if (utils.typeName(arg) == 'ArrayBuffer') {
- ret.push({
- 'CDVType': 'ArrayBuffer',
- 'data': base64.fromArrayBuffer(arg)
- });
- } else {
- ret.push(arg);
- }
- });
- return ret;
-}
-
-function OSXExec() {
-
- var successCallback, failCallback, service, action, actionArgs, splitCommand;
- var callbackId = 'INVALID';
-
- successCallback = arguments[0];
- failCallback = arguments[1];
- service = arguments[2];
- action = arguments[3];
- actionArgs = arguments[4];
-
- // Register the callbacks and add the callbackId to the positional
- // arguments if given.
- if (successCallback || failCallback) {
- callbackId = service + cordova.callbackId++;
- cordova.callbacks[callbackId] =
- {success:successCallback, fail:failCallback};
- }
-
- actionArgs = massageArgsJsToNative(actionArgs);
-
- if (window.cordovabridge && window.cordovabridge.exec) {
- window.cordovabridge.exec(callbackId, service, action, actionArgs);
- } else {
- alert('window.cordovabridge binding is missing.');
- }
-}
-
-
-OSXExec.nativeCallback = function(callbackId, status, message, keepCallback) {
- var success = status === 0 || status === 1;
- var args = convertMessageToArgsNativeToJs(message);
- cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
-};
-
-module.exports = OSXExec;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/osx/platform.js
----------------------------------------------------------------------
diff --git a/src/osx/platform.js b/src/osx/platform.js
deleted file mode 100644
index c74c2be..0000000
--- a/src/osx/platform.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- id: "osx",
- initialize:function() {
- }
-};
-
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/osx/plugin/osx/.gitignore
----------------------------------------------------------------------
diff --git a/src/osx/plugin/osx/.gitignore b/src/osx/plugin/osx/.gitignore
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/ubuntu/exec.js
----------------------------------------------------------------------
diff --git a/src/ubuntu/exec.js b/src/ubuntu/exec.js
deleted file mode 100644
index 1c3e04c..0000000
--- a/src/ubuntu/exec.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var cordova = require('cordova'),
- utils = require('cordova/utils');
-
-var callbackId = 1;
-cordova.callbacks = [];
-
-cordova.callback = function() {
- var scId = arguments[0];
- var callbackRef = null;
-
- var parameters = [];
- for (var i = 1; i < arguments.length; i++) {
- parameters[i-1] = arguments[i];
- }
- callbackRef = cordova.callbacks[scId];
-
- // Even IDs are success-, odd are error-callbacks - make sure we remove both
- if ((scId % 2) !== 0) {
- scId = scId - 1;
- }
- // Remove both the success as well as the error callback from the stack
- delete cordova.callbacks[scId];
- delete cordova.callbacks[scId + 1];
-
- if (typeof callbackRef == "function") callbackRef.apply(this, parameters);
-};
-
-cordova.callbackWithoutRemove = function() {
- var scId = arguments[0];
- var callbackRef = null;
-
- var parameters = [];
- for (var i = 1; i < arguments.length; i++) {
- parameters[i-1] = arguments[i];
- }
- callbackRef = cordova.callbacks[scId];
-
- if (typeof(callbackRef) == "function") callbackRef.apply(this, parameters);
-};
-
-var _initialized = false;
-function ubuntuExec(success, fail, service, action, args) {
- if (callbackId % 2) {
- callbackId++;
- }
-
- var scId = callbackId++;
- var ecId = callbackId++;
- cordova.callbacks[scId] = success;
- cordova.callbacks[ecId] = fail;
-
- args.unshift(ecId);
- args.unshift(scId);
-
- if (!_initialized) {
- _initialized = true;
- window.oxide.addMessageHandler("EXECUTE", function (msg) {
- eval(msg.args.code);
- });
- }
-
- window.oxide.sendMessage("from-cordova", {messageType: "callPluginFunction", plugin: service, func: action, params: args});
-}
-module.exports = ubuntuExec;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/ubuntu/platform.js
----------------------------------------------------------------------
diff --git a/src/ubuntu/platform.js b/src/ubuntu/platform.js
deleted file mode 100644
index cf792a2..0000000
--- a/src/ubuntu/platform.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- id: "ubuntu",
- bootstrap: function() {
- var channel = require("cordova/channel"),
- cordova = require('cordova'),
- exec = require('cordova/exec'),
- modulemapper = require('cordova/modulemapper');
-
- modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
- require('cordova/channel').onNativeReady.fire();
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/webos/exec.js
----------------------------------------------------------------------
diff --git a/src/webos/exec.js b/src/webos/exec.js
deleted file mode 100644
index 2a0e0d8..0000000
--- a/src/webos/exec.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var execProxy = require('cordova/exec/proxy');
-
-module.exports = function(success, fail, service, action, args) {
- var proxy = execProxy.get(service,action);
- if(proxy) {
- try {
- proxy(success, fail, args);
- } catch(e) {
- console.log("Exception calling exec with command :: " + service + " :: " + action + " ::exception=" + e);
- }
- } else {
- fail && fail("Missing Command Error");
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/webos/platform.js
----------------------------------------------------------------------
diff --git a/src/webos/platform.js b/src/webos/platform.js
deleted file mode 100644
index 965a6ad..0000000
--- a/src/webos/platform.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- id: 'webos',
- bootstrap: function() {
- var channel = require('cordova/channel');
- var isLegacy = ((navigator.userAgent.indexOf("webOS")>-1) || (navigator.userAgent.indexOf("hpwOS")>-1));
- var webOSjsLib = (window.webOS!==undefined);
- if(!webOSjsLib && window.PalmSystem && window.PalmSystem.stageReady && isLegacy) {
- window.PalmSystem.stageReady();
- }
-
- // create global legacy Mojo object if it does not exist
- window.Mojo = window.Mojo || {};
-
- // Check for support for page visibility api
- if(typeof document.webkitHidden !== "undefined") {
- document.addEventListener("webkitvisibilitychange", function(e) {
- if(document.webkitHidden) {
- channel.onPause.fire();
- } else {
- channel.onResume.fire();
- }
- });
- } else { //backward compatability with webOS devices that don't support Page Visibility API
- // LunaSysMgr calls this when the windows is maximized or opened.
- window.Mojo.stageActivated = function() {
- channel.onResume.fire();
- };
- // LunaSysMgr calls this when the windows is minimized or closed.
- window.Mojo.stageDeactivated = function() {
- channel.onPause.fire();
- };
- }
-
- if(isLegacy && !webOSjsLib) {
- var lp = JSON.parse(PalmSystem.launchParams || "{}") || {};
- window.cordova.fireDocumentEvent("webOSLaunch", {type:"webOSLaunch", detail:lp});
- // LunaSysMgr calls this whenever an app is "launched;"
- window.Mojo.relaunch = function(e) {
- var lp = JSON.parse(PalmSystem.launchParams || "{}") || {};
- if(lp['palm-command'] && lp['palm-command'] == 'open-app-menu') {
- window.cordova.fireDocumentEvent("menubutton");
- return true;
- } else {
- window.cordova.fireDocumentEvent("webOSRelaunch", {type:"webOSRelaunch", detail:lp});
- }
- };
- }
- document.addEventListener("keydown", function(e) {
- // back gesture/button varies by version and build
- if(e.keyCode == 27 || e.keyIdentifier == "U+1200001" ||
- e.keyIdentifier == "U+001B" || e.keyIdentifier == "Back") {
- window.cordova.fireDocumentEvent("backbutton", e);
- }
- });
- // SmartTV webOS uses HTML5 History API, so bind to that
- // Leave freedom upto developers to enforce History states as they please
- // rather than enforcing particular states
- window.addEventListener("popstate", function(e) {
- window.cordova.fireDocumentEvent("backbutton", e);
- });
-
- require('cordova/modulemapper').clobbers('cordova/webos/service', 'navigator.service');
- channel.onNativeReady.fire();
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/webos/webos/service.js
----------------------------------------------------------------------
diff --git a/src/webos/webos/service.js b/src/webos/webos/service.js
deleted file mode 100644
index 0e4b111..0000000
--- a/src/webos/webos/service.js
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var isLegacy = ((navigator.userAgent.indexOf("webOS")>-1) || (navigator.userAgent.indexOf("hpwOS")>-1));
-
-function LS2Request(uri, params) {
- this.uri = uri;
- params = params || {};
- if(params.method) {
- if(this.uri.charAt(this.uri.length-1) != "/") {
- this.uri += "/";
- }
- this.uri += params.method;
- }
- if(typeof params.onSuccess === 'function') {
- this.onSuccess = params.onSuccess;
- }
- if(typeof params.onFailure === 'function') {
- this.onFailure = params.onFailure;
- }
- if(typeof params.onComplete === 'function') {
- this.onComplete = params.onComplete;
- }
- this.params = (typeof params.parameters === 'object') ? params.parameters : {};
- this.subscribe = params.subscribe || false;
- if(this.subscribe) {
- this.params.subscribe = params.subscribe;
- }
- if(this.params.subscribe) {
- this.subscribe = this.params.subscribe;
- }
- this.resubscribe = params.resubscribe || false;
- this.send();
-}
-
-LS2Request.prototype.send = function() {
- if(!window.PalmServiceBridge) {
- console.error("PalmServiceBridge not found.");
- return;
- }
- this.bridge = new PalmServiceBridge();
- var self = this;
- this.bridge.onservicecallback = this.callback = function(msg) {
- var parsedMsg;
- if(self.cancelled) {
- return;
- }
- try {
- parsedMsg = JSON.parse(msg);
- } catch(e) {
- parsedMsg = {
- errorCode: -1,
- errorText: msg
- };
- }
- if((parsedMsg.errorCode || parsedMsg.returnValue===false) && self.onFailure) {
- self.onFailure(parsedMsg);
- if(self.resubscribe && self.subscribe) {
- self.delayID = setTimeout(function() {
- self.send();
- }, LS2Request.resubscribeDelay);
- }
- } else if(self.onSuccess) {
- self.onSuccess(parsedMsg);
- }
- if(self.onComplete) {
- self.onComplete(parsedMsg);
- }
- if(!self.subscribe) {
- self.cancel();
- }
- };
- this.bridge.call(this.uri, JSON.stringify(this.params));
-};
-
-LS2Request.prototype.cancel = function() {
- this.cancelled = true;
- if(this.resubscribeJob) {
- clearTimeout(this.delayID);
- }
- if(this.bridge) {
- this.bridge.cancel();
- this.bridge = undefined;
- }
-};
-
-LS2Request.prototype.toString = function() {
- return "[LS2Request]";
-};
-
-LS2Request.resubscribeDelay = 10000;
-
-module.exports = {
- request: function (uri, params) {
- var req = new LS2Request(uri, params);
- return req;
- },
- systemPrefix: ((isLegacy) ? "com.palm." : "com.webos."),
- protocol: "luna://"
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/windows/exec.js
----------------------------------------------------------------------
diff --git a/src/windows/exec.js b/src/windows/exec.js
deleted file mode 100644
index 18f559a..0000000
--- a/src/windows/exec.js
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/*jslint sloppy:true, plusplus:true*/
-/*global require, module, console */
-
-var cordova = require('cordova');
-var execProxy = require('cordova/exec/proxy');
-
-/**
- * Execute a cordova command. It is up to the native side whether this action
- * is synchronous or asynchronous. The native side can return:
- * Synchronous: PluginResult object as a JSON string
- * Asynchronous: Empty string ""
- * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
- * depending upon the result of the action.
- *
- * @param {Function} success The success callback
- * @param {Function} fail The fail callback
- * @param {String} service The name of the service to use
- * @param {String} action Action to be run in cordova
- * @param {String[]} [args] Zero or more arguments to pass to the method
- */
-module.exports = function (success, fail, service, action, args) {
-
- var proxy = execProxy.get(service, action),
- callbackId,
- onSuccess,
- onError;
-
- args = args || [];
-
- if (proxy) {
- callbackId = service + cordova.callbackId++;
- // console.log("EXEC:" + service + " : " + action);
- if (typeof success === "function" || typeof fail === "function") {
- cordova.callbacks[callbackId] = {success: success, fail: fail};
- }
- try {
- // callbackOptions param represents additional optional parameters command could pass back, like keepCallback or
- // custom callbackId, for example {callbackId: id, keepCallback: true, status: cordova.callbackStatus.JSON_EXCEPTION }
- // CB-5806 [Windows8] Add keepCallback support to proxy
- onSuccess = function (result, callbackOptions) {
- callbackOptions = callbackOptions || {};
- var callbackStatus;
- // covering both undefined and null.
- // strict null comparison was causing callbackStatus to be undefined
- // and then no callback was called because of the check in cordova.callbackFromNative
- // see CB-8996 Mobilespec app hang on windows
- if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
- callbackStatus = callbackOptions.status;
- }
- else {
- callbackStatus = cordova.callbackStatus.OK;
- }
- cordova.callbackSuccess(callbackOptions.callbackId || callbackId,
- {
- status: callbackStatus,
- message: result,
- keepCallback: callbackOptions.keepCallback || false
- });
- };
- onError = function (err, callbackOptions) {
- callbackOptions = callbackOptions || {};
- var callbackStatus;
- // covering both undefined and null.
- // strict null comparison was causing callbackStatus to be undefined
- // and then no callback was called because of the check in cordova.callbackFromNative
- // see CB-8996 Mobilespec app hang on windows
- if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
- callbackStatus = callbackOptions.status;
- }
- else {
- callbackStatus = cordova.callbackStatus.OK;
- }
- cordova.callbackError(callbackOptions.callbackId || callbackId,
- {
- status: callbackStatus,
- message: err,
- keepCallback: callbackOptions.keepCallback || false
- });
- };
- proxy(onSuccess, onError, args);
-
- } catch (e) {
- console.log("Exception calling native with command :: " + service + " :: " + action + " ::exception=" + e);
- }
- } else {
- if (typeof fail === "function") {
- fail("Missing Command Error");
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/windows/platform.js
----------------------------------------------------------------------
diff --git a/src/windows/platform.js b/src/windows/platform.js
deleted file mode 100644
index defb8fa..0000000
--- a/src/windows/platform.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- // for backward compatibility we report 'windows8' when run on Windows 8.0 and
- // 'windows' for Windows 8.1 and Windows Phone 8.1
- id: (navigator.appVersion.indexOf("MSAppHost/1.0") !== -1) ? 'windows8' : 'windows',
- bootstrap:function() {
- var cordova = require('cordova'),
- exec = require('cordova/exec'),
- channel = cordova.require('cordova/channel'),
- modulemapper = require('cordova/modulemapper');
-
- modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
- channel.onNativeReady.fire();
-
- var onWinJSReady = function () {
- var app = WinJS.Application;
- var checkpointHandler = function checkpointHandler() {
- cordova.fireDocumentEvent('pause',null,true);
- };
-
- var resumingHandler = function resumingHandler() {
- cordova.fireDocumentEvent('resume',null,true);
- };
-
- app.addEventListener("checkpoint", checkpointHandler);
- Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
- app.start();
- };
-
- if (!window.WinJS) {
- var scriptElem = document.createElement("script");
-
- if (navigator.appVersion.indexOf('MSAppHost/3.0') !== -1) {
- // Windows 10 UWP
- scriptElem.src = '/WinJS/js/WinJS.js';
- } else if (navigator.appVersion.indexOf("Windows Phone 8.1;") !== -1) {
- // windows phone 8.1 + Mobile IE 11
- scriptElem.src = "//Microsoft.Phone.WinJS.2.1/js/base.js";
- } else if (navigator.appVersion.indexOf("MSAppHost/2.0;") !== -1) {
- // windows 8.1 + IE 11
- scriptElem.src = "//Microsoft.WinJS.2.0/js/base.js";
- } else {
- // windows 8.0 + IE 10
- scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
- }
- scriptElem.addEventListener("load", onWinJSReady);
- document.head.appendChild(scriptElem);
- }
- else {
- onWinJSReady();
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/wp8/exec.js
----------------------------------------------------------------------
diff --git a/src/wp8/exec.js b/src/wp8/exec.js
deleted file mode 100644
index 25fcf5c..0000000
--- a/src/wp8/exec.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var cordova = require('cordova'),
- base64 = require('cordova/base64');
-
-/**
- * Execute a cordova command. It is up to the native side whether this action
- * is synchronous or asynchronous. The native side can return:
- * Synchronous: PluginResult object as a JSON string
- * Asynchronous: Empty string ""
- * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
- * depending upon the result of the action.
- *
- * @param {Function} success The success callback
- * @param {Function} fail The fail callback
- * @param {String} service The name of the service to use
- * @param {String} action Action to be run in cordova
- * @param {String[]} [args] Zero or more arguments to pass to the method
-
- */
-
-module.exports = function(success, fail, service, action, args) {
-
- var callbackId = service + cordova.callbackId++;
- if (typeof success == "function" || typeof fail == "function") {
- cordova.callbacks[callbackId] = {success:success, fail:fail};
- }
- args = args || [];
- // generate a new command string, ex. DebugConsole/log/DebugConsole23/["wtf dude?"]
- for(var n = 0; n < args.length; n++)
- {
- // special case for ArrayBuffer which could not be stringified out of the box
- if(typeof ArrayBuffer !== "undefined" && args[n] instanceof ArrayBuffer)
- {
- args[n] = base64.fromArrayBuffer(args[n]);
- }
-
- if(typeof args[n] !== "string")
- {
- args[n] = JSON.stringify(args[n]);
- }
- }
- var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
- // pass it on to Notify
- try {
- if(window.external) {
- window.external.Notify(command);
- }
- else {
- console.log("window.external not available :: command=" + command);
- }
- }
- catch(e) {
- console.log("Exception calling native with command :: " + command + " :: exception=" + e);
- }
-};
-
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/src/wp8/platform.js
----------------------------------------------------------------------
diff --git a/src/wp8/platform.js b/src/wp8/platform.js
deleted file mode 100644
index 237d4f5..0000000
--- a/src/wp8/platform.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- id: 'windowsphone',
- bootstrap: function() {
- var cordova = require('cordova'),
- exec = require('cordova/exec');
-
- // 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() {
- exec(null, null, "CoreEvents", "overridebackbutton", [this.numHandlers == 1]);
- };
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/994d6bba/tasks/lib/bundle.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle.js b/tasks/lib/bundle.js
index 686fa77..66190a7 100644
--- a/tasks/lib/bundle.js
+++ b/tasks/lib/bundle.js
@@ -28,14 +28,30 @@ module.exports = function bundle(platform, debug, commitId, platformVersion) {
var modules = collectFiles(path.join('src', 'common'));
var scripts = collectFiles(path.join('src', 'scripts'));
modules[''] = path.join('src', 'cordova.js');
- copyProps(modules, collectFiles(path.join('src', platform)));
+
+ var platformDep = path.join('node_modules', 'cordova-'+platform);
+ //check to see if platform dependency has cordova-js-src directory
+ if(fs.existsSync(platformDep) && fs.existsSync(path.join(platformDep, 'cordova-js-src'))) {
+ console.log('using node module platform dependency');
+ copyProps(modules, collectFiles(path.join('node_modules', 'cordova-'+platform, 'cordova-js-src')));
+ } else {
+ if(platform !== 'test') {
+ //for platforms that don't have a release with cordova-js-src yet
+ copyProps(modules, collectFiles(path.join('src', 'legacy-exec', platform)));
+ } else {
+ //platform === test
+ copyProps(modules, collectFiles(path.join('src', platform)));
+ }
+
+ }
+ console.log(modules)
if (platform === 'test') {
// Add any platform-specific modules that have tests to the test bundle.
- var testFilesPath = path.join('src', 'android', 'android');
+ var testFilesPath = path.join('node_modules', 'cordova-android', 'cordova-js-src', 'android');
copyProps(modules, collectFiles(testFilesPath, 'android'));
- modules['android/exec'] = path.join('src', 'android' , 'exec.js');
- modules['ios/exec'] = path.join('src', 'ios' , 'exec.js');
+ modules['android/exec'] = path.join('node_modules', 'cordova-android', 'cordova-js-src', 'exec.js');
+ modules['ios/exec'] = path.join('node_modules', 'cordova-ios', 'cordova-js-src', 'exec.js');
}
var output = [];
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org