@mlightcad/common 1.2.4 → 1.2.6
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/common.js +678 -382
- package/dist/common.umd.cjs +1 -1
- package/lib/AcCmColor.d.ts +106 -132
- package/lib/AcCmColor.d.ts.map +1 -1
- package/lib/AcCmColor.js +356 -493
- package/lib/AcCmColor.js.map +1 -1
- package/lib/AcCmColorMethod.d.ts +17 -0
- package/lib/AcCmColorMethod.d.ts.map +1 -0
- package/lib/AcCmColorMethod.js +18 -0
- package/lib/AcCmColorMethod.js.map +1 -0
- package/lib/AcCmColorUtil.d.ts +45 -12
- package/lib/AcCmColorUtil.d.ts.map +1 -1
- package/lib/AcCmColorUtil.js +254 -15
- package/lib/AcCmColorUtil.js.map +1 -1
- package/lib/AcCmEntityColor.d.ts +119 -0
- package/lib/AcCmEntityColor.d.ts.map +1 -0
- package/lib/AcCmEntityColor.js +198 -0
- package/lib/AcCmEntityColor.js.map +1 -0
- package/lib/AcCmLodashUtils.d.ts +6 -0
- package/lib/AcCmLodashUtils.d.ts.map +1 -1
- package/lib/AcCmLodashUtils.js +31 -0
- package/lib/AcCmLodashUtils.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/dist/common.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(r, e) {
|
|
2
2
|
for (var t = 0; t < e.length; t++) {
|
|
3
|
-
const
|
|
4
|
-
if (typeof
|
|
5
|
-
for (const
|
|
6
|
-
if (
|
|
7
|
-
const i = Object.getOwnPropertyDescriptor(
|
|
8
|
-
i && Object.defineProperty(
|
|
3
|
+
const s = e[t];
|
|
4
|
+
if (typeof s != "string" && !Array.isArray(s)) {
|
|
5
|
+
for (const n in s)
|
|
6
|
+
if (n !== "default" && !(n in r)) {
|
|
7
|
+
const i = Object.getOwnPropertyDescriptor(s, n);
|
|
8
|
+
i && Object.defineProperty(r, n, i.get ? i : {
|
|
9
9
|
enumerable: !0,
|
|
10
|
-
get: () =>
|
|
10
|
+
get: () => s[n]
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
return Object.freeze(Object.defineProperty(
|
|
15
|
+
return Object.freeze(Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }));
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
var o = /* @__PURE__ */ ((r) => (r[r.ByColor = 1] = "ByColor", r[r.ByACI = 2] = "ByACI", r[r.ByLayer = 3] = "ByLayer", r[r.ByBlock = 4] = "ByBlock", r[r.None = 0] = "None", r))(o || {});
|
|
18
|
+
const S = {
|
|
18
19
|
aliceblue: 15792383,
|
|
19
20
|
antiquewhite: 16444375,
|
|
20
21
|
aqua: 65535,
|
|
@@ -159,7 +160,7 @@ const I = {
|
|
|
159
160
|
whitesmoke: 16119285,
|
|
160
161
|
yellow: 16776960,
|
|
161
162
|
yellowgreen: 10145074
|
|
162
|
-
},
|
|
163
|
+
}, x = [
|
|
163
164
|
0,
|
|
164
165
|
16711680,
|
|
165
166
|
16776960,
|
|
@@ -418,266 +419,543 @@ const I = {
|
|
|
418
419
|
16777215,
|
|
419
420
|
0
|
|
420
421
|
];
|
|
421
|
-
|
|
422
|
-
return Math.max(e, Math.min(t, n));
|
|
423
|
-
}
|
|
424
|
-
const C = class C {
|
|
422
|
+
class B {
|
|
425
423
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
424
|
+
* Returns the RGB color value for a given AutoCAD color index.
|
|
425
|
+
*
|
|
426
|
+
* @param {number} index - The AutoCAD color index value (0-255).
|
|
427
|
+
* @returns {number} The RGB color value as a 24-bit integer.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* // Get the RGB value for color index 1 (red)
|
|
432
|
+
* const redColor = AcCmColorUtil.getAcadColor(1); // returns 16711680 (0xFF0000)
|
|
433
|
+
* ```
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```typescript
|
|
437
|
+
* // Get special inheritance colors
|
|
438
|
+
* const byBlock = AcCmColorUtil.getAcadColor(0); // "ByBlock" color
|
|
439
|
+
* const byLayer = AcCmColorUtil.getAcadColor(256); // "ByLayer" color
|
|
440
|
+
* ```
|
|
428
441
|
*/
|
|
429
|
-
|
|
430
|
-
|
|
442
|
+
static getColorByIndex(e) {
|
|
443
|
+
return x[e];
|
|
431
444
|
}
|
|
432
445
|
/**
|
|
433
|
-
*
|
|
446
|
+
* Finds the AutoCAD color index associated with a given RGB value.
|
|
434
447
|
*
|
|
435
|
-
* @
|
|
448
|
+
* @private
|
|
449
|
+
* @param {number} color - The RGB value to find an index for.
|
|
450
|
+
* @returns {number | undefined} The color index if found, undefined otherwise.
|
|
436
451
|
*/
|
|
437
|
-
|
|
438
|
-
|
|
452
|
+
static getIndexByColor(e) {
|
|
453
|
+
const t = x.length - 1;
|
|
454
|
+
for (let s = 1; s < t; ++s)
|
|
455
|
+
if (x[s] === e)
|
|
456
|
+
return s;
|
|
439
457
|
}
|
|
440
458
|
/**
|
|
441
|
-
*
|
|
459
|
+
* Returns the RGB color value for a given CSS color name.
|
|
460
|
+
*
|
|
461
|
+
* @param {string} name - The CSS color name (e.g., "red", "blue", "aliceblue").
|
|
462
|
+
* @returns {number | undefined} The RGB color value as a 24-bit integer, or undefined if the name is not found.
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```typescript
|
|
466
|
+
* // Get the RGB value for a standard color name
|
|
467
|
+
* const redColor = AcCmColorUtil.getColorByName("red"); // returns 16711680 (0xFF0000)
|
|
468
|
+
* const blueColor = AcCmColorUtil.getColorByName("blue"); // returns 255 (0x0000FF)
|
|
469
|
+
* ```
|
|
442
470
|
*
|
|
443
|
-
* @
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* // Handle undefined for unknown color names
|
|
474
|
+
* const unknownColor = AcCmColorUtil.getColorByName("unknown"); // returns undefined
|
|
475
|
+
* ```
|
|
444
476
|
*/
|
|
445
|
-
|
|
446
|
-
|
|
477
|
+
static getColorByName(e) {
|
|
478
|
+
return S[e.toLowerCase()];
|
|
447
479
|
}
|
|
448
480
|
/**
|
|
449
|
-
*
|
|
481
|
+
* Finds the color name associated with a given RGB value.
|
|
450
482
|
*
|
|
451
|
-
* @
|
|
483
|
+
* @param {number} rgb - The RGB value to find a name for.
|
|
484
|
+
* @returns {string | undefined} The color name if found, undefined otherwise.
|
|
452
485
|
*/
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
e = "0" + e;
|
|
458
|
-
return `0x${e}`;
|
|
459
|
-
}
|
|
460
|
-
return "";
|
|
486
|
+
static getNameByColor(e) {
|
|
487
|
+
for (const [t, s] of Object.entries(S))
|
|
488
|
+
if (s === e)
|
|
489
|
+
return t;
|
|
461
490
|
}
|
|
462
491
|
/**
|
|
463
|
-
*
|
|
492
|
+
* Finds the color name associated with a given color index.
|
|
464
493
|
*
|
|
465
|
-
* @
|
|
494
|
+
* @param {number} index - The color index to find a name for.
|
|
495
|
+
* @returns {string | undefined} The color name if found, undefined otherwise.
|
|
466
496
|
*/
|
|
467
|
-
|
|
468
|
-
|
|
497
|
+
static getNameByIndex(e) {
|
|
498
|
+
const t = this.getColorByIndex(e);
|
|
499
|
+
return this.getNameByColor(t);
|
|
469
500
|
}
|
|
501
|
+
}
|
|
502
|
+
class v {
|
|
470
503
|
/**
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* @
|
|
504
|
+
* Constructs a new AcCmColor.
|
|
505
|
+
* @param method Initial color method (defaults to `ByColor`)
|
|
506
|
+
* @param value Internal packed value
|
|
474
507
|
*/
|
|
475
|
-
|
|
476
|
-
|
|
508
|
+
constructor(e = o.ByLayer, t) {
|
|
509
|
+
this._colorMethod = e, this._colorMethod == o.ByColor && t == null ? this._value = 16777215 : this._colorMethod == o.ByACI ? t == null ? this._value = 8 : t === 0 ? this._colorMethod = o.ByBlock : t === 256 ? this._colorMethod = o.ByLayer : this._value = Math.max(0, Math.min(t, 256)) : this._value = t;
|
|
510
|
+
}
|
|
511
|
+
// ---------------------------------------------------------------------
|
|
512
|
+
// Color method
|
|
513
|
+
// ---------------------------------------------------------------------
|
|
514
|
+
/** Gets the current color method. */
|
|
515
|
+
get colorMethod() {
|
|
516
|
+
return this._colorMethod;
|
|
477
517
|
}
|
|
478
518
|
/**
|
|
479
|
-
*
|
|
519
|
+
* Sets the color method.
|
|
480
520
|
*
|
|
481
|
-
*
|
|
521
|
+
* Note: Changing the method does not modify `_value`.
|
|
482
522
|
*/
|
|
523
|
+
set colorMethod(e) {
|
|
524
|
+
this._colorMethod = e;
|
|
525
|
+
}
|
|
526
|
+
// ---------------------------------------------------------------------
|
|
527
|
+
// RGB accessors (ByColor)
|
|
528
|
+
// ---------------------------------------------------------------------
|
|
529
|
+
/** Gets the red component (0–255). */
|
|
530
|
+
get red() {
|
|
531
|
+
const e = this.RGB;
|
|
532
|
+
return e != null ? e >> 16 & 255 : void 0;
|
|
533
|
+
}
|
|
534
|
+
/** Gets the green component (0–255). */
|
|
483
535
|
get green() {
|
|
484
|
-
|
|
536
|
+
const e = this.RGB;
|
|
537
|
+
return e != null ? e >> 8 & 255 : void 0;
|
|
538
|
+
}
|
|
539
|
+
/** Gets the blue component (0–255). */
|
|
540
|
+
get blue() {
|
|
541
|
+
const e = this.RGB;
|
|
542
|
+
return e != null ? e & 255 : void 0;
|
|
485
543
|
}
|
|
486
544
|
/**
|
|
487
|
-
* Gets the
|
|
545
|
+
* Gets the packed RGB value (0xRRGGBB).
|
|
488
546
|
*
|
|
489
|
-
*
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
547
|
+
* - For `ByColor`, returns `_value` directly
|
|
548
|
+
* - For `ByACI`, converts index to RGB via `AcCmColorUtil`
|
|
549
|
+
* - For `ByLayer` or `ByBlock`, returns `_value` directly
|
|
550
|
+
*/
|
|
551
|
+
get RGB() {
|
|
552
|
+
switch (this._colorMethod) {
|
|
553
|
+
case o.ByColor:
|
|
554
|
+
case o.ByBlock:
|
|
555
|
+
case o.ByLayer:
|
|
556
|
+
return this._value;
|
|
557
|
+
case o.ByACI:
|
|
558
|
+
return this._value ? B.getColorByIndex(this._value) : this._value;
|
|
559
|
+
default:
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
493
562
|
}
|
|
494
563
|
/**
|
|
495
|
-
*
|
|
496
|
-
* 0 and 256 are special values.
|
|
564
|
+
* Sets the RGB color.
|
|
497
565
|
*
|
|
498
|
-
* @
|
|
566
|
+
* @param r Red component (0–255)
|
|
567
|
+
* @param g Green component (0–255)
|
|
568
|
+
* @param b Blue component (0–255)
|
|
569
|
+
* @returns The current instance for chaining
|
|
499
570
|
*/
|
|
500
|
-
|
|
501
|
-
|
|
571
|
+
setRGB(e, t, s) {
|
|
572
|
+
const n = Math.max(0, Math.min(255, Math.round(e))), i = Math.max(0, Math.min(255, Math.round(t))), a = Math.max(0, Math.min(255, Math.round(s)));
|
|
573
|
+
return this._value = n << 16 | i << 8 | a, this._colorMethod = o.ByColor, this;
|
|
502
574
|
}
|
|
503
575
|
/**
|
|
504
|
-
* Sets the
|
|
505
|
-
* 256 is set, 256 will be used.
|
|
506
|
-
* - 0 indicates that the entity uses the color of the BlockReference that's displaying it. If the entity
|
|
507
|
-
* is not displayed through a block reference (for example, it is directly owned by the model space
|
|
508
|
-
* block table record) and its color is 0, then it will display as though its color were 7.
|
|
509
|
-
* - 256 indicates that the entity uses the color specified in the layer table record it references.
|
|
576
|
+
* Sets the RGB color by a single packed number (0xRRGGBB).
|
|
510
577
|
*
|
|
511
|
-
* @param
|
|
578
|
+
* @param value Packed RGB number
|
|
512
579
|
*/
|
|
513
|
-
|
|
514
|
-
e == null
|
|
580
|
+
setRGBValue(e) {
|
|
581
|
+
return e == null || !Number.isFinite(e) ? (console.warn("Invalid RGB value:", e), this) : (this._value = e & 16777215, this._colorMethod = o.ByColor, this);
|
|
515
582
|
}
|
|
516
583
|
/**
|
|
517
|
-
*
|
|
584
|
+
* Sets the RGB color from a CSS color string.
|
|
518
585
|
*
|
|
519
|
-
*
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
586
|
+
* Examples:
|
|
587
|
+
* - "#FF00FF"
|
|
588
|
+
* - "#F0F"
|
|
589
|
+
* - "rgb(255,0,255)"
|
|
590
|
+
* - "rgba(255,0,255,0.5)"
|
|
591
|
+
* - "red" (named colors)
|
|
592
|
+
*
|
|
593
|
+
* @param cssString CSS color string
|
|
594
|
+
* @returns The current instance for chaining
|
|
595
|
+
*/
|
|
596
|
+
setRGBFromCss(e) {
|
|
597
|
+
if (!e) return this;
|
|
598
|
+
const t = e.trim().toLowerCase();
|
|
599
|
+
if (t.startsWith("#")) {
|
|
600
|
+
let i = 0, a = 0, c = 0;
|
|
601
|
+
if (t.length === 7)
|
|
602
|
+
i = parseInt(t.substr(1, 2), 16), a = parseInt(t.substr(3, 2), 16), c = parseInt(t.substr(5, 2), 16);
|
|
603
|
+
else if (t.length === 4)
|
|
604
|
+
i = parseInt(t[1] + t[1], 16), a = parseInt(t[2] + t[2], 16), c = parseInt(t[3] + t[3], 16);
|
|
605
|
+
else
|
|
606
|
+
return console.warn("Invalid hex color:", e), this;
|
|
607
|
+
return this.setRGB(i, a, c);
|
|
608
|
+
}
|
|
609
|
+
const s = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
610
|
+
if (s) {
|
|
611
|
+
const i = parseInt(s[1], 10), a = parseInt(s[2], 10), c = parseInt(s[3], 10);
|
|
612
|
+
return this.setRGB(i, a, c);
|
|
613
|
+
}
|
|
614
|
+
const n = B.getColorByName(e);
|
|
615
|
+
return n !== void 0 ? this.setRGBValue(n) : (console.warn("Unknown CSS color string:", e), this);
|
|
523
616
|
}
|
|
524
617
|
/**
|
|
525
|
-
* Sets the color
|
|
618
|
+
* Sets the color as a scalar grayscale value.
|
|
526
619
|
*
|
|
527
|
-
* @param
|
|
620
|
+
* @param scalar Scalar value (0–255)
|
|
621
|
+
* @returns The current instance for chaining
|
|
528
622
|
*/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const t = I[e.toLowerCase()];
|
|
532
|
-
t !== void 0 ? (this._colorName = e, this._color = t, this._colorIndex = this.getColorIndexByValue(this._color)) : console.warn("Unknown color: " + e);
|
|
533
|
-
} else
|
|
534
|
-
this._colorName = null;
|
|
623
|
+
setScalar(e) {
|
|
624
|
+
return this.setRGB(e, e, e);
|
|
535
625
|
}
|
|
536
626
|
/**
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
* @returns {boolean} True if the color has no name, false otherwise.
|
|
627
|
+
* Gets the hexadecimal representation of the color (e.g., "0xFF00FF").
|
|
540
628
|
*/
|
|
541
|
-
get
|
|
542
|
-
|
|
629
|
+
get hexColor() {
|
|
630
|
+
const e = this.RGB;
|
|
631
|
+
return e == null ? void 0 : "0x" + e.toString(16).padStart(6, "0").toUpperCase();
|
|
543
632
|
}
|
|
544
633
|
/**
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* @returns {boolean} True if the color has no index, false otherwise.
|
|
634
|
+
* Gets the CSS RGB color string (e.g., "rgb(255,0,255)").
|
|
548
635
|
*/
|
|
549
|
-
get
|
|
550
|
-
|
|
636
|
+
get cssColor() {
|
|
637
|
+
const e = this.RGB;
|
|
638
|
+
if (e != null)
|
|
639
|
+
return `rgb(${e >> 16 & 255},${e >> 8 & 255},${e & 255})`;
|
|
640
|
+
}
|
|
641
|
+
// ---------------------------------------------------------------------
|
|
642
|
+
// ACI accessors (ByACI)
|
|
643
|
+
// ---------------------------------------------------------------------
|
|
644
|
+
/** Gets the AutoCAD Color Index (ACI), or undefined if not ByACI, ByBlock, or ByLayer. */
|
|
645
|
+
get colorIndex() {
|
|
646
|
+
return this._colorMethod === o.ByACI ? this._value : this._colorMethod === o.ByLayer ? 256 : this._colorMethod === o.ByBlock ? 0 : void 0;
|
|
551
647
|
}
|
|
552
648
|
/**
|
|
553
|
-
*
|
|
649
|
+
* Sets the AutoCAD Color Index (0–256).
|
|
650
|
+
*
|
|
651
|
+
* - 0 sets the color method to `ByBlock`
|
|
652
|
+
* - 256 sets the color method to `ByLayer`
|
|
653
|
+
* - 1–255 sets the color method to `ByACI`
|
|
554
654
|
*
|
|
555
|
-
* @
|
|
655
|
+
* @param index ACI index
|
|
556
656
|
*/
|
|
557
|
-
|
|
558
|
-
|
|
657
|
+
set colorIndex(e) {
|
|
658
|
+
if (e == null) return;
|
|
659
|
+
const t = Math.max(0, Math.min(256, Math.round(e)));
|
|
660
|
+
t === 0 ? (this._colorMethod = o.ByBlock, this._value = void 0) : t === 256 ? (this._colorMethod = o.ByLayer, this._value = void 0) : (this._colorMethod = o.ByACI, this._value = t);
|
|
559
661
|
}
|
|
560
662
|
/**
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
* @returns {AcCmColor} The current instance.
|
|
663
|
+
* Returns true if the color method is ByColor (explicit RGB).
|
|
564
664
|
*/
|
|
565
|
-
|
|
566
|
-
return this.
|
|
665
|
+
get isByColor() {
|
|
666
|
+
return this._colorMethod === o.ByColor;
|
|
567
667
|
}
|
|
568
668
|
/**
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
* @returns {boolean} True if the color is "ByBlock", false otherwise.
|
|
669
|
+
* Returns true if the color method is ByACI.
|
|
572
670
|
*/
|
|
573
|
-
get
|
|
574
|
-
return this.
|
|
671
|
+
get isByACI() {
|
|
672
|
+
return this._colorMethod === o.ByACI;
|
|
673
|
+
}
|
|
674
|
+
// ---------------------------------------------------------------------
|
|
675
|
+
// Layer / Block helpers
|
|
676
|
+
// ---------------------------------------------------------------------
|
|
677
|
+
/** Returns true if the color method is ByLayer. */
|
|
678
|
+
get isByLayer() {
|
|
679
|
+
return this._colorMethod === o.ByLayer;
|
|
575
680
|
}
|
|
576
681
|
/**
|
|
577
|
-
* Sets the color to
|
|
578
|
-
*
|
|
579
|
-
* @returns {AcCmColor} The current instance.
|
|
682
|
+
* Sets the color to ByLayer.
|
|
683
|
+
* @param value - Option layer color value
|
|
580
684
|
*/
|
|
581
|
-
|
|
582
|
-
return this.
|
|
685
|
+
setByLayer(e) {
|
|
686
|
+
return this._colorMethod = o.ByLayer, e == null ? this._value = 256 : this._value = e, this;
|
|
687
|
+
}
|
|
688
|
+
/** Returns true if the color method is ByBlock. */
|
|
689
|
+
get isByBlock() {
|
|
690
|
+
return this._colorMethod === o.ByBlock;
|
|
583
691
|
}
|
|
584
692
|
/**
|
|
585
|
-
* Sets the color
|
|
586
|
-
*
|
|
587
|
-
* @param {number} scalar - The scalar value (0-255).
|
|
588
|
-
* @returns {AcCmColor} The current instance.
|
|
693
|
+
* Sets the color to ByBlock.
|
|
694
|
+
* @param value - Option layer color value
|
|
589
695
|
*/
|
|
590
|
-
|
|
591
|
-
return this.
|
|
696
|
+
setByBlock(e) {
|
|
697
|
+
return this._colorMethod = o.ByBlock, e == null ? this._value = 0 : this._value = e, this;
|
|
592
698
|
}
|
|
699
|
+
// ---------------------------------------------------------------------
|
|
700
|
+
// Color name (dynamic)
|
|
701
|
+
// ---------------------------------------------------------------------
|
|
593
702
|
/**
|
|
594
|
-
*
|
|
703
|
+
* Gets the color name.
|
|
595
704
|
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
* @param {number} b - The blue component (0-255).
|
|
599
|
-
* @returns {AcCmColor} The current instance.
|
|
705
|
+
* For `ByColor` or `ByACI`, resolves the name via `AcCmColorUtil`.
|
|
706
|
+
* For `ByLayer` or `ByBlock`, returns the corresponding string.
|
|
600
707
|
*/
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
708
|
+
get colorName() {
|
|
709
|
+
switch (this._colorMethod) {
|
|
710
|
+
case o.ByLayer:
|
|
711
|
+
return "ByLayer";
|
|
712
|
+
case o.ByBlock:
|
|
713
|
+
return "ByBlock";
|
|
714
|
+
case o.ByColor:
|
|
715
|
+
return this._value ? B.getNameByColor(this._value) : "";
|
|
716
|
+
case o.ByACI:
|
|
717
|
+
return this._value ? B.getNameByIndex(this._value) : "";
|
|
718
|
+
default:
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
604
721
|
}
|
|
605
722
|
/**
|
|
606
723
|
* Sets the color by name.
|
|
607
724
|
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
725
|
+
* Resolves the name to an RGB value via `AcCmColorUtil`.
|
|
726
|
+
*
|
|
727
|
+
* @param name Color name
|
|
610
728
|
*/
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
729
|
+
set colorName(e) {
|
|
730
|
+
if (!e) return;
|
|
731
|
+
const t = B.getColorByName(e);
|
|
732
|
+
t !== void 0 ? (this._value = t, this._colorMethod = o.ByColor) : console.warn("Unknown color name:", e);
|
|
614
733
|
}
|
|
734
|
+
// ---------------------------------------------------------------------
|
|
735
|
+
// Clone / Copy / Equals
|
|
736
|
+
// ---------------------------------------------------------------------
|
|
615
737
|
/**
|
|
616
|
-
*
|
|
738
|
+
* Creates a clone of this color instance.
|
|
617
739
|
*
|
|
618
|
-
* @returns
|
|
740
|
+
* @returns A new AcCmColor instance with the same method and value
|
|
619
741
|
*/
|
|
620
742
|
clone() {
|
|
621
|
-
const e = new
|
|
622
|
-
return e.
|
|
743
|
+
const e = new v();
|
|
744
|
+
return e._colorMethod = this._colorMethod, e._value = this._value, e;
|
|
623
745
|
}
|
|
624
746
|
/**
|
|
625
|
-
* Copies
|
|
747
|
+
* Copies color values from another AcCmColor instance.
|
|
626
748
|
*
|
|
627
|
-
* @param
|
|
628
|
-
* @returns
|
|
749
|
+
* @param other The source color
|
|
750
|
+
* @returns The current instance
|
|
629
751
|
*/
|
|
630
752
|
copy(e) {
|
|
631
|
-
return this.
|
|
753
|
+
return this._colorMethod = e._colorMethod, this._value = e._value, this;
|
|
632
754
|
}
|
|
633
755
|
/**
|
|
634
|
-
* Checks
|
|
756
|
+
* Checks equality with another color.
|
|
635
757
|
*
|
|
636
|
-
* @param
|
|
637
|
-
* @returns
|
|
758
|
+
* @param other The color to compare
|
|
759
|
+
* @returns True if color method and value are identical
|
|
638
760
|
*/
|
|
639
761
|
equals(e) {
|
|
640
|
-
return
|
|
762
|
+
return this._colorMethod === e._colorMethod && this._value === e._value;
|
|
641
763
|
}
|
|
764
|
+
// ---------------------------------------------------------------------
|
|
765
|
+
// String representation
|
|
766
|
+
// ---------------------------------------------------------------------
|
|
642
767
|
/**
|
|
643
768
|
* Returns a string representation of the color.
|
|
644
769
|
*
|
|
645
|
-
*
|
|
770
|
+
* - "ByLayer" for ByLayer colors
|
|
771
|
+
* - "ByBlock" for ByBlock colors
|
|
772
|
+
* - One number for color index
|
|
773
|
+
* - Three comma-separated numbers for RGB color
|
|
646
774
|
*/
|
|
647
775
|
toString() {
|
|
648
|
-
|
|
776
|
+
switch (this._colorMethod) {
|
|
777
|
+
case o.ByLayer:
|
|
778
|
+
return "ByLayer";
|
|
779
|
+
case o.ByBlock:
|
|
780
|
+
return "ByBlock";
|
|
781
|
+
case o.ByACI:
|
|
782
|
+
return this._value !== void 0 ? String(this._value) : "";
|
|
783
|
+
case o.ByColor:
|
|
784
|
+
return this._value ? `${this.red},${this.green},${this.blue}` : "";
|
|
785
|
+
default:
|
|
786
|
+
return "";
|
|
787
|
+
}
|
|
649
788
|
}
|
|
650
789
|
/**
|
|
651
|
-
*
|
|
790
|
+
* Creates one AcCmColor from one string
|
|
791
|
+
*/
|
|
792
|
+
static fromString(e) {
|
|
793
|
+
if (!e) return;
|
|
794
|
+
const t = e.trim();
|
|
795
|
+
if (/^bylayer$/i.test(t))
|
|
796
|
+
return new v(o.ByLayer);
|
|
797
|
+
if (/^byblock$/i.test(t))
|
|
798
|
+
return new v(o.ByBlock);
|
|
799
|
+
if (/^\d{1,3},\d{1,3},\d{1,3}$/i.test(t)) {
|
|
800
|
+
const [n, i, a] = t.split(",").map(Number), c = new v(o.ByColor);
|
|
801
|
+
return c.setRGB(n, i, a), c;
|
|
802
|
+
}
|
|
803
|
+
if (/^\d+$/.test(t)) {
|
|
804
|
+
const n = parseInt(t, 10);
|
|
805
|
+
return new v(o.ByACI, n);
|
|
806
|
+
}
|
|
807
|
+
const s = B.getColorByName(t);
|
|
808
|
+
if (s != null)
|
|
809
|
+
return new v(o.ByColor, s);
|
|
810
|
+
console.warn("Unknown color name:", e);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
class re {
|
|
814
|
+
/**
|
|
815
|
+
* Constructs a new `AcCmEntityColor`.
|
|
652
816
|
*
|
|
653
|
-
* @
|
|
654
|
-
* @param
|
|
655
|
-
* @returns {string | null} The color name if found, null otherwise.
|
|
817
|
+
* @param method Initial color method (defaults to `ByColor`)
|
|
818
|
+
* @param value Internal packed value (defaults to `0`)
|
|
656
819
|
*/
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
if (r === e)
|
|
660
|
-
return t;
|
|
661
|
-
return null;
|
|
820
|
+
constructor(e = o.ByColor, t = 0) {
|
|
821
|
+
this._colorMethod = e, this._value = t;
|
|
662
822
|
}
|
|
663
823
|
/**
|
|
664
|
-
*
|
|
824
|
+
* Gets the method used to determine the final color.
|
|
825
|
+
*/
|
|
826
|
+
get colorMethd() {
|
|
827
|
+
return this._colorMethod;
|
|
828
|
+
}
|
|
829
|
+
// ---------------------------------------------------------------------
|
|
830
|
+
// RGB accessors
|
|
831
|
+
// ---------------------------------------------------------------------
|
|
832
|
+
/**
|
|
833
|
+
* Gets the red component (0–255). Only valid when colorMethod = ByColor.
|
|
834
|
+
*/
|
|
835
|
+
get red() {
|
|
836
|
+
return this._value >> 16 & 255;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Sets the red component and updates the packed RGB value.
|
|
840
|
+
*/
|
|
841
|
+
set red(e) {
|
|
842
|
+
this._colorMethod = o.ByColor, this._value = this._value & 65535 | (e & 255) << 16;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Gets the green component (0–255). Only valid when colorMethod = ByColor.
|
|
846
|
+
*/
|
|
847
|
+
get green() {
|
|
848
|
+
return this._value >> 8 & 255;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Sets the green component and updates the packed RGB value.
|
|
852
|
+
*/
|
|
853
|
+
set green(e) {
|
|
854
|
+
this._colorMethod = o.ByColor, this._value = this._value & 16711935 | (e & 255) << 8;
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Gets the blue component (0–255). Only valid when colorMethod = ByColor.
|
|
858
|
+
*/
|
|
859
|
+
get blue() {
|
|
860
|
+
return this._value & 255;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Sets the blue component and updates the packed RGB value.
|
|
864
|
+
*/
|
|
865
|
+
set blue(e) {
|
|
866
|
+
this._colorMethod = o.ByColor, this._value = this._value & 16776960 | e & 255;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Sets all RGB components.
|
|
665
870
|
*
|
|
666
|
-
* @
|
|
667
|
-
* @param
|
|
668
|
-
* @
|
|
669
|
-
*/
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
871
|
+
* @param r Red (0–255)
|
|
872
|
+
* @param g Green (0–255)
|
|
873
|
+
* @param b Blue (0–255)
|
|
874
|
+
*/
|
|
875
|
+
setRGB(e, t, s) {
|
|
876
|
+
this._colorMethod = o.ByColor, this._value = (e & 255) << 16 | (t & 255) << 8 | s & 255;
|
|
877
|
+
}
|
|
878
|
+
// ---------------------------------------------------------------------
|
|
879
|
+
// ACI accessors
|
|
880
|
+
// ---------------------------------------------------------------------
|
|
881
|
+
/**
|
|
882
|
+
* Gets the AutoCAD Color Index (ACI). Only valid when colorMethod = ByACI.
|
|
883
|
+
*/
|
|
884
|
+
get colorIndex() {
|
|
885
|
+
return this._value;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Sets the AutoCAD Color Index (ACI).
|
|
889
|
+
*/
|
|
890
|
+
set colorIndex(e) {
|
|
891
|
+
this._colorMethod = o.ByACI, this._value = e;
|
|
892
|
+
}
|
|
893
|
+
// ---------------------------------------------------------------------
|
|
894
|
+
// Layer index accessors
|
|
895
|
+
// ---------------------------------------------------------------------
|
|
896
|
+
/**
|
|
897
|
+
* Gets the referenced layer index. Only valid when colorMethod = ByLayer.
|
|
898
|
+
*/
|
|
899
|
+
get layerIndex() {
|
|
900
|
+
return this._value;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Sets the layer index for ByLayer color mode.
|
|
904
|
+
*/
|
|
905
|
+
set layerIndex(e) {
|
|
906
|
+
this._colorMethod = o.ByLayer, this._value = e;
|
|
907
|
+
}
|
|
908
|
+
// ---------------------------------------------------------------------
|
|
909
|
+
// Utility methods
|
|
910
|
+
// ---------------------------------------------------------------------
|
|
911
|
+
/**
|
|
912
|
+
* Returns true if the color method is ByColor (explicit RGB).
|
|
913
|
+
*/
|
|
914
|
+
isByColor() {
|
|
915
|
+
return this._colorMethod === o.ByColor;
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Returns true if the color method is ByLayer.
|
|
919
|
+
*/
|
|
920
|
+
isByLayer() {
|
|
921
|
+
return this._colorMethod === o.ByLayer;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Returns true if the color method is ByBlock.
|
|
925
|
+
*/
|
|
926
|
+
isByBlock() {
|
|
927
|
+
return this._colorMethod === o.ByBlock;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Returns true if the color method is ByACI.
|
|
931
|
+
*/
|
|
932
|
+
isByACI() {
|
|
933
|
+
return this._colorMethod === o.ByACI;
|
|
676
934
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
935
|
+
/**
|
|
936
|
+
* Returns true if color is uninitialized or invalid.
|
|
937
|
+
*/
|
|
938
|
+
isNone() {
|
|
939
|
+
return this._colorMethod === o.None;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Gets the packed internal value.
|
|
943
|
+
*
|
|
944
|
+
* - RGB → packed 24-bit integer
|
|
945
|
+
* - ACI → index
|
|
946
|
+
* - Layer → index
|
|
947
|
+
*/
|
|
948
|
+
get rawValue() {
|
|
949
|
+
return this._value;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Sets a raw internal value. The meaning depends on `colorMethod`.
|
|
953
|
+
*/
|
|
954
|
+
set rawValue(e) {
|
|
955
|
+
this._value = e;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
const se = {
|
|
681
959
|
/**
|
|
682
960
|
* Throw error ILLEGAL_PARAMETERS when cannot instantiate from given parameter
|
|
683
961
|
*/
|
|
@@ -713,7 +991,7 @@ const te = {
|
|
|
713
991
|
return new Error("Not implemented yet");
|
|
714
992
|
}
|
|
715
993
|
};
|
|
716
|
-
class
|
|
994
|
+
class ne {
|
|
717
995
|
/**
|
|
718
996
|
* Creates {@link AcCmEventDispatcher} object.
|
|
719
997
|
*/
|
|
@@ -722,20 +1000,20 @@ class re {
|
|
|
722
1000
|
}
|
|
723
1001
|
addEventListener(e, t) {
|
|
724
1002
|
this._listeners === void 0 && (this._listeners = {});
|
|
725
|
-
const
|
|
726
|
-
|
|
1003
|
+
const s = this._listeners;
|
|
1004
|
+
s[e] === void 0 && (s[e] = []), s[e].indexOf(t) === -1 && s[e].push(t);
|
|
727
1005
|
}
|
|
728
1006
|
hasEventListener(e, t) {
|
|
729
1007
|
if (this._listeners === void 0) return !1;
|
|
730
|
-
const
|
|
731
|
-
return
|
|
1008
|
+
const s = this._listeners;
|
|
1009
|
+
return s[e] !== void 0 && s[e].indexOf(t) !== -1;
|
|
732
1010
|
}
|
|
733
1011
|
removeEventListener(e, t) {
|
|
734
1012
|
if (this._listeners === void 0) return;
|
|
735
|
-
const
|
|
736
|
-
if (
|
|
737
|
-
const i =
|
|
738
|
-
i !== -1 &&
|
|
1013
|
+
const n = this._listeners[e];
|
|
1014
|
+
if (n !== void 0) {
|
|
1015
|
+
const i = n.indexOf(t);
|
|
1016
|
+
i !== -1 && n.splice(i, 1);
|
|
739
1017
|
}
|
|
740
1018
|
}
|
|
741
1019
|
/**
|
|
@@ -744,12 +1022,12 @@ class re {
|
|
|
744
1022
|
*/
|
|
745
1023
|
dispatchEvent(e) {
|
|
746
1024
|
if (this._listeners === void 0) return;
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
1025
|
+
const s = this._listeners[e.type];
|
|
1026
|
+
if (s !== void 0) {
|
|
749
1027
|
e.target = this;
|
|
750
|
-
const
|
|
751
|
-
for (let i = 0,
|
|
752
|
-
|
|
1028
|
+
const n = s.slice(0);
|
|
1029
|
+
for (let i = 0, a = n.length; i < a; i++)
|
|
1030
|
+
n[i].call(this, e);
|
|
753
1031
|
}
|
|
754
1032
|
}
|
|
755
1033
|
}
|
|
@@ -783,223 +1061,237 @@ class U {
|
|
|
783
1061
|
* @param payload Input payload passed to listener
|
|
784
1062
|
*/
|
|
785
1063
|
dispatch(e, ...t) {
|
|
786
|
-
for (const
|
|
787
|
-
|
|
1064
|
+
for (const s of this.listeners)
|
|
1065
|
+
s.call(null, e, ...t);
|
|
788
1066
|
}
|
|
789
1067
|
}
|
|
790
1068
|
var K = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
791
|
-
function
|
|
792
|
-
return
|
|
1069
|
+
function W(r) {
|
|
1070
|
+
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
793
1071
|
}
|
|
794
|
-
var
|
|
795
|
-
(function(
|
|
1072
|
+
var D = { exports: {} };
|
|
1073
|
+
(function(r) {
|
|
796
1074
|
(function(e, t) {
|
|
797
|
-
|
|
1075
|
+
r.exports ? r.exports = t() : e.log = t();
|
|
798
1076
|
})(K, function() {
|
|
799
1077
|
var e = function() {
|
|
800
|
-
}, t = "undefined",
|
|
1078
|
+
}, t = "undefined", s = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), n = [
|
|
801
1079
|
"trace",
|
|
802
1080
|
"debug",
|
|
803
1081
|
"info",
|
|
804
1082
|
"warn",
|
|
805
1083
|
"error"
|
|
806
|
-
], i = {},
|
|
807
|
-
function
|
|
808
|
-
var
|
|
809
|
-
if (typeof
|
|
810
|
-
return
|
|
1084
|
+
], i = {}, a = null;
|
|
1085
|
+
function c(h, d) {
|
|
1086
|
+
var l = h[d];
|
|
1087
|
+
if (typeof l.bind == "function")
|
|
1088
|
+
return l.bind(h);
|
|
811
1089
|
try {
|
|
812
|
-
return Function.prototype.bind.call(
|
|
1090
|
+
return Function.prototype.bind.call(l, h);
|
|
813
1091
|
} catch {
|
|
814
1092
|
return function() {
|
|
815
|
-
return Function.prototype.apply.apply(
|
|
1093
|
+
return Function.prototype.apply.apply(l, [h, arguments]);
|
|
816
1094
|
};
|
|
817
1095
|
}
|
|
818
1096
|
}
|
|
819
|
-
function
|
|
1097
|
+
function M() {
|
|
820
1098
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
821
1099
|
}
|
|
822
|
-
function
|
|
823
|
-
return
|
|
1100
|
+
function _(h) {
|
|
1101
|
+
return h === "debug" && (h = "log"), typeof console === t ? !1 : h === "trace" && s ? M : console[h] !== void 0 ? c(console, h) : console.log !== void 0 ? c(console, "log") : e;
|
|
824
1102
|
}
|
|
825
1103
|
function p() {
|
|
826
|
-
for (var
|
|
827
|
-
var
|
|
828
|
-
this[
|
|
1104
|
+
for (var h = this.getLevel(), d = 0; d < n.length; d++) {
|
|
1105
|
+
var l = n[d];
|
|
1106
|
+
this[l] = d < h ? e : this.methodFactory(l, h, this.name);
|
|
829
1107
|
}
|
|
830
|
-
if (this.log = this.debug, typeof console === t &&
|
|
1108
|
+
if (this.log = this.debug, typeof console === t && h < this.levels.SILENT)
|
|
831
1109
|
return "No console available for logging";
|
|
832
1110
|
}
|
|
833
|
-
function
|
|
1111
|
+
function A(h) {
|
|
834
1112
|
return function() {
|
|
835
|
-
typeof console !== t && (p.call(this), this[
|
|
1113
|
+
typeof console !== t && (p.call(this), this[h].apply(this, arguments));
|
|
836
1114
|
};
|
|
837
1115
|
}
|
|
838
|
-
function
|
|
839
|
-
return
|
|
1116
|
+
function f(h, d, l) {
|
|
1117
|
+
return _(h) || A.apply(this, arguments);
|
|
840
1118
|
}
|
|
841
|
-
function
|
|
842
|
-
var
|
|
843
|
-
typeof
|
|
844
|
-
function
|
|
845
|
-
var
|
|
846
|
-
if (!(typeof window === t || !
|
|
1119
|
+
function R(h, d) {
|
|
1120
|
+
var l = this, k, O, w, y = "loglevel";
|
|
1121
|
+
typeof h == "string" ? y += ":" + h : typeof h == "symbol" && (y = void 0);
|
|
1122
|
+
function j(u) {
|
|
1123
|
+
var g = (n[u] || "silent").toUpperCase();
|
|
1124
|
+
if (!(typeof window === t || !y)) {
|
|
847
1125
|
try {
|
|
848
|
-
window.localStorage[
|
|
1126
|
+
window.localStorage[y] = g;
|
|
849
1127
|
return;
|
|
850
1128
|
} catch {
|
|
851
1129
|
}
|
|
852
1130
|
try {
|
|
853
|
-
window.document.cookie = encodeURIComponent(
|
|
1131
|
+
window.document.cookie = encodeURIComponent(y) + "=" + g + ";";
|
|
854
1132
|
} catch {
|
|
855
1133
|
}
|
|
856
1134
|
}
|
|
857
1135
|
}
|
|
858
|
-
function
|
|
859
|
-
var
|
|
860
|
-
if (!(typeof window === t || !
|
|
1136
|
+
function T() {
|
|
1137
|
+
var u;
|
|
1138
|
+
if (!(typeof window === t || !y)) {
|
|
861
1139
|
try {
|
|
862
|
-
|
|
1140
|
+
u = window.localStorage[y];
|
|
863
1141
|
} catch {
|
|
864
1142
|
}
|
|
865
|
-
if (typeof
|
|
1143
|
+
if (typeof u === t)
|
|
866
1144
|
try {
|
|
867
|
-
var
|
|
868
|
-
|
|
869
|
-
|
|
1145
|
+
var g = window.document.cookie, I = encodeURIComponent(y), P = g.indexOf(I + "=");
|
|
1146
|
+
P !== -1 && (u = /^([^;]+)/.exec(
|
|
1147
|
+
g.slice(P + I.length + 1)
|
|
870
1148
|
)[1]);
|
|
871
1149
|
} catch {
|
|
872
1150
|
}
|
|
873
|
-
return
|
|
1151
|
+
return l.levels[u] === void 0 && (u = void 0), u;
|
|
874
1152
|
}
|
|
875
1153
|
}
|
|
876
|
-
function
|
|
877
|
-
if (!(typeof window === t || !
|
|
1154
|
+
function V() {
|
|
1155
|
+
if (!(typeof window === t || !y)) {
|
|
878
1156
|
try {
|
|
879
|
-
window.localStorage.removeItem(
|
|
1157
|
+
window.localStorage.removeItem(y);
|
|
880
1158
|
} catch {
|
|
881
1159
|
}
|
|
882
1160
|
try {
|
|
883
|
-
window.document.cookie = encodeURIComponent(
|
|
1161
|
+
window.document.cookie = encodeURIComponent(y) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
884
1162
|
} catch {
|
|
885
1163
|
}
|
|
886
1164
|
}
|
|
887
1165
|
}
|
|
888
|
-
function
|
|
889
|
-
var
|
|
890
|
-
if (typeof
|
|
891
|
-
return
|
|
892
|
-
throw new TypeError("log.setLevel() called with invalid level: " +
|
|
1166
|
+
function m(u) {
|
|
1167
|
+
var g = u;
|
|
1168
|
+
if (typeof g == "string" && l.levels[g.toUpperCase()] !== void 0 && (g = l.levels[g.toUpperCase()]), typeof g == "number" && g >= 0 && g <= l.levels.SILENT)
|
|
1169
|
+
return g;
|
|
1170
|
+
throw new TypeError("log.setLevel() called with invalid level: " + u);
|
|
893
1171
|
}
|
|
894
|
-
|
|
1172
|
+
l.name = h, l.levels = {
|
|
895
1173
|
TRACE: 0,
|
|
896
1174
|
DEBUG: 1,
|
|
897
1175
|
INFO: 2,
|
|
898
1176
|
WARN: 3,
|
|
899
1177
|
ERROR: 4,
|
|
900
1178
|
SILENT: 5
|
|
901
|
-
},
|
|
902
|
-
return
|
|
903
|
-
},
|
|
904
|
-
return
|
|
905
|
-
},
|
|
906
|
-
|
|
907
|
-
},
|
|
908
|
-
|
|
909
|
-
},
|
|
910
|
-
|
|
911
|
-
},
|
|
912
|
-
|
|
913
|
-
},
|
|
914
|
-
if (
|
|
915
|
-
for (var
|
|
916
|
-
i[
|
|
917
|
-
},
|
|
918
|
-
|
|
1179
|
+
}, l.methodFactory = d || f, l.getLevel = function() {
|
|
1180
|
+
return w ?? O ?? k;
|
|
1181
|
+
}, l.setLevel = function(u, g) {
|
|
1182
|
+
return w = m(u), g !== !1 && j(w), p.call(l);
|
|
1183
|
+
}, l.setDefaultLevel = function(u) {
|
|
1184
|
+
O = m(u), T() || l.setLevel(u, !1);
|
|
1185
|
+
}, l.resetLevel = function() {
|
|
1186
|
+
w = null, V(), p.call(l);
|
|
1187
|
+
}, l.enableAll = function(u) {
|
|
1188
|
+
l.setLevel(l.levels.TRACE, u);
|
|
1189
|
+
}, l.disableAll = function(u) {
|
|
1190
|
+
l.setLevel(l.levels.SILENT, u);
|
|
1191
|
+
}, l.rebuild = function() {
|
|
1192
|
+
if (a !== l && (k = m(a.getLevel())), p.call(l), a === l)
|
|
1193
|
+
for (var u in i)
|
|
1194
|
+
i[u].rebuild();
|
|
1195
|
+
}, k = m(
|
|
1196
|
+
a ? a.getLevel() : "WARN"
|
|
919
1197
|
);
|
|
920
|
-
var
|
|
921
|
-
|
|
1198
|
+
var N = T();
|
|
1199
|
+
N != null && (w = m(N)), p.call(l);
|
|
922
1200
|
}
|
|
923
|
-
|
|
924
|
-
if (typeof
|
|
1201
|
+
a = new R(), a.getLogger = function(d) {
|
|
1202
|
+
if (typeof d != "symbol" && typeof d != "string" || d === "")
|
|
925
1203
|
throw new TypeError("You must supply a name when creating a logger.");
|
|
926
|
-
var
|
|
927
|
-
return
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
)),
|
|
1204
|
+
var l = i[d];
|
|
1205
|
+
return l || (l = i[d] = new R(
|
|
1206
|
+
d,
|
|
1207
|
+
a.methodFactory
|
|
1208
|
+
)), l;
|
|
931
1209
|
};
|
|
932
|
-
var
|
|
933
|
-
return
|
|
934
|
-
return typeof window !== t && window.log ===
|
|
935
|
-
},
|
|
1210
|
+
var $ = typeof window !== t ? window.log : void 0;
|
|
1211
|
+
return a.noConflict = function() {
|
|
1212
|
+
return typeof window !== t && window.log === a && (window.log = $), a;
|
|
1213
|
+
}, a.getLoggers = function() {
|
|
936
1214
|
return i;
|
|
937
|
-
},
|
|
1215
|
+
}, a.default = a, a;
|
|
938
1216
|
});
|
|
939
|
-
})(
|
|
940
|
-
var
|
|
941
|
-
const
|
|
1217
|
+
})(D);
|
|
1218
|
+
var F = D.exports;
|
|
1219
|
+
const Y = /* @__PURE__ */ W(F), Z = /* @__PURE__ */ z({
|
|
942
1220
|
__proto__: null,
|
|
943
|
-
default:
|
|
944
|
-
}, [
|
|
945
|
-
|
|
946
|
-
const
|
|
1221
|
+
default: Y
|
|
1222
|
+
}, [F]), oe = !0, E = Z;
|
|
1223
|
+
E.setLevel("debug");
|
|
1224
|
+
const ie = (r) => {
|
|
947
1225
|
try {
|
|
948
|
-
|
|
1226
|
+
E.setLevel(r);
|
|
949
1227
|
} catch (e) {
|
|
950
|
-
|
|
1228
|
+
E.setLevel("error"), E.error(e);
|
|
951
1229
|
}
|
|
952
1230
|
};
|
|
953
|
-
function
|
|
954
|
-
return
|
|
1231
|
+
function C(r) {
|
|
1232
|
+
return r === null || typeof r != "object" ? r : Array.isArray(r) ? [...r] : { ...r };
|
|
955
1233
|
}
|
|
956
|
-
function
|
|
1234
|
+
function G(r) {
|
|
1235
|
+
if (r === null || typeof r != "object")
|
|
1236
|
+
return r;
|
|
1237
|
+
if (r instanceof Date)
|
|
1238
|
+
return new Date(r.getTime());
|
|
1239
|
+
if (r instanceof RegExp)
|
|
1240
|
+
return new RegExp(r.source, r.flags);
|
|
1241
|
+
if (Array.isArray(r))
|
|
1242
|
+
return r.map(G);
|
|
1243
|
+
const e = {};
|
|
1244
|
+
for (const t in r)
|
|
1245
|
+
Object.prototype.hasOwnProperty.call(r, t) && (e[t] = G(r[t]));
|
|
1246
|
+
return e;
|
|
1247
|
+
}
|
|
1248
|
+
function J(r, ...e) {
|
|
957
1249
|
for (const t of e)
|
|
958
1250
|
if (t)
|
|
959
|
-
for (const
|
|
960
|
-
Object.prototype.hasOwnProperty.call(t,
|
|
961
|
-
return
|
|
1251
|
+
for (const s in t)
|
|
1252
|
+
Object.prototype.hasOwnProperty.call(t, s) && r[s] === void 0 && (r[s] = t[s]);
|
|
1253
|
+
return r;
|
|
962
1254
|
}
|
|
963
|
-
function
|
|
964
|
-
return
|
|
1255
|
+
function X(r, e) {
|
|
1256
|
+
return r != null && Object.prototype.hasOwnProperty.call(r, e);
|
|
965
1257
|
}
|
|
966
|
-
function
|
|
967
|
-
return
|
|
1258
|
+
function Q(r) {
|
|
1259
|
+
return r == null ? !0 : Array.isArray(r) || typeof r == "string" ? r.length === 0 : r instanceof Map || r instanceof Set ? r.size === 0 : typeof r == "object" ? Object.keys(r).length === 0 : !1;
|
|
968
1260
|
}
|
|
969
|
-
function
|
|
970
|
-
if (
|
|
1261
|
+
function L(r, e) {
|
|
1262
|
+
if (r === e)
|
|
971
1263
|
return !0;
|
|
972
|
-
if (
|
|
973
|
-
return
|
|
974
|
-
if (typeof
|
|
1264
|
+
if (r == null || e == null)
|
|
1265
|
+
return r === e;
|
|
1266
|
+
if (typeof r != typeof e)
|
|
975
1267
|
return !1;
|
|
976
|
-
if (typeof
|
|
977
|
-
return
|
|
978
|
-
if (Array.isArray(
|
|
1268
|
+
if (typeof r != "object")
|
|
1269
|
+
return r === e;
|
|
1270
|
+
if (Array.isArray(r) !== Array.isArray(e))
|
|
979
1271
|
return !1;
|
|
980
|
-
if (Array.isArray(
|
|
981
|
-
if (
|
|
1272
|
+
if (Array.isArray(r)) {
|
|
1273
|
+
if (r.length !== e.length)
|
|
982
1274
|
return !1;
|
|
983
|
-
for (let
|
|
984
|
-
if (!
|
|
1275
|
+
for (let n = 0; n < r.length; n++)
|
|
1276
|
+
if (!L(r[n], e[n]))
|
|
985
1277
|
return !1;
|
|
986
1278
|
return !0;
|
|
987
1279
|
}
|
|
988
|
-
const t = Object.keys(
|
|
989
|
-
if (t.length !==
|
|
1280
|
+
const t = Object.keys(r), s = Object.keys(e);
|
|
1281
|
+
if (t.length !== s.length)
|
|
990
1282
|
return !1;
|
|
991
|
-
for (const
|
|
1283
|
+
for (const n of t)
|
|
992
1284
|
if (!Object.prototype.hasOwnProperty.call(
|
|
993
1285
|
e,
|
|
994
|
-
|
|
995
|
-
) || !
|
|
996
|
-
n
|
|
997
|
-
e[
|
|
1286
|
+
n
|
|
1287
|
+
) || !L(
|
|
1288
|
+
r[n],
|
|
1289
|
+
e[n]
|
|
998
1290
|
))
|
|
999
1291
|
return !1;
|
|
1000
1292
|
return !0;
|
|
1001
1293
|
}
|
|
1002
|
-
class
|
|
1294
|
+
class q {
|
|
1003
1295
|
/**
|
|
1004
1296
|
* Create one object to store attributes. For performance reason, values of attributes passed to constructor
|
|
1005
1297
|
* will not be cloned to `attributes` property. So it means that value of `attributes` property in this object
|
|
@@ -1011,8 +1303,8 @@ class F {
|
|
|
1011
1303
|
attrChanged: new U(),
|
|
1012
1304
|
modelChanged: new U()
|
|
1013
1305
|
}, this._changing = !1, this._previousAttributes = {}, this._pending = !1;
|
|
1014
|
-
const
|
|
1015
|
-
t &&
|
|
1306
|
+
const s = e || {};
|
|
1307
|
+
t && J(s, t), this.attributes = s, this.changed = {};
|
|
1016
1308
|
}
|
|
1017
1309
|
/**
|
|
1018
1310
|
* Gets the value of an attribute.
|
|
@@ -1043,31 +1335,31 @@ class F {
|
|
|
1043
1335
|
get(e) {
|
|
1044
1336
|
return this.attributes[e];
|
|
1045
1337
|
}
|
|
1046
|
-
set(e, t,
|
|
1338
|
+
set(e, t, s) {
|
|
1047
1339
|
if (e == null) return this;
|
|
1048
|
-
let
|
|
1049
|
-
typeof e == "object" ? (
|
|
1050
|
-
const i =
|
|
1051
|
-
this._changing = !0,
|
|
1052
|
-
const
|
|
1053
|
-
for (const
|
|
1054
|
-
t =
|
|
1055
|
-
if (!
|
|
1056
|
-
|
|
1057
|
-
for (let
|
|
1340
|
+
let n;
|
|
1341
|
+
typeof e == "object" ? (n = e, s = t) : (n = {}, n[e] = t), s || (s = {});
|
|
1342
|
+
const i = s.unset, a = s.silent, c = [], M = this._changing;
|
|
1343
|
+
this._changing = !0, M || (this._previousAttributes = C(this.attributes), this.changed = {});
|
|
1344
|
+
const _ = this.attributes, p = this.changed, A = this._previousAttributes;
|
|
1345
|
+
for (const f in n)
|
|
1346
|
+
t = n[f], L(_[f], t) || c.push(f), L(A[f], t) ? delete p[f] : p[f] = t, i ? delete _[f] : _[f] = t;
|
|
1347
|
+
if (!a) {
|
|
1348
|
+
c.length && (this._pending = s);
|
|
1349
|
+
for (let f = 0; f < c.length; f++)
|
|
1058
1350
|
this.events.attrChanged.dispatch({
|
|
1059
1351
|
object: this,
|
|
1060
|
-
attrName:
|
|
1061
|
-
attrValue:
|
|
1062
|
-
options:
|
|
1352
|
+
attrName: c[f],
|
|
1353
|
+
attrValue: _[c[f]],
|
|
1354
|
+
options: s
|
|
1063
1355
|
});
|
|
1064
1356
|
}
|
|
1065
|
-
if (
|
|
1066
|
-
if (!
|
|
1357
|
+
if (M) return this;
|
|
1358
|
+
if (!a)
|
|
1067
1359
|
for (; this._pending; )
|
|
1068
|
-
|
|
1360
|
+
s = this._pending, this._pending = !1, this.events.modelChanged.dispatch({
|
|
1069
1361
|
object: this,
|
|
1070
|
-
options:
|
|
1362
|
+
options: s
|
|
1071
1363
|
});
|
|
1072
1364
|
return this._pending = !1, this._changing = !1, this;
|
|
1073
1365
|
}
|
|
@@ -1079,7 +1371,7 @@ class F {
|
|
|
1079
1371
|
* If you specify an attribute name, determine if that attribute has changed.
|
|
1080
1372
|
*/
|
|
1081
1373
|
hasChanged(e) {
|
|
1082
|
-
return e == null ? !
|
|
1374
|
+
return e == null ? !Q(this.changed) : X(this.changed, e);
|
|
1083
1375
|
}
|
|
1084
1376
|
/**
|
|
1085
1377
|
* Return an object containing all the attributes that have changed. Useful for determining what parts
|
|
@@ -1089,13 +1381,13 @@ class F {
|
|
|
1089
1381
|
* the model, determining if there *would be* a change.
|
|
1090
1382
|
*/
|
|
1091
1383
|
changedAttributes(e) {
|
|
1092
|
-
if (!e) return this.hasChanged() ?
|
|
1093
|
-
const t = this._changing ? this._previousAttributes : this.attributes,
|
|
1094
|
-
for (const
|
|
1095
|
-
const i = e[
|
|
1096
|
-
|
|
1384
|
+
if (!e) return this.hasChanged() ? C(this.changed) : {};
|
|
1385
|
+
const t = this._changing ? this._previousAttributes : this.attributes, s = {};
|
|
1386
|
+
for (const n in e) {
|
|
1387
|
+
const i = e[n];
|
|
1388
|
+
L(t[n], i) || (s[n] = i);
|
|
1097
1389
|
}
|
|
1098
|
-
return
|
|
1390
|
+
return s;
|
|
1099
1391
|
}
|
|
1100
1392
|
/**
|
|
1101
1393
|
* Get the previous value of an attribute, recorded at the time the last `"change"` event was fired.
|
|
@@ -1107,14 +1399,14 @@ class F {
|
|
|
1107
1399
|
* Get all of the attributes of the model at the time of the previous `"change"` event.
|
|
1108
1400
|
*/
|
|
1109
1401
|
previousAttributes() {
|
|
1110
|
-
return
|
|
1402
|
+
return C(this._previousAttributes);
|
|
1111
1403
|
}
|
|
1112
1404
|
/**
|
|
1113
1405
|
* Create a new model with identical attributes to this one.
|
|
1114
1406
|
*/
|
|
1115
1407
|
clone() {
|
|
1116
|
-
const e =
|
|
1117
|
-
return new
|
|
1408
|
+
const e = C(this.attributes);
|
|
1409
|
+
return new q(e);
|
|
1118
1410
|
}
|
|
1119
1411
|
}
|
|
1120
1412
|
class b {
|
|
@@ -1176,7 +1468,7 @@ class b {
|
|
|
1176
1468
|
return this.entries.delete(e);
|
|
1177
1469
|
}
|
|
1178
1470
|
}
|
|
1179
|
-
class
|
|
1471
|
+
class le {
|
|
1180
1472
|
/**
|
|
1181
1473
|
* Converts a byte count to a human-readable string using appropriate size units.
|
|
1182
1474
|
*
|
|
@@ -1201,11 +1493,11 @@ class se {
|
|
|
1201
1493
|
*/
|
|
1202
1494
|
static formatBytes(e, t = 2) {
|
|
1203
1495
|
if (e === 0) return "0 B";
|
|
1204
|
-
const
|
|
1205
|
-
return `${parseFloat(
|
|
1496
|
+
const s = 1024, n = Math.max(0, t), i = ["B", "KB", "MB", "GB", "TB"], a = Math.floor(Math.log(e) / Math.log(s)), c = e / Math.pow(s, a);
|
|
1497
|
+
return `${parseFloat(c.toFixed(n))} ${i[a]}`;
|
|
1206
1498
|
}
|
|
1207
1499
|
}
|
|
1208
|
-
class
|
|
1500
|
+
class ae {
|
|
1209
1501
|
/**
|
|
1210
1502
|
* Creates a new task with the specified name.
|
|
1211
1503
|
*
|
|
@@ -1228,7 +1520,7 @@ class ie {
|
|
|
1228
1520
|
throw new Error("run() must be implemented by subclass");
|
|
1229
1521
|
}
|
|
1230
1522
|
}
|
|
1231
|
-
class
|
|
1523
|
+
class he {
|
|
1232
1524
|
constructor() {
|
|
1233
1525
|
this.tasks = [], this.onProgress = () => {
|
|
1234
1526
|
}, this.onComplete = () => {
|
|
@@ -1244,11 +1536,11 @@ class le {
|
|
|
1244
1536
|
* @returns Promise that resolves with the result of the callback
|
|
1245
1537
|
*/
|
|
1246
1538
|
scheduleTask(e) {
|
|
1247
|
-
return new Promise((t,
|
|
1248
|
-
const
|
|
1249
|
-
Promise.resolve(e()).then(t).catch(
|
|
1539
|
+
return new Promise((t, s) => {
|
|
1540
|
+
const n = () => {
|
|
1541
|
+
Promise.resolve(e()).then(t).catch(s);
|
|
1250
1542
|
};
|
|
1251
|
-
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(
|
|
1543
|
+
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(n) : setTimeout(n, 0);
|
|
1252
1544
|
});
|
|
1253
1545
|
}
|
|
1254
1546
|
/**
|
|
@@ -1282,31 +1574,31 @@ class le {
|
|
|
1282
1574
|
*/
|
|
1283
1575
|
async run(e) {
|
|
1284
1576
|
const t = this.tasks.length;
|
|
1285
|
-
let
|
|
1286
|
-
for (let
|
|
1287
|
-
const i = this.tasks[
|
|
1577
|
+
let s = e;
|
|
1578
|
+
for (let n = 0; n < t; n++) {
|
|
1579
|
+
const i = this.tasks[n];
|
|
1288
1580
|
try {
|
|
1289
|
-
|
|
1290
|
-
const
|
|
1291
|
-
return this.onProgress((
|
|
1581
|
+
s = await this.scheduleTask(async () => {
|
|
1582
|
+
const a = await i.run(s);
|
|
1583
|
+
return this.onProgress((n + 1) / t, i), a;
|
|
1292
1584
|
});
|
|
1293
|
-
} catch (
|
|
1294
|
-
if (this.onError({ error:
|
|
1585
|
+
} catch (a) {
|
|
1586
|
+
if (this.onError({ error: a, taskIndex: n, task: i }))
|
|
1295
1587
|
break;
|
|
1296
1588
|
}
|
|
1297
1589
|
}
|
|
1298
|
-
this.onComplete(
|
|
1590
|
+
this.onComplete(s);
|
|
1299
1591
|
}
|
|
1300
1592
|
}
|
|
1301
|
-
class
|
|
1593
|
+
class ee {
|
|
1302
1594
|
/**
|
|
1303
1595
|
* Create a new AcCmLoadingManager instance
|
|
1304
1596
|
* @param onLoad this function will be called when all loaders are done.
|
|
1305
1597
|
* @param onProgress this function will be called when an item is complete.
|
|
1306
1598
|
* @param onError this function will be called a loader encounters errors.
|
|
1307
1599
|
*/
|
|
1308
|
-
constructor(e, t,
|
|
1309
|
-
this.isLoading = !1, this.itemsLoaded = 0, this.itemsTotal = 0, this.urlModifier = void 0, this.handlers = [], this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError =
|
|
1600
|
+
constructor(e, t, s) {
|
|
1601
|
+
this.isLoading = !1, this.itemsLoaded = 0, this.itemsTotal = 0, this.urlModifier = void 0, this.handlers = [], this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = s;
|
|
1310
1602
|
}
|
|
1311
1603
|
/**
|
|
1312
1604
|
* This should be called by any loader using the manager when the loader starts loading an url.
|
|
@@ -1374,22 +1666,22 @@ class Q {
|
|
|
1374
1666
|
* @returns Return the registered loader for the given file path.
|
|
1375
1667
|
*/
|
|
1376
1668
|
getHandler(e) {
|
|
1377
|
-
for (let t = 0,
|
|
1378
|
-
const
|
|
1379
|
-
if (
|
|
1669
|
+
for (let t = 0, s = this.handlers.length; t < s; t += 2) {
|
|
1670
|
+
const n = this.handlers[t], i = this.handlers[t + 1];
|
|
1671
|
+
if (n.global && (n.lastIndex = 0), n.test(e))
|
|
1380
1672
|
return i;
|
|
1381
1673
|
}
|
|
1382
1674
|
return null;
|
|
1383
1675
|
}
|
|
1384
1676
|
}
|
|
1385
|
-
const
|
|
1386
|
-
class
|
|
1677
|
+
const te = /* @__PURE__ */ new ee();
|
|
1678
|
+
class ue {
|
|
1387
1679
|
/**
|
|
1388
1680
|
* Creates a new AcCmLoader instance.
|
|
1389
1681
|
* @param manager The loadingManager for the loader to use. Default is DefaultLoadingManager.
|
|
1390
1682
|
*/
|
|
1391
1683
|
constructor(e) {
|
|
1392
|
-
this.manager = e !== void 0 ? e :
|
|
1684
|
+
this.manager = e !== void 0 ? e : te, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {};
|
|
1393
1685
|
}
|
|
1394
1686
|
/**
|
|
1395
1687
|
* This method is equivalent to 'load', but returns a Promise.
|
|
@@ -1400,8 +1692,8 @@ class ae {
|
|
|
1400
1692
|
* @returns Return a promise.
|
|
1401
1693
|
*/
|
|
1402
1694
|
loadAsync(e, t) {
|
|
1403
|
-
return new Promise((
|
|
1404
|
-
this.load(e,
|
|
1695
|
+
return new Promise((s, n) => {
|
|
1696
|
+
this.load(e, s, t, n);
|
|
1405
1697
|
});
|
|
1406
1698
|
}
|
|
1407
1699
|
/**
|
|
@@ -1455,24 +1747,28 @@ class ae {
|
|
|
1455
1747
|
}
|
|
1456
1748
|
}
|
|
1457
1749
|
export {
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1750
|
+
v as AcCmColor,
|
|
1751
|
+
o as AcCmColorMethod,
|
|
1752
|
+
B as AcCmColorUtil,
|
|
1753
|
+
re as AcCmEntityColor,
|
|
1754
|
+
se as AcCmErrors,
|
|
1755
|
+
ne as AcCmEventDispatcher,
|
|
1461
1756
|
U as AcCmEventManager,
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1757
|
+
ue as AcCmLoader,
|
|
1758
|
+
ee as AcCmLoadingManager,
|
|
1759
|
+
q as AcCmObject,
|
|
1465
1760
|
b as AcCmPerformanceCollector,
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
J as
|
|
1474
|
-
X as
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1761
|
+
ae as AcCmTask,
|
|
1762
|
+
he as AcCmTaskScheduler,
|
|
1763
|
+
le as AcTrStringUtil,
|
|
1764
|
+
oe as DEBUG_MODE,
|
|
1765
|
+
te as DefaultLoadingManager,
|
|
1766
|
+
C as clone,
|
|
1767
|
+
G as deepClone,
|
|
1768
|
+
J as defaults,
|
|
1769
|
+
X as has,
|
|
1770
|
+
Q as isEmpty,
|
|
1771
|
+
L as isEqual,
|
|
1772
|
+
E as log,
|
|
1773
|
+
ie as setLogLevel
|
|
1478
1774
|
};
|