@qooxdoo/framework 7.5.1 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/Manifest.json +169 -44
  2. package/lib/compiler/compile-info.json +76 -68
  3. package/lib/compiler/index.js +3683 -2588
  4. package/lib/resource/qx/tool/schema/Manifest-1-0-0.json +79 -26
  5. package/lib/resource/qx/tool/schema/Manifest-2-0-0.json +17 -26
  6. package/lib/resource/qx/tool/schema/compile-1-0-0.json +40 -53
  7. package/package.json +2 -2
  8. package/source/class/qx/bom/Font.js +36 -0
  9. package/source/class/qx/bom/webfonts/Validator.js +31 -6
  10. package/source/class/qx/bom/webfonts/WebFont.js +60 -64
  11. package/source/class/qx/bom/webfonts/WebFontLoader.js +461 -0
  12. package/source/class/qx/core/Object.js +1 -1
  13. package/source/class/qx/data/Array.js +27 -0
  14. package/source/class/qx/dev/FakeServer.js +1 -1
  15. package/source/class/qx/event/handler/Focus.js +2 -1
  16. package/source/class/qx/event/handler/GestureCore.js +1 -1
  17. package/source/class/qx/test/bom/webfonts/Validator.js +0 -6
  18. package/source/class/qx/test/core/Environment.js +8 -8
  19. package/source/class/qx/test/core/Validation.js +2 -2
  20. package/source/class/qx/test/dev/unit/Requirements.js +6 -6
  21. package/source/class/qx/test/ui/basic/Image.js +3 -3
  22. package/source/class/qx/test/ui/basic/Label.js +0 -65
  23. package/source/class/qx/test/ui/form/Field.js +56 -52
  24. package/source/class/qx/theme/classic/Font.js +7 -23
  25. package/source/class/qx/theme/iconfont/LoadMaterialIcons.js +2 -4
  26. package/source/class/qx/theme/iconfont/LoadMaterialIconsOutlined.js +2 -4
  27. package/source/class/qx/theme/iconfont/LoadMaterialIconsRound.js +2 -4
  28. package/source/class/qx/theme/iconfont/LoadMaterialIconsSharp.js +2 -4
  29. package/source/class/qx/theme/iconfont/LoadMaterialIconsTwoTone.js +2 -4
  30. package/source/class/qx/theme/indigo/Font.js +8 -15
  31. package/source/class/qx/theme/manager/Font.js +151 -38
  32. package/source/class/qx/theme/modern/Font.js +1 -0
  33. package/source/class/qx/theme/simple/Font.js +3 -1
  34. package/source/class/qx/theme/tangible/Appearance.js +1 -0
  35. package/source/class/qx/theme/tangible/Font.js +9 -62
  36. package/source/class/qx/theme/tangible/Image.js +1 -4
  37. package/source/class/qx/tool/cli/Cli.js +12 -0
  38. package/source/class/qx/tool/cli/Watch.js +3 -0
  39. package/source/class/qx/tool/cli/api/CompilerApi.js +8 -0
  40. package/source/class/qx/tool/cli/commands/Add.js +1 -1
  41. package/source/class/qx/tool/cli/commands/Compile.js +22 -0
  42. package/source/class/qx/tool/cli/commands/Config.js +16 -141
  43. package/source/class/qx/tool/cli/commands/ExportGlyphs.js +134 -0
  44. package/source/class/qx/tool/cli/commands/Package.js +3 -0
  45. package/source/class/qx/tool/cli/commands/Pkg.js +1 -1
  46. package/source/class/qx/tool/cli/commands/config/Delete.js +47 -0
  47. package/source/class/qx/tool/cli/commands/config/Get.js +52 -0
  48. package/source/class/qx/tool/cli/commands/config/List.js +81 -0
  49. package/source/class/qx/tool/cli/commands/config/Set.js +61 -0
  50. package/source/class/qx/tool/cli/commands/package/Update.js +3 -3
  51. package/source/class/qx/tool/compiler/Analyser.js +45 -0
  52. package/source/class/qx/tool/compiler/ClassFile.js +41 -0
  53. package/source/class/qx/tool/compiler/Console.js +6 -1
  54. package/source/class/qx/tool/compiler/app/Application.js +19 -0
  55. package/source/class/qx/tool/compiler/app/Library.js +51 -2
  56. package/source/class/qx/tool/compiler/app/ManifestFont.js +181 -0
  57. package/source/class/qx/tool/compiler/app/WebFont.js +144 -234
  58. package/source/class/qx/tool/compiler/makers/AppMaker.js +13 -0
  59. package/source/class/qx/tool/compiler/resources/ImageLoader.js +22 -12
  60. package/source/class/qx/tool/compiler/resources/Manager.js +2 -2
  61. package/source/class/qx/tool/compiler/resources/MetaLoader.js +7 -2
  62. package/source/class/qx/tool/compiler/resources/ResourceLoader.js +21 -0
  63. package/source/class/qx/tool/compiler/targets/Target.js +186 -67
  64. package/source/class/qx/tool/migration/M7_5_6.js +75 -0
  65. package/source/class/qx/tool/utils/Http.js +69 -0
  66. package/source/class/qx/ui/basic/Label.js +20 -38
  67. package/source/class/qx/ui/form/AbstractField.js +8 -2
  68. package/source/class/qx/ui/form/FileSelectorButton.js +5 -0
  69. package/source/class/qx/ui/table/pane/FocusIndicator.js +5 -4
  70. package/source/class/qx/ui/table/pane/Pane.js +14 -0
  71. package/source/class/qx/ui/table/pane/Scroller.js +3 -3
  72. package/source/class/qx/ui/virtual/core/Scroller.js +8 -2
  73. package/source/class/qx/ui/window/Window.js +9 -8
  74. package/source/resource/qx/iconfont/MaterialIcons/materialicons.json +10912 -0
  75. package/source/resource/qx/iconfont/MaterialIcons/materialiconsoutlined.json +10967 -0
  76. package/source/resource/qx/iconfont/MaterialIcons/materialiconsround.json +10992 -0
  77. package/source/resource/qx/iconfont/MaterialIcons/materialiconssharp.json +10992 -0
  78. package/source/resource/qx/iconfont/MaterialIcons/materialiconstwotone.json +9947 -0
  79. package/source/resource/qx/iconfont/MaterialIcons/x.json +10967 -0
  80. package/source/resource/qx/iconfont/export-glyphs.sh +22 -0
  81. package/source/resource/qx/tool/schema/Manifest-1-0-0.json +79 -26
  82. package/source/resource/qx/tool/schema/Manifest-2-0-0.json +17 -26
  83. package/source/resource/qx/tool/schema/compile-1-0-0.json +40 -53
  84. package/source/class/qx/bom/webfonts/Manager.js +0 -652
  85. package/source/class/qx/test/bom/webfonts/Manager.js +0 -238
@@ -208,6 +208,7 @@ qx.Class.define("qx.tool.compiler.ClassFile", {
208
208
  };
209
209
 
210
210
  this.__requiredAssets = [];
211
+ this.__requiredFonts = {};
211
212
  this.__translations = [];
212
213
  this.__markers = [];
213
214
  this.__haveMarkersFor = {};
@@ -256,6 +257,10 @@ qx.Class.define("qx.tool.compiler.ClassFile", {
256
257
  __requiredClasses: null,
257
258
  __environmentChecks: null,
258
259
  __requiredAssets: null,
260
+
261
+ /** @type{Map<String,Object>} list of fonts indexed by name; the value is an object with `name` and `loc` */
262
+ __requiredFonts: null,
263
+
259
264
  __translateMessageIds: null,
260
265
  __scope: null,
261
266
  __inDefer: false,
@@ -631,6 +636,22 @@ qx.Class.define("qx.tool.compiler.ClassFile", {
631
636
  if (assets.length) {
632
637
  dbClassInfo.assets = assets;
633
638
  }
639
+
640
+ // Fonts
641
+ var fontNames = Object.keys(this.__requiredFonts);
642
+ if (fontNames.length) {
643
+ dbClassInfo.fonts = fontNames;
644
+ for (let fontName in this.__requiredFonts) {
645
+ if (!this.__analyser.getFont(fontName)) {
646
+ t.addMarker(
647
+ "fonts.unresolved#" + fontName,
648
+ this.__requiredFonts[fontName].loc.start,
649
+ fontName
650
+ );
651
+ }
652
+ }
653
+ }
654
+
634
655
  if (meta) {
635
656
  if (meta.aliases) {
636
657
  dbClassInfo.aliases = {};
@@ -754,6 +775,11 @@ qx.Class.define("qx.tool.compiler.ClassFile", {
754
775
  t._requireAsset(elem.body);
755
776
  });
756
777
  }
778
+ if (jsdoc["@usefont"]) {
779
+ jsdoc["@usefont"].forEach(function (elem) {
780
+ t._requireFont(elem.body, loc);
781
+ });
782
+ }
757
783
  return jsdoc;
758
784
  }
759
785
 
@@ -861,6 +887,9 @@ qx.Class.define("qx.tool.compiler.ClassFile", {
861
887
  } else {
862
888
  meta.type = "variable";
863
889
  }
890
+ if (node.async) {
891
+ meta.async = true;
892
+ }
864
893
  if (functionName.startsWith("__")) {
865
894
  meta.access = "private";
866
895
  } else if (functionName.startsWith("_")) {
@@ -2896,6 +2925,18 @@ qx.Class.define("qx.tool.compiler.ClassFile", {
2896
2925
  return this.__requiredAssets;
2897
2926
  },
2898
2927
 
2928
+ /**
2929
+ * Adds a required font
2930
+ * @param {String} name name of the font
2931
+ * @param {Location} the Babel location
2932
+ */
2933
+ _requireFont(name, loc) {
2934
+ this.__requiredFonts[name] = {
2935
+ name,
2936
+ loc
2937
+ };
2938
+ },
2939
+
2899
2940
  /**
2900
2941
  * Finds an object property in a node tree (not a Qooxdoo property, an
2901
2942
  * object property)
@@ -267,7 +267,12 @@ qx.Class.define("qx.tool.compiler.Console", {
267
267
  /* eslint-enable no-template-curly-in-string */
268
268
 
269
269
  "qx.tool.compiler.maker.appNotHeadless":
270
- "Compiling application '%1' but the target supports non-headless output, you may find unwanted dependencies are loaded during startup"
270
+ "Compiling application '%1' but the target supports non-headless output, you may find unwanted dependencies are loaded during startup",
271
+
272
+ // Fonts
273
+ "qx.tool.compiler.webfonts.deprecated":
274
+ "Manifest uses deprecated provides.webfonts, consider switching to provides.font",
275
+ "qx.tool.compiler.fonts.unresolved": "Cannot find font with name %1"
271
276
  },
272
277
 
273
278
  "warning"
@@ -833,6 +833,25 @@ qx.Class.define("qx.tool.compiler.app.Application", {
833
833
  return assets;
834
834
  },
835
835
 
836
+ /**
837
+ * Returns a list of fonts required by the application, where the font is detailed in Manifest.json
838
+ * in `provides.fonts`
839
+ *
840
+ * @returns {String[]}
841
+ */
842
+ getFonts() {
843
+ var fonts = {};
844
+ var analyser = this.getAnalyser();
845
+ var db = analyser.getDatabase();
846
+ this.__loadDeps.forEach(classname => {
847
+ var classInfo = db.classInfo[classname];
848
+ if (classInfo.fonts) {
849
+ classInfo.fonts.forEach(fontName => (fonts[fontName] = true));
850
+ }
851
+ });
852
+ return Object.keys(fonts);
853
+ },
854
+
836
855
  /**
837
856
  * Returns the class name for the application
838
857
  * @returns {String}
@@ -93,7 +93,10 @@ qx.Class.define("qx.tool.compiler.app.Library", {
93
93
  check: "String"
94
94
  },
95
95
 
96
- /** {WebFont[]} List of webfonts provided */
96
+ /**
97
+ * {WebFont[]} List of webfonts provided
98
+ * @deprecated
99
+ */
97
100
  webFonts: {
98
101
  init: null,
99
102
  nullable: true,
@@ -121,6 +124,7 @@ qx.Class.define("qx.tool.compiler.app.Library", {
121
124
  __sourceFileExtensions: null,
122
125
  __promiseLoadManifest: null,
123
126
  __environmentChecks: null,
127
+ __fontsData: null,
124
128
 
125
129
  /**
126
130
  * Transform for rootDir; converts it to an absolute path
@@ -238,13 +242,19 @@ qx.Class.define("qx.tool.compiler.app.Library", {
238
242
  this.setTranslationPath(data.provides.translation);
239
243
  }
240
244
  if (data.provides.webfonts) {
241
- var fonts = [];
245
+ let fonts = [];
246
+ if (data.provides.webfonts.length) {
247
+ qx.tool.compiler.Console.print(
248
+ "qx.tool.compiler.webfonts.deprecated"
249
+ );
250
+ }
242
251
  data.provides.webfonts.forEach(wf => {
243
252
  var font = new qx.tool.compiler.app.WebFont(this).set(wf);
244
253
  fonts.push(font);
245
254
  });
246
255
  this.setWebFonts(fonts);
247
256
  }
257
+ this.__fontsData = data.provides.fonts || {};
248
258
  if (data.externalResources) {
249
259
  if (data.externalResources.script) {
250
260
  this.setAddScript(data.externalResources.script);
@@ -264,6 +274,15 @@ qx.Class.define("qx.tool.compiler.app.Library", {
264
274
  }
265
275
  },
266
276
 
277
+ /**
278
+ * Returns the provides.fonts data from the manifest
279
+ *
280
+ * @returns {Array}
281
+ */
282
+ getFontsData() {
283
+ return this.__fontsData;
284
+ },
285
+
267
286
  /**
268
287
  * Scans the filing system looking for classes; there are occasions (ie Qooxdoo's qxWeb module)
269
288
  * where the class name does not comply with the namespace, this method is used to find those
@@ -366,6 +385,36 @@ qx.Class.define("qx.tool.compiler.app.Library", {
366
385
  });
367
386
  },
368
387
 
388
+ /**
389
+ * Detects whether the filename is one of the library's fonts
390
+ *
391
+ * @param {String} filename
392
+ * @returns {Boolean}
393
+ */
394
+ isFontAsset(filename) {
395
+ let isWebFont = false;
396
+ if (filename.endsWith("svg")) {
397
+ let fonts = this.getWebFonts() || [];
398
+ isWebFont = fonts.find(webFont =>
399
+ webFont.getResources().find(resource => resource == filename)
400
+ );
401
+
402
+ if (!isWebFont) {
403
+ for (let fontId in this.__fontsData) {
404
+ let fontData = this.__fontsData[fontId];
405
+ isWebFont = (fontData.fontFaces || []).find(fontFace =>
406
+ (fontFace.paths || []).find(resource => resource == filename)
407
+ );
408
+
409
+ if (isWebFont) {
410
+ break;
411
+ }
412
+ }
413
+ }
414
+ }
415
+ return isWebFont;
416
+ },
417
+
369
418
  /**
370
419
  * Detects the type of a symbol, "class", "resource", "package", "environment", or null if not found
371
420
  *
@@ -0,0 +1,181 @@
1
+ /* ************************************************************************
2
+
3
+ qooxdoo - the new era of web development
4
+
5
+ http://qooxdoo.org
6
+
7
+ Copyright:
8
+ 2023 Zenesis Limited https://www.zenesis.com
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 (@johnspackman)
16
+
17
+ ************************************************************************ */
18
+
19
+ const fs = require("fs");
20
+ const path = require("path");
21
+
22
+ /**
23
+ * Represents a font as defined in the Manifest.json's
24
+ *
25
+ * @typedef Sources
26
+ * @param {String?} family the family name that is in the font files (defaults to the name of the font)
27
+ * @param {String[]?} paths the filenames of font files inside the resources dircetory
28
+ * @param {String[]?} urls the urls of font files in a CDN
29
+ *
30
+ */
31
+ qx.Class.define("qx.tool.compiler.app.ManifestFont", {
32
+ extend: qx.core.Object,
33
+
34
+ construct(name) {
35
+ super();
36
+ this.setName(name);
37
+ },
38
+
39
+ properties: {
40
+ /** The name of the font - this is the key in Manifest.json provides.fonts */
41
+ name: {
42
+ check: "String"
43
+ },
44
+
45
+ /** Default size of the font */
46
+ defaultSize: {
47
+ init: null,
48
+ nullable: true,
49
+ check: "Integer"
50
+ },
51
+
52
+ /** Comparison string to be used */
53
+ comparisonString: {
54
+ init: null,
55
+ nullable: true,
56
+ check: "String"
57
+ },
58
+
59
+ /** CSS filenames or URLs to be loaded (indicating that font-face will be defined outside of Qooxdoo) */
60
+ css: {
61
+ init: null,
62
+ check: "Array",
63
+ nullable: true
64
+ },
65
+
66
+ /** Font faces that have to be defined, including the resource paths or urls */
67
+ fontFaces: {
68
+ init: null,
69
+ check: "Array",
70
+ nullable: true
71
+ },
72
+
73
+ /** Glyphs filename (relative to resources of the library that defines it) */
74
+ glyphs: {
75
+ init: null,
76
+ nullable: true,
77
+ check: "String"
78
+ },
79
+
80
+ /** Family names for the browser to search for */
81
+ family: {
82
+ init: null,
83
+ nullable: true,
84
+ check: "Array"
85
+ }
86
+ },
87
+
88
+ members: {
89
+ /** @type{Map<String,Object>} font data required by the Qooxdoo app at runtime */
90
+ __fontData: null,
91
+
92
+ /**
93
+ * Updates this from the data in the Manifest.json
94
+ *
95
+ * @param {Object} data the data from Manifest
96
+ * @param {qx.tool.compiler.app.Library} library the library
97
+ */
98
+ async updateFromManifest(data, library) {
99
+ let toSet = {};
100
+ [
101
+ "defaultSize",
102
+ "comparisonString",
103
+ "css",
104
+ "fontFaces",
105
+ "glyphs",
106
+ "family"
107
+ ].forEach(name => {
108
+ if (data.hasOwnProperty(name)) {
109
+ toSet[name] = data[name];
110
+ }
111
+ });
112
+ this.set(toSet);
113
+ if (data.glyphs !== undefined) {
114
+ let glyphsFilename = library.getResourceFilename(data.glyphs);
115
+ let glyphsData = await fs.promises.readFile(glyphsFilename, "utf8");
116
+ glyphsData = JSON.parse(glyphsData);
117
+ this.__fontData = {};
118
+ let name = this.getName();
119
+ let defaultSize = this.getDefaultSize();
120
+
121
+ for (let key in glyphsData) {
122
+ let glyph = glyphsData[key];
123
+ this.__fontData["@" + name + "/" + key] = [
124
+ // width
125
+ Math.ceil((defaultSize * glyph.advanceWidth) / glyph.advanceHeight),
126
+
127
+ // height
128
+ defaultSize,
129
+ glyph.codePoint
130
+ ];
131
+ }
132
+ }
133
+ },
134
+
135
+ /**
136
+ * Generates the font data used by the application; loads the data if not already loaded
137
+ *
138
+ * @returns {Map<String,Object>}
139
+ */
140
+ getApplicationFontData() {
141
+ return this.__fontData;
142
+ },
143
+
144
+ /**
145
+ * Return bootstrap code that is executed before the Application starts.
146
+ *
147
+ * @param {qx.tool.compiler.targets.Target} target the target
148
+ * @param {qx.tool.compiler.app.Application} application the application being built
149
+ * @param {Boolean} useLocalFonts whether to use local fonts or use CSS
150
+ * @return {String} code to include in the output
151
+ */
152
+ getBootstrapCode(target, application, useLocalFonts) {
153
+ let res = "";
154
+ let font = {
155
+ family: this.getFamily() || [this.getName()]
156
+ };
157
+
158
+ if (!useLocalFonts) {
159
+ if (this.getCss()) {
160
+ font.css = this.getCss();
161
+ }
162
+ } else {
163
+ font.fontFaces = this.getFontFaces();
164
+ }
165
+
166
+ if (this.getDefaultSize() !== null) {
167
+ font.defaultSize = this.getDefaultSize();
168
+ }
169
+ if (this.getComparisonString() !== null) {
170
+ font.comparisonString = this.getComparisonString();
171
+ }
172
+
173
+ return (res +=
174
+ "qx.$$fontBootstrap['" +
175
+ this.getName() +
176
+ "']=" +
177
+ JSON.stringify(font, null, 2) +
178
+ ";");
179
+ }
180
+ }
181
+ });