everyday-helper 1.2.9 → 1.2.10

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 (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import {lazy,useCallback,useEffect,useRef,useState,useSyncExternalStore}from'react';import {useLocation}from'react-router-dom';var C=Object.defineProperty;var U=(e,t,n)=>t in e?C(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var o=(e,t)=>C(e,"name",{value:t,configurable:true});var h=(e,t,n)=>U(e,typeof t!="symbol"?t+"":t,n);function _(...e){return e.flatMap(t=>t?typeof t=="string"?[t]:Array.isArray(t)?_(...t):typeof t=="object"?Object.keys(t).filter(n=>!!t[n]):[]:[]).join(" ")}o(_,"cn");var g=o(()=>typeof window>"u","isServer"),p=o(()=>!g(),"isBrowser"),Ee=o(()=>p()?window:void 0,"safeWindow");var O={set:o((e,t,n={domain:"",path:"/"})=>{if(g())return;let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(n.expires){let i=null;typeof n.expires=="number"?(i=new Date,i.setDate(i.getDate()+n.expires)):(typeof n.expires=="string"||n.expires instanceof Date)&&(i=new Date(n.expires)),i&&!isNaN(i.getTime())&&(r+=`; expires=${i.toUTCString()}`);}n.path&&(r+=`; path=${n.path}`),n.domain&&(r+=`; domain=${n.domain}`),n.secure&&(r+="; secure"),n.sameSite&&(r+=`; SameSite=${n.sameSite}`),document.cookie=r;},"set"),get:o(e=>{if(g())return null;let t=document.cookie.split(";");for(let n of t){let[r,i]=n.trim().split("=").map(decodeURIComponent);if(r===e)return i}return null},"get"),remove:o((e,t={domain:"",path:"/"})=>{if(g())return;let n=new Date(0),r=`${encodeURIComponent(e)}=; expires=${n.toUTCString()}`;t.path&&(r+=`; path=${t.path}`),t.domain&&(r+=`; domain=${t.domain}`),document.cookie=r;},"remove")};var P=o(e=>({set:o((t,n)=>{try{e.setItem(t,JSON.stringify(n));}catch(r){console.error(`[Storage] Failed to set "${t}":`,r);}},"set"),get:o(t=>{try{let n=e.getItem(t);return n===null?null:JSON.parse(n)}catch(n){return console.warn(`[Storage] Failed to parse "${t}":`,n),null}},"get"),getOr:o((t,n)=>{let r=e.getItem(t);if(r===null)return n;try{return JSON.parse(r)}catch{return n}},"getOr"),remove:o(t=>{e.removeItem(t);},"remove"),has:o(t=>e.getItem(t)!==null,"has"),clear:o(()=>{e.clear();},"clear"),keys:o(()=>Object.keys(e),"keys")}),"createStorage"),Ye=p()?P(localStorage):null,Ue=p()?P(sessionStorage):null;var D=class D{constructor(t){h(this,"formData");h(this,"options");this.formData=new FormData,this.options={skipNull:false,skipUndefined:true,skipEmptyStrings:false,...t};}append(t,n){return this.shouldSkip(n)?this:(n instanceof File?this.formData.append(t,n):typeof n=="object"&&n!==null?this.formData.append(t,JSON.stringify(n)):typeof n=="boolean"||typeof n=="number"?this.formData.append(t,n.toString()):typeof n=="string"&&this.formData.append(t,n),this)}appendFields(t){return Object.entries(t).forEach(([n,r])=>{this.append(n,r);}),this}appendArray(t,n){return !n||!Array.isArray(n)?this:(n.forEach((r,i)=>{r&&typeof r=="object"&&Object.entries(r).forEach(([s,u])=>{let c=`${t}[${i}].${s}`;this.append(c,u);});}),this)}appendFile(t,n){return n&&this.formData.append(t,n),this}appendJSON(t,n){return this.shouldSkip(n)?this:(n&&typeof n=="object"&&this.formData.append(t,JSON.stringify(n)),this)}build(){return this.formData}shouldSkip(t){return t===void 0&&this.options.skipUndefined||t===null&&this.options.skipNull?true:!!(t===""&&this.options.skipEmptyStrings)}};o(D,"FormDataBuilder");var b=D;function $e(e){return new b(e)}o($e,"createFormData");function $(e,t,n){return new Promise((r,i)=>{let s=o(u=>{e().then(r).catch(c=>{u===0?i(c):setTimeout(()=>s(u-1),n);});},"attempt");s(t);})}o($,"retryImport");var He=o((e,t={})=>{let{retries:n=2,delayMs:r=250}=t,i={};for(let[s,u]of Object.entries(e))i[s]=lazy(()=>$(u,n,r));return i},"lazyLoad");var R={padding:"20px",fit:"contain",maxWidth:"100%",maxHeight:"100%",background:"#fff"},w={printDelay:150,cleanupDelay:1e4},Qe=o(()=>{let e=o((r,i={})=>{let{padding:s,fit:u,maxWidth:c,maxHeight:f,background:m}={...R,...i};return `
1
+ import {lazy,useCallback,useEffect,useRef,useState,useSyncExternalStore}from'react';import {useLocation}from'react-router-dom';var C=Object.defineProperty;var U=(e,t,n)=>t in e?C(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var o=(e,t)=>C(e,"name",{value:t,configurable:true});var h=(e,t,n)=>U(e,typeof t!="symbol"?t+"":t,n);function _(...e){return e.flatMap(t=>t?typeof t=="string"?[t]:Array.isArray(t)?_(...t):typeof t=="object"?Object.keys(t).filter(n=>!!t[n]):[]:[]).join(" ")}o(_,"cn");var g=o(()=>typeof window>"u","isServer"),p=o(()=>!g(),"isBrowser"),Ee=o(()=>p()?window:void 0,"safeWindow");var O={set:o((e,t,n={domain:window.location.hostname,path:"/"})=>{if(g())return;let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(n.expires){let i=null;typeof n.expires=="number"?(i=new Date,i.setDate(i.getDate()+n.expires)):(typeof n.expires=="string"||n.expires instanceof Date)&&(i=new Date(n.expires)),i&&!isNaN(i.getTime())&&(r+=`; expires=${i.toUTCString()}`);}n.path&&(r+=`; path=${n.path}`),n.domain&&(r+=`; domain=${n.domain}`),n.secure&&(r+="; secure"),n.sameSite&&(r+=`; SameSite=${n.sameSite}`),document.cookie=r;},"set"),get:o(e=>{if(g())return null;let t=document.cookie.split(";");for(let n of t){let[r,i]=n.trim().split("=").map(decodeURIComponent);if(r===e)return i}return null},"get"),remove:o((e,t={domain:window.location.hostname,path:"/"})=>{if(g())return;let n=new Date(0),r=`${encodeURIComponent(e)}=; expires=${n.toUTCString()}`;t.path&&(r+=`; path=${t.path}`),t.domain&&(r+=`; domain=${t.domain}`),document.cookie=r;},"remove")};var P=o(e=>({set:o((t,n)=>{try{e.setItem(t,JSON.stringify(n));}catch(r){console.error(`[Storage] Failed to set "${t}":`,r);}},"set"),get:o(t=>{try{let n=e.getItem(t);return n===null?null:JSON.parse(n)}catch(n){return console.warn(`[Storage] Failed to parse "${t}":`,n),null}},"get"),getOr:o((t,n)=>{let r=e.getItem(t);if(r===null)return n;try{return JSON.parse(r)}catch{return n}},"getOr"),remove:o(t=>{e.removeItem(t);},"remove"),has:o(t=>e.getItem(t)!==null,"has"),clear:o(()=>{e.clear();},"clear"),keys:o(()=>Object.keys(e),"keys")}),"createStorage"),Ye=p()?P(localStorage):null,Ue=p()?P(sessionStorage):null;var D=class D{constructor(t){h(this,"formData");h(this,"options");this.formData=new FormData,this.options={skipNull:false,skipUndefined:true,skipEmptyStrings:false,...t};}append(t,n){return this.shouldSkip(n)?this:(n instanceof File?this.formData.append(t,n):typeof n=="object"&&n!==null?this.formData.append(t,JSON.stringify(n)):typeof n=="boolean"||typeof n=="number"?this.formData.append(t,n.toString()):typeof n=="string"&&this.formData.append(t,n),this)}appendFields(t){return Object.entries(t).forEach(([n,r])=>{this.append(n,r);}),this}appendArray(t,n){return !n||!Array.isArray(n)?this:(n.forEach((r,i)=>{r&&typeof r=="object"&&Object.entries(r).forEach(([s,u])=>{let c=`${t}[${i}].${s}`;this.append(c,u);});}),this)}appendFile(t,n){return n&&this.formData.append(t,n),this}appendJSON(t,n){return this.shouldSkip(n)?this:(n&&typeof n=="object"&&this.formData.append(t,JSON.stringify(n)),this)}build(){return this.formData}shouldSkip(t){return t===void 0&&this.options.skipUndefined||t===null&&this.options.skipNull?true:!!(t===""&&this.options.skipEmptyStrings)}};o(D,"FormDataBuilder");var b=D;function $e(e){return new b(e)}o($e,"createFormData");function $(e,t,n){return new Promise((r,i)=>{let s=o(u=>{e().then(r).catch(c=>{u===0?i(c):setTimeout(()=>s(u-1),n);});},"attempt");s(t);})}o($,"retryImport");var He=o((e,t={})=>{let{retries:n=2,delayMs:r=250}=t,i={};for(let[s,u]of Object.entries(e))i[s]=lazy(()=>$(u,n,r));return i},"lazyLoad");var R={padding:"20px",fit:"contain",maxWidth:"100%",maxHeight:"100%",background:"#fff"},w={printDelay:150,cleanupDelay:1e4},Qe=o(()=>{let e=o((r,i={})=>{let{padding:s,fit:u,maxWidth:c,maxHeight:f,background:m}={...R,...i};return `
2
2
  <!DOCTYPE html>
3
3
  <html>
4
4
  <head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "everyday-helper",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "description": "A lightweight collection of React hooks, utility functions, and helpers for modern React development",
5
5
  "license": "MIT",
6
6
  "type": "module",