tiny-essentials 1.26.4 → 1.27.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.
Files changed (120) hide show
  1. package/.github/workflows/node.js.yml +1 -1
  2. package/README.md +0 -1
  3. package/changelog/1/27/0.md +24 -0
  4. package/dist/v1/ColorSafeStringify.min.js +1 -1
  5. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  6. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  7. package/dist/v1/TinyAnalogClock.min.js +1 -1
  8. package/dist/v1/TinyArrayComparator.min.js +1 -1
  9. package/dist/v1/TinyArrayPaginator.min.js +1 -1
  10. package/dist/v1/TinyBasicsEs.min.js +1 -1
  11. package/dist/v1/TinyClassManager.min.js +1 -1
  12. package/dist/v1/TinyClipboard.min.js +1 -1
  13. package/dist/v1/TinyColorConverter.min.js +1 -1
  14. package/dist/v1/TinyColorValidator.min.js +1 -1
  15. package/dist/v1/TinyCookieConsent.min.js +1 -1
  16. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  17. package/dist/v1/TinyDomReadyManager.min.js +1 -1
  18. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  19. package/dist/v1/TinyDragger.min.js +1 -1
  20. package/dist/v1/TinyElementObserver.min.js +1 -1
  21. package/dist/v1/TinyEssentials.min.js +1 -1
  22. package/dist/v1/TinyEvents.min.js +1 -1
  23. package/dist/v1/TinyGamepad.min.js +1 -1
  24. package/dist/v1/TinyHtml.min.js +1 -1
  25. package/dist/v1/TinyI18.min.js +1 -1
  26. package/dist/v1/TinyIframeEvents.min.js +1 -1
  27. package/dist/v1/TinyInventory.min.js +1 -1
  28. package/dist/v1/TinyInventoryTrader.min.js +1 -1
  29. package/dist/v1/TinyLevelUp.min.js +1 -1
  30. package/dist/v1/TinyLoadingScreen.min.js +1 -1
  31. package/dist/v1/TinyLocalStorage.min.js +1 -1
  32. package/dist/v1/TinyMaInSys.min.js +1 -1
  33. package/dist/v1/TinyMediaPlayer.min.js +1 -0
  34. package/dist/v1/TinyNeedBar.min.js +1 -1
  35. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  36. package/dist/v1/TinyNotifications.min.js +1 -1
  37. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  38. package/dist/v1/TinyPromiseQueue.min.js +1 -1
  39. package/dist/v1/TinyRadioFm.min.js +1 -0
  40. package/dist/v1/TinyRateLimiter.min.js +1 -1
  41. package/dist/v1/TinySimpleDice.min.js +1 -1
  42. package/dist/v1/TinySmartScroller.min.js +1 -1
  43. package/dist/v1/TinyTextDiffer.min.js +1 -1
  44. package/dist/v1/TinyTextRangeEditor.min.js +1 -1
  45. package/dist/v1/TinyTextarea.min.js +1 -1
  46. package/dist/v1/TinyTimeout.min.js +1 -1
  47. package/dist/v1/TinyToastNotify.min.js +1 -1
  48. package/dist/v1/TinyUploadClicker.min.js +1 -1
  49. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  50. package/dist/v1/basics/index.cjs +5 -0
  51. package/dist/v1/basics/index.d.mts +5 -1
  52. package/dist/v1/basics/index.mjs +2 -1
  53. package/dist/v1/basics/mediaContent.cjs +644 -0
  54. package/dist/v1/basics/mediaContent.d.mts +296 -0
  55. package/dist/v1/basics/mediaContent.mjs +557 -0
  56. package/dist/v1/build/TinyMediaPlayer.cjs +7 -0
  57. package/dist/v1/build/TinyMediaPlayer.d.mts +3 -0
  58. package/dist/v1/build/TinyMediaPlayer.mjs +2 -0
  59. package/dist/v1/build/TinyRadioFm.cjs +7 -0
  60. package/dist/v1/build/TinyRadioFm.d.mts +3 -0
  61. package/dist/v1/build/TinyRadioFm.mjs +2 -0
  62. package/dist/v1/index.cjs +9 -0
  63. package/dist/v1/index.d.mts +7 -1
  64. package/dist/v1/index.mjs +5 -2
  65. package/dist/v1/libs/ColorSafeStringify.d.mts +1 -1
  66. package/dist/v1/libs/TinyAfterScrollWatcher.cjs +16 -3
  67. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +7 -3
  68. package/dist/v1/libs/TinyAfterScrollWatcher.mjs +13 -3
  69. package/dist/v1/libs/TinyArrayComparator.cjs +14 -11
  70. package/dist/v1/libs/TinyArrayComparator.d.mts +22 -19
  71. package/dist/v1/libs/TinyArrayComparator.mjs +14 -11
  72. package/dist/v1/libs/TinyArrayPaginator.cjs +23 -16
  73. package/dist/v1/libs/TinyArrayPaginator.d.mts +57 -30
  74. package/dist/v1/libs/TinyArrayPaginator.mjs +22 -16
  75. package/dist/v1/libs/TinyClassManager/TinyPluginInliner.cjs +265 -0
  76. package/dist/v1/libs/TinyClassManager/TinyPluginInliner.d.mts +92 -0
  77. package/dist/v1/libs/TinyClassManager/TinyPluginInliner.mjs +223 -0
  78. package/dist/v1/libs/TinyClassManager.cjs +52 -22
  79. package/dist/v1/libs/TinyClassManager.d.mts +26 -16
  80. package/dist/v1/libs/TinyClassManager.mjs +50 -21
  81. package/dist/v1/libs/TinyColorValidator.d.mts +16 -16
  82. package/dist/v1/libs/TinyDragDropDetector.cjs +9 -34
  83. package/dist/v1/libs/TinyDragDropDetector.d.mts +7 -21
  84. package/dist/v1/libs/TinyDragDropDetector.mjs +9 -24
  85. package/dist/v1/libs/TinyDragger.cjs +5 -5
  86. package/dist/v1/libs/TinyDragger.d.mts +4 -3
  87. package/dist/v1/libs/TinyDragger.mjs +5 -5
  88. package/dist/v1/libs/TinyElementObserver.cjs +6 -21
  89. package/dist/v1/libs/TinyElementObserver.d.mts +6 -15
  90. package/dist/v1/libs/TinyElementObserver.mjs +6 -20
  91. package/dist/v1/libs/TinyGamepad.cjs +4 -6
  92. package/dist/v1/libs/TinyGamepad.d.mts +1 -1
  93. package/dist/v1/libs/TinyHtml/TinyHtmlIcon.d.mts +1 -1
  94. package/dist/v1/libs/TinyHtml/TinyHtmlTemplate.d.mts +1 -1
  95. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.d.mts +1 -1
  96. package/dist/v1/libs/TinyHtml/index.d.mts +1 -1
  97. package/dist/v1/libs/TinyHtml.cjs +72 -98
  98. package/dist/v1/libs/TinyHtml.d.mts +15 -32
  99. package/dist/v1/libs/TinyHtml.mjs +53 -77
  100. package/dist/v1/libs/TinyInventory.d.mts +1 -1
  101. package/dist/v1/libs/TinyMediaPlayer.cjs +844 -0
  102. package/dist/v1/libs/TinyMediaPlayer.d.mts +306 -0
  103. package/dist/v1/libs/TinyMediaPlayer.mjs +755 -0
  104. package/dist/v1/libs/TinyRadioFm.cjs +1378 -0
  105. package/dist/v1/libs/TinyRadioFm.d.mts +554 -0
  106. package/dist/v1/libs/TinyRadioFm.mjs +1137 -0
  107. package/dist/v1/libs/TinySmartScroller.cjs +39 -26
  108. package/dist/v1/libs/TinySmartScroller.d.mts +16 -62
  109. package/dist/v1/libs/TinySmartScroller.mjs +35 -26
  110. package/dist/v1/libs/UltraRandomMsgGen.d.mts +7 -7
  111. package/docs/v1/README.md +6 -0
  112. package/docs/v1/basics/mediaContent.md +131 -0
  113. package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +107 -0
  114. package/docs/v1/libs/TinyDragDropDetector.md +5 -9
  115. package/docs/v1/libs/TinyElementObserver.md +3 -6
  116. package/docs/v1/libs/TinyHtml.md +0 -29
  117. package/docs/v1/libs/TinyMediaPlayer.md +100 -0
  118. package/docs/v1/libs/TinyRadioFm.md +141 -0
  119. package/docs/v1/libs/TinySmartScroller.md +3 -3
  120. package/package.json +40 -22
@@ -1,7 +1,5 @@
1
1
  /**
2
2
  * @typedef {Object} DragAndDropOptions
3
- * @property {HTMLElement} [target=document.body] - The DOM element where drag listeners will be attached. Defaults to `document.body` if `fullscreen` is true or no target is provided.
4
- * @property {boolean} [fullscreen=true] - If true, listeners are attached to the entire page (`document.body`). If false, the `target` must be specified.
5
3
  * @property {string} [hoverClass="dnd-hover"] - CSS class applied to the target element while files are being dragged over it.
6
4
  * @property {(files: FileList, event: DragEvent) => void} [onDrop] - Callback function executed when files are dropped onto the target.
7
5
  * @property {(event: DragEvent) => void} [onEnter] - Optional callback triggered when dragging enters the target area.
@@ -14,12 +12,11 @@
14
12
  * It handles the drag lifecycle (enter, over, leave, drop) and provides hooks for developers to handle file uploads or UI changes.
15
13
  *
16
14
  * @class
15
+ * @template {HTMLElement} HTMLTarget
17
16
  */
18
17
  class TinyDragDropDetector {
19
- /** @type {HTMLElement} */
18
+ /** @type {HTMLTarget} */
20
19
  #target;
21
- /** @type {boolean} */
22
- #fullscreen;
23
20
  /** @type {string} */
24
21
  #hoverClass;
25
22
  /** @type {(files: FileList, event: DragEvent) => void} */
@@ -35,22 +32,18 @@ class TinyDragDropDetector {
35
32
  /**
36
33
  * Creates a new instance of TinyDragDropDetector to handle drag-and-drop file detection.
37
34
  *
38
- * @param {DragAndDropOptions} [options={}] - Configuration options for the detector.
35
+ * @param {HTMLTarget} target - The DOM element where drag listeners will be attached.
36
+ * @param {DragAndDropOptions} options - Configuration options for the detector.
39
37
  * @throws {TypeError} If `target` is not an HTMLElement.
40
- * @throws {TypeError} If `fullscreen` is not a boolean.
41
38
  * @throws {TypeError} If `hoverClass` is not a string.
42
39
  * @throws {TypeError} If `onDrop` is defined but not a function.
43
40
  * @throws {TypeError} If `onEnter` is defined but not a function.
44
41
  * @throws {TypeError} If `onLeave` is defined but not a function.
45
42
  */
46
- constructor(options = {}) {
47
- const { target, fullscreen = true, hoverClass = 'dnd-hover', onDrop, onEnter, onLeave, } = options;
48
- // Validate fullscreen
49
- if (typeof fullscreen !== 'boolean')
50
- throw new TypeError('The "fullscreen" option must be a boolean.');
43
+ constructor(target, options) {
44
+ const { hoverClass = 'dnd-hover', onDrop, onEnter, onLeave } = options;
51
45
  // Validate target
52
- const resolvedTarget = fullscreen ? document.body : target || document.body;
53
- if (!(resolvedTarget instanceof HTMLElement))
46
+ if (!(target instanceof HTMLElement))
54
47
  throw new TypeError('The "target" option must be an instance of HTMLElement.');
55
48
  // Validate hoverClass
56
49
  if (typeof hoverClass !== 'string')
@@ -65,8 +58,7 @@ class TinyDragDropDetector {
65
58
  if (typeof onLeave !== 'function')
66
59
  throw new TypeError('The "onLeave" option must be a function.');
67
60
  // Store properties
68
- this.#target = resolvedTarget;
69
- this.#fullscreen = fullscreen;
61
+ this.#target = target;
70
62
  this.#hoverClass = hoverClass;
71
63
  this.#onDropCallback = onDrop || (() => { });
72
64
  this.#onEnterCallback = onEnter;
@@ -82,7 +74,7 @@ class TinyDragDropDetector {
82
74
  }
83
75
  /**
84
76
  * Returns the current target DOM element where the listeners are attached.
85
- * @returns {HTMLElement}
77
+ * @returns {HTMLTarget}
86
78
  */
87
79
  getTarget() {
88
80
  return this.#target;
@@ -94,13 +86,6 @@ class TinyDragDropDetector {
94
86
  getHoverClass() {
95
87
  return this.#hoverClass;
96
88
  }
97
- /**
98
- * Indicates whether the detector is operating in fullscreen mode.
99
- * @returns {boolean}
100
- */
101
- isFullScreen() {
102
- return this.#fullscreen;
103
- }
104
89
  /**
105
90
  * Returns whether a drag operation is currently active over the target.
106
91
  * @returns {boolean}
@@ -16,6 +16,7 @@ var objChecker = require('../basics/objChecker.cjs');
16
16
  * TinyDragger enables drag-and-drop functionality for a DOM element.
17
17
  * It supports jail boundaries, optional collision detection, vibration feedback,
18
18
  * automatic reverting, proxy dragging, and event dispatching.
19
+ * @template {HTMLElement} HTMLTarget
19
20
  */
20
21
  class TinyDragger {
21
22
  static Utils = { ...collision, TinyHtml };
@@ -49,7 +50,7 @@ class TinyDragger {
49
50
  /** @type {HTMLElement|null} */
50
51
  #jail = null;
51
52
 
52
- /** @type {HTMLElement} */
53
+ /** @type {HTMLTarget} */
53
54
  #target;
54
55
 
55
56
  #dragHiddenClass = 'drag-hidden';
@@ -63,7 +64,7 @@ class TinyDragger {
63
64
  /** @typedef {(event: TouchEvent) => void} TouchDragEvent */
64
65
 
65
66
  /**
66
- * @param {HTMLElement|TinyHtml<any>} targetElement - The element to make draggable.
67
+ * @param {HTMLTarget} targetElement - The element to make draggable.
67
68
  * @param {Object} [options={}] - Configuration options.
68
69
  * @param {HTMLElement} [options.jail] - Optional container to restrict dragging within.
69
70
  * @param {boolean} [options.mirrorElem=true] - Use a visual clone instead of dragging the original element.
@@ -83,11 +84,10 @@ class TinyDragger {
83
84
  * @throws {Error} If any option has an invalid type.
84
85
  */
85
86
  constructor(targetElement, options = {}) {
86
- const targetElem = !(targetElement instanceof TinyHtml) ? targetElement : targetElement.get(0);
87
- if (!(targetElem instanceof HTMLElement))
87
+ if (!(targetElement instanceof HTMLElement))
88
88
  throw new Error('TinyDragger requires a valid target HTMLElement to initialize.');
89
89
 
90
- this.#target = targetElem;
90
+ this.#target = targetElement;
91
91
 
92
92
  // === Validations ===
93
93
  if (options.jail !== undefined && !(options.jail instanceof HTMLElement))
@@ -28,8 +28,9 @@ export type VibrationPatterns = {
28
28
  * TinyDragger enables drag-and-drop functionality for a DOM element.
29
29
  * It supports jail boundaries, optional collision detection, vibration feedback,
30
30
  * automatic reverting, proxy dragging, and event dispatching.
31
+ * @template {HTMLElement} HTMLTarget
31
32
  */
32
- declare class TinyDragger {
33
+ declare class TinyDragger<HTMLTarget extends HTMLElement> {
33
34
  static Utils: {
34
35
  TinyHtml: typeof TinyHtml;
35
36
  getElsRelativeCenterOffset(rect1: ObjRect, rect2: ObjRect): {
@@ -82,7 +83,7 @@ declare class TinyDragger {
82
83
  };
83
84
  /** @typedef {(event: TouchEvent) => void} TouchDragEvent */
84
85
  /**
85
- * @param {HTMLElement|TinyHtml<any>} targetElement - The element to make draggable.
86
+ * @param {HTMLTarget} targetElement - The element to make draggable.
86
87
  * @param {Object} [options={}] - Configuration options.
87
88
  * @param {HTMLElement} [options.jail] - Optional container to restrict dragging within.
88
89
  * @param {boolean} [options.mirrorElem=true] - Use a visual clone instead of dragging the original element.
@@ -101,7 +102,7 @@ declare class TinyDragger {
101
102
  * @param {string} [options.classHidden='drag-hidden'] - CSS class to hide original element during dragging.
102
103
  * @throws {Error} If any option has an invalid type.
103
104
  */
104
- constructor(targetElement: HTMLElement | TinyHtml<any>, options?: {
105
+ constructor(targetElement: HTMLTarget, options?: {
105
106
  jail?: HTMLElement | undefined;
106
107
  mirrorElem?: boolean | undefined;
107
108
  defaultZIndex?: number | undefined;
@@ -12,6 +12,7 @@ import { isJsonObject } from '../basics/objChecker.mjs';
12
12
  * TinyDragger enables drag-and-drop functionality for a DOM element.
13
13
  * It supports jail boundaries, optional collision detection, vibration feedback,
14
14
  * automatic reverting, proxy dragging, and event dispatching.
15
+ * @template {HTMLElement} HTMLTarget
15
16
  */
16
17
  class TinyDragger {
17
18
  static Utils = { ...TinyCollision, TinyHtml };
@@ -36,7 +37,7 @@ class TinyDragger {
36
37
  #vibration = { start: false, end: false, collide: false, move: false };
37
38
  /** @type {HTMLElement|null} */
38
39
  #jail = null;
39
- /** @type {HTMLElement} */
40
+ /** @type {HTMLTarget} */
40
41
  #target;
41
42
  #dragHiddenClass = 'drag-hidden';
42
43
  #classDragging = 'dragging';
@@ -47,7 +48,7 @@ class TinyDragger {
47
48
  #defaultZIndex = 9999;
48
49
  /** @typedef {(event: TouchEvent) => void} TouchDragEvent */
49
50
  /**
50
- * @param {HTMLElement|TinyHtml<any>} targetElement - The element to make draggable.
51
+ * @param {HTMLTarget} targetElement - The element to make draggable.
51
52
  * @param {Object} [options={}] - Configuration options.
52
53
  * @param {HTMLElement} [options.jail] - Optional container to restrict dragging within.
53
54
  * @param {boolean} [options.mirrorElem=true] - Use a visual clone instead of dragging the original element.
@@ -67,10 +68,9 @@ class TinyDragger {
67
68
  * @throws {Error} If any option has an invalid type.
68
69
  */
69
70
  constructor(targetElement, options = {}) {
70
- const targetElem = !(targetElement instanceof TinyHtml) ? targetElement : targetElement.get(0);
71
- if (!(targetElem instanceof HTMLElement))
71
+ if (!(targetElement instanceof HTMLElement))
72
72
  throw new Error('TinyDragger requires a valid target HTMLElement to initialize.');
73
- this.#target = targetElem;
73
+ this.#target = targetElement;
74
74
  // === Validations ===
75
75
  if (options.jail !== undefined && !(options.jail instanceof HTMLElement))
76
76
  throw new Error('The "jail" option must be an HTMLElement if provided.');
@@ -16,35 +16,20 @@
16
16
  * A utility class for tracking DOM element mutations.
17
17
  * It leverages the native MutationObserver API, providing a higher-level abstraction
18
18
  * with a system of configurable detectors that can dispatch custom events or run custom logic.
19
+ * @template {Element} HTMLElement
19
20
  */
20
21
  class TinyElementObserver {
21
- /** @type {Element|undefined} */
22
+ /** @type {HTMLElement} */
22
23
  #el;
23
24
 
24
25
  /**
25
26
  * Get the current element being observed.
26
- * @returns {Element|undefined} The DOM element being tracked, or `undefined` if none is set.
27
+ * @returns {HTMLElement} The DOM element being tracked, or `undefined` if none is set.
27
28
  */
28
29
  get el() {
29
30
  return this.#el;
30
31
  }
31
32
 
32
- /**
33
- * Set the target element to be observed.
34
- * Can only be set once.
35
- *
36
- * @param {Element|undefined} el - The DOM element to observe.
37
- * @throws {Error} If the element is already defined.
38
- * @throws {TypeError} If the provided value is not an Element.
39
- */
40
- set el(el) {
41
- if (this.#el)
42
- throw new Error('The observed element has already been set and cannot be reassigned.');
43
- if (typeof el !== 'undefined' && !(el instanceof Element))
44
- throw new TypeError('The observed element must be a valid DOM Element.');
45
- this.#el = el;
46
- }
47
-
48
33
  /**
49
34
  * Configuration settings for the MutationObserver instance.
50
35
  *
@@ -140,13 +125,13 @@ class TinyElementObserver {
140
125
  /**
141
126
  * Create a new TinyElementObserver instance.
142
127
  *
128
+ * @param {HTMLElement} el - Set the target element to be observed.
143
129
  * @param {Object} [settings={}] - Configuration object.
144
- * @param {Element} [settings.el] - Optional DOM element to observe from the start.
145
130
  * @param {Array<[string, ElementDetectorsFn]>} [settings.initDetectors=[]] - Optional initial detectors to register.
146
131
  * @param {MutationObserverInit} [settings.initCfg] - Optional MutationObserver configuration.
147
132
  */
148
- constructor({ el, initDetectors = [], initCfg = {} } = {}) {
149
- this.el = el;
133
+ constructor(el, { initDetectors = [], initCfg = {} } = {}) {
134
+ this.#el = el;
150
135
  if (initDetectors.length) this.detectors = initDetectors;
151
136
  if (initCfg) this.settings = initCfg;
152
137
  }
@@ -18,35 +18,26 @@ export type ElementDetectorsFn = (mutation: MutationRecord, index: number, mutat
18
18
  * A utility class for tracking DOM element mutations.
19
19
  * It leverages the native MutationObserver API, providing a higher-level abstraction
20
20
  * with a system of configurable detectors that can dispatch custom events or run custom logic.
21
+ * @template {Element} HTMLElement
21
22
  */
22
- declare class TinyElementObserver {
23
+ declare class TinyElementObserver<HTMLElement extends Element> {
23
24
  /**
24
25
  * Create a new TinyElementObserver instance.
25
26
  *
27
+ * @param {HTMLElement} el - Set the target element to be observed.
26
28
  * @param {Object} [settings={}] - Configuration object.
27
- * @param {Element} [settings.el] - Optional DOM element to observe from the start.
28
29
  * @param {Array<[string, ElementDetectorsFn]>} [settings.initDetectors=[]] - Optional initial detectors to register.
29
30
  * @param {MutationObserverInit} [settings.initCfg] - Optional MutationObserver configuration.
30
31
  */
31
- constructor({ el, initDetectors, initCfg }?: {
32
- el?: Element | undefined;
32
+ constructor(el: HTMLElement, { initDetectors, initCfg }?: {
33
33
  initDetectors?: [string, ElementDetectorsFn][] | undefined;
34
34
  initCfg?: MutationObserverInit | undefined;
35
35
  });
36
- /**
37
- * Set the target element to be observed.
38
- * Can only be set once.
39
- *
40
- * @param {Element|undefined} el - The DOM element to observe.
41
- * @throws {Error} If the element is already defined.
42
- * @throws {TypeError} If the provided value is not an Element.
43
- */
44
- set el(el: Element | undefined);
45
36
  /**
46
37
  * Get the current element being observed.
47
- * @returns {Element|undefined} The DOM element being tracked, or `undefined` if none is set.
38
+ * @returns {HTMLElement} The DOM element being tracked, or `undefined` if none is set.
48
39
  */
49
- get el(): Element | undefined;
40
+ get el(): HTMLElement;
50
41
  /**
51
42
  * Set the observer settings.
52
43
  * @param {MutationObserverInit} settings
@@ -13,32 +13,18 @@
13
13
  * A utility class for tracking DOM element mutations.
14
14
  * It leverages the native MutationObserver API, providing a higher-level abstraction
15
15
  * with a system of configurable detectors that can dispatch custom events or run custom logic.
16
+ * @template {Element} HTMLElement
16
17
  */
17
18
  class TinyElementObserver {
18
- /** @type {Element|undefined} */
19
+ /** @type {HTMLElement} */
19
20
  #el;
20
21
  /**
21
22
  * Get the current element being observed.
22
- * @returns {Element|undefined} The DOM element being tracked, or `undefined` if none is set.
23
+ * @returns {HTMLElement} The DOM element being tracked, or `undefined` if none is set.
23
24
  */
24
25
  get el() {
25
26
  return this.#el;
26
27
  }
27
- /**
28
- * Set the target element to be observed.
29
- * Can only be set once.
30
- *
31
- * @param {Element|undefined} el - The DOM element to observe.
32
- * @throws {Error} If the element is already defined.
33
- * @throws {TypeError} If the provided value is not an Element.
34
- */
35
- set el(el) {
36
- if (this.#el)
37
- throw new Error('The observed element has already been set and cannot be reassigned.');
38
- if (typeof el !== 'undefined' && !(el instanceof Element))
39
- throw new TypeError('The observed element must be a valid DOM Element.');
40
- this.#el = el;
41
- }
42
28
  /**
43
29
  * Configuration settings for the MutationObserver instance.
44
30
  *
@@ -125,13 +111,13 @@ class TinyElementObserver {
125
111
  /**
126
112
  * Create a new TinyElementObserver instance.
127
113
  *
114
+ * @param {HTMLElement} el - Set the target element to be observed.
128
115
  * @param {Object} [settings={}] - Configuration object.
129
- * @param {Element} [settings.el] - Optional DOM element to observe from the start.
130
116
  * @param {Array<[string, ElementDetectorsFn]>} [settings.initDetectors=[]] - Optional initial detectors to register.
131
117
  * @param {MutationObserverInit} [settings.initCfg] - Optional MutationObserver configuration.
132
118
  */
133
- constructor({ el, initDetectors = [], initCfg = {} } = {}) {
134
- this.el = el;
119
+ constructor(el, { initDetectors = [], initCfg = {} } = {}) {
120
+ this.#el = el;
135
121
  if (initDetectors.length)
136
122
  this.detectors = initDetectors;
137
123
  if (initCfg)
@@ -1267,12 +1267,10 @@ class TinyGamepad {
1267
1267
  mapInput(logicalName, physicalInput) {
1268
1268
  if (typeof logicalName !== 'string' || !logicalName.trim())
1269
1269
  throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
1270
- if (
1271
- !(
1272
- typeof physicalInput === 'string' ||
1273
- (Array.isArray(physicalInput) && physicalInput.every((p) => typeof p === 'string'))
1274
- )
1275
- )
1270
+ if (!(
1271
+ typeof physicalInput === 'string' ||
1272
+ (Array.isArray(physicalInput) && physicalInput.every((p) => typeof p === 'string'))
1273
+ ))
1276
1274
  throw new TypeError(
1277
1275
  `Invalid "physicalInput": expected string or array of strings, got ${JSON.stringify(physicalInput)}`,
1278
1276
  );
@@ -493,7 +493,7 @@ export type ExportedConfig = {
493
493
  */
494
494
  declare class TinyGamepad {
495
495
  /** @type {Record<string, string>} */
496
- static "__#private@#specialMap": Record<string, string>;
496
+ static #specialMap: Record<string, string>;
497
497
  /**
498
498
  * Add or update a special key mapping.
499
499
  * @param {string} char - The character to map.
@@ -8,7 +8,7 @@ export default TinyHtmlIcon;
8
8
  */
9
9
  declare class TinyHtmlIcon extends TinyHtmlTemplate<HTMLElement> {
10
10
  /** @type {string} */
11
- static "__#private@#defaultTag": string;
11
+ static #defaultTag: string;
12
12
  /** @param {string} value */
13
13
  static set defaultTag(value: string);
14
14
  /** @returns {string} */
@@ -34,7 +34,7 @@ declare class TinyHtmlTemplate<TinyHtmlT extends Element> extends TinyHtml<TinyH
34
34
  * @param {ClassSetter} value
35
35
  * @returns {Set<string>}
36
36
  */
37
- static "__#private@#normalizeClasses"(value: ClassSetter): Set<string>;
37
+ static #normalizeClasses(value: ClassSetter): Set<string>;
38
38
  /**
39
39
  * Creates a new TinyHtmlTemplate instance.
40
40
  * @param {TinyHtmlT} tag - The HTML tag name to create (e.g., 'div', 'span').
@@ -57,7 +57,7 @@ declare class TinyHtmlTextarea extends TinyHtmlTemplate<HTMLTextAreaElement> {
57
57
  name?: string | undefined;
58
58
  readonly?: boolean | undefined;
59
59
  required?: boolean | undefined;
60
- spellcheck?: boolean | "false" | "true" | "default" | undefined;
60
+ spellcheck?: boolean | "false" | "default" | "true" | undefined;
61
61
  wrap?: "off" | "soft" | "hard" | undefined;
62
62
  tags?: string | string[] | Set<string> | undefined;
63
63
  mainClass?: string | undefined;
@@ -4,7 +4,7 @@ export default TinyHtmlElems;
4
4
  * @beta
5
5
  */
6
6
  declare class TinyHtmlElems {
7
- static "__#private@#list": (typeof TinyHtmlTemplate | typeof TinyHtmlAnchor | typeof TinyHtmlButton | typeof TinyHtmlCanvas | typeof TinyHtmlDatalist | typeof TinyHtmlEmbed | typeof TinyHtmlForm | typeof TinyHtmlIcon | typeof TinyHtmlIframe | typeof TinyHtmlImage | typeof TinyHtmlInput | typeof TinyHtmlLink | typeof TinyHtmlMedia | typeof TinyHtmlScript | typeof TinyHtmlSelect | typeof TinyHtmlStyle | typeof TinyHtmlTextarea | typeof TinyHtmlResetInput | typeof TinyHtmlNumberInput | typeof TinyHtmlFileInput | typeof TinyHtmlHiddenInput | typeof TinyHtmlImageInput | typeof TinyHtmlAudio | typeof TinyHtmlObject | typeof TinyHtmlSource)[];
7
+ static #list: (typeof TinyHtmlTemplate | typeof TinyHtmlAnchor | typeof TinyHtmlButton | typeof TinyHtmlCanvas | typeof TinyHtmlDatalist | typeof TinyHtmlEmbed | typeof TinyHtmlForm | typeof TinyHtmlIcon | typeof TinyHtmlIframe | typeof TinyHtmlImage | typeof TinyHtmlInput | typeof TinyHtmlLink | typeof TinyHtmlMedia | typeof TinyHtmlScript | typeof TinyHtmlSelect | typeof TinyHtmlStyle | typeof TinyHtmlTextarea | typeof TinyHtmlResetInput | typeof TinyHtmlNumberInput | typeof TinyHtmlFileInput | typeof TinyHtmlHiddenInput | typeof TinyHtmlImageInput | typeof TinyHtmlAudio | typeof TinyHtmlObject | typeof TinyHtmlSource)[];
8
8
  static get list(): (typeof TinyHtmlTemplate | typeof TinyHtmlAnchor | typeof TinyHtmlButton | typeof TinyHtmlCanvas | typeof TinyHtmlDatalist | typeof TinyHtmlEmbed | typeof TinyHtmlForm | typeof TinyHtmlIcon | typeof TinyHtmlIframe | typeof TinyHtmlImage | typeof TinyHtmlInput | typeof TinyHtmlLink | typeof TinyHtmlMedia | typeof TinyHtmlScript | typeof TinyHtmlSelect | typeof TinyHtmlStyle | typeof TinyHtmlTextarea | typeof TinyHtmlResetInput | typeof TinyHtmlNumberInput | typeof TinyHtmlFileInput | typeof TinyHtmlHiddenInput | typeof TinyHtmlImageInput | typeof TinyHtmlAudio | typeof TinyHtmlObject | typeof TinyHtmlSource)[];
9
9
  static ButtonInput: typeof TinyHtmlButtonInput;
10
10
  static ResetInput: typeof TinyHtmlResetInput;
@@ -481,105 +481,79 @@ class TinyHtml {
481
481
 
482
482
  /////////////////////////////////////////////////////////////////////
483
483
 
484
- /**
485
- * Flag to determine if element observer should start automatically.
486
- * @type {boolean}
487
- */
488
- static #autoStartElemObserver = true;
489
-
490
- /**
491
- * Get the auto-start flag for the observer.
492
- * @returns {boolean}
493
- */
494
- static get autoStartElemObserver() {
495
- return TinyHtml.#autoStartElemObserver;
496
- }
497
-
498
- /**
499
- * Set the auto-start flag for the observer.
500
- * @param {boolean} value
501
- */
502
- static set autoStartElemObserver(value) {
503
- if (typeof value !== 'boolean') throw new TypeError('autoStartElemObserver must be a boolean.');
504
- TinyHtml.#autoStartElemObserver = value;
505
- }
506
-
507
- /** @type {TinyElementObserver} */
508
- static #tinyObserver = new TinyElementObserver({
509
- el:
510
- typeof window !== 'undefined' && typeof window.document !== 'undefined'
511
- ? window.document.documentElement
512
- : undefined,
513
- initDetectors: [
514
- // Style Detector
515
- [
516
- 'tinyStyleEvent',
517
- (mutation) => {
518
- if (
519
- mutation.type !== 'attributes' ||
520
- mutation.attributeName !== 'style' ||
521
- !(mutation.target instanceof HTMLElement)
522
- )
523
- return;
524
- const oldVal = mutation.oldValue || '';
525
- const newVal = mutation.target.getAttribute('style') || '';
526
-
527
- const oldStyles = TinyHtml.parseStyle(oldVal);
528
- const newStyles = TinyHtml.parseStyle(newVal);
529
-
530
- const changes = text.diffStrings(oldStyles, newStyles);
531
-
532
- if (
533
- Object.keys(changes.added).length ||
534
- Object.keys(changes.removed).length ||
535
- Object.keys(changes.modified).length
536
- ) {
537
- mutation.target.dispatchEvent(
538
- new CustomEvent('tinyhtml.stylechanged', {
539
- detail: changes,
540
- }),
541
- );
542
- }
543
- },
544
- ],
545
-
546
- // Class Detector
547
- [
548
- 'tinyClassEvent',
549
- (mutation) => {
550
- if (
551
- mutation.type !== 'attributes' ||
552
- mutation.attributeName !== 'class' ||
553
- !(mutation.target instanceof HTMLElement)
554
- )
555
- return;
556
- const oldVal = mutation.oldValue || '';
557
- const newVal = mutation.target.className || '';
558
-
559
- const oldClasses = oldVal.split(/\s+/).filter(Boolean);
560
- const newClasses = newVal.split(/\s+/).filter(Boolean);
561
-
562
- const changes = array.diffArrayList(oldClasses, newClasses);
563
-
564
- if (changes.added.length || changes.removed.length) {
565
- mutation.target.dispatchEvent(
566
- new CustomEvent('tinyhtml.classchanged', {
567
- detail: changes,
568
- }),
569
- );
570
- }
571
- },
572
- ],
573
- ],
574
- initCfg: {
575
- attributeOldValue: true,
576
- attributes: true,
577
- subtree: true,
578
- attributeFilter: ['style', 'class'],
579
- },
580
- });
484
+ static #tinyObserver =
485
+ typeof window !== 'undefined' && typeof window.document !== 'undefined'
486
+ ? new TinyElementObserver(window.document.documentElement, {
487
+ initDetectors: [
488
+ // Style Detector
489
+ [
490
+ 'tinyStyleEvent',
491
+ (mutation) => {
492
+ if (
493
+ mutation.type !== 'attributes' ||
494
+ mutation.attributeName !== 'style' ||
495
+ !(mutation.target instanceof HTMLElement)
496
+ )
497
+ return;
498
+ const oldVal = mutation.oldValue || '';
499
+ const newVal = mutation.target.getAttribute('style') || '';
500
+
501
+ const oldStyles = TinyHtml.parseStyle(oldVal);
502
+ const newStyles = TinyHtml.parseStyle(newVal);
503
+
504
+ const changes = text.diffStrings(oldStyles, newStyles);
505
+
506
+ if (
507
+ Object.keys(changes.added).length ||
508
+ Object.keys(changes.removed).length ||
509
+ Object.keys(changes.modified).length
510
+ ) {
511
+ mutation.target.dispatchEvent(
512
+ new CustomEvent('tinyhtml.stylechanged', {
513
+ detail: changes,
514
+ }),
515
+ );
516
+ }
517
+ },
518
+ ],
519
+
520
+ // Class Detector
521
+ [
522
+ 'tinyClassEvent',
523
+ (mutation) => {
524
+ if (
525
+ mutation.type !== 'attributes' ||
526
+ mutation.attributeName !== 'class' ||
527
+ !(mutation.target instanceof HTMLElement)
528
+ )
529
+ return;
530
+ const oldVal = mutation.oldValue || '';
531
+ const newVal = mutation.target.className || '';
532
+
533
+ const oldClasses = oldVal.split(/\s+/).filter(Boolean);
534
+ const newClasses = newVal.split(/\s+/).filter(Boolean);
535
+
536
+ const changes = array.diffArrayList(oldClasses, newClasses);
537
+
538
+ if (changes.added.length || changes.removed.length) {
539
+ mutation.target.dispatchEvent(
540
+ new CustomEvent('tinyhtml.classchanged', {
541
+ detail: changes,
542
+ }),
543
+ );
544
+ }
545
+ },
546
+ ],
547
+ ],
548
+ initCfg: {
549
+ attributeOldValue: true,
550
+ attributes: true,
551
+ subtree: true,
552
+ attributeFilter: ['style', 'class'],
553
+ },
554
+ })
555
+ : undefined;
581
556
 
582
- /** @returns {TinyElementObserver} */
583
557
  static get tinyObserver() {
584
558
  return TinyHtml.#tinyObserver;
585
559
  }