leafer-ui 1.3.2 → 1.4.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.
- package/README.md +14 -4
- package/dist/web.cjs +30 -19
- package/dist/web.cjs.map +1 -0
- package/dist/web.esm.js +30 -19
- package/dist/web.esm.js.map +1 -0
- package/dist/web.esm.min.js +2 -1
- package/dist/web.esm.min.js.map +1 -0
- package/dist/web.js +267 -251
- package/dist/web.js.map +1 -0
- package/dist/web.min.cjs +2 -1
- package/dist/web.min.cjs.map +1 -0
- package/dist/web.min.js +2 -1
- package/dist/web.min.js.map +1 -0
- package/dist/web.module.js +267 -251
- package/dist/web.module.js.map +1 -0
- package/dist/web.module.min.js +2 -1
- package/dist/web.module.min.js.map +1 -0
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
## 场景包
|
|
32
32
|
|
|
33
|
-
高效绘图场景,推荐直接安装更轻量的 [leafer-draw](https://leaferjs.com/ui/guide/install/draw/start.html) (
|
|
33
|
+
高效绘图场景,推荐直接安装更轻量的 [leafer-draw](https://leaferjs.com/ui/guide/install/draw/start.html) (50KB min+gzip)。
|
|
34
34
|
|
|
35
35
|
游戏开发场景,推荐直接安装更省心的 [leafer-game](https://leaferjs.com/ui/guide/install/game/start.html),已集成了游戏相关插件。
|
|
36
36
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
## 互动交流
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
有 Bug、建议可以 [提交 issue](https://github.com/leaferjs/leafer-ui/issues),留下你的贡献足迹,了解 [提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E6%8F%90%E9%97%AE%E7%9A%84%E6%99%BA%E6%85%A7)
|
|
42
42
|
。
|
|
43
43
|
|
|
44
44
|
欢迎加入 [技术交流群](https://leaferjs.com/#contact) ,与小伙伴们建立联系,共同学习进步,偶尔会有特殊福利。
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
|
|
58
58
|
[test](https://github.com/leaferjs/test) 自动化测试仓库。
|
|
59
59
|
|
|
60
|
+
[code](https://github.com/leaferjs/code) 示例代码仓库。
|
|
61
|
+
|
|
62
|
+
[docs](https://github.com/leaferjs/docs) 在线文档仓库。
|
|
63
|
+
|
|
60
64
|
## 使命与愿景
|
|
61
65
|
|
|
62
66
|
LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标准,表现力丰富,便于 AI 理解,人类可视化使用,并为数字化产品开发提供跨平台、轻量化、高性能的运行时。
|
|
@@ -137,7 +141,13 @@ LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
|
|
|
137
141
|
</p>
|
|
138
142
|
<p><h3 align="center">银牌赞助</h3></p>
|
|
139
143
|
<p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 5px;">
|
|
140
|
-
<a target="_blank" href="https://
|
|
144
|
+
<a target="_blank" href="https://frameelf.com/">
|
|
145
|
+
<img width="40" title="边框水印精灵" src="https://www.leaferjs.com/image/sponsor/user/134.jpg" loading="lazy" />
|
|
146
|
+
</a>
|
|
147
|
+
<a target="_blank" href="">
|
|
148
|
+
<img width="40" title="Y" src="https://www.leaferjs.com/image/sponsor/user/131.jpg" loading="lazy" />
|
|
149
|
+
</a>
|
|
150
|
+
<a target="_blank" href="https://github.com/daodaolee">
|
|
141
151
|
<img width="40" title="道里" src="https://www.leaferjs.com/image/sponsor/user/108.jpg" loading="lazy" />
|
|
142
152
|
</a>
|
|
143
153
|
<a target="_blank" href="https://afdian.com/u/4c42d1dc97f311ef908752540025c377">
|
|
@@ -278,7 +288,7 @@ LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
|
|
|
278
288
|
</p>
|
|
279
289
|
<p><h3 align="center">铜牌赞助</h3></p>
|
|
280
290
|
<p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 15px;">
|
|
281
|
-
|
|
291
|
+
张余🌈 Jerry 李狗嗨。💢 李维亮 朝夕 SaltedFish zhk 格子 等等 goosen 建伟F4nniu 梁福斌 江万江 杨超 ToB Dev 前端之虎陈随易 A☀️云☀️A ʚ LMT ɞ 爱发电用户_c9c82 轻简历 爱发电用户_0fac0 wangyesheji.cn 风间 爱发电用户_Tqsm 爱发电用户_6KpE dongdong zwm 爱发电用户_3725c Noth1ng 纳西妲の√ 爱发电用户_Ahb9 爱发电用户_7617d 冷漠 爱发电用户_9RXB 今日值得读 爱发电用户_49sT 爱发电用户_NFCS 爱发电用户_43ad8 爱发电用户_30455 xiaozhang 砖吐筷筷 爱发电用户_b47b3 longbow1998 爱发电用户_5d755 爱发电用户_b76b8 爱发电用户_e70c2 爱发电用户_039dc 花祁 爱发电用户_99f39 坤坤 爱发电用户_X6hp 爱发电用户_s5u9 曹吉美爸爸 啸沧海 Ronny Biu 王志强 PD.新城คิดถึง 糖颂缘冥倾 ALBERT. 爱发电用户_UXEV SaltedFish 爱发电用户_76f9d Leafer 爱发电用户_Pbm7 </p>
|
|
282
292
|
|
|
283
293
|
## License
|
|
284
294
|
|
package/dist/web.cjs
CHANGED
|
@@ -122,7 +122,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
125
|
-
window.addEventListener('resize', () => {
|
|
125
|
+
window.addEventListener('resize', this.windowListener = () => {
|
|
126
126
|
const pixelRatio = core.Platform.devicePixelRatio;
|
|
127
127
|
if (this.pixelRatio !== pixelRatio) {
|
|
128
128
|
const { width, height } = this;
|
|
@@ -151,11 +151,9 @@ class LeaferCanvas extends core.LeaferCanvasBase {
|
|
|
151
151
|
}
|
|
152
152
|
stopAutoLayout() {
|
|
153
153
|
this.autoLayout = false;
|
|
154
|
-
this.
|
|
155
|
-
if (this.resizeObserver) {
|
|
154
|
+
if (this.resizeObserver)
|
|
156
155
|
this.resizeObserver.disconnect();
|
|
157
|
-
|
|
158
|
-
}
|
|
156
|
+
this.resizeListener = this.resizeObserver = null;
|
|
159
157
|
}
|
|
160
158
|
emitResize(size) {
|
|
161
159
|
const oldSize = {};
|
|
@@ -176,6 +174,10 @@ class LeaferCanvas extends core.LeaferCanvasBase {
|
|
|
176
174
|
destroy() {
|
|
177
175
|
if (this.view) {
|
|
178
176
|
this.stopAutoLayout();
|
|
177
|
+
if (this.windowListener) {
|
|
178
|
+
window.removeEventListener('resize', this.windowListener);
|
|
179
|
+
this.windowListener = null;
|
|
180
|
+
}
|
|
179
181
|
if (!this.unreal) {
|
|
180
182
|
const view = this.view;
|
|
181
183
|
if (view.parentElement)
|
|
@@ -202,7 +204,10 @@ function useCanvas(_canvasType, _power) {
|
|
|
202
204
|
canvas.height = height;
|
|
203
205
|
return canvas;
|
|
204
206
|
},
|
|
205
|
-
canvasToDataURL: (canvas, type, quality) =>
|
|
207
|
+
canvasToDataURL: (canvas, type, quality) => {
|
|
208
|
+
const imageType = mineType(type), url = canvas.toDataURL(imageType, quality);
|
|
209
|
+
return imageType === 'image/bmp' ? url.replace('image/png;', 'image/bmp;') : url;
|
|
210
|
+
},
|
|
206
211
|
canvasToBolb: (canvas, type, quality) => new Promise((resolve) => canvas.toBlob(resolve, mineType(type), quality)),
|
|
207
212
|
canvasSaveAs: (canvas, filename, quality) => {
|
|
208
213
|
const url = canvas.toDataURL(mineType(fileType(filename)), quality);
|
|
@@ -247,7 +252,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
247
252
|
core.Platform.name = 'web';
|
|
248
253
|
core.Platform.isMobile = 'ontouchstart' in window;
|
|
249
254
|
core.Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
|
|
250
|
-
core.defineKey(core.Platform, 'devicePixelRatio', { get() { return
|
|
255
|
+
core.defineKey(core.Platform, 'devicePixelRatio', { get() { return devicePixelRatio; } });
|
|
251
256
|
const { userAgent } = navigator;
|
|
252
257
|
if (userAgent.indexOf("Firefox") > -1) {
|
|
253
258
|
core.Platform.conicGradientRotate90 = true;
|
|
@@ -523,7 +528,7 @@ class Layouter {
|
|
|
523
528
|
}
|
|
524
529
|
partLayout() {
|
|
525
530
|
var _a;
|
|
526
|
-
if (!((_a = this.__updatedList) === null || _a ===
|
|
531
|
+
if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
|
|
527
532
|
return;
|
|
528
533
|
const t = core.Run.start('PartLayout');
|
|
529
534
|
const { target, __updatedList: updateList } = this;
|
|
@@ -1053,6 +1058,7 @@ class Interaction extends core$1.InteractionBase {
|
|
|
1053
1058
|
'pointerdown': this.onPointerDown,
|
|
1054
1059
|
'mousedown': this.onMouseDown,
|
|
1055
1060
|
'touchstart': this.onTouchStart,
|
|
1061
|
+
'pointerleave': this.onPointerLeave,
|
|
1056
1062
|
'contextmenu': this.onContextMenu,
|
|
1057
1063
|
'wheel': this.onWheel,
|
|
1058
1064
|
'gesturestart': this.onGesturestart,
|
|
@@ -1135,11 +1141,15 @@ class Interaction extends core$1.InteractionBase {
|
|
|
1135
1141
|
this.usePointer || (this.usePointer = true);
|
|
1136
1142
|
this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)));
|
|
1137
1143
|
}
|
|
1138
|
-
onPointerMove(e) {
|
|
1144
|
+
onPointerMove(e, isLeave) {
|
|
1139
1145
|
if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
|
|
1140
1146
|
return;
|
|
1141
1147
|
this.usePointer || (this.usePointer = true);
|
|
1142
|
-
|
|
1148
|
+
const data = PointerEventHelper.convert(e, this.getLocal(e, true));
|
|
1149
|
+
isLeave ? this.pointerHover(data) : this.pointerMove(data);
|
|
1150
|
+
}
|
|
1151
|
+
onPointerLeave(e) {
|
|
1152
|
+
this.onPointerMove(e, true);
|
|
1143
1153
|
}
|
|
1144
1154
|
onPointerUp(e) {
|
|
1145
1155
|
if (this.downData)
|
|
@@ -1906,7 +1916,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
1906
1916
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1907
1917
|
PERFORMANCE OF THIS SOFTWARE.
|
|
1908
1918
|
***************************************************************************** */
|
|
1909
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1919
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1910
1920
|
|
|
1911
1921
|
|
|
1912
1922
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
@@ -1967,7 +1977,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1967
1977
|
}
|
|
1968
1978
|
else {
|
|
1969
1979
|
if (!paint.patternTask) {
|
|
1970
|
-
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this,
|
|
1980
|
+
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
|
|
1971
1981
|
paint.patternTask = null;
|
|
1972
1982
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1973
1983
|
createPattern(ui, paint, pixelRatio);
|
|
@@ -2123,7 +2133,7 @@ function shadow(ui, current, shape) {
|
|
|
2123
2133
|
const end = shadow.length - 1;
|
|
2124
2134
|
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
2125
2135
|
shadow.forEach((item, index) => {
|
|
2126
|
-
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
|
|
2136
|
+
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, draw.ColorConvert.string(item.color));
|
|
2127
2137
|
spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
|
|
2128
2138
|
drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
|
|
2129
2139
|
copyBounds = bounds;
|
|
@@ -2199,7 +2209,7 @@ function innerShadow(ui, current, shape) {
|
|
|
2199
2209
|
other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
|
|
2200
2210
|
copyBounds = bounds;
|
|
2201
2211
|
}
|
|
2202
|
-
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
2212
|
+
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
2203
2213
|
if (ui.__worldFlipped) {
|
|
2204
2214
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
2205
2215
|
}
|
|
@@ -2557,11 +2567,11 @@ const TextMode = 2;
|
|
|
2557
2567
|
function layoutChar(drawData, style, width, _height) {
|
|
2558
2568
|
const { rows } = drawData;
|
|
2559
2569
|
const { textAlign, paraIndent, letterSpacing } = style;
|
|
2560
|
-
let charX, addWordWidth, indentWidth, mode, wordChar;
|
|
2570
|
+
let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
|
|
2561
2571
|
rows.forEach(row => {
|
|
2562
2572
|
if (row.words) {
|
|
2563
|
-
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2564
|
-
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') &&
|
|
2573
|
+
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
2574
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
|
|
2565
2575
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2566
2576
|
if (row.isOverflow && !letterSpacing)
|
|
2567
2577
|
row.textMode = true;
|
|
@@ -2573,7 +2583,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2573
2583
|
row.x += indentWidth;
|
|
2574
2584
|
charX = row.x;
|
|
2575
2585
|
row.data = [];
|
|
2576
|
-
row.words.forEach(word => {
|
|
2586
|
+
row.words.forEach((word, index) => {
|
|
2577
2587
|
if (mode === WordMode) {
|
|
2578
2588
|
wordChar = { char: '', x: charX };
|
|
2579
2589
|
charX = toWordChar(word.data, charX, wordChar);
|
|
@@ -2583,7 +2593,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2583
2593
|
else {
|
|
2584
2594
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2585
2595
|
}
|
|
2586
|
-
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2596
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
|
|
2587
2597
|
charX += addWordWidth;
|
|
2588
2598
|
row.width += addWordWidth;
|
|
2589
2599
|
}
|
|
@@ -2863,3 +2873,4 @@ Object.keys(core$1).forEach(function (k) {
|
|
|
2863
2873
|
get: function () { return core$1[k]; }
|
|
2864
2874
|
});
|
|
2865
2875
|
});
|
|
2876
|
+
//# sourceMappingURL=web.cjs.map
|