@tspro/ts-utils-lib 2.2.0 → 2.2.1
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/CHANGELOG.md +6 -0
- package/dist/index.es5.iife.js +1 -1
- package/dist/index.es5.polyfilled.iife.js +1 -1
- package/dist/index.js +60 -35
- package/dist/index.mjs +60 -35
- package/package.json +4 -6
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
|
-
* TsUtilsLib v2.2.
|
|
4
|
+
* TsUtilsLib v2.2.1 (cjs)
|
|
5
5
|
* (c) 2023-2025 PahkaSoft
|
|
6
6
|
* Licensed under the MIT License
|
|
7
7
|
*/
|
|
@@ -1145,7 +1145,9 @@ var _consent;
|
|
|
1145
1145
|
var _expires;
|
|
1146
1146
|
var str = _read(ConsentCookieName);
|
|
1147
1147
|
_consent = str === "accept" /* Accept */ || str === "decline" /* Decline */ ? str : void 0;
|
|
1148
|
-
function
|
|
1148
|
+
function _getCookieList() {
|
|
1149
|
+
if (typeof document === "undefined")
|
|
1150
|
+
return [];
|
|
1149
1151
|
let s = document.cookie;
|
|
1150
1152
|
return s.split(";").map((c) => c.trim());
|
|
1151
1153
|
}
|
|
@@ -1154,15 +1156,17 @@ function _save(name, value) {
|
|
|
1154
1156
|
if (_expires) {
|
|
1155
1157
|
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
1156
1158
|
}
|
|
1157
|
-
document
|
|
1159
|
+
if (typeof document !== "undefined")
|
|
1160
|
+
document.cookie = cookie;
|
|
1158
1161
|
return value;
|
|
1159
1162
|
}
|
|
1160
1163
|
function _read(name, defaultValue) {
|
|
1161
|
-
let str2 =
|
|
1164
|
+
let str2 = _getCookieList().find((c) => c.startsWith(name + "="));
|
|
1162
1165
|
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
1163
1166
|
}
|
|
1164
1167
|
function _erase(name) {
|
|
1165
|
-
|
|
1168
|
+
if (typeof document !== "undefined")
|
|
1169
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
1166
1170
|
}
|
|
1167
1171
|
function setExpireDays(days) {
|
|
1168
1172
|
_expires = /* @__PURE__ */ new Date();
|
|
@@ -1211,7 +1215,8 @@ function erase(name) {
|
|
|
1211
1215
|
_erase(name);
|
|
1212
1216
|
}
|
|
1213
1217
|
function eraseAll() {
|
|
1214
|
-
|
|
1218
|
+
if (typeof document !== "undefined")
|
|
1219
|
+
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
1215
1220
|
}
|
|
1216
1221
|
|
|
1217
1222
|
// src/web/device.ts
|
|
@@ -1229,12 +1234,16 @@ __export(device_exports, {
|
|
|
1229
1234
|
toPx: () => toPx
|
|
1230
1235
|
});
|
|
1231
1236
|
function getDPI() {
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1237
|
+
try {
|
|
1238
|
+
let el = document.createElement("div");
|
|
1239
|
+
el.style.width = "1in";
|
|
1240
|
+
document.body.appendChild(el);
|
|
1241
|
+
let dpi = el.offsetWidth;
|
|
1242
|
+
el.remove();
|
|
1243
|
+
return dpi || 96;
|
|
1244
|
+
} catch (e) {
|
|
1245
|
+
return 96;
|
|
1246
|
+
}
|
|
1238
1247
|
}
|
|
1239
1248
|
function getScrollBarWidth() {
|
|
1240
1249
|
try {
|
|
@@ -1257,18 +1266,23 @@ function getScrollBarWidth() {
|
|
|
1257
1266
|
}
|
|
1258
1267
|
}
|
|
1259
1268
|
function getSystemFontSize() {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1269
|
+
try {
|
|
1270
|
+
let tmpDiv = document.createElement("div");
|
|
1271
|
+
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
1272
|
+
tmpDiv.appendChild(document.createTextNode("M"));
|
|
1273
|
+
document.body.appendChild(tmpDiv);
|
|
1274
|
+
let fontsize = tmpDiv.offsetHeight;
|
|
1275
|
+
document.body.removeChild(tmpDiv);
|
|
1276
|
+
return fontsize;
|
|
1277
|
+
} catch (e) {
|
|
1278
|
+
return 16;
|
|
1279
|
+
}
|
|
1267
1280
|
}
|
|
1268
1281
|
function getIsTouchDevice() {
|
|
1269
|
-
if (
|
|
1282
|
+
if (typeof window === "undefined")
|
|
1283
|
+
return false;
|
|
1284
|
+
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document)
|
|
1270
1285
|
return true;
|
|
1271
|
-
}
|
|
1272
1286
|
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
1273
1287
|
var mq = function(query2) {
|
|
1274
1288
|
return window.matchMedia(query2).matches;
|
|
@@ -1281,7 +1295,10 @@ function getIsMobileDevice() {
|
|
|
1281
1295
|
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
1282
1296
|
}
|
|
1283
1297
|
function getHostAddress() {
|
|
1284
|
-
|
|
1298
|
+
if (typeof location === "undefined" || !location.host) {
|
|
1299
|
+
return "localhost";
|
|
1300
|
+
}
|
|
1301
|
+
return `${location.protocol}//${location.host}`;
|
|
1285
1302
|
}
|
|
1286
1303
|
var UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
1287
1304
|
var ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
@@ -1441,6 +1458,9 @@ __export(dom_exports, {
|
|
|
1441
1458
|
setWidth: () => setWidth,
|
|
1442
1459
|
styleLayoutChanged: () => styleLayoutChanged
|
|
1443
1460
|
});
|
|
1461
|
+
function _getElemById(id) {
|
|
1462
|
+
return typeof document === "undefined" ? void 0 : document.getElementById(id) ?? void 0;
|
|
1463
|
+
}
|
|
1444
1464
|
function toPx2(value) {
|
|
1445
1465
|
return value === void 0 ? void 0 : device_exports.toPx(value);
|
|
1446
1466
|
}
|
|
@@ -1477,12 +1497,17 @@ function setOffset(el, left, top, unit = "px") {
|
|
|
1477
1497
|
el.style.top = top + unit;
|
|
1478
1498
|
}
|
|
1479
1499
|
function getOffset(el) {
|
|
1480
|
-
let
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
top
|
|
1484
|
-
|
|
1485
|
-
|
|
1500
|
+
let { left, top } = el.getBoundingClientRect();
|
|
1501
|
+
if (typeof window !== "undefined") {
|
|
1502
|
+
left += window.pageXOffset;
|
|
1503
|
+
top += window.pageYOffset;
|
|
1504
|
+
}
|
|
1505
|
+
if (typeof document !== "undefined") {
|
|
1506
|
+
let de = document.documentElement;
|
|
1507
|
+
left -= de.clientLeft;
|
|
1508
|
+
top -= de.clientTop;
|
|
1509
|
+
}
|
|
1510
|
+
return { left, top };
|
|
1486
1511
|
}
|
|
1487
1512
|
function getWidth(el) {
|
|
1488
1513
|
if (el instanceof Window) {
|
|
@@ -1522,11 +1547,11 @@ function setRect(el, left, top, width, height, unit = "px") {
|
|
|
1522
1547
|
el.style.height = height + unit;
|
|
1523
1548
|
}
|
|
1524
1549
|
function getButton(btn) {
|
|
1525
|
-
let el = typeof btn === "string" ?
|
|
1550
|
+
let el = typeof btn === "string" ? _getElemById(btn) : btn;
|
|
1526
1551
|
return el instanceof HTMLButtonElement ? el : void 0;
|
|
1527
1552
|
}
|
|
1528
1553
|
function getCanvas(canvas2) {
|
|
1529
|
-
let el = typeof canvas2 === "string" ?
|
|
1554
|
+
let el = typeof canvas2 === "string" ? _getElemById(canvas2) : canvas2;
|
|
1530
1555
|
return el instanceof HTMLCanvasElement ? el : void 0;
|
|
1531
1556
|
}
|
|
1532
1557
|
function getPadding(style) {
|
|
@@ -1599,11 +1624,11 @@ function styleLayoutChanged(style1, style2) {
|
|
|
1599
1624
|
}
|
|
1600
1625
|
var canvas;
|
|
1601
1626
|
function getCanvasTextWidth(text, font) {
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1627
|
+
if (!canvas && typeof document !== "undefined")
|
|
1628
|
+
canvas = document.createElement("canvas");
|
|
1629
|
+
let ctx = canvas?.getContext("2d");
|
|
1630
|
+
if (!ctx)
|
|
1605
1631
|
return 0;
|
|
1606
|
-
}
|
|
1607
1632
|
ctx.font = font;
|
|
1608
1633
|
return ctx.measureText(text).width;
|
|
1609
1634
|
}
|
|
@@ -4344,7 +4369,7 @@ var LinkedList = class _LinkedList extends BaseContainer {
|
|
|
4344
4369
|
|
|
4345
4370
|
// src/index.ts
|
|
4346
4371
|
function getLibInfo() {
|
|
4347
|
-
return "TsUtilsLib v2.2.
|
|
4372
|
+
return "TsUtilsLib v2.2.1 (cjs)";
|
|
4348
4373
|
}
|
|
4349
4374
|
|
|
4350
4375
|
exports.AnchoredRect = AnchoredRect;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* TsUtilsLib v2.2.
|
|
2
|
+
* TsUtilsLib v2.2.1 (esm)
|
|
3
3
|
* (c) 2023-2025 PahkaSoft
|
|
4
4
|
* Licensed under the MIT License
|
|
5
5
|
*/
|
|
@@ -1143,7 +1143,9 @@ var _consent;
|
|
|
1143
1143
|
var _expires;
|
|
1144
1144
|
var str = _read(ConsentCookieName);
|
|
1145
1145
|
_consent = str === "accept" /* Accept */ || str === "decline" /* Decline */ ? str : void 0;
|
|
1146
|
-
function
|
|
1146
|
+
function _getCookieList() {
|
|
1147
|
+
if (typeof document === "undefined")
|
|
1148
|
+
return [];
|
|
1147
1149
|
let s = document.cookie;
|
|
1148
1150
|
return s.split(";").map((c) => c.trim());
|
|
1149
1151
|
}
|
|
@@ -1152,15 +1154,17 @@ function _save(name, value) {
|
|
|
1152
1154
|
if (_expires) {
|
|
1153
1155
|
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
1154
1156
|
}
|
|
1155
|
-
document
|
|
1157
|
+
if (typeof document !== "undefined")
|
|
1158
|
+
document.cookie = cookie;
|
|
1156
1159
|
return value;
|
|
1157
1160
|
}
|
|
1158
1161
|
function _read(name, defaultValue) {
|
|
1159
|
-
let str2 =
|
|
1162
|
+
let str2 = _getCookieList().find((c) => c.startsWith(name + "="));
|
|
1160
1163
|
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
1161
1164
|
}
|
|
1162
1165
|
function _erase(name) {
|
|
1163
|
-
|
|
1166
|
+
if (typeof document !== "undefined")
|
|
1167
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
1164
1168
|
}
|
|
1165
1169
|
function setExpireDays(days) {
|
|
1166
1170
|
_expires = /* @__PURE__ */ new Date();
|
|
@@ -1209,7 +1213,8 @@ function erase(name) {
|
|
|
1209
1213
|
_erase(name);
|
|
1210
1214
|
}
|
|
1211
1215
|
function eraseAll() {
|
|
1212
|
-
|
|
1216
|
+
if (typeof document !== "undefined")
|
|
1217
|
+
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
1213
1218
|
}
|
|
1214
1219
|
|
|
1215
1220
|
// src/web/device.ts
|
|
@@ -1227,12 +1232,16 @@ __export(device_exports, {
|
|
|
1227
1232
|
toPx: () => toPx
|
|
1228
1233
|
});
|
|
1229
1234
|
function getDPI() {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1235
|
+
try {
|
|
1236
|
+
let el = document.createElement("div");
|
|
1237
|
+
el.style.width = "1in";
|
|
1238
|
+
document.body.appendChild(el);
|
|
1239
|
+
let dpi = el.offsetWidth;
|
|
1240
|
+
el.remove();
|
|
1241
|
+
return dpi || 96;
|
|
1242
|
+
} catch (e) {
|
|
1243
|
+
return 96;
|
|
1244
|
+
}
|
|
1236
1245
|
}
|
|
1237
1246
|
function getScrollBarWidth() {
|
|
1238
1247
|
try {
|
|
@@ -1255,18 +1264,23 @@ function getScrollBarWidth() {
|
|
|
1255
1264
|
}
|
|
1256
1265
|
}
|
|
1257
1266
|
function getSystemFontSize() {
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1267
|
+
try {
|
|
1268
|
+
let tmpDiv = document.createElement("div");
|
|
1269
|
+
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
1270
|
+
tmpDiv.appendChild(document.createTextNode("M"));
|
|
1271
|
+
document.body.appendChild(tmpDiv);
|
|
1272
|
+
let fontsize = tmpDiv.offsetHeight;
|
|
1273
|
+
document.body.removeChild(tmpDiv);
|
|
1274
|
+
return fontsize;
|
|
1275
|
+
} catch (e) {
|
|
1276
|
+
return 16;
|
|
1277
|
+
}
|
|
1265
1278
|
}
|
|
1266
1279
|
function getIsTouchDevice() {
|
|
1267
|
-
if (
|
|
1280
|
+
if (typeof window === "undefined")
|
|
1281
|
+
return false;
|
|
1282
|
+
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document)
|
|
1268
1283
|
return true;
|
|
1269
|
-
}
|
|
1270
1284
|
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
1271
1285
|
var mq = function(query2) {
|
|
1272
1286
|
return window.matchMedia(query2).matches;
|
|
@@ -1279,7 +1293,10 @@ function getIsMobileDevice() {
|
|
|
1279
1293
|
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
1280
1294
|
}
|
|
1281
1295
|
function getHostAddress() {
|
|
1282
|
-
|
|
1296
|
+
if (typeof location === "undefined" || !location.host) {
|
|
1297
|
+
return "localhost";
|
|
1298
|
+
}
|
|
1299
|
+
return `${location.protocol}//${location.host}`;
|
|
1283
1300
|
}
|
|
1284
1301
|
var UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
1285
1302
|
var ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
@@ -1439,6 +1456,9 @@ __export(dom_exports, {
|
|
|
1439
1456
|
setWidth: () => setWidth,
|
|
1440
1457
|
styleLayoutChanged: () => styleLayoutChanged
|
|
1441
1458
|
});
|
|
1459
|
+
function _getElemById(id) {
|
|
1460
|
+
return typeof document === "undefined" ? void 0 : document.getElementById(id) ?? void 0;
|
|
1461
|
+
}
|
|
1442
1462
|
function toPx2(value) {
|
|
1443
1463
|
return value === void 0 ? void 0 : device_exports.toPx(value);
|
|
1444
1464
|
}
|
|
@@ -1475,12 +1495,17 @@ function setOffset(el, left, top, unit = "px") {
|
|
|
1475
1495
|
el.style.top = top + unit;
|
|
1476
1496
|
}
|
|
1477
1497
|
function getOffset(el) {
|
|
1478
|
-
let
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
top
|
|
1482
|
-
|
|
1483
|
-
|
|
1498
|
+
let { left, top } = el.getBoundingClientRect();
|
|
1499
|
+
if (typeof window !== "undefined") {
|
|
1500
|
+
left += window.pageXOffset;
|
|
1501
|
+
top += window.pageYOffset;
|
|
1502
|
+
}
|
|
1503
|
+
if (typeof document !== "undefined") {
|
|
1504
|
+
let de = document.documentElement;
|
|
1505
|
+
left -= de.clientLeft;
|
|
1506
|
+
top -= de.clientTop;
|
|
1507
|
+
}
|
|
1508
|
+
return { left, top };
|
|
1484
1509
|
}
|
|
1485
1510
|
function getWidth(el) {
|
|
1486
1511
|
if (el instanceof Window) {
|
|
@@ -1520,11 +1545,11 @@ function setRect(el, left, top, width, height, unit = "px") {
|
|
|
1520
1545
|
el.style.height = height + unit;
|
|
1521
1546
|
}
|
|
1522
1547
|
function getButton(btn) {
|
|
1523
|
-
let el = typeof btn === "string" ?
|
|
1548
|
+
let el = typeof btn === "string" ? _getElemById(btn) : btn;
|
|
1524
1549
|
return el instanceof HTMLButtonElement ? el : void 0;
|
|
1525
1550
|
}
|
|
1526
1551
|
function getCanvas(canvas2) {
|
|
1527
|
-
let el = typeof canvas2 === "string" ?
|
|
1552
|
+
let el = typeof canvas2 === "string" ? _getElemById(canvas2) : canvas2;
|
|
1528
1553
|
return el instanceof HTMLCanvasElement ? el : void 0;
|
|
1529
1554
|
}
|
|
1530
1555
|
function getPadding(style) {
|
|
@@ -1597,11 +1622,11 @@ function styleLayoutChanged(style1, style2) {
|
|
|
1597
1622
|
}
|
|
1598
1623
|
var canvas;
|
|
1599
1624
|
function getCanvasTextWidth(text, font) {
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1625
|
+
if (!canvas && typeof document !== "undefined")
|
|
1626
|
+
canvas = document.createElement("canvas");
|
|
1627
|
+
let ctx = canvas?.getContext("2d");
|
|
1628
|
+
if (!ctx)
|
|
1603
1629
|
return 0;
|
|
1604
|
-
}
|
|
1605
1630
|
ctx.font = font;
|
|
1606
1631
|
return ctx.measureText(text).width;
|
|
1607
1632
|
}
|
|
@@ -4342,7 +4367,7 @@ var LinkedList = class _LinkedList extends BaseContainer {
|
|
|
4342
4367
|
|
|
4343
4368
|
// src/index.ts
|
|
4344
4369
|
function getLibInfo() {
|
|
4345
|
-
return "TsUtilsLib v2.2.
|
|
4370
|
+
return "TsUtilsLib v2.2.1 (esm)";
|
|
4346
4371
|
}
|
|
4347
4372
|
|
|
4348
4373
|
export { AnchoredRect, assert_exports as Assert, BaseContainer, BiMap, cookies_exports as Cookies, DefaultArray, DefaultEqualityFn, device_exports as Device, guard_exports as Guard, IndexArray, LRUCache, LinkedList, MultiContainer, Rect, SignedIndexArray, Stack, TriMap, UniMap, utils_exports as Utils, ValueSet, Vec, asMulti, getLibInfo };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tspro/ts-utils-lib",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"author": "PahkaSoft",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@swc/core": "^1.14.0",
|
|
50
50
|
"@types/jasmine": "^5.1.8",
|
|
51
51
|
"benchmark": "^2.1.4",
|
|
52
|
+
"core-js": "^3.46.0",
|
|
52
53
|
"jasmine": "^5.8.0",
|
|
53
54
|
"karma": "^6.4.4",
|
|
54
55
|
"karma-chrome-launcher": "^3.2.0",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"karma-jasmine": "^5.1.0",
|
|
57
58
|
"karma-webpack": "^5.0.1",
|
|
58
59
|
"npm-watch": "^0.13.0",
|
|
60
|
+
"regenerator-runtime": "^0.14.1",
|
|
59
61
|
"ts-loader": "^9.5.2",
|
|
60
62
|
"tsup": "^8.5.0",
|
|
61
63
|
"typedoc": "^0.28.7",
|
|
@@ -67,9 +69,5 @@
|
|
|
67
69
|
"watch": "tsup --watch",
|
|
68
70
|
"test": "karma start",
|
|
69
71
|
"docs": "typedoc"
|
|
70
|
-
},
|
|
71
|
-
"dependencies": {
|
|
72
|
-
"core-js": "^3.46.0",
|
|
73
|
-
"regenerator-runtime": "^0.14.1"
|
|
74
72
|
}
|
|
75
|
-
}
|
|
73
|
+
}
|