@galacean/effects 1.4.2 → 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/weapp.js CHANGED
@@ -676,6 +676,18 @@ function asserts(condition, msg) {
676
676
  }
677
677
  }
678
678
 
679
+ /**
680
+ * 判断是否为可解析的字体
681
+ * - 首字母不能为数字或 `.`
682
+ * - 不能包含特殊字符,`_-` 是被允许的
683
+ * @param fontFamily - 字体名称
684
+ * @returns
685
+ */
686
+ function isValidFontFamily(fontFamily) {
687
+ // iOS 11/12 不支持自定义字体开头为数字的名称,特殊字符也有风险
688
+ return /^[^\d.][\w-]*$/.test(fontFamily);
689
+ }
690
+
679
691
  /*!
680
692
  * Name: @galacean/effects-specification
681
693
  * Description: Galacean Effects JSON Specification
@@ -20370,7 +20382,8 @@ var TextItem = /** @class */ (function (_super) {
20370
20382
  * @returns
20371
20383
  */
20372
20384
  TextItem.prototype.setFontFamily = function (value) {
20373
- if (this.textStyle.fontFamily === value) {
20385
+ if (this.textStyle.fontFamily === value && !isValidFontFamily(value)) {
20386
+ console.warn('The font is either the current font or an risky font family.');
20374
20387
  return;
20375
20388
  }
20376
20389
  this.textStyle.fontFamily = value;
@@ -24200,11 +24213,15 @@ var AssetManager = /** @class */ (function () {
24200
24213
  switch (_b.label) {
24201
24214
  case 0:
24202
24215
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
24203
- url = new weapp.URL(font.fontURL, this.baseUrl).href;
24204
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
24216
+ if (!isValidFontFamily(font.fontFamily)) {
24217
+ // 在所有设备上提醒开发者
24218
+ console.warn("Risky font family: ".concat(font.fontFamily));
24219
+ }
24205
24220
  _b.label = 1;
24206
24221
  case 1:
24207
24222
  _b.trys.push([1, 3, , 4]);
24223
+ url = new weapp.URL(font.fontURL, this.baseUrl).href;
24224
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
24208
24225
  return [4 /*yield*/, fontFace.load()];
24209
24226
  case 2:
24210
24227
  _b.sent();
@@ -24214,7 +24231,7 @@ var AssetManager = /** @class */ (function () {
24214
24231
  return [3 /*break*/, 4];
24215
24232
  case 3:
24216
24233
  _b.sent();
24217
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
24234
+ logger.warn("Invalid font family or font source: ".concat(JSON.stringify(font.fontURL)));
24218
24235
  return [3 /*break*/, 4];
24219
24236
  case 4: return [2 /*return*/];
24220
24237
  }
@@ -30903,7 +30920,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
30903
30920
  Engine.create = function (gl) {
30904
30921
  return new GLEngine(gl);
30905
30922
  };
30906
- var version = "1.4.2";
30923
+ var version = "1.4.4";
30907
30924
  logger.info('player version: ' + version);
30908
30925
 
30909
30926
  exports.AbstractPlugin = AbstractPlugin;
@@ -31101,6 +31118,7 @@ exports.isSimulatorCellPhone = isSimulatorCellPhone;
31101
31118
  exports.isString = isString;
31102
31119
  exports.isUniformStruct = isUniformStruct;
31103
31120
  exports.isUniformStructArray = isUniformStructArray;
31121
+ exports.isValidFontFamily = isValidFontFamily;
31104
31122
  exports.isWebGL2 = isWebGL2;
31105
31123
  exports.itemFrag = itemFrag;
31106
31124
  exports.itemFrameFrag = itemFrameFrag;