@qooxdoo/framework 7.0.0-beta.3 → 7.0.0-beta.7

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 (105) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/Manifest.json +1 -1
  3. package/README.md +9 -3
  4. package/lib/compiler/compile-info.json +60 -58
  5. package/lib/compiler/index.js +3242 -1883
  6. package/lib/resource/qx/tool/cli/templates/skeleton/mobile/source/theme/custom/css/custom.css.map +1 -1
  7. package/lib/resource/qx/tool/loadsass.js +6 -4
  8. package/lib/resource/qx/tool/schema/compile-1-0-0.json +6 -11
  9. package/package.json +17 -3
  10. package/source/class/qx/Bootstrap.js +22 -1
  11. package/source/class/qx/bom/Blocker.js +2 -1
  12. package/source/class/qx/core/Environment.js +3 -12
  13. package/source/class/qx/core/MProperty.js +1 -1
  14. package/source/class/qx/dev/unit/Sinon.js +1 -1
  15. package/source/class/qx/io/__init__.js +5 -3
  16. package/source/class/qx/io/exception/Cancel.js +34 -0
  17. package/source/class/qx/io/exception/Exception.js +38 -0
  18. package/source/class/qx/io/exception/Protocol.js +26 -0
  19. package/source/class/qx/io/exception/Transport.js +39 -0
  20. package/source/class/qx/io/exception/__init__.js +4 -0
  21. package/source/class/qx/io/graphql/Client.js +112 -0
  22. package/source/class/qx/io/graphql/__init__.js +9 -0
  23. package/source/class/qx/io/graphql/protocol/Message.js +65 -0
  24. package/source/class/qx/io/graphql/protocol/Request.js +95 -0
  25. package/source/class/qx/io/graphql/protocol/Response.js +61 -0
  26. package/source/class/qx/io/graphql/protocol/__init__.js +6 -0
  27. package/source/class/qx/io/jsonrpc/Client.js +323 -0
  28. package/source/class/qx/io/jsonrpc/__init__.js +15 -0
  29. package/source/class/qx/io/jsonrpc/protocol/Batch.js +97 -0
  30. package/source/class/qx/io/jsonrpc/protocol/Error.js +63 -0
  31. package/source/class/qx/io/jsonrpc/protocol/Message.js +48 -0
  32. package/source/class/qx/io/jsonrpc/protocol/Notification.js +45 -0
  33. package/source/class/qx/io/jsonrpc/protocol/Parser.js +81 -0
  34. package/source/class/qx/io/jsonrpc/protocol/Request.js +93 -0
  35. package/source/class/qx/io/jsonrpc/protocol/Result.js +48 -0
  36. package/source/class/qx/io/jsonrpc/protocol/__init__.js +5 -0
  37. package/source/class/qx/io/request/authentication/Bearer.js +52 -0
  38. package/source/class/qx/io/transport/AbstractClient.js +100 -0
  39. package/source/class/qx/io/transport/AbstractTransport.js +41 -0
  40. package/source/class/qx/io/transport/Fetch.js +95 -0
  41. package/source/class/qx/io/transport/ITransport.js +40 -0
  42. package/source/class/qx/io/transport/PostMessage.js +55 -0
  43. package/source/class/qx/io/transport/Websocket.js +97 -0
  44. package/source/class/qx/io/transport/Xhr.js +139 -0
  45. package/source/class/qx/io/transport/__init__.js +18 -0
  46. package/source/class/qx/test/core/Assert.js +1 -1
  47. package/source/class/qx/test/core/Environment.js +0 -3
  48. package/source/class/qx/test/io/MAssert.js +46 -0
  49. package/source/class/qx/test/io/graphql/Client.js +169 -0
  50. package/source/class/qx/test/io/graphql/ClientFetch.js +34 -0
  51. package/source/class/qx/test/io/graphql/Request.js +42 -0
  52. package/source/class/qx/test/io/jsonrpc/Client.js +267 -0
  53. package/source/class/qx/test/io/jsonrpc/Protocol.js +80 -0
  54. package/source/class/qx/test/io/transport/PostMessage.js +56 -0
  55. package/source/class/qx/test/io/transport/Websocket.js +63 -0
  56. package/source/class/qx/test/ui/embed/Iframe.js +1 -1
  57. package/source/class/qx/test/util/DateFormat.js +45 -6
  58. package/source/class/qx/tool/cli/Cli.js +1 -0
  59. package/source/class/qx/tool/cli/commands/Compile.js +13 -3
  60. package/source/class/qx/tool/cli/commands/Es6ify.js +93 -0
  61. package/source/class/qx/tool/cli/commands/package/Install.js +1 -1
  62. package/source/class/qx/tool/cli/commands/package/Publish.js +14 -0
  63. package/source/class/qx/tool/compiler/ClassFile.js +67 -27
  64. package/source/class/qx/tool/compiler/Es6ify.js +368 -0
  65. package/source/class/qx/tool/compiler/makers/AppMaker.js +2 -1
  66. package/source/class/qx/tool/compiler/targets/Target.js +57 -47
  67. package/source/class/qx/tool/compiler/targets/meta/AbstractJavascriptMeta.js +25 -18
  68. package/source/class/qx/tool/compiler/targets/meta/BootJs.js +16 -16
  69. package/source/class/qx/tool/compiler/targets/meta/PolyfillJs.js +11 -3
  70. package/source/class/qx/tool/compiler/targets/meta/Uglify.js +10 -10
  71. package/source/class/qx/ui/core/Widget.js +70 -0
  72. package/source/class/qx/ui/decoration/MLinearBackgroundGradient.js +2 -1
  73. package/source/class/qx/ui/form/ComboBox.js +8 -3
  74. package/source/class/qx/ui/form/DateField.js +16 -1
  75. package/source/class/qx/ui/form/MenuButton.js +8 -4
  76. package/source/class/qx/ui/form/SelectBox.js +8 -3
  77. package/source/class/qx/ui/menu/AbstractButton.js +12 -8
  78. package/source/class/qx/ui/menu/Menu.js +18 -8
  79. package/source/class/qx/ui/table/pane/Model.js +10 -4
  80. package/source/class/qx/ui/window/Window.js +8 -0
  81. package/source/class/qx/util/format/DateFormat.js +44 -17
  82. package/source/resource/qx/tool/loadsass.js +6 -4
  83. package/source/resource/qx/tool/schema/compile-1-0-0.json +6 -11
  84. package/source/translation/hr.po +297 -0
  85. package/lib/resource/qx/static/blank.gif +0 -0
  86. package/source/class/qx/io/remote/Exchange.js +0 -1063
  87. package/source/class/qx/io/remote/Request.js +0 -1021
  88. package/source/class/qx/io/remote/RequestQueue.js +0 -521
  89. package/source/class/qx/io/remote/Response.js +0 -137
  90. package/source/class/qx/io/remote/Rpc.js +0 -1075
  91. package/source/class/qx/io/remote/RpcError.js +0 -198
  92. package/source/class/qx/io/remote/__init__.js +0 -88
  93. package/source/class/qx/io/remote/transport/Abstract.js +0 -513
  94. package/source/class/qx/io/remote/transport/Iframe.js +0 -652
  95. package/source/class/qx/io/remote/transport/Script.js +0 -475
  96. package/source/class/qx/io/remote/transport/XmlHttp.js +0 -1019
  97. package/source/class/qx/io/remote/transport/__init__.js +0 -3
  98. package/source/class/qx/test/io/remote/AbstractRequest.js +0 -150
  99. package/source/class/qx/test/io/remote/RequestIframe.js +0 -105
  100. package/source/class/qx/test/io/remote/RequestXhr.js +0 -151
  101. package/source/class/qx/test/io/remote/Rpc.js +0 -205
  102. package/source/class/qx/test/io/remote/__init__.js +0 -4
  103. package/source/class/qx/test/io/remote/transport/Iframe.js +0 -67
  104. package/source/class/qx/test/io/remote/transport/XmlHttp.js +0 -133
  105. package/source/class/qx/test/io/remote/transport/__init__.js +0 -4
@@ -0,0 +1,267 @@
1
+ /* ************************************************************************
2
+
3
+ qooxdoo - the new era of web development
4
+
5
+ http://qooxdoo.org
6
+
7
+ Copyright:
8
+ 2004-2011 1&1 Internet AG, Germany, http://www.1und1.de & contributors
9
+
10
+ License:
11
+ MIT: https://opensource.org/licenses/MIT
12
+ See the LICENSE file in the project's top-level directory for details.
13
+
14
+ Authors:
15
+ * Tristan Koch (tristankoch)
16
+ * Christian Boulanger (cboulanger)
17
+
18
+ ************************************************************************ */
19
+
20
+ /**
21
+ * Tests for qx.io.jsonrpc.Client with a qx.test.io.request.Xhr transport
22
+ */
23
+ qx.Class.define("qx.test.io.jsonrpc.Client",
24
+ {
25
+ extend : qx.dev.unit.TestCase,
26
+
27
+ include : [
28
+ qx.dev.unit.MMock,
29
+ qx.test.io.MAssert
30
+ ],
31
+
32
+ members : {
33
+
34
+ setUp() {
35
+ this.sinon = qx.dev.unit.Sinon.getSinon();
36
+ this.setUpRequest();
37
+ this.setUpFakeTransport();
38
+ qx.io.jsonrpc.protocol.Request.resetId();
39
+ },
40
+
41
+ setUpRequest: function () {
42
+ this.req && this.req.dispose();
43
+ this.req = new qx.io.request.Xhr();
44
+ this.req.setUrl("url");
45
+ },
46
+
47
+ setUpFakeTransport: function () {
48
+ if (this.transport && this.transport.send.restore) {
49
+ return;
50
+ }
51
+ this.transport = this.injectStub(qx.io.request.Xhr.prototype, "_createTransport");
52
+ this.setUpRequest();
53
+ },
54
+
55
+ setUpFakeXhr: function () {
56
+ // Not fake transport
57
+ this.getSandbox().restore();
58
+ this.useFakeXMLHttpRequest();
59
+ this.setUpRequest();
60
+ },
61
+
62
+ /**
63
+ * Sets up the fake server and instructs it to send the given response(s)
64
+ * @param {String} response The server response to the first request
65
+ */
66
+ setUpFakeServer: function (response) {
67
+ // Not fake transport
68
+ this.getSandbox().restore();
69
+ this.useFakeServer();
70
+ this.setUpRequest();
71
+ this.getServer().respondWith(
72
+ "POST", /.*/,
73
+ [200, {"Content-Type": "application/json; charset=utf-8"}, response]
74
+ );
75
+ this.getServer().autoRespond = true;
76
+ },
77
+
78
+ /**
79
+ * Assert that the given exception is thrown on receiving the given result
80
+ * @param {String} response
81
+ * @param {Class|Number} exception If class, the exception class, which must
82
+ * be a subclass of qx.io.exception.Exception. If number, the error number
83
+ */
84
+ assertExceptionThrown: function (response, exception) {
85
+ if (!(qx.lang.Type.isNumber(exception) || qx.Class.isSubClassOf(exception, qx.io.exception.Exception))) {
86
+ throw new Error("Second argument must be a Number or a subclass of qx.io.exception.Exception");
87
+ }
88
+ this.setUpFakeServer(response);
89
+ const message_out = new qx.io.jsonrpc.protocol.Request("foo",[1,2,3]);
90
+ const client = new qx.io.jsonrpc.Client("http://jsonrpc");
91
+ const errorCallback = this.spy(err => {
92
+ //console.warn(err);
93
+ if (qx.lang.Type.isNumber(exception)) {
94
+ if (!(err instanceof qx.io.exception.Exception)) {
95
+ throw err;
96
+ }
97
+ this.assertEquals(exception, err.code,`Error code does not match`);
98
+ } else {
99
+ this.assertInstance(err, exception,
100
+ `Exception class does not match. Expected ${exception.classname}, got ${err}.`);
101
+ }
102
+ });
103
+ // check message promise
104
+ message_out.getPromise().catch(errorCallback);
105
+ // check event
106
+ client.addListener("error", evt => errorCallback(evt.getData()));
107
+ // check transport promise
108
+ client.send(message_out).catch(errorCallback);
109
+ this.wait(100, () => {
110
+ if (
111
+ // the request promise will not be called since the promise is already rejected
112
+ exception === qx.io.exception.Transport.DUPLICATE_ID
113
+ // or the send promise will not be rejected because we have a server-side error
114
+ || exception === qx.io.exception.Protocol) {
115
+ this.assertCalledTwice(errorCallback)
116
+ } else {
117
+ // the error handler will be called three times
118
+ this.assertCalledThrice(errorCallback)
119
+ }
120
+ });
121
+ },
122
+
123
+ tearDown: function () {
124
+ this.getSandbox().restore();
125
+ this.req.dispose();
126
+ },
127
+
128
+ resetId(){
129
+ qx.io.jsonrpc.protocol.Request.resetId();
130
+ },
131
+
132
+ //
133
+ // Auth, should be moved into qx.test.io.request.Xhr
134
+ //
135
+
136
+ "test: Bearer authentication": function () {
137
+ this.setUpFakeTransport();
138
+
139
+ var transport = this.transport, auth, call, key, credentials;
140
+
141
+ auth = new qx.io.request.authentication.Bearer("TOKEN");
142
+ this.req.setAuthentication(auth);
143
+ this.req.send();
144
+
145
+ call = transport.setRequestHeader.getCall(1);
146
+ key = "Authorization";
147
+ credentials = /Bearer\s(.*)/.exec(call.args[1])[1];
148
+ this.assertEquals(key, call.args[0]);
149
+ this.assertEquals("TOKEN", credentials);
150
+ },
151
+
152
+ //
153
+ // JSON-RPC
154
+ //
155
+
156
+ "test: throw on invalid response id" : function() {
157
+ this.resetId();
158
+ var response = qx.lang.Json.stringify({"jsonrpc": "2.0", "result": 19, "id": 2});
159
+ this.assertExceptionThrown(response, qx.io.exception.Transport.UNKNOWN_ID);
160
+ },
161
+
162
+ "test: throw on duplicate response id" : function() {
163
+ this.resetId();
164
+ var response = qx.lang.Json.stringify([
165
+ {"jsonrpc": "2.0", "result": 19, "id": 1},
166
+ {"jsonrpc": "2.0", "result": 19, "id": 1}
167
+ ]);
168
+ this.assertExceptionThrown(response, qx.io.exception.Transport.DUPLICATE_ID);
169
+ },
170
+
171
+ "test: call jsonrpc method and receive response with single result" : async function() {
172
+ this.resetId();
173
+ let message_out = new qx.io.jsonrpc.protocol.Request("foo", ["bar"]);
174
+ let result = "Hello World!";
175
+ let message_in = new qx.io.jsonrpc.protocol.Result(message_out.getId(), result);
176
+ this.setUpFakeServer(message_in.toString());
177
+ const client = new qx.io.jsonrpc.Client("http://jsonrpc");
178
+ let spy = this.spy(value => this.assertEquals(result, value));
179
+ message_out.getPromise().then(spy);
180
+ await client.send(message_out);
181
+ this.assertCalled(spy);
182
+ },
183
+
184
+ "test: call jsonrpc method and receive batched response" : async function() {
185
+ this.resetId();
186
+ let message_out = new qx.io.jsonrpc.protocol.Request("foo", ["bar"]);
187
+ let result = "Hello World!";
188
+ let response = (new qx.io.jsonrpc.protocol.Batch())
189
+ .add(new qx.io.jsonrpc.protocol.Result(message_out.getId(), result))
190
+ .addRequest("foo", ["bar"])
191
+ .addNotification("logout")
192
+ .toString();
193
+ this.setUpFakeServer(response);
194
+ const client = new qx.io.jsonrpc.Client("http://jsonrpc");
195
+ let spy = this.spy(value => this.assertEquals(result, value));
196
+ message_out.getPromise().then(spy);
197
+ await client.send(message_out);
198
+ this.assertCalled(spy);
199
+ },
200
+
201
+ "test: call jsonrpc method and expect error on invalid reponse "() {
202
+ this.assertExceptionThrown("helloworld!", qx.io.exception.Transport.INVALID_JSON);
203
+ },
204
+
205
+ "test: call jsonrpc method and expect error on invalid reponse - missing result" () {
206
+ this.assertExceptionThrown("null", qx.io.exception.Transport.NO_DATA);
207
+ },
208
+
209
+ "test: call jsonrpc method and expect error response"() {
210
+ this.resetId();
211
+ var response = qx.lang.Json.stringify({"jsonrpc": "2.0", "error" : {"code": -32600, "message": "Division by zero!"}, "id": 1});
212
+ this.assertExceptionThrown(response, qx.io.exception.Protocol);
213
+ },
214
+
215
+ "test: send batched requests"() {
216
+ this.resetId();
217
+ var response = qx.lang.Json.stringify([
218
+ {"jsonrpc": "2.0", "result": 7, "id": 1},
219
+ {"jsonrpc": "2.0", "result": "foo", "id": 2},
220
+ {"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request"}, "id": 3},
221
+ {"jsonrpc": "2.0", "error": {"code": -32601, "message": "Method not found"}, "id": 4},
222
+ {"jsonrpc": "2.0", "result": ["hello", 5], "id": 5}]);
223
+ this.setUpFakeServer(response);
224
+ var client = new qx.io.jsonrpc.Client("http://jsonrpc");
225
+ var spies = [];
226
+ var batch = new qx.io.jsonrpc.protocol.Batch();
227
+ for( var i=1; i < 6; i++) {
228
+ spies[i] = { result: this.spy(), error: this.spy() };
229
+ let request = new qx.io.jsonrpc.protocol.Request("someMethod", []);
230
+ request.getPromise()
231
+ .then(spies[i].result)
232
+ .catch(spies[i].error);
233
+ batch.add(request);
234
+ }
235
+ client.sendBatch(batch).catch(err => {
236
+ this.assertInstance(err, qx.io.exception.Protocol);
237
+ });
238
+ this.wait(100, function(){
239
+ this.assertCalledWith(spies[1].result, 7);
240
+ this.assertCalledWith(spies[2].result, "foo");
241
+ this.assertCalled(spies[3].error);
242
+ this.assertCalled(spies[4].error);
243
+ this.assertCalledWith(spies[5].result, ["hello", 5]);
244
+ },this);
245
+ },
246
+
247
+ "test: receive jsonrpc requests from server" : function() {
248
+ this.resetId();
249
+ var response = [
250
+ {"jsonrpc": "2.0", "method": "clientMethod", "params": ["foo", "bar"], "id": 1},
251
+ {"jsonrpc": "2.0", "method": "clientNotification", "params": []}
252
+ ];
253
+ this.setUpFakeServer(qx.lang.Json.stringify(response));
254
+ var client = new qx.io.jsonrpc.Client("http://jsonrpc");
255
+ var spy = this.spy();
256
+ client.addListener("incomingRequest", evt => {
257
+ let message = evt.getData().toObject();
258
+ this.assertDeepEquals(response.shift(), message);
259
+ spy(message);
260
+ });
261
+ client.sendNotification("ping");
262
+ this.wait(100, function(){
263
+ this.assertCalledTwice(spy);
264
+ },this);
265
+ }
266
+ }
267
+ });
@@ -0,0 +1,80 @@
1
+ /* ************************************************************************
2
+
3
+ qooxdoo - the new era of web development
4
+
5
+ http://qooxdoo.org
6
+
7
+ Copyright:
8
+ 2020 Christian Boulanger
9
+
10
+ License:
11
+ MIT: https://opensource.org/licenses/MIT
12
+ See the LICENSE file in the project's top-level directory for details.
13
+
14
+ Authors:
15
+ * Christian Boulanger (cboulanger)
16
+
17
+ ************************************************************************ */
18
+
19
+ qx.Class.define("qx.test.io.jsonrpc.Protocol",
20
+ {
21
+ extend : qx.dev.unit.TestCase,
22
+ include : [qx.test.io.MAssert],
23
+ construct() {
24
+ this.base(arguments);
25
+ this.parser = new qx.io.jsonrpc.protocol.Parser();
26
+ },
27
+ members : {
28
+ "test: JSON-RPC request message object"() {
29
+ let message = new qx.io.jsonrpc.protocol.Request("foo", ["bar", 1, false]);
30
+ let expected = {
31
+ id: 1,
32
+ jsonrpc: "2.0",
33
+ method: "foo",
34
+ params: ["bar", 1, false]
35
+ };
36
+ this.assertDeepEquals(expected, message.toObject());
37
+ // test parser
38
+ this.assertDeepEquals(expected, this.parser.parse(JSON.stringify(expected)).toObject());
39
+ },
40
+
41
+ "test: JSON-RPC request notification object"() {
42
+ let message = new qx.io.jsonrpc.protocol.Notification("foo", ["bar", 1, false]);
43
+ let expected = {
44
+ jsonrpc: "2.0",
45
+ method: "foo",
46
+ params: ["bar", 1, false]
47
+ };
48
+ this.assertDeepEquals(expected, message.toObject());
49
+ // test parser
50
+ this.assertDeepEquals(expected, this.parser.parse(JSON.stringify(expected)).toObject());
51
+ },
52
+
53
+ "test: JSON-RPC error object"() {
54
+ let message = new qx.io.jsonrpc.protocol.Error(1, 5, "error!");
55
+ let expected = {
56
+ jsonrpc: "2.0",
57
+ id: 1,
58
+ error: {
59
+ code: 5,
60
+ message: "error!"
61
+ }
62
+ };
63
+ this.assertDeepEquals(expected, message.toObject());
64
+ // test parser
65
+ this.assertDeepEquals(expected, this.parser.parse(JSON.stringify(expected)).toObject());
66
+ },
67
+
68
+ "test: JSON-RPC result object"() {
69
+ let message = new qx.io.jsonrpc.protocol.Error(1, 5, "error!");
70
+ let expected = {
71
+ jsonrpc: "2.0", id: 1, error: {
72
+ code: 5, message: "error!"
73
+ }
74
+ };
75
+ this.assertDeepEquals(expected, message.toObject());
76
+ // test parser
77
+ this.assertDeepEquals(expected, this.parser.parse(JSON.stringify(expected)).toObject());
78
+ }
79
+ }
80
+ });
@@ -0,0 +1,56 @@
1
+ /* ************************************************************************
2
+
3
+ qooxdoo - the new era of web development
4
+
5
+ http://qooxdoo.org
6
+
7
+ Copyright:
8
+ 2004-2011 1&1 Internet AG, Germany, http://www.1und1.de & contributors
9
+
10
+ License:
11
+ MIT: https://opensource.org/licenses/MIT
12
+ See the LICENSE file in the project's top-level directory for details.
13
+
14
+ Authors:
15
+ * Tristan Koch (tristankoch)
16
+ * Christian Boulanger (cboulanger)
17
+
18
+ ************************************************************************ */
19
+
20
+ /**
21
+ * Tests for the postMessage transport
22
+ * @ignore(URL)
23
+ * @ignore(Worker)
24
+ * @ignore(self)
25
+ */
26
+ qx.Class.define("qx.test.io.transport.PostMessage", {
27
+ extend: qx.dev.unit.TestCase,
28
+
29
+ members: {
30
+
31
+ setUp() {
32
+ // see https://medium.com/@dee_bloo/make-multithreading-easier-with-inline-web-workers-a58723428a42
33
+ function createWorker(fn) {
34
+ let blob = new Blob(['self.onmessage = ', fn.toString()], { type: 'text/javascript' });
35
+ return new Worker(URL.createObjectURL(blob));
36
+ }
37
+ // create echo server
38
+ const worker = createWorker(evt => {
39
+ self.postMessage(evt.data);
40
+ });
41
+ this.transport = new qx.io.transport.PostMessage(worker);
42
+ },
43
+
44
+ async "test: send message to worker and check response"() {
45
+ let message = "Hello World!";
46
+ await new qx.Promise((resolve, reject) => {
47
+ this.transport.addListenerOnce("message", evt => {
48
+ this.assertEquals(message, evt.getData());
49
+ });
50
+ this.transport.send(message)
51
+ .then(resolve)
52
+ .catch(reject);
53
+ });
54
+ }
55
+ }
56
+ });
@@ -0,0 +1,63 @@
1
+ /* ************************************************************************
2
+
3
+ qooxdoo - the new era of web development
4
+
5
+ http://qooxdoo.org
6
+
7
+ Copyright:
8
+ 2004-2011 1&1 Internet AG, Germany, http://www.1und1.de & contributors
9
+
10
+ License:
11
+ MIT: https://opensource.org/licenses/MIT
12
+ See the LICENSE file in the project's top-level directory for details.
13
+
14
+ Authors:
15
+ * Tristan Koch (tristankoch)
16
+ * Christian Boulanger (cboulanger)
17
+
18
+ ************************************************************************ */
19
+
20
+ /**
21
+ * Tests for the websocket transport
22
+ */
23
+ qx.Class.define("qx.test.io.transport.Websocket", {
24
+ extend: qx.dev.unit.TestCase,
25
+
26
+ statics: {
27
+ TEST_ENDPOINT: "echo.websocket.events"
28
+ },
29
+
30
+ members: {
31
+
32
+ __hasEndpoint : false,
33
+ __skipMsg: "Skipping test as endpoint is not available.",
34
+
35
+ setUp() {
36
+ this.transport = new qx.io.transport.Websocket("wss://" + this.constructor.TEST_ENDPOINT);
37
+ },
38
+
39
+ async "test: check endpoint"() {
40
+ try {
41
+ await this.transport.send("test");
42
+ this.__hasEndpoint = true;
43
+ } catch(e) {
44
+ console.error(`Endpoint ${this.constructor.TEST_ENDPOINT} is not accessible: ${e.message}`);
45
+ }
46
+ },
47
+
48
+ async "test: send message to public websocket echo server and check response"() {
49
+ if (!this.__hasEndpoint) {
50
+ return this.skip(this.__skipMsg);
51
+ }
52
+ let message = "Hello World!";
53
+ await new qx.Promise((resolve, reject) => {
54
+ this.transport.addListenerOnce("message", evt => {
55
+ this.assertEquals(message, evt.getData());
56
+ });
57
+ this.transport.send(message)
58
+ .then(resolve)
59
+ .catch(reject);
60
+ });
61
+ }
62
+ }
63
+ });
@@ -88,6 +88,7 @@ qx.Class.define("qx.test.ui.embed.Iframe",
88
88
  this.wait(10000);
89
89
  },
90
90
 
91
+ /** @ignore(require) */
91
92
  testSyncSourceAfterDOMMove : function ()
92
93
  {
93
94
  // This breaks (very) frequently when run under headless chrome on Travis; we can't
@@ -99,7 +100,6 @@ qx.Class.define("qx.test.ui.embed.Iframe",
99
100
 
100
101
  // This also breaks on MacOS runners on GitHub with webkit
101
102
  try {
102
- /** @ignore(require) */
103
103
  let CI = require("process").env.CI;
104
104
  if (CI && qx.core.Environment.get("browser.name") === "webkit") {
105
105
  this.skip("Skipping for Webkit for MacOS");
@@ -805,15 +805,54 @@ qx.Class.define("qx.test.util.DateFormat",
805
805
  this._testIsoMasks(date, 'isoDate', 'yyyy-MM-dd');
806
806
  this._testIsoMasks(date, 'isoTime', 'HH:mm:ss');
807
807
  this._testIsoMasks(date, 'isoDateTime', "yyyy-MM-dd'T'HH:mm:ss");
808
-
809
- // var isodf = new qx.util.format.DateFormat('isoUtcDateTime');
810
- // var df = new qx.util.format.DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
811
- // var isoDateFormatted = isodf.format(date);
812
- // var dateFormatted = df.format(date);
813
- // this.assertEquals(isodf.parse(isoDateFormatted).getTime(),df.parse(dateFormatted).getTime());
808
+ this._testIsoMasks(date, 'isoDateTimeTz', "yyyy-MM-dd'T'HH:mm:ssZ");
809
+ //this._testIsoMasks(date, 'isoUtcDateTime', "yyyy-MM-dd'T'HH:mm:ss'Z'");
814
810
  }
815
811
  },
816
812
 
813
+ testIsoTz : function() {
814
+ var isodf = new qx.util.format.DateFormat('isoDateTimeTz');
815
+ var parsedDate = isodf.parse("2013-01-01T00:00:00+0000");
816
+ this.assertEquals(parsedDate.getUTCFullYear(), 2013);
817
+ this.assertEquals(parsedDate.getUTCMonth(), 0);
818
+ this.assertEquals(parsedDate.getUTCDate(), 1);
819
+ this.assertEquals(parsedDate.getUTCHours(), 0);
820
+ this.assertEquals(parsedDate.getUTCMinutes(), 0);
821
+ this.assertEquals(parsedDate.getUTCSeconds(), 0);
822
+ this.assertEquals(parsedDate.getUTCMilliseconds(), 0);
823
+
824
+ parsedDate = isodf.parse("2004-04-04T04:04:04-0500")
825
+ this.assertEquals(parsedDate.getUTCFullYear(), 2004);
826
+ this.assertEquals(parsedDate.getUTCMonth(), 3);
827
+ this.assertEquals(parsedDate.getUTCDate(), 3);
828
+ this.assertEquals(parsedDate.getUTCHours(), 23);
829
+ this.assertEquals(parsedDate.getUTCMinutes(), 4);
830
+ this.assertEquals(parsedDate.getUTCSeconds(), 4);
831
+ this.assertEquals(parsedDate.getUTCMilliseconds(), 0);
832
+ },
833
+
834
+ testUtc : function () {
835
+ var isodf = new qx.util.format.DateFormat('isoUtcDateTime');
836
+ var parsedDate = isodf.parse("2013-01-01T00:00:00Z");
837
+ this.assertEquals(parsedDate.getUTCFullYear(), 2013);
838
+ this.assertEquals(parsedDate.getUTCMonth(), 0);
839
+ this.assertEquals(parsedDate.getUTCDate(), 1);
840
+ this.assertEquals(parsedDate.getUTCHours(), 0);
841
+ this.assertEquals(parsedDate.getUTCMinutes(), 0);
842
+ this.assertEquals(parsedDate.getUTCSeconds(), 0);
843
+ this.assertEquals(parsedDate.getUTCMilliseconds(), 0);
844
+
845
+ // checks that UTC hours are calculated correctly
846
+ parsedDate = isodf.parse("2004-04-04T04:04:04Z");
847
+ this.assertEquals(parsedDate.getUTCHours(), 4);
848
+
849
+ // checks that UTC format does not parse a date with a timezone
850
+ this.assertException(function() {
851
+ isodf.parse("2004-04-04T04:04:04+05:00");
852
+ }, Error);
853
+
854
+ },
855
+
817
856
  testChangingLocales : function()
818
857
  {
819
858
  var manager = qx.locale.Manager.getInstance();
@@ -179,6 +179,7 @@ Version: v${await qx.tool.config.Utils.getQxVersion()}
179
179
  "Compile",
180
180
  "Config",
181
181
  "Deploy",
182
+ "Es6ify",
182
183
  "Package",
183
184
  "Pkg", // alias for Package
184
185
  "Create",
@@ -128,6 +128,11 @@ qx.Class.define("qx.tool.cli.commands.Compile", {
128
128
  type: "boolean",
129
129
  default: false
130
130
  },
131
+ "source-map-relative-paths": {
132
+ "describe": "If true, the source file will be saved in the map file if the target supports it. Can be overridden on a per application basis.",
133
+ "type": "boolean",
134
+ default: false
135
+ },
131
136
  "save-unminified": {
132
137
  alias: "u",
133
138
  describe: "Saves a copy of the unminified version of output files (build target only)",
@@ -571,10 +576,10 @@ Framework: v${await this.getQxVersion()} in ${await this.getQxPath()}`);
571
576
  createMakersFromConfig: async function(data) {
572
577
  const Console = qx.tool.compiler.Console.getInstance();
573
578
  var t = this;
574
-
575
579
  if (data.babelOptions) {
576
- if (!data.babelConfig) {
577
- data.babelConfig = { options: data.babelOptions };
580
+ if (!data?.babel?.options) {
581
+ data.babel = data.babel || {};
582
+ data.babel.options = data.babelOptions;
578
583
  qx.tool.compiler.Console.print("qx.tool.cli.compile.deprecatedBabelOptions");
579
584
  } else {
580
585
  qx.tool.compiler.Console.print("qx.tool.cli.compile.deprecatedBabelOptionsConflicting");
@@ -841,6 +846,11 @@ Framework: v${await this.getQxVersion()} in ${await this.getQxPath()}`);
841
846
  target.setSaveSourceInMap(saveSourceInMap);
842
847
  }
843
848
 
849
+ var sourceMapRelativePaths = chooseValue(targetConfig["source-map-relative-paths"], t.argv["sourceMapRelativePaths"]);
850
+ if ((typeof sourceMapRelativePaths == "boolean") && (typeof target.setSourceMapRelativePaths == "function")) {
851
+ target.setSourceMapRelativePaths(sourceMapRelativePaths);
852
+ }
853
+
844
854
  var saveUnminified = chooseValue(targetConfig["save-unminified"], t.argv["save-unminified"]);
845
855
  if (typeof saveUnminified == "boolean" && typeof target.setSaveUnminified == "function") {
846
856
  target.setSaveUnminified(saveUnminified);
@@ -0,0 +1,93 @@
1
+ /* ************************************************************************
2
+
3
+ qooxdoo - the new era of web development
4
+
5
+ http://qooxdoo.org
6
+
7
+ Copyright:
8
+ 2021 Zenesis Ltd
9
+
10
+ License:
11
+ MIT: https://opensource.org/licenses/MIT
12
+ See the LICENSE file in the project's top-level directory for details.
13
+
14
+ Authors:
15
+ * John Spackman (john.spackman@zenesis.com, @johnspackman)
16
+
17
+ ************************************************************************ */
18
+
19
+ const fs = require("fs");
20
+ const path = require("upath");
21
+
22
+ /**
23
+ * Migrates code to ES6 (partially)
24
+ */
25
+ qx.Class.define("qx.tool.cli.commands.Es6ify", {
26
+ extend: qx.tool.cli.commands.Command,
27
+ statics: {
28
+ getYargsCommand: function () {
29
+ return {
30
+ command: "es6ify [file]",
31
+ describe: "help migrate code to ES6",
32
+ builder: {
33
+ verbose: {
34
+ alias: "v",
35
+ describe: "Verbose logging",
36
+ },
37
+ overwrite: {
38
+ type: "boolean",
39
+ default: true,
40
+ describe: "Overwrite source files"
41
+ },
42
+ exclude: {
43
+ type: "array",
44
+ describe: "Paths to exclude"
45
+ },
46
+ arrowFunctions: {
47
+ choices: [ "never", "always", "careful", "aggressive" ],
48
+ default: "careful"
49
+ }
50
+ }
51
+ };
52
+ }
53
+ },
54
+
55
+ members: {
56
+ async process() {
57
+ await this.base(arguments);
58
+ let exclude = this.argv.exclude;
59
+
60
+ const processFile = async filename => {
61
+ if (exclude && filename.startsWith(exclude)) {
62
+ return;
63
+ }
64
+
65
+ console.log(`Processing ${filename}...`);
66
+ let ify = new qx.tool.compiler.Es6ify(filename);
67
+ ify.set({
68
+ arrowFunctions: this.argv.arrowFunctions,
69
+ overwrite: this.argv.overwrite
70
+ });
71
+ await ify.transform();
72
+ };
73
+
74
+ const scanImpl = async filename => {
75
+ let basename = path.basename(filename);
76
+ let stat = await fs.promises.stat(filename);
77
+
78
+ if (stat.isFile() && basename.match(/\.js$/)) {
79
+ await processFile(filename);
80
+
81
+ } else if (stat.isDirectory() && (basename == "." || basename[0] != '.')) {
82
+ let files = await fs.promises.readdir(filename);
83
+ for (let i = 0; i < files.length; i++) {
84
+ let subname = path.join(filename, files[i]);
85
+ await scanImpl(subname);
86
+ }
87
+ }
88
+ };
89
+
90
+ await scanImpl(this.argv.file);
91
+ }
92
+ }
93
+ });