hcordova 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +204 -0
  2. package/README.md +346 -0
  3. package/bin/hcordova +27 -0
  4. package/package.json +39 -0
  5. package/src/base-cli.js +1181 -0
  6. package/src/utils/DependencyChecker.js +382 -0
  7. package/src/utils/PlatformProject.js +452 -0
  8. package/src/utils/PluginConfigParser.js +408 -0
  9. package/src/utils/PluginDownloader.js +181 -0
  10. package/src/utils/PluginHandler.js +1097 -0
  11. package/src/utils/VariableValidator.js +369 -0
  12. package/src/utils/args-processor.js +79 -0
  13. package/templates/project/AppScope/app.json5 +10 -0
  14. package/templates/project/AppScope/resources/base/element/string.json +8 -0
  15. package/templates/project/AppScope/resources/base/media/background.png +0 -0
  16. package/templates/project/AppScope/resources/base/media/foreground.png +0 -0
  17. package/templates/project/AppScope/resources/base/media/layered_image.json +7 -0
  18. package/templates/project/build-profile.json5 +46 -0
  19. package/templates/project/code-linter.json5 +32 -0
  20. package/templates/project/entry/build-profile.json5 +28 -0
  21. package/templates/project/entry/hvigorfile.ts +6 -0
  22. package/templates/project/entry/obfuscation-rules.txt +23 -0
  23. package/templates/project/entry/oh-package.json5 +12 -0
  24. package/templates/project/entry/src/main/ets/entryability/EntryAbility.ets +62 -0
  25. package/templates/project/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +32 -0
  26. package/templates/project/entry/src/main/ets/pages/Index.ets +40 -0
  27. package/templates/project/entry/src/main/module.json5 +52 -0
  28. package/templates/project/entry/src/main/resources/base/element/color.json +8 -0
  29. package/templates/project/entry/src/main/resources/base/element/float.json +8 -0
  30. package/templates/project/entry/src/main/resources/base/element/string.json +16 -0
  31. package/templates/project/entry/src/main/resources/base/media/background.png +0 -0
  32. package/templates/project/entry/src/main/resources/base/media/foreground.png +0 -0
  33. package/templates/project/entry/src/main/resources/base/media/layered_image.json +7 -0
  34. package/templates/project/entry/src/main/resources/base/media/startIcon.png +0 -0
  35. package/templates/project/entry/src/main/resources/base/profile/backup_config.json +3 -0
  36. package/templates/project/entry/src/main/resources/base/profile/main_pages.json +5 -0
  37. package/templates/project/entry/src/main/resources/dark/element/color.json +8 -0
  38. package/templates/project/entry/src/main/resources/rawfile/config.xml +26 -0
  39. package/templates/project/entry/src/main/resources/rawfile/www/cordova.js +1925 -0
  40. package/templates/project/entry/src/main/resources/rawfile/www/css/index.css +158 -0
  41. package/templates/project/entry/src/main/resources/rawfile/www/img/cordova.png +0 -0
  42. package/templates/project/entry/src/main/resources/rawfile/www/img/logo.png +0 -0
  43. package/templates/project/entry/src/main/resources/rawfile/www/index.html +110 -0
  44. package/templates/project/entry/src/main/resources/rawfile/www/js/index.js +68 -0
  45. package/templates/project/entry/src/mock/mock-config.json5 +2 -0
  46. package/templates/project/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
  47. package/templates/project/entry/src/ohosTest/ets/test/List.test.ets +5 -0
  48. package/templates/project/entry/src/ohosTest/module.json5 +13 -0
  49. package/templates/project/entry/src/test/List.test.ets +5 -0
  50. package/templates/project/entry/src/test/LocalUnit.test.ets +33 -0
  51. package/templates/project/hvigor/hvigor-config.json5 +22 -0
  52. package/templates/project/hvigorfile.ts +6 -0
  53. package/templates/project/local.properties +9 -0
  54. package/templates/project/oh-package-lock.json5 +27 -0
  55. package/templates/project/oh-package.json5 +10 -0
@@ -0,0 +1,1925 @@
1
+ // Platform: cordova-android
2
+ // cordova-js 6.1.0
3
+ /*
4
+ Licensed to the Apache Software Foundation (ASF) under one
5
+ or more contributor license agreements. See the NOTICE file
6
+ distributed with this work for additional information
7
+ regarding copyright ownership. The ASF licenses this file
8
+ to you under the Apache License, Version 2.0 (the
9
+ "License"); you may not use this file except in compliance
10
+ with the License. You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing,
15
+ software distributed under the License is distributed on an
16
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ KIND, either express or implied. See the License for the
18
+ specific language governing permissions and limitations
19
+ under the License.
20
+ */
21
+ ;(function() {
22
+ var PLATFORM_VERSION_BUILD_LABEL = '14.0.1';
23
+ // file: src/scripts/require.js
24
+ var require;
25
+ var define;
26
+
27
+ (function () {
28
+ var modules = {};
29
+ // Stack of moduleIds currently being built.
30
+ var requireStack = [];
31
+ // Map of module ID -> index into requireStack of modules currently being built.
32
+ var inProgressModules = {};
33
+ var SEPARATOR = '.';
34
+
35
+ function build (module) {
36
+ var factory = module.factory;
37
+ var localRequire = function (id) {
38
+ var resultantId = id;
39
+ // Its a relative path, so lop off the last portion and add the id (minus "./")
40
+ if (id.charAt(0) === '.') {
41
+ resultantId = module.id.slice(0, module.id.lastIndexOf(SEPARATOR)) + SEPARATOR + id.slice(2);
42
+ }
43
+ return require(resultantId);
44
+ };
45
+ module.exports = {};
46
+ delete module.factory;
47
+ factory(localRequire, module.exports, module);
48
+ return module.exports;
49
+ }
50
+
51
+ require = function (id) {
52
+ if (!modules[id]) {
53
+ throw new Error('module ' + id + ' not found');
54
+ } else if (id in inProgressModules) {
55
+ var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
56
+ throw new Error('Cycle in require graph: ' + cycle);
57
+ }
58
+ if (modules[id].factory) {
59
+ try {
60
+ inProgressModules[id] = requireStack.length;
61
+ requireStack.push(id);
62
+ return build(modules[id]);
63
+ } finally {
64
+ delete inProgressModules[id];
65
+ requireStack.pop();
66
+ }
67
+ }
68
+ return modules[id].exports;
69
+ };
70
+
71
+ define = function (id, factory) {
72
+ if (Object.prototype.hasOwnProperty.call(modules, id)) {
73
+ throw new Error('module ' + id + ' already defined');
74
+ }
75
+
76
+ modules[id] = {
77
+ id: id,
78
+ factory: factory
79
+ };
80
+ };
81
+
82
+ define.remove = function (id) {
83
+ delete modules[id];
84
+ };
85
+
86
+ define.moduleMap = modules;
87
+ })();
88
+
89
+ // Export for use in node
90
+ if (typeof module === 'object' && typeof require === 'function') {
91
+ module.exports.require = require;
92
+ module.exports.define = define;
93
+ }
94
+
95
+ // file: src/cordova.js
96
+ define("cordova", function(require, exports, module) {
97
+
98
+ // Workaround for Windows 10 in hosted environment case
99
+ // http://www.w3.org/html/wg/drafts/html/master/browsers.html#named-access-on-the-window-object
100
+ if (window.cordova && !(window.cordova instanceof HTMLElement)) {
101
+ throw new Error('cordova already defined');
102
+ }
103
+
104
+ var channel = require('cordova/channel');
105
+ var platform = require('cordova/platform');
106
+
107
+ /**
108
+ * Intercept calls to addEventListener + removeEventListener and handle deviceready,
109
+ * resume, and pause events.
110
+ */
111
+ var m_document_addEventListener = document.addEventListener;
112
+ var m_document_removeEventListener = document.removeEventListener;
113
+ var m_window_addEventListener = window.addEventListener;
114
+ var m_window_removeEventListener = window.removeEventListener;
115
+
116
+ /**
117
+ * Houses custom event handlers to intercept on document + window event listeners.
118
+ */
119
+ var documentEventHandlers = {};
120
+ var windowEventHandlers = {};
121
+
122
+ document.addEventListener = function (evt, handler, capture) {
123
+ var e = evt.toLowerCase();
124
+ if (typeof documentEventHandlers[e] !== 'undefined') {
125
+ documentEventHandlers[e].subscribe(handler);
126
+ } else {
127
+ m_document_addEventListener.call(document, evt, handler, capture);
128
+ }
129
+ };
130
+
131
+ window.addEventListener = function (evt, handler, capture) {
132
+ var e = evt.toLowerCase();
133
+ if (typeof windowEventHandlers[e] !== 'undefined') {
134
+ windowEventHandlers[e].subscribe(handler);
135
+ } else {
136
+ m_window_addEventListener.call(window, evt, handler, capture);
137
+ }
138
+ };
139
+
140
+ document.removeEventListener = function (evt, handler, capture) {
141
+ var e = evt.toLowerCase();
142
+ // If unsubscribing from an event that is handled by a plugin
143
+ if (typeof documentEventHandlers[e] !== 'undefined') {
144
+ documentEventHandlers[e].unsubscribe(handler);
145
+ } else {
146
+ m_document_removeEventListener.call(document, evt, handler, capture);
147
+ }
148
+ };
149
+
150
+ window.removeEventListener = function (evt, handler, capture) {
151
+ var e = evt.toLowerCase();
152
+ // If unsubscribing from an event that is handled by a plugin
153
+ if (typeof windowEventHandlers[e] !== 'undefined') {
154
+ windowEventHandlers[e].unsubscribe(handler);
155
+ } else {
156
+ m_window_removeEventListener.call(window, evt, handler, capture);
157
+ }
158
+ };
159
+
160
+ function createEvent (type, data) {
161
+ var event = document.createEvent('Events');
162
+ event.initEvent(type, false, false);
163
+ if (data) {
164
+ for (var i in data) {
165
+ if (Object.prototype.hasOwnProperty.call(data, i)) {
166
+ event[i] = data[i];
167
+ }
168
+ }
169
+ }
170
+ return event;
171
+ }
172
+
173
+ var cordova = {
174
+ define: define,
175
+ require: require,
176
+ version: PLATFORM_VERSION_BUILD_LABEL,
177
+ platformVersion: PLATFORM_VERSION_BUILD_LABEL,
178
+ platformId: platform.id,
179
+
180
+ /**
181
+ * Methods to add/remove your own addEventListener hijacking on document + window.
182
+ */
183
+ addWindowEventHandler: function (event) {
184
+ return (windowEventHandlers[event] = channel.create(event));
185
+ },
186
+ addStickyDocumentEventHandler: function (event) {
187
+ return (documentEventHandlers[event] = channel.createSticky(event));
188
+ },
189
+ addDocumentEventHandler: function (event) {
190
+ return (documentEventHandlers[event] = channel.create(event));
191
+ },
192
+ removeWindowEventHandler: function (event) {
193
+ delete windowEventHandlers[event];
194
+ },
195
+ removeDocumentEventHandler: function (event) {
196
+ delete documentEventHandlers[event];
197
+ },
198
+
199
+ /**
200
+ * Retrieve original event handlers that were replaced by Cordova
201
+ *
202
+ * @return object
203
+ */
204
+ getOriginalHandlers: function () {
205
+ return {
206
+ document: {
207
+ addEventListener: m_document_addEventListener,
208
+ removeEventListener: m_document_removeEventListener
209
+ },
210
+ window: {
211
+ addEventListener: m_window_addEventListener,
212
+ removeEventListener: m_window_removeEventListener
213
+ }
214
+ };
215
+ },
216
+
217
+ /**
218
+ * Method to fire event from native code
219
+ * bNoDetach is required for events which cause an exception which needs to be caught in native code
220
+ */
221
+ fireDocumentEvent: function (type, data, bNoDetach) {
222
+ var evt = createEvent(type, data);
223
+ if (typeof documentEventHandlers[type] !== 'undefined') {
224
+ if (bNoDetach) {
225
+ documentEventHandlers[type].fire(evt);
226
+ } else {
227
+ setTimeout(function () {
228
+ // Fire deviceready on listeners that were registered before cordova.js was loaded.
229
+ if (type === 'deviceready') {
230
+ document.dispatchEvent(evt);
231
+ }
232
+ documentEventHandlers[type].fire(evt);
233
+ }, 0);
234
+ }
235
+ } else {
236
+ document.dispatchEvent(evt);
237
+ }
238
+ },
239
+
240
+ fireWindowEvent: function (type, data) {
241
+ var evt = createEvent(type, data);
242
+ if (typeof windowEventHandlers[type] !== 'undefined') {
243
+ setTimeout(function () {
244
+ windowEventHandlers[type].fire(evt);
245
+ }, 0);
246
+ } else {
247
+ window.dispatchEvent(evt);
248
+ }
249
+ },
250
+
251
+ /**
252
+ * Plugin callback mechanism.
253
+ */
254
+ // Randomize the starting callbackId to avoid collisions after refreshing or navigating.
255
+ // This way, it's very unlikely that any new callback would get the same callbackId as an old callback.
256
+ callbackId: Math.floor(Math.random() * 2000000000),
257
+ callbacks: {},
258
+ callbackStatus: {
259
+ NO_RESULT: 0,
260
+ OK: 1,
261
+ CLASS_NOT_FOUND_EXCEPTION: 2,
262
+ ILLEGAL_ACCESS_EXCEPTION: 3,
263
+ INSTANTIATION_EXCEPTION: 4,
264
+ MALFORMED_URL_EXCEPTION: 5,
265
+ IO_EXCEPTION: 6,
266
+ INVALID_ACTION: 7,
267
+ JSON_EXCEPTION: 8,
268
+ ERROR: 9
269
+ },
270
+
271
+ /**
272
+ * Called by native code when returning successful result from an action.
273
+ */
274
+ callbackSuccess: function (callbackId, args) {
275
+ cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
276
+ },
277
+
278
+ /**
279
+ * Called by native code when returning error result from an action.
280
+ */
281
+ callbackError: function (callbackId, args) {
282
+ // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
283
+ // Derive success from status.
284
+ cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
285
+ },
286
+
287
+ /**
288
+ * Called by native code when returning the result from an action.
289
+ */
290
+ callbackFromNative: function (callbackId, isSuccess, status, args, keepCallback) {
291
+ try {
292
+ var callback = cordova.callbacks[callbackId];
293
+ if (callback) {
294
+ if (isSuccess && status === cordova.callbackStatus.OK) {
295
+ callback.success && callback.success.apply(null, args);
296
+ } else if (!isSuccess) {
297
+ callback.fail && callback.fail.apply(null, args);
298
+ }
299
+ /*
300
+ else
301
+ Note, this case is intentionally not caught.
302
+ this can happen if isSuccess is true, but callbackStatus is NO_RESULT
303
+ which is used to remove a callback from the list without calling the callbacks
304
+ typically keepCallback is false in this case
305
+ */
306
+ // Clear callback if not expecting any more results
307
+ if (!keepCallback) {
308
+ delete cordova.callbacks[callbackId];
309
+ }
310
+ }
311
+ } catch (err) {
312
+ var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err;
313
+ cordova.fireWindowEvent('cordovacallbackerror', { message: msg, error: err });
314
+ throw err;
315
+ }
316
+ },
317
+
318
+ addConstructor: function (func) {
319
+ channel.onCordovaReady.subscribe(function () {
320
+ try {
321
+ func();
322
+ } catch (e) {
323
+ console.log('Failed to run constructor: ' + e);
324
+ }
325
+ });
326
+ }
327
+ };
328
+
329
+ module.exports = cordova;
330
+
331
+ });
332
+
333
+ // file: ../../cordova-js-src/android/nativeapiprovider.js
334
+ define("cordova/android/nativeapiprovider", function(require, exports, module) {
335
+
336
+ /**
337
+ * Exports the ExposedJsApi.java object if available, otherwise exports the PromptBasedNativeApi.
338
+ */
339
+
340
+ var nativeApi = this._cordovaNative || require('cordova/android/promptbasednativeapi');
341
+ var currentApi = nativeApi;
342
+
343
+ module.exports = {
344
+ get: function () { return currentApi; },
345
+ setPreferPrompt: function (value) {
346
+ currentApi = value ? require('cordova/android/promptbasednativeapi') : nativeApi;
347
+ },
348
+ // Used only by tests.
349
+ set: function (value) {
350
+ currentApi = value;
351
+ }
352
+ };
353
+
354
+ });
355
+
356
+ // file: ../../cordova-js-src/android/promptbasednativeapi.js
357
+ define("cordova/android/promptbasednativeapi", function(require, exports, module) {
358
+
359
+ /**
360
+ * Implements the API of ExposedJsApi.java, but uses prompt() to communicate.
361
+ * This is used pre-JellyBean, where addJavascriptInterface() is disabled.
362
+ */
363
+
364
+ module.exports = {
365
+ exec: function (bridgeSecret, service, action, callbackId, argsJson) {
366
+ return prompt(argsJson, 'gap:' + JSON.stringify([bridgeSecret, service, action, callbackId]));
367
+ },
368
+ setNativeToJsBridgeMode: function (bridgeSecret, value) {
369
+ prompt(value, 'gap_bridge_mode:' + bridgeSecret);
370
+ },
371
+ retrieveJsMessages: function (bridgeSecret, fromOnlineEvent) {
372
+ return prompt(+fromOnlineEvent, 'gap_poll:' + bridgeSecret);
373
+ }
374
+ };
375
+
376
+ });
377
+
378
+ // file: src/common/argscheck.js
379
+ define("cordova/argscheck", function(require, exports, module) {
380
+
381
+ var utils = require('cordova/utils');
382
+
383
+ var moduleExports = module.exports;
384
+
385
+ var typeMap = {
386
+ A: 'Array',
387
+ D: 'Date',
388
+ N: 'Number',
389
+ S: 'String',
390
+ F: 'Function',
391
+ O: 'Object'
392
+ };
393
+
394
+ function extractParamName (callee, argIndex) {
395
+ return (/\(\s*([^)]*?)\s*\)/).exec(callee)[1].split(/\s*,\s*/)[argIndex];
396
+ }
397
+
398
+ /**
399
+ * Checks the given arguments' types and throws if they are not as expected.
400
+ *
401
+ * `spec` is a string where each character stands for the required type of the
402
+ * argument at the same position. In other words: the character at `spec[i]`
403
+ * specifies the required type for `args[i]`. The characters in `spec` are the
404
+ * first letter of the required type's name. The supported types are:
405
+ *
406
+ * Array, Date, Number, String, Function, Object
407
+ *
408
+ * Lowercase characters specify arguments that must not be `null` or `undefined`
409
+ * while uppercase characters allow those values to be passed.
410
+ *
411
+ * Finally, `*` can be used to allow any type at the corresponding position.
412
+ *
413
+ * @example
414
+ * function foo (arr, opts) {
415
+ * // require `arr` to be an Array and `opts` an Object, null or undefined
416
+ * checkArgs('aO', 'my.package.foo', arguments);
417
+ * // ...
418
+ * }
419
+ * @param {String} spec - the type specification for `args` as described above
420
+ * @param {String} functionName - full name of the callee.
421
+ * Used in the error message
422
+ * @param {Array|arguments} args - the arguments to be checked against `spec`
423
+ * @param {Function} [opt_callee=args.callee] - the recipient of `args`.
424
+ * Used to extract parameter names for the error message
425
+ * @throws {TypeError} if args do not satisfy spec
426
+ */
427
+ function checkArgs (spec, functionName, args, opt_callee) {
428
+ if (!moduleExports.enableChecks) {
429
+ return;
430
+ }
431
+ var errMsg = null;
432
+ var typeName;
433
+ for (var i = 0; i < spec.length; ++i) {
434
+ var c = spec.charAt(i);
435
+ var cUpper = c.toUpperCase();
436
+ var arg = args[i];
437
+ // Asterix means allow anything.
438
+ if (c === '*') {
439
+ continue;
440
+ }
441
+ typeName = utils.typeName(arg);
442
+ if ((arg === null || arg === undefined) && c === cUpper) {
443
+ continue;
444
+ }
445
+ if (typeName !== typeMap[cUpper]) {
446
+ errMsg = 'Expected ' + typeMap[cUpper];
447
+ break;
448
+ }
449
+ }
450
+ if (errMsg) {
451
+ errMsg += ', but got ' + typeName + '.';
452
+ errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
453
+ // Don't log when running unit tests.
454
+ if (typeof jasmine === 'undefined') {
455
+ console.error(errMsg);
456
+ }
457
+ throw TypeError(errMsg);
458
+ }
459
+ }
460
+
461
+ function getValue (value, defaultValue) {
462
+ return value === undefined ? defaultValue : value;
463
+ }
464
+
465
+ moduleExports.checkArgs = checkArgs;
466
+ moduleExports.getValue = getValue;
467
+ moduleExports.enableChecks = true;
468
+
469
+ });
470
+
471
+ // file: src/common/base64.js
472
+ define("cordova/base64", function(require, exports, module) {
473
+
474
+ var base64 = exports;
475
+
476
+ base64.fromArrayBuffer = function (arrayBuffer) {
477
+ var array = new Uint8Array(arrayBuffer);
478
+ return uint8ToBase64(array);
479
+ };
480
+
481
+ base64.toArrayBuffer = function (str) {
482
+ var decodedStr = atob(str);
483
+ var arrayBuffer = new ArrayBuffer(decodedStr.length);
484
+ var array = new Uint8Array(arrayBuffer);
485
+ for (var i = 0, len = decodedStr.length; i < len; i++) {
486
+ array[i] = decodedStr.charCodeAt(i);
487
+ }
488
+ return arrayBuffer;
489
+ };
490
+
491
+ // ------------------------------------------------------------------------------
492
+
493
+ /* This code is based on the performance tests at http://jsperf.com/b64tests
494
+ * This 12-bit-at-a-time algorithm was the best performing version on all
495
+ * platforms tested.
496
+ */
497
+
498
+ var b64_6bit = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
499
+ var b64_12bit;
500
+
501
+ var b64_12bitTable = function () {
502
+ b64_12bit = [];
503
+ for (var i = 0; i < 64; i++) {
504
+ for (var j = 0; j < 64; j++) {
505
+ b64_12bit[i * 64 + j] = b64_6bit[i] + b64_6bit[j];
506
+ }
507
+ }
508
+ b64_12bitTable = function () { return b64_12bit; };
509
+ return b64_12bit;
510
+ };
511
+
512
+ function uint8ToBase64 (rawData) {
513
+ var numBytes = rawData.byteLength;
514
+ var output = '';
515
+ var segment;
516
+ var table = b64_12bitTable();
517
+ for (var i = 0; i < numBytes - 2; i += 3) {
518
+ segment = (rawData[i] << 16) + (rawData[i + 1] << 8) + rawData[i + 2];
519
+ output += table[segment >> 12];
520
+ output += table[segment & 0xfff];
521
+ }
522
+ if (numBytes - i === 2) {
523
+ segment = (rawData[i] << 16) + (rawData[i + 1] << 8);
524
+ output += table[segment >> 12];
525
+ output += b64_6bit[(segment & 0xfff) >> 6];
526
+ output += '=';
527
+ } else if (numBytes - i === 1) {
528
+ segment = (rawData[i] << 16);
529
+ output += table[segment >> 12];
530
+ output += '==';
531
+ }
532
+ return output;
533
+ }
534
+
535
+ });
536
+
537
+ // file: src/common/builder.js
538
+ define("cordova/builder", function(require, exports, module) {
539
+
540
+ var utils = require('cordova/utils');
541
+
542
+ function each (objects, func, context) {
543
+ for (var prop in objects) {
544
+ if (Object.prototype.hasOwnProperty.call(objects, prop)) {
545
+ func.apply(context, [objects[prop], prop]);
546
+ }
547
+ }
548
+ }
549
+
550
+ function clobber (obj, key, value) {
551
+ var needsProperty = false;
552
+ try {
553
+ obj[key] = value;
554
+ } catch (e) {
555
+ needsProperty = true;
556
+ }
557
+ // Getters can only be overridden by getters.
558
+ if (needsProperty || obj[key] !== value) {
559
+ utils.defineGetter(obj, key, function () {
560
+ return value;
561
+ });
562
+ }
563
+ }
564
+
565
+ function assignOrWrapInDeprecateGetter (obj, key, value, message) {
566
+ if (message) {
567
+ utils.defineGetter(obj, key, function () {
568
+ console.log(message);
569
+ delete obj[key];
570
+ clobber(obj, key, value);
571
+ return value;
572
+ });
573
+ } else {
574
+ clobber(obj, key, value);
575
+ }
576
+ }
577
+
578
+ function include (parent, objects, clobber, merge) {
579
+ each(objects, function (obj, key) {
580
+ try {
581
+ var result = obj.path ? require(obj.path) : {};
582
+
583
+ if (clobber) {
584
+ // Clobber if it doesn't exist.
585
+ if (typeof parent[key] === 'undefined') {
586
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
587
+ } else if (typeof obj.path !== 'undefined') {
588
+ // If merging, merge properties onto parent, otherwise, clobber.
589
+ if (merge) {
590
+ recursiveMerge(parent[key], result);
591
+ } else {
592
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
593
+ }
594
+ }
595
+ result = parent[key];
596
+ } else {
597
+ // Overwrite if not currently defined.
598
+ if (typeof parent[key] === 'undefined') {
599
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
600
+ } else {
601
+ // Set result to what already exists, so we can build children into it if they exist.
602
+ result = parent[key];
603
+ }
604
+ }
605
+
606
+ if (obj.children) {
607
+ include(result, obj.children, clobber, merge);
608
+ }
609
+ } catch (e) {
610
+ utils.alert('Exception building Cordova JS globals: ' + e + ' for key "' + key + '"');
611
+ }
612
+ });
613
+ }
614
+
615
+ /**
616
+ * Merge properties from one object onto another recursively. Properties from
617
+ * the src object will overwrite existing target property.
618
+ *
619
+ * @param target Object to merge properties into.
620
+ * @param src Object to merge properties from.
621
+ */
622
+ function recursiveMerge (target, src) {
623
+ for (var prop in src) {
624
+ if (Object.prototype.hasOwnProperty.call(src, prop)) {
625
+ if (target.prototype && target.prototype.constructor === target) {
626
+ // If the target object is a constructor override off prototype.
627
+ clobber(target.prototype, prop, src[prop]);
628
+ } else {
629
+ if (typeof src[prop] === 'object' && typeof target[prop] === 'object') {
630
+ recursiveMerge(target[prop], src[prop]);
631
+ } else {
632
+ clobber(target, prop, src[prop]);
633
+ }
634
+ }
635
+ }
636
+ }
637
+ }
638
+
639
+ exports.buildIntoButDoNotClobber = function (objects, target) {
640
+ include(target, objects, false, false);
641
+ };
642
+ exports.buildIntoAndClobber = function (objects, target) {
643
+ include(target, objects, true, false);
644
+ };
645
+ exports.buildIntoAndMerge = function (objects, target) {
646
+ include(target, objects, true, true);
647
+ };
648
+ exports.recursiveMerge = recursiveMerge;
649
+ exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter;
650
+
651
+ });
652
+
653
+ // file: src/common/channel.js
654
+ define("cordova/channel", function(require, exports, module) {
655
+
656
+ var utils = require('cordova/utils');
657
+ var nextGuid = 1;
658
+
659
+ /**
660
+ * Custom pub-sub "channel" that can have functions subscribed to it
661
+ * This object is used to define and control firing of events for
662
+ * cordova initialization, as well as for custom events thereafter.
663
+ *
664
+ * The order of events during page load and Cordova startup is as follows:
665
+ *
666
+ * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
667
+ * onNativeReady* Internal event that indicates the Cordova native side is ready.
668
+ * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
669
+ * onDeviceReady* User event fired to indicate that Cordova is ready
670
+ * onResume User event fired to indicate a start/resume lifecycle event
671
+ * onPause User event fired to indicate a pause lifecycle event
672
+ *
673
+ * The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
674
+ * All listeners that subscribe after the event is fired will be executed right away.
675
+ *
676
+ * The only Cordova events that user code should register for are:
677
+ * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
678
+ * pause App has moved to background
679
+ * resume App has returned to foreground
680
+ *
681
+ * Listeners can be registered as:
682
+ * document.addEventListener("deviceready", myDeviceReadyListener, false);
683
+ * document.addEventListener("resume", myResumeListener, false);
684
+ * document.addEventListener("pause", myPauseListener, false);
685
+ *
686
+ * The DOM lifecycle events should be used for saving and restoring state
687
+ * window.onload
688
+ * window.onunload
689
+ *
690
+ */
691
+
692
+ /**
693
+ * Channel
694
+ * @constructor
695
+ * @param type String the channel name
696
+ */
697
+ var Channel = function (type, sticky) {
698
+ this.type = type;
699
+ // Map of guid -> function.
700
+ this.handlers = {};
701
+ // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired.
702
+ this.state = sticky ? 1 : 0;
703
+ // Used in sticky mode to remember args passed to fire().
704
+ this.fireArgs = null;
705
+ // Used by onHasSubscribersChange to know if there are any listeners.
706
+ this.numHandlers = 0;
707
+ // Function that is called when the first listener is subscribed, or when
708
+ // the last listener is unsubscribed.
709
+ this.onHasSubscribersChange = null;
710
+ };
711
+ var channel = {
712
+ /**
713
+ * Calls the provided function only after all of the channels specified
714
+ * have been fired. All channels must be sticky channels.
715
+ */
716
+ join: function (h, c) {
717
+ var len = c.length;
718
+ var i = len;
719
+ var f = function () {
720
+ if (!(--i)) h();
721
+ };
722
+ for (var j = 0; j < len; j++) {
723
+ if (c[j].state === 0) {
724
+ throw Error('Can only use join with sticky channels.');
725
+ }
726
+ c[j].subscribe(f);
727
+ }
728
+ if (!len) h();
729
+ },
730
+
731
+ create: function (type) {
732
+ return (channel[type] = new Channel(type, false));
733
+ },
734
+ createSticky: function (type) {
735
+ return (channel[type] = new Channel(type, true));
736
+ },
737
+
738
+ /**
739
+ * cordova Channels that must fire before "deviceready" is fired.
740
+ */
741
+ deviceReadyChannelsArray: [],
742
+ deviceReadyChannelsMap: {},
743
+
744
+ /**
745
+ * Indicate that a feature needs to be initialized before it is ready to be used.
746
+ * This holds up Cordova's "deviceready" event until the feature has been initialized
747
+ * and Cordova.initComplete(feature) is called.
748
+ *
749
+ * @param feature {String} The unique feature name
750
+ */
751
+ waitForInitialization: function (feature) {
752
+ if (feature) {
753
+ var c = channel[feature] || this.createSticky(feature);
754
+ this.deviceReadyChannelsMap[feature] = c;
755
+ this.deviceReadyChannelsArray.push(c);
756
+ }
757
+ },
758
+
759
+ /**
760
+ * Indicate that initialization code has completed and the feature is ready to be used.
761
+ *
762
+ * @param feature {String} The unique feature name
763
+ */
764
+ initializationComplete: function (feature) {
765
+ var c = this.deviceReadyChannelsMap[feature];
766
+ if (c) {
767
+ c.fire();
768
+ }
769
+ }
770
+ };
771
+
772
+ function checkSubscriptionArgument (argument) {
773
+ if (typeof argument !== 'function' && typeof argument.handleEvent !== 'function') {
774
+ throw new Error(
775
+ 'Must provide a function or an EventListener object ' +
776
+ 'implementing the handleEvent interface.'
777
+ );
778
+ }
779
+ }
780
+
781
+ /**
782
+ * Subscribes the given function to the channel. Any time that
783
+ * Channel.fire is called so too will the function.
784
+ * Optionally specify an execution context for the function
785
+ * and a guid that can be used to stop subscribing to the channel.
786
+ * Returns the guid.
787
+ */
788
+ Channel.prototype.subscribe = function (eventListenerOrFunction, eventListener) {
789
+ checkSubscriptionArgument(eventListenerOrFunction);
790
+ var handleEvent, guid;
791
+
792
+ if (eventListenerOrFunction && typeof eventListenerOrFunction === 'object') {
793
+ // Received an EventListener object implementing the handleEvent interface
794
+ handleEvent = eventListenerOrFunction.handleEvent;
795
+ eventListener = eventListenerOrFunction;
796
+ } else {
797
+ // Received a function to handle event
798
+ handleEvent = eventListenerOrFunction;
799
+ }
800
+
801
+ if (this.state === 2) {
802
+ handleEvent.apply(eventListener || this, this.fireArgs);
803
+ return;
804
+ }
805
+
806
+ guid = eventListenerOrFunction.observer_guid;
807
+ if (typeof eventListener === 'object') {
808
+ handleEvent = utils.close(eventListener, handleEvent);
809
+ }
810
+
811
+ if (!guid) {
812
+ // First time any channel has seen this subscriber
813
+ guid = '' + nextGuid++;
814
+ }
815
+ handleEvent.observer_guid = guid;
816
+ eventListenerOrFunction.observer_guid = guid;
817
+
818
+ // Don't add the same handler more than once.
819
+ if (!this.handlers[guid]) {
820
+ this.handlers[guid] = handleEvent;
821
+ this.numHandlers++;
822
+ if (this.numHandlers === 1) {
823
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
824
+ }
825
+ }
826
+ };
827
+
828
+ /**
829
+ * Unsubscribes the function with the given guid from the channel.
830
+ */
831
+ Channel.prototype.unsubscribe = function (eventListenerOrFunction) {
832
+ checkSubscriptionArgument(eventListenerOrFunction);
833
+ var handleEvent, guid, handler;
834
+
835
+ if (eventListenerOrFunction && typeof eventListenerOrFunction === 'object') {
836
+ // Received an EventListener object implementing the handleEvent interface
837
+ handleEvent = eventListenerOrFunction.handleEvent;
838
+ } else {
839
+ // Received a function to handle event
840
+ handleEvent = eventListenerOrFunction;
841
+ }
842
+
843
+ guid = handleEvent.observer_guid;
844
+ handler = this.handlers[guid];
845
+ if (handler) {
846
+ delete this.handlers[guid];
847
+ this.numHandlers--;
848
+ if (this.numHandlers === 0) {
849
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
850
+ }
851
+ }
852
+ };
853
+
854
+ /**
855
+ * Calls all functions subscribed to this channel.
856
+ */
857
+ Channel.prototype.fire = function (e) {
858
+ var fireArgs = Array.prototype.slice.call(arguments);
859
+ // Apply stickiness.
860
+ if (this.state === 1) {
861
+ this.state = 2;
862
+ this.fireArgs = fireArgs;
863
+ }
864
+ if (this.numHandlers) {
865
+ // Copy the values first so that it is safe to modify it from within
866
+ // callbacks.
867
+ var toCall = [];
868
+ for (var item in this.handlers) {
869
+ toCall.push(this.handlers[item]);
870
+ }
871
+ for (var i = 0; i < toCall.length; ++i) {
872
+ toCall[i].apply(this, fireArgs);
873
+ }
874
+ if (this.state === 2 && this.numHandlers) {
875
+ this.numHandlers = 0;
876
+ this.handlers = {};
877
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
878
+ }
879
+ }
880
+ };
881
+
882
+ // defining them here so they are ready super fast!
883
+ // DOM event that is received when the web page is loaded and parsed.
884
+ channel.createSticky('onDOMContentLoaded');
885
+
886
+ // Event to indicate the Cordova native side is ready.
887
+ channel.createSticky('onNativeReady');
888
+
889
+ // Event to indicate that all Cordova JavaScript objects have been created
890
+ // and it's time to run plugin constructors.
891
+ channel.createSticky('onCordovaReady');
892
+
893
+ // Event to indicate that all automatically loaded JS plugins are loaded and ready.
894
+ // FIXME remove this
895
+ channel.createSticky('onPluginsReady');
896
+
897
+ // Event to indicate that Cordova is ready
898
+ channel.createSticky('onDeviceReady');
899
+
900
+ // Event to indicate a resume lifecycle event
901
+ channel.create('onResume');
902
+
903
+ // Event to indicate a pause lifecycle event
904
+ channel.create('onPause');
905
+
906
+ // Channels that must fire before "deviceready" is fired.
907
+ channel.waitForInitialization('onCordovaReady');
908
+ channel.waitForInitialization('onDOMContentLoaded');
909
+
910
+ module.exports = channel;
911
+
912
+ });
913
+
914
+ // file: ../../cordova-js-src/exec.js
915
+ define("cordova/exec", function(require, exports, module) {
916
+
917
+ /**
918
+ * Execute a cordova command. It is up to the native side whether this action
919
+ * is synchronous or asynchronous. The native side can return:
920
+ * Synchronous: PluginResult object as a JSON string
921
+ * Asynchronous: Empty string ""
922
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
923
+ * depending upon the result of the action.
924
+ *
925
+ * @param {Function} success The success callback
926
+ * @param {Function} fail The fail callback
927
+ * @param {String} service The name of the service to use
928
+ * @param {String} action Action to be run in cordova
929
+ * @param {String[]} [args] Zero or more arguments to pass to the method
930
+ */
931
+ var cordova = require('cordova');
932
+ var nativeApiProvider = require('cordova/android/nativeapiprovider');
933
+ var utils = require('cordova/utils');
934
+ var base64 = require('cordova/base64');
935
+ var channel = require('cordova/channel');
936
+ var jsToNativeModes = {
937
+ PROMPT: 0,
938
+ JS_OBJECT: 1
939
+ };
940
+ var nativeToJsModes = {
941
+ // Polls for messages using the JS->Native bridge.
942
+ POLLING: 0,
943
+ // For LOAD_URL to be viable, it would need to have a work-around for
944
+ // the bug where the soft-keyboard gets dismissed when a message is sent.
945
+ LOAD_URL: 1,
946
+ // For the ONLINE_EVENT to be viable, it would need to intercept all event
947
+ // listeners (both through addEventListener and window.ononline) as well
948
+ // as set the navigator property itself.
949
+ ONLINE_EVENT: 2,
950
+ EVAL_BRIDGE: 3
951
+ };
952
+ var jsToNativeBridgeMode; // Set lazily.
953
+ var nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE;
954
+ var pollEnabled = false;
955
+ var bridgeSecret = -1;
956
+
957
+ var messagesFromNative = [];
958
+ var isProcessing = false;
959
+ var resolvedPromise = typeof Promise === 'undefined' ? null : Promise.resolve();
960
+ var nextTick = resolvedPromise ? function (fn) { resolvedPromise.then(fn); } : function (fn) { setTimeout(fn); };
961
+
962
+ function androidExec (success, fail, service, action, args) {
963
+ if (bridgeSecret < 0) {
964
+ // If we ever catch this firing, we'll need to queue up exec()s
965
+ // and fire them once we get a secret. For now, I don't think
966
+ // it's possible for exec() to be called since plugins are parsed but
967
+ // not run until until after onNativeReady.
968
+ throw new Error('exec() called without bridgeSecret');
969
+ }
970
+ // Set default bridge modes if they have not already been set.
971
+ // By default, we use the failsafe, since addJavascriptInterface breaks too often
972
+ if (jsToNativeBridgeMode === undefined) {
973
+ androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
974
+ }
975
+
976
+ // If args is not provided, default to an empty array
977
+ args = args || [];
978
+
979
+ // Process any ArrayBuffers in the args into a string.
980
+ for (var i = 0; i < args.length; i++) {
981
+ if (utils.typeName(args[i]) === 'ArrayBuffer') {
982
+ args[i] = base64.fromArrayBuffer(args[i]);
983
+ }
984
+ }
985
+
986
+ var callbackId = service + cordova.callbackId++;
987
+ var argsJson = JSON.stringify(args);
988
+ if (success || fail) {
989
+ cordova.callbacks[callbackId] = { success: success, fail: fail };
990
+ }
991
+
992
+ var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
993
+ // If argsJson was received by Java as null, try again with the PROMPT bridge mode.
994
+ // This happens in rare circumstances, such as when certain Unicode characters are passed over the bridge on a Galaxy S2. See CB-2666.
995
+ if (jsToNativeBridgeMode === jsToNativeModes.JS_OBJECT && msgs === '@Null arguments.') {
996
+ androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
997
+ androidExec(success, fail, service, action, args);
998
+ androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
999
+ } else if (msgs) {
1000
+ messagesFromNative.push(msgs);
1001
+ // Always process async to avoid exceptions messing up stack.
1002
+ nextTick(processMessages);
1003
+ }
1004
+ }
1005
+
1006
+ androidExec.init = function () {
1007
+ bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
1008
+ channel.onNativeReady.fire();
1009
+ };
1010
+
1011
+ function pollOnceFromOnlineEvent () {
1012
+ pollOnce(true);
1013
+ }
1014
+
1015
+ function pollOnce (opt_fromOnlineEvent) {
1016
+ if (bridgeSecret < 0) {
1017
+ // This can happen when the NativeToJsMessageQueue resets the online state on page transitions.
1018
+ // We know there's nothing to retrieve, so no need to poll.
1019
+ return;
1020
+ }
1021
+ var msgs = nativeApiProvider.get().retrieveJsMessages(bridgeSecret, !!opt_fromOnlineEvent);
1022
+ if (msgs) {
1023
+ messagesFromNative.push(msgs);
1024
+ // Process sync since we know we're already top-of-stack.
1025
+ processMessages();
1026
+ }
1027
+ }
1028
+
1029
+ function pollingTimerFunc () {
1030
+ if (pollEnabled) {
1031
+ pollOnce();
1032
+ setTimeout(pollingTimerFunc, 50);
1033
+ }
1034
+ }
1035
+
1036
+ function hookOnlineApis () {
1037
+ function proxyEvent (e) {
1038
+ cordova.fireWindowEvent(e.type);
1039
+ }
1040
+ // The network module takes care of firing online and offline events.
1041
+ // It currently fires them only on document though, so we bridge them
1042
+ // to window here (while first listening for exec()-releated online/offline
1043
+ // events).
1044
+ window.addEventListener('online', pollOnceFromOnlineEvent, false);
1045
+ window.addEventListener('offline', pollOnceFromOnlineEvent, false);
1046
+ cordova.addWindowEventHandler('online');
1047
+ cordova.addWindowEventHandler('offline');
1048
+ document.addEventListener('online', proxyEvent, false);
1049
+ document.addEventListener('offline', proxyEvent, false);
1050
+ }
1051
+
1052
+ hookOnlineApis();
1053
+
1054
+ androidExec.jsToNativeModes = jsToNativeModes;
1055
+ androidExec.nativeToJsModes = nativeToJsModes;
1056
+
1057
+ androidExec.setJsToNativeBridgeMode = function (mode) {
1058
+ if (mode === jsToNativeModes.JS_OBJECT && !window._cordovaNative) {
1059
+ mode = jsToNativeModes.PROMPT;
1060
+ }
1061
+ nativeApiProvider.setPreferPrompt(mode === jsToNativeModes.PROMPT);
1062
+ jsToNativeBridgeMode = mode;
1063
+ };
1064
+
1065
+ androidExec.setNativeToJsBridgeMode = function (mode) {
1066
+ if (mode === nativeToJsBridgeMode) {
1067
+ return;
1068
+ }
1069
+ if (nativeToJsBridgeMode === nativeToJsModes.POLLING) {
1070
+ pollEnabled = false;
1071
+ }
1072
+
1073
+ nativeToJsBridgeMode = mode;
1074
+ // Tell the native side to switch modes.
1075
+ // Otherwise, it will be set by androidExec.init()
1076
+ if (bridgeSecret >= 0) {
1077
+ nativeApiProvider.get().setNativeToJsBridgeMode(bridgeSecret, mode);
1078
+ }
1079
+
1080
+ if (mode === nativeToJsModes.POLLING) {
1081
+ pollEnabled = true;
1082
+ setTimeout(pollingTimerFunc, 1);
1083
+ }
1084
+ };
1085
+
1086
+ function buildPayload (payload, message) {
1087
+ var payloadKind = message.charAt(0);
1088
+ if (payloadKind === 's') {
1089
+ payload.push(message.slice(1));
1090
+ } else if (payloadKind === 't') {
1091
+ payload.push(true);
1092
+ } else if (payloadKind === 'f') {
1093
+ payload.push(false);
1094
+ } else if (payloadKind === 'N') {
1095
+ payload.push(null);
1096
+ } else if (payloadKind === 'n') {
1097
+ payload.push(+message.slice(1));
1098
+ } else if (payloadKind === 'A') {
1099
+ var data = message.slice(1);
1100
+ payload.push(base64.toArrayBuffer(data));
1101
+ } else if (payloadKind === 'S') {
1102
+ payload.push(window.atob(message.slice(1)));
1103
+ } else if (payloadKind === 'M') {
1104
+ var multipartMessages = message.slice(1);
1105
+ while (multipartMessages !== '') {
1106
+ var spaceIdx = multipartMessages.indexOf(' ');
1107
+ var msgLen = +multipartMessages.slice(0, spaceIdx);
1108
+ var multipartMessage = multipartMessages.substr(spaceIdx + 1, msgLen);
1109
+ multipartMessages = multipartMessages.slice(spaceIdx + msgLen + 1);
1110
+ buildPayload(payload, multipartMessage);
1111
+ }
1112
+ } else {
1113
+ payload.push(JSON.parse(message));
1114
+ }
1115
+ }
1116
+
1117
+ // Processes a single message, as encoded by NativeToJsMessageQueue.java.
1118
+ function processMessage (message) {
1119
+ var firstChar = message.charAt(0);
1120
+ if (firstChar === 'J') {
1121
+ // This is deprecated on the .java side. It doesn't work with CSP enabled.
1122
+ // eslint-disable-next-line no-eval
1123
+ eval(message.slice(1));
1124
+ } else if (firstChar === 'S' || firstChar === 'F') {
1125
+ var success = firstChar === 'S';
1126
+ var keepCallback = message.charAt(1) === '1';
1127
+ var spaceIdx = message.indexOf(' ', 2);
1128
+ var status = +message.slice(2, spaceIdx);
1129
+ var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
1130
+ var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
1131
+ var payloadMessage = message.slice(nextSpaceIdx + 1);
1132
+ var payload = [];
1133
+ buildPayload(payload, payloadMessage);
1134
+ cordova.callbackFromNative(callbackId, success, status, payload, keepCallback);
1135
+ } else {
1136
+ console.log('processMessage failed: invalid message: ' + JSON.stringify(message));
1137
+ }
1138
+ }
1139
+
1140
+ function processMessages () {
1141
+ // Check for the reentrant case.
1142
+ if (isProcessing) {
1143
+ return;
1144
+ }
1145
+ if (messagesFromNative.length === 0) {
1146
+ return;
1147
+ }
1148
+ isProcessing = true;
1149
+ try {
1150
+ var msg = popMessageFromQueue();
1151
+ // The Java side can send a * message to indicate that it
1152
+ // still has messages waiting to be retrieved.
1153
+ if (msg === '*' && messagesFromNative.length === 0) {
1154
+ nextTick(pollOnce);
1155
+ return;
1156
+ }
1157
+ processMessage(msg);
1158
+ } finally {
1159
+ isProcessing = false;
1160
+ if (messagesFromNative.length > 0) {
1161
+ nextTick(processMessages);
1162
+ }
1163
+ }
1164
+ }
1165
+
1166
+ function popMessageFromQueue () {
1167
+ var messageBatch = messagesFromNative.shift();
1168
+ if (messageBatch === '*') {
1169
+ return '*';
1170
+ }
1171
+
1172
+ var spaceIdx = messageBatch.indexOf(' ');
1173
+ var msgLen = +messageBatch.slice(0, spaceIdx);
1174
+ var message = messageBatch.substr(spaceIdx + 1, msgLen);
1175
+ messageBatch = messageBatch.slice(spaceIdx + msgLen + 1);
1176
+ if (messageBatch) {
1177
+ messagesFromNative.unshift(messageBatch);
1178
+ }
1179
+ return message;
1180
+ }
1181
+
1182
+ module.exports = androidExec;
1183
+
1184
+ });
1185
+
1186
+ // file: src/common/exec/proxy.js
1187
+ define("cordova/exec/proxy", function(require, exports, module) {
1188
+
1189
+ // internal map of proxy function
1190
+ var CommandProxyMap = {};
1191
+
1192
+ module.exports = {
1193
+
1194
+ // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
1195
+ add: function (id, proxyObj) {
1196
+ console.log('adding proxy for ' + id);
1197
+ CommandProxyMap[id] = proxyObj;
1198
+ return proxyObj;
1199
+ },
1200
+
1201
+ // cordova.commandProxy.remove("Accelerometer");
1202
+ remove: function (id) {
1203
+ var proxy = CommandProxyMap[id];
1204
+ delete CommandProxyMap[id];
1205
+ CommandProxyMap[id] = null;
1206
+ return proxy;
1207
+ },
1208
+
1209
+ get: function (service, action) {
1210
+ return (CommandProxyMap[service] ? CommandProxyMap[service][action] : null);
1211
+ }
1212
+ };
1213
+
1214
+ });
1215
+
1216
+ // file: src/common/init.js
1217
+ define("cordova/init", function(require, exports, module) {
1218
+
1219
+ var channel = require('cordova/channel');
1220
+ var cordova = require('cordova');
1221
+ var modulemapper = require('cordova/modulemapper');
1222
+ var platform = require('cordova/platform');
1223
+ var pluginloader = require('cordova/pluginloader');
1224
+
1225
+ var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
1226
+
1227
+ function logUnfiredChannels (arr) {
1228
+ for (var i = 0; i < arr.length; ++i) {
1229
+ if (arr[i].state !== 2) {
1230
+ console.log('Channel not fired: ' + arr[i].type);
1231
+ }
1232
+ }
1233
+ }
1234
+
1235
+ window.setTimeout(function () {
1236
+ if (channel.onDeviceReady.state !== 2) {
1237
+ console.log('deviceready has not fired after 5 seconds.');
1238
+ logUnfiredChannels(platformInitChannelsArray);
1239
+ logUnfiredChannels(channel.deviceReadyChannelsArray);
1240
+ }
1241
+ }, 5000);
1242
+
1243
+ if (!window.console) {
1244
+ window.console = {
1245
+ log: function () {}
1246
+ };
1247
+ }
1248
+ if (!window.console.warn) {
1249
+ window.console.warn = function (msg) {
1250
+ this.log('warn: ' + msg);
1251
+ };
1252
+ }
1253
+
1254
+ // Register pause, resume and deviceready channels as events on document.
1255
+ channel.onPause = cordova.addDocumentEventHandler('pause');
1256
+ channel.onResume = cordova.addDocumentEventHandler('resume');
1257
+ channel.onActivated = cordova.addDocumentEventHandler('activated');
1258
+ channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
1259
+
1260
+ // Listen for DOMContentLoaded and notify our channel subscribers.
1261
+ if (document.readyState === 'complete' || document.readyState === 'interactive') {
1262
+ channel.onDOMContentLoaded.fire();
1263
+ } else {
1264
+ document.addEventListener('DOMContentLoaded', function () {
1265
+ channel.onDOMContentLoaded.fire();
1266
+ }, false);
1267
+ }
1268
+
1269
+ // _nativeReady is global variable that the native side can set
1270
+ // to signify that the native code is ready. It is a global since
1271
+ // it may be called before any cordova JS is ready.
1272
+ if (window._nativeReady) {
1273
+ channel.onNativeReady.fire();
1274
+ }
1275
+
1276
+ modulemapper.clobbers('cordova', 'cordova');
1277
+ modulemapper.clobbers('cordova/exec', 'cordova.exec');
1278
+ modulemapper.clobbers('cordova/exec', 'Cordova.exec');
1279
+
1280
+ // Call the platform-specific initialization.
1281
+ platform.bootstrap && platform.bootstrap();
1282
+
1283
+ // Wrap in a setTimeout to support the use-case of having plugin JS appended to cordova.js.
1284
+ // The delay allows the attached modules to be defined before the plugin loader looks for them.
1285
+ setTimeout(function () {
1286
+ pluginloader.load(function () {
1287
+ channel.onPluginsReady.fire();
1288
+ });
1289
+ }, 0);
1290
+
1291
+ /**
1292
+ * Create all cordova objects once native side is ready.
1293
+ */
1294
+ channel.join(function () {
1295
+ modulemapper.mapModules(window);
1296
+
1297
+ platform.initialize && platform.initialize();
1298
+
1299
+ // Fire event to notify that all objects are created
1300
+ channel.onCordovaReady.fire();
1301
+
1302
+ // Fire onDeviceReady event once page has fully loaded, all
1303
+ // constructors have run and cordova info has been received from native
1304
+ // side.
1305
+ channel.join(function () {
1306
+ require('cordova').fireDocumentEvent('deviceready');
1307
+ }, channel.deviceReadyChannelsArray);
1308
+ }, platformInitChannelsArray);
1309
+
1310
+ });
1311
+
1312
+ // file: src/common/modulemapper.js
1313
+ define("cordova/modulemapper", function(require, exports, module) {
1314
+
1315
+ var builder = require('cordova/builder');
1316
+ var moduleMap = define.moduleMap;
1317
+ var symbolList;
1318
+ var deprecationMap;
1319
+
1320
+ exports.reset = function () {
1321
+ symbolList = [];
1322
+ deprecationMap = {};
1323
+ };
1324
+
1325
+ function addEntry (strategy, moduleName, symbolPath, opt_deprecationMessage) {
1326
+ if (!(moduleName in moduleMap)) {
1327
+ throw new Error('Module ' + moduleName + ' does not exist.');
1328
+ }
1329
+ symbolList.push(strategy, moduleName, symbolPath);
1330
+ if (opt_deprecationMessage) {
1331
+ deprecationMap[symbolPath] = opt_deprecationMessage;
1332
+ }
1333
+ }
1334
+
1335
+ // Note: Android 2.3 does have Function.bind().
1336
+ exports.clobbers = function (moduleName, symbolPath, opt_deprecationMessage) {
1337
+ addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
1338
+ };
1339
+
1340
+ exports.merges = function (moduleName, symbolPath, opt_deprecationMessage) {
1341
+ addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
1342
+ };
1343
+
1344
+ exports.defaults = function (moduleName, symbolPath, opt_deprecationMessage) {
1345
+ addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
1346
+ };
1347
+
1348
+ exports.runs = function (moduleName) {
1349
+ addEntry('r', moduleName, null);
1350
+ };
1351
+
1352
+ function prepareNamespace (symbolPath, context) {
1353
+ if (!symbolPath) {
1354
+ return context;
1355
+ }
1356
+ return symbolPath.split('.').reduce(function (cur, part) {
1357
+ return (cur[part] = cur[part] || {});
1358
+ }, context);
1359
+ }
1360
+
1361
+ exports.mapModules = function (context) {
1362
+ var origSymbols = {};
1363
+ context.CDV_origSymbols = origSymbols;
1364
+ for (var i = 0, len = symbolList.length; i < len; i += 3) {
1365
+ var strategy = symbolList[i];
1366
+ var moduleName = symbolList[i + 1];
1367
+ var module = require(moduleName);
1368
+ // <runs/>
1369
+ if (strategy === 'r') {
1370
+ continue;
1371
+ }
1372
+ var symbolPath = symbolList[i + 2];
1373
+ var lastDot = symbolPath.lastIndexOf('.');
1374
+ var namespace = symbolPath.substr(0, lastDot);
1375
+ var lastName = symbolPath.substr(lastDot + 1);
1376
+
1377
+ var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
1378
+ var parentObj = prepareNamespace(namespace, context);
1379
+ var target = parentObj[lastName];
1380
+
1381
+ if (strategy === 'm' && target) {
1382
+ builder.recursiveMerge(target, module);
1383
+ } else if ((strategy === 'd' && !target) || (strategy !== 'd')) {
1384
+ if (!(symbolPath in origSymbols)) {
1385
+ origSymbols[symbolPath] = target;
1386
+ }
1387
+ builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
1388
+ }
1389
+ }
1390
+ };
1391
+
1392
+ exports.getOriginalSymbol = function (context, symbolPath) {
1393
+ var origSymbols = context.CDV_origSymbols;
1394
+ if (origSymbols && (symbolPath in origSymbols)) {
1395
+ return origSymbols[symbolPath];
1396
+ }
1397
+ var parts = symbolPath.split('.');
1398
+ var obj = context;
1399
+ for (var i = 0; i < parts.length; ++i) {
1400
+ obj = obj && obj[parts[i]];
1401
+ }
1402
+ return obj;
1403
+ };
1404
+
1405
+ exports.reset();
1406
+
1407
+ });
1408
+
1409
+ // file: ../../cordova-js-src/platform.js
1410
+ define("cordova/platform", function(require, exports, module) {
1411
+
1412
+ // The last resume event that was received that had the result of a plugin call.
1413
+ var lastResumeEvent = null;
1414
+
1415
+ module.exports = {
1416
+ id: 'android',
1417
+ bootstrap: function () {
1418
+ var channel = require('cordova/channel');
1419
+ var cordova = require('cordova');
1420
+ var exec = require('cordova/exec');
1421
+ var modulemapper = require('cordova/modulemapper');
1422
+
1423
+ // Get the shared secret needed to use the bridge.
1424
+ exec.init();
1425
+
1426
+ // TODO: Extract this as a proper plugin.
1427
+ modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
1428
+
1429
+ // Core Splash Screen
1430
+ modulemapper.clobbers('cordova/plugin/android/splashscreen', 'navigator.splashscreen');
1431
+
1432
+ var APP_PLUGIN_NAME = Number(cordova.platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App';
1433
+
1434
+ // Inject a listener for the backbutton on the document.
1435
+ var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
1436
+ backButtonChannel.onHasSubscribersChange = function () {
1437
+ // If we just attached the first handler or detached the last handler,
1438
+ // let native know we need to override the back button.
1439
+ exec(null, null, APP_PLUGIN_NAME, 'overrideBackbutton', [this.numHandlers === 1]);
1440
+ };
1441
+
1442
+ // Add hardware MENU and SEARCH button handlers
1443
+ cordova.addDocumentEventHandler('menubutton');
1444
+ cordova.addDocumentEventHandler('searchbutton');
1445
+
1446
+ function bindButtonChannel (buttonName) {
1447
+ // generic button bind used for volumeup/volumedown buttons
1448
+ var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
1449
+ volumeButtonChannel.onHasSubscribersChange = function () {
1450
+ exec(null, null, APP_PLUGIN_NAME, 'overrideButton', [buttonName, this.numHandlers === 1]);
1451
+ };
1452
+ }
1453
+ // Inject a listener for the volume buttons on the document.
1454
+ bindButtonChannel('volumeup');
1455
+ bindButtonChannel('volumedown');
1456
+
1457
+ // The resume event is not "sticky", but it is possible that the event
1458
+ // will contain the result of a plugin call. We need to ensure that the
1459
+ // plugin result is delivered even after the event is fired (CB-10498)
1460
+ var cordovaAddEventListener = document.addEventListener;
1461
+
1462
+ document.addEventListener = function (evt, handler, capture) {
1463
+ cordovaAddEventListener(evt, handler, capture);
1464
+
1465
+ if (evt === 'resume' && lastResumeEvent) {
1466
+ handler(lastResumeEvent);
1467
+ }
1468
+ };
1469
+
1470
+ // Let native code know we are all done on the JS side.
1471
+ // Native code will then un-hide the WebView.
1472
+ channel.onCordovaReady.subscribe(function () {
1473
+ exec(onMessageFromNative, null, APP_PLUGIN_NAME, 'messageChannel', []);
1474
+ exec(null, null, APP_PLUGIN_NAME, 'show', []);
1475
+ });
1476
+ }
1477
+ };
1478
+
1479
+ function onMessageFromNative (msg) {
1480
+ var cordova = require('cordova');
1481
+ var action = msg.action;
1482
+
1483
+ switch (action) {
1484
+ // pause and resume are Android app life cycle events
1485
+ case 'backbutton':
1486
+ case 'menubutton':
1487
+ case 'searchbutton':
1488
+ case 'pause':
1489
+ case 'volumedownbutton':
1490
+ case 'volumeupbutton':
1491
+ cordova.fireDocumentEvent(action);
1492
+ break;
1493
+ case 'resume':
1494
+ if (arguments.length > 1 && msg.pendingResult) {
1495
+ if (arguments.length === 2) {
1496
+ msg.pendingResult.result = arguments[1];
1497
+ } else {
1498
+ // The plugin returned a multipart message
1499
+ var res = [];
1500
+ for (var i = 1; i < arguments.length; i++) {
1501
+ res.push(arguments[i]);
1502
+ }
1503
+ msg.pendingResult.result = res;
1504
+ }
1505
+
1506
+ // Save the plugin result so that it can be delivered to the js
1507
+ // even if they miss the initial firing of the event
1508
+ lastResumeEvent = msg;
1509
+ }
1510
+ cordova.fireDocumentEvent(action, msg);
1511
+ break;
1512
+ default:
1513
+ throw new Error('Unknown event action ' + action);
1514
+ }
1515
+ }
1516
+
1517
+ });
1518
+
1519
+ // file: ../../cordova-js-src/plugin/android/app.js
1520
+ define("cordova/plugin/android/app", function(require, exports, module) {
1521
+
1522
+ var exec = require('cordova/exec');
1523
+ var APP_PLUGIN_NAME = Number(require('cordova').platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App';
1524
+
1525
+ module.exports = {
1526
+ /**
1527
+ * Clear the resource cache.
1528
+ */
1529
+ clearCache: function () {
1530
+ exec(null, null, APP_PLUGIN_NAME, 'clearCache', []);
1531
+ },
1532
+
1533
+ /**
1534
+ * Load the url into the WebView or into new browser instance.
1535
+ *
1536
+ * @param url The URL to load
1537
+ * @param props Properties that can be passed in to the activity:
1538
+ * wait: int => wait msec before loading URL
1539
+ * loadingDialog: "Title,Message" => display a native loading dialog
1540
+ * loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error
1541
+ * clearHistory: boolean => clear WebView history (default=false)
1542
+ * openExternal: boolean => open in a new browser (default=false)
1543
+ *
1544
+ * Example:
1545
+ * navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
1546
+ */
1547
+ loadUrl: function (url, props) {
1548
+ exec(null, null, APP_PLUGIN_NAME, 'loadUrl', [url, props]);
1549
+ },
1550
+
1551
+ /**
1552
+ * Cancel loadUrl that is waiting to be loaded.
1553
+ */
1554
+ cancelLoadUrl: function () {
1555
+ exec(null, null, APP_PLUGIN_NAME, 'cancelLoadUrl', []);
1556
+ },
1557
+
1558
+ /**
1559
+ * Clear web history in this web view.
1560
+ * Instead of BACK button loading the previous web page, it will exit the app.
1561
+ */
1562
+ clearHistory: function () {
1563
+ exec(null, null, APP_PLUGIN_NAME, 'clearHistory', []);
1564
+ },
1565
+
1566
+ /**
1567
+ * Go to previous page displayed.
1568
+ * This is the same as pressing the backbutton on Android device.
1569
+ */
1570
+ backHistory: function () {
1571
+ exec(null, null, APP_PLUGIN_NAME, 'backHistory', []);
1572
+ },
1573
+
1574
+ /**
1575
+ * Override the default behavior of the Android back button.
1576
+ * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
1577
+ *
1578
+ * Note: The user should not have to call this method. Instead, when the user
1579
+ * registers for the "backbutton" event, this is automatically done.
1580
+ *
1581
+ * @param override T=override, F=cancel override
1582
+ */
1583
+ overrideBackbutton: function (override) {
1584
+ exec(null, null, APP_PLUGIN_NAME, 'overrideBackbutton', [override]);
1585
+ },
1586
+
1587
+ /**
1588
+ * Override the default behavior of the Android volume button.
1589
+ * If overridden, when the volume button is pressed, the "volume[up|down]button"
1590
+ * JavaScript event will be fired.
1591
+ *
1592
+ * Note: The user should not have to call this method. Instead, when the user
1593
+ * registers for the "volume[up|down]button" event, this is automatically done.
1594
+ *
1595
+ * @param button volumeup, volumedown
1596
+ * @param override T=override, F=cancel override
1597
+ */
1598
+ overrideButton: function (button, override) {
1599
+ exec(null, null, APP_PLUGIN_NAME, 'overrideButton', [button, override]);
1600
+ },
1601
+
1602
+ /**
1603
+ * Exit and terminate the application.
1604
+ */
1605
+ exitApp: function () {
1606
+ return exec(null, null, APP_PLUGIN_NAME, 'exitApp', []);
1607
+ }
1608
+ };
1609
+
1610
+ });
1611
+
1612
+ // file: ../../cordova-js-src/plugin/android/splashscreen.js
1613
+ define("cordova/plugin/android/splashscreen", function(require, exports, module) {
1614
+
1615
+ var exec = require('cordova/exec');
1616
+
1617
+ var splashscreen = {
1618
+ show: function () {
1619
+ console.log('"navigator.splashscreen.show()" is unsupported on Android.');
1620
+ },
1621
+ hide: function () {
1622
+ exec(null, null, 'CordovaSplashScreenPlugin', 'hide', []);
1623
+ }
1624
+ };
1625
+
1626
+ module.exports = splashscreen;
1627
+
1628
+ });
1629
+
1630
+ // file: src/common/pluginloader.js
1631
+ define("cordova/pluginloader", function(require, exports, module) {
1632
+
1633
+ var modulemapper = require('cordova/modulemapper');
1634
+
1635
+ // Helper function to inject a <script> tag.
1636
+ // Exported for testing.
1637
+ exports.injectScript = function (url, onload, onerror) {
1638
+ var script = document.createElement('script');
1639
+ // onload fires even when script fails loads with an error.
1640
+ script.onload = onload;
1641
+ // onerror fires for malformed URLs.
1642
+ script.onerror = onerror;
1643
+ script.src = url;
1644
+ document.head.appendChild(script);
1645
+ };
1646
+
1647
+ function injectIfNecessary (id, url, onload, onerror) {
1648
+ onerror = onerror || onload;
1649
+ if (id in define.moduleMap) {
1650
+ onload();
1651
+ } else {
1652
+ exports.injectScript(url, function () {
1653
+ if (id in define.moduleMap) {
1654
+ onload();
1655
+ } else {
1656
+ onerror();
1657
+ }
1658
+ }, onerror);
1659
+ }
1660
+ }
1661
+
1662
+ function onScriptLoadingComplete (moduleList, finishPluginLoading) {
1663
+ // Loop through all the plugins and then through their clobbers and merges.
1664
+ for (var i = 0, module; (module = moduleList[i]); i++) {
1665
+ if (module.clobbers && module.clobbers.length) {
1666
+ for (var j = 0; j < module.clobbers.length; j++) {
1667
+ modulemapper.clobbers(module.id, module.clobbers[j]);
1668
+ }
1669
+ }
1670
+
1671
+ if (module.merges && module.merges.length) {
1672
+ for (var k = 0; k < module.merges.length; k++) {
1673
+ modulemapper.merges(module.id, module.merges[k]);
1674
+ }
1675
+ }
1676
+
1677
+ // Finally, if runs is truthy we want to simply require() the module.
1678
+ if (module.runs) {
1679
+ modulemapper.runs(module.id);
1680
+ }
1681
+ }
1682
+
1683
+ finishPluginLoading();
1684
+ }
1685
+
1686
+ // Handler for the cordova_plugins.js content.
1687
+ // See plugman's plugin_loader.js for the details of this object.
1688
+ // This function is only called if the really is a plugins array that isn't empty.
1689
+ // Otherwise the onerror response handler will just call finishPluginLoading().
1690
+ function handlePluginsObject (path, moduleList, finishPluginLoading) {
1691
+ // Now inject the scripts.
1692
+ var scriptCounter = moduleList.length;
1693
+
1694
+ if (!scriptCounter) {
1695
+ finishPluginLoading();
1696
+ return;
1697
+ }
1698
+ function scriptLoadedCallback () {
1699
+ if (!--scriptCounter) {
1700
+ onScriptLoadingComplete(moduleList, finishPluginLoading);
1701
+ }
1702
+ }
1703
+
1704
+ for (var i = 0; i < moduleList.length; i++) {
1705
+ injectIfNecessary(moduleList[i].id, path + moduleList[i].file, scriptLoadedCallback);
1706
+ }
1707
+ }
1708
+
1709
+ function findCordovaPath () {
1710
+ var path = null;
1711
+ var scripts = document.getElementsByTagName('script');
1712
+ var term = '/cordova.js';
1713
+ for (var n = scripts.length - 1; n > -1; n--) {
1714
+ var src = scripts[n].src.replace(/\?.*$/, ''); // Strip any query param (CB-6007).
1715
+ if (src.indexOf(term) === (src.length - term.length)) {
1716
+ path = src.substring(0, src.length - term.length) + '/';
1717
+ break;
1718
+ }
1719
+ }
1720
+ return path;
1721
+ }
1722
+
1723
+ // Tries to load all plugins' js-modules.
1724
+ // This is an async process, but onDeviceReady is blocked on onPluginsReady.
1725
+ // onPluginsReady is fired when there are no plugins to load, or they are all done.
1726
+ exports.load = function (callback) {
1727
+ var pathPrefix = findCordovaPath();
1728
+ if (pathPrefix === null) {
1729
+ console.log('Could not find cordova.js script tag. Plugin loading may fail.');
1730
+ pathPrefix = '';
1731
+ }
1732
+ injectIfNecessary('cordova/plugin_list', pathPrefix + 'cordova_plugins.js', function () {
1733
+ var moduleList = require('cordova/plugin_list');
1734
+ handlePluginsObject(pathPrefix, moduleList, callback);
1735
+ }, callback);
1736
+ };
1737
+
1738
+ });
1739
+
1740
+ // file: src/common/urlutil.js
1741
+ define("cordova/urlutil", function(require, exports, module) {
1742
+
1743
+ /**
1744
+ * For already absolute URLs, returns what is passed in.
1745
+ * For relative URLs, converts them to absolute ones.
1746
+ */
1747
+ exports.makeAbsolute = function makeAbsolute (url) {
1748
+ var anchorEl = document.createElement('a');
1749
+ anchorEl.href = url;
1750
+ return anchorEl.href;
1751
+ };
1752
+
1753
+ });
1754
+
1755
+ // file: src/common/utils.js
1756
+ define("cordova/utils", function(require, exports, module) {
1757
+
1758
+ var utils = exports;
1759
+
1760
+ /**
1761
+ * Defines a property getter / setter for obj[key].
1762
+ */
1763
+ utils.defineGetterSetter = function (obj, key, getFunc, opt_setFunc) {
1764
+ if (Object.defineProperty) {
1765
+ var desc = {
1766
+ get: getFunc,
1767
+ configurable: true
1768
+ };
1769
+ if (opt_setFunc) {
1770
+ desc.set = opt_setFunc;
1771
+ }
1772
+ Object.defineProperty(obj, key, desc);
1773
+ } else {
1774
+ obj.__defineGetter__(key, getFunc);
1775
+ if (opt_setFunc) {
1776
+ obj.__defineSetter__(key, opt_setFunc);
1777
+ }
1778
+ }
1779
+ };
1780
+
1781
+ /**
1782
+ * Defines a property getter for obj[key].
1783
+ */
1784
+ utils.defineGetter = utils.defineGetterSetter;
1785
+
1786
+ utils.arrayIndexOf = function (a, item) {
1787
+ if (a.indexOf) {
1788
+ return a.indexOf(item);
1789
+ }
1790
+ var len = a.length;
1791
+ for (var i = 0; i < len; ++i) {
1792
+ if (a[i] === item) {
1793
+ return i;
1794
+ }
1795
+ }
1796
+ return -1;
1797
+ };
1798
+
1799
+ /**
1800
+ * Returns whether the item was found in the array.
1801
+ */
1802
+ utils.arrayRemove = function (a, item) {
1803
+ var index = utils.arrayIndexOf(a, item);
1804
+ if (index !== -1) {
1805
+ a.splice(index, 1);
1806
+ }
1807
+ return index !== -1;
1808
+ };
1809
+
1810
+ utils.typeName = function (val) {
1811
+ return Object.prototype.toString.call(val).slice(8, -1);
1812
+ };
1813
+
1814
+ /**
1815
+ * Returns an indication of whether the argument is an array or not
1816
+ */
1817
+ utils.isArray = Array.isArray ||
1818
+ function (a) { return utils.typeName(a) === 'Array'; };
1819
+
1820
+ /**
1821
+ * Returns an indication of whether the argument is a Date or not
1822
+ */
1823
+ utils.isDate = function (d) {
1824
+ return (d instanceof Date);
1825
+ };
1826
+
1827
+ /**
1828
+ * Does a deep clone of the object.
1829
+ */
1830
+ utils.clone = function (obj) {
1831
+ if (!obj || typeof obj === 'function' || utils.isDate(obj) || typeof obj !== 'object') {
1832
+ return obj;
1833
+ }
1834
+
1835
+ var retVal, i;
1836
+
1837
+ if (utils.isArray(obj)) {
1838
+ retVal = [];
1839
+ for (i = 0; i < obj.length; ++i) {
1840
+ retVal.push(utils.clone(obj[i]));
1841
+ }
1842
+ return retVal;
1843
+ }
1844
+
1845
+ retVal = {};
1846
+ for (i in obj) {
1847
+ // 'unknown' type may be returned in custom protocol activation case on
1848
+ // Windows Phone 8.1 causing "No such interface supported" exception on
1849
+ // cloning (https://issues.apache.org/jira/browse/CB-11522)
1850
+ // eslint-disable-next-line valid-typeof
1851
+ if ((!(i in retVal) || retVal[i] !== obj[i]) && typeof obj[i] !== 'undefined' && typeof obj[i] !== 'unknown') {
1852
+ retVal[i] = utils.clone(obj[i]);
1853
+ }
1854
+ }
1855
+ return retVal;
1856
+ };
1857
+
1858
+ /**
1859
+ * Returns a wrapped version of the function
1860
+ */
1861
+ utils.close = function (context, func, params) {
1862
+ return function () {
1863
+ var args = params || arguments;
1864
+ return func.apply(context, args);
1865
+ };
1866
+ };
1867
+
1868
+ // ------------------------------------------------------------------------------
1869
+ function UUIDcreatePart (length) {
1870
+ var uuidpart = '';
1871
+ for (var i = 0; i < length; i++) {
1872
+ var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
1873
+ if (uuidchar.length === 1) {
1874
+ uuidchar = '0' + uuidchar;
1875
+ }
1876
+ uuidpart += uuidchar;
1877
+ }
1878
+ return uuidpart;
1879
+ }
1880
+
1881
+ /**
1882
+ * Create a UUID
1883
+ */
1884
+ utils.createUUID = function () {
1885
+ return UUIDcreatePart(4) + '-' +
1886
+ UUIDcreatePart(2) + '-' +
1887
+ UUIDcreatePart(2) + '-' +
1888
+ UUIDcreatePart(2) + '-' +
1889
+ UUIDcreatePart(6);
1890
+ };
1891
+
1892
+ /**
1893
+ * Extends a child object from a parent object using classical inheritance
1894
+ * pattern.
1895
+ */
1896
+ utils.extend = (function () {
1897
+ // proxy used to establish prototype chain
1898
+ var F = function () {};
1899
+ // extend Child from Parent
1900
+ return function (Child, Parent) {
1901
+ F.prototype = Parent.prototype;
1902
+ Child.prototype = new F();
1903
+ Child.__super__ = Parent.prototype;
1904
+ Child.prototype.constructor = Child;
1905
+ };
1906
+ }());
1907
+
1908
+ /**
1909
+ * Alerts a message in any available way: alert or console.log.
1910
+ */
1911
+ utils.alert = function (msg) {
1912
+ if (window.alert) {
1913
+ window.alert(msg);
1914
+ } else if (console && console.log) {
1915
+ console.log(msg);
1916
+ }
1917
+ };
1918
+
1919
+ });
1920
+
1921
+ window.cordova = require('cordova');
1922
+ // file: src/scripts/bootstrap.js
1923
+ require('cordova/init');
1924
+
1925
+ })();