You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/07/16 00:08:00 UTC

[1/2] js commit: CB-6976 Add support for Windows Universal apps (Windows 8.1 and WP 8.1)

Repository: cordova-js
Updated Branches:
  refs/heads/master 3f3eb72ae -> bbfeb7305


CB-6976 Add support for Windows Universal apps (Windows 8.1 and WP 8.1)


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/cd084de7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/cd084de7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/cd084de7

Branch: refs/heads/master
Commit: cd084de7fdf514b554a841be83f15579363fce18
Parents: 70cdca3
Author: sgrebnov <v-...@microsoft.com>
Authored: Mon Jul 14 11:50:36 2014 +0400
Committer: sgrebnov <v-...@microsoft.com>
Committed: Mon Jul 14 11:50:36 2014 +0400

----------------------------------------------------------------------
 Gruntfile.js                         |  2 +
 src/windows/exec.js                  | 89 +++++++++++++++++++++++++++++++
 src/windows/platform.js              | 70 ++++++++++++++++++++++++
 src/windows/windows/commandProxy.js  | 23 ++++++++
 src/windows/windows8/commandProxy.js | 23 ++++++++
 5 files changed, 207 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/cd084de7/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 5182572..1c18b63 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -27,6 +27,7 @@ module.exports = function(grunt) {
             "ios": {},
             "osx": {},
             "test": {},
+            "windows": { useWindowsLineEndings: true },
             "windows8": { useWindowsLineEndings: true },
             "windowsphone": { useWindowsLineEndings: true },
             "firefoxos": {},
@@ -40,6 +41,7 @@ module.exports = function(grunt) {
             "ios": {},
             "osx": {},
             //"test": {},
+            "windows": { useWindowsLineEndings: true },
             "windows8": { useWindowsLineEndings: true },
             "windowsphone": { useWindowsLineEndings: true },
             "firefoxos": {},

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/cd084de7/src/windows/exec.js
----------------------------------------------------------------------
diff --git a/src/windows/exec.js b/src/windows/exec.js
new file mode 100644
index 0000000..04a9458
--- /dev/null
+++ b/src/windows/exec.js
@@ -0,0 +1,89 @@
+/*
+ *
+ * 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 || {};
+                cordova.callbackSuccess(callbackOptions.callbackId || callbackId,
+                    {
+                        status: callbackOptions.status || cordova.callbackStatus.OK,
+                        message: result,
+                        keepCallback: callbackOptions.keepCallback || false
+                    });
+            };
+            onError = function (err, callbackOptions) {
+                callbackOptions = callbackOptions || {};
+                cordova.callbackError(callbackOptions.callbackId || callbackId,
+                    {
+                        status: callbackOptions.status || cordova.callbackStatus.ERROR,
+                        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");
+        }
+    }
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/cd084de7/src/windows/platform.js
----------------------------------------------------------------------
diff --git a/src/windows/platform.js b/src/windows/platform.js
new file mode 100644
index 0000000..2807505
--- /dev/null
+++ b/src/windows/platform.js
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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("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/cd084de7/src/windows/windows/commandProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/windows/commandProxy.js b/src/windows/windows/commandProxy.js
new file mode 100644
index 0000000..cbdf720
--- /dev/null
+++ b/src/windows/windows/commandProxy.js
@@ -0,0 +1,23 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+console.log('WARNING: please require cordova/exec/proxy instead');
+module.exports = require('cordova/exec/proxy');

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/cd084de7/src/windows/windows8/commandProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/windows8/commandProxy.js b/src/windows/windows8/commandProxy.js
new file mode 100644
index 0000000..cbdf720
--- /dev/null
+++ b/src/windows/windows8/commandProxy.js
@@ -0,0 +1,23 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+console.log('WARNING: please require cordova/exec/proxy instead');
+module.exports = require('cordova/exec/proxy');


[2/2] js commit: Merge branch 'CB-6976-win-universal-apps' of https://github.com/MSOpenTech/cordova-js

Posted by pu...@apache.org.
Merge branch 'CB-6976-win-universal-apps' of https://github.com/MSOpenTech/cordova-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/bbfeb730
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/bbfeb730
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/bbfeb730

Branch: refs/heads/master
Commit: bbfeb73052f98ab1be3d9b4ebaeb9001c21c05b2
Parents: 3f3eb72 cd084de
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 15 14:47:48 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 15 14:47:48 2014 -0700

----------------------------------------------------------------------
 Gruntfile.js                         |  2 +
 src/windows/exec.js                  | 89 +++++++++++++++++++++++++++++++
 src/windows/platform.js              | 70 ++++++++++++++++++++++++
 src/windows/windows/commandProxy.js  | 23 ++++++++
 src/windows/windows8/commandProxy.js | 23 ++++++++
 5 files changed, 207 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/bbfeb730/Gruntfile.js
----------------------------------------------------------------------