@galacean/effects 1.4.3 → 1.4.4

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/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime player for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.4.3
6
+ * Version: v1.4.4
7
7
  */
8
8
 
9
9
  'use strict';
@@ -682,6 +682,18 @@ function asserts(condition, msg) {
682
682
  }
683
683
  }
684
684
 
685
+ /**
686
+ * 判断是否为可解析的字体
687
+ * - 首字母不能为数字或 `.`
688
+ * - 不能包含特殊字符,`_-` 是被允许的
689
+ * @param fontFamily - 字体名称
690
+ * @returns
691
+ */
692
+ function isValidFontFamily(fontFamily) {
693
+ // iOS 11/12 不支持自定义字体开头为数字的名称,特殊字符也有风险
694
+ return /^[^\d.][\w-]*$/.test(fontFamily);
695
+ }
696
+
685
697
  /*!
686
698
  * Name: @galacean/effects-specification
687
699
  * Description: Galacean Effects JSON Specification
@@ -20376,7 +20388,8 @@ var TextItem = /** @class */ (function (_super) {
20376
20388
  * @returns
20377
20389
  */
20378
20390
  TextItem.prototype.setFontFamily = function (value) {
20379
- if (this.textStyle.fontFamily === value) {
20391
+ if (this.textStyle.fontFamily === value && !isValidFontFamily(value)) {
20392
+ console.warn('The font is either the current font or an risky font family.');
20380
20393
  return;
20381
20394
  }
20382
20395
  this.textStyle.fontFamily = value;
@@ -24206,11 +24219,15 @@ var AssetManager = /** @class */ (function () {
24206
24219
  switch (_b.label) {
24207
24220
  case 0:
24208
24221
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
24209
- url = new URL(font.fontURL, this.baseUrl).href;
24210
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
24222
+ if (!isValidFontFamily(font.fontFamily)) {
24223
+ // 在所有设备上提醒开发者
24224
+ console.warn("Risky font family: ".concat(font.fontFamily));
24225
+ }
24211
24226
  _b.label = 1;
24212
24227
  case 1:
24213
24228
  _b.trys.push([1, 3, , 4]);
24229
+ url = new URL(font.fontURL, this.baseUrl).href;
24230
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
24214
24231
  return [4 /*yield*/, fontFace.load()];
24215
24232
  case 2:
24216
24233
  _b.sent();
@@ -24220,7 +24237,7 @@ var AssetManager = /** @class */ (function () {
24220
24237
  return [3 /*break*/, 4];
24221
24238
  case 3:
24222
24239
  _b.sent();
24223
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
24240
+ logger.warn("Invalid font family or font source: ".concat(JSON.stringify(font.fontURL)));
24224
24241
  return [3 /*break*/, 4];
24225
24242
  case 4: return [2 /*return*/];
24226
24243
  }
@@ -30909,7 +30926,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
30909
30926
  Engine.create = function (gl) {
30910
30927
  return new GLEngine(gl);
30911
30928
  };
30912
- var version = "1.4.3";
30929
+ var version = "1.4.4";
30913
30930
  logger.info('player version: ' + version);
30914
30931
 
30915
30932
  exports.AbstractPlugin = AbstractPlugin;
@@ -31107,6 +31124,7 @@ exports.isSimulatorCellPhone = isSimulatorCellPhone;
31107
31124
  exports.isString = isString;
31108
31125
  exports.isUniformStruct = isUniformStruct;
31109
31126
  exports.isUniformStructArray = isUniformStructArray;
31127
+ exports.isValidFontFamily = isValidFontFamily;
31110
31128
  exports.isWebGL2 = isWebGL2;
31111
31129
  exports.itemFrag = itemFrag;
31112
31130
  exports.itemFrameFrag = itemFrameFrag;