@qooxdoo/framework 7.0.0-beta.6 → 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.
- package/Manifest.json +1 -1
- package/README.md +3 -1
- package/lib/compiler/compile-info.json +57 -55
- package/lib/compiler/index.js +2440 -1860
- package/lib/resource/qx/tool/cli/templates/skeleton/mobile/source/theme/custom/css/custom.css.map +1 -1
- package/lib/resource/qx/tool/schema/compile-1-0-0.json +6 -11
- package/package.json +3 -2
- package/source/class/qx/Bootstrap.js +22 -1
- package/source/class/qx/bom/Blocker.js +2 -1
- package/source/class/qx/core/Environment.js +3 -12
- package/source/class/qx/core/MProperty.js +1 -1
- package/source/class/qx/dev/unit/Sinon.js +1 -1
- package/source/class/qx/test/core/Assert.js +1 -1
- package/source/class/qx/test/core/Environment.js +0 -3
- package/source/class/qx/tool/cli/Cli.js +1 -0
- package/source/class/qx/tool/cli/commands/Compile.js +10 -0
- package/source/class/qx/tool/cli/commands/Es6ify.js +93 -0
- package/source/class/qx/tool/cli/commands/package/Install.js +1 -1
- package/source/class/qx/tool/compiler/ClassFile.js +67 -27
- package/source/class/qx/tool/compiler/Es6ify.js +368 -0
- package/source/class/qx/tool/compiler/targets/Target.js +56 -47
- package/source/class/qx/tool/compiler/targets/meta/AbstractJavascriptMeta.js +25 -18
- package/source/class/qx/tool/compiler/targets/meta/BootJs.js +16 -16
- package/source/class/qx/tool/compiler/targets/meta/Uglify.js +10 -10
- package/source/class/qx/ui/decoration/MLinearBackgroundGradient.js +2 -1
- package/source/resource/qx/tool/schema/compile-1-0-0.json +6 -11
- package/lib/resource/qx/static/blank.gif +0 -0
- package/source/class/qx/io/remote/Exchange.js +0 -1063
- package/source/class/qx/io/remote/Request.js +0 -1021
- package/source/class/qx/io/remote/RequestQueue.js +0 -521
- package/source/class/qx/io/remote/Response.js +0 -137
- package/source/class/qx/io/remote/Rpc.js +0 -1075
- package/source/class/qx/io/remote/RpcError.js +0 -198
- package/source/class/qx/io/remote/__init__.js +0 -88
- package/source/class/qx/io/remote/transport/Abstract.js +0 -513
- package/source/class/qx/io/remote/transport/Iframe.js +0 -652
- package/source/class/qx/io/remote/transport/Script.js +0 -475
- package/source/class/qx/io/remote/transport/XmlHttp.js +0 -1019
- package/source/class/qx/io/remote/transport/__init__.js +0 -3
- package/source/class/qx/test/io/remote/AbstractRequest.js +0 -150
- package/source/class/qx/test/io/remote/RequestIframe.js +0 -105
- package/source/class/qx/test/io/remote/RequestXhr.js +0 -151
- package/source/class/qx/test/io/remote/Rpc.js +0 -205
- package/source/class/qx/test/io/remote/__init__.js +0 -4
- package/source/class/qx/test/io/remote/transport/Iframe.js +0 -67
- package/source/class/qx/test/io/remote/transport/XmlHttp.js +0 -133
- package/source/class/qx/test/io/remote/transport/__init__.js +0 -4
|
@@ -0,0 +1,368 @@
|
|
|
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("path");
|
|
21
|
+
const babelCore = require("@babel/core");
|
|
22
|
+
|
|
23
|
+
const types = require("@babel/types");
|
|
24
|
+
const babylon = require("@babel/parser");
|
|
25
|
+
const prettier = require("prettier");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Helper method that collapses the MemberExpression into a string
|
|
29
|
+
* @param node
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
function collapseMemberExpression(node) {
|
|
33
|
+
var done = false;
|
|
34
|
+
function doCollapse(node) {
|
|
35
|
+
if (node.type == "ThisExpression") {
|
|
36
|
+
return "this";
|
|
37
|
+
}
|
|
38
|
+
if (node.type == "Identifier") {
|
|
39
|
+
return node.name;
|
|
40
|
+
}
|
|
41
|
+
if (node.type == "ArrayExpression") {
|
|
42
|
+
var result = [];
|
|
43
|
+
node.elements.forEach(element => result.push(doCollapse(element)));
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
if (node.type != "MemberExpression") {
|
|
47
|
+
return "(" + node.type + ")";
|
|
48
|
+
}
|
|
49
|
+
if (types.isIdentifier(node.object)) {
|
|
50
|
+
let str = node.object.name;
|
|
51
|
+
if (node.property.name) {
|
|
52
|
+
str += "." + node.property.name;
|
|
53
|
+
} else {
|
|
54
|
+
done = true;
|
|
55
|
+
}
|
|
56
|
+
return str;
|
|
57
|
+
}
|
|
58
|
+
var str;
|
|
59
|
+
if (node.object.type == "ArrayExpression") {
|
|
60
|
+
str = "[]";
|
|
61
|
+
} else {
|
|
62
|
+
str = doCollapse(node.object);
|
|
63
|
+
}
|
|
64
|
+
if (done) {
|
|
65
|
+
return str;
|
|
66
|
+
}
|
|
67
|
+
// `computed` is set if the expression is a subscript, eg `abc[def]`
|
|
68
|
+
if (node.computed) {
|
|
69
|
+
done = true;
|
|
70
|
+
} else if (node.property.name) {
|
|
71
|
+
str += "." + node.property.name;
|
|
72
|
+
} else {
|
|
73
|
+
done = true;
|
|
74
|
+
}
|
|
75
|
+
return str;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return doCollapse(node);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Processes a .js source file and tries to upgrade to ES6 syntax
|
|
83
|
+
*
|
|
84
|
+
* This is a reliable but fairly unintrusive upgrade, provided that `arrowFunctions` property is
|
|
85
|
+
* `careful`. The issue is that this code: `setTimeout(function() { something(); })` can be
|
|
86
|
+
* changed to `setTimeout(() => something())` and that is often desirable, but it also means that
|
|
87
|
+
* the `this` will be different because an arrow function always has the `this` from where the
|
|
88
|
+
* code is written.
|
|
89
|
+
*
|
|
90
|
+
* However, if you use an API which changes `this` then the switch to arrow functions will break
|
|
91
|
+
* your code. Mostly, in Qooxdoo, changes to `this` are done via an explicit API (eg
|
|
92
|
+
* `obj.addListener("changeXyx", function() {}, this)`) and so those known APIs can be translated,
|
|
93
|
+
* but there are places which do not work this way (eg the unit tests `qx.dev.unit.TestCase.resume()`).
|
|
94
|
+
* Third party integrations are of course completely unknown.
|
|
95
|
+
*
|
|
96
|
+
* If `arrowFunctions` is set to aggressive, then all functions are switched to arrow functions except
|
|
97
|
+
* where there is a known API that does not support it (eg any call to `.resume` in a test class); this
|
|
98
|
+
* could break your code.
|
|
99
|
+
*
|
|
100
|
+
* If `arrowFunctions is set to `careful` (the default), then functions are only switched to arrow
|
|
101
|
+
* functions where the API is known (eg `.addListener`).
|
|
102
|
+
*
|
|
103
|
+
* The final step is that the ES6ify will use https://prettier.io/ to reformat the code, and will use
|
|
104
|
+
* the nearest `prettierrc.json` for configuration
|
|
105
|
+
*/
|
|
106
|
+
qx.Class.define("qx.tool.compiler.Es6ify", {
|
|
107
|
+
extend: qx.core.Object,
|
|
108
|
+
|
|
109
|
+
construct(filename) {
|
|
110
|
+
this.base(arguments);
|
|
111
|
+
this.__filename = filename;
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
properties: {
|
|
115
|
+
/** Whether to convert functions to arrow functions; careful means only on things like addListener callbacks */
|
|
116
|
+
arrowFunctions: {
|
|
117
|
+
init: "careful",
|
|
118
|
+
check: [ "never", "always", "careful", "aggressive" ],
|
|
119
|
+
nullable: true
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
/** Whether to overwrite the original file */
|
|
123
|
+
overwrite: {
|
|
124
|
+
init: false,
|
|
125
|
+
check: "Boolean"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
members: {
|
|
130
|
+
__filename: null,
|
|
131
|
+
|
|
132
|
+
async transform() {
|
|
133
|
+
let src = await fs.promises.readFile(this.__filename, "utf8");
|
|
134
|
+
|
|
135
|
+
let babelConfig = {};
|
|
136
|
+
let options = qx.lang.Object.clone(babelConfig.options || {}, true);
|
|
137
|
+
options.modules = false;
|
|
138
|
+
let plugins = [
|
|
139
|
+
require("@babel/plugin-syntax-jsx"),
|
|
140
|
+
this.__pluginFunctionExpressions()
|
|
141
|
+
];
|
|
142
|
+
if (this.getArrowFunctions() != "never") {
|
|
143
|
+
plugins.push(this.__pluginArrowFunctions());
|
|
144
|
+
}
|
|
145
|
+
plugins.push(this.__pluginRemoveUnnecessaryThis());
|
|
146
|
+
plugins.push(this.__pluginSwitchToSuper());
|
|
147
|
+
var config = {
|
|
148
|
+
ast: true,
|
|
149
|
+
babelrc: false,
|
|
150
|
+
sourceFileName: this.__filename,
|
|
151
|
+
filename: this.__filename,
|
|
152
|
+
sourceMaps: false,
|
|
153
|
+
presets: [
|
|
154
|
+
[
|
|
155
|
+
{
|
|
156
|
+
plugins: plugins
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
],
|
|
160
|
+
parserOpts: {
|
|
161
|
+
allowSuperOutsideMethod: true,
|
|
162
|
+
sourceType: "script"
|
|
163
|
+
},
|
|
164
|
+
generatorOpts: {
|
|
165
|
+
retainLines: true
|
|
166
|
+
},
|
|
167
|
+
passPerPreset: true
|
|
168
|
+
};
|
|
169
|
+
let result = babelCore.transform(src, config);
|
|
170
|
+
|
|
171
|
+
let prettierConfig = await prettier.resolveConfig(this.__filename, { editorConfig: true })||{};
|
|
172
|
+
prettierConfig.parser = "babel";
|
|
173
|
+
let prettyCode = prettier.format(result.code, prettierConfig);
|
|
174
|
+
|
|
175
|
+
let outname = this.__filename + (this.isOverwrite() ? "" : ".es6ify");
|
|
176
|
+
await fs.promises.writeFile(outname, prettyCode, "utf8");
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Plugin that converts object properties which are functions into object methods, eg
|
|
181
|
+
* ```
|
|
182
|
+
* {
|
|
183
|
+
* myMethod: function() {}
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
186
|
+
* becomes
|
|
187
|
+
* ```
|
|
188
|
+
* {
|
|
189
|
+
* myMethod() {}
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
* @returns
|
|
193
|
+
*/
|
|
194
|
+
__pluginFunctionExpressions() {
|
|
195
|
+
return {
|
|
196
|
+
visitor: {
|
|
197
|
+
ObjectExpression(path) {
|
|
198
|
+
for (let i = 0; i < path.node.properties.length; i++) {
|
|
199
|
+
let propNode = path.node.properties[i];
|
|
200
|
+
if (
|
|
201
|
+
propNode.type == "ObjectProperty" &&
|
|
202
|
+
propNode.value.type == "FunctionExpression"
|
|
203
|
+
) {
|
|
204
|
+
let replacement = types.objectMethod(
|
|
205
|
+
"method",
|
|
206
|
+
propNode.key,
|
|
207
|
+
propNode.value.params,
|
|
208
|
+
propNode.value.body,
|
|
209
|
+
propNode.value.computed,
|
|
210
|
+
propNode.value.generator,
|
|
211
|
+
propNode.value.async
|
|
212
|
+
);
|
|
213
|
+
replacement.loc = propNode.loc;
|
|
214
|
+
replacement.start = propNode.start;
|
|
215
|
+
replacement.end = propNode.end;
|
|
216
|
+
replacement.leadingComments = propNode.leadingComments;
|
|
217
|
+
path.node.properties[i] = replacement;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
__toArrowExpression(argNode) {
|
|
226
|
+
let body = argNode.body;
|
|
227
|
+
if (body.body.length == 1 && body.body[0].type == "ReturnStatement") {
|
|
228
|
+
body = body.body[0].argument;
|
|
229
|
+
}
|
|
230
|
+
let replacement = types.arrowFunctionExpression(
|
|
231
|
+
argNode.params,
|
|
232
|
+
body,
|
|
233
|
+
argNode.async
|
|
234
|
+
);
|
|
235
|
+
replacement.loc = argNode.loc;
|
|
236
|
+
replacement.start = argNode.start;
|
|
237
|
+
replacement.end = argNode.end;
|
|
238
|
+
replacement.leadingComments = argNode.leadingComments;
|
|
239
|
+
return replacement;
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Tries to convert functions into arrow functions
|
|
244
|
+
* @returns
|
|
245
|
+
*/
|
|
246
|
+
__pluginArrowFunctions() {
|
|
247
|
+
let t = this;
|
|
248
|
+
const isTest = this.__filename.indexOf("/test/") > -1;
|
|
249
|
+
let arrowFunctions = this.getArrowFunctions();
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
visitor: {
|
|
253
|
+
CallExpression(path) {
|
|
254
|
+
if (path.node.callee.type == "MemberExpression") {
|
|
255
|
+
let callee = collapseMemberExpression(path.node.callee);
|
|
256
|
+
if (arrowFunctions == "careful") {
|
|
257
|
+
if (!callee.endsWith(".addListener")) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (
|
|
261
|
+
path.node.arguments.length != 3 ||
|
|
262
|
+
path.node.arguments[0].type != "StringLiteral" ||
|
|
263
|
+
path.node.arguments[1].type != "ArrowFunctionExpression" ||
|
|
264
|
+
path.node.arguments[2].type != "ThisExpression"
|
|
265
|
+
) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
} else if (arrowFunctions == "aggressive") {
|
|
270
|
+
if (callee == "qx.event.GlobalError.observeMethod" ||
|
|
271
|
+
callee == "this.assertException" ||
|
|
272
|
+
callee == "this.assertEventFired" ||
|
|
273
|
+
callee == "qx.core.Assert.assertEventFired" ||
|
|
274
|
+
(isTest && callee.endsWith(".resume"))) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} else if (arrowFunctions == "careful") {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
for (let i = 0; i < path.node.arguments.length; i++){
|
|
282
|
+
let argNode = path.node.arguments[i];
|
|
283
|
+
if (argNode.type == "FunctionExpression") {
|
|
284
|
+
path.node.arguments[i] = t.__toArrowExpression(argNode);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Where a function has been translated into an arrow function, the this binding is not needed
|
|
294
|
+
* and can be removed
|
|
295
|
+
* @returns
|
|
296
|
+
*/
|
|
297
|
+
__pluginRemoveUnnecessaryThis() {
|
|
298
|
+
return {
|
|
299
|
+
visitor: {
|
|
300
|
+
CallExpression(path) {
|
|
301
|
+
if (
|
|
302
|
+
path.node.callee.type == "MemberExpression" &&
|
|
303
|
+
path.node.callee.object.type == "ThisExpression" &&
|
|
304
|
+
path.node.callee.property.type == "Identifier" &&
|
|
305
|
+
path.node.callee.property.name == "addListener" &&
|
|
306
|
+
path.node.arguments.length == 3 &&
|
|
307
|
+
path.node.arguments[0].type == "StringLiteral" &&
|
|
308
|
+
path.node.arguments[1].type == "ArrowFunctionExpression" &&
|
|
309
|
+
path.node.arguments[2].type == "ThisExpression"
|
|
310
|
+
) {
|
|
311
|
+
qx.lang.Array.removeAt(path.node.arguments, 2);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Translates `this.base(arguments...)` into `super`
|
|
320
|
+
* @returns
|
|
321
|
+
*/
|
|
322
|
+
__pluginSwitchToSuper() {
|
|
323
|
+
let methodNameStack = [];
|
|
324
|
+
function peekMethodName() {
|
|
325
|
+
for (let i = methodNameStack.length - 1; i >= 0; i--) {
|
|
326
|
+
let methodName = methodNameStack[i];
|
|
327
|
+
if (methodName) {
|
|
328
|
+
return methodName;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
visitor: {
|
|
335
|
+
ObjectMethod: {
|
|
336
|
+
enter(path) {
|
|
337
|
+
methodNameStack.push(path.node.key.name||null);
|
|
338
|
+
},
|
|
339
|
+
exit(path) {
|
|
340
|
+
methodNameStack.pop();
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
CallExpression(path) {
|
|
344
|
+
if (
|
|
345
|
+
path.node.callee.type == "MemberExpression" &&
|
|
346
|
+
path.node.callee.object.type == "ThisExpression" &&
|
|
347
|
+
path.node.callee.property.type == "Identifier" &&
|
|
348
|
+
path.node.callee.property.name == "base" &&
|
|
349
|
+
path.node.arguments.length >= 1
|
|
350
|
+
) {
|
|
351
|
+
let args = qx.lang.Array.clone(path.node.arguments);
|
|
352
|
+
args.shift();
|
|
353
|
+
let methodName = peekMethodName();
|
|
354
|
+
if (methodName == "construct") {
|
|
355
|
+
path.node.callee = types.super();
|
|
356
|
+
path.node.arguments = args;
|
|
357
|
+
} else if (methodName) {
|
|
358
|
+
let replacement = types.memberExpression(types.super(), types.identifier(methodName), false, false);
|
|
359
|
+
path.node.callee = replacement;
|
|
360
|
+
path.node.arguments = args;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
});
|
|
@@ -81,7 +81,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
81
81
|
inheritable: true,
|
|
82
82
|
nullable: true
|
|
83
83
|
},
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
/**
|
|
86
86
|
* List of environment keys to preserve in code, ie reserve for runtime detection
|
|
87
87
|
* and exclude from code elimination
|
|
@@ -98,7 +98,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
98
98
|
analyser: {
|
|
99
99
|
nullable: false
|
|
100
100
|
},
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
/**
|
|
103
103
|
* Whether to inline external scripts
|
|
104
104
|
*/
|
|
@@ -121,7 +121,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
121
121
|
init: [ "en" ],
|
|
122
122
|
transform: "_transformLocales"
|
|
123
123
|
},
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
/** Whether to break locale & translation data out into separate parts */
|
|
126
126
|
i18nAsParts: {
|
|
127
127
|
init: false,
|
|
@@ -142,7 +142,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
142
142
|
nullable: false,
|
|
143
143
|
check: "Boolean"
|
|
144
144
|
},
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
/** What to do with library transation strings */
|
|
147
147
|
libraryPoPolicy: {
|
|
148
148
|
init: "ignore",
|
|
@@ -166,6 +166,15 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
166
166
|
init: true,
|
|
167
167
|
nullable: false,
|
|
168
168
|
check: "Boolean"
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether to use relative paths in source maps
|
|
173
|
+
*/
|
|
174
|
+
sourceMapRelativePaths: {
|
|
175
|
+
init: false,
|
|
176
|
+
nullable: false,
|
|
177
|
+
check: "Boolean"
|
|
169
178
|
}
|
|
170
179
|
|
|
171
180
|
},
|
|
@@ -178,15 +187,15 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
178
187
|
* enviroment: {Object} enviroment data
|
|
179
188
|
*/
|
|
180
189
|
"checkEnvironment": "qx.event.type.Data",
|
|
181
|
-
|
|
182
|
-
/**
|
|
190
|
+
|
|
191
|
+
/**
|
|
183
192
|
* Fired when an application is about to be serialized to disk; the appMeta is fully
|
|
184
193
|
* populated, and this is an opportunity to amend the meta data before it is serialized
|
|
185
|
-
* into files on disk
|
|
194
|
+
* into files on disk
|
|
186
195
|
*/
|
|
187
196
|
"writingApplication": "qx.event.type.Event",
|
|
188
|
-
|
|
189
|
-
/**
|
|
197
|
+
|
|
198
|
+
/**
|
|
190
199
|
* Fired when an application has been serialized to disk
|
|
191
200
|
*/
|
|
192
201
|
"writtenApplication": "qx.event.type.Event"
|
|
@@ -196,10 +205,10 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
196
205
|
members: {
|
|
197
206
|
/** @type {Map} maps filenames to uris */
|
|
198
207
|
__pathMappings: null,
|
|
199
|
-
|
|
208
|
+
|
|
200
209
|
/** @type {qx.tool.compiler.targets.meta.ApplicationMeta} for the current application */
|
|
201
210
|
__appMeta: null,
|
|
202
|
-
|
|
211
|
+
|
|
203
212
|
/**
|
|
204
213
|
* Initialises the target, creating directories etc
|
|
205
214
|
*/
|
|
@@ -221,7 +230,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
221
230
|
}
|
|
222
231
|
return value;
|
|
223
232
|
},
|
|
224
|
-
|
|
233
|
+
|
|
225
234
|
/**
|
|
226
235
|
* Returns the root for applications
|
|
227
236
|
*/
|
|
@@ -237,7 +246,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
237
246
|
getProjectDir: function (application) {
|
|
238
247
|
return application.getOutputPath() || application.getName();
|
|
239
248
|
},
|
|
240
|
-
|
|
249
|
+
|
|
241
250
|
/**
|
|
242
251
|
* Returns the URI for the root of the output, relative to the application
|
|
243
252
|
*/
|
|
@@ -331,22 +340,22 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
331
340
|
|
|
332
341
|
let appMeta = this.__appMeta = new qx.tool.compiler.targets.meta.ApplicationMeta(this, application);
|
|
333
342
|
appMeta.setAddTimestampsToUrls(this.getAddTimestampsToUrls());
|
|
334
|
-
/*
|
|
343
|
+
/*
|
|
335
344
|
if (!appMeta.getAppLibrary()) {
|
|
336
345
|
qx.tool.compiler.Console.print("qx.tool.compiler.target.missingAppLibrary", application.getClassName());
|
|
337
346
|
return;
|
|
338
347
|
}
|
|
339
|
-
*/
|
|
348
|
+
*/
|
|
340
349
|
let targetUri = t._getOutputRootUri(application);
|
|
341
350
|
var appRootDir = this.getApplicationRoot(application);
|
|
342
|
-
|
|
351
|
+
|
|
343
352
|
let mapTo = this.getPathMapping(path.join(appRootDir, this.getOutputDir(), "transpiled/"));
|
|
344
353
|
appMeta.setSourceUri(mapTo ? mapTo : targetUri + "transpiled/");
|
|
345
354
|
mapTo = this.getPathMapping(path.join(appRootDir, this.getOutputDir(), "resource"));
|
|
346
355
|
appMeta.setResourceUri(mapTo ? mapTo : targetUri + "resource");
|
|
347
|
-
|
|
356
|
+
|
|
348
357
|
const requiredLibs = application.getRequiredLibraries();
|
|
349
|
-
|
|
358
|
+
|
|
350
359
|
await qx.tool.utils.Utils.makeDirs(appRootDir);
|
|
351
360
|
|
|
352
361
|
appMeta.setEnvironment({
|
|
@@ -357,7 +366,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
357
366
|
"qx.compiler.targetType": this.getType(),
|
|
358
367
|
"qx.compiler.outputDir": this.getOutputDir()
|
|
359
368
|
});
|
|
360
|
-
|
|
369
|
+
|
|
361
370
|
let externals = {};
|
|
362
371
|
const addExternal = (arr, type) => {
|
|
363
372
|
if (arr) {
|
|
@@ -380,7 +389,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
380
389
|
});
|
|
381
390
|
}
|
|
382
391
|
};
|
|
383
|
-
|
|
392
|
+
|
|
384
393
|
requiredLibs.forEach(libnamespace => {
|
|
385
394
|
var library = analyser.findLibrary(libnamespace);
|
|
386
395
|
appMeta.addLibrary(library);
|
|
@@ -400,7 +409,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
400
409
|
}
|
|
401
410
|
await t.fireDataEventAsync("checkEnvironment", { application: application, environment: appMeta.getEnvironment() });
|
|
402
411
|
|
|
403
|
-
|
|
412
|
+
|
|
404
413
|
/*
|
|
405
414
|
* Boot files
|
|
406
415
|
*/
|
|
@@ -408,7 +417,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
408
417
|
let bootPackage = appMeta.createPackage();
|
|
409
418
|
appMeta.setBootMetaJs(bootJs);
|
|
410
419
|
bootPackage.addJavascriptMeta(new qx.tool.compiler.targets.meta.PolyfillJs(appMeta));
|
|
411
|
-
|
|
420
|
+
|
|
412
421
|
|
|
413
422
|
/*
|
|
414
423
|
* Assemble the Parts
|
|
@@ -425,7 +434,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
425
434
|
if (index == 0) {
|
|
426
435
|
partMeta.addPackage(bootPackage);
|
|
427
436
|
}
|
|
428
|
-
|
|
437
|
+
|
|
429
438
|
partData.classes.forEach(classname => {
|
|
430
439
|
let classFilename = classname.replace(/\./g, "/") + ".js";
|
|
431
440
|
|
|
@@ -435,10 +444,10 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
435
444
|
let library = analyser.findLibrary(dbClassInfo.libraryName);
|
|
436
445
|
let sourcePath = library.getFilename(classFilename);
|
|
437
446
|
let jsMeta = new qx.tool.compiler.targets.meta.Javascript(appMeta, transpiledClassFilename, sourcePath);
|
|
438
|
-
|
|
447
|
+
|
|
439
448
|
let packageName = matchBundle(classname) ? "__bundle" : partData.name;
|
|
440
449
|
let pkg = packages[packageName];
|
|
441
|
-
|
|
450
|
+
|
|
442
451
|
if (!pkg || pkg !== lastPackage) {
|
|
443
452
|
pkg = packages[packageName] = appMeta.createPackage();
|
|
444
453
|
if (packageName == "__bundle") {
|
|
@@ -454,7 +463,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
454
463
|
lastPackage = pkg;
|
|
455
464
|
});
|
|
456
465
|
});
|
|
457
|
-
|
|
466
|
+
|
|
458
467
|
var assetUris = application.getAssetUris(t, rm, appMeta.getEnvironment()); // Save any changes that getAssets collected
|
|
459
468
|
await rm.saveDatabase();
|
|
460
469
|
|
|
@@ -462,8 +471,8 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
462
471
|
analyser.getCldr("en")
|
|
463
472
|
.then(cldr => bootPackage.addLocale("C", cldr)),
|
|
464
473
|
t._writeTranslations()
|
|
465
|
-
];
|
|
466
|
-
|
|
474
|
+
];
|
|
475
|
+
|
|
467
476
|
var fontCntr = 0;
|
|
468
477
|
var assets = {};
|
|
469
478
|
rm.getAssetsForPaths(assetUris).forEach(asset => {
|
|
@@ -475,7 +484,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
475
484
|
// Get a list of all fonts to load; use the font name as a unique identifier, and
|
|
476
485
|
// prioritise the application's library's definitions - this allows the application
|
|
477
486
|
// the opportunity to override the font definitions. This is important when the
|
|
478
|
-
// library uses the open source/free versions of a font but the application
|
|
487
|
+
// library uses the open source/free versions of a font but the application
|
|
479
488
|
// developer has purchased the commercial/full version of the font (eg FontAwesome)
|
|
480
489
|
let appLibrary = appMeta.getAppLibrary();
|
|
481
490
|
let fontsToLoad = { };
|
|
@@ -507,7 +516,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
507
516
|
return;
|
|
508
517
|
}
|
|
509
518
|
font.setResources(res);
|
|
510
|
-
|
|
519
|
+
|
|
511
520
|
await font.generateForTarget(t);
|
|
512
521
|
let resources = await font.generateForApplication(t, application);
|
|
513
522
|
for (var key in resources) {
|
|
@@ -617,10 +626,10 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
617
626
|
return accumulateCldr(localeId);
|
|
618
627
|
}
|
|
619
628
|
|
|
620
|
-
var promises = t.getLocales().map(async localeId => {
|
|
629
|
+
var promises = t.getLocales().map(async localeId => {
|
|
621
630
|
let cldr = await loadLocaleData(localeId);
|
|
622
631
|
let pkg = this.isI18nAsParts() ? appMeta.getLocalePackage(localeId) : bootPackage;
|
|
623
|
-
pkg.addLocale(localeId, cldr);
|
|
632
|
+
pkg.addLocale(localeId, cldr);
|
|
624
633
|
});
|
|
625
634
|
|
|
626
635
|
await qx.Promise.all(promises);
|
|
@@ -656,8 +665,8 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
656
665
|
promises.push(
|
|
657
666
|
addTrans(library, localeId)
|
|
658
667
|
);
|
|
659
|
-
});
|
|
660
|
-
// translation from main app should overwrite package translations
|
|
668
|
+
});
|
|
669
|
+
// translation from main app should overwrite package translations
|
|
661
670
|
promises.push(
|
|
662
671
|
addTrans(appMeta.getAppLibrary(), localeId)
|
|
663
672
|
);
|
|
@@ -726,24 +735,24 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
726
735
|
});
|
|
727
736
|
});
|
|
728
737
|
},
|
|
729
|
-
|
|
738
|
+
|
|
730
739
|
/**
|
|
731
740
|
* Writes the application
|
|
732
741
|
*/
|
|
733
742
|
async _writeApplication() {
|
|
734
743
|
var t = this;
|
|
735
|
-
|
|
744
|
+
|
|
736
745
|
await this.fireEventAsync("writingApplication");
|
|
737
|
-
|
|
746
|
+
|
|
738
747
|
let appMeta = this.getAppMeta();
|
|
739
748
|
var application = appMeta.getApplication();
|
|
740
749
|
var appRootDir = appMeta.getApplicationRoot();
|
|
741
|
-
|
|
750
|
+
|
|
742
751
|
if (!appMeta.getAppLibrary()) {
|
|
743
752
|
qx.tool.compiler.Console.print("qx.tool.compiler.target.missingAppLibrary", application.getName());
|
|
744
753
|
return;
|
|
745
754
|
}
|
|
746
|
-
|
|
755
|
+
|
|
747
756
|
let bootMeta = appMeta.getBootMetaJs();
|
|
748
757
|
for (let arr = appMeta.getPackages(), i = 0; i < arr.length; i++) {
|
|
749
758
|
let pkg = arr[i];
|
|
@@ -753,16 +762,16 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
753
762
|
}
|
|
754
763
|
await pkg.getJavascript().unwrap().writeToDisk();
|
|
755
764
|
}
|
|
756
|
-
|
|
765
|
+
|
|
757
766
|
await appMeta.getBootMetaJs().unwrap().writeToDisk();
|
|
758
|
-
|
|
767
|
+
|
|
759
768
|
await this._writeIndexHtml();
|
|
760
769
|
|
|
761
770
|
if (!t.isWriteCompileInfo()) {
|
|
762
771
|
await this.fireEventAsync("writtenApplication");
|
|
763
772
|
return;
|
|
764
773
|
}
|
|
765
|
-
|
|
774
|
+
|
|
766
775
|
let bootPackage = appMeta.getPackages()[0];
|
|
767
776
|
let appSummary = {
|
|
768
777
|
appClass: application.getClassName(),
|
|
@@ -783,11 +792,11 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
783
792
|
name: partData.name
|
|
784
793
|
});
|
|
785
794
|
});
|
|
786
|
-
|
|
795
|
+
|
|
787
796
|
await fs.writeFileAsync(appRootDir + "/compile-info.json",
|
|
788
797
|
JSON.stringify(appSummary, null, 2) + "\n",
|
|
789
798
|
{ encoding: "utf8" });
|
|
790
|
-
|
|
799
|
+
|
|
791
800
|
await this.fireEventAsync("writtenApplication");
|
|
792
801
|
},
|
|
793
802
|
|
|
@@ -808,7 +817,7 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
808
817
|
}
|
|
809
818
|
|
|
810
819
|
var resDir = this.getApplicationRoot(application);
|
|
811
|
-
|
|
820
|
+
|
|
812
821
|
let timeStamp = (new Date()).getTime();
|
|
813
822
|
let pathToTarget = path.relative(path.join(t.getOutputDir(), t.getProjectDir(application)), t.getOutputDir()) + "/";
|
|
814
823
|
let indexJsTimestamp = "";
|
|
@@ -895,12 +904,12 @@ qx.Class.define("qx.tool.compiler.targets.Target", {
|
|
|
895
904
|
"preBootJs": "",
|
|
896
905
|
"appTitle": (application.getTitle()||"Qooxdoo Application"),
|
|
897
906
|
"timeStamp": timeStamp,
|
|
898
|
-
"indexJsTimestamp": indexJsTimestamp
|
|
907
|
+
"indexJsTimestamp": indexJsTimestamp
|
|
899
908
|
};
|
|
900
909
|
await fs.writeFileAsync(t.getOutputDir() + "index.html", replaceVars(indexHtml), { encoding: "utf8" });
|
|
901
910
|
}
|
|
902
911
|
},
|
|
903
|
-
|
|
912
|
+
|
|
904
913
|
getAppMeta() {
|
|
905
914
|
return this.__appMeta;
|
|
906
915
|
}
|