@aivex/ui 1.2.0-dev.40 → 1.2.0-dev.41
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/components/ShapeEditor/_model/imageLoad.d.ts +15 -0
- package/dist/components/ShapeEditor/_model/viewerPatch.d.ts +60 -0
- package/dist/components/ShapeEditor/_model/viewerPatch.test.d.ts +1 -0
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +370 -180
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -3023,9 +3023,49 @@ async function tr(e) {
|
|
|
3023
3023
|
}
|
|
3024
3024
|
return er(e, { crossOrigin: !0 });
|
|
3025
3025
|
}
|
|
3026
|
+
async function nr(e) {
|
|
3027
|
+
for (let t of ["default", "reload"]) try {
|
|
3028
|
+
let n = await fetch(e, {
|
|
3029
|
+
mode: "cors",
|
|
3030
|
+
credentials: "omit",
|
|
3031
|
+
cache: t
|
|
3032
|
+
});
|
|
3033
|
+
return n.ok ? await n.blob() : null;
|
|
3034
|
+
} catch {}
|
|
3035
|
+
return null;
|
|
3036
|
+
}
|
|
3037
|
+
async function rr(e) {
|
|
3038
|
+
let t = await nr(e);
|
|
3039
|
+
if (t) try {
|
|
3040
|
+
let e = await createImageBitmap(t);
|
|
3041
|
+
return {
|
|
3042
|
+
source: e,
|
|
3043
|
+
width: e.width,
|
|
3044
|
+
height: e.height,
|
|
3045
|
+
release: () => e.close()
|
|
3046
|
+
};
|
|
3047
|
+
} catch {}
|
|
3048
|
+
let n = await tr(e);
|
|
3049
|
+
return n ? {
|
|
3050
|
+
source: n,
|
|
3051
|
+
width: n.naturalWidth,
|
|
3052
|
+
height: n.naturalHeight,
|
|
3053
|
+
release: () => {}
|
|
3054
|
+
} : null;
|
|
3055
|
+
}
|
|
3056
|
+
var ir = 2, ar = 0, or = [];
|
|
3057
|
+
async function sr(e) {
|
|
3058
|
+
ar < ir ? ar += 1 : await new Promise((e) => or.push(e));
|
|
3059
|
+
try {
|
|
3060
|
+
return await e();
|
|
3061
|
+
} finally {
|
|
3062
|
+
let e = or.shift();
|
|
3063
|
+
e ? e() : --ar;
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3026
3066
|
//#endregion
|
|
3027
3067
|
//#region src/components/ShapeEditor/_model/imageDiagnosis.ts
|
|
3028
|
-
function
|
|
3068
|
+
function cr(e) {
|
|
3029
3069
|
return new Promise((t) => {
|
|
3030
3070
|
let n = null, r = !1, i = () => {
|
|
3031
3071
|
r || (r = !0, clearTimeout(o), document.removeEventListener("securitypolicyviolation", a), t(n));
|
|
@@ -3038,24 +3078,24 @@ function nr(e) {
|
|
|
3038
3078
|
});
|
|
3039
3079
|
});
|
|
3040
3080
|
}
|
|
3041
|
-
var
|
|
3042
|
-
function
|
|
3043
|
-
let t =
|
|
3044
|
-
if (t && n - t.at <
|
|
3045
|
-
let r =
|
|
3081
|
+
var lr = 3e4, ur = 200, dr = /* @__PURE__ */ new Map();
|
|
3082
|
+
function fr(e) {
|
|
3083
|
+
let t = dr.get(e), n = Date.now();
|
|
3084
|
+
if (t && n - t.at < lr) return t.result;
|
|
3085
|
+
let r = pr(e).catch((t) => (dr.delete(e), {
|
|
3046
3086
|
kind: "unknown",
|
|
3047
3087
|
detail: t instanceof Error ? t.message : String(t)
|
|
3048
3088
|
}));
|
|
3049
|
-
if (
|
|
3089
|
+
if (dr.set(e, {
|
|
3050
3090
|
at: n,
|
|
3051
3091
|
result: r
|
|
3052
|
-
}),
|
|
3053
|
-
let e =
|
|
3054
|
-
e !== void 0 &&
|
|
3092
|
+
}), dr.size > ur) {
|
|
3093
|
+
let e = dr.keys().next().value;
|
|
3094
|
+
e !== void 0 && dr.delete(e);
|
|
3055
3095
|
}
|
|
3056
3096
|
return r;
|
|
3057
3097
|
}
|
|
3058
|
-
async function
|
|
3098
|
+
async function pr(e) {
|
|
3059
3099
|
let t = e;
|
|
3060
3100
|
try {
|
|
3061
3101
|
t = new URL(e, location.href).origin;
|
|
@@ -3098,7 +3138,7 @@ async function sr(e) {
|
|
|
3098
3138
|
kind: "unexpected-content",
|
|
3099
3139
|
detail: `HTTP ${r} (${t})${n.redirected ? " via redirect" : ""}`
|
|
3100
3140
|
};
|
|
3101
|
-
let i = await
|
|
3141
|
+
let i = await cr(e);
|
|
3102
3142
|
return i ? {
|
|
3103
3143
|
kind: "csp-img",
|
|
3104
3144
|
detail: i
|
|
@@ -3135,7 +3175,7 @@ async function sr(e) {
|
|
|
3135
3175
|
detail: `HTTP ${r}`
|
|
3136
3176
|
};
|
|
3137
3177
|
}
|
|
3138
|
-
function
|
|
3178
|
+
function mr() {
|
|
3139
3179
|
try {
|
|
3140
3180
|
let e = document.createElement("canvas");
|
|
3141
3181
|
return !!(e.getContext("webgl2") ?? e.getContext("webgl"));
|
|
@@ -3143,12 +3183,12 @@ function cr() {
|
|
|
3143
3183
|
return !1;
|
|
3144
3184
|
}
|
|
3145
3185
|
}
|
|
3146
|
-
function
|
|
3186
|
+
function hr(e) {
|
|
3147
3187
|
let t = e instanceof Error ? e.message : String(e);
|
|
3148
3188
|
return /unsafe-eval/i.test(t) ? {
|
|
3149
3189
|
kind: "csp-eval",
|
|
3150
3190
|
detail: t
|
|
3151
|
-
} :
|
|
3191
|
+
} : mr() ? {
|
|
3152
3192
|
kind: "renderer-init",
|
|
3153
3193
|
detail: t || "renderer init failed"
|
|
3154
3194
|
} : {
|
|
@@ -3158,8 +3198,8 @@ function lr(e) {
|
|
|
3158
3198
|
}
|
|
3159
3199
|
//#endregion
|
|
3160
3200
|
//#region src/components/ShapeEditor/_model/imageTiles.ts
|
|
3161
|
-
var
|
|
3162
|
-
function
|
|
3201
|
+
var gr = 4e3;
|
|
3202
|
+
function _r(e, t, n = gr) {
|
|
3163
3203
|
if (e <= 0 || t <= 0) return [];
|
|
3164
3204
|
let r = Math.ceil(e / n), i = Math.ceil(t / n);
|
|
3165
3205
|
return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
|
|
@@ -3174,7 +3214,7 @@ function dr(e, t, n = ur) {
|
|
|
3174
3214
|
};
|
|
3175
3215
|
})).flat();
|
|
3176
3216
|
}
|
|
3177
|
-
function
|
|
3217
|
+
function vr(e, t) {
|
|
3178
3218
|
let n = document.createElement("canvas");
|
|
3179
3219
|
n.width = t.width, n.height = t.height;
|
|
3180
3220
|
let r = n.getContext("2d");
|
|
@@ -3182,7 +3222,7 @@ function fr(e, t) {
|
|
|
3182
3222
|
}
|
|
3183
3223
|
//#endregion
|
|
3184
3224
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
3185
|
-
function
|
|
3225
|
+
function yr(e, t, n) {
|
|
3186
3226
|
if (t === R.POINT) {
|
|
3187
3227
|
e.setAttrs({
|
|
3188
3228
|
x: n[0].x,
|
|
@@ -3218,17 +3258,17 @@ function pr(e, t, n) {
|
|
|
3218
3258
|
}
|
|
3219
3259
|
//#endregion
|
|
3220
3260
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
3221
|
-
var
|
|
3222
|
-
function
|
|
3223
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
3261
|
+
var br = "M8 0C12.4183 0 16 3.58172 16 8C16 11.5323 13.71 14.5277 10.5342 15.5879L10.166 20.0068C10.0721 21.1334 9.13046 22 8 22C6.86954 22 5.92786 21.1334 5.83398 20.0068L5.46484 15.5879C2.28949 14.5275 0 11.532 0 8C0 3.58172 3.58172 0 8 0Z", xr = "#ffffff", Sr = 1.5;
|
|
3262
|
+
function Cr(e) {
|
|
3263
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${br}" fill="${e}" stroke="${xr}" stroke-width="${Sr}"/></svg>`;
|
|
3224
3264
|
}
|
|
3225
3265
|
//#endregion
|
|
3226
3266
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
3227
|
-
var
|
|
3228
|
-
function
|
|
3267
|
+
var wr = Math.PI / 12;
|
|
3268
|
+
function Tr(e, t) {
|
|
3229
3269
|
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === R.ROTATED_RECTANGLE;
|
|
3230
3270
|
}
|
|
3231
|
-
function
|
|
3271
|
+
function Er(e, t, n) {
|
|
3232
3272
|
if (e.kind === "resize") {
|
|
3233
3273
|
let r = n ? e.box : ue(e.anchor, e.box, t.x, t.y);
|
|
3234
3274
|
return {
|
|
@@ -3259,7 +3299,7 @@ function br(e, t, n) {
|
|
|
3259
3299
|
}
|
|
3260
3300
|
if (e.kind === "rotate") {
|
|
3261
3301
|
let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
|
|
3262
|
-
return e.shiftKey && (n = Math.round(n /
|
|
3302
|
+
return e.shiftKey && (n = Math.round(n / wr) * wr), {
|
|
3263
3303
|
updates: [{
|
|
3264
3304
|
id: e.id,
|
|
3265
3305
|
points: e.points.map((t) => fe(t, e.center, n))
|
|
@@ -3279,13 +3319,13 @@ function br(e, t, n) {
|
|
|
3279
3319
|
box: U(a)
|
|
3280
3320
|
};
|
|
3281
3321
|
}
|
|
3282
|
-
function
|
|
3322
|
+
function Dr(e, t) {
|
|
3283
3323
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
3284
3324
|
x: t.center.x + Math.cos(t.startAngle),
|
|
3285
3325
|
y: t.center.y + Math.sin(t.startAngle)
|
|
3286
|
-
} :
|
|
3326
|
+
} : Tr(e, t) ? Ce(t.shapes[0].points)[H.indexOf(t.anchor)] : le(t.anchor, t.box);
|
|
3287
3327
|
}
|
|
3288
|
-
function
|
|
3328
|
+
function Or(e, t, n) {
|
|
3289
3329
|
let r = e.filter((e) => t.includes(e.id) && oe(e)).map((e) => ({
|
|
3290
3330
|
id: e.id,
|
|
3291
3331
|
points: e.points
|
|
@@ -3297,23 +3337,23 @@ function Sr(e, t, n) {
|
|
|
3297
3337
|
shapes: r
|
|
3298
3338
|
} : null;
|
|
3299
3339
|
}
|
|
3300
|
-
function
|
|
3340
|
+
function kr(e) {
|
|
3301
3341
|
return e.map((e) => ({
|
|
3302
3342
|
...e,
|
|
3303
3343
|
points: e.points.map((e) => ({ ...e }))
|
|
3304
3344
|
}));
|
|
3305
3345
|
}
|
|
3306
|
-
function
|
|
3346
|
+
function Ar(e, t) {
|
|
3307
3347
|
let n = new Set(t);
|
|
3308
3348
|
return e.filter((e) => n.has(e.id) && ae(e));
|
|
3309
3349
|
}
|
|
3310
|
-
function
|
|
3350
|
+
function jr(e, t) {
|
|
3311
3351
|
return e.filter((e) => B(e) && Fe(e, t)).map((e) => e.id);
|
|
3312
3352
|
}
|
|
3313
|
-
function
|
|
3353
|
+
function Mr(e, t, n) {
|
|
3314
3354
|
return (e ? at(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
3315
3355
|
}
|
|
3316
|
-
function
|
|
3356
|
+
function Nr(e, t) {
|
|
3317
3357
|
return {
|
|
3318
3358
|
minX: e.x - t,
|
|
3319
3359
|
minY: e.y - t,
|
|
@@ -3321,9 +3361,9 @@ function Dr(e, t) {
|
|
|
3321
3361
|
maxY: e.y + t
|
|
3322
3362
|
};
|
|
3323
3363
|
}
|
|
3324
|
-
function
|
|
3364
|
+
function Pr(e, t, n) {
|
|
3325
3365
|
if (e.type === R.ROTATED_RECTANGLE) return t;
|
|
3326
|
-
let r = e.type === R.POINT ?
|
|
3366
|
+
let r = e.type === R.POINT ? Nr(t[0], n) : U(t);
|
|
3327
3367
|
return pe([{
|
|
3328
3368
|
x: r.minX,
|
|
3329
3369
|
y: r.minY
|
|
@@ -3332,17 +3372,17 @@ function Or(e, t, n) {
|
|
|
3332
3372
|
y: r.maxY
|
|
3333
3373
|
}]);
|
|
3334
3374
|
}
|
|
3335
|
-
function
|
|
3375
|
+
function Fr(e) {
|
|
3336
3376
|
return 24 / (e || 1);
|
|
3337
3377
|
}
|
|
3338
|
-
function
|
|
3378
|
+
function Ir(e, t) {
|
|
3339
3379
|
return Math.atan2(t.y - e.y, t.x - e.x);
|
|
3340
3380
|
}
|
|
3341
3381
|
//#endregion
|
|
3342
3382
|
//#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
|
|
3343
|
-
var
|
|
3383
|
+
var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
3344
3384
|
constructor(e, t) {
|
|
3345
|
-
this.layer = new N.Layer(), this.world = new N.Group(), this.bgGroup = new N.Group(), this.overlayGroup = new N.Group({ listening: !1 }), this.regionOverlayGroup = new N.Group({ listening: !1 }), this.dimOverlayGroup = new N.Group({ listening: !1 }), this.shapeGroup = new N.Group(), this.selGroup = new N.Group(), this.previewGroup = new N.Group(), this.handleGroup = new N.Group(), this.baseCursor = "default", this.strokeSize =
|
|
3385
|
+
this.layer = new N.Layer(), this.world = new N.Group(), this.bgGroup = new N.Group(), this.overlayGroup = new N.Group({ listening: !1 }), this.regionOverlayGroup = new N.Group({ listening: !1 }), this.dimOverlayGroup = new N.Group({ listening: !1 }), this.shapeGroup = new N.Group(), this.selGroup = new N.Group(), this.previewGroup = new N.Group(), this.handleGroup = new N.Group(), this.baseCursor = "default", this.strokeSize = Lr, this.imageSmoothing = !0, this.imageWidth = 0, this.imageHeight = 0, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.altNodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.imageLoadToken = 0, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastImg = {
|
|
3346
3386
|
x: 0,
|
|
3347
3387
|
y: 0
|
|
3348
3388
|
}, this.lastDragImg = null, this.ro = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorders = [], this.upCleanup = null, this.lastPreviewPoly = null, this.preview = null, this.marquee = null, this.host = e, this.cb = t, this.stage = new N.Stage({
|
|
@@ -3469,7 +3509,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3469
3509
|
x: a / i.naturalWidth,
|
|
3470
3510
|
y: o / i.naturalHeight
|
|
3471
3511
|
}), this.bgGroup.destroyChildren();
|
|
3472
|
-
for (let e of
|
|
3512
|
+
for (let e of _r(i.naturalWidth, i.naturalHeight)) this.bgGroup.add(new N.Image({
|
|
3473
3513
|
image: i,
|
|
3474
3514
|
x: e.x,
|
|
3475
3515
|
y: e.y,
|
|
@@ -3579,7 +3619,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3579
3619
|
let e = this.lastPreviewPoly;
|
|
3580
3620
|
e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
|
|
3581
3621
|
}
|
|
3582
|
-
this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3622
|
+
this.activeDrag ? this.dragTransform(this.lastDragImg ?? Dr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
|
|
3583
3623
|
}
|
|
3584
3624
|
fit() {
|
|
3585
3625
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -3608,7 +3648,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3608
3648
|
});
|
|
3609
3649
|
}
|
|
3610
3650
|
setShapes(e, t) {
|
|
3611
|
-
if (this.shapes =
|
|
3651
|
+
if (this.shapes = kr(e), this.selected = t, !this.activeDrag) {
|
|
3612
3652
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
3613
3653
|
for (let t of se(e).filter(z)) {
|
|
3614
3654
|
let e = this.makeNode(t), n = at(t, { strokeWidth: this.strokeSize });
|
|
@@ -3654,7 +3694,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3654
3694
|
if (t === R.POINT) {
|
|
3655
3695
|
let t = 1 / (this.world.scaleX() || 1), a = new N.Path({
|
|
3656
3696
|
id: e.id,
|
|
3657
|
-
data:
|
|
3697
|
+
data: br,
|
|
3658
3698
|
x: n[0].x,
|
|
3659
3699
|
y: n[0].y,
|
|
3660
3700
|
offsetX: 16 / 2,
|
|
@@ -3662,8 +3702,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3662
3702
|
scaleX: t,
|
|
3663
3703
|
scaleY: t,
|
|
3664
3704
|
fill: r.color,
|
|
3665
|
-
stroke:
|
|
3666
|
-
strokeWidth:
|
|
3705
|
+
stroke: xr,
|
|
3706
|
+
strokeWidth: Sr,
|
|
3667
3707
|
strokeScaleEnabled: !1,
|
|
3668
3708
|
shadowColor: "#000",
|
|
3669
3709
|
shadowBlur: 2,
|
|
@@ -3709,13 +3749,13 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3709
3749
|
liveUpdateShape(e, t) {
|
|
3710
3750
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3711
3751
|
if (n && r) {
|
|
3712
|
-
|
|
3752
|
+
yr(n, r.type, t);
|
|
3713
3753
|
let i = this.altNodes.get(e);
|
|
3714
|
-
i &&
|
|
3754
|
+
i && yr(i, r.type, t), r.type === R.POINT && n instanceof N.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3715
3755
|
}
|
|
3716
3756
|
}
|
|
3717
3757
|
pointRadius(e) {
|
|
3718
|
-
return
|
|
3758
|
+
return Mr(e, this.strokeSize, this.world.scaleX() || 1);
|
|
3719
3759
|
}
|
|
3720
3760
|
scaledDash(e) {
|
|
3721
3761
|
return e;
|
|
@@ -3735,7 +3775,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3735
3775
|
}
|
|
3736
3776
|
}
|
|
3737
3777
|
shapesIntersecting(e) {
|
|
3738
|
-
return
|
|
3778
|
+
return jr(this.shapes, e);
|
|
3739
3779
|
}
|
|
3740
3780
|
drawSelectionBorders() {
|
|
3741
3781
|
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && B(t)) : [];
|
|
@@ -3744,7 +3784,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3744
3784
|
this.selectionBorders = t.map(() => {
|
|
3745
3785
|
let e = new N.Line({
|
|
3746
3786
|
closed: !0,
|
|
3747
|
-
stroke:
|
|
3787
|
+
stroke: zr,
|
|
3748
3788
|
strokeWidth: 1.5,
|
|
3749
3789
|
strokeScaleEnabled: !1,
|
|
3750
3790
|
listening: !1
|
|
@@ -3765,7 +3805,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3765
3805
|
}
|
|
3766
3806
|
}
|
|
3767
3807
|
selectionOutlinePoints(e, t) {
|
|
3768
|
-
return
|
|
3808
|
+
return Pr(e, t, this.pointRadius(e));
|
|
3769
3809
|
}
|
|
3770
3810
|
clearPreview() {
|
|
3771
3811
|
this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3828,8 +3868,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3828
3868
|
x: n.x,
|
|
3829
3869
|
y: n.y,
|
|
3830
3870
|
radius: (r ? 6 : 5) / l,
|
|
3831
|
-
fill: r ?
|
|
3832
|
-
stroke: r ? "#ffffff" :
|
|
3871
|
+
fill: r ? Rr : "#ffffff",
|
|
3872
|
+
stroke: r ? "#ffffff" : Rr,
|
|
3833
3873
|
strokeWidth: 1.5,
|
|
3834
3874
|
strokeScaleEnabled: !1,
|
|
3835
3875
|
listening: !1
|
|
@@ -3883,14 +3923,14 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3883
3923
|
setTransformerOutlinePoints(e) {
|
|
3884
3924
|
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new N.Line({
|
|
3885
3925
|
closed: !0,
|
|
3886
|
-
stroke:
|
|
3926
|
+
stroke: Rr,
|
|
3887
3927
|
strokeWidth: 1,
|
|
3888
3928
|
strokeScaleEnabled: !1,
|
|
3889
3929
|
listening: !1
|
|
3890
3930
|
}), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
|
|
3891
3931
|
}
|
|
3892
3932
|
rotationHandleGap() {
|
|
3893
|
-
return
|
|
3933
|
+
return Fr(this.viewport.scale);
|
|
3894
3934
|
}
|
|
3895
3935
|
rotationHandleScreenPoint(e) {
|
|
3896
3936
|
return this.imgToScreen(we(e, this.rotationHandleGap()));
|
|
@@ -3909,7 +3949,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3909
3949
|
n.x,
|
|
3910
3950
|
n.y
|
|
3911
3951
|
],
|
|
3912
|
-
stroke:
|
|
3952
|
+
stroke: Rr,
|
|
3913
3953
|
strokeWidth: 1,
|
|
3914
3954
|
listening: !1
|
|
3915
3955
|
}), this.handleGroup.add(this.rotLineNode));
|
|
@@ -3924,7 +3964,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3924
3964
|
}), e.rotation(n * 180 / Math.PI);
|
|
3925
3965
|
}
|
|
3926
3966
|
orientedHandleAngle(e) {
|
|
3927
|
-
return
|
|
3967
|
+
return Ir(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
3928
3968
|
}
|
|
3929
3969
|
repositionOrientedHandles(e) {
|
|
3930
3970
|
let t = this.orientedHandleAngle(e);
|
|
@@ -3946,7 +3986,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3946
3986
|
for (let e of this.vertexNodes) e.destroy();
|
|
3947
3987
|
for (let e of this.midNodes) e.destroy();
|
|
3948
3988
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
3949
|
-
let e =
|
|
3989
|
+
let e = Ar(this.shapes, this.selected);
|
|
3950
3990
|
if (!e.length || e.length === 1 && e[0].type === R.POINT) return;
|
|
3951
3991
|
let t = e.length === 1 && (e[0].type === R.POLYGON || e[0].type === R.LINE) && this.editingId === e[0].id ? e[0] : null, n = U(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === R.ROTATED_RECTANGLE ? e[0] : null, i = r ? Ce(r.points) : H.map((e) => le(e, n));
|
|
3952
3992
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -3961,12 +4001,12 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3961
4001
|
offsetY: 4,
|
|
3962
4002
|
rotation: a * 180 / Math.PI,
|
|
3963
4003
|
fill: "#ffffff",
|
|
3964
|
-
stroke:
|
|
4004
|
+
stroke: Rr,
|
|
3965
4005
|
strokeWidth: 1
|
|
3966
4006
|
}), r = Kt(e, a);
|
|
3967
4007
|
this.bindCursor(n, r), n.on("mousedown", (t) => {
|
|
3968
4008
|
t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
3969
|
-
let n =
|
|
4009
|
+
let n = Ar(this.shapes, this.selected);
|
|
3970
4010
|
this.activeDrag = {
|
|
3971
4011
|
kind: "resize",
|
|
3972
4012
|
anchor: e,
|
|
@@ -3983,7 +4023,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3983
4023
|
radius: i * .8,
|
|
3984
4024
|
fill: "#ffffff",
|
|
3985
4025
|
opacity: .6,
|
|
3986
|
-
stroke:
|
|
4026
|
+
stroke: Rr,
|
|
3987
4027
|
strokeWidth: 1,
|
|
3988
4028
|
visible: !1,
|
|
3989
4029
|
listening: !1
|
|
@@ -4043,8 +4083,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
4043
4083
|
x: a.x,
|
|
4044
4084
|
y: a.y,
|
|
4045
4085
|
radius: i,
|
|
4046
|
-
fill: o ?
|
|
4047
|
-
stroke: o ? "#ffffff" :
|
|
4086
|
+
fill: o ? Rr : "#ffffff",
|
|
4087
|
+
stroke: o ? "#ffffff" : Rr,
|
|
4048
4088
|
strokeWidth: Math.max(1.5, i * .3)
|
|
4049
4089
|
});
|
|
4050
4090
|
this.bindCursor(s, "pointer"), s.on("mousedown", (t) => {
|
|
@@ -4069,7 +4109,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
4069
4109
|
y: r.y,
|
|
4070
4110
|
radius: 6,
|
|
4071
4111
|
fill: "#ffffff",
|
|
4072
|
-
stroke:
|
|
4112
|
+
stroke: Rr,
|
|
4073
4113
|
strokeWidth: 1.5
|
|
4074
4114
|
});
|
|
4075
4115
|
this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
|
|
@@ -4088,7 +4128,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
4088
4128
|
this.layer.batchDraw();
|
|
4089
4129
|
}
|
|
4090
4130
|
beginMove(e, t) {
|
|
4091
|
-
let n =
|
|
4131
|
+
let n = Or(this.shapes, t, e);
|
|
4092
4132
|
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === R.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4093
4133
|
}
|
|
4094
4134
|
repositionHandles(e) {
|
|
@@ -4130,7 +4170,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
4130
4170
|
let t = this.activeDrag;
|
|
4131
4171
|
if (!t) return;
|
|
4132
4172
|
this.applyCursor();
|
|
4133
|
-
let n =
|
|
4173
|
+
let n = Tr(this.shapes, t), { updates: r, box: i } = Er(t, e, n);
|
|
4134
4174
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
4135
4175
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
4136
4176
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
@@ -4167,18 +4207,18 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
4167
4207
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4168
4208
|
return;
|
|
4169
4209
|
}
|
|
4170
|
-
let { updates: n } =
|
|
4210
|
+
let { updates: n } = Er(e, t, Tr(this.shapes, e));
|
|
4171
4211
|
this.commitTransformUpdates(n);
|
|
4172
4212
|
}
|
|
4173
|
-
},
|
|
4174
|
-
function
|
|
4175
|
-
if (!e) return
|
|
4213
|
+
}, Vr = 2, Hr = 58879, Ur = 6725103;
|
|
4214
|
+
function Wr(e) {
|
|
4215
|
+
if (!e) return Hr;
|
|
4176
4216
|
let t = e.replace("#", "");
|
|
4177
4217
|
return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
|
|
4178
4218
|
}
|
|
4179
|
-
var
|
|
4219
|
+
var Gr = class {
|
|
4180
4220
|
constructor(e, t) {
|
|
4181
|
-
this.app = new P(), this.world = new I(), this.bgLayer = new I(), this.overlayLayer = new I(), this.regionOverlayLayer = new I(), this.dimOverlayLayer = new I(), this.shapeLayer = new I(), this.selLayer = new I(), this.previewLayer = new I(), this.handleLayer = new I(), this.filter = new F(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize =
|
|
4221
|
+
this.app = new P(), this.world = new I(), this.bgLayer = new I(), this.overlayLayer = new I(), this.regionOverlayLayer = new I(), this.dimOverlayLayer = new I(), this.shapeLayer = new I(), this.selLayer = new I(), this.previewLayer = new I(), this.handleLayer = new I(), this.filter = new F(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize = gr, this.region = null, this.regionDimMaskG = new L(), this.regionDimG = new L(), this.regionZoneMaskG = new L(), this.regionZoneG = new L(), this.regionOutlineG = new L(), this.baseCursor = "default", this.strokeSize = Vr, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.brightness = 1, this.contrast = 1, this.imageSmoothing = !0, this.destroyed = !1, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastDragImg = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorderGfx = [], this.previewG = new L(), this.marqueeG = new L(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
4182
4222
|
}
|
|
4183
4223
|
ev(e) {
|
|
4184
4224
|
return {
|
|
@@ -4208,7 +4248,7 @@ var zr = class {
|
|
|
4208
4248
|
}
|
|
4209
4249
|
this.host.appendChild(this.app.canvas);
|
|
4210
4250
|
let e = this.app.renderer.gl, t = e?.getParameter(e.MAX_TEXTURE_SIZE);
|
|
4211
|
-
typeof t == "number" && t > 1 && (this.tileSize = Math.min(
|
|
4251
|
+
typeof t == "number" && t > 1 && (this.tileSize = Math.min(gr, t - 1)), this.applyCursor(), this.overlayLayer.addChild(this.regionOverlayLayer, this.dimOverlayLayer), this.regionOverlayLayer.addChild(this.regionDimMaskG, this.regionDimG, this.regionZoneMaskG, this.regionZoneG, this.regionOutlineG), this.regionDimG.setMask({
|
|
4212
4252
|
mask: this.regionDimMaskG,
|
|
4213
4253
|
inverse: !0
|
|
4214
4254
|
}), this.regionZoneG.setMask({ mask: this.regionZoneMaskG }), this.world.addChild(this.bgLayer, this.overlayLayer, this.shapeLayer, this.selLayer, this.previewLayer), this.app.stage.addChild(this.world, this.handleLayer), this.world.visible = !1, this.app.stage.eventMode = "static", this.syncHitArea(), this.app.stage.on("pointerdown", (e) => {
|
|
@@ -4291,8 +4331,8 @@ var zr = class {
|
|
|
4291
4331
|
this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
|
|
4292
4332
|
let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
|
|
4293
4333
|
this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
|
|
4294
|
-
for (let e of
|
|
4295
|
-
let t = re.from(
|
|
4334
|
+
for (let e of _r(i.naturalWidth, i.naturalHeight, this.tileSize)) {
|
|
4335
|
+
let t = re.from(vr(i, e));
|
|
4296
4336
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
4297
4337
|
let n = new ne(t);
|
|
4298
4338
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
@@ -4339,7 +4379,7 @@ var zr = class {
|
|
|
4339
4379
|
if (t && this.imageWidth) {
|
|
4340
4380
|
let e = nn(this.host);
|
|
4341
4381
|
this.dimOverlayLayer.addChild(new L().rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
4342
|
-
color:
|
|
4382
|
+
color: Wr(e.color),
|
|
4343
4383
|
alpha: e.opacity
|
|
4344
4384
|
}));
|
|
4345
4385
|
}
|
|
@@ -4347,7 +4387,7 @@ var zr = class {
|
|
|
4347
4387
|
}
|
|
4348
4388
|
setRegionOverlay(e) {
|
|
4349
4389
|
if (this.region = e, this.regionDimMaskG.clear(), this.regionDimG.clear(), this.regionZoneMaskG.clear(), this.regionZoneG.clear(), this.regionOutlineG.clear(), !e) return;
|
|
4350
|
-
let t =
|
|
4390
|
+
let t = Wr(e.dim.color);
|
|
4351
4391
|
for (let t of e.rects) this.regionDimMaskG.rect(t.x, t.y, t.w, t.h).fill(16777215), this.regionZoneMaskG.rect(t.x, t.y, t.w, t.h).fill(16777215);
|
|
4352
4392
|
this.regionDimG.rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
4353
4393
|
color: t,
|
|
@@ -4368,7 +4408,7 @@ var zr = class {
|
|
|
4368
4408
|
}
|
|
4369
4409
|
applyViewport(e) {
|
|
4370
4410
|
let t = e.scale !== this.lastAppliedScale;
|
|
4371
|
-
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
4411
|
+
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ?? Dr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
|
|
4372
4412
|
}
|
|
4373
4413
|
fit() {
|
|
4374
4414
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -4404,7 +4444,7 @@ var zr = class {
|
|
|
4404
4444
|
});
|
|
4405
4445
|
}
|
|
4406
4446
|
setShapes(e, t) {
|
|
4407
|
-
this.shapes =
|
|
4447
|
+
this.shapes = kr(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
|
|
4408
4448
|
}
|
|
4409
4449
|
setSelection(e) {
|
|
4410
4450
|
this.selected = e, (e.length !== 1 || e[0] !== this.vertexPolygonId) && (this.vertexPolygonId = null, this.selectedVertices.clear()), this.editingId && (e.length !== 1 || e[0] !== this.editingId) && (this.editingId = null), !this.activeDrag && (this.drawSelectionBorders(), this.drawTransformer());
|
|
@@ -4427,10 +4467,10 @@ var zr = class {
|
|
|
4427
4467
|
this.handleLayer.interactiveChildren = !e;
|
|
4428
4468
|
}
|
|
4429
4469
|
strokeW(e) {
|
|
4430
|
-
return (e ? at(e, { strokeWidth: this.strokeSize }).strokeWidth :
|
|
4470
|
+
return (e ? at(e, { strokeWidth: this.strokeSize }).strokeWidth : Vr) / this.world.scale.x;
|
|
4431
4471
|
}
|
|
4432
4472
|
pointRadius(e) {
|
|
4433
|
-
return
|
|
4473
|
+
return Mr(e, this.strokeSize, this.world.scale.x);
|
|
4434
4474
|
}
|
|
4435
4475
|
dashForShape(e) {
|
|
4436
4476
|
let t = at(e, { strokeWidth: this.strokeSize }).dash;
|
|
@@ -4455,9 +4495,9 @@ var zr = class {
|
|
|
4455
4495
|
}
|
|
4456
4496
|
paintShape(e, t) {
|
|
4457
4497
|
e.clear();
|
|
4458
|
-
let n = at(t, { strokeWidth: this.strokeSize }), r =
|
|
4498
|
+
let n = at(t, { strokeWidth: this.strokeSize }), r = Wr(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
4459
4499
|
if (t.type === R.POINT) {
|
|
4460
|
-
e.svg(
|
|
4500
|
+
e.svg(Cr(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
4461
4501
|
let r = 1 / (this.world.scale.x || 1);
|
|
4462
4502
|
e.scale.set(r, r), e.alpha = a;
|
|
4463
4503
|
return;
|
|
@@ -4482,7 +4522,7 @@ var zr = class {
|
|
|
4482
4522
|
if (o) {
|
|
4483
4523
|
t.style?.alternateColor && (this.path(e, t), e.stroke({
|
|
4484
4524
|
width: i,
|
|
4485
|
-
color:
|
|
4525
|
+
color: Wr(t.style.alternateColor),
|
|
4486
4526
|
alpha: a
|
|
4487
4527
|
})), this.dashedStrokeShape(e, t, i, r, a, o);
|
|
4488
4528
|
return;
|
|
@@ -4501,7 +4541,7 @@ var zr = class {
|
|
|
4501
4541
|
});
|
|
4502
4542
|
}
|
|
4503
4543
|
shapesIntersecting(e) {
|
|
4504
|
-
return
|
|
4544
|
+
return jr(this.shapes, e);
|
|
4505
4545
|
}
|
|
4506
4546
|
shapesAt(e) {
|
|
4507
4547
|
return this.shapes.filter((t) => {
|
|
@@ -4538,16 +4578,16 @@ var zr = class {
|
|
|
4538
4578
|
}, a = this.strokeW(i);
|
|
4539
4579
|
r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
|
|
4540
4580
|
width: a,
|
|
4541
|
-
color:
|
|
4581
|
+
color: Wr(r.alternateColor)
|
|
4542
4582
|
}));
|
|
4543
4583
|
let o = this.dashForShape(i);
|
|
4544
4584
|
if (o) {
|
|
4545
|
-
this.dashedStrokeShape(this.previewG, i, a,
|
|
4585
|
+
this.dashedStrokeShape(this.previewG, i, a, Wr(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
|
|
4546
4586
|
return;
|
|
4547
4587
|
}
|
|
4548
4588
|
this.path(this.previewG, i), this.previewG.stroke({
|
|
4549
4589
|
width: a,
|
|
4550
|
-
color:
|
|
4590
|
+
color: Wr(r.color ?? "#00e5ff"),
|
|
4551
4591
|
alpha: r.opacity ?? 1
|
|
4552
4592
|
});
|
|
4553
4593
|
}
|
|
@@ -4569,12 +4609,12 @@ var zr = class {
|
|
|
4569
4609
|
}, c = this.strokeW(s);
|
|
4570
4610
|
n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
|
|
4571
4611
|
width: c,
|
|
4572
|
-
color:
|
|
4612
|
+
color: Wr(n.alternateColor)
|
|
4573
4613
|
}));
|
|
4574
4614
|
let l = this.dashForShape(s);
|
|
4575
|
-
if (l ? this.dashedStrokeShape(this.previewG, s, c,
|
|
4615
|
+
if (l ? this.dashedStrokeShape(this.previewG, s, c, Wr(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
|
|
4576
4616
|
width: c,
|
|
4577
|
-
color:
|
|
4617
|
+
color: Wr(n.color ?? "#00e5ff"),
|
|
4578
4618
|
alpha: n.opacity ?? 1
|
|
4579
4619
|
})), !a) return;
|
|
4580
4620
|
let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
|
|
@@ -4593,7 +4633,7 @@ var zr = class {
|
|
|
4593
4633
|
}
|
|
4594
4634
|
previewMarquee(e, t) {
|
|
4595
4635
|
this.ensurePreview(), this.marqueeG.clear();
|
|
4596
|
-
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o =
|
|
4636
|
+
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o = Wr(nt);
|
|
4597
4637
|
this.marqueeG.rect(n, r, i, a).fill({
|
|
4598
4638
|
color: o,
|
|
4599
4639
|
alpha: rt
|
|
@@ -4627,8 +4667,8 @@ var zr = class {
|
|
|
4627
4667
|
o.y
|
|
4628
4668
|
], !1).stroke({
|
|
4629
4669
|
width: i,
|
|
4630
|
-
color:
|
|
4631
|
-
}), this.strokeDashedPolyline(e, [n, o], !1, i,
|
|
4670
|
+
color: Wr(r.underlayColor)
|
|
4671
|
+
}), this.strokeDashedPolyline(e, [n, o], !1, i, Wr(r.color), r.opacity, a);
|
|
4632
4672
|
};
|
|
4633
4673
|
r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
|
|
4634
4674
|
}
|
|
@@ -4740,7 +4780,7 @@ var zr = class {
|
|
|
4740
4780
|
let r = this.selectionBorderGfx[t];
|
|
4741
4781
|
r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4742
4782
|
width: n,
|
|
4743
|
-
color:
|
|
4783
|
+
color: Ur
|
|
4744
4784
|
});
|
|
4745
4785
|
});
|
|
4746
4786
|
}
|
|
@@ -4751,12 +4791,12 @@ var zr = class {
|
|
|
4751
4791
|
let a = this.selectionBorderGfx[r++];
|
|
4752
4792
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4753
4793
|
width: n,
|
|
4754
|
-
color:
|
|
4794
|
+
color: Ur
|
|
4755
4795
|
}));
|
|
4756
4796
|
}
|
|
4757
4797
|
}
|
|
4758
4798
|
selectionOutlinePoints(e, t) {
|
|
4759
|
-
return
|
|
4799
|
+
return Pr(e, t, this.pointRadius(e));
|
|
4760
4800
|
}
|
|
4761
4801
|
imgToScreen(e) {
|
|
4762
4802
|
let t = this.world.toGlobal({
|
|
@@ -4785,7 +4825,7 @@ var zr = class {
|
|
|
4785
4825
|
}));
|
|
4786
4826
|
}
|
|
4787
4827
|
rotationHandleGap() {
|
|
4788
|
-
return
|
|
4828
|
+
return Fr(this.viewport.scale);
|
|
4789
4829
|
}
|
|
4790
4830
|
rotationHandleScreenPoint(e) {
|
|
4791
4831
|
return this.imgToScreen(we(e, this.rotationHandleGap()));
|
|
@@ -4801,7 +4841,7 @@ var zr = class {
|
|
|
4801
4841
|
e.position.set(t.x, t.y), e.rotation = n;
|
|
4802
4842
|
}
|
|
4803
4843
|
orientedHandleAngle(e) {
|
|
4804
|
-
return
|
|
4844
|
+
return Ir(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
4805
4845
|
}
|
|
4806
4846
|
drawTransformer() {
|
|
4807
4847
|
if (this.activeDrag) return;
|
|
@@ -4809,7 +4849,7 @@ var zr = class {
|
|
|
4809
4849
|
for (let e of this.vertexNodes) e.destroy();
|
|
4810
4850
|
for (let e of this.midNodes) e.destroy();
|
|
4811
4851
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
4812
|
-
let e =
|
|
4852
|
+
let e = Ar(this.shapes, this.selected);
|
|
4813
4853
|
if (e.length === 0 || e.length === 1 && e[0].type === R.POINT) return;
|
|
4814
4854
|
let t = e.length === 1 && (e[0].type === R.POLYGON || e[0].type === R.LINE) && this.editingId === e[0].id ? e[0] : null, n = U(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === R.ROTATED_RECTANGLE ? e[0] : null, i = r ? Ce(r.points) : H.map((e) => le(e, n));
|
|
4815
4855
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -4823,7 +4863,7 @@ var zr = class {
|
|
|
4823
4863
|
let r = Kt(e, a);
|
|
4824
4864
|
this.bindCursor(n, r), n.on("pointerdown", (t) => {
|
|
4825
4865
|
t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4826
|
-
let n =
|
|
4866
|
+
let n = Ar(this.shapes, this.selected);
|
|
4827
4867
|
this.activeDrag = {
|
|
4828
4868
|
kind: "resize",
|
|
4829
4869
|
anchor: e,
|
|
@@ -4920,7 +4960,7 @@ var zr = class {
|
|
|
4920
4960
|
}
|
|
4921
4961
|
}
|
|
4922
4962
|
beginMove(e, t) {
|
|
4923
|
-
let n =
|
|
4963
|
+
let n = Or(this.shapes, t, e);
|
|
4924
4964
|
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === R.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4925
4965
|
}
|
|
4926
4966
|
repositionHandlesForBox(e) {
|
|
@@ -4988,7 +5028,7 @@ var zr = class {
|
|
|
4988
5028
|
let t = this.activeDrag;
|
|
4989
5029
|
if (!t) return;
|
|
4990
5030
|
this.applyCursor();
|
|
4991
|
-
let n =
|
|
5031
|
+
let n = Tr(this.shapes, t), { updates: r, box: i } = Er(t, e, n);
|
|
4992
5032
|
if (t.kind === "move") {
|
|
4993
5033
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4994
5034
|
for (let e of t.shapes) {
|
|
@@ -5030,13 +5070,13 @@ var zr = class {
|
|
|
5030
5070
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
5031
5071
|
return;
|
|
5032
5072
|
}
|
|
5033
|
-
let { updates: n } =
|
|
5073
|
+
let { updates: n } = Er(e, t, Tr(this.shapes, e));
|
|
5034
5074
|
e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
|
|
5035
5075
|
}
|
|
5036
5076
|
};
|
|
5037
5077
|
//#endregion
|
|
5038
5078
|
//#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
|
|
5039
|
-
function
|
|
5079
|
+
function Kr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
|
|
5040
5080
|
if (!r) return e !== null || n !== null ? { kind: "clear" } : { kind: "none" };
|
|
5041
5081
|
let i = e !== t;
|
|
5042
5082
|
return !i && n === r ? { kind: "none" } : {
|
|
@@ -5044,10 +5084,10 @@ function Br({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r
|
|
|
5044
5084
|
docChange: i
|
|
5045
5085
|
};
|
|
5046
5086
|
}
|
|
5047
|
-
function
|
|
5087
|
+
function qr({ keepZoomOnImageChange: e, viewportSeeded: t }) {
|
|
5048
5088
|
return e && t;
|
|
5049
5089
|
}
|
|
5050
|
-
function
|
|
5090
|
+
function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImageUrl: i, makeCallbacks: a, viewRef: o, readOnlyRef: s, toolRef: c, renderShapesRef: l, coordinateSizeRef: u, imageSizeRef: d, selRef: f, regionOverlayRef: p, dimmedRef: m, syncMinimap: h, setImage: g, setImageVisible: _, setReady: v, setImageStatus: y, onContextMenuRequest: b }) {
|
|
5051
5091
|
let x = j(i);
|
|
5052
5092
|
x.current = i;
|
|
5053
5093
|
let S = j(r);
|
|
@@ -5058,12 +5098,12 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5058
5098
|
A.current = b, T(() => {
|
|
5059
5099
|
let r = t.current;
|
|
5060
5100
|
if (!r) return;
|
|
5061
|
-
let i = !1, a = null, b = null, T = k.current(), j = e === "konva" ? new
|
|
5101
|
+
let i = !1, a = null, b = null, T = k.current(), j = e === "konva" ? new Br(r, T) : new Gr(r, T);
|
|
5062
5102
|
return n.current = j, O.current = !1, (async () => {
|
|
5063
5103
|
try {
|
|
5064
5104
|
await j.init();
|
|
5065
5105
|
} catch (e) {
|
|
5066
|
-
i || y("error",
|
|
5106
|
+
i || y("error", hr(e));
|
|
5067
5107
|
return;
|
|
5068
5108
|
}
|
|
5069
5109
|
if (i) return;
|
|
@@ -5074,7 +5114,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5074
5114
|
try {
|
|
5075
5115
|
n = await j.setImage(e, u.current, d.current);
|
|
5076
5116
|
} catch (t) {
|
|
5077
|
-
!i && x.current === e && y("error",
|
|
5117
|
+
!i && x.current === e && y("error", hr(t));
|
|
5078
5118
|
}
|
|
5079
5119
|
if (i) return;
|
|
5080
5120
|
if (n !== null) {
|
|
@@ -5085,7 +5125,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5085
5125
|
let r = D.current;
|
|
5086
5126
|
r?.viewport && (r.imageUrl === C.current || o.current.keepZoomOnImageChange) ? j.applyViewport(r.viewport) : j.fit(), O.current = !0, h(), v(!0);
|
|
5087
5127
|
let a = () => x.current === e;
|
|
5088
|
-
n ? a() && y("ready") :
|
|
5128
|
+
n ? a() && y("ready") : fr(e).then((e) => {
|
|
5089
5129
|
!i && a() && y("error", e);
|
|
5090
5130
|
});
|
|
5091
5131
|
}
|
|
@@ -5129,7 +5169,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5129
5169
|
}, [e]), T(() => {
|
|
5130
5170
|
let e = n.current;
|
|
5131
5171
|
if (!e || !E.current) return;
|
|
5132
|
-
let t =
|
|
5172
|
+
let t = Kr({
|
|
5133
5173
|
currentDocId: w.current,
|
|
5134
5174
|
documentId: r,
|
|
5135
5175
|
loadedUrl: C.current,
|
|
@@ -5152,7 +5192,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5152
5192
|
try {
|
|
5153
5193
|
i = await e.setImage(s, u.current, d.current);
|
|
5154
5194
|
} catch (t) {
|
|
5155
|
-
!c && n.current === e && y("error",
|
|
5195
|
+
!c && n.current === e && y("error", hr(t));
|
|
5156
5196
|
return;
|
|
5157
5197
|
}
|
|
5158
5198
|
if (c || n.current !== e) return;
|
|
@@ -5162,7 +5202,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5162
5202
|
y("ready");
|
|
5163
5203
|
return;
|
|
5164
5204
|
}
|
|
5165
|
-
|
|
5205
|
+
fr(s).then((e) => {
|
|
5166
5206
|
c || y("error", e);
|
|
5167
5207
|
});
|
|
5168
5208
|
};
|
|
@@ -5173,7 +5213,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5173
5213
|
w.current = r, g({
|
|
5174
5214
|
w: e.imageWidth,
|
|
5175
5215
|
h: e.imageHeight
|
|
5176
|
-
}), _(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showRegionMask ? p.current : null, m.current),
|
|
5216
|
+
}), _(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showRegionMask ? p.current : null, m.current), qr({
|
|
5177
5217
|
keepZoomOnImageChange: o.current.keepZoomOnImageChange,
|
|
5178
5218
|
viewportSeeded: O.current
|
|
5179
5219
|
}) || e.fit(), O.current = !0, h(), v(!0), a();
|
|
@@ -5184,19 +5224,19 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5184
5224
|
}
|
|
5185
5225
|
//#endregion
|
|
5186
5226
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
5187
|
-
var
|
|
5188
|
-
function
|
|
5227
|
+
var Yr = .05, Xr = 20;
|
|
5228
|
+
function Zr(e) {
|
|
5189
5229
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
5190
5230
|
return r === 0 ? Math.abs(t) < 10 || Math.abs(n) < 10 || !Number.isInteger(t) || !Number.isInteger(n) : r === 1 ? !1 : !Number.isInteger(t) || !Number.isInteger(n);
|
|
5191
5231
|
}
|
|
5192
|
-
function
|
|
5232
|
+
function Qr(e) {
|
|
5193
5233
|
let t = e.currentTarget.getBoundingClientRect();
|
|
5194
5234
|
return {
|
|
5195
5235
|
x: e.clientX - t.left,
|
|
5196
5236
|
y: e.clientY - t.top
|
|
5197
5237
|
};
|
|
5198
5238
|
}
|
|
5199
|
-
function
|
|
5239
|
+
function $r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
5200
5240
|
let i = j(null), a = !!t && t.w > 0 && t.h > 0, o = a ? Math.min(r / t.w, r / t.h) : 1, s = a ? t.w * o : 0, c = a ? t.h * o : 0, l = a ? (r - s) / 2 : 0, u = a ? (r - c) / 2 : 0, d = w(() => {
|
|
5201
5241
|
let t = e.current;
|
|
5202
5242
|
if (!t) return null;
|
|
@@ -5234,7 +5274,7 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5234
5274
|
let n = e.current, r = d();
|
|
5235
5275
|
if (!n || !r) return;
|
|
5236
5276
|
t.preventDefault(), t.stopPropagation();
|
|
5237
|
-
let a =
|
|
5277
|
+
let a = Qr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
|
|
5238
5278
|
offsetX: a.x - r.x,
|
|
5239
5279
|
offsetY: a.y - r.y
|
|
5240
5280
|
} : {
|
|
@@ -5251,7 +5291,7 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5251
5291
|
d
|
|
5252
5292
|
]), m = w((t) => {
|
|
5253
5293
|
let n = i.current, r = e.current;
|
|
5254
|
-
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(
|
|
5294
|
+
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(Qr(t), r.viewport.scale, n));
|
|
5255
5295
|
}, [f, e]), h = w((e) => {
|
|
5256
5296
|
let t = i.current;
|
|
5257
5297
|
!t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
|
|
@@ -5259,8 +5299,8 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5259
5299
|
let r = e.current;
|
|
5260
5300
|
if (!r || !n) return;
|
|
5261
5301
|
t.preventDefault(), t.stopPropagation();
|
|
5262
|
-
let i =
|
|
5263
|
-
f(
|
|
5302
|
+
let i = Zr(t.nativeEvent) ? 2.5 : 1, a = t.deltaY * i, o = 1.05, s = a > 0 ? r.viewport.scale / o : r.viewport.scale * o, c = Math.max(Yr, Math.min(Xr, s));
|
|
5303
|
+
f(Qr(t), c);
|
|
5264
5304
|
}, [
|
|
5265
5305
|
f,
|
|
5266
5306
|
e,
|
|
@@ -5297,7 +5337,7 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5297
5337
|
}
|
|
5298
5338
|
//#endregion
|
|
5299
5339
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
5300
|
-
function
|
|
5340
|
+
function ei(e, t, n) {
|
|
5301
5341
|
if (!(!e || !n.length)) {
|
|
5302
5342
|
if (t.type === R.POINT) {
|
|
5303
5343
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
@@ -5315,7 +5355,7 @@ function Jr(e, t, n) {
|
|
|
5315
5355
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
5316
5356
|
}
|
|
5317
5357
|
}
|
|
5318
|
-
function
|
|
5358
|
+
function ti({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
|
|
5319
5359
|
let s = j(/* @__PURE__ */ new Map());
|
|
5320
5360
|
return {
|
|
5321
5361
|
registerMinimapShape: w((e, t) => {
|
|
@@ -5324,13 +5364,13 @@ function Yr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
5324
5364
|
applyMinimapPreview: w((e) => {
|
|
5325
5365
|
let n = t.current.getShapes();
|
|
5326
5366
|
if (!e.length) {
|
|
5327
|
-
for (let e of n)
|
|
5367
|
+
for (let e of n) ei(s.current.get(e.id), e, e.points);
|
|
5328
5368
|
return;
|
|
5329
5369
|
}
|
|
5330
5370
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
5331
5371
|
for (let t of e) {
|
|
5332
5372
|
let e = r.get(t.id);
|
|
5333
|
-
e &&
|
|
5373
|
+
e && ei(s.current.get(e.id), e, t.points);
|
|
5334
5374
|
}
|
|
5335
5375
|
}, [t]),
|
|
5336
5376
|
syncMinimap: w(() => {
|
|
@@ -5359,8 +5399,8 @@ function Yr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
5359
5399
|
}
|
|
5360
5400
|
//#endregion
|
|
5361
5401
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
5362
|
-
var
|
|
5363
|
-
function
|
|
5402
|
+
var ni = 12;
|
|
5403
|
+
function ri({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
|
|
5364
5404
|
let s = j(0), c = j(!0), l = j(n), u = j(a), d = j(o);
|
|
5365
5405
|
l.current = n, u.current = a, d.current = o, T(() => (c.current = !0, () => {
|
|
5366
5406
|
c.current = !1;
|
|
@@ -5394,7 +5434,7 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5394
5434
|
let e = U(m);
|
|
5395
5435
|
f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
|
|
5396
5436
|
} else {
|
|
5397
|
-
let e = !!n.documentId && n.documentId !== a, t = Bt(s.current, e,
|
|
5437
|
+
let e = !!n.documentId && n.documentId !== a, t = Bt(s.current, e, ni);
|
|
5398
5438
|
f = t.offset, s.current = t.nextPasteCount, p = f;
|
|
5399
5439
|
}
|
|
5400
5440
|
let h = n.shapes.map((e) => ({
|
|
@@ -5419,8 +5459,8 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5419
5459
|
...e,
|
|
5420
5460
|
id: ce(),
|
|
5421
5461
|
points: e.points.map((e) => ({
|
|
5422
|
-
x: e.x +
|
|
5423
|
-
y: e.y +
|
|
5462
|
+
x: e.x + ni,
|
|
5463
|
+
y: e.y + ni
|
|
5424
5464
|
}))
|
|
5425
5465
|
}));
|
|
5426
5466
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -5501,7 +5541,7 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5501
5541
|
}
|
|
5502
5542
|
//#endregion
|
|
5503
5543
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
5504
|
-
function
|
|
5544
|
+
function ii({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
5505
5545
|
let o = j(null), s = j(null), c = w(() => {
|
|
5506
5546
|
o.current?.(), o.current = null;
|
|
5507
5547
|
}, []), l = w((t, n = r) => {
|
|
@@ -5573,16 +5613,16 @@ function Qr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5573
5613
|
}
|
|
5574
5614
|
//#endregion
|
|
5575
5615
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
5576
|
-
var
|
|
5616
|
+
var ai = "__draft_preview__", oi = new Set([
|
|
5577
5617
|
"copy",
|
|
5578
5618
|
"selectAll",
|
|
5579
5619
|
"clearSelection",
|
|
5580
5620
|
"zoomToSelection"
|
|
5581
5621
|
]);
|
|
5582
|
-
function
|
|
5622
|
+
function si(e, t) {
|
|
5583
5623
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
5584
5624
|
}
|
|
5585
|
-
function
|
|
5625
|
+
function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: o, draftMeta: s, readOnly: c, disableMarquee: l, locked: u, onLockedInteraction: f, onDrawAttemptWithoutDraft: p, onIdleEscape: m, overrideShapeInteraction: h, defaultViewSettings: g, viewSettings: _, onViewSettingsChange: v, showMinimap: y = !0, minimapPosition: b = "bottom-left", showViewSettings: C = !0, getContextMenuItems: A, strings: N, viewSettingItems: P, canMergeSelection: F, brushSize: I = 20, zoomBound: L, zoomAnimationDuration: ee = 300, decorationShapes: te, regionMask: ne, overlayMarkers: re, renderOverlayMarker: ie, onOverlayMarkerClick: oe, renderImageOverlay: se, getSelectionLabel: V, hideSelectionLabelDot: H, formatSelectionInfo: U, externalTools: le, assistant: ue, keymap: de, handleRef: fe, backend: pe = "pixi", onActiveToolChange: me, onSelectionChange: he, onEditingChange: ge, onShapesCreated: _e, onShapesUpdated: ve, onShapesDeleted: ye, onDrawSessionChange: be, onDraftShapeChange: xe, onViewportChange: Se, onShapesTransformPreview: Ce }) {
|
|
5586
5626
|
let we = j(null), W = j(null), Te = j(null), Ee = j(null), De = j(null), Oe = `${E()}-minimap`, [G, ke] = M(null), [Ae, je] = M(!1), [Me, Ne] = M(!1), [Pe, Fe] = M(null), [Ie, Le] = M({
|
|
5587
5627
|
active: !1,
|
|
5588
5628
|
kind: "none",
|
|
@@ -5707,7 +5747,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5707
5747
|
});
|
|
5708
5748
|
}, []), en = w((e) => {
|
|
5709
5749
|
let t = $t(e);
|
|
5710
|
-
|
|
5750
|
+
si(At.current, t) || (lt || ct(t), W.current?.setSelection(t), he?.(t));
|
|
5711
5751
|
}, [
|
|
5712
5752
|
$t,
|
|
5713
5753
|
he,
|
|
@@ -5720,7 +5760,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5720
5760
|
sn.current = nn, T(() => {
|
|
5721
5761
|
if (!lt) return;
|
|
5722
5762
|
let e = $t(i);
|
|
5723
|
-
|
|
5763
|
+
si(i, e) || he?.(e);
|
|
5724
5764
|
}, [
|
|
5725
5765
|
i,
|
|
5726
5766
|
J.shapes,
|
|
@@ -5730,7 +5770,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5730
5770
|
]);
|
|
5731
5771
|
let ln = j(Se);
|
|
5732
5772
|
ln.current = Se;
|
|
5733
|
-
let { registerMinimapShape: un, applyMinimapPreview: dn, syncMinimap: fn } =
|
|
5773
|
+
let { registerMinimapShape: un, applyMinimapPreview: dn, syncMinimap: fn } = ti({
|
|
5734
5774
|
engineRef: W,
|
|
5735
5775
|
docRef: Gt,
|
|
5736
5776
|
overlayRef: Ee,
|
|
@@ -5770,14 +5810,14 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5770
5810
|
return;
|
|
5771
5811
|
}
|
|
5772
5812
|
let t = {
|
|
5773
|
-
id:
|
|
5813
|
+
id: ai,
|
|
5774
5814
|
type: e.type,
|
|
5775
5815
|
points: e.points,
|
|
5776
5816
|
style: Mt.current,
|
|
5777
5817
|
meta: Nt.current
|
|
5778
5818
|
}, n = gn.current !== null;
|
|
5779
5819
|
gn.current = t, n ? xn([{
|
|
5780
|
-
id:
|
|
5820
|
+
id: ai,
|
|
5781
5821
|
points: e.points
|
|
5782
5822
|
}]) : bn(t);
|
|
5783
5823
|
}, [xn, xe]), wn = w((e, t) => {
|
|
@@ -5821,7 +5861,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5821
5861
|
assistantRef: qn
|
|
5822
5862
|
}), Jn = j($);
|
|
5823
5863
|
Jn.current = $;
|
|
5824
|
-
let Yn = k(() => Pt(Ue), [Ue]), { selectAll: Xn, clearSelection: Zn, deleteSelection: Qn, copySelection: er, canPaste: tr, paste: nr, duplicate: rr, bringToFront: ir, sendToBack: ar, nudgeSelection: or, getMergeTargets: sr, mergeSelection: cr } =
|
|
5864
|
+
let Yn = k(() => Pt(Ue), [Ue]), { selectAll: Xn, clearSelection: Zn, deleteSelection: Qn, copySelection: er, canPaste: tr, paste: nr, duplicate: rr, bringToFront: ir, sendToBack: ar, nudgeSelection: or, getMergeTargets: sr, mergeSelection: cr } = ri({
|
|
5825
5865
|
doc: J,
|
|
5826
5866
|
selRef: At,
|
|
5827
5867
|
effectiveReadOnly: Q,
|
|
@@ -5829,7 +5869,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5829
5869
|
canMergeSelection: F,
|
|
5830
5870
|
clipboardDocumentId: Yn,
|
|
5831
5871
|
clipboardScope: t ?? Yn
|
|
5832
|
-
}), { zoomToBounds: lr, zoomToShapes: ur, zoomToSelection: dr, zoomAtCenter: fr } =
|
|
5872
|
+
}), { zoomToBounds: lr, zoomToShapes: ur, zoomToSelection: dr, zoomAtCenter: fr } = ii({
|
|
5833
5873
|
engineRef: W,
|
|
5834
5874
|
doc: J,
|
|
5835
5875
|
selRef: At,
|
|
@@ -5962,7 +6002,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5962
6002
|
Sn,
|
|
5963
6003
|
Cn
|
|
5964
6004
|
]), hr = j([]);
|
|
5965
|
-
|
|
6005
|
+
Jr({
|
|
5966
6006
|
backend: pe,
|
|
5967
6007
|
hostRef: we,
|
|
5968
6008
|
engineRef: W,
|
|
@@ -6329,10 +6369,10 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6329
6369
|
disabled: !Er,
|
|
6330
6370
|
onClick: dr
|
|
6331
6371
|
}
|
|
6332
|
-
], Pr = c ? Nr.filter((e) => "separator" in e || !!e.id &&
|
|
6372
|
+
], Pr = c ? Nr.filter((e) => "separator" in e || !!e.id && oi.has(e.id)) : Nr, Fr = A ? A(Pr, {
|
|
6333
6373
|
selectedIds: Y,
|
|
6334
6374
|
readOnly: Q
|
|
6335
|
-
}) : Pr, Ir =
|
|
6375
|
+
}) : Pr, Ir = $r({
|
|
6336
6376
|
engineRef: W,
|
|
6337
6377
|
image: G,
|
|
6338
6378
|
wheelZoom: X.wheelZoom,
|
|
@@ -6477,15 +6517,67 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6477
6517
|
});
|
|
6478
6518
|
}
|
|
6479
6519
|
//#endregion
|
|
6520
|
+
//#region src/components/ShapeEditor/_model/viewerPatch.ts
|
|
6521
|
+
function li({ viewport: e, image: t, focusPoints: n, zoomPadding: r, focusFit: i }) {
|
|
6522
|
+
let a = Math.min(e.width / t.width, e.height / t.height);
|
|
6523
|
+
if (!n?.length) return {
|
|
6524
|
+
scale: a,
|
|
6525
|
+
offsetX: (e.width - t.width * a) / 2,
|
|
6526
|
+
offsetY: (e.height - t.height * a) / 2
|
|
6527
|
+
};
|
|
6528
|
+
let o = U(n), s = Math.max(o.maxX - o.minX, 50), c = Math.max(o.maxY - o.minY, 50), l = Math.min(s, c) * r, u = Math.min(e.width / (s + l * 2), e.height / (c + l * 2));
|
|
6529
|
+
i === "cover" && (u = Math.max(u, Math.max(e.width / t.width, e.height / t.height)));
|
|
6530
|
+
let d = e.width / 2 - (o.minX + o.maxX) / 2 * u, f = e.height / 2 - (o.minY + o.maxY) / 2 * u;
|
|
6531
|
+
return i === "cover" && (d = Math.min(0, Math.max(d, e.width - t.width * u)), f = Math.min(0, Math.max(f, e.height - t.height * u))), {
|
|
6532
|
+
scale: u,
|
|
6533
|
+
offsetX: d,
|
|
6534
|
+
offsetY: f
|
|
6535
|
+
};
|
|
6536
|
+
}
|
|
6537
|
+
function ui(e, t, n) {
|
|
6538
|
+
let r = Math.max(0, -e.offsetX / e.scale), i = Math.max(0, -e.offsetY / e.scale), a = Math.min(n.width, (t.width - e.offsetX) / e.scale), o = Math.min(n.height, (t.height - e.offsetY) / e.scale);
|
|
6539
|
+
return a <= r || o <= i ? null : {
|
|
6540
|
+
x: r,
|
|
6541
|
+
y: i,
|
|
6542
|
+
width: a - r,
|
|
6543
|
+
height: o - i
|
|
6544
|
+
};
|
|
6545
|
+
}
|
|
6546
|
+
function di({ visible: e, image: t, natural: n, density: r }) {
|
|
6547
|
+
let i = n.width / t.width, a = n.height / t.height, o = Math.max(0, Math.floor(e.x * i)), s = Math.max(0, Math.floor(e.y * a)), c = Math.min(n.width, Math.ceil((e.x + e.width) * i)) - o, l = Math.min(n.height, Math.ceil((e.y + e.height) * a)) - s, u = {
|
|
6548
|
+
x: o / i,
|
|
6549
|
+
y: s / a,
|
|
6550
|
+
width: c / i,
|
|
6551
|
+
height: l / a
|
|
6552
|
+
};
|
|
6553
|
+
return {
|
|
6554
|
+
source: {
|
|
6555
|
+
x: o,
|
|
6556
|
+
y: s,
|
|
6557
|
+
width: c,
|
|
6558
|
+
height: l
|
|
6559
|
+
},
|
|
6560
|
+
rect: u,
|
|
6561
|
+
outputWidth: Math.max(1, Math.min(c, Math.ceil(u.width * r))),
|
|
6562
|
+
outputHeight: Math.max(1, Math.min(l, Math.ceil(u.height * r)))
|
|
6563
|
+
};
|
|
6564
|
+
}
|
|
6565
|
+
function fi(e, t, n) {
|
|
6566
|
+
let r = 1e-6;
|
|
6567
|
+
if (!(e.rect.x <= t.x + r && e.rect.y <= t.y + r && e.rect.x + e.rect.width >= t.x + t.width - r && e.rect.y + e.rect.height >= t.y + t.height - r)) return !1;
|
|
6568
|
+
let i = Math.min(n.density, n.natural.width / n.image.width), a = Math.min(n.density, n.natural.height / n.image.height);
|
|
6569
|
+
return e.outputWidth / e.rect.width >= i * .99 && e.outputHeight / e.rect.height >= a * .99;
|
|
6570
|
+
}
|
|
6571
|
+
//#endregion
|
|
6480
6572
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
6481
|
-
function
|
|
6573
|
+
function pi(e, t, n) {
|
|
6482
6574
|
if (t.length !== 0) {
|
|
6483
6575
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
6484
6576
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
6485
6577
|
n && e.closePath();
|
|
6486
6578
|
}
|
|
6487
6579
|
}
|
|
6488
|
-
function
|
|
6580
|
+
function mi(e, t, n, r) {
|
|
6489
6581
|
if (t.interaction?.visible === !1) return;
|
|
6490
6582
|
let i = at(t, {
|
|
6491
6583
|
strokeWidth: r,
|
|
@@ -6502,11 +6594,53 @@ function ii(e, t, n, r) {
|
|
|
6502
6594
|
let i = Math.min(n.x, r.x), a = Math.min(n.y, r.y), o = Math.abs(r.x - n.x), s = Math.abs(r.y - n.y);
|
|
6503
6595
|
e.beginPath(), t.type === R.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
6504
6596
|
}
|
|
6505
|
-
} else
|
|
6597
|
+
} else pi(e, t.points, t.type !== R.LINE);
|
|
6506
6598
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill("evenodd"), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
|
|
6507
6599
|
}
|
|
6508
|
-
function
|
|
6509
|
-
let
|
|
6600
|
+
async function hi(e, t, n) {
|
|
6601
|
+
let r = await rr(e);
|
|
6602
|
+
if (!r) return null;
|
|
6603
|
+
try {
|
|
6604
|
+
let i = {
|
|
6605
|
+
width: r.width,
|
|
6606
|
+
height: r.height
|
|
6607
|
+
}, a = {
|
|
6608
|
+
url: e,
|
|
6609
|
+
smoothing: t,
|
|
6610
|
+
natural: i,
|
|
6611
|
+
bitmap: null,
|
|
6612
|
+
rect: {
|
|
6613
|
+
x: 0,
|
|
6614
|
+
y: 0,
|
|
6615
|
+
width: 0,
|
|
6616
|
+
height: 0
|
|
6617
|
+
},
|
|
6618
|
+
outputWidth: 0,
|
|
6619
|
+
outputHeight: 0
|
|
6620
|
+
}, o = n(i);
|
|
6621
|
+
if (!o?.visibleRect) return a;
|
|
6622
|
+
let s = di({
|
|
6623
|
+
visible: o.visibleRect,
|
|
6624
|
+
natural: i,
|
|
6625
|
+
...o
|
|
6626
|
+
}), c = await createImageBitmap(r.source, s.source.x, s.source.y, s.source.width, s.source.height, {
|
|
6627
|
+
resizeWidth: s.outputWidth,
|
|
6628
|
+
resizeHeight: s.outputHeight,
|
|
6629
|
+
resizeQuality: t ? "high" : "pixelated"
|
|
6630
|
+
});
|
|
6631
|
+
return {
|
|
6632
|
+
...a,
|
|
6633
|
+
...s,
|
|
6634
|
+
bitmap: c
|
|
6635
|
+
};
|
|
6636
|
+
} catch {
|
|
6637
|
+
return null;
|
|
6638
|
+
} finally {
|
|
6639
|
+
r.release();
|
|
6640
|
+
}
|
|
6641
|
+
}
|
|
6642
|
+
function gi({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, focusedShapeId: a, focusFit: o = "contain", zoomPadding: s = .3, strokeSize: c = 1, brightness: l = 1, contrast: u = 1, imageSmoothing: d = !0, lazy: f = !0, className: p, style: m, renderImageState: h }) {
|
|
6643
|
+
let g = j(null), _ = j(null), v = j(null), [y, b] = M(!f), [C, w] = M("loading"), [E, D] = M(null), [O, A] = M(0), [N, P] = M(0);
|
|
6510
6644
|
T(() => {
|
|
6511
6645
|
if (!f || y) return;
|
|
6512
6646
|
let e = g.current;
|
|
@@ -6520,29 +6654,72 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6520
6654
|
if (!e) return;
|
|
6521
6655
|
let t = new ResizeObserver(() => A((e) => e + 1));
|
|
6522
6656
|
return t.observe(e), () => t.disconnect();
|
|
6523
|
-
}, [])
|
|
6657
|
+
}, []);
|
|
6658
|
+
let F = k(() => r.find((e) => e.id === a), [a, r]);
|
|
6659
|
+
return T(() => {
|
|
6524
6660
|
if (!y || !e) {
|
|
6525
6661
|
w(e ? "loading" : "missing"), D(null);
|
|
6526
6662
|
return;
|
|
6527
6663
|
}
|
|
6528
|
-
let t =
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6664
|
+
let t = g.current;
|
|
6665
|
+
if (!t) return;
|
|
6666
|
+
let { width: r, height: i } = t.getBoundingClientRect();
|
|
6667
|
+
if (!r || !i) return;
|
|
6668
|
+
let a = {
|
|
6669
|
+
width: r,
|
|
6670
|
+
height: i
|
|
6671
|
+
}, c = (e) => {
|
|
6672
|
+
let t = n ?? e;
|
|
6673
|
+
if (!t.width || !t.height) return null;
|
|
6674
|
+
let r = li({
|
|
6675
|
+
viewport: a,
|
|
6676
|
+
image: t,
|
|
6677
|
+
focusPoints: F?.points,
|
|
6678
|
+
zoomPadding: s,
|
|
6679
|
+
focusFit: o
|
|
6680
|
+
});
|
|
6681
|
+
return {
|
|
6682
|
+
image: t,
|
|
6683
|
+
visibleRect: ui(r, a, t),
|
|
6684
|
+
density: r.scale * (window.devicePixelRatio || 1)
|
|
6685
|
+
};
|
|
6686
|
+
}, l = v.current;
|
|
6687
|
+
if (l?.url === e && l.smoothing === d) {
|
|
6688
|
+
let e = c(l.natural);
|
|
6689
|
+
if (!e?.visibleRect || l.bitmap && fi(l, e.visibleRect, {
|
|
6690
|
+
...e,
|
|
6691
|
+
natural: l.natural
|
|
6692
|
+
})) return;
|
|
6693
|
+
} else l?.url !== e && (w("loading"), D(null));
|
|
6694
|
+
let u = !0;
|
|
6695
|
+
return (async () => {
|
|
6696
|
+
let t = await sr(() => u ? hi(e, d, c) : Promise.resolve(void 0));
|
|
6697
|
+
if (!u) {
|
|
6698
|
+
t?.bitmap?.close();
|
|
6699
|
+
return;
|
|
6700
|
+
}
|
|
6701
|
+
if (t === null) {
|
|
6702
|
+
v.current?.bitmap?.close(), v.current = null, w("error");
|
|
6703
|
+
let t = await fr(e);
|
|
6704
|
+
u && D(t);
|
|
6533
6705
|
return;
|
|
6534
6706
|
}
|
|
6535
|
-
v.current =
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
}), () => {
|
|
6539
|
-
t = !1;
|
|
6707
|
+
t && (v.current?.bitmap?.close(), v.current = t, w("ready"), P((e) => e + 1));
|
|
6708
|
+
})(), () => {
|
|
6709
|
+
u = !1;
|
|
6540
6710
|
};
|
|
6541
|
-
}, [
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6711
|
+
}, [
|
|
6712
|
+
n,
|
|
6713
|
+
F,
|
|
6714
|
+
o,
|
|
6715
|
+
d,
|
|
6716
|
+
e,
|
|
6717
|
+
O,
|
|
6718
|
+
y,
|
|
6719
|
+
s
|
|
6720
|
+
]), T(() => () => {
|
|
6721
|
+
v.current?.bitmap?.close(), v.current = null;
|
|
6722
|
+
}, []), T(() => {
|
|
6546
6723
|
if (C === "error") {
|
|
6547
6724
|
let e = _.current;
|
|
6548
6725
|
e?.getContext("2d")?.clearRect(0, 0, e.width, e.height);
|
|
@@ -6556,41 +6733,54 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6556
6733
|
t.width = Math.max(1, Math.round(f * m)), t.height = Math.max(1, Math.round(p * m)), t.style.width = `${f}px`, t.style.height = `${p}px`;
|
|
6557
6734
|
let h = t.getContext("2d");
|
|
6558
6735
|
if (!h) return;
|
|
6559
|
-
let y = n?.width ?? a.
|
|
6736
|
+
let y = n?.width ?? a.natural.width, b = n?.height ?? a.natural.height;
|
|
6560
6737
|
if (!y || !b) return;
|
|
6561
|
-
let
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6738
|
+
let { scale: x, offsetX: S, offsetY: w } = li({
|
|
6739
|
+
viewport: {
|
|
6740
|
+
width: f,
|
|
6741
|
+
height: p
|
|
6742
|
+
},
|
|
6743
|
+
image: {
|
|
6744
|
+
width: y,
|
|
6745
|
+
height: b
|
|
6746
|
+
},
|
|
6747
|
+
focusPoints: F?.points,
|
|
6748
|
+
zoomPadding: s,
|
|
6749
|
+
focusFit: o
|
|
6750
|
+
});
|
|
6566
6751
|
h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, f, p), h.save(), h.translate(S, w), h.scale(x, x), h.imageSmoothingEnabled = d;
|
|
6567
6752
|
let T = We({
|
|
6568
6753
|
brightness: l,
|
|
6569
6754
|
contrast: u
|
|
6570
6755
|
});
|
|
6571
|
-
h.filter = `brightness(${T.brightness}) contrast(${T.contrast})`,
|
|
6756
|
+
if (h.filter = `brightness(${T.brightness}) contrast(${T.contrast})`, a.bitmap) {
|
|
6757
|
+
let { x: e, y: t, width: n, height: r } = a.rect;
|
|
6758
|
+
h.drawImage(a.bitmap, e, t, n, r);
|
|
6759
|
+
}
|
|
6760
|
+
h.filter = "none";
|
|
6572
6761
|
let E = i ? cn(i, y, b) : null;
|
|
6573
6762
|
if (E && (tn(h, E, y, b), E.outlineStyles)) {
|
|
6574
6763
|
let e = (e, t) => {
|
|
6575
6764
|
if (h.lineWidth = t.width / x, t.underlayColor) {
|
|
6576
6765
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
6577
|
-
for (let [t, n] of e)
|
|
6766
|
+
for (let [t, n] of e) pi(h, [t, n], !1), h.stroke();
|
|
6578
6767
|
}
|
|
6579
6768
|
h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / x)), h.strokeStyle = t.color;
|
|
6580
|
-
for (let [t, n] of e)
|
|
6769
|
+
for (let [t, n] of e) pi(h, [t, n], !1), h.stroke();
|
|
6581
6770
|
h.restore();
|
|
6582
6771
|
};
|
|
6583
6772
|
e(E.visibleOutline, E.outlineStyles.visible), e(E.occludedOutline, E.outlineStyles.occluded);
|
|
6584
6773
|
}
|
|
6585
|
-
for (let e of se(r))
|
|
6774
|
+
for (let e of se(r)) mi(h, e, x, c);
|
|
6586
6775
|
h.restore();
|
|
6587
6776
|
}, [
|
|
6588
6777
|
l,
|
|
6589
6778
|
u,
|
|
6590
6779
|
n,
|
|
6591
|
-
|
|
6780
|
+
F,
|
|
6592
6781
|
o,
|
|
6593
6782
|
d,
|
|
6783
|
+
N,
|
|
6594
6784
|
i,
|
|
6595
6785
|
r,
|
|
6596
6786
|
O,
|
|
@@ -6663,6 +6853,6 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6663
6853
|
});
|
|
6664
6854
|
}
|
|
6665
6855
|
//#endregion
|
|
6666
|
-
export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS, R as SHAPE_TYPE,
|
|
6856
|
+
export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS, R as SHAPE_TYPE, ci as ShapeEditor, ci as default, gi as ShapeViewer, q as TOOL, He as VIEW_SETTING_RANGES, We as clampViewSettings, ce as generateId };
|
|
6667
6857
|
|
|
6668
6858
|
//# sourceMappingURL=shape-editor.js.map
|