@tspro/ts-utils-lib 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,16 @@
1
1
  # Changelog
2
+ ## [3.0.0] - 2026-01-08
3
+ ### Breaking Change
4
+ - Device module update.
5
+
6
+ ## [2.3.0] - 2025-11-27
7
+ ### Changed
8
+ - Replaced .d.mts type declarations with .d.ts.
9
+ - Include .map files in package.
10
+
11
+ ### Added
12
+ - Utils.Dom.injectCss()
13
+
2
14
  ## [2.2.1] - 2025-11-25
3
15
  ### Fixed
4
16
  - Moved "core-js" and "regenerator-runtime" to "devDependencies" because
package/README.md CHANGED
@@ -15,7 +15,7 @@ lib is written by AI.
15
15
  Homepage contains TS Docs/API Reference.
16
16
 
17
17
  ## Install
18
- `npm i @tspro/ts-utils-lib`
18
+ `npm install @tspro/ts-utils-lib`
19
19
 
20
20
  ## Usage
21
21
  ```js
@@ -36,12 +36,12 @@ const map = new UniMap();
36
36
 
37
37
  ```html
38
38
  <!-- Load non-polyfilled or polyfilled bundles on unpkg cdn -->
39
- <script src="https://unpkg.com/@tspro/ts-utils-lib@2.2.0/dist/index.es5.iife.js"></script>
40
- <script src="https://unpkg.com/@tspro/ts-utils-lib@2.2.0/dist/index.es5.polyfilled.iife.js"></script>
39
+ <script src="https://unpkg.com/@tspro/ts-utils-lib@2.3.0/dist/index.es5.iife.js"></script>
40
+ <script src="https://unpkg.com/@tspro/ts-utils-lib@2.3.0/dist/index.es5.polyfilled.iife.js"></script>
41
41
 
42
42
  <!-- Load non-polyfilled or polyfilled bundles on jsdelivr cdn -->
43
- <script src="https://cdn.jsdelivr.net/npm/@tspro/ts-utils-lib@2.2.0/dist/index.es5.iife.js"></script>
44
- <script src="https://cdn.jsdelivr.net/npm/@tspro/ts-utils-lib@2.2.0/dist/index.es5.polyfilled.iife.js"></script>
43
+ <script src="https://cdn.jsdelivr.net/npm/@tspro/ts-utils-lib@2.3.0/dist/index.es5.iife.js"></script>
44
+ <script src="https://cdn.jsdelivr.net/npm/@tspro/ts-utils-lib@2.3.0/dist/index.es5.polyfilled.iife.js"></script>
45
45
 
46
46
  <!-- JS example: -->
47
47
  <script>
package/dist/index.d.ts CHANGED
@@ -186,10 +186,7 @@ declare namespace cookies {
186
186
  export { cookies_accept as accept, cookies_decline as decline, cookies_erase as erase, cookies_eraseAll as eraseAll, cookies_isConsentPending as isConsentPending, cookies_read as read, cookies_readBool as readBool, cookies_readInt as readInt, cookies_save as save, cookies_setExpireDays as setExpireDays };
187
187
  }
188
188
 
189
- /** Devices dots per inch. */
190
- declare const DPI: number;
191
- /** Devices pixels per millimeter. */
192
- declare const PxPerMm: number;
189
+ type CssUnit = "px" | "cm" | "mm" | "in" | "pt" | "pc" | "em" | "rem" | "vw" | "vh" | "vmin" | "vmax" | "%";
193
190
  /** Browsers scroll bar width. */
194
191
  declare const ScrollbarWidth: number;
195
192
  /** Browsers system font size. */
@@ -200,39 +197,34 @@ declare const IsTouchDevice: boolean;
200
197
  declare const IsMobileDevice: boolean;
201
198
  /** Host address. */
202
199
  declare const HostAddress: string;
203
- /**
204
- * Convert pixels to millimeters on a device.
205
- * @param px - Pixels.
206
- * @returns - Millimeters.
207
- */
208
- declare function pxToMm(px: number): number;
209
- /**
210
- * Convert millimeters to pixels on a device.
211
- * @param mm - Millimeters.
212
- * @returns - Pixels.
213
- */
214
- declare function mmToPx(mm: number): number;
200
+ /** Device pixel ratio. */
201
+ declare const DevicePixelRatio: number;
202
+ /** Devices dots per inch. */
203
+ declare const DPI: number;
215
204
  /**
216
205
  * Convert input to pixels on a device. Input value is in html style form containing number
217
206
  * followed by unit (e.g. "10px"). Supported units are "mm", "cm", "in", "inch", "em" and "px".
218
207
  *
219
- * @param input - Input value.
208
+ * @param valueUnit - Input value.
220
209
  * @returns - Pixels.
221
210
  */
222
- declare function toPx(input: string | number): number;
211
+ declare function unitToPx(valueUnit: string | number): number;
212
+ declare function pxToUnit(px: number, unit: CssUnit): number;
213
+ declare function pxToUnitStr(px: number, unit: CssUnit): string;
223
214
 
215
+ type device_CssUnit = CssUnit;
224
216
  declare const device_DPI: typeof DPI;
217
+ declare const device_DevicePixelRatio: typeof DevicePixelRatio;
225
218
  declare const device_FontSize: typeof FontSize;
226
219
  declare const device_HostAddress: typeof HostAddress;
227
220
  declare const device_IsMobileDevice: typeof IsMobileDevice;
228
221
  declare const device_IsTouchDevice: typeof IsTouchDevice;
229
- declare const device_PxPerMm: typeof PxPerMm;
230
222
  declare const device_ScrollbarWidth: typeof ScrollbarWidth;
231
- declare const device_mmToPx: typeof mmToPx;
232
- declare const device_pxToMm: typeof pxToMm;
233
- declare const device_toPx: typeof toPx;
223
+ declare const device_pxToUnit: typeof pxToUnit;
224
+ declare const device_pxToUnitStr: typeof pxToUnitStr;
225
+ declare const device_unitToPx: typeof unitToPx;
234
226
  declare namespace device {
235
- export { device_DPI as DPI, device_FontSize as FontSize, device_HostAddress as HostAddress, device_IsMobileDevice as IsMobileDevice, device_IsTouchDevice as IsTouchDevice, device_PxPerMm as PxPerMm, device_ScrollbarWidth as ScrollbarWidth, device_mmToPx as mmToPx, device_pxToMm as pxToMm, device_toPx as toPx };
227
+ export { type device_CssUnit as CssUnit, device_DPI as DPI, device_DevicePixelRatio as DevicePixelRatio, device_FontSize as FontSize, device_HostAddress as HostAddress, device_IsMobileDevice as IsMobileDevice, device_IsTouchDevice as IsTouchDevice, device_ScrollbarWidth as ScrollbarWidth, device_pxToUnit as pxToUnit, device_pxToUnitStr as pxToUnitStr, device_unitToPx as unitToPx };
236
228
  }
237
229
 
238
230
  type HasProps<T extends object> = T extends Record<string, unknown> ? T : never;
@@ -471,6 +463,12 @@ declare function getDimension(style?: CSSProperties): {
471
463
  };
472
464
  declare function styleLayoutChanged(style1?: CSSProperties, style2?: CSSProperties): boolean;
473
465
  declare function getCanvasTextWidth(text: string, font: string): number;
466
+ /**
467
+ * Add style element to document head.
468
+ * @param styleId - Id of style element.
469
+ * @param styleCss - Style CSS string.
470
+ */
471
+ declare function injectCss(styleId: string, styleCss: string): void;
474
472
 
475
473
  type index$4_CSSProperties = CSSProperties;
476
474
  declare const index$4_addClass: typeof addClass;
@@ -484,6 +482,7 @@ declare const index$4_getOffset: typeof getOffset;
484
482
  declare const index$4_getPadding: typeof getPadding;
485
483
  declare const index$4_getWidth: typeof getWidth;
486
484
  declare const index$4_hasClass: typeof hasClass;
485
+ declare const index$4_injectCss: typeof injectCss;
487
486
  declare const index$4_removeClass: typeof removeClass;
488
487
  declare const index$4_removeFromParent: typeof removeFromParent;
489
488
  declare const index$4_setHeight: typeof setHeight;
@@ -493,7 +492,7 @@ declare const index$4_setVisibility: typeof setVisibility;
493
492
  declare const index$4_setWidth: typeof setWidth;
494
493
  declare const index$4_styleLayoutChanged: typeof styleLayoutChanged;
495
494
  declare namespace index$4 {
496
- export { type index$4_CSSProperties as CSSProperties, index$4_addClass as addClass, index$4_appendTo as appendTo, index$4_getButton as getButton, index$4_getCanvas as getCanvas, index$4_getCanvasTextWidth as getCanvasTextWidth, index$4_getDimension as getDimension, index$4_getHeight as getHeight, index$4_getOffset as getOffset, index$4_getPadding as getPadding, index$4_getWidth as getWidth, index$4_hasClass as hasClass, index$4_removeClass as removeClass, index$4_removeFromParent as removeFromParent, index$4_setHeight as setHeight, index$4_setOffset as setOffset, index$4_setRect as setRect, index$4_setVisibility as setVisibility, index$4_setWidth as setWidth, index$4_styleLayoutChanged as styleLayoutChanged };
495
+ export { type index$4_CSSProperties as CSSProperties, index$4_addClass as addClass, index$4_appendTo as appendTo, index$4_getButton as getButton, index$4_getCanvas as getCanvas, index$4_getCanvasTextWidth as getCanvasTextWidth, index$4_getDimension as getDimension, index$4_getHeight as getHeight, index$4_getOffset as getOffset, index$4_getPadding as getPadding, index$4_getWidth as getWidth, index$4_hasClass as hasClass, index$4_injectCss as injectCss, index$4_removeClass as removeClass, index$4_removeFromParent as removeFromParent, index$4_setHeight as setHeight, index$4_setOffset as setOffset, index$4_setRect as setRect, index$4_setVisibility as setVisibility, index$4_setWidth as setWidth, index$4_styleLayoutChanged as styleLayoutChanged };
497
496
  }
498
497
 
499
498
  declare function linearToDecibels(linearVolume: number): number;