tabris 3.8.0-dev.20210928 → 3.8.0-dev.20211003
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.
- package/boot.js +1 -1
- package/package.json +1 -1
- package/tabris.d.ts +22 -1
- package/tabris.js +393 -262
- package/tabris.min.js +1 -1
package/tabris.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Tabris.js 3.8.0-dev.
|
|
2
|
+
* Tabris.js 3.8.0-dev.20211003+0318
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2014, 2020 EclipseSource Inc.
|
|
5
5
|
* All rights reserved.
|
|
@@ -689,7 +689,7 @@ class Console {
|
|
|
689
689
|
for (const level of ['debug', 'info', 'log', 'warn', 'error']) {
|
|
690
690
|
this._console[level] = (...args) => {
|
|
691
691
|
const message = this._prepareOutput(...args);
|
|
692
|
-
tabris.trigger('log', { level, message });
|
|
692
|
+
tabris.trigger('log', { level, message, logTime: Date.now() });
|
|
693
693
|
nativeConsole.print(level, message);
|
|
694
694
|
};
|
|
695
695
|
}
|
|
@@ -4705,12 +4705,299 @@ class NativeObjectRegistry {
|
|
|
4705
4705
|
}
|
|
4706
4706
|
}
|
|
4707
4707
|
|
|
4708
|
+
const PHASE_CONSTANTS = {
|
|
4709
|
+
NONE: { value: 0 },
|
|
4710
|
+
CAPTURING_PHASE: { value: 1 },
|
|
4711
|
+
AT_TARGET: { value: 2 },
|
|
4712
|
+
BUBBLING_PHASE: { value: 3 }
|
|
4713
|
+
};
|
|
4714
|
+
class Event {
|
|
4715
|
+
constructor(type, config) {
|
|
4716
|
+
if (arguments.length < 1) {
|
|
4717
|
+
throw new Error('Not enough arguments to Event');
|
|
4718
|
+
}
|
|
4719
|
+
Object.defineProperties(this, {
|
|
4720
|
+
$timeStamp: { enumerable: false, writable: true, value: Date.now() },
|
|
4721
|
+
$type: { enumerable: false, writable: true, value: type || '' },
|
|
4722
|
+
$bubbles: { enumerable: false, writable: true, value: config && !!config.bubbles || false },
|
|
4723
|
+
$cancelable: { enumerable: false, writable: true, value: config && !!config.cancelable || false },
|
|
4724
|
+
$target: { enumerable: false, writable: true, value: null },
|
|
4725
|
+
$defaultPrevented: { enumerable: false, writable: true, value: false }
|
|
4726
|
+
});
|
|
4727
|
+
}
|
|
4728
|
+
initEvent(type, bubbles, cancelable) {
|
|
4729
|
+
if (arguments.length < 3) {
|
|
4730
|
+
throw new Error('Not enough arguments to initEvent');
|
|
4731
|
+
}
|
|
4732
|
+
this.$type = type + '';
|
|
4733
|
+
this.$bubbles = !!bubbles;
|
|
4734
|
+
this.$cancelable = !!cancelable;
|
|
4735
|
+
}
|
|
4736
|
+
get type() {
|
|
4737
|
+
return this.$type;
|
|
4738
|
+
}
|
|
4739
|
+
get timeStamp() {
|
|
4740
|
+
return this.$timeStamp;
|
|
4741
|
+
}
|
|
4742
|
+
get bubbles() {
|
|
4743
|
+
return this.$bubbles;
|
|
4744
|
+
}
|
|
4745
|
+
get cancelable() {
|
|
4746
|
+
return this.$cancelable;
|
|
4747
|
+
}
|
|
4748
|
+
get target() {
|
|
4749
|
+
return this.$target;
|
|
4750
|
+
}
|
|
4751
|
+
get currentTarget() {
|
|
4752
|
+
return this.$target;
|
|
4753
|
+
}
|
|
4754
|
+
get defaultPrevented() {
|
|
4755
|
+
return this.$defaultPrevented;
|
|
4756
|
+
}
|
|
4757
|
+
get eventPhase() {
|
|
4758
|
+
return 0;
|
|
4759
|
+
}
|
|
4760
|
+
get isTrusted() {
|
|
4761
|
+
return false;
|
|
4762
|
+
}
|
|
4763
|
+
stopPropagation() {
|
|
4764
|
+
}
|
|
4765
|
+
stopImmediatePropagation() {
|
|
4766
|
+
}
|
|
4767
|
+
preventDefault() {
|
|
4768
|
+
if (this.$cancelable) {
|
|
4769
|
+
this.$defaultPrevented = true;
|
|
4770
|
+
}
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
Object.defineProperties(Event, PHASE_CONSTANTS);
|
|
4774
|
+
Object.defineProperties(Event.prototype, PHASE_CONSTANTS);
|
|
4775
|
+
function addDOMEventTargetMethods(target) {
|
|
4776
|
+
if (typeof target.addEventListener === 'function') {
|
|
4777
|
+
return;
|
|
4778
|
+
}
|
|
4779
|
+
let listeners;
|
|
4780
|
+
target.addEventListener = function (type, listener /* , useCapture*/) {
|
|
4781
|
+
if (arguments.length < 2) {
|
|
4782
|
+
throw new Error('Not enough arguments to addEventListener');
|
|
4783
|
+
}
|
|
4784
|
+
if (!listeners) {
|
|
4785
|
+
listeners = [];
|
|
4786
|
+
}
|
|
4787
|
+
if (!(type in listeners)) {
|
|
4788
|
+
listeners[type] = [];
|
|
4789
|
+
}
|
|
4790
|
+
if (!listeners[type].includes(listener)) {
|
|
4791
|
+
listeners[type].push(listener);
|
|
4792
|
+
}
|
|
4793
|
+
};
|
|
4794
|
+
target.removeEventListener = function (type, listener /* , useCapture */) {
|
|
4795
|
+
if (arguments.length < 2) {
|
|
4796
|
+
throw new Error('Not enough arguments to removeEventListener');
|
|
4797
|
+
}
|
|
4798
|
+
if (listeners && type in listeners) {
|
|
4799
|
+
const index = listeners[type].indexOf(listener);
|
|
4800
|
+
if (index !== -1) {
|
|
4801
|
+
listeners[type].splice(index, 1);
|
|
4802
|
+
}
|
|
4803
|
+
}
|
|
4804
|
+
};
|
|
4805
|
+
target.dispatchEvent = function (event) {
|
|
4806
|
+
if (arguments.length < 1) {
|
|
4807
|
+
throw new Error('Not enough arguments to dispatchEvent');
|
|
4808
|
+
}
|
|
4809
|
+
if (!(event instanceof Event)) {
|
|
4810
|
+
throw new Error('Invalid event given to dispatchEvent');
|
|
4811
|
+
}
|
|
4812
|
+
event.$target = target;
|
|
4813
|
+
if (listeners && event.type in listeners) {
|
|
4814
|
+
for (const listener of listeners[event.type]) {
|
|
4815
|
+
listener.call(this, event);
|
|
4816
|
+
}
|
|
4817
|
+
}
|
|
4818
|
+
return !event.defaultPrevented;
|
|
4819
|
+
};
|
|
4820
|
+
}
|
|
4821
|
+
function defineEventHandlerProperties(target, types) {
|
|
4822
|
+
types.forEach(type => defineEventHandlerProperty(target, type));
|
|
4823
|
+
}
|
|
4824
|
+
function defineEventHandlerProperty(target, type) {
|
|
4825
|
+
const handler = 'on' + type;
|
|
4826
|
+
if (handler in target) {
|
|
4827
|
+
return;
|
|
4828
|
+
}
|
|
4829
|
+
let listener = null;
|
|
4830
|
+
Object.defineProperty(target, handler, {
|
|
4831
|
+
get() {
|
|
4832
|
+
return listener;
|
|
4833
|
+
},
|
|
4834
|
+
set(value) {
|
|
4835
|
+
// ignore other types, mimicks the behavior of Firefox and Chromium
|
|
4836
|
+
if (typeof value === 'function') {
|
|
4837
|
+
if (listener) {
|
|
4838
|
+
target.removeEventListener(type, listener);
|
|
4839
|
+
}
|
|
4840
|
+
listener = value;
|
|
4841
|
+
target.addEventListener(type, listener);
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
});
|
|
4845
|
+
}
|
|
4846
|
+
|
|
4847
|
+
class ImageData {
|
|
4848
|
+
constructor() {
|
|
4849
|
+
if (arguments.length < 2) {
|
|
4850
|
+
throw new TypeError('Not enough arguments to ImageData');
|
|
4851
|
+
}
|
|
4852
|
+
let array, width, height;
|
|
4853
|
+
if (arguments[0] instanceof Uint8ClampedArray) {
|
|
4854
|
+
array = checkArray(arguments[0]);
|
|
4855
|
+
width = checkSize(arguments[1]);
|
|
4856
|
+
height = arguments.length > 2 ? checkSize(arguments[2]) : array.byteLength / 4 / width;
|
|
4857
|
+
if (array.byteLength !== width * height * 4) {
|
|
4858
|
+
throw new Error('Wrong array size');
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
else {
|
|
4862
|
+
width = checkSize(arguments[0]);
|
|
4863
|
+
height = checkSize(arguments[1]);
|
|
4864
|
+
array = new Uint8ClampedArray(width * height * 4);
|
|
4865
|
+
}
|
|
4866
|
+
Object.defineProperties(this, {
|
|
4867
|
+
data: { value: array },
|
|
4868
|
+
width: { value: width },
|
|
4869
|
+
height: { value: height }
|
|
4870
|
+
});
|
|
4871
|
+
}
|
|
4872
|
+
}
|
|
4873
|
+
Object.defineProperty(ImageData.prototype, 'data', { value: /** @type {Uint8ClampedArray} */ (null) });
|
|
4874
|
+
Object.defineProperty(ImageData.prototype, 'width', { value: 0 });
|
|
4875
|
+
Object.defineProperty(ImageData.prototype, 'height', { value: 0 });
|
|
4876
|
+
function checkArray(array) {
|
|
4877
|
+
if (array.byteLength % 4 !== 0) {
|
|
4878
|
+
throw new Error('Illegal array length');
|
|
4879
|
+
}
|
|
4880
|
+
return array;
|
|
4881
|
+
}
|
|
4882
|
+
function checkSize(input) {
|
|
4883
|
+
const size = Math.floor(input);
|
|
4884
|
+
if (size <= 0 || !isFinite(size)) {
|
|
4885
|
+
throw new Error('Illegal size for ImageData');
|
|
4886
|
+
}
|
|
4887
|
+
return size;
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
const EVENT_TYPES = ['message', 'error', 'messageerror'];
|
|
4891
|
+
class _Worker extends NativeObject {
|
|
4892
|
+
get _nativeType() {
|
|
4893
|
+
return 'tabris.Worker';
|
|
4894
|
+
}
|
|
4895
|
+
postMessage(param) {
|
|
4896
|
+
this._nativeCall('postMessage', param);
|
|
4897
|
+
}
|
|
4898
|
+
terminate() {
|
|
4899
|
+
this._nativeCall('terminate');
|
|
4900
|
+
}
|
|
4901
|
+
}
|
|
4902
|
+
NativeObject.defineProperties(_Worker.prototype, {
|
|
4903
|
+
scriptPath: { type: 'string', const: true, default: '' }
|
|
4904
|
+
});
|
|
4905
|
+
NativeObject.defineEvents(_Worker.prototype, {
|
|
4906
|
+
message: { native: true },
|
|
4907
|
+
error: { native: true },
|
|
4908
|
+
messageError: true
|
|
4909
|
+
});
|
|
4910
|
+
class Worker {
|
|
4911
|
+
constructor(scriptPath) {
|
|
4912
|
+
if (typeof scriptPath !== 'string') {
|
|
4913
|
+
throw new Error('The Worker script path has to be of type string');
|
|
4914
|
+
}
|
|
4915
|
+
addDOMEventTargetMethods(this);
|
|
4916
|
+
defineEventHandlerProperties(this, EVENT_TYPES);
|
|
4917
|
+
Object.defineProperty(this, '_nativeObject', {
|
|
4918
|
+
enumerable: false, writable: false, value: this.$createNativeObject(scriptPath)
|
|
4919
|
+
});
|
|
4920
|
+
}
|
|
4921
|
+
$createNativeObject(scriptPath) {
|
|
4922
|
+
return new _Worker({
|
|
4923
|
+
scriptPath
|
|
4924
|
+
}).on({
|
|
4925
|
+
_message: ({ data, logs, internal }) => {
|
|
4926
|
+
try {
|
|
4927
|
+
if (logs instanceof Array) {
|
|
4928
|
+
for (const logData of logs) {
|
|
4929
|
+
tabris.trigger('log', logData);
|
|
4930
|
+
}
|
|
4931
|
+
}
|
|
4932
|
+
}
|
|
4933
|
+
finally {
|
|
4934
|
+
if (!internal) {
|
|
4935
|
+
this.dispatchEvent(Object.assign(new Event('message'), { data }));
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
},
|
|
4939
|
+
_error: ({ message }) => {
|
|
4940
|
+
this.dispatchEvent(Object.assign(new Event('error'), { message }));
|
|
4941
|
+
},
|
|
4942
|
+
_messageError: ({ message }) => {
|
|
4943
|
+
this.dispatchEvent(Object.assign(new Event('messageerror'), { message }));
|
|
4944
|
+
}
|
|
4945
|
+
});
|
|
4946
|
+
}
|
|
4947
|
+
postMessage(data, transferList) {
|
|
4948
|
+
validateMessage(data);
|
|
4949
|
+
this._nativeObject._nativeCall('postMessage', { data, transferList });
|
|
4950
|
+
}
|
|
4951
|
+
terminate() {
|
|
4952
|
+
this._nativeObject._nativeCall('postMessage', { internal: true, data: 'terminate' });
|
|
4953
|
+
this._nativeObject._nativeCall('terminate');
|
|
4954
|
+
}
|
|
4955
|
+
}
|
|
4956
|
+
function validateMessage(message) {
|
|
4957
|
+
if (!isValidMessage(message)) {
|
|
4958
|
+
throw new TypeError('The message could not be cloned');
|
|
4959
|
+
}
|
|
4960
|
+
else {
|
|
4961
|
+
if (message instanceof Array) {
|
|
4962
|
+
for (const messageEntry of message) {
|
|
4963
|
+
validateMessage(messageEntry);
|
|
4964
|
+
}
|
|
4965
|
+
}
|
|
4966
|
+
else if (typeof (message) === 'object') {
|
|
4967
|
+
for (const property in message) {
|
|
4968
|
+
if (Object.prototype.hasOwnProperty.call(message, property)) {
|
|
4969
|
+
validateMessage(message[property]);
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
}
|
|
4975
|
+
function isValidMessage(message) {
|
|
4976
|
+
return message === undefined ||
|
|
4977
|
+
message === null ||
|
|
4978
|
+
typeof message === 'string' ||
|
|
4979
|
+
typeof message === 'number' ||
|
|
4980
|
+
typeof message === 'boolean' ||
|
|
4981
|
+
message && typeof message === 'object' &&
|
|
4982
|
+
(message.constructor === Object ||
|
|
4983
|
+
message.constructor === Array ||
|
|
4984
|
+
message.constructor === DataView ||
|
|
4985
|
+
message.constructor === ArrayBuffer ||
|
|
4986
|
+
message.constructor === ImageData);
|
|
4987
|
+
}
|
|
4988
|
+
|
|
4708
4989
|
class Tabris extends NativeObject {
|
|
4709
4990
|
constructor() {
|
|
4710
4991
|
super();
|
|
4992
|
+
this._logPushInterval = -1;
|
|
4993
|
+
this._logBuffer = null;
|
|
4994
|
+
this._pushBufferTimer = null;
|
|
4711
4995
|
Object.defineProperties(this, {
|
|
4712
4996
|
_started: { enumerable: false, writable: true, value: false },
|
|
4713
4997
|
_init: { enumerable: false, writable: true, value: this._init.bind(this) },
|
|
4998
|
+
postMessage: { enumerable: false, value: this.postMessage.bind(this) },
|
|
4999
|
+
close: { enumerable: false, value: this.close.bind(this) },
|
|
5000
|
+
$sendLogBufferInternal: { enumerable: false, value: this.$sendLogBufferInternal.bind(this) },
|
|
4714
5001
|
_notify: { enumerable: false, writable: true, value: this._notify.bind(this) },
|
|
4715
5002
|
_stackTraceStack: { enumerable: false, writable: true, value: [] },
|
|
4716
5003
|
_nativeObjectRegistry: { enumerable: false, writable: true, value: null },
|
|
@@ -4721,17 +5008,48 @@ class Tabris extends NativeObject {
|
|
|
4721
5008
|
this.$publishProxies();
|
|
4722
5009
|
}
|
|
4723
5010
|
get version() {
|
|
4724
|
-
return '3.8.0-dev.
|
|
5011
|
+
return '3.8.0-dev.20211003+0318';
|
|
4725
5012
|
}
|
|
4726
5013
|
get started() {
|
|
4727
5014
|
return !!this._started;
|
|
4728
5015
|
}
|
|
5016
|
+
get logPushInterval() {
|
|
5017
|
+
return this._logPushInterval;
|
|
5018
|
+
}
|
|
5019
|
+
set logPushInterval(value) {
|
|
5020
|
+
this._logPushInterval = value;
|
|
5021
|
+
if (this.headless && this.logPushInterval > -1) {
|
|
5022
|
+
this.on('_log', this.$logToBuffer, this);
|
|
5023
|
+
this.$logToBuffer({});
|
|
5024
|
+
}
|
|
5025
|
+
else {
|
|
5026
|
+
this._logBuffer = null;
|
|
5027
|
+
this.off('_log', this.$logToBuffer, this);
|
|
5028
|
+
}
|
|
5029
|
+
}
|
|
4729
5030
|
flush() {
|
|
4730
5031
|
this.trigger('tick');
|
|
4731
5032
|
this.trigger('flush');
|
|
4732
5033
|
this._nativeBridge.clearCache();
|
|
4733
5034
|
this._nativeBridge.flush();
|
|
4734
5035
|
}
|
|
5036
|
+
postMessage(data, transferList) {
|
|
5037
|
+
if (this.headless) {
|
|
5038
|
+
validateMessage(data);
|
|
5039
|
+
const logs = this.logPushInterval >= 0 ? this._logBuffer : null;
|
|
5040
|
+
const internal = false;
|
|
5041
|
+
this._nativeCall('postMessage', { data, transferList, logs, internal });
|
|
5042
|
+
if (logs) {
|
|
5043
|
+
this._logBuffer = null;
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
close() {
|
|
5048
|
+
if (this.headless) {
|
|
5049
|
+
this.$sendLogBufferInternal();
|
|
5050
|
+
this._nativeCall('close', {});
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
4735
5053
|
get _nativeType() {
|
|
4736
5054
|
return 'tabris.Tabris';
|
|
4737
5055
|
}
|
|
@@ -4744,12 +5062,23 @@ class Tabris extends NativeObject {
|
|
|
4744
5062
|
Object.defineProperty(this, 'cid', { value: cid });
|
|
4745
5063
|
}
|
|
4746
5064
|
_init(client, options) {
|
|
5065
|
+
var _a;
|
|
4747
5066
|
this._client = client;
|
|
5067
|
+
Object.defineProperty(this, 'headless', { writable: false, value: !!(options === null || options === void 0 ? void 0 : options.headless) });
|
|
4748
5068
|
this._nativeBridge = new NativeBridge(client);
|
|
4749
5069
|
this._register();
|
|
4750
5070
|
this._nativeBridge.create(this.cid, this._nativeType);
|
|
5071
|
+
if (this.headless) {
|
|
5072
|
+
this.on('_log', this.$logToBuffer, this);
|
|
5073
|
+
this._listen('message', true);
|
|
5074
|
+
}
|
|
4751
5075
|
this.trigger('start', options || { headless: false });
|
|
5076
|
+
if ((_a = this.$app) === null || _a === void 0 ? void 0 : _a.debugBuild) {
|
|
5077
|
+
this.logPushInterval = 2000;
|
|
5078
|
+
}
|
|
4752
5079
|
this._started = true;
|
|
5080
|
+
global.postMessage = this.postMessage;
|
|
5081
|
+
global.close = this.close;
|
|
4753
5082
|
}
|
|
4754
5083
|
_setEntryPoint(entryPoint) {
|
|
4755
5084
|
this._entryPoint = entryPoint;
|
|
@@ -4777,6 +5106,15 @@ class Tabris extends NativeObject {
|
|
|
4777
5106
|
}
|
|
4778
5107
|
return returnValue;
|
|
4779
5108
|
}
|
|
5109
|
+
_trigger(event, param) {
|
|
5110
|
+
if (event === 'message') {
|
|
5111
|
+
return this.$handleMessage(param);
|
|
5112
|
+
}
|
|
5113
|
+
else if (event === 'messageError') {
|
|
5114
|
+
return this.$handleMessageError(param);
|
|
5115
|
+
}
|
|
5116
|
+
return super._trigger(event, param);
|
|
5117
|
+
}
|
|
4780
5118
|
$publishProxies() {
|
|
4781
5119
|
[
|
|
4782
5120
|
'contentView', 'drawer', 'navigationBar', 'statusBar', 'permission', 'printer', 'device', 'app', 'localStorage',
|
|
@@ -4786,12 +5124,57 @@ class Tabris extends NativeObject {
|
|
|
4786
5124
|
Object.defineProperty(this, name, { value });
|
|
4787
5125
|
});
|
|
4788
5126
|
}
|
|
5127
|
+
$logToBuffer({ level, message }) {
|
|
5128
|
+
if (!this._logBuffer) {
|
|
5129
|
+
this._logBuffer = [];
|
|
5130
|
+
}
|
|
5131
|
+
if (level) {
|
|
5132
|
+
this._logBuffer.push({ level, message, logTime: Date.now() });
|
|
5133
|
+
}
|
|
5134
|
+
if (this.logPushInterval > -1 && this._pushBufferTimer === null) {
|
|
5135
|
+
this._pushBufferTimer = setTimeout(this.$sendLogBufferInternal, this.logPushInterval);
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
$handleMessage({ internal, data }) {
|
|
5139
|
+
if (internal) {
|
|
5140
|
+
if (data === 'terminate') {
|
|
5141
|
+
this.$sendLogBufferInternal();
|
|
5142
|
+
}
|
|
5143
|
+
}
|
|
5144
|
+
else {
|
|
5145
|
+
this.trigger('message', { data });
|
|
5146
|
+
const event = Object.assign(new Event('message'), { data });
|
|
5147
|
+
global.dispatchEvent(event);
|
|
5148
|
+
}
|
|
5149
|
+
return false;
|
|
5150
|
+
}
|
|
5151
|
+
$sendLogBufferInternal() {
|
|
5152
|
+
const logs = this._logBuffer;
|
|
5153
|
+
this._pushBufferTimer = null;
|
|
5154
|
+
this._logBuffer = null;
|
|
5155
|
+
if (this.logPushInterval === -1) {
|
|
5156
|
+
this.off('_log', this.$logToBuffer, this);
|
|
5157
|
+
return;
|
|
5158
|
+
}
|
|
5159
|
+
if (!logs) {
|
|
5160
|
+
return;
|
|
5161
|
+
}
|
|
5162
|
+
this._nativeCall('postMessage', { logs, internal: true });
|
|
5163
|
+
}
|
|
5164
|
+
$handleMessageError(rawEvent) {
|
|
5165
|
+
this.trigger('messageError', rawEvent);
|
|
5166
|
+
const event = Object.assign(new Event('messageerror'), { data: rawEvent.data });
|
|
5167
|
+
global.dispatchEvent(event);
|
|
5168
|
+
return false;
|
|
5169
|
+
}
|
|
4789
5170
|
}
|
|
4790
5171
|
NativeObject.defineEvents(Tabris.prototype, {
|
|
4791
5172
|
start: {},
|
|
4792
5173
|
flush: {},
|
|
4793
5174
|
layout: {},
|
|
4794
|
-
log: {}
|
|
5175
|
+
log: {},
|
|
5176
|
+
message: { native: true },
|
|
5177
|
+
messageError: { native: true }
|
|
4795
5178
|
});
|
|
4796
5179
|
|
|
4797
5180
|
const SUPPORTED_ENCODINGS = ['ascii', 'utf-8'];
|
|
@@ -5096,49 +5479,6 @@ function defineReadOnlyProperty(target, name, getter) {
|
|
|
5096
5479
|
});
|
|
5097
5480
|
}
|
|
5098
5481
|
|
|
5099
|
-
class ImageData {
|
|
5100
|
-
constructor() {
|
|
5101
|
-
if (arguments.length < 2) {
|
|
5102
|
-
throw new TypeError('Not enough arguments to ImageData');
|
|
5103
|
-
}
|
|
5104
|
-
let array, width, height;
|
|
5105
|
-
if (arguments[0] instanceof Uint8ClampedArray) {
|
|
5106
|
-
array = checkArray(arguments[0]);
|
|
5107
|
-
width = checkSize(arguments[1]);
|
|
5108
|
-
height = arguments.length > 2 ? checkSize(arguments[2]) : array.byteLength / 4 / width;
|
|
5109
|
-
if (array.byteLength !== width * height * 4) {
|
|
5110
|
-
throw new Error('Wrong array size');
|
|
5111
|
-
}
|
|
5112
|
-
}
|
|
5113
|
-
else {
|
|
5114
|
-
width = checkSize(arguments[0]);
|
|
5115
|
-
height = checkSize(arguments[1]);
|
|
5116
|
-
array = new Uint8ClampedArray(width * height * 4);
|
|
5117
|
-
}
|
|
5118
|
-
Object.defineProperties(this, {
|
|
5119
|
-
data: { value: array },
|
|
5120
|
-
width: { value: width },
|
|
5121
|
-
height: { value: height }
|
|
5122
|
-
});
|
|
5123
|
-
}
|
|
5124
|
-
}
|
|
5125
|
-
Object.defineProperty(ImageData.prototype, 'data', { value: /** @type {Uint8ClampedArray} */ (null) });
|
|
5126
|
-
Object.defineProperty(ImageData.prototype, 'width', { value: 0 });
|
|
5127
|
-
Object.defineProperty(ImageData.prototype, 'height', { value: 0 });
|
|
5128
|
-
function checkArray(array) {
|
|
5129
|
-
if (array.byteLength % 4 !== 0) {
|
|
5130
|
-
throw new Error('Illegal array length');
|
|
5131
|
-
}
|
|
5132
|
-
return array;
|
|
5133
|
-
}
|
|
5134
|
-
function checkSize(input) {
|
|
5135
|
-
const size = Math.floor(input);
|
|
5136
|
-
if (size <= 0 || !isFinite(size)) {
|
|
5137
|
-
throw new Error('Illegal size for ImageData');
|
|
5138
|
-
}
|
|
5139
|
-
return size;
|
|
5140
|
-
}
|
|
5141
|
-
|
|
5142
5482
|
const OPCODES = {
|
|
5143
5483
|
arc: 1,
|
|
5144
5484
|
arcTo: 2,
|
|
@@ -7945,142 +8285,6 @@ function create$7() {
|
|
|
7945
8285
|
return new DevTools(true);
|
|
7946
8286
|
}
|
|
7947
8287
|
|
|
7948
|
-
const PHASE_CONSTANTS = {
|
|
7949
|
-
NONE: { value: 0 },
|
|
7950
|
-
CAPTURING_PHASE: { value: 1 },
|
|
7951
|
-
AT_TARGET: { value: 2 },
|
|
7952
|
-
BUBBLING_PHASE: { value: 3 }
|
|
7953
|
-
};
|
|
7954
|
-
class Event {
|
|
7955
|
-
constructor(type, config) {
|
|
7956
|
-
if (arguments.length < 1) {
|
|
7957
|
-
throw new Error('Not enough arguments to Event');
|
|
7958
|
-
}
|
|
7959
|
-
Object.defineProperties(this, {
|
|
7960
|
-
$timeStamp: { enumerable: false, writable: true, value: Date.now() },
|
|
7961
|
-
$type: { enumerable: false, writable: true, value: type || '' },
|
|
7962
|
-
$bubbles: { enumerable: false, writable: true, value: config && !!config.bubbles || false },
|
|
7963
|
-
$cancelable: { enumerable: false, writable: true, value: config && !!config.cancelable || false },
|
|
7964
|
-
$target: { enumerable: false, writable: true, value: null },
|
|
7965
|
-
$defaultPrevented: { enumerable: false, writable: true, value: false }
|
|
7966
|
-
});
|
|
7967
|
-
}
|
|
7968
|
-
initEvent(type, bubbles, cancelable) {
|
|
7969
|
-
if (arguments.length < 3) {
|
|
7970
|
-
throw new Error('Not enough arguments to initEvent');
|
|
7971
|
-
}
|
|
7972
|
-
this.$type = type + '';
|
|
7973
|
-
this.$bubbles = !!bubbles;
|
|
7974
|
-
this.$cancelable = !!cancelable;
|
|
7975
|
-
}
|
|
7976
|
-
get type() {
|
|
7977
|
-
return this.$type;
|
|
7978
|
-
}
|
|
7979
|
-
get timeStamp() {
|
|
7980
|
-
return this.$timeStamp;
|
|
7981
|
-
}
|
|
7982
|
-
get bubbles() {
|
|
7983
|
-
return this.$bubbles;
|
|
7984
|
-
}
|
|
7985
|
-
get cancelable() {
|
|
7986
|
-
return this.$cancelable;
|
|
7987
|
-
}
|
|
7988
|
-
get target() {
|
|
7989
|
-
return this.$target;
|
|
7990
|
-
}
|
|
7991
|
-
get currentTarget() {
|
|
7992
|
-
return this.$target;
|
|
7993
|
-
}
|
|
7994
|
-
get defaultPrevented() {
|
|
7995
|
-
return this.$defaultPrevented;
|
|
7996
|
-
}
|
|
7997
|
-
get eventPhase() {
|
|
7998
|
-
return 0;
|
|
7999
|
-
}
|
|
8000
|
-
get isTrusted() {
|
|
8001
|
-
return false;
|
|
8002
|
-
}
|
|
8003
|
-
stopPropagation() {
|
|
8004
|
-
}
|
|
8005
|
-
stopImmediatePropagation() {
|
|
8006
|
-
}
|
|
8007
|
-
preventDefault() {
|
|
8008
|
-
if (this.$cancelable) {
|
|
8009
|
-
this.$defaultPrevented = true;
|
|
8010
|
-
}
|
|
8011
|
-
}
|
|
8012
|
-
}
|
|
8013
|
-
Object.defineProperties(Event, PHASE_CONSTANTS);
|
|
8014
|
-
Object.defineProperties(Event.prototype, PHASE_CONSTANTS);
|
|
8015
|
-
function addDOMEventTargetMethods(target) {
|
|
8016
|
-
if (typeof target.addEventListener === 'function') {
|
|
8017
|
-
return;
|
|
8018
|
-
}
|
|
8019
|
-
let listeners;
|
|
8020
|
-
target.addEventListener = function (type, listener /* , useCapture*/) {
|
|
8021
|
-
if (arguments.length < 2) {
|
|
8022
|
-
throw new Error('Not enough arguments to addEventListener');
|
|
8023
|
-
}
|
|
8024
|
-
if (!listeners) {
|
|
8025
|
-
listeners = [];
|
|
8026
|
-
}
|
|
8027
|
-
if (!(type in listeners)) {
|
|
8028
|
-
listeners[type] = [];
|
|
8029
|
-
}
|
|
8030
|
-
if (!listeners[type].includes(listener)) {
|
|
8031
|
-
listeners[type].push(listener);
|
|
8032
|
-
}
|
|
8033
|
-
};
|
|
8034
|
-
target.removeEventListener = function (type, listener /* , useCapture */) {
|
|
8035
|
-
if (arguments.length < 2) {
|
|
8036
|
-
throw new Error('Not enough arguments to removeEventListener');
|
|
8037
|
-
}
|
|
8038
|
-
if (listeners && type in listeners) {
|
|
8039
|
-
const index = listeners[type].indexOf(listener);
|
|
8040
|
-
if (index !== -1) {
|
|
8041
|
-
listeners[type].splice(index, 1);
|
|
8042
|
-
}
|
|
8043
|
-
}
|
|
8044
|
-
};
|
|
8045
|
-
target.dispatchEvent = function (event) {
|
|
8046
|
-
if (arguments.length < 1) {
|
|
8047
|
-
throw new Error('Not enough arguments to dispatchEvent');
|
|
8048
|
-
}
|
|
8049
|
-
if (!(event instanceof Event)) {
|
|
8050
|
-
throw new Error('Invalid event given to dispatchEvent');
|
|
8051
|
-
}
|
|
8052
|
-
event.$target = target;
|
|
8053
|
-
if (listeners && event.type in listeners) {
|
|
8054
|
-
for (const listener of listeners[event.type]) {
|
|
8055
|
-
listener.call(this, event);
|
|
8056
|
-
}
|
|
8057
|
-
}
|
|
8058
|
-
return !event.defaultPrevented;
|
|
8059
|
-
};
|
|
8060
|
-
}
|
|
8061
|
-
function defineEventHandlerProperties(target, types) {
|
|
8062
|
-
types.forEach(type => defineEventHandlerProperty(target, type));
|
|
8063
|
-
}
|
|
8064
|
-
function defineEventHandlerProperty(target, type) {
|
|
8065
|
-
const handler = 'on' + type;
|
|
8066
|
-
let listener = null;
|
|
8067
|
-
Object.defineProperty(target, handler, {
|
|
8068
|
-
get() {
|
|
8069
|
-
return listener;
|
|
8070
|
-
},
|
|
8071
|
-
set(value) {
|
|
8072
|
-
// ignore other types, mimicks the behavior of Firefox and Chromium
|
|
8073
|
-
if (typeof value === 'function') {
|
|
8074
|
-
if (listener) {
|
|
8075
|
-
target.removeEventListener(type, listener);
|
|
8076
|
-
}
|
|
8077
|
-
listener = value;
|
|
8078
|
-
target.addEventListener(type, listener);
|
|
8079
|
-
}
|
|
8080
|
-
}
|
|
8081
|
-
});
|
|
8082
|
-
}
|
|
8083
|
-
|
|
8084
8288
|
function addDOMDocument(target) {
|
|
8085
8289
|
class HTMLElement {
|
|
8086
8290
|
constructor(tagName) {
|
|
@@ -11975,13 +12179,13 @@ NativeObject.defineProperties(Video.prototype, {
|
|
|
11975
12179
|
state: { readonly: true, nocache: true }
|
|
11976
12180
|
});
|
|
11977
12181
|
|
|
11978
|
-
const EVENT_TYPES = ['navigate', 'load', 'download', 'message'];
|
|
12182
|
+
const EVENT_TYPES$1 = ['navigate', 'load', 'download', 'message'];
|
|
11979
12183
|
class WebView extends Widget {
|
|
11980
12184
|
get _nativeType() {
|
|
11981
12185
|
return 'tabris.WebView';
|
|
11982
12186
|
}
|
|
11983
12187
|
_listen(name, listening) {
|
|
11984
|
-
if (EVENT_TYPES.includes(name)) {
|
|
12188
|
+
if (EVENT_TYPES$1.includes(name)) {
|
|
11985
12189
|
this._nativeListen(name, listening);
|
|
11986
12190
|
}
|
|
11987
12191
|
else {
|
|
@@ -12042,11 +12246,11 @@ const CONSTANTS = {
|
|
|
12042
12246
|
CLOSING: { value: CLOSING },
|
|
12043
12247
|
CLOSED: { value: CLOSED }
|
|
12044
12248
|
};
|
|
12045
|
-
const EVENT_TYPES$
|
|
12249
|
+
const EVENT_TYPES$2 = ['open', 'message', 'close', 'error'];
|
|
12046
12250
|
class _WebSocket extends NativeObject {
|
|
12047
12251
|
constructor(properties) {
|
|
12048
12252
|
super(properties);
|
|
12049
|
-
EVENT_TYPES$
|
|
12253
|
+
EVENT_TYPES$2.forEach(type => this._nativeListen(type, true));
|
|
12050
12254
|
}
|
|
12051
12255
|
get _nativeType() {
|
|
12052
12256
|
return 'tabris.WebSocket';
|
|
@@ -12076,7 +12280,7 @@ class WebSocket {
|
|
|
12076
12280
|
this.protocol = '';
|
|
12077
12281
|
this.extensions = '';
|
|
12078
12282
|
addDOMEventTargetMethods(this);
|
|
12079
|
-
defineEventHandlerProperties(this, EVENT_TYPES$
|
|
12283
|
+
defineEventHandlerProperties(this, EVENT_TYPES$2);
|
|
12080
12284
|
Object.defineProperty(this, '_nativeObject', {
|
|
12081
12285
|
enumerable: false, writable: false, value: this.$createProxy(url, protocols)
|
|
12082
12286
|
});
|
|
@@ -12185,80 +12389,6 @@ function extractScheme(url) {
|
|
|
12185
12389
|
return match ? match[1] : null;
|
|
12186
12390
|
}
|
|
12187
12391
|
|
|
12188
|
-
const EVENT_TYPES$2 = ['message', 'error', 'messageerror'];
|
|
12189
|
-
class _Worker extends NativeObject {
|
|
12190
|
-
get _nativeType() {
|
|
12191
|
-
return 'tabris.Worker';
|
|
12192
|
-
}
|
|
12193
|
-
}
|
|
12194
|
-
NativeObject.defineProperty(_Worker.prototype, 'scriptPath', { type: 'string', default: '' });
|
|
12195
|
-
NativeObject.defineEvents(_Worker.prototype, {
|
|
12196
|
-
message: { native: true },
|
|
12197
|
-
error: { native: true },
|
|
12198
|
-
messageError: true
|
|
12199
|
-
});
|
|
12200
|
-
class Worker {
|
|
12201
|
-
constructor(scriptPath) {
|
|
12202
|
-
if (typeof scriptPath !== 'string') {
|
|
12203
|
-
throw new Error('The Worker script path has to be of type string');
|
|
12204
|
-
}
|
|
12205
|
-
addDOMEventTargetMethods(this);
|
|
12206
|
-
defineEventHandlerProperties(this, EVENT_TYPES$2);
|
|
12207
|
-
Object.defineProperty(this, '_nativeObject', {
|
|
12208
|
-
enumerable: false, writable: false, value: this.$createProxy({ scriptPath })
|
|
12209
|
-
});
|
|
12210
|
-
}
|
|
12211
|
-
$createProxy(scriptPath) {
|
|
12212
|
-
return new _Worker(scriptPath)
|
|
12213
|
-
.onMessage((event) => {
|
|
12214
|
-
this.dispatchEvent(Object.assign(new Event('message'), omit(event, ['target', 'type', 'timeStamp'])));
|
|
12215
|
-
}).onError((event) => {
|
|
12216
|
-
this.dispatchEvent(Object.assign(new Event('error'), omit(event, ['target', 'type', 'timeStamp'])));
|
|
12217
|
-
}).onMessageError((event) => {
|
|
12218
|
-
this.dispatchEvent(Object.assign(new Event('messageerror'), omit(event, ['target', 'type', 'timeStamp'])));
|
|
12219
|
-
});
|
|
12220
|
-
}
|
|
12221
|
-
postMessage(message, transferList) {
|
|
12222
|
-
this._validateMessage(message);
|
|
12223
|
-
this._nativeObject._nativeCall('postMessage', { message, transferList });
|
|
12224
|
-
}
|
|
12225
|
-
_validateMessage(message) {
|
|
12226
|
-
if (!this._isValidMessage(message)) {
|
|
12227
|
-
this.dispatchEvent(Object.assign(new Event('messageerror')));
|
|
12228
|
-
}
|
|
12229
|
-
else {
|
|
12230
|
-
if (message instanceof Array) {
|
|
12231
|
-
for (let i = 0; i < message.length; i++) {
|
|
12232
|
-
this._validateMessage(message[i]);
|
|
12233
|
-
}
|
|
12234
|
-
}
|
|
12235
|
-
else if (typeof (message) === 'object') {
|
|
12236
|
-
for (const property in message) {
|
|
12237
|
-
if (Object.prototype.hasOwnProperty.call(message, property)) {
|
|
12238
|
-
this._validateMessage(message[property]);
|
|
12239
|
-
}
|
|
12240
|
-
}
|
|
12241
|
-
}
|
|
12242
|
-
}
|
|
12243
|
-
}
|
|
12244
|
-
_isValidMessage(message) {
|
|
12245
|
-
return message === undefined ||
|
|
12246
|
-
message === null ||
|
|
12247
|
-
typeof message === 'string' ||
|
|
12248
|
-
typeof message === 'number' ||
|
|
12249
|
-
typeof message === 'boolean' ||
|
|
12250
|
-
message &&
|
|
12251
|
-
(message.constructor === Object ||
|
|
12252
|
-
message.constructor === Array ||
|
|
12253
|
-
message.constructor === DataView ||
|
|
12254
|
-
message.constructor === ArrayBuffer ||
|
|
12255
|
-
message.constructor === ImageData);
|
|
12256
|
-
}
|
|
12257
|
-
terminate() {
|
|
12258
|
-
this._nativeObject._nativeCall('terminate');
|
|
12259
|
-
}
|
|
12260
|
-
}
|
|
12261
|
-
|
|
12262
12392
|
class HttpRequest extends NativeObject {
|
|
12263
12393
|
constructor() {
|
|
12264
12394
|
super();
|
|
@@ -13169,6 +13299,7 @@ else {
|
|
|
13169
13299
|
Object.assign(global, WHATWG, { $ });
|
|
13170
13300
|
addDOMDocument(global);
|
|
13171
13301
|
addDOMEventTargetMethods(global);
|
|
13302
|
+
defineEventHandlerProperties(global, ['message', 'messageerror', 'error']);
|
|
13172
13303
|
addWindowTimerMethods(global);
|
|
13173
13304
|
}
|
|
13174
13305
|
tabrisMain.on('start', (options) => {
|