tiny-essentials 1.22.5 → 1.22.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.
Files changed (70) hide show
  1. package/changelog/1/1/0.md +1 -0
  2. package/changelog/1/10/0.md +19 -0
  3. package/changelog/1/10/2.md +23 -0
  4. package/changelog/1/11/0.md +66 -0
  5. package/changelog/1/12/0.md +54 -0
  6. package/changelog/1/12/1.md +37 -0
  7. package/changelog/1/12/2.md +29 -0
  8. package/changelog/1/13/0.md +41 -0
  9. package/changelog/1/13/1.md +7 -0
  10. package/changelog/1/13/2.md +13 -0
  11. package/changelog/1/14/0.md +33 -0
  12. package/changelog/1/15/0.md +39 -0
  13. package/changelog/1/16/0.md +42 -0
  14. package/changelog/1/16/1.md +43 -0
  15. package/changelog/1/16/2.md +29 -0
  16. package/changelog/1/17/0.md +28 -0
  17. package/changelog/1/17/1.md +40 -0
  18. package/changelog/1/18/0.md +43 -0
  19. package/changelog/1/18/1.md +12 -0
  20. package/changelog/1/19/1.md +21 -0
  21. package/changelog/1/19/2.md +23 -0
  22. package/changelog/1/19/3.md +15 -0
  23. package/changelog/1/2/0.md +5 -0
  24. package/changelog/1/2/1.md +5 -0
  25. package/changelog/1/20/0.md +9 -0
  26. package/changelog/1/20/1.md +40 -0
  27. package/changelog/1/20/2.md +22 -0
  28. package/changelog/1/20/3.md +39 -0
  29. package/changelog/1/21/0.md +23 -0
  30. package/changelog/1/21/1.md +12 -0
  31. package/changelog/1/21/10.md +23 -0
  32. package/changelog/1/21/2.md +9 -0
  33. package/changelog/1/21/3.md +9 -0
  34. package/changelog/1/21/4.md +9 -0
  35. package/changelog/1/21/6.md +23 -0
  36. package/changelog/1/21/7.md +16 -0
  37. package/changelog/1/21/8.md +5 -0
  38. package/changelog/1/21/9.md +17 -0
  39. package/changelog/1/22/1.md +28 -0
  40. package/changelog/1/22/2.md +17 -0
  41. package/changelog/1/22/3.md +11 -0
  42. package/changelog/1/22/4.md +35 -0
  43. package/changelog/1/22/5.md +23 -0
  44. package/changelog/1/22/6.md +25 -0
  45. package/changelog/1/3/1.md +4 -0
  46. package/changelog/1/3/2.md +2 -0
  47. package/changelog/1/4/0.md +5 -0
  48. package/changelog/1/5/0.md +4 -0
  49. package/changelog/1/5/1.md +2 -0
  50. package/changelog/1/6/0.md +6 -0
  51. package/changelog/1/7/0.md +3 -0
  52. package/changelog/1/7/1.md +3 -0
  53. package/changelog/1/8/0.md +3 -0
  54. package/changelog/1/8/1.md +2 -0
  55. package/changelog/1/8/2.md +2 -0
  56. package/changelog/1/8/3.md +3 -0
  57. package/changelog/1/8/4.md +2 -0
  58. package/changelog/1/8/5.md +6 -0
  59. package/changelog/1/9/0.md +27 -0
  60. package/changelog/1/9/1.md +5 -0
  61. package/changelog/1/9/2.md +14 -0
  62. package/dist/v1/TinyDragger.min.js +1 -1
  63. package/dist/v1/TinyEssentials.min.js +1 -1
  64. package/dist/v1/TinyHtml.min.js +1 -1
  65. package/dist/v1/TinySmartScroller.min.js +1 -1
  66. package/dist/v1/TinyUploadClicker.min.js +1 -1
  67. package/dist/v1/libs/TinyHtml.cjs +106 -6
  68. package/dist/v1/libs/TinyHtml.d.mts +36 -0
  69. package/dist/v1/libs/TinyHtml.mjs +102 -6
  70. package/package.json +1 -1
@@ -339,6 +339,94 @@ class TinyHtml {
339
339
 
340
340
  static Utils = { ...collision };
341
341
 
342
+ /**
343
+ * Controls whether TinyHtml emits detailed debug output to the console.
344
+ * When enabled, helper methods print structured diagnostics for easier troubleshooting.
345
+ * @type {boolean}
346
+ */
347
+ static #elemDebug = false;
348
+
349
+ /**
350
+ * Gets whether debug output is enabled.
351
+ * @returns {boolean} True if debug output is enabled; otherwise, false.
352
+ */
353
+ static get elemDebug() {
354
+ return TinyHtml.#elemDebug;
355
+ }
356
+
357
+ /**
358
+ * Enables or disables debug output.
359
+ * @param {boolean} value True to enable debug output; false to disable.
360
+ * @throws {TypeError} Thrown if the provided value is not a boolean.
361
+ * @returns {void}
362
+ */
363
+ static set elemDebug(value) {
364
+ if (typeof value !== 'boolean') throw new TypeError('Expected a boolean value for elemDebug');
365
+ TinyHtml.#elemDebug = value;
366
+ }
367
+
368
+ /**
369
+ * Logs a standardized debug error for element validation, including a console.table
370
+ * with the involved elements. Use this when an element argument is invalid, unexpected,
371
+ * or fails a guard/validation.
372
+ *
373
+ * The output includes:
374
+ * - A concise error header
375
+ * - A stack trace (when supported)
376
+ * - A table of elements (index, typeof, constructor, summary, value)
377
+ * - The specific problematic element, if provided
378
+ *
379
+ * @param {(ConstructorElValues | EventTarget | TinyElement | null)[]} elems
380
+ * A list of elements participating in the operation (may include nulls).
381
+ * @param {ConstructorElValues | EventTarget | TinyElement | null} [elem]
382
+ * The specific element that triggered the error, if available.
383
+ * @returns {void}
384
+ */
385
+ static _debugElemError(elems, elem) {
386
+ if (!TinyHtml.#elemDebug) return;
387
+ const header = '[TinyHtml Debug] Element validation error';
388
+
389
+ console.groupCollapsed(`${header}${elem ? ' — details below' : ''}`);
390
+ console.error(header);
391
+
392
+ // Stack trace for call-site visibility
393
+ if (typeof Error !== 'undefined' && typeof Error.captureStackTrace === 'function') {
394
+ const err = new Error(header);
395
+ Error.captureStackTrace(err, TinyHtml._debugElemError);
396
+ console.error(err.stack);
397
+ } else {
398
+ console.trace(header);
399
+ }
400
+
401
+ // Tabular overview of provided elements
402
+ if (Array.isArray(elems)) {
403
+ const rows = elems.map((el, index) => {
404
+ const typeOf = el === null ? 'null' : typeof el;
405
+ const ctor = el?.constructor?.name ?? (el === null ? 'null' : 'primitive');
406
+ const isDomEl = typeof Element !== 'undefined' && el instanceof Element;
407
+ const summary = isDomEl
408
+ ? `${el.tagName?.toLowerCase?.() ?? 'element'}#${el.id || ''}.${String(el.className || '')
409
+ .trim()
410
+ .replace(/\s+/g, '.')}`
411
+ : el && typeof el === 'object' && 'nodeType' in el
412
+ ? `nodeType:${/** @type {any} */ (el).nodeType}`
413
+ : '';
414
+ return { index, typeOf, constructor: ctor, summary, value: el };
415
+ });
416
+ console.table(rows);
417
+ } else {
418
+ console.warn('[TinyHtml Debug] "elems" is not an array:', elems);
419
+ }
420
+
421
+ // Highlight the specific problematic element, if any
422
+ if (arguments.length > 1) {
423
+ console.error('[TinyHtml Debug] Problematic element:', elem);
424
+ if (elem && typeof elem === 'object') console.dir(elem);
425
+ }
426
+
427
+ console.groupEnd();
428
+ }
429
+
342
430
  /**
343
431
  * Parse inline styles into an object.
344
432
  * @param {string} styleText
@@ -943,8 +1031,10 @@ class TinyHtml {
943
1031
  !(this.#el[index] instanceof Window) &&
944
1032
  !(this.#el[index] instanceof Document) &&
945
1033
  !(this.#el[index] instanceof Text)
946
- )
1034
+ ) {
1035
+ TinyHtml._debugElemError([...this.#el], this.#el[index]);
947
1036
  throw new Error(`[TinyHtml] Invalid Element in ${where}().`);
1037
+ }
948
1038
  return this.#el[index];
949
1039
  }
950
1040
 
@@ -964,8 +1054,10 @@ class TinyHtml {
964
1054
  el instanceof Document ||
965
1055
  el instanceof Text,
966
1056
  )
967
- )
1057
+ ) {
1058
+ TinyHtml._debugElemError([...this.#el]);
968
1059
  throw new Error(`[TinyHtml] Invalid Element in ${where}().`);
1060
+ }
969
1061
  return [...this.#el];
970
1062
  }
971
1063
 
@@ -998,10 +1090,12 @@ class TinyHtml {
998
1090
  break;
999
1091
  }
1000
1092
  }
1001
- if (!allowed)
1093
+ if (!allowed) {
1094
+ TinyHtml._debugElemError([...item], result);
1002
1095
  throw new Error(
1003
1096
  `[TinyHtml] Invalid element of the list "${elemName.join(',')}" in ${where}().`,
1004
1097
  );
1098
+ }
1005
1099
  results.push(result);
1006
1100
  return result;
1007
1101
  }),
@@ -1029,10 +1123,12 @@ class TinyHtml {
1029
1123
  const checkElement = (item) => {
1030
1124
  const elem = item[0];
1031
1125
  const result = elem instanceof TinyHtml ? elem._getElements(where) : [elem];
1032
- if (result.length > 1)
1126
+ if (result.length > 1) {
1127
+ TinyHtml._debugElemError([...item]);
1033
1128
  throw new Error(
1034
1129
  `[TinyHtml] Invalid element amount in ${where}() (Received ${result.length}/1).`,
1035
1130
  );
1131
+ }
1036
1132
 
1037
1133
  let allowed = false;
1038
1134
  for (const TheTinyElement of TheTinyElements) {
@@ -1047,17 +1143,21 @@ class TinyHtml {
1047
1143
  allowed = true;
1048
1144
  }
1049
1145
 
1050
- if (!allowed)
1146
+ if (!allowed) {
1147
+ TinyHtml._debugElemError([...item], result[0]);
1051
1148
  throw new Error(
1052
1149
  `[TinyHtml] Invalid element of the list "${elemName.join(',')}" in ${where}().`,
1053
1150
  );
1151
+ }
1054
1152
  return result[0];
1055
1153
  };
1056
1154
  if (!Array.isArray(elems)) return checkElement([elems]);
1057
- if (elems.length > 1)
1155
+ if (elems.length > 1) {
1156
+ TinyHtml._debugElemError([...elems]);
1058
1157
  throw new Error(
1059
1158
  `[TinyHtml] Invalid element amount in ${where}() (Received ${elems.length}/1).`,
1060
1159
  );
1160
+ }
1061
1161
  return checkElement(elems);
1062
1162
  }
1063
1163
 
@@ -300,6 +300,42 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
300
300
  y: number;
301
301
  };
302
302
  };
303
+ /**
304
+ * Controls whether TinyHtml emits detailed debug output to the console.
305
+ * When enabled, helper methods print structured diagnostics for easier troubleshooting.
306
+ * @type {boolean}
307
+ */
308
+ static "__#8@#elemDebug": boolean;
309
+ /**
310
+ * Enables or disables debug output.
311
+ * @param {boolean} value True to enable debug output; false to disable.
312
+ * @throws {TypeError} Thrown if the provided value is not a boolean.
313
+ * @returns {void}
314
+ */
315
+ static set elemDebug(value: boolean);
316
+ /**
317
+ * Gets whether debug output is enabled.
318
+ * @returns {boolean} True if debug output is enabled; otherwise, false.
319
+ */
320
+ static get elemDebug(): boolean;
321
+ /**
322
+ * Logs a standardized debug error for element validation, including a console.table
323
+ * with the involved elements. Use this when an element argument is invalid, unexpected,
324
+ * or fails a guard/validation.
325
+ *
326
+ * The output includes:
327
+ * - A concise error header
328
+ * - A stack trace (when supported)
329
+ * - A table of elements (index, typeof, constructor, summary, value)
330
+ * - The specific problematic element, if provided
331
+ *
332
+ * @param {(ConstructorElValues | EventTarget | TinyElement | null)[]} elems
333
+ * A list of elements participating in the operation (may include nulls).
334
+ * @param {ConstructorElValues | EventTarget | TinyElement | null} [elem]
335
+ * The specific element that triggered the error, if available.
336
+ * @returns {void}
337
+ */
338
+ static _debugElemError(elems: (ConstructorElValues | EventTarget | TinyElement | null)[], elem?: ConstructorElValues | EventTarget | TinyElement | null, ...args: any[]): void;
303
339
  /**
304
340
  * Parse inline styles into an object.
305
341
  * @param {string} styleText
@@ -286,6 +286,90 @@ const __elemCollision = {
286
286
  class TinyHtml {
287
287
  /** @typedef {import('../basics/collision.mjs').ObjRect} ObjRect */
288
288
  static Utils = { ...TinyCollision };
289
+ /**
290
+ * Controls whether TinyHtml emits detailed debug output to the console.
291
+ * When enabled, helper methods print structured diagnostics for easier troubleshooting.
292
+ * @type {boolean}
293
+ */
294
+ static #elemDebug = false;
295
+ /**
296
+ * Gets whether debug output is enabled.
297
+ * @returns {boolean} True if debug output is enabled; otherwise, false.
298
+ */
299
+ static get elemDebug() {
300
+ return TinyHtml.#elemDebug;
301
+ }
302
+ /**
303
+ * Enables or disables debug output.
304
+ * @param {boolean} value True to enable debug output; false to disable.
305
+ * @throws {TypeError} Thrown if the provided value is not a boolean.
306
+ * @returns {void}
307
+ */
308
+ static set elemDebug(value) {
309
+ if (typeof value !== 'boolean')
310
+ throw new TypeError('Expected a boolean value for elemDebug');
311
+ TinyHtml.#elemDebug = value;
312
+ }
313
+ /**
314
+ * Logs a standardized debug error for element validation, including a console.table
315
+ * with the involved elements. Use this when an element argument is invalid, unexpected,
316
+ * or fails a guard/validation.
317
+ *
318
+ * The output includes:
319
+ * - A concise error header
320
+ * - A stack trace (when supported)
321
+ * - A table of elements (index, typeof, constructor, summary, value)
322
+ * - The specific problematic element, if provided
323
+ *
324
+ * @param {(ConstructorElValues | EventTarget | TinyElement | null)[]} elems
325
+ * A list of elements participating in the operation (may include nulls).
326
+ * @param {ConstructorElValues | EventTarget | TinyElement | null} [elem]
327
+ * The specific element that triggered the error, if available.
328
+ * @returns {void}
329
+ */
330
+ static _debugElemError(elems, elem) {
331
+ if (!TinyHtml.#elemDebug)
332
+ return;
333
+ const header = '[TinyHtml Debug] Element validation error';
334
+ console.groupCollapsed(`${header}${elem ? ' — details below' : ''}`);
335
+ console.error(header);
336
+ // Stack trace for call-site visibility
337
+ if (typeof Error !== 'undefined' && typeof Error.captureStackTrace === 'function') {
338
+ const err = new Error(header);
339
+ Error.captureStackTrace(err, TinyHtml._debugElemError);
340
+ console.error(err.stack);
341
+ }
342
+ else {
343
+ console.trace(header);
344
+ }
345
+ // Tabular overview of provided elements
346
+ if (Array.isArray(elems)) {
347
+ const rows = elems.map((el, index) => {
348
+ const typeOf = el === null ? 'null' : typeof el;
349
+ const ctor = el?.constructor?.name ?? (el === null ? 'null' : 'primitive');
350
+ const isDomEl = typeof Element !== 'undefined' && el instanceof Element;
351
+ const summary = isDomEl
352
+ ? `${el.tagName?.toLowerCase?.() ?? 'element'}#${el.id || ''}.${String(el.className || '')
353
+ .trim()
354
+ .replace(/\s+/g, '.')}`
355
+ : el && typeof el === 'object' && 'nodeType' in el
356
+ ? `nodeType:${ /** @type {any} */(el).nodeType}`
357
+ : '';
358
+ return { index, typeOf, constructor: ctor, summary, value: el };
359
+ });
360
+ console.table(rows);
361
+ }
362
+ else {
363
+ console.warn('[TinyHtml Debug] "elems" is not an array:', elems);
364
+ }
365
+ // Highlight the specific problematic element, if any
366
+ if (arguments.length > 1) {
367
+ console.error('[TinyHtml Debug] Problematic element:', elem);
368
+ if (elem && typeof elem === 'object')
369
+ console.dir(elem);
370
+ }
371
+ console.groupEnd();
372
+ }
289
373
  /**
290
374
  * Parse inline styles into an object.
291
375
  * @param {string} styleText
@@ -815,8 +899,10 @@ class TinyHtml {
815
899
  if (!(this.#el[index] instanceof Element) &&
816
900
  !(this.#el[index] instanceof Window) &&
817
901
  !(this.#el[index] instanceof Document) &&
818
- !(this.#el[index] instanceof Text))
902
+ !(this.#el[index] instanceof Text)) {
903
+ TinyHtml._debugElemError([...this.#el], this.#el[index]);
819
904
  throw new Error(`[TinyHtml] Invalid Element in ${where}().`);
905
+ }
820
906
  return this.#el[index];
821
907
  }
822
908
  /**
@@ -830,8 +916,10 @@ class TinyHtml {
830
916
  if (!this.#el.every((el) => el instanceof Element ||
831
917
  el instanceof Window ||
832
918
  el instanceof Document ||
833
- el instanceof Text))
919
+ el instanceof Text)) {
920
+ TinyHtml._debugElemError([...this.#el]);
834
921
  throw new Error(`[TinyHtml] Invalid Element in ${where}().`);
922
+ }
835
923
  return [...this.#el];
836
924
  }
837
925
  //////////////////////////////////////////////////////
@@ -860,8 +948,10 @@ class TinyHtml {
860
948
  break;
861
949
  }
862
950
  }
863
- if (!allowed)
951
+ if (!allowed) {
952
+ TinyHtml._debugElemError([...item], result);
864
953
  throw new Error(`[TinyHtml] Invalid element of the list "${elemName.join(',')}" in ${where}().`);
954
+ }
865
955
  results.push(result);
866
956
  return result;
867
957
  }));
@@ -888,8 +978,10 @@ class TinyHtml {
888
978
  const checkElement = (item) => {
889
979
  const elem = item[0];
890
980
  const result = elem instanceof TinyHtml ? elem._getElements(where) : [elem];
891
- if (result.length > 1)
981
+ if (result.length > 1) {
982
+ TinyHtml._debugElemError([...item]);
892
983
  throw new Error(`[TinyHtml] Invalid element amount in ${where}() (Received ${result.length}/1).`);
984
+ }
893
985
  let allowed = false;
894
986
  for (const TheTinyElement of TheTinyElements) {
895
987
  if (result[0] instanceof TheTinyElement) {
@@ -901,14 +993,18 @@ class TinyHtml {
901
993
  result[0] = null;
902
994
  allowed = true;
903
995
  }
904
- if (!allowed)
996
+ if (!allowed) {
997
+ TinyHtml._debugElemError([...item], result[0]);
905
998
  throw new Error(`[TinyHtml] Invalid element of the list "${elemName.join(',')}" in ${where}().`);
999
+ }
906
1000
  return result[0];
907
1001
  };
908
1002
  if (!Array.isArray(elems))
909
1003
  return checkElement([elems]);
910
- if (elems.length > 1)
1004
+ if (elems.length > 1) {
1005
+ TinyHtml._debugElemError([...elems]);
911
1006
  throw new Error(`[TinyHtml] Invalid element amount in ${where}() (Received ${elems.length}/1).`);
1007
+ }
912
1008
  return checkElement(elems);
913
1009
  }
914
1010
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.22.5",
3
+ "version": "1.22.6",
4
4
  "description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
5
5
  "scripts": {
6
6
  "test": "npm run test:mjs && npm run test:cjs && npm run test:js",