tiny-essentials 1.17.1 → 1.18.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.
Files changed (60) hide show
  1. package/dist/legacy/get/countObj.cjs +2 -2
  2. package/dist/legacy/get/countObj.d.mts +1 -1
  3. package/dist/legacy/get/countObj.mjs +1 -1
  4. package/dist/legacy/index.cjs +2 -1
  5. package/dist/v1/TinyBasicsEs.js +559 -411
  6. package/dist/v1/TinyBasicsEs.min.js +1 -1
  7. package/dist/v1/TinyClipboard.js +459 -0
  8. package/dist/v1/TinyClipboard.min.js +1 -0
  9. package/dist/v1/TinyDragger.js +170 -2454
  10. package/dist/v1/TinyDragger.min.js +1 -2
  11. package/dist/v1/TinyEssentials.js +1093 -63
  12. package/dist/v1/TinyEssentials.min.js +1 -1
  13. package/dist/v1/TinyHtml.js +164 -21
  14. package/dist/v1/TinyHtml.min.js +1 -1
  15. package/dist/v1/TinySmartScroller.js +164 -21
  16. package/dist/v1/TinySmartScroller.min.js +1 -1
  17. package/dist/v1/TinyTextRangeEditor.js +497 -0
  18. package/dist/v1/TinyTextRangeEditor.min.js +1 -0
  19. package/dist/v1/TinyUploadClicker.js +219 -467
  20. package/dist/v1/TinyUploadClicker.min.js +1 -1
  21. package/dist/v1/basics/html.cjs +3 -3
  22. package/dist/v1/basics/html.mjs +1 -1
  23. package/dist/v1/basics/index.cjs +3 -2
  24. package/dist/v1/basics/index.d.mts +2 -2
  25. package/dist/v1/basics/index.mjs +2 -1
  26. package/dist/v1/basics/objChecker.cjs +46 -0
  27. package/dist/v1/basics/objChecker.d.mts +29 -0
  28. package/dist/v1/basics/objChecker.mjs +45 -0
  29. package/dist/v1/basics/objFilter.cjs +4 -45
  30. package/dist/v1/basics/objFilter.d.mts +3 -28
  31. package/dist/v1/basics/objFilter.mjs +2 -45
  32. package/dist/v1/build/TinyClipboard.cjs +7 -0
  33. package/dist/v1/build/TinyClipboard.d.mts +3 -0
  34. package/dist/v1/build/TinyClipboard.mjs +2 -0
  35. package/dist/v1/build/TinyTextRangeEditor.cjs +7 -0
  36. package/dist/v1/build/TinyTextRangeEditor.d.mts +3 -0
  37. package/dist/v1/build/TinyTextRangeEditor.mjs +2 -0
  38. package/dist/v1/index.cjs +7 -2
  39. package/dist/v1/index.d.mts +5 -3
  40. package/dist/v1/index.mjs +5 -2
  41. package/dist/v1/libs/TinyClipboard.cjs +420 -0
  42. package/dist/v1/libs/TinyClipboard.d.mts +155 -0
  43. package/dist/v1/libs/TinyClipboard.mjs +398 -0
  44. package/dist/v1/libs/TinyDragger.cjs +3 -3
  45. package/dist/v1/libs/TinyDragger.mjs +1 -1
  46. package/dist/v1/libs/TinyHtml.cjs +164 -21
  47. package/dist/v1/libs/TinyHtml.d.mts +150 -27
  48. package/dist/v1/libs/TinyHtml.mjs +158 -20
  49. package/dist/v1/libs/TinyTextRangeEditor.cjs +458 -0
  50. package/dist/v1/libs/TinyTextRangeEditor.d.mts +200 -0
  51. package/dist/v1/libs/TinyTextRangeEditor.mjs +424 -0
  52. package/dist/v1/libs/TinyUploadClicker.cjs +5 -4
  53. package/docs/v1/README.md +3 -0
  54. package/docs/v1/basics/objChecker.md +47 -0
  55. package/docs/v1/basics/objFilter.md +0 -40
  56. package/docs/v1/libs/TinyClipboard.md +213 -0
  57. package/docs/v1/libs/TinyHtml.md +112 -15
  58. package/docs/v1/libs/TinyTextRangeEditor.md +208 -0
  59. package/package.json +1 -1
  60. package/dist/v1/TinyDragger.min.js.LICENSE.txt +0 -8
@@ -2530,207 +2530,11 @@ function formatDayTimer(seconds) {
2530
2530
  return formatCustomTimer(seconds, 'days', '{days}d {hours}:{minutes}:{seconds}');
2531
2531
  }
2532
2532
 
2533
- // EXTERNAL MODULE: ./node_modules/buffer/index.js
2534
- var buffer = __webpack_require__(287);
2535
- ;// ./src/v1/basics/objFilter.mjs
2536
-
2537
-
2538
- const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
2539
-
2540
- /**
2541
- * An object containing type validation functions and their evaluation order.
2542
- *
2543
- * Each item in `typeValidator.items` is a function that receives any value
2544
- * and returns a boolean indicating whether the value matches the corresponding type.
2545
- *
2546
- * The `order` array defines the priority in which types should be checked,
2547
- * which can be useful for functions that infer types in a consistent manner.
2548
- *
2549
- */
2550
- const typeValidator = {
2551
- items: {},
2552
- /**
2553
- * Evaluation order of the type checkers.
2554
- * @type {string[]}
2555
- * */
2556
- order: [],
2557
- };
2558
-
2559
- /** @typedef {Object.<string, (val: any) => *>} ExtendObjType */
2560
- /** @typedef {Array<[string, (val: any) => *]>} ExtendObjTypeArray */
2561
-
2562
- /**
2563
- * Adds new type checkers to the typeValidator without overwriting existing ones.
2564
- *
2565
- * Accepts either an object with named functions or an array of [key, fn] arrays.
2566
- * If no index is provided, the type is inserted just before 'object' (if it exists), or at the end.
2567
- *
2568
- * @param {ExtendObjType|ExtendObjTypeArray} newItems
2569
- * - New type validators to be added.
2570
- * @param {number} [index] - Optional. Position at which to insert each new type. Ignored if the type already exists.
2571
- * @returns {string[]} - A list of successfully added type names.
2572
- *
2573
- * @example
2574
- * extendObjType({
2575
- * htmlElement2: val => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement
2576
- * });
2577
- *
2578
- * @example
2579
- * extendObjType([
2580
- * ['alpha', val => typeof val === 'string'],
2581
- * ['beta', val => Array.isArray(val)]
2582
- * ]);
2583
- */
2584
- function extendObjType(newItems, index) {
2585
- const added = [];
2586
-
2587
- const entries = Array.isArray(newItems) ? newItems : Object.entries(newItems);
2588
- for (const [key, fn] of entries) {
2589
- if (!typeValidator.items.hasOwnProperty(key)) {
2590
- // @ts-ignore
2591
- typeValidator.items[key] = fn;
2592
-
2593
- let insertAt = typeof index === 'number' ? index : -1; // Default to -1 if index isn't provided
2594
-
2595
- // Default to before 'object', or to the end
2596
- if (insertAt === -1) {
2597
- const objectIndex = typeValidator.order.indexOf('object');
2598
- insertAt = objectIndex > -1 ? objectIndex : typeValidator.order.length;
2599
- }
2600
-
2601
- // Ensure insertAt is a valid number and not out of bounds
2602
- insertAt = Math.min(Math.max(0, insertAt), typeValidator.order.length);
2603
-
2604
- typeValidator.order.splice(insertAt, 0, key);
2605
- added.push(key);
2606
- }
2607
- }
2608
-
2609
- return added;
2610
- }
2611
-
2612
- /**
2613
- * Reorders the typeValidator.order array according to a custom new order.
2614
- * All values in the new order must already exist in the current order.
2615
- * The function does not mutate the original array structure directly.
2616
- *
2617
- * @param {string[]} newOrder - The new order of type names.
2618
- * @returns {boolean} - Returns true if the reorder was successful, false if invalid keys were found.
2619
- *
2620
- * @example
2621
- * reorderObjTypeOrder([
2622
- * 'string', 'number', 'array', 'object'
2623
- * ]);
2624
- */
2625
- function reorderObjTypeOrder(newOrder) {
2626
- const currentOrder = [...typeValidator.order]; // shallow clone
2627
-
2628
- // All keys in newOrder must exist in currentOrder
2629
- const isValid = newOrder.every((type) => currentOrder.includes(type));
2630
-
2631
- if (!isValid) return false;
2632
-
2633
- // Reassign only if valid
2634
- typeValidator.order = newOrder.slice(); // assign shallow copy
2635
- return true;
2636
- }
2637
-
2638
- /**
2639
- * Returns a cloned version of the `typeValidator.order` array.
2640
- * The cloned array will not be affected by future changes to the original `order`.
2641
- *
2642
- * @returns {string[]} - A new array with the same values as `typeValidator.order`.
2643
- */
2644
- function cloneObjTypeOrder() {
2645
- return [...typeValidator.order]; // Creates a shallow copy of the array
2646
- }
2647
-
2648
- /**
2649
- * Returns the detected type name of a given value based on predefined type validators.
2650
- *
2651
- * This function uses `getType` with a predefined `typeValidator` to determine or compare types safely.
2652
- * in the specified `typeValidator.order`. The first matching type is returned.
2653
- *
2654
- * If `val` is `null`, it immediately returns `'null'`.
2655
- * If no match is found, it returns `'unknown'`.
2656
- *
2657
- * @param {any} val - The value whose type should be determined.
2658
- * @returns {string} - The type name of the value (e.g., "array", "date", "map"), or "unknown" if no match is found.
2659
- *
2660
- * @example
2661
- * getType([]); // "array"
2662
- * getType(null); // "null"
2663
- * getType(new Set()); // "set"
2664
- * getType(() => {}); // "unknown"
2665
- */
2666
- const getType = (val) => {
2667
- if (val === null) return 'null';
2668
- // @ts-ignore
2669
- for (const name of typeValidator.order) {
2670
- // @ts-ignore
2671
- if (typeof typeValidator.items[name] !== 'function' || typeValidator.items[name](val))
2672
- return name;
2673
- }
2674
- return 'unknown';
2675
- };
2676
-
2677
- /**
2678
- * Checks the type of a given object or returns its type as a string.
2679
- *
2680
- * @param {*} obj - The object to check or identify.
2681
- * @param {string} [type] - Optional. If provided, checks whether the object matches this type (e.g., "object", "array", "string").
2682
- * @returns {boolean|string|null} - Returns `true` if the type matches, `false` if not,
2683
- * the type string if no type is provided, or `null` if the object is `undefined`.
2684
- *
2685
- * @example
2686
- * objType([], 'array'); // true
2687
- * objType({}, 'object'); // true
2688
- * objType('hello'); // "string"
2689
- * objType(undefined); // null
2690
- */
2691
- function objType(obj, type) {
2692
- if (typeof obj === 'undefined') return null;
2693
- const result = getType(obj);
2694
- if (typeof type === 'string') return result === type.toLowerCase();
2695
- return result;
2696
- }
2697
-
2698
- /**
2699
- * Checks the type of a given object and returns the validation value if a known type is detected.
2700
- *
2701
- * @param {*} obj - The object to check or identify.
2702
- * @returns {{ valid:*; type: string | null }} - Returns the type result.
2703
- */
2704
- function checkObj(obj) {
2705
- /** @type {{ valid:*; type: string | null }} */
2706
- const data = { valid: null, type: null };
2707
- for (const name of typeValidator.order) {
2708
- // @ts-ignore
2709
- if (typeof typeValidator.items[name] === 'function') {
2710
- // @ts-ignore
2711
- const result = typeValidator.items[name](obj);
2712
- if (result) {
2713
- data.valid = result;
2714
- data.type = name;
2715
- break;
2716
- }
2717
- }
2718
- }
2719
- return data;
2720
- }
2721
-
2722
- /**
2723
- * Creates a clone of the functions from the `typeValidator` object.
2724
- * It returns a new object where the keys are the same and the values are the cloned functions.
2725
- */
2726
- function getCheckObj() {
2727
- return Object.fromEntries(Object.entries(typeValidator.items).map(([key, fn]) => [key, fn]));
2728
- }
2729
-
2533
+ ;// ./src/v1/basics/objChecker.mjs
2730
2534
  /**
2731
2535
  * Counts the number of elements in an array or the number of properties in an object.
2732
2536
  *
2733
- * @param {Array<*>|Record<string|number, any>} obj - The array or object to count.
2537
+ * @param {Array<*>|Record<string | number | symbol, any>} obj - The array or object to count.
2734
2538
  * @returns {number} - The count of items (array elements or object keys), or `0` if the input is neither an array nor an object.
2735
2539
  *
2736
2540
  * @example
@@ -2742,7 +2546,7 @@ function countObj(obj) {
2742
2546
  // Is Array
2743
2547
  if (Array.isArray(obj)) return obj.length;
2744
2548
  // Object
2745
- if (objType(obj, 'object')) return Object.keys(obj).length;
2549
+ if (isJsonObject(obj)) return Object.keys(obj).length;
2746
2550
  // Nothing
2747
2551
  return 0;
2748
2552
  }
@@ -2769,132 +2573,6 @@ function isJsonObject(value) {
2769
2573
  return true;
2770
2574
  }
2771
2575
 
2772
- // Insert obj types
2773
-
2774
- extendObjType([
2775
- [
2776
- 'undefined',
2777
- /** @param {*} val @returns {val is undefined} */
2778
- (val) => typeof val === 'undefined',
2779
- ],
2780
- [
2781
- 'null',
2782
- /** @param {*} val @returns {val is null} */
2783
- (val) => val === null,
2784
- ],
2785
- [
2786
- 'boolean',
2787
- /** @param {*} val @returns {val is boolean} */
2788
- (val) => typeof val === 'boolean',
2789
- ],
2790
- [
2791
- 'number',
2792
- /** @param {*} val @returns {val is number} */
2793
- (val) => typeof val === 'number' && !Number.isNaN(val),
2794
- ],
2795
- [
2796
- 'bigint',
2797
- /** @param {*} val @returns {val is bigint} */
2798
- (val) => typeof val === 'bigint',
2799
- ],
2800
- [
2801
- 'string',
2802
- /** @param {*} val @returns {val is string} */
2803
- (val) => typeof val === 'string',
2804
- ],
2805
- [
2806
- 'symbol',
2807
- /** @param {*} val @returns {val is symbol} */
2808
- (val) => typeof val === 'symbol',
2809
- ],
2810
- [
2811
- 'function',
2812
- /** @param {*} val @returns {val is Function} */
2813
- (val) => typeof val === 'function',
2814
- ],
2815
- [
2816
- 'array',
2817
- /** @param {*} val @returns {val is any[]} */
2818
- (val) => Array.isArray(val),
2819
- ],
2820
- ]);
2821
-
2822
- if (!isBrowser) {
2823
- extendObjType([
2824
- [
2825
- 'buffer',
2826
- /** @param {*} val @returns {val is Buffer} */
2827
- (val) => typeof buffer/* Buffer */.hp !== 'undefined' && buffer/* Buffer */.hp.isBuffer(val),
2828
- ],
2829
- ]);
2830
- }
2831
-
2832
- if (isBrowser) {
2833
- extendObjType([
2834
- [
2835
- 'file',
2836
- /** @param {*} val @returns {val is File} */
2837
- (val) => typeof File !== 'undefined' && val instanceof File,
2838
- ],
2839
- ]);
2840
- }
2841
-
2842
- extendObjType([
2843
- [
2844
- 'date',
2845
- /** @param {*} val @returns {val is Date} */
2846
- (val) => val instanceof Date,
2847
- ],
2848
- [
2849
- 'regexp',
2850
- /** @param {*} val @returns {val is RegExp} */
2851
- (val) => val instanceof RegExp,
2852
- ],
2853
- [
2854
- 'map',
2855
- /** @param {*} val @returns {val is Map<unknown, unknown>} */
2856
- (val) => val instanceof Map,
2857
- ],
2858
- [
2859
- 'set',
2860
- /** @param {*} val @returns {val is Set<unknown>} */
2861
- (val) => val instanceof Set,
2862
- ],
2863
- [
2864
- 'weakmap',
2865
- /** @param {*} val @returns {val is WeakMap<unknown, unknown>} */
2866
- (val) => val instanceof WeakMap,
2867
- ],
2868
- [
2869
- 'weakset',
2870
- /** @param {*} val @returns {val is WeakSet<unknown>} */
2871
- (val) => val instanceof WeakSet,
2872
- ],
2873
- [
2874
- 'promise',
2875
- /** @param {*} val @returns {val is Promise<unknown>} */
2876
- (val) => val instanceof Promise,
2877
- ],
2878
- ]);
2879
-
2880
- if (isBrowser) {
2881
- extendObjType([
2882
- [
2883
- 'htmlelement',
2884
- /** @param {*} val @returns {val is HTMLElement} */
2885
- (val) => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement,
2886
- ],
2887
- ]);
2888
- }
2889
-
2890
- extendObjType([
2891
- [
2892
- 'object',
2893
- /** @param {*} val @returns {val is Record<string | number | symbol, unknown>} */
2894
- (val) => isJsonObject(val),
2895
- ],
2896
- ]);
2897
-
2898
2576
  ;// ./src/v1/basics/html.mjs
2899
2577
 
2900
2578
 
@@ -3764,22 +3442,37 @@ const {
3764
3442
  * Represents a value that can be either a DOM Element or the global Window object.
3765
3443
  * Useful for functions that operate generically on scrollable or measurable targets.
3766
3444
  *
3767
- * @typedef {Element|Window} ElementAndWindow
3445
+ * @typedef {Element|Window} ElementAndWindow
3446
+ */
3447
+
3448
+ /**
3449
+ * Represents a raw DOM element/window/document or an instance of TinyHtml.
3450
+ * This type is used to abstract interactions with both plain elements
3451
+ * and wrapped elements via the TinyHtml class.
3452
+ *
3453
+ * @typedef {ElementAndWinAndDoc|TinyHtml} TinyElementAndWinAndDoc
3454
+ */
3455
+
3456
+ /**
3457
+ * Represents a value that can be either a DOM Element, or the global Window object, or the document object.
3458
+ * Useful for functions that operate generically on scrollable or measurable targets.
3459
+ *
3460
+ * @typedef {Element|Window|Document} ElementAndWinAndDoc
3768
3461
  */
3769
3462
 
3770
3463
  /**
3771
- * Represents a raw DOM element/window/document or an instance of TinyHtml.
3464
+ * Represents a raw DOM element with document or an instance of TinyHtml.
3772
3465
  * This type is used to abstract interactions with both plain elements
3773
3466
  * and wrapped elements via the TinyHtml class.
3774
3467
  *
3775
- * @typedef {ElementAndWinAndDoc|TinyHtml} TinyElementAndWinAndDoc
3468
+ * @typedef {ElementWithDoc|TinyHtml} TinyElementWithDoc
3776
3469
  */
3777
3470
 
3778
3471
  /**
3779
- * Represents a value that can be either a DOM Element, or the global Window object, or the document object.
3780
- * Useful for functions that operate generically on scrollable or measurable targets.
3472
+ * Represents a value that can be either a DOM Element, or the document object.
3473
+ * Useful for functions that operate generically on measurable targets.
3781
3474
  *
3782
- * @typedef {Element|Window|Document} ElementAndWinAndDoc
3475
+ * @typedef {Element|Document} ElementWithDoc
3783
3476
  */
3784
3477
 
3785
3478
  /**
@@ -3801,12 +3494,6 @@ const {
3801
3494
  * @typedef {Window|Element|Document|Text} ConstructorElValues
3802
3495
  */
3803
3496
 
3804
- /**
3805
- * The handler function used in event listeners.
3806
- *
3807
- * @typedef {(e: Event) => any} EventRegistryHandle
3808
- */
3809
-
3810
3497
  /**
3811
3498
  * Options passed to `addEventListener` or `removeEventListener`.
3812
3499
  * Can be a boolean or an object of type `AddEventListenerOptions`.
@@ -3818,7 +3505,7 @@ const {
3818
3505
  * Structure describing a registered event callback and its options.
3819
3506
  *
3820
3507
  * @typedef {Object} EventRegistryItem
3821
- * @property {EventRegistryHandle} handler - The function to be executed when the event is triggered.
3508
+ * @property {EventListenerOrEventListenerObject|null} handler - The function to be executed when the event is triggered.
3822
3509
  * @property {EventRegistryOptions} [options] - Optional configuration passed to the listener.
3823
3510
  */
3824
3511
 
@@ -4377,9 +4064,9 @@ class TinyHtml_TinyHtml {
4377
4064
  * Ensures the input is returned as an array.
4378
4065
  * Useful to normalize operations across multiple or single element/window/document elements.
4379
4066
  *
4380
- * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/window element or array of html elements.
4067
+ * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/document/window element or array of html elements.
4381
4068
  * @param {string} where - The method or context name where validation is being called.
4382
- * @returns {ElementAndWindow[]} - Always returns an array of element/window elements.
4069
+ * @returns {ElementAndWindow[]} - Always returns an array of element/document/window elements.
4383
4070
  * @readonly
4384
4071
  */
4385
4072
  static _preElemsAndWinAndDoc(elems, where) {
@@ -4396,9 +4083,9 @@ class TinyHtml_TinyHtml {
4396
4083
  * Ensures the input is returned as an single element/window/document element.
4397
4084
  * Useful to normalize operations across multiple or single element/window/document elements.
4398
4085
  *
4399
- * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/window element or array of html elements.
4086
+ * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/document/window element or array of html elements.
4400
4087
  * @param {string} where - The method or context name where validation is being called.
4401
- * @returns {ElementAndWindow} - Always returns an single element/window element.
4088
+ * @returns {ElementAndWindow} - Always returns an single element/document/window element.
4402
4089
  * @readonly
4403
4090
  */
4404
4091
  static _preElemAndWinAndDoc(elems, where) {
@@ -4412,6 +4099,32 @@ class TinyHtml_TinyHtml {
4412
4099
  return result;
4413
4100
  }
4414
4101
 
4102
+ /**
4103
+ * Ensures the input is returned as an array.
4104
+ * Useful to normalize operations across multiple or single element with document elements.
4105
+ *
4106
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} elems - A single element with document element or array of html elements.
4107
+ * @param {string} where - The method or context name where validation is being called.
4108
+ * @returns {ElementWithDoc[]} - Always returns an array of element with document elements.
4109
+ * @readonly
4110
+ */
4111
+ static _preElemsWithDoc(elems, where) {
4112
+ return TinyHtml_TinyHtml._preElemsTemplate(elems, where, [Element, Document], ['Element', 'Document']);
4113
+ }
4114
+
4115
+ /**
4116
+ * Ensures the input is returned as an single element with document element.
4117
+ * Useful to normalize operations across multiple or single element with document elements.
4118
+ *
4119
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} elems - A single element/window element or array of html elements.
4120
+ * @param {string} where - The method or context name where validation is being called.
4121
+ * @returns {ElementWithDoc} - Always returns an single element/window element.
4122
+ * @readonly
4123
+ */
4124
+ static _preElemWithDoc(elems, where) {
4125
+ return TinyHtml_TinyHtml._preElemTemplate(elems, where, [Element, Document], ['Element', 'Document']);
4126
+ }
4127
+
4415
4128
  /**
4416
4129
  * Normalizes and converts one or more DOM elements (or TinyHtml instances)
4417
4130
  * into an array of `TinyHtml` instances.
@@ -7671,12 +7384,120 @@ class TinyHtml_TinyHtml {
7671
7384
 
7672
7385
  ////////////////////////////////////////////
7673
7386
 
7387
+ /**
7388
+ * Registers a listener for the "paste" event to extract files and text from the clipboard (e.g., when the user presses Ctrl+V).
7389
+ *
7390
+ * This method allows reacting to pasted content by providing separate callbacks for files and plain text.
7391
+ * Useful for building file upload areas, rich-text editors, or input enhancements.
7392
+ *
7393
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} el - The target element(s) where the "paste" event will be listened.
7394
+ * @param {Object} [settings={}] - Optional callbacks to handle clipboard content.
7395
+ * @param {(data: DataTransferItem, file: File) => void} [settings.onFilePaste] - Called for each file pasted from the clipboard (e.g., images).
7396
+ * @param {(data: DataTransferItem, text: string) => void} [settings.onTextPaste] - Called when plain text is pasted from the clipboard.
7397
+ * @returns {EventListenerOrEventListenerObject} The internal "paste" event handler used.
7398
+ */
7399
+ static listenForPaste(el, { onFilePaste, onTextPaste } = {}) {
7400
+ if (typeof onFilePaste !== 'undefined' && typeof onFilePaste !== 'function')
7401
+ throw new TypeError('onFilePaste must be a function.');
7402
+ if (typeof onTextPaste !== 'undefined' && typeof onTextPaste !== 'function')
7403
+ throw new TypeError('onTextPaste must be a function.');
7404
+
7405
+ /** @type {EventListenerOrEventListenerObject} */
7406
+ const pasteEvent = (event) => {
7407
+ if (!(event instanceof ClipboardEvent)) return;
7408
+ const items = event.clipboardData?.items || [];
7409
+ for (const item of items) {
7410
+ if (item.kind === 'file') {
7411
+ if (typeof onFilePaste === 'function') {
7412
+ const file = item.getAsFile();
7413
+ if (file) onFilePaste(item, file);
7414
+ }
7415
+ } else if (item.kind === 'string') {
7416
+ if (typeof onTextPaste === 'function')
7417
+ item.getAsString((text) => onTextPaste(item, text));
7418
+ }
7419
+ }
7420
+ };
7421
+
7422
+ TinyHtml_TinyHtml._preElemsWithDoc(el, 'listenForPaste').forEach((elem) =>
7423
+ TinyHtml_TinyHtml.on(elem, 'paste', pasteEvent),
7424
+ );
7425
+ return pasteEvent;
7426
+ }
7427
+
7428
+ /**
7429
+ * Registers a listener for the "paste" event to extract files and text from the clipboard (e.g., when the user presses Ctrl+V).
7430
+ *
7431
+ * This method allows reacting to pasted content by providing separate callbacks for files and plain text.
7432
+ * Useful for building file upload areas, rich-text editors, or input enhancements.
7433
+ *
7434
+ * @param {Object} [settings={}] - Optional callbacks to handle clipboard content.
7435
+ * @param {(data: DataTransferItem, file: File) => void} [settings.onFilePaste] - Called for each file pasted from the clipboard (e.g., images).
7436
+ * @param {(data: DataTransferItem, text: string) => void} [settings.onTextPaste] - Called when plain text is pasted from the clipboard.
7437
+ * @returns {EventListenerOrEventListenerObject} The internal "paste" event handler used.
7438
+ */
7439
+ listenForPaste({ onFilePaste, onTextPaste } = {}) {
7440
+ return TinyHtml_TinyHtml.listenForPaste(this, { onFilePaste, onTextPaste });
7441
+ }
7442
+
7443
+ /**
7444
+ * Checks if the element has a listener for a specific event.
7445
+ *
7446
+ * @param {TinyEventTarget} el - The element to check.
7447
+ * @param {string} event - The event name to check.
7448
+ * @returns {boolean}
7449
+ */
7450
+ static hasEventListener(el, event) {
7451
+ const elem = TinyHtml_TinyHtml._preEventTargetElem(el, 'hasEventListener');
7452
+ if (!__eventRegistry.has(elem)) return false;
7453
+ const events = __eventRegistry.get(elem);
7454
+ return !!(events && Array.isArray(events[event]) && events[event].length > 0);
7455
+ }
7456
+
7457
+ /**
7458
+ * Checks if the element has a listener for a specific event.
7459
+ *
7460
+ * @param {string} event - The event name to check.
7461
+ * @returns {boolean}
7462
+ */
7463
+ hasEventListener(event) {
7464
+ return TinyHtml_TinyHtml.hasEventListener(this, event);
7465
+ }
7466
+
7467
+ /**
7468
+ * Checks if the element has the exact handler registered for a specific event.
7469
+ *
7470
+ * @param {TinyEventTarget} el - The element to check.
7471
+ * @param {string} event - The event name to check.
7472
+ * @param {EventListenerOrEventListenerObject} handler - The handler function to check.
7473
+ * @returns {boolean}
7474
+ */
7475
+ static hasExactEventListener(el, event, handler) {
7476
+ const elem = TinyHtml_TinyHtml._preEventTargetElem(el, 'hasExactEventListener');
7477
+ if (typeof handler !== 'function') throw new TypeError('The "handler" must be a function.');
7478
+ if (!__eventRegistry.has(elem)) return false;
7479
+ const events = __eventRegistry.get(elem);
7480
+ if (!events || !Array.isArray(events[event])) return false;
7481
+ return events[event].some((item) => item.handler === handler);
7482
+ }
7483
+
7484
+ /**
7485
+ * Checks if the element has the exact handler registered for a specific event.
7486
+ *
7487
+ * @param {string} event - The event name to check.
7488
+ * @param {EventListenerOrEventListenerObject} handler - The handler function to check.
7489
+ * @returns {boolean}
7490
+ */
7491
+ hasExactEventListener(event, handler) {
7492
+ return TinyHtml_TinyHtml.hasExactEventListener(this, event, handler);
7493
+ }
7494
+
7674
7495
  /**
7675
7496
  * Registers an event listener on the specified element.
7676
7497
  *
7677
7498
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
7678
7499
  * @param {string} event - The event type (e.g. 'click', 'keydown').
7679
- * @param {EventRegistryHandle} handler - The callback function to run on event.
7500
+ * @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
7680
7501
  * @param {EventRegistryOptions} [options] - Optional event listener options.
7681
7502
  * @returns {TinyEventTarget|TinyEventTarget[]}
7682
7503
  */
@@ -7698,7 +7519,7 @@ class TinyHtml_TinyHtml {
7698
7519
  * Registers an event listener on the specified element.
7699
7520
  *
7700
7521
  * @param {string} event - The event type (e.g. 'click', 'keydown').
7701
- * @param {EventRegistryHandle} handler - The callback function to run on event.
7522
+ * @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
7702
7523
  * @param {EventRegistryOptions} [options] - Optional event listener options.
7703
7524
  * @returns {TinyEventTarget|TinyEventTarget[]}
7704
7525
  */
@@ -7711,17 +7532,17 @@ class TinyHtml_TinyHtml {
7711
7532
  *
7712
7533
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
7713
7534
  * @param {string} event - The event type (e.g. 'click', 'keydown').
7714
- * @param {EventRegistryHandle} handler - The callback function to run on event.
7535
+ * @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
7715
7536
  * @param {EventRegistryOptions} [options={}] - Optional event listener options.
7716
7537
  * @returns {TinyEventTarget|TinyEventTarget[]}
7717
7538
  */
7718
7539
  static once(el, event, handler, options = {}) {
7719
7540
  if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
7720
7541
  TinyHtml_TinyHtml._preEventTargetElems(el, 'once').forEach((elem) => {
7721
- /** @type {EventRegistryHandle} e */
7542
+ /** @type {EventListenerOrEventListenerObject} */
7722
7543
  const wrapped = (e) => {
7723
7544
  TinyHtml_TinyHtml.off(elem, event, wrapped);
7724
- handler(e);
7545
+ if (typeof handler === 'function') handler(e);
7725
7546
  };
7726
7547
 
7727
7548
  TinyHtml_TinyHtml.on(
@@ -7738,7 +7559,7 @@ class TinyHtml_TinyHtml {
7738
7559
  * Registers an event listener that runs only once, then is removed.
7739
7560
  *
7740
7561
  * @param {string} event - The event type (e.g. 'click', 'keydown').
7741
- * @param {EventRegistryHandle} handler - The callback function to run on event.
7562
+ * @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
7742
7563
  * @param {EventRegistryOptions} [options={}] - Optional event listener options.
7743
7564
  * @returns {TinyEventTarget|TinyEventTarget[]}
7744
7565
  */
@@ -7751,7 +7572,7 @@ class TinyHtml_TinyHtml {
7751
7572
  *
7752
7573
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
7753
7574
  * @param {string} event - The event type.
7754
- * @param {EventRegistryHandle} handler - The function originally bound to the event.
7575
+ * @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
7755
7576
  * @param {boolean|EventListenerOptions} [options] - Optional listener options.
7756
7577
  * @returns {TinyEventTarget|TinyEventTarget[]}
7757
7578
  */
@@ -7773,7 +7594,7 @@ class TinyHtml_TinyHtml {
7773
7594
  * Removes a specific event listener from an element.
7774
7595
  *
7775
7596
  * @param {string} event - The event type.
7776
- * @param {EventRegistryHandle} handler - The function originally bound to the event.
7597
+ * @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
7777
7598
  * @param {boolean|EventListenerOptions} [options] - Optional listener options.
7778
7599
  * @returns {TinyEventTarget|TinyEventTarget[]}
7779
7600
  */
@@ -7816,7 +7637,7 @@ class TinyHtml_TinyHtml {
7816
7637
  * Removes all event listeners of all types from the element.
7817
7638
  *
7818
7639
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
7819
- * @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
7640
+ * @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
7820
7641
  * Optional filter function to selectively remove specific handlers.
7821
7642
  * @returns {TinyEventTarget|TinyEventTarget[]}
7822
7643
  */
@@ -7843,7 +7664,7 @@ class TinyHtml_TinyHtml {
7843
7664
  /**
7844
7665
  * Removes all event listeners of all types from the element.
7845
7666
  *
7846
- * @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
7667
+ * @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
7847
7668
  * Optional filter function to selectively remove specific handlers.
7848
7669
  * @returns {TinyEventTarget|TinyEventTarget[]}
7849
7670
  */
@@ -8648,94 +8469,420 @@ function areHtmlElsPerfColliding(elem1, elem2) {
8648
8469
  return TinyHtml.isCollPerfWith(elem1, elem2);
8649
8470
  }
8650
8471
 
8651
- ///////////////////////////////////////////////////////////////////////////
8472
+ ///////////////////////////////////////////////////////////////////////////
8473
+
8474
+ /**
8475
+ * @typedef {import('../libs/TinyHtml.mjs').HtmlElBoxSides} HtmlElBoxSides
8476
+ */
8477
+
8478
+ /**
8479
+ * Returns the total border width and individual sides from `border{Side}Width` CSS properties.
8480
+ *
8481
+ * @param {Element} el - The target DOM element.
8482
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border widths, and each side individually.
8483
+ * @deprecated - Use TinyHtml.borderWidth instead.
8484
+ */
8485
+ const getHtmlElBordersWidth = (el) => {
8486
+ return libs_TinyHtml.borderWidth(el);
8487
+ };
8488
+
8489
+ /**
8490
+ * Returns the total border size and individual sides from `border{Side}` CSS properties.
8491
+ *
8492
+ * @param {Element} el - The target DOM element.
8493
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border sizes, and each side individually.
8494
+ * @deprecated - Use TinyHtml.border instead.
8495
+ */
8496
+ const getHtmlElBorders = (el) => {
8497
+ return libs_TinyHtml.border(el);
8498
+ };
8499
+
8500
+ /**
8501
+ * Returns the total margin and individual sides from `margin{Side}` CSS properties.
8502
+ *
8503
+ * @param {Element} el - The target DOM element.
8504
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) margins, and each side individually.
8505
+ * @deprecated - Use TinyHtml.margin instead.
8506
+ */
8507
+ const getHtmlElMargin = (el) => {
8508
+ return libs_TinyHtml.margin(el);
8509
+ };
8510
+
8511
+ /**
8512
+ * Returns the total padding and individual sides from `padding{Side}` CSS properties.
8513
+ *
8514
+ * @param {Element} el - The target DOM element.
8515
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
8516
+ * @deprecated - Use TinyHtml.padding instead.
8517
+ */
8518
+ const getHtmlElPadding = (el) => {
8519
+ return libs_TinyHtml.padding(el);
8520
+ };
8521
+
8522
+ /////////////////////////////////////////////////////////////
8523
+
8524
+ // The new version will receive great modifications, the deprecated code has been preserved for non-glitch designs that are using the original code.
8525
+
8526
+ /**
8527
+ * Checks if the given element is at least partially visible in the viewport.
8528
+ *
8529
+ * @param {HTMLElement} element - The DOM element to check.
8530
+ * @returns {boolean} True if the element is partially in the viewport, false otherwise.
8531
+ * @deprecated - Use TinyHtml.isInViewport instead.
8532
+ */
8533
+ function isInViewport(element) {
8534
+ const elementTop = element.offsetTop;
8535
+ const elementBottom = elementTop + element.offsetHeight;
8536
+
8537
+ const viewportTop = window.scrollY;
8538
+ const viewportBottom = viewportTop + window.innerHeight;
8539
+
8540
+ return elementBottom > viewportTop && elementTop < viewportBottom;
8541
+ }
8542
+
8543
+ /**
8544
+ * Checks if the given element is fully visible in the viewport (top and bottom).
8545
+ *
8546
+ * @param {HTMLElement} element - The DOM element to check.
8547
+ * @returns {boolean} True if the element is fully visible in the viewport, false otherwise.
8548
+ * @deprecated - Use TinyHtml.isScrolledIntoView instead.
8549
+ */
8550
+ function isScrolledIntoView(element) {
8551
+ const viewportTop = window.scrollY;
8552
+ const viewportBottom = viewportTop + window.innerHeight;
8553
+
8554
+ const elemTop = element.offsetTop;
8555
+ const elemBottom = elemTop + element.offsetHeight;
8556
+
8557
+ return elemBottom <= viewportBottom && elemTop >= viewportTop;
8558
+ }
8559
+
8560
+ // EXTERNAL MODULE: ./node_modules/buffer/index.js
8561
+ var buffer = __webpack_require__(287);
8562
+ ;// ./src/v1/basics/objFilter.mjs
8563
+
8564
+
8565
+
8566
+
8567
+
8568
+ const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
8569
+
8570
+ /**
8571
+ * An object containing type validation functions and their evaluation order.
8572
+ *
8573
+ * Each item in `typeValidator.items` is a function that receives any value
8574
+ * and returns a boolean indicating whether the value matches the corresponding type.
8575
+ *
8576
+ * The `order` array defines the priority in which types should be checked,
8577
+ * which can be useful for functions that infer types in a consistent manner.
8578
+ *
8579
+ */
8580
+ const typeValidator = {
8581
+ items: {},
8582
+ /**
8583
+ * Evaluation order of the type checkers.
8584
+ * @type {string[]}
8585
+ * */
8586
+ order: [],
8587
+ };
8588
+
8589
+ /** @typedef {Object.<string, (val: any) => *>} ExtendObjType */
8590
+ /** @typedef {Array<[string, (val: any) => *]>} ExtendObjTypeArray */
8591
+
8592
+ /**
8593
+ * Adds new type checkers to the typeValidator without overwriting existing ones.
8594
+ *
8595
+ * Accepts either an object with named functions or an array of [key, fn] arrays.
8596
+ * If no index is provided, the type is inserted just before 'object' (if it exists), or at the end.
8597
+ *
8598
+ * @param {ExtendObjType|ExtendObjTypeArray} newItems
8599
+ * - New type validators to be added.
8600
+ * @param {number} [index] - Optional. Position at which to insert each new type. Ignored if the type already exists.
8601
+ * @returns {string[]} - A list of successfully added type names.
8602
+ *
8603
+ * @example
8604
+ * extendObjType({
8605
+ * htmlElement2: val => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement
8606
+ * });
8607
+ *
8608
+ * @example
8609
+ * extendObjType([
8610
+ * ['alpha', val => typeof val === 'string'],
8611
+ * ['beta', val => Array.isArray(val)]
8612
+ * ]);
8613
+ */
8614
+ function extendObjType(newItems, index) {
8615
+ const added = [];
8616
+
8617
+ const entries = Array.isArray(newItems) ? newItems : Object.entries(newItems);
8618
+ for (const [key, fn] of entries) {
8619
+ if (!typeValidator.items.hasOwnProperty(key)) {
8620
+ // @ts-ignore
8621
+ typeValidator.items[key] = fn;
8622
+
8623
+ let insertAt = typeof index === 'number' ? index : -1; // Default to -1 if index isn't provided
8624
+
8625
+ // Default to before 'object', or to the end
8626
+ if (insertAt === -1) {
8627
+ const objectIndex = typeValidator.order.indexOf('object');
8628
+ insertAt = objectIndex > -1 ? objectIndex : typeValidator.order.length;
8629
+ }
8630
+
8631
+ // Ensure insertAt is a valid number and not out of bounds
8632
+ insertAt = Math.min(Math.max(0, insertAt), typeValidator.order.length);
8633
+
8634
+ typeValidator.order.splice(insertAt, 0, key);
8635
+ added.push(key);
8636
+ }
8637
+ }
8638
+
8639
+ return added;
8640
+ }
8641
+
8642
+ /**
8643
+ * Reorders the typeValidator.order array according to a custom new order.
8644
+ * All values in the new order must already exist in the current order.
8645
+ * The function does not mutate the original array structure directly.
8646
+ *
8647
+ * @param {string[]} newOrder - The new order of type names.
8648
+ * @returns {boolean} - Returns true if the reorder was successful, false if invalid keys were found.
8649
+ *
8650
+ * @example
8651
+ * reorderObjTypeOrder([
8652
+ * 'string', 'number', 'array', 'object'
8653
+ * ]);
8654
+ */
8655
+ function reorderObjTypeOrder(newOrder) {
8656
+ const currentOrder = [...typeValidator.order]; // shallow clone
8657
+
8658
+ // All keys in newOrder must exist in currentOrder
8659
+ const isValid = newOrder.every((type) => currentOrder.includes(type));
8660
+
8661
+ if (!isValid) return false;
8652
8662
 
8653
- /**
8654
- * @typedef {import('../libs/TinyHtml.mjs').HtmlElBoxSides} HtmlElBoxSides
8655
- */
8663
+ // Reassign only if valid
8664
+ typeValidator.order = newOrder.slice(); // assign shallow copy
8665
+ return true;
8666
+ }
8656
8667
 
8657
8668
  /**
8658
- * Returns the total border width and individual sides from `border{Side}Width` CSS properties.
8669
+ * Returns a cloned version of the `typeValidator.order` array.
8670
+ * The cloned array will not be affected by future changes to the original `order`.
8659
8671
  *
8660
- * @param {Element} el - The target DOM element.
8661
- * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border widths, and each side individually.
8662
- * @deprecated - Use TinyHtml.borderWidth instead.
8672
+ * @returns {string[]} - A new array with the same values as `typeValidator.order`.
8663
8673
  */
8664
- const getHtmlElBordersWidth = (el) => {
8665
- return libs_TinyHtml.borderWidth(el);
8666
- };
8674
+ function cloneObjTypeOrder() {
8675
+ return [...typeValidator.order]; // Creates a shallow copy of the array
8676
+ }
8667
8677
 
8668
8678
  /**
8669
- * Returns the total border size and individual sides from `border{Side}` CSS properties.
8679
+ * Returns the detected type name of a given value based on predefined type validators.
8670
8680
  *
8671
- * @param {Element} el - The target DOM element.
8672
- * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border sizes, and each side individually.
8673
- * @deprecated - Use TinyHtml.border instead.
8681
+ * This function uses `getType` with a predefined `typeValidator` to determine or compare types safely.
8682
+ * in the specified `typeValidator.order`. The first matching type is returned.
8683
+ *
8684
+ * If `val` is `null`, it immediately returns `'null'`.
8685
+ * If no match is found, it returns `'unknown'`.
8686
+ *
8687
+ * @param {any} val - The value whose type should be determined.
8688
+ * @returns {string} - The type name of the value (e.g., "array", "date", "map"), or "unknown" if no match is found.
8689
+ *
8690
+ * @example
8691
+ * getType([]); // "array"
8692
+ * getType(null); // "null"
8693
+ * getType(new Set()); // "set"
8694
+ * getType(() => {}); // "unknown"
8674
8695
  */
8675
- const getHtmlElBorders = (el) => {
8676
- return libs_TinyHtml.border(el);
8696
+ const getType = (val) => {
8697
+ if (val === null) return 'null';
8698
+ // @ts-ignore
8699
+ for (const name of typeValidator.order) {
8700
+ // @ts-ignore
8701
+ if (typeof typeValidator.items[name] !== 'function' || typeValidator.items[name](val))
8702
+ return name;
8703
+ }
8704
+ return 'unknown';
8677
8705
  };
8678
8706
 
8679
8707
  /**
8680
- * Returns the total margin and individual sides from `margin{Side}` CSS properties.
8708
+ * Checks the type of a given object or returns its type as a string.
8681
8709
  *
8682
- * @param {Element} el - The target DOM element.
8683
- * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) margins, and each side individually.
8684
- * @deprecated - Use TinyHtml.margin instead.
8710
+ * @param {*} obj - The object to check or identify.
8711
+ * @param {string} [type] - Optional. If provided, checks whether the object matches this type (e.g., "object", "array", "string").
8712
+ * @returns {boolean|string|null} - Returns `true` if the type matches, `false` if not,
8713
+ * the type string if no type is provided, or `null` if the object is `undefined`.
8714
+ *
8715
+ * @example
8716
+ * objType([], 'array'); // true
8717
+ * objType({}, 'object'); // true
8718
+ * objType('hello'); // "string"
8719
+ * objType(undefined); // null
8685
8720
  */
8686
- const getHtmlElMargin = (el) => {
8687
- return libs_TinyHtml.margin(el);
8688
- };
8721
+ function objType(obj, type) {
8722
+ if (typeof obj === 'undefined') return null;
8723
+ const result = getType(obj);
8724
+ if (typeof type === 'string') return result === type.toLowerCase();
8725
+ return result;
8726
+ }
8689
8727
 
8690
8728
  /**
8691
- * Returns the total padding and individual sides from `padding{Side}` CSS properties.
8729
+ * Checks the type of a given object and returns the validation value if a known type is detected.
8692
8730
  *
8693
- * @param {Element} el - The target DOM element.
8694
- * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
8695
- * @deprecated - Use TinyHtml.padding instead.
8731
+ * @param {*} obj - The object to check or identify.
8732
+ * @returns {{ valid:*; type: string | null }} - Returns the type result.
8696
8733
  */
8697
- const getHtmlElPadding = (el) => {
8698
- return libs_TinyHtml.padding(el);
8699
- };
8700
-
8701
- /////////////////////////////////////////////////////////////
8702
-
8703
- // The new version will receive great modifications, the deprecated code has been preserved for non-glitch designs that are using the original code.
8734
+ function checkObj(obj) {
8735
+ /** @type {{ valid:*; type: string | null }} */
8736
+ const data = { valid: null, type: null };
8737
+ for (const name of typeValidator.order) {
8738
+ // @ts-ignore
8739
+ if (typeof typeValidator.items[name] === 'function') {
8740
+ // @ts-ignore
8741
+ const result = typeValidator.items[name](obj);
8742
+ if (result) {
8743
+ data.valid = result;
8744
+ data.type = name;
8745
+ break;
8746
+ }
8747
+ }
8748
+ }
8749
+ return data;
8750
+ }
8704
8751
 
8705
8752
  /**
8706
- * Checks if the given element is at least partially visible in the viewport.
8707
- *
8708
- * @param {HTMLElement} element - The DOM element to check.
8709
- * @returns {boolean} True if the element is partially in the viewport, false otherwise.
8710
- * @deprecated - Use TinyHtml.isInViewport instead.
8753
+ * Creates a clone of the functions from the `typeValidator` object.
8754
+ * It returns a new object where the keys are the same and the values are the cloned functions.
8711
8755
  */
8712
- function isInViewport(element) {
8713
- const elementTop = element.offsetTop;
8714
- const elementBottom = elementTop + element.offsetHeight;
8756
+ function getCheckObj() {
8757
+ return Object.fromEntries(Object.entries(typeValidator.items).map(([key, fn]) => [key, fn]));
8758
+ }
8715
8759
 
8716
- const viewportTop = window.scrollY;
8717
- const viewportBottom = viewportTop + window.innerHeight;
8760
+ // Insert obj types
8718
8761
 
8719
- return elementBottom > viewportTop && elementTop < viewportBottom;
8762
+ extendObjType([
8763
+ [
8764
+ 'undefined',
8765
+ /** @param {*} val @returns {val is undefined} */
8766
+ (val) => typeof val === 'undefined',
8767
+ ],
8768
+ [
8769
+ 'null',
8770
+ /** @param {*} val @returns {val is null} */
8771
+ (val) => val === null,
8772
+ ],
8773
+ [
8774
+ 'boolean',
8775
+ /** @param {*} val @returns {val is boolean} */
8776
+ (val) => typeof val === 'boolean',
8777
+ ],
8778
+ [
8779
+ 'number',
8780
+ /** @param {*} val @returns {val is number} */
8781
+ (val) => typeof val === 'number' && !Number.isNaN(val),
8782
+ ],
8783
+ [
8784
+ 'bigint',
8785
+ /** @param {*} val @returns {val is bigint} */
8786
+ (val) => typeof val === 'bigint',
8787
+ ],
8788
+ [
8789
+ 'string',
8790
+ /** @param {*} val @returns {val is string} */
8791
+ (val) => typeof val === 'string',
8792
+ ],
8793
+ [
8794
+ 'symbol',
8795
+ /** @param {*} val @returns {val is symbol} */
8796
+ (val) => typeof val === 'symbol',
8797
+ ],
8798
+ [
8799
+ 'function',
8800
+ /** @param {*} val @returns {val is Function} */
8801
+ (val) => typeof val === 'function',
8802
+ ],
8803
+ [
8804
+ 'array',
8805
+ /** @param {*} val @returns {val is any[]} */
8806
+ (val) => Array.isArray(val),
8807
+ ],
8808
+ ]);
8809
+
8810
+ if (!isBrowser) {
8811
+ extendObjType([
8812
+ [
8813
+ 'buffer',
8814
+ /** @param {*} val @returns {val is Buffer} */
8815
+ (val) => typeof buffer/* Buffer */.hp !== 'undefined' && buffer/* Buffer */.hp.isBuffer(val),
8816
+ ],
8817
+ ]);
8720
8818
  }
8721
8819
 
8722
- /**
8723
- * Checks if the given element is fully visible in the viewport (top and bottom).
8724
- *
8725
- * @param {HTMLElement} element - The DOM element to check.
8726
- * @returns {boolean} True if the element is fully visible in the viewport, false otherwise.
8727
- * @deprecated - Use TinyHtml.isScrolledIntoView instead.
8728
- */
8729
- function isScrolledIntoView(element) {
8730
- const viewportTop = window.scrollY;
8731
- const viewportBottom = viewportTop + window.innerHeight;
8820
+ if (isBrowser) {
8821
+ extendObjType([
8822
+ [
8823
+ 'file',
8824
+ /** @param {*} val @returns {val is File} */
8825
+ (val) => typeof File !== 'undefined' && val instanceof File,
8826
+ ],
8827
+ ]);
8828
+ }
8732
8829
 
8733
- const elemTop = element.offsetTop;
8734
- const elemBottom = elemTop + element.offsetHeight;
8830
+ extendObjType([
8831
+ [
8832
+ 'date',
8833
+ /** @param {*} val @returns {val is Date} */
8834
+ (val) => val instanceof Date,
8835
+ ],
8836
+ [
8837
+ 'regexp',
8838
+ /** @param {*} val @returns {val is RegExp} */
8839
+ (val) => val instanceof RegExp,
8840
+ ],
8841
+ [
8842
+ 'map',
8843
+ /** @param {*} val @returns {val is Map<unknown, unknown>} */
8844
+ (val) => val instanceof Map,
8845
+ ],
8846
+ [
8847
+ 'set',
8848
+ /** @param {*} val @returns {val is Set<unknown>} */
8849
+ (val) => val instanceof Set,
8850
+ ],
8851
+ [
8852
+ 'weakmap',
8853
+ /** @param {*} val @returns {val is WeakMap<unknown, unknown>} */
8854
+ (val) => val instanceof WeakMap,
8855
+ ],
8856
+ [
8857
+ 'weakset',
8858
+ /** @param {*} val @returns {val is WeakSet<unknown>} */
8859
+ (val) => val instanceof WeakSet,
8860
+ ],
8861
+ [
8862
+ 'promise',
8863
+ /** @param {*} val @returns {val is Promise<unknown>} */
8864
+ (val) => val instanceof Promise,
8865
+ ],
8866
+ ]);
8735
8867
 
8736
- return elemBottom <= viewportBottom && elemTop >= viewportTop;
8868
+ if (isBrowser) {
8869
+ extendObjType([
8870
+ [
8871
+ 'htmlelement',
8872
+ /** @param {*} val @returns {val is HTMLElement} */
8873
+ (val) => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement,
8874
+ ],
8875
+ ]);
8737
8876
  }
8738
8877
 
8878
+ extendObjType([
8879
+ [
8880
+ 'object',
8881
+ /** @param {*} val @returns {val is Record<string | number | symbol, unknown>} */
8882
+ (val) => isJsonObject(val),
8883
+ ],
8884
+ ]);
8885
+
8739
8886
  ;// ./src/v1/basics/fullScreen.mjs
8740
8887
  /**
8741
8888
  * Checks if the document is currently in fullscreen mode.
@@ -9172,6 +9319,7 @@ export default KeyPressHandler;
9172
9319
 
9173
9320
 
9174
9321
 
9322
+
9175
9323
  })();
9176
9324
 
9177
9325
  window.TinyBasicsEs = __webpack_exports__;