new version

This commit is contained in:
silas
2021-12-12 18:51:24 +01:00
parent 7ff899a7fd
commit a032d1eded
18 changed files with 102964 additions and 1 deletions

90
dist/cordova-js-src/confighelper.js vendored Normal file
View File

@@ -0,0 +1,90 @@
/*
*
* 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 config;
function Config(xhr) {
function loadPreferences(xhr) {
var parser = new DOMParser();
var doc = parser.parseFromString(xhr.responseText, "application/xml");
var preferences = doc.getElementsByTagName("preference");
return Array.prototype.slice.call(preferences);
}
this.xhr = xhr;
this.preferences = loadPreferences(this.xhr);
}
function readConfig(success, error) {
var xhr;
if(typeof config != 'undefined') {
success(config);
}
function fail(msg) {
console.error(msg);
if(error) {
error(msg);
}
}
var xhrStatusChangeHandler = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200 || xhr.status == 304 || xhr.status === 0 /* file:// */) {
config = new Config(xhr);
success(config);
}
else {
fail('[Browser][cordova.js][xhrStatusChangeHandler] Could not XHR config.xml: ' + xhr.statusText);
}
}
};
xhr = new XMLHttpRequest();
xhr.addEventListener("load", xhrStatusChangeHandler);
try {
xhr.open("get", "config.xml", true);
xhr.send();
} catch(e) {
fail('[Browser][cordova.js][readConfig] Could not XHR config.xml: ' + JSON.stringify(e));
}
}
/**
* Reads a preference value from config.xml.
* Returns preference value or undefined if it does not exist.
* @param {String} preferenceName Preference name to read */
Config.prototype.getPreferenceValue = function getPreferenceValue(preferenceName) {
var preferenceItem = this.preferences && this.preferences.filter(function(item) {
return item.attributes.name && item.attributes.name.value === preferenceName;
});
if(preferenceItem && preferenceItem[0] && preferenceItem[0].attributes && preferenceItem[0].attributes.value) {
return preferenceItem[0].attributes.value.value;
}
};
exports.readConfig = readConfig;

114
dist/cordova-js-src/exec.js vendored Normal file
View File

@@ -0,0 +1,114 @@
/*
*
* 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);
args = args || [];
if (proxy) {
var callbackId = service + cordova.callbackId++;
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 }
var 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
});
};
var 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
// note: status can be 0
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 {
console.log("Error: exec proxy not found for :: " + service + " :: " + action);
if(typeof fail === "function" ) {
fail("Missing Command Error");
}
}
};

46
dist/cordova-js-src/platform.js vendored Normal file
View File

@@ -0,0 +1,46 @@
/*
*
* 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: 'browser',
cordovaVersion: '4.2.0', // cordova-js
bootstrap: function() {
var modulemapper = require('cordova/modulemapper');
var channel = require('cordova/channel');
modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
channel.onNativeReady.fire();
document.addEventListener("visibilitychange", function(){
if(document.hidden) {
channel.onPause.fire();
}
else {
channel.onResume.fire();
}
});
// End of bootstrap
}
};