@galacean/effects-core 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/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -6
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/text.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v1.4.
|
|
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
|
-
|
|
24210
|
-
|
|
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
|
|
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
|
}
|
|
@@ -26059,6 +26076,7 @@ exports.isSimulatorCellPhone = isSimulatorCellPhone;
|
|
|
26059
26076
|
exports.isString = isString;
|
|
26060
26077
|
exports.isUniformStruct = isUniformStruct;
|
|
26061
26078
|
exports.isUniformStructArray = isUniformStructArray;
|
|
26079
|
+
exports.isValidFontFamily = isValidFontFamily;
|
|
26062
26080
|
exports.isWebGL2 = isWebGL2;
|
|
26063
26081
|
exports.itemFrag = itemFrag;
|
|
26064
26082
|
exports.itemFrameFrag = itemFrameFrag;
|