tiny-essentials 1.18.1 → 1.19.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 (74) hide show
  1. package/README.md +17 -3
  2. package/dist/node_modules/firebase-functions/lib/common/trace.cjs +0 -1
  3. package/dist/node_modules/firebase-functions/lib/logger/index.cjs +1 -0
  4. package/dist/v1/ColorSafeStringify.min.js +1 -1
  5. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  6. package/dist/v1/TinyBasicsEs.js +13 -6
  7. package/dist/v1/TinyBasicsEs.min.js +1 -1
  8. package/dist/v1/TinyClipboard.min.js +1 -1
  9. package/dist/v1/TinyColorConverter.js +617 -0
  10. package/dist/v1/TinyColorConverter.min.js +1 -0
  11. package/dist/v1/TinyDomReadyManager.min.js +1 -1
  12. package/dist/v1/TinyDragger.min.js +1 -1
  13. package/dist/v1/TinyEssentials.js +2635 -482
  14. package/dist/v1/TinyEssentials.min.js +1 -1
  15. package/dist/v1/TinyEvents.js +402 -0
  16. package/dist/v1/TinyEvents.min.js +1 -0
  17. package/dist/v1/TinyHtml.min.js +1 -1
  18. package/dist/v1/TinyLocalStorage.js +1292 -0
  19. package/dist/v1/TinyLocalStorage.min.js +1 -0
  20. package/dist/v1/TinyNotifications.min.js +1 -1
  21. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  22. package/dist/v1/TinyPromiseQueue.min.js +1 -1
  23. package/dist/v1/TinyRateLimiter.js +2 -1
  24. package/dist/v1/TinyRateLimiter.min.js +1 -1
  25. package/dist/v1/TinySmartScroller.js +570 -52
  26. package/dist/v1/TinySmartScroller.min.js +1 -1
  27. package/dist/v1/TinyTextRangeEditor.min.js +1 -1
  28. package/dist/v1/TinyTimeout.js +233 -0
  29. package/dist/v1/TinyTimeout.min.js +1 -0
  30. package/dist/v1/TinyToastNotify.min.js +1 -1
  31. package/dist/v1/TinyUploadClicker.js +1457 -106
  32. package/dist/v1/TinyUploadClicker.min.js +1 -1
  33. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  34. package/dist/v1/basics/html.cjs +13 -6
  35. package/dist/v1/basics/html.d.mts +12 -4
  36. package/dist/v1/basics/html.mjs +13 -6
  37. package/dist/v1/build/TinyColorConverter.cjs +7 -0
  38. package/dist/v1/build/TinyColorConverter.d.mts +3 -0
  39. package/dist/v1/build/TinyColorConverter.mjs +2 -0
  40. package/dist/v1/build/TinyEvents.cjs +7 -0
  41. package/dist/v1/build/TinyEvents.d.mts +3 -0
  42. package/dist/v1/build/TinyEvents.mjs +2 -0
  43. package/dist/v1/build/TinyLocalStorage.cjs +7 -0
  44. package/dist/v1/build/TinyLocalStorage.d.mts +3 -0
  45. package/dist/v1/build/TinyLocalStorage.mjs +2 -0
  46. package/dist/v1/build/TinyTimeout.cjs +7 -0
  47. package/dist/v1/build/TinyTimeout.d.mts +3 -0
  48. package/dist/v1/build/TinyTimeout.mjs +2 -0
  49. package/dist/v1/index.cjs +8 -0
  50. package/dist/v1/index.d.mts +5 -1
  51. package/dist/v1/index.mjs +5 -1
  52. package/dist/v1/libs/TinyColorConverter.cjs +578 -0
  53. package/dist/v1/libs/TinyColorConverter.d.mts +396 -0
  54. package/dist/v1/libs/TinyColorConverter.mjs +520 -0
  55. package/dist/v1/libs/TinyEvents.cjs +363 -0
  56. package/dist/v1/libs/TinyEvents.d.mts +160 -0
  57. package/dist/v1/libs/TinyEvents.mjs +328 -0
  58. package/dist/v1/libs/TinyLocalStorage.cjs +847 -0
  59. package/dist/v1/libs/TinyLocalStorage.d.mts +407 -0
  60. package/dist/v1/libs/TinyLocalStorage.mjs +740 -0
  61. package/dist/v1/libs/TinySmartScroller.cjs +207 -52
  62. package/dist/v1/libs/TinySmartScroller.d.mts +164 -16
  63. package/dist/v1/libs/TinySmartScroller.mjs +181 -52
  64. package/dist/v1/libs/TinyTimeout.cjs +194 -0
  65. package/dist/v1/libs/TinyTimeout.d.mts +89 -0
  66. package/dist/v1/libs/TinyTimeout.mjs +179 -0
  67. package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
  68. package/docs/v1/README.md +4 -0
  69. package/docs/v1/libs/TinyColorConverter.md +220 -0
  70. package/docs/v1/libs/TinyEvents.md +199 -0
  71. package/docs/v1/libs/TinyLocalStorage.md +350 -0
  72. package/docs/v1/libs/TinyRateLimiter.md +0 -3
  73. package/docs/v1/libs/TinyTimeout.md +190 -0
  74. package/package.json +28 -5
package/README.md CHANGED
@@ -70,6 +70,14 @@ Check out the full documentation here:
70
70
 
71
71
  ---
72
72
 
73
+ ### 🔧 Recommended Tool: **JsStore**
74
+
75
+ Although not part of Tiny Essentials, we recommend using [**JsStore**](https://www.npmjs.com/package/jsstore) if you're looking for a well-maintained and developer-friendly solution to interact with **IndexedDB** using SQL-like syntax.
76
+
77
+ > 💬 *This is a personal recommendation. This project is not sponsored or affiliated with JsStore.*
78
+
79
+ ---
80
+
73
81
  ## 🤝 Contributions
74
82
 
75
83
  Feel free to fork, contribute, and create pull requests for improvements! Whether it's a bug fix or an additional feature, contributions are always welcome.
@@ -78,11 +86,17 @@ Feel free to fork, contribute, and create pull requests for improvements! Whethe
78
86
 
79
87
  This project is licensed under the GPL-3.0 License - see the [LICENSE](LICENSE) file for details.
80
88
 
81
- ---
82
-
83
89
  ### 💡 Credits
84
90
 
85
91
  This project was inspired by the need for lightweight, reusable code that can be used across many different kinds of applications. Contributions and suggestions are always appreciated!
86
92
 
87
93
  > 🧠 **Note**: This documentation was written by [ChatGPT](https://openai.com/chatgpt), an AI assistant developed by OpenAI, based on the project structure and descriptions provided by the repository author.
88
- > If you find any inaccuracies or need improvements, feel free to contribute or open an issue!
94
+ > If you find any inaccuracies or need improvements, feel free to contribute or open an issue!
95
+
96
+ ---
97
+
98
+ <div align="center">
99
+ <a href="./test/img/"><img src="./test/img/5ec92aff-7a9d-4b86-bcc3-fe715def537a.png" height="300" /></a>
100
+ <br/>
101
+ Made with tiny love!
102
+ </div>
@@ -11,7 +11,6 @@ function requireTrace () {
11
11
  Object.defineProperty(trace.__exports, "__esModule", { value: true });
12
12
  trace.__exports.extractTraceContext = trace.__exports.traceContext = void 0;
13
13
  const async_hooks_1 = require$$0;
14
- /* @internal */
15
14
  trace.__exports.traceContext = new async_hooks_1.AsyncLocalStorage();
16
15
  /**
17
16
  * A regex to match the Cloud Trace header.
@@ -66,6 +66,7 @@ function requireLogger () {
66
66
  returnObj[k] = removeCircular(obj[k], refs);
67
67
  }
68
68
  }
69
+ refs.pop();
69
70
  return returnObj;
70
71
  }
71
72
  /**
@@ -1 +1 @@
1
- (()=>{"use strict";var e={d:(r,t)=>{for(var s in t)e.o(t,s)&&!e.o(r,s)&&Object.defineProperty(r,s,{enumerable:!0,get:t[s]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)},r={};e.d(r,{ColorSafeStringify:()=>s});class t{#e;static#r={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...t.#r.default,...e}}#t(e,r){const t=[];e=(e=(e=e.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${r.number}$1${r.reset}`)).replace(/"([^"]+)":/g,((e,r)=>{const s=`___KEY${t.length}___`;return t.push({marker:s,key:r}),`${s}:`}))).replace(/"(?:\\.|[^"\\])*?"/g,(e=>{const t=e.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(t)?`${r.string_url}${e}${r.reset}`:/^(true|false|null)$/.test(t)?`${r.string_bool}${e}${r.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(t)?`${r.string_number}${e}${r.reset}`:`${r.string}${e}${r.reset}`}));for(const{marker:s,key:o}of t){const t=new RegExp(s,"g");e=e.replace(t,`${r.key}"${o}"${r.reset}`)}return(e=(e=(e=(e=e.replace(/(?<!")\b(true|false)\b(?!")/g,`${r.boolean}$1${r.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${r.null}null${r.reset}`)).replace(/\[Circular\]/g,`${r.special}[Circular]${r.reset}`)).replace(/\[undefined\]/g,`${r.special}[undefined]${r.reset}`)).replace(/"function.*?[^\\]"/gs,`${r.func}$&${r.reset}`)}colorize(e,r={}){const t={...this.#e,...r};return this.#t(e,t)}getColors(){return{...this.#e}}updateColors(e){Object.assign(this.#e,e)}resetColors(){this.#e={...t.#r.default}}loadColorPreset(e){const r=t.#r[e];if(!r)throw new Error(`Preset "${e}" not found.`);this.#e={...r}}saveColorPreset(e,r){t.#r[e]={...r}}getAvailablePresets(){return Object.keys(t.#r)}}const s=t;window.ColorSafeStringify=r.ColorSafeStringify})();
1
+ (()=>{"use strict";var e={d:(r,t)=>{for(var s in t)e.o(t,s)&&!e.o(r,s)&&Object.defineProperty(r,s,{enumerable:!0,get:t[s]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)},r={};e.d(r,{ColorSafeStringify:()=>s});class t{#e;static#r={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...t.#r.default,...e}}#t(e,r){const t=[];e=(e=(e=e.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${r.number}$1${r.reset}`)).replace(/"([^"]+)":/g,(e,r)=>{const s=`___KEY${t.length}___`;return t.push({marker:s,key:r}),`${s}:`})).replace(/"(?:\\.|[^"\\])*?"/g,e=>{const t=e.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(t)?`${r.string_url}${e}${r.reset}`:/^(true|false|null)$/.test(t)?`${r.string_bool}${e}${r.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(t)?`${r.string_number}${e}${r.reset}`:`${r.string}${e}${r.reset}`});for(const{marker:s,key:o}of t){const t=new RegExp(s,"g");e=e.replace(t,`${r.key}"${o}"${r.reset}`)}return(e=(e=(e=(e=e.replace(/(?<!")\b(true|false)\b(?!")/g,`${r.boolean}$1${r.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${r.null}null${r.reset}`)).replace(/\[Circular\]/g,`${r.special}[Circular]${r.reset}`)).replace(/\[undefined\]/g,`${r.special}[undefined]${r.reset}`)).replace(/"function.*?[^\\]"/gs,`${r.func}$&${r.reset}`)}colorize(e,r={}){const t={...this.#e,...r};return this.#t(e,t)}getColors(){return{...this.#e}}updateColors(e){Object.assign(this.#e,e)}resetColors(){this.#e={...t.#r.default}}loadColorPreset(e){const r=t.#r[e];if(!r)throw new Error(`Preset "${e}" not found.`);this.#e={...r}}saveColorPreset(e,r){t.#r[e]={...r}}getAvailablePresets(){return Object.keys(t.#r)}}const s=t;window.ColorSafeStringify=r.ColorSafeStringify})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{TinyAfterScrollWatcher:()=>r});const r=class{#e;#t=null;#r=[];#i=100;#o=new Set;#n=new Set;#s=!1;constructor(e=window,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#e=e,this._checkTimer=this._checkTimer.bind(this),this.#e.addEventListener("scroll",this._checkTimer),this.#i=t}_checkTimer=()=>{this.#t&&clearTimeout(this.#t),this.#t=setTimeout((()=>{this.#t=null,this.#l()}),this.#i)};get inactivityTime(){return this.#i}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#i=e}#l(){if(!this.#s){for(const e of this.#n)"function"==typeof e&&e();for(;this.#r.length;){const e=this.#r.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#r.push(e)}onStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#n.add(e)}offStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#n.delete(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#e.addEventListener("scroll",e),this.#o.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#o.has(e)&&(this.#e.removeEventListener("scroll",e),this.#o.delete(e))}destroy(){if(!this.#s){this.#s=!0,this.#e.removeEventListener("scroll",this._checkTimer);for(const e of this.#o)this.#e.removeEventListener("scroll",e);this.#o.clear(),this.#n.clear()}}};window.TinyAfterScrollWatcher=t.TinyAfterScrollWatcher})();
1
+ (()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{TinyAfterScrollWatcher:()=>r});const r=class{#e;#t=null;#r=[];#i=100;#o=new Set;#n=new Set;#s=!1;constructor(e=window,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#e=e,this._checkTimer=this._checkTimer.bind(this),this.#e.addEventListener("scroll",this._checkTimer),this.#i=t}_checkTimer=()=>{this.#t&&clearTimeout(this.#t),this.#t=setTimeout(()=>{this.#t=null,this.#l()},this.#i)};get inactivityTime(){return this.#i}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#i=e}#l(){if(!this.#s){for(const e of this.#n)"function"==typeof e&&e();for(;this.#r.length;){const e=this.#r.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#r.push(e)}onStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#n.add(e)}offStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#n.delete(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#e.addEventListener("scroll",e),this.#o.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#o.has(e)&&(this.#e.removeEventListener("scroll",e),this.#o.delete(e))}destroy(){if(!this.#s){this.#s=!0,this.#e.removeEventListener("scroll",this._checkTimer);for(const e of this.#o)this.#e.removeEventListener("scroll",e);this.#o.clear(),this.#n.clear()}}};window.TinyAfterScrollWatcher=t.TinyAfterScrollWatcher})();
@@ -2857,8 +2857,8 @@ async function fetchBlob(url, allowedMimeTypes, options) {
2857
2857
  * @param {Element} [settings.element=document.body] - The element to receive visibility classes.
2858
2858
  * @param {string} [settings.hiddenClass='windowHidden'] - CSS class applied when the page is hidden.
2859
2859
  * @param {string} [settings.visibleClass='windowVisible'] - CSS class applied when the page is visible.
2860
- * @param {() => void} [settings.onVisible] - Callback called when page becomes visible.
2861
- * @param {() => void} [settings.onHidden] - Callback called when page becomes hidden.
2860
+ * @param {(data: { type: string; oldType: string; oldClass: string; }) => void} [settings.onVisible] - Callback called when page becomes visible.
2861
+ * @param {(data: { type: string; oldType: string; oldClass: string; }) => void} [settings.onHidden] - Callback called when page becomes hidden.
2862
2862
  * @returns {() => void} Function that removes all installed event listeners.
2863
2863
  * @throws {TypeError} If any provided setting is invalid.
2864
2864
  */
@@ -2878,6 +2878,8 @@ function installWindowHiddenScript({
2878
2878
  if (onHidden !== undefined && typeof onHidden !== 'function')
2879
2879
  throw new TypeError(`"onHidden" must be a function if provided.`);
2880
2880
 
2881
+ let oldType = '';
2882
+ let oldClass = '';
2881
2883
  const removeClass = () => {
2882
2884
  element.classList.remove(hiddenClass);
2883
2885
  element.classList.remove(visibleClass);
@@ -2915,19 +2917,24 @@ function installWindowHiddenScript({
2915
2917
 
2916
2918
  if (visibleEvents.includes(type)) {
2917
2919
  element.classList.add(visibleClass);
2918
- onVisible?.();
2920
+ onVisible?.({ type, oldClass, oldType });
2921
+ oldClass = visibleClass;
2919
2922
  } else if (hiddenEvents.includes(type)) {
2920
2923
  element.classList.add(hiddenClass);
2921
- onHidden?.();
2924
+ onHidden?.({ type, oldClass, oldType });
2925
+ oldClass = hiddenClass;
2922
2926
  } else {
2923
2927
  if (isHidden) {
2924
2928
  element.classList.add(hiddenClass);
2925
- onHidden?.();
2929
+ onHidden?.({ type, oldClass, oldType });
2930
+ oldClass = hiddenClass;
2926
2931
  } else {
2927
2932
  element.classList.add(visibleClass);
2928
- onVisible?.();
2933
+ onVisible?.({ type, oldClass, oldType });
2934
+ oldClass = visibleClass;
2929
2935
  }
2930
2936
  }
2937
+ oldType = type;
2931
2938
  };
2932
2939
 
2933
2940
  /** @type {() => void} */