dphelper 4.3.5 → 4.5.2
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.
- package/README.md +39 -29
- package/SECURITY.md +26 -26
- package/index.cjs +11 -11
- package/index.js +11 -11
- package/modules/ai.cjs +7 -0
- package/modules/ai.d.ts +15 -0
- package/modules/ai.js +7 -0
- package/modules/anchor.cjs +4 -0
- package/modules/anchor.d.ts +10 -0
- package/modules/anchor.js +4 -0
- package/modules/array.cjs +1 -0
- package/modules/array.d.ts +25 -0
- package/modules/array.js +1 -0
- package/modules/audio.cjs +1 -0
- package/modules/audio.d.ts +14 -0
- package/modules/audio.js +1 -0
- package/modules/avoid.cjs +1 -0
- package/modules/avoid.d.ts +6 -0
- package/modules/avoid.js +1 -0
- package/modules/biometric.cjs +2 -0
- package/modules/biometric.d.ts +18 -0
- package/modules/biometric.js +2 -0
- package/modules/browser.cjs +37 -0
- package/modules/browser.d.ts +14 -0
- package/modules/browser.js +37 -0
- package/modules/check.cjs +1 -0
- package/modules/check.d.ts +8 -0
- package/modules/check.js +1 -0
- package/modules/color.cjs +1 -0
- package/modules/color.d.ts +10 -0
- package/modules/color.js +1 -0
- package/modules/compress.cjs +1 -0
- package/modules/compress.d.ts +17 -0
- package/modules/compress.js +1 -0
- package/modules/cookie.cjs +1 -0
- package/modules/cookie.d.ts +16 -0
- package/modules/cookie.js +1 -0
- package/modules/coords.cjs +8 -0
- package/modules/coords.d.ts +12 -0
- package/modules/coords.js +8 -0
- package/modules/credits.cjs +1 -0
- package/modules/credits.d.ts +15 -0
- package/modules/credits.js +1 -0
- package/modules/date.cjs +12 -0
- package/modules/date.d.ts +29 -0
- package/modules/date.js +12 -0
- package/modules/disable.cjs +1 -0
- package/modules/disable.d.ts +12 -0
- package/modules/disable.js +1 -0
- package/modules/dispatch.cjs +1 -0
- package/modules/dispatch.d.ts +8 -0
- package/modules/dispatch.js +1 -0
- package/modules/elements.cjs +1 -0
- package/modules/elements.d.ts +7 -0
- package/modules/elements.js +1 -0
- package/modules/events.cjs +1 -0
- package/modules/events.d.ts +10 -0
- package/modules/events.js +1 -0
- package/modules/fetch.cjs +2 -0
- package/modules/fetch.d.ts +19 -0
- package/modules/fetch.js +2 -0
- package/modules/form.cjs +1 -0
- package/modules/form.d.ts +17 -0
- package/modules/form.js +1 -0
- package/modules/format.cjs +1 -0
- package/modules/format.d.ts +7 -0
- package/modules/format.js +1 -0
- package/modules/i18n.cjs +1 -0
- package/modules/i18n.d.ts +15 -0
- package/modules/i18n.js +1 -0
- package/modules/image.cjs +1 -0
- package/modules/image.d.ts +17 -0
- package/modules/image.js +1 -0
- package/modules/json.cjs +3 -0
- package/modules/json.d.ts +12 -0
- package/modules/json.js +3 -0
- package/modules/load.cjs +1 -0
- package/modules/load.d.ts +12 -0
- package/modules/load.js +1 -0
- package/modules/logging.cjs +1 -0
- package/modules/logging.d.ts +12 -0
- package/modules/logging.js +1 -0
- package/modules/math.cjs +1 -0
- package/modules/math.d.ts +17 -0
- package/modules/math.js +1 -0
- package/modules/memory.cjs +1 -0
- package/modules/memory.d.ts +7 -0
- package/modules/memory.js +1 -0
- package/modules/navigation.cjs +2 -0
- package/modules/navigation.d.ts +8 -0
- package/modules/navigation.js +2 -0
- package/modules/net.cjs +1 -0
- package/modules/net.d.ts +14 -0
- package/modules/net.js +1 -0
- package/modules/objects.cjs +4 -0
- package/modules/objects.d.ts +19 -0
- package/modules/objects.js +4 -0
- package/modules/path.cjs +1 -0
- package/modules/path.d.ts +8 -0
- package/modules/path.js +1 -0
- package/modules/promise.cjs +1 -0
- package/modules/promise.d.ts +7 -0
- package/modules/promise.js +1 -0
- package/modules/sanitize.cjs +2 -0
- package/modules/sanitize.d.ts +6 -0
- package/modules/sanitize.js +2 -0
- package/modules/screen.cjs +1 -0
- package/modules/screen.d.ts +15 -0
- package/modules/screen.js +1 -0
- package/modules/scrollbar.cjs +65 -0
- package/modules/scrollbar.d.ts +13 -0
- package/modules/scrollbar.js +65 -0
- package/modules/security.cjs +1 -0
- package/modules/security.d.ts +19 -0
- package/modules/security.js +1 -0
- package/modules/shortcut.cjs +1 -0
- package/modules/shortcut.d.ts +6 -0
- package/modules/shortcut.js +1 -0
- package/modules/socket.cjs +2 -0
- package/modules/socket.d.ts +17 -0
- package/modules/socket.js +2 -0
- package/modules/sse.cjs +2 -0
- package/modules/sse.d.ts +12 -0
- package/modules/sse.js +2 -0
- package/modules/svg.cjs +2 -0
- package/modules/svg.d.ts +16 -0
- package/modules/svg.js +2 -0
- package/modules/sync.cjs +1 -0
- package/modules/sync.d.ts +17 -0
- package/modules/sync.js +1 -0
- package/modules/system.cjs +1 -0
- package/modules/system.d.ts +6 -0
- package/modules/system.js +1 -0
- package/modules/text.cjs +15 -0
- package/modules/text.d.ts +16 -0
- package/modules/text.js +15 -0
- package/modules/timer.cjs +1 -0
- package/modules/timer.d.ts +7 -0
- package/modules/timer.js +1 -0
- package/modules/tools.cjs +1 -0
- package/modules/tools.d.ts +9 -0
- package/modules/tools.js +1 -0
- package/modules/translators.cjs +1 -0
- package/modules/translators.d.ts +6 -0
- package/modules/translators.js +1 -0
- package/modules/triggers.cjs +1 -0
- package/modules/triggers.d.ts +47 -0
- package/modules/triggers.js +1 -0
- package/modules/types.cjs +1 -0
- package/modules/types.d.ts +9 -0
- package/modules/types.js +1 -0
- package/modules/ui.cjs +6 -0
- package/modules/ui.d.ts +7 -0
- package/modules/ui.js +6 -0
- package/modules/window.cjs +7 -0
- package/modules/window.d.ts +13 -0
- package/modules/window.js +7 -0
- package/modules/worker.cjs +2 -0
- package/modules/worker.d.ts +20 -0
- package/modules/worker.js +2 -0
- package/package.json +277 -4
- package/sbom.json +48 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';var m={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var b={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...m},configurable:true,writable:true},version:{value:b.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var n=dphelper;Object.defineProperty(n,"setProps",{value:(t,e,r)=>{Object.defineProperty(t,e.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(n,"setDescription",{value:(t,e)=>{Object.defineProperties(n,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(r=>(Object.defineProperties(n[t.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),n.setProps(n,t,{writable:false,configurable:false,enumerable:false}),n._list.scripts.push(t);}});var y={name:"scrollbar",active:true,subCommand:[{name:"custom",version:"0.0.2",example:"dphelper.scrollbar.custom(selector)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Apply custom styles to the scrollbar for the selected elements.",env:"client",subCommand:[]},{name:"indicator",version:"0.0.2",example:"dphelper.scrollbar.indicator(selector)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Add a scroll indicator to the selected elements.",env:"client",subCommand:[]},{name:"position.get",version:"0.0.2",example:"dphelper.scrollbar.position.get(selector)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Get the current scroll position of the selected elements.",env:"client",subCommand:[]},{name:"position.set",version:"0.0.2",example:"dphelper.scrollbar.position.set(selector, position)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Set the scroll position of the selected elements.",env:"client",subCommand:[]},{name:"smooth",version:"0.0.2",example:"dphelper.scrollbar.smooth(container, element, gap)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Smoothly scroll to a specific element within a container with an optional gap.",env:"client",subCommand:[]},{name:"scrollTo",version:"0.0.2",example:"dphelper.scrollbar.scrollTo(container, element, gap)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Scroll to a specific element within a container with an optional gap.",env:"client",subCommand:[]}]},v={custom:(t,e)=>{e.color_1=e?.color_1||"black",e.color_1_hover=e?.color_1_hover||"black",e.color_2=e?.color_2||"transparent",e.color_3=e?.color_3||"rgba(30,150,255,.5)",e.type=e?.type||"thin",e.behavior=e?.behavior||"smooth",e.width=e?.width||"16px",e.height=e?.height||"16px",e.rounded=e?.rounded||"10px",e.margin=e?.margin||0,e.border=e?.border||"5px",e.opacity=e?.opacity||1;let r=` ${t}::-webkit-scrollbar {
|
|
2
|
+
scroll-behavior: ${e.behavior};
|
|
3
|
+
width: ${e.width};
|
|
4
|
+
height: ${e.height};
|
|
5
|
+
}
|
|
6
|
+
${t}::-webkit-scrollbar-thumb {
|
|
7
|
+
opacity: ${e.opacity} !important;
|
|
8
|
+
-webkit-border-radius: ${e.rounded} !important;
|
|
9
|
+
-webkit-box-shadow: none !important;
|
|
10
|
+
box-shadow: none !important;
|
|
11
|
+
border-radius: ${e.rounded} !important;
|
|
12
|
+
background: ${e.color_1} !important;
|
|
13
|
+
background-clip: content-box !important;
|
|
14
|
+
border: ${e.border} solid transparent !important;
|
|
15
|
+
min-height: 2px !important;
|
|
16
|
+
min-width: 2px !important;
|
|
17
|
+
}
|
|
18
|
+
${t}::-webkit-scrollbar-thumb:hover{
|
|
19
|
+
background: ${e.color_1_hover} !important;
|
|
20
|
+
}
|
|
21
|
+
${t}::-webkit-scrollbar-thumb:active{
|
|
22
|
+
background: ${e.color_1} !important;
|
|
23
|
+
background-clip: content-box !important;
|
|
24
|
+
border: calc( ${e.border} - 1.5px ) solid transparent !important;
|
|
25
|
+
}
|
|
26
|
+
${t}::-webkit-scrollbar-track {
|
|
27
|
+
background: ${e.color_2};
|
|
28
|
+
border-radius: ${e.rounded};
|
|
29
|
+
}
|
|
30
|
+
${t}::-webkit-scrollbar-track:hover {
|
|
31
|
+
/*background: rgba(128,128,128,.15) !important;*/
|
|
32
|
+
}
|
|
33
|
+
${t}::-webkit-scrollbar-track:vertical:hover {
|
|
34
|
+
/* border-left: 1px solid rgba(0,0,0,.1) !important; */
|
|
35
|
+
}
|
|
36
|
+
${t}::-webkit-scrollbar-track:horizontal:hover {
|
|
37
|
+
/* border-top: 1px solid rgba(0,0,0,.1) !important; */
|
|
38
|
+
}
|
|
39
|
+
${t}::-webkit-scrollbar-corner {
|
|
40
|
+
background:rgba(0,0,0,0)
|
|
41
|
+
}
|
|
42
|
+
/*
|
|
43
|
+
${t}::-webkit-scrollbar-thumb:window-inactive {
|
|
44
|
+
background: ${e.color_3}
|
|
45
|
+
}
|
|
46
|
+
*/
|
|
47
|
+
select::-webkit-scrollbar-thumb {
|
|
48
|
+
border: 4px solid hsl(0 0% 92% / 1) !important;
|
|
49
|
+
}
|
|
50
|
+
select::-webkit-scrollbar-track {
|
|
51
|
+
background: hsl(0 0% 92% / 1) !important;
|
|
52
|
+
}
|
|
53
|
+
select::-webkit-scrollbar-track:vertical,
|
|
54
|
+
select::-webkit-scrollbar-track:horizontal {
|
|
55
|
+
border-top: none !important;
|
|
56
|
+
border-left: none !important;
|
|
57
|
+
}
|
|
58
|
+
`,o=document.createElement("style");document.head.appendChild(o),o.innerHTML=r;},indicator:t=>{let e=document.querySelector(t.el),r=document.querySelector(".scrollindicator");if(!r){let o=document.createElement("div");o.classList.add("scrollindicator"),document.querySelector("header")?.appendChild(o),o.style.cssText=`
|
|
59
|
+
height:5px;
|
|
60
|
+
background:#65c45c;
|
|
61
|
+
position:absolute;
|
|
62
|
+
bottom:0;
|
|
63
|
+
left:0;
|
|
64
|
+
z-index:2
|
|
65
|
+
`;}if(!t.el&&r){r.style.width="0%";return}try{let o=document.querySelector(".scrollindicator");e.addEventListener("scroll",function(a){o.style.width="0%";let c=Number(this.scrollTop),i=Number(this.scrollHeight-this.clientHeight),s=Math.min(Math.max(c/i*100),100);o.style.width=`${s}%`,o.click();}),e.addEventListener("popstate",a=>{o.style.width=0;});}catch(o){console.error(o);return}},position:{set:t=>{let e=typeof t=="string"?document.querySelector(t):t;if(!e)return;let r=[e.scrollTop,e.scrollLeft];r[0]!=null&&r[1]!=null&&localStorage.setItem(t,JSON.stringify(r));},get:t=>{if(localStorage.getItem(t))try{let e=localStorage.getItem(t),r=typeof t=="string"?document.querySelector(t):t;r&&e&&(r.scrollTop=e[0],r.scrollLeft=e[1]);}catch(e){console.error("Error getting scroll position:",e);}}},smooth:(t,e,r)=>{t===document&&(t=document.scrollingElement||document.documentElement||document.body.parentNode||document.body);let o=false,a=t.scrollTop,c=t===document.body&&document.documentElement?document.documentElement:t,i=l=>{l.preventDefault();let h=s(l);a+=-h*e,a=Math.max(0,Math.min(a,t.scrollHeight-c.clientHeight)),o||u();};t.addEventListener("mousewheel",i,{passive:false}),t.addEventListener("DOMMouseScroll",i,{passive:false});let s=l=>l.detail?l.wheelDelta?l.wheelDelta/l.detail/40*(l.detail>0?1:-1):-l.detail/3:l.wheelDelta/120,u=()=>{o=true;let l=(a-t.scrollTop)/r;t.scrollTop+=l,Math.abs(l)>.5?p(u):o=false;},p=dphelper.window.animationframe();},scrollTo:(t,e,r=0)=>{let o=document.querySelector(t),a=document.querySelector(e);o&&a&&o.scrollTo({top:a.offsetTop-r,behavior:"smooth"});}};dphelper?.setDescription(y,v);var P=dphelper.scrollbar;exports.scrollbar=P;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
+
export interface ScrollbarTool {
|
|
3
|
+
custom: (el: string, options: any) => void
|
|
4
|
+
indicator: (props: any) => void
|
|
5
|
+
position: {
|
|
6
|
+
get: (el: any) => void
|
|
7
|
+
set: (el: any) => void
|
|
8
|
+
}
|
|
9
|
+
smooth: (target: any, speed: any, smooth: any) => void
|
|
10
|
+
scrollTo: (container: string, element: string, gap?: number) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const scrollbar: ScrollbarTool
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var b={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var p={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...b},configurable:true,writable:true},version:{value:p.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var n=dphelper;Object.defineProperty(n,"setProps",{value:(t,e,r)=>{Object.defineProperty(t,e.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(n,"setDescription",{value:(t,e)=>{Object.defineProperties(n,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(r=>(Object.defineProperties(n[t.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),n.setProps(n,t,{writable:false,configurable:false,enumerable:false}),n._list.scripts.push(t);}});var v={name:"scrollbar",active:true,subCommand:[{name:"custom",version:"0.0.2",example:"dphelper.scrollbar.custom(selector)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Apply custom styles to the scrollbar for the selected elements.",env:"client",subCommand:[]},{name:"indicator",version:"0.0.2",example:"dphelper.scrollbar.indicator(selector)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Add a scroll indicator to the selected elements.",env:"client",subCommand:[]},{name:"position.get",version:"0.0.2",example:"dphelper.scrollbar.position.get(selector)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Get the current scroll position of the selected elements.",env:"client",subCommand:[]},{name:"position.set",version:"0.0.2",example:"dphelper.scrollbar.position.set(selector, position)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Set the scroll position of the selected elements.",env:"client",subCommand:[]},{name:"smooth",version:"0.0.2",example:"dphelper.scrollbar.smooth(container, element, gap)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Smoothly scroll to a specific element within a container with an optional gap.",env:"client",subCommand:[]},{name:"scrollTo",version:"0.0.2",example:"dphelper.scrollbar.scrollTo(container, element, gap)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Scroll to a specific element within a container with an optional gap.",env:"client",subCommand:[]}]},w={custom:(t,e)=>{e.color_1=e?.color_1||"black",e.color_1_hover=e?.color_1_hover||"black",e.color_2=e?.color_2||"transparent",e.color_3=e?.color_3||"rgba(30,150,255,.5)",e.type=e?.type||"thin",e.behavior=e?.behavior||"smooth",e.width=e?.width||"16px",e.height=e?.height||"16px",e.rounded=e?.rounded||"10px",e.margin=e?.margin||0,e.border=e?.border||"5px",e.opacity=e?.opacity||1;let r=` ${t}::-webkit-scrollbar {
|
|
2
|
+
scroll-behavior: ${e.behavior};
|
|
3
|
+
width: ${e.width};
|
|
4
|
+
height: ${e.height};
|
|
5
|
+
}
|
|
6
|
+
${t}::-webkit-scrollbar-thumb {
|
|
7
|
+
opacity: ${e.opacity} !important;
|
|
8
|
+
-webkit-border-radius: ${e.rounded} !important;
|
|
9
|
+
-webkit-box-shadow: none !important;
|
|
10
|
+
box-shadow: none !important;
|
|
11
|
+
border-radius: ${e.rounded} !important;
|
|
12
|
+
background: ${e.color_1} !important;
|
|
13
|
+
background-clip: content-box !important;
|
|
14
|
+
border: ${e.border} solid transparent !important;
|
|
15
|
+
min-height: 2px !important;
|
|
16
|
+
min-width: 2px !important;
|
|
17
|
+
}
|
|
18
|
+
${t}::-webkit-scrollbar-thumb:hover{
|
|
19
|
+
background: ${e.color_1_hover} !important;
|
|
20
|
+
}
|
|
21
|
+
${t}::-webkit-scrollbar-thumb:active{
|
|
22
|
+
background: ${e.color_1} !important;
|
|
23
|
+
background-clip: content-box !important;
|
|
24
|
+
border: calc( ${e.border} - 1.5px ) solid transparent !important;
|
|
25
|
+
}
|
|
26
|
+
${t}::-webkit-scrollbar-track {
|
|
27
|
+
background: ${e.color_2};
|
|
28
|
+
border-radius: ${e.rounded};
|
|
29
|
+
}
|
|
30
|
+
${t}::-webkit-scrollbar-track:hover {
|
|
31
|
+
/*background: rgba(128,128,128,.15) !important;*/
|
|
32
|
+
}
|
|
33
|
+
${t}::-webkit-scrollbar-track:vertical:hover {
|
|
34
|
+
/* border-left: 1px solid rgba(0,0,0,.1) !important; */
|
|
35
|
+
}
|
|
36
|
+
${t}::-webkit-scrollbar-track:horizontal:hover {
|
|
37
|
+
/* border-top: 1px solid rgba(0,0,0,.1) !important; */
|
|
38
|
+
}
|
|
39
|
+
${t}::-webkit-scrollbar-corner {
|
|
40
|
+
background:rgba(0,0,0,0)
|
|
41
|
+
}
|
|
42
|
+
/*
|
|
43
|
+
${t}::-webkit-scrollbar-thumb:window-inactive {
|
|
44
|
+
background: ${e.color_3}
|
|
45
|
+
}
|
|
46
|
+
*/
|
|
47
|
+
select::-webkit-scrollbar-thumb {
|
|
48
|
+
border: 4px solid hsl(0 0% 92% / 1) !important;
|
|
49
|
+
}
|
|
50
|
+
select::-webkit-scrollbar-track {
|
|
51
|
+
background: hsl(0 0% 92% / 1) !important;
|
|
52
|
+
}
|
|
53
|
+
select::-webkit-scrollbar-track:vertical,
|
|
54
|
+
select::-webkit-scrollbar-track:horizontal {
|
|
55
|
+
border-top: none !important;
|
|
56
|
+
border-left: none !important;
|
|
57
|
+
}
|
|
58
|
+
`,o=document.createElement("style");document.head.appendChild(o),o.innerHTML=r;},indicator:t=>{let e=document.querySelector(t.el),r=document.querySelector(".scrollindicator");if(!r){let o=document.createElement("div");o.classList.add("scrollindicator"),document.querySelector("header")?.appendChild(o),o.style.cssText=`
|
|
59
|
+
height:5px;
|
|
60
|
+
background:#65c45c;
|
|
61
|
+
position:absolute;
|
|
62
|
+
bottom:0;
|
|
63
|
+
left:0;
|
|
64
|
+
z-index:2
|
|
65
|
+
`;}if(!t.el&&r){r.style.width="0%";return}try{let o=document.querySelector(".scrollindicator");e.addEventListener("scroll",function(a){o.style.width="0%";let c=Number(this.scrollTop),i=Number(this.scrollHeight-this.clientHeight),s=Math.min(Math.max(c/i*100),100);o.style.width=`${s}%`,o.click();}),e.addEventListener("popstate",a=>{o.style.width=0;});}catch(o){console.error(o);return}},position:{set:t=>{let e=typeof t=="string"?document.querySelector(t):t;if(!e)return;let r=[e.scrollTop,e.scrollLeft];r[0]!=null&&r[1]!=null&&localStorage.setItem(t,JSON.stringify(r));},get:t=>{if(localStorage.getItem(t))try{let e=localStorage.getItem(t),r=typeof t=="string"?document.querySelector(t):t;r&&e&&(r.scrollTop=e[0],r.scrollLeft=e[1]);}catch(e){console.error("Error getting scroll position:",e);}}},smooth:(t,e,r)=>{t===document&&(t=document.scrollingElement||document.documentElement||document.body.parentNode||document.body);let o=false,a=t.scrollTop,c=t===document.body&&document.documentElement?document.documentElement:t,i=l=>{l.preventDefault();let f=s(l);a+=-f*e,a=Math.max(0,Math.min(a,t.scrollHeight-c.clientHeight)),o||m();};t.addEventListener("mousewheel",i,{passive:false}),t.addEventListener("DOMMouseScroll",i,{passive:false});let s=l=>l.detail?l.wheelDelta?l.wheelDelta/l.detail/40*(l.detail>0?1:-1):-l.detail/3:l.wheelDelta/120,m=()=>{o=true;let l=(a-t.scrollTop)/r;t.scrollTop+=l,Math.abs(l)>.5?h(m):o=false;},h=dphelper.window.animationframe();},scrollTo:(t,e,r=0)=>{let o=document.querySelector(t),a=document.querySelector(e);o&&a&&o.scrollTo({top:a.offsetTop-r,behavior:"smooth"});}};dphelper?.setDescription(v,w);var j=dphelper.scrollbar;export{j as scrollbar};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var f={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var m={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...f},configurable:true,writable:true},version:{value:m.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var l=dphelper;Object.defineProperty(l,"setProps",{value:(e,r,n)=>{Object.defineProperty(e,r.name,n||{writable:false,configurable:false,enumerable:false}),n?.lock&&Object.freeze(e[r.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(l,"setDescription",{value:(e,r)=>{Object.defineProperties(l,{[e.name]:{value:r,writable:false,configurable:false,enumerable:false}}),Object.keys(r).map(n=>(Object.defineProperties(l[e.name],{[n]:{writable:false,configurable:false,enumerable:false}}),null)),l.setProps(l,e,{writable:false,configurable:false,enumerable:false}),l._list.scripts.push(e);}});var x={name:"security",active:true,subCommand:[{name:"uuid",version:"0.0.2",example:"dphelper.security.uuid",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"UUID related commands",subCommand:[{name:"byVal",version:"0.0.2",example:"dphelper.security.uuid.byVal('string')",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",type:"function",active:true,description:"Generate a UUID based on a given string",env:"both",subCommand:[]},{name:"v4",version:"0.0.2",example:"dphelper.security.uuid.v4",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"return",active:true,description:"Generate a random UUID v4",env:"both",subCommand:[]},{name:"v5",version:"0.0.2",example:"dphelper.security.uuid.v5",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"return",active:true,description:"Generate a random UUID v5",env:"both",subCommand:[]}]},{name:"hashPass",description:"Generate a crypto digest starting from user and password values (Uses SHA-256, CNSA compliant)",example:"dphelper.security.hashPass(user, password)",version:"0.0.3",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260329",active:true,env:"both",subCommand:[]},{name:"crypt",description:"Encrypt your message using a secret_key in a default format AES",example:"dphelper.security.crypt(data, secret_key, [optional mode])",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"deCrypt",description:"Decrypt your message using a secret_key in a default format AES",example:"dphelper.security.deCrypt(data, secret_key, [optional mode])",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"AES_KeyGen",description:"Generate a key based on the AES algorithm",example:"dphelper.security.AES_KeyGen(secret_key)",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"SHA256_Hex",description:"Generate a SHA256 hash in hexadecimal format",example:"dphelper.security.SHA256_Hex(secret_key)",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",active:true,env:"both",subCommand:[]},{name:"ulid",description:"Generate ULID code",example:"dphelper.security.ulid()",version:"0.0.2",type:"function",author:"mix",creationDate:"20250212",lastMod:"20250212",active:true,env:"both",subCommand:[]},{name:"fingerprint",description:"Generate a unique browser fingerprint",example:"dphelper.security.fingerprint()",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"saveEncrypted",description:"Save encrypted data to localStorage",example:"dphelper.security.saveEncrypted('key', 'value', 'secret')",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"getEncrypted",description:"Retrieve and decrypt data from localStorage",example:"dphelper.security.getEncrypted('key', 'secret')",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]}]},p=new TextEncoder,A=new TextDecoder,S=e=>{let r=new Uint8Array(e),n="";for(let t=0;t<r.byteLength;t++)n+=String.fromCharCode(r[t]);return btoa(n)},D=e=>{let r=atob(e),n=new Uint8Array(r.length);for(let t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return n.buffer},P=async e=>{let r=p.encode(e),n=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")},h=async(e,r)=>{let n=p.encode(r),t=await crypto.subtle.importKey("raw",n,{name:"HMAC",hash:"SHA-256"},false,["sign"]),s=await crypto.subtle.sign("HMAC",t,p.encode(e));return Array.from(new Uint8Array(s)).map(a=>a.toString(16).padStart(2,"0")).join("")},g=async(e,r,n)=>{let t=await crypto.subtle.importKey("raw",p.encode(e),"PBKDF2",false,["deriveBits","deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:r.buffer,iterations:n,hash:"SHA-256"},t,{name:"AES-GCM",length:256},false,["encrypt","decrypt"])},C=async(e,r)=>{let n=crypto.getRandomValues(new Uint8Array(16)),t=crypto.getRandomValues(new Uint8Array(12)),s=await g(r,new Uint8Array(n.buffer),31e4),i=await crypto.subtle.encrypt({name:"AES-GCM",iv:new Uint8Array(t.buffer)},s,p.encode(e)),a=new Uint8Array(n.length+t.length+i.byteLength);return a.set(n,0),a.set(t,n.length),a.set(new Uint8Array(i),n.length+t.length),S(a.buffer)},U=async(e,r)=>{try{let n=new Uint8Array(D(e)),t=n.slice(0,16),s=n.slice(16,28),i=n.slice(28),a=await g(r,new Uint8Array(t.buffer),31e4),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(s.buffer)},a,i);return A.decode(o)}catch{return ""}},b=-1,c=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","M","N","P","Q","R","S","T","V","W","X","Y","Z"],k={uuid:{byVal:async e=>{if(!e)return console.warn("You need to pass a value to obtain a fixed uuid"),"";let r=await dphelper.security.SHA256_Hex(e);return [r.slice(0,8),r.slice(8,4),`4${r.slice(12,3)}`,`8${r.slice(15,3)}`,r.slice(18,12)].join("-")},v4:"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),v5:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=crypto.getRandomValues(new Uint8Array(1))[0];return (e==="x"?r:r&3|8).toString(16)})},hashPass:async(e,r)=>{if(!e||!r)return console.warn("hashPass: user and password are required"),"";let n=new TextEncoder,t=crypto.getRandomValues(new Uint8Array(16)),s=Array.from(t).map(u=>u.toString(16).padStart(2,"0")).join(""),i=await crypto.subtle.importKey("raw",n.encode(r.toLowerCase()+e.toLowerCase()),{name:"PBKDF2"},false,["deriveBits"]),a=await crypto.subtle.deriveBits({name:"PBKDF2",salt:t.buffer,iterations:31e4,hash:"SHA-256"},i,256),d=Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("");return s+d},crypt:async(e,r)=>await C(e,r),deCrypt:async(e,r)=>await U(e,r),AES_KeyGen:async e=>{let r=e||crypto.randomUUID(),n=crypto.getRandomValues(new Uint8Array(16)),t=Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join(""),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:n.buffer,iterations:31e4,hash:"SHA-256"},await crypto.subtle.importKey("raw",p.encode(r),"PBKDF2",false,["deriveBits"]),512),i=Array.from(new Uint8Array(s));return t+i.map(a=>a.toString(16).padStart(2,"0")).join("")},SHA256_Hex:async e=>P(e),ulid:()=>{let e=new Uint8Array(16),r=new DataView(e.buffer,0,6),n=new Uint8Array(e.buffer,6,10),t=new Array(26),s=a=>{t[0]=c[a[0]>>5],t[1]=c[a[0]>>0&31];for(let o=0;o<3;o++)t[o*8+2]=c[a[o*5+1]>>3],t[o*8+3]=c[(a[o*5+1]<<2|a[o*5+2]>>6)&31],t[o*8+4]=c[a[o*5+2]>>1&31],t[o*8+5]=c[(a[o*5+2]<<4|a[o*5+3]>>4)&31],t[o*8+6]=c[(a[o*5+3]<<1|a[o*5+4]>>7)&31],t[o*8+7]=c[a[o*5+4]>>2&31],t[o*8+8]=c[(a[o*5+4]<<3|a[o*5+5]>>5)&31],t[o*8+9]=c[a[o*5+5]>>0&31];return t.join("")},i=Date.now();if(i===b)for(let a=9;a>=0&&!(n[a]!==void 0&&n[a]++<255);a--);else b=i,r.setUint16(0,i/4294967296|0),r.setUint32(2,i|0),window.crypto.getRandomValues(n);return s(e)},fingerprint:async e=>{let r=e?.requireConsent!==false,n=e?.consent;if(r&&n!==true)return console.warn("dphelper.security.fingerprint: User consent required. Pass { consent: true } to enable."),console.warn("dphelper.security.fingerprint: Fingerprinting is subject to GDPR/CCPA. Ensure privacy policy and user consent."),"";let t=navigator,s=window.screen,i=document.createElement("canvas"),a=i.getContext("2d"),o="dphelper_fingerprint_v1",d="";a&&(i.width=200,i.height=30,a.textBaseline="top",a.font="14px 'Arial'",a.textBaseline="alphabetic",a.fillStyle="#f60",a.fillRect(125,1,62,20),a.fillStyle="#069",a.fillText(o,2,15),a.fillStyle="rgba(102, 204, 0, 0.7)",a.fillText(o,4,17),d=i.toDataURL());let u=[t.userAgent,t.language,s.colorDepth,s.width+"x"+s.height,new Date().getTimezoneOffset(),t.deviceMemory||"unknown",t.hardwareConcurrency||"unknown",d].join("|");return dphelper.security.SHA256_Hex(u)},saveEncrypted:async(e,r,n)=>{if(typeof document>"u"||typeof window>"u"){console.warn("[dphelper] localStorage not available in this environment");return}let t=await dphelper.security.crypt(r,n),s=await h(t,n);localStorage.setItem(e,JSON.stringify({d:t,h:s,v:"2.0"}));},getEncrypted:async(e,r)=>{let n=localStorage.getItem(e);if(!n)return null;try{let t=JSON.parse(n);if(t&&t.h&&t.d){let s=await h(t.d,r);return t.h!==s?(console.error(`[dphelper] Security Alert: Data tampering detected for key "${e}"`),null):dphelper.security.deCrypt(t.d,r)}return dphelper.security.deCrypt(n,r)}catch{try{return dphelper.security.deCrypt(n,r)}catch(s){return console.warn(`[dphelper] Persistence Error for key "${e}":`,s),null}}}},B=k;typeof dphelper?.setDescription=="function"&&dphelper.setDescription(x,B);var F=dphelper.security;exports.security=F;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
+
export interface SecurityTool {
|
|
3
|
+
uuid: {
|
|
4
|
+
byVal: (string: string) => string
|
|
5
|
+
v4: string
|
|
6
|
+
v5: string
|
|
7
|
+
}
|
|
8
|
+
hashPass: (u: string, p: string) => Promise<string>
|
|
9
|
+
crypt: (u: string, p: string) => Promise<string>
|
|
10
|
+
deCrypt: (u: string, p: string) => Promise<string>
|
|
11
|
+
AES_KeyGen: (passKey?: string) => Promise<string>
|
|
12
|
+
SHA256_Hex: (passKey: string) => Promise<string>
|
|
13
|
+
ulid: () => string
|
|
14
|
+
fingerprint: (options?: { requireConsent?: boolean; consent?: boolean }) => Promise<string>
|
|
15
|
+
saveEncrypted: (key: string, value: string, secret: string) => Promise<void>
|
|
16
|
+
getEncrypted: (key: string, secret: string) => Promise<string | null>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const security: SecurityTool
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var h={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...m},configurable:true,writable:true},version:{value:h.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var l=dphelper;Object.defineProperty(l,"setProps",{value:(e,r,n)=>{Object.defineProperty(e,r.name,n||{writable:false,configurable:false,enumerable:false}),n?.lock&&Object.freeze(e[r.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(l,"setDescription",{value:(e,r)=>{Object.defineProperties(l,{[e.name]:{value:r,writable:false,configurable:false,enumerable:false}}),Object.keys(r).map(n=>(Object.defineProperties(l[e.name],{[n]:{writable:false,configurable:false,enumerable:false}}),null)),l.setProps(l,e,{writable:false,configurable:false,enumerable:false}),l._list.scripts.push(e);}});var A={name:"security",active:true,subCommand:[{name:"uuid",version:"0.0.2",example:"dphelper.security.uuid",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"UUID related commands",subCommand:[{name:"byVal",version:"0.0.2",example:"dphelper.security.uuid.byVal('string')",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",type:"function",active:true,description:"Generate a UUID based on a given string",env:"both",subCommand:[]},{name:"v4",version:"0.0.2",example:"dphelper.security.uuid.v4",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"return",active:true,description:"Generate a random UUID v4",env:"both",subCommand:[]},{name:"v5",version:"0.0.2",example:"dphelper.security.uuid.v5",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"return",active:true,description:"Generate a random UUID v5",env:"both",subCommand:[]}]},{name:"hashPass",description:"Generate a crypto digest starting from user and password values (Uses SHA-256, CNSA compliant)",example:"dphelper.security.hashPass(user, password)",version:"0.0.3",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260329",active:true,env:"both",subCommand:[]},{name:"crypt",description:"Encrypt your message using a secret_key in a default format AES",example:"dphelper.security.crypt(data, secret_key, [optional mode])",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"deCrypt",description:"Decrypt your message using a secret_key in a default format AES",example:"dphelper.security.deCrypt(data, secret_key, [optional mode])",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"AES_KeyGen",description:"Generate a key based on the AES algorithm",example:"dphelper.security.AES_KeyGen(secret_key)",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"SHA256_Hex",description:"Generate a SHA256 hash in hexadecimal format",example:"dphelper.security.SHA256_Hex(secret_key)",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",active:true,env:"both",subCommand:[]},{name:"ulid",description:"Generate ULID code",example:"dphelper.security.ulid()",version:"0.0.2",type:"function",author:"mix",creationDate:"20250212",lastMod:"20250212",active:true,env:"both",subCommand:[]},{name:"fingerprint",description:"Generate a unique browser fingerprint",example:"dphelper.security.fingerprint()",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"saveEncrypted",description:"Save encrypted data to localStorage",example:"dphelper.security.saveEncrypted('key', 'value', 'secret')",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"getEncrypted",description:"Retrieve and decrypt data from localStorage",example:"dphelper.security.getEncrypted('key', 'secret')",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]}]},p=new TextEncoder,S=new TextDecoder,D=e=>{let r=new Uint8Array(e),n="";for(let t=0;t<r.byteLength;t++)n+=String.fromCharCode(r[t]);return btoa(n)},P=e=>{let r=atob(e),n=new Uint8Array(r.length);for(let t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return n.buffer},C=async e=>{let r=p.encode(e),n=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")},b=async(e,r)=>{let n=p.encode(r),t=await crypto.subtle.importKey("raw",n,{name:"HMAC",hash:"SHA-256"},false,["sign"]),s=await crypto.subtle.sign("HMAC",t,p.encode(e));return Array.from(new Uint8Array(s)).map(a=>a.toString(16).padStart(2,"0")).join("")},v=async(e,r,n)=>{let t=await crypto.subtle.importKey("raw",p.encode(e),"PBKDF2",false,["deriveBits","deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:r.buffer,iterations:n,hash:"SHA-256"},t,{name:"AES-GCM",length:256},false,["encrypt","decrypt"])},U=async(e,r)=>{let n=crypto.getRandomValues(new Uint8Array(16)),t=crypto.getRandomValues(new Uint8Array(12)),s=await v(r,new Uint8Array(n.buffer),31e4),i=await crypto.subtle.encrypt({name:"AES-GCM",iv:new Uint8Array(t.buffer)},s,p.encode(e)),a=new Uint8Array(n.length+t.length+i.byteLength);return a.set(n,0),a.set(t,n.length),a.set(new Uint8Array(i),n.length+t.length),D(a.buffer)},k=async(e,r)=>{try{let n=new Uint8Array(P(e)),t=n.slice(0,16),s=n.slice(16,28),i=n.slice(28),a=await v(r,new Uint8Array(t.buffer),31e4),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(s.buffer)},a,i);return S.decode(o)}catch{return ""}},g=-1,c=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","M","N","P","Q","R","S","T","V","W","X","Y","Z"],B={uuid:{byVal:async e=>{if(!e)return console.warn("You need to pass a value to obtain a fixed uuid"),"";let r=await dphelper.security.SHA256_Hex(e);return [r.slice(0,8),r.slice(8,4),`4${r.slice(12,3)}`,`8${r.slice(15,3)}`,r.slice(18,12)].join("-")},v4:"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),v5:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=crypto.getRandomValues(new Uint8Array(1))[0];return (e==="x"?r:r&3|8).toString(16)})},hashPass:async(e,r)=>{if(!e||!r)return console.warn("hashPass: user and password are required"),"";let n=new TextEncoder,t=crypto.getRandomValues(new Uint8Array(16)),s=Array.from(t).map(u=>u.toString(16).padStart(2,"0")).join(""),i=await crypto.subtle.importKey("raw",n.encode(r.toLowerCase()+e.toLowerCase()),{name:"PBKDF2"},false,["deriveBits"]),a=await crypto.subtle.deriveBits({name:"PBKDF2",salt:t.buffer,iterations:31e4,hash:"SHA-256"},i,256),d=Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("");return s+d},crypt:async(e,r)=>await U(e,r),deCrypt:async(e,r)=>await k(e,r),AES_KeyGen:async e=>{let r=e||crypto.randomUUID(),n=crypto.getRandomValues(new Uint8Array(16)),t=Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join(""),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:n.buffer,iterations:31e4,hash:"SHA-256"},await crypto.subtle.importKey("raw",p.encode(r),"PBKDF2",false,["deriveBits"]),512),i=Array.from(new Uint8Array(s));return t+i.map(a=>a.toString(16).padStart(2,"0")).join("")},SHA256_Hex:async e=>C(e),ulid:()=>{let e=new Uint8Array(16),r=new DataView(e.buffer,0,6),n=new Uint8Array(e.buffer,6,10),t=new Array(26),s=a=>{t[0]=c[a[0]>>5],t[1]=c[a[0]>>0&31];for(let o=0;o<3;o++)t[o*8+2]=c[a[o*5+1]>>3],t[o*8+3]=c[(a[o*5+1]<<2|a[o*5+2]>>6)&31],t[o*8+4]=c[a[o*5+2]>>1&31],t[o*8+5]=c[(a[o*5+2]<<4|a[o*5+3]>>4)&31],t[o*8+6]=c[(a[o*5+3]<<1|a[o*5+4]>>7)&31],t[o*8+7]=c[a[o*5+4]>>2&31],t[o*8+8]=c[(a[o*5+4]<<3|a[o*5+5]>>5)&31],t[o*8+9]=c[a[o*5+5]>>0&31];return t.join("")},i=Date.now();if(i===g)for(let a=9;a>=0&&!(n[a]!==void 0&&n[a]++<255);a--);else g=i,r.setUint16(0,i/4294967296|0),r.setUint32(2,i|0),window.crypto.getRandomValues(n);return s(e)},fingerprint:async e=>{let r=e?.requireConsent!==false,n=e?.consent;if(r&&n!==true)return console.warn("dphelper.security.fingerprint: User consent required. Pass { consent: true } to enable."),console.warn("dphelper.security.fingerprint: Fingerprinting is subject to GDPR/CCPA. Ensure privacy policy and user consent."),"";let t=navigator,s=window.screen,i=document.createElement("canvas"),a=i.getContext("2d"),o="dphelper_fingerprint_v1",d="";a&&(i.width=200,i.height=30,a.textBaseline="top",a.font="14px 'Arial'",a.textBaseline="alphabetic",a.fillStyle="#f60",a.fillRect(125,1,62,20),a.fillStyle="#069",a.fillText(o,2,15),a.fillStyle="rgba(102, 204, 0, 0.7)",a.fillText(o,4,17),d=i.toDataURL());let u=[t.userAgent,t.language,s.colorDepth,s.width+"x"+s.height,new Date().getTimezoneOffset(),t.deviceMemory||"unknown",t.hardwareConcurrency||"unknown",d].join("|");return dphelper.security.SHA256_Hex(u)},saveEncrypted:async(e,r,n)=>{if(typeof document>"u"||typeof window>"u"){console.warn("[dphelper] localStorage not available in this environment");return}let t=await dphelper.security.crypt(r,n),s=await b(t,n);localStorage.setItem(e,JSON.stringify({d:t,h:s,v:"2.0"}));},getEncrypted:async(e,r)=>{let n=localStorage.getItem(e);if(!n)return null;try{let t=JSON.parse(n);if(t&&t.h&&t.d){let s=await b(t.d,r);return t.h!==s?(console.error(`[dphelper] Security Alert: Data tampering detected for key "${e}"`),null):dphelper.security.deCrypt(t.d,r)}return dphelper.security.deCrypt(n,r)}catch{try{return dphelper.security.deCrypt(n,r)}catch(s){return console.warn(`[dphelper] Persistence Error for key "${e}":`,s),null}}}},E=B;typeof dphelper?.setDescription=="function"&&dphelper.setDescription(A,E);var I=dphelper.security;export{I as security};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var n={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var i={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...n},configurable:true,writable:true},version:{value:i.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var a=dphelper;Object.defineProperty(a,"setProps",{value:(e,t,l)=>{Object.defineProperty(e,t.name,l||{writable:false,configurable:false,enumerable:false}),l?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(a,"setDescription",{value:(e,t)=>{Object.defineProperties(a,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(l=>(Object.defineProperties(a[e.name],{[l]:{writable:false,configurable:false,enumerable:false}}),null)),a.setProps(a,e,{writable:false,configurable:false,enumerable:false}),a._list.scripts.push(e);}});var u={name:"shortcut",active:true,subCommand:[{name:"keys",version:"0.0.2",example:"dphelper.shortcut.keys([e, trigger])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Handle keyboard shortcuts.",env:"client",subCommand:[]}]},p={keys:(e,t)=>{let l=e.which?e.which:e.keyCode;t||(t={data:[{key:"83",ctrl:true,active:true,description:"CTRL+S",function:""},{key:"27",ctrl:false,active:true,description:"ESC",element:"",function:""},{key:"80",ctrl:true,active:true,description:"CTRL+P",element:"",function:"function(){ Print }"}]}),t.data&&t.data.map(r=>(e.ctrlKey||e.metaKey&&r.ctrl===true)&&l===Number.parseInt(r.key)&&r.active===true?(r.element&&r.element.click(),r.function?JSON.stringify(r.function):(e.preventDefault(),null)):null);}};dphelper?.setDescription(u,p);var j=dphelper.shortcut;exports.shortcut=j;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var s={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...i},configurable:true,writable:true},version:{value:s.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var a=dphelper;Object.defineProperty(a,"setProps",{value:(e,t,l)=>{Object.defineProperty(e,t.name,l||{writable:false,configurable:false,enumerable:false}),l?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(a,"setDescription",{value:(e,t)=>{Object.defineProperties(a,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(l=>(Object.defineProperties(a[e.name],{[l]:{writable:false,configurable:false,enumerable:false}}),null)),a.setProps(a,e,{writable:false,configurable:false,enumerable:false}),a._list.scripts.push(e);}});var p={name:"shortcut",active:true,subCommand:[{name:"keys",version:"0.0.2",example:"dphelper.shortcut.keys([e, trigger])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Handle keyboard shortcuts.",env:"client",subCommand:[]}]},f={keys:(e,t)=>{let l=e.which?e.which:e.keyCode;t||(t={data:[{key:"83",ctrl:true,active:true,description:"CTRL+S",function:""},{key:"27",ctrl:false,active:true,description:"ESC",element:"",function:""},{key:"80",ctrl:true,active:true,description:"CTRL+P",element:"",function:"function(){ Print }"}]}),t.data&&t.data.map(r=>(e.ctrlKey||e.metaKey&&r.ctrl===true)&&l===Number.parseInt(r.key)&&r.active===true?(r.element&&r.element.click(),r.function?JSON.stringify(r.function):(e.preventDefault(),null)):null);}};dphelper?.setDescription(p,f);var P=dphelper.shortcut;export{P as shortcut};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var m={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var g={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...m},configurable:true,writable:true},version:{value:g.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var l=dphelper;Object.defineProperty(l,"setProps",{value:(t,e,o)=>{Object.defineProperty(t,e.name,o||{writable:false,configurable:false,enumerable:false}),o?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(l,"setDescription",{value:(t,e)=>{Object.defineProperties(l,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(o=>(Object.defineProperties(l[t.name],{[o]:{writable:false,configurable:false,enumerable:false}}),null)),l.setProps(l,t,{writable:false,configurable:false,enumerable:false}),l._list.scripts.push(t);}});var a={ws:{}},v={name:"socket",active:true,subCommand:[{name:"info",version:"0.0.2",example:"dphelper.socket.info(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Retrieve socket information",env:"client",subCommand:[]},{name:"start",version:"0.0.2",example:"dphelper.socket.start(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Start a socket connection",env:"client",subCommand:[]},{name:"conn",version:"0.0.2",example:"dphelper.socket.conn(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Manage socket connections",env:"client",subCommand:[]},{name:"connect",version:"0.0.2",example:"dphelper.socket.connect(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Connect to a socket",env:"client",subCommand:[]},{name:"open",version:"0.0.2",example:"dphelper.socket.open(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Open a socket connection",env:"client",subCommand:[]},{name:"send",version:"0.0.2",example:"dphelper.socket.send(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Send data through a socket",env:"client",subCommand:[]},{name:"receive",version:"0.0.2",example:"dphelper.socket.receive(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Receive data from a socket",env:"client",subCommand:[]},{name:"keepAlive",version:"0.0.2",example:"dphelper.socket.keepAlive(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Keep the socket connection alive",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.socket.check()",author:"Dario Passariello",creationDate:"2023-05-27",lastMod:"2023-05-27",type:"function",active:true,description:"Check how many websocket connections are open",env:"client",subCommand:[]},{name:"list",version:"0.0.2",example:"dphelper.socket.list()",author:"Dario Passariello",creationDate:"2023-05-27",lastMod:"2023-05-27",type:"function",active:true,description:"List all websocket connections in real-time",env:"client",subCommand:[]},{name:"close",version:"0.0.1",example:"dphelper.socket.close([name])",author:"Dario Passariello",creationDate:"2026-05-18",lastMod:"2025-05-18",type:"function",active:true,description:"Close websocket connections by name",env:"client",subCommand:[]}]},y={info:()=>"Created by Dario Passariello",start:(t,e="general")=>{a.ws={},dphelper.socket.connect(t,e);},conn:(t,e,o,r)=>{if(!(t&&e)){console.debug("please use connect!");return}try{let n;try{n=new URL(e);}catch{if(!e.startsWith("/")&&!e.startsWith("ws")&&!e.startsWith("wss"))n=new URL(e,window.location.origin);else {console.error("Invalid WebSocket URL");return}}if(n.protocol==="ws:"){console.error("Insecure WebSocket protocol 'ws://' - must use 'wss://'");return}r&&n.searchParams.set("token",r);let s=new WebSocket(n.toString());return s.binaryType="blob",s.onmessage=p=>{},[s,t,o]}catch(n){console.error(n);return}},connect:(t,e)=>{t&&dphelper.socket.open(dphelper.security.uuid.v5,t,e);},open:(t,e,o,r)=>{if(t)try{let n=dphelper.socket.conn(t,e,o,r);if(!n)return;a.ws[o]=n,dphelper._list.sockets.indexOf(n[0])===-1&&dphelper._list.sockets.push(n[0]);let s=0,p=5,h=1e3,b=()=>{if(s>=p){console.error(`[dphelper] Socket "${o}" max reconnect attempts (${p}) reached`);return}s++;let i=Math.min(h*Math.pow(2,s),3e4);console.debug(`[dphelper] Reconnecting socket "${o}" in ${i}ms (attempt ${s}/${p})`),setTimeout(()=>{dphelper.socket.open(t,e,o,r);},i);},u=()=>{dphelper.log.reg(`${t} connected`),s=0;},c=i=>{dphelper.log.debug(i.wasClean?"Disconnected":`Connection break: ${i.reason||i.code}`),i.wasClean||b();},d=i=>{dphelper.log?.error(i);};n[0].onopen=u,n[0].onclose=c,n[0].onerror=d,n[0].__dphelper_handlers={origOnOpen:u,origOnClose:c,origOnError:d};}catch(n){console.error(n);}},ping:t=>{if(a.ws[t]?.[1])try{a.ws[t]?.[0]?.send('{"debug":"__ping__"}');}catch(e){console.error(e);}},send:(t,e)=>{if(a.ws[e]?.[1]&&t)try{let o=a.ws[e];if(!o)return;o[0].send(String(t));}catch(o){console.error(o);}},receive:(t,e)=>{if(a.ws[e]?.[1])try{let o=a.ws[e],r=o[0];r.onmessage=n=>{t(n),dphelper.log.reg(n);};}catch(o){console.error(o);}},keepAlive:t=>{try{let e=a.ws[t];if(!e)return;let o=e[0],r=o.__dphelper_handlers;if(!r){console.warn("[dphelper] keepAlive: no stored handlers found for",t);return}let n,s=(c=5e3)=>{n=setTimeout(()=>{dphelper.socket.ping(t);},c);},p=()=>clearTimeout(n),h=()=>{r.origOnOpen?.(),setInterval(s,3e4);},b=c=>{try{Object.values(JSON.parse(c.data))[0]==="__ping__"&&p();}catch(d){console.error(d);}},u=r.origOnMessage;o.onopen=h,o.onmessage=c=>{typeof u=="function"&&u(c),b(c);};}catch(e){console.error(e);}},check:()=>{dphelper._list.sockets=dphelper._list.sockets.filter(t=>t.readyState!==WebSocket.CLOSED);},list:()=>dphelper._list.sockets,close:t=>{try{let e=a.ws[t];if(!e)return;e[0].close();}catch(e){console.error(e);}}};dphelper?.setDescription(v,y);typeof document<"u"&&dphelper?.socket?.check();var R=dphelper.socket;
|
|
2
|
+
exports.socket=R;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
+
export interface SocketTool {
|
|
3
|
+
info: () => string
|
|
4
|
+
start: (server: any, name: string) => void
|
|
5
|
+
conn: (id: any, server: any, name: string) => void
|
|
6
|
+
connect: (server: any, name: string) => void
|
|
7
|
+
open: (id: any, server: any, name: string) => void
|
|
8
|
+
ping: (name: string) => void
|
|
9
|
+
send: (mex: any, name: string) => void
|
|
10
|
+
receive: (func: Function, name: string) => void
|
|
11
|
+
keepAlive: (name: string) => void
|
|
12
|
+
check: () => void
|
|
13
|
+
list: () => WebSocket[]
|
|
14
|
+
close: (name: string) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const socket: SocketTool
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var k={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...g},configurable:true,writable:true},version:{value:k.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var l=dphelper;Object.defineProperty(l,"setProps",{value:(t,e,o)=>{Object.defineProperty(t,e.name,o||{writable:false,configurable:false,enumerable:false}),o?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(l,"setDescription",{value:(t,e)=>{Object.defineProperties(l,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(o=>(Object.defineProperties(l[t.name],{[o]:{writable:false,configurable:false,enumerable:false}}),null)),l.setProps(l,t,{writable:false,configurable:false,enumerable:false}),l._list.scripts.push(t);}});var a={ws:{}},y={name:"socket",active:true,subCommand:[{name:"info",version:"0.0.2",example:"dphelper.socket.info(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Retrieve socket information",env:"client",subCommand:[]},{name:"start",version:"0.0.2",example:"dphelper.socket.start(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Start a socket connection",env:"client",subCommand:[]},{name:"conn",version:"0.0.2",example:"dphelper.socket.conn(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Manage socket connections",env:"client",subCommand:[]},{name:"connect",version:"0.0.2",example:"dphelper.socket.connect(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Connect to a socket",env:"client",subCommand:[]},{name:"open",version:"0.0.2",example:"dphelper.socket.open(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Open a socket connection",env:"client",subCommand:[]},{name:"send",version:"0.0.2",example:"dphelper.socket.send(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Send data through a socket",env:"client",subCommand:[]},{name:"receive",version:"0.0.2",example:"dphelper.socket.receive(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Receive data from a socket",env:"client",subCommand:[]},{name:"keepAlive",version:"0.0.2",example:"dphelper.socket.keepAlive(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Keep the socket connection alive",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.socket.check()",author:"Dario Passariello",creationDate:"2023-05-27",lastMod:"2023-05-27",type:"function",active:true,description:"Check how many websocket connections are open",env:"client",subCommand:[]},{name:"list",version:"0.0.2",example:"dphelper.socket.list()",author:"Dario Passariello",creationDate:"2023-05-27",lastMod:"2023-05-27",type:"function",active:true,description:"List all websocket connections in real-time",env:"client",subCommand:[]},{name:"close",version:"0.0.1",example:"dphelper.socket.close([name])",author:"Dario Passariello",creationDate:"2026-05-18",lastMod:"2025-05-18",type:"function",active:true,description:"Close websocket connections by name",env:"client",subCommand:[]}]},D={info:()=>"Created by Dario Passariello",start:(t,e="general")=>{a.ws={},dphelper.socket.connect(t,e);},conn:(t,e,o,r)=>{if(!(t&&e)){console.debug("please use connect!");return}try{let n;try{n=new URL(e);}catch{if(!e.startsWith("/")&&!e.startsWith("ws")&&!e.startsWith("wss"))n=new URL(e,window.location.origin);else {console.error("Invalid WebSocket URL");return}}if(n.protocol==="ws:"){console.error("Insecure WebSocket protocol 'ws://' - must use 'wss://'");return}r&&n.searchParams.set("token",r);let s=new WebSocket(n.toString());return s.binaryType="blob",s.onmessage=p=>{},[s,t,o]}catch(n){console.error(n);return}},connect:(t,e)=>{t&&dphelper.socket.open(dphelper.security.uuid.v5,t,e);},open:(t,e,o,r)=>{if(t)try{let n=dphelper.socket.conn(t,e,o,r);if(!n)return;a.ws[o]=n,dphelper._list.sockets.indexOf(n[0])===-1&&dphelper._list.sockets.push(n[0]);let s=0,p=5,h=1e3,b=()=>{if(s>=p){console.error(`[dphelper] Socket "${o}" max reconnect attempts (${p}) reached`);return}s++;let i=Math.min(h*Math.pow(2,s),3e4);console.debug(`[dphelper] Reconnecting socket "${o}" in ${i}ms (attempt ${s}/${p})`),setTimeout(()=>{dphelper.socket.open(t,e,o,r);},i);},u=()=>{dphelper.log.reg(`${t} connected`),s=0;},c=i=>{dphelper.log.debug(i.wasClean?"Disconnected":`Connection break: ${i.reason||i.code}`),i.wasClean||b();},d=i=>{dphelper.log?.error(i);};n[0].onopen=u,n[0].onclose=c,n[0].onerror=d,n[0].__dphelper_handlers={origOnOpen:u,origOnClose:c,origOnError:d};}catch(n){console.error(n);}},ping:t=>{if(a.ws[t]?.[1])try{a.ws[t]?.[0]?.send('{"debug":"__ping__"}');}catch(e){console.error(e);}},send:(t,e)=>{if(a.ws[e]?.[1]&&t)try{let o=a.ws[e];if(!o)return;o[0].send(String(t));}catch(o){console.error(o);}},receive:(t,e)=>{if(a.ws[e]?.[1])try{let o=a.ws[e],r=o[0];r.onmessage=n=>{t(n),dphelper.log.reg(n);};}catch(o){console.error(o);}},keepAlive:t=>{try{let e=a.ws[t];if(!e)return;let o=e[0],r=o.__dphelper_handlers;if(!r){console.warn("[dphelper] keepAlive: no stored handlers found for",t);return}let n,s=(c=5e3)=>{n=setTimeout(()=>{dphelper.socket.ping(t);},c);},p=()=>clearTimeout(n),h=()=>{r.origOnOpen?.(),setInterval(s,3e4);},b=c=>{try{Object.values(JSON.parse(c.data))[0]==="__ping__"&&p();}catch(d){console.error(d);}},u=r.origOnMessage;o.onopen=h,o.onmessage=c=>{typeof u=="function"&&u(c),b(c);};}catch(e){console.error(e);}},check:()=>{dphelper._list.sockets=dphelper._list.sockets.filter(t=>t.readyState!==WebSocket.CLOSED);},list:()=>dphelper._list.sockets,close:t=>{try{let e=a.ws[t];if(!e)return;e[0].close();}catch(e){console.error(e);}}};dphelper?.setDescription(y,D);typeof document<"u"&&dphelper?.socket?.check();var A=dphelper.socket;
|
|
2
|
+
export{A as socket};
|
package/modules/sse.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var b={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var h={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...b},configurable:true,writable:true},version:{value:h.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var s=dphelper;Object.defineProperty(s,"setProps",{value:(e,r,o)=>{Object.defineProperty(e,r.name,o||{writable:false,configurable:false,enumerable:false}),o?.lock&&Object.freeze(e[r.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(s,"setDescription",{value:(e,r)=>{Object.defineProperties(s,{[e.name]:{value:r,writable:false,configurable:false,enumerable:false}}),Object.keys(r).map(o=>(Object.defineProperties(s[e.name],{[o]:{writable:false,configurable:false,enumerable:false}}),null)),s.setProps(s,e,{writable:false,configurable:false,enumerable:false}),s._list.scripts.push(e);}});var P={name:"sse",active:true,subCommand:[{name:"open",version:"0.0.2",example:"dphelper.sse.open('/api/stream', { method: 'POST', body: ... })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260513",type:"function",active:true,description:"Advanced Server-Sent Events client with POST and Custom Headers support. HTTPS required. Validates Content-Type before processing.",env:"client",subCommand:[]}]},S=e=>{try{let r=new URL(e);return r.protocol!=="https:"&&r.protocol!=="http:"?(console.error("[dphelper] Only HTTP/HTTPS protocols allowed for SSE"),!1):!0}catch{return true}},T=e=>e?e.includes("text/event-stream")||e.includes("text/plain"):false,j={open:(e,r={})=>{if(!S(e))return {on:()=>{},close:()=>{}};let o={message:[],error:[],open:[]},p=new AbortController,l=(t,a)=>{o[t]?.forEach(i=>i(a));};return (async()=>{try{let t=await fetch(e,{...r,signal:p.signal,headers:{Accept:"text/event-stream",...r.headers||{}}});if(!t.ok)throw new Error(`SSE failed: ${t.statusText}`);let a=t.headers.get("Content-Type");if(!T(a)){console.error(`[dphelper] SSE: Invalid Content-Type "${a}". Expected text/event-stream.`),p.abort(),l("error",new Error(`Invalid Content-Type: ${a}`));return}l("open",{status:t.status});let i=t.body?.getReader(),m=new TextDecoder;if(!i)return;let c="";for(;;){let{done:v,value:g}=await i.read();if(v)break;c+=m.decode(g,{stream:!0});let d=c.split(`
|
|
2
|
+
`);c=d.pop()||"";for(let f of d)if(f.startsWith("data:")){let n=f.replace("data:","").trim();try{(n.includes("[")||n.includes("{"))&&(n=JSON.parse(n));}catch{}l("message",n);}}}catch(t){t.name!=="AbortError"&&l("error",t);}})(),{on:(t,a)=>{o[t]&&o[t].push(a);},close:()=>p.abort()}}};dphelper?.setDescription(P,j);var L=dphelper.sse;exports.sse=L;
|
package/modules/sse.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
+
export interface SseTool {
|
|
3
|
+
/**
|
|
4
|
+
* Opens an SSE connection with support for custom fetch options (POST, Headers, etc).
|
|
5
|
+
*/
|
|
6
|
+
open(url: string, options?: any): {
|
|
7
|
+
on(event: "message" | "error" | "open", cb: (data: any) => void): void
|
|
8
|
+
close(): void
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const sse: SseTool
|
package/modules/sse.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var h={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var m={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...h},configurable:true,writable:true},version:{value:m.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var s=dphelper;Object.defineProperty(s,"setProps",{value:(e,r,o)=>{Object.defineProperty(e,r.name,o||{writable:false,configurable:false,enumerable:false}),o?.lock&&Object.freeze(e[r.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(s,"setDescription",{value:(e,r)=>{Object.defineProperties(s,{[e.name]:{value:r,writable:false,configurable:false,enumerable:false}}),Object.keys(r).map(o=>(Object.defineProperties(s[e.name],{[o]:{writable:false,configurable:false,enumerable:false}}),null)),s.setProps(s,e,{writable:false,configurable:false,enumerable:false}),s._list.scripts.push(e);}});var S={name:"sse",active:true,subCommand:[{name:"open",version:"0.0.2",example:"dphelper.sse.open('/api/stream', { method: 'POST', body: ... })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260513",type:"function",active:true,description:"Advanced Server-Sent Events client with POST and Custom Headers support. HTTPS required. Validates Content-Type before processing.",env:"client",subCommand:[]}]},T=e=>{try{let r=new URL(e);return r.protocol!=="https:"&&r.protocol!=="http:"?(console.error("[dphelper] Only HTTP/HTTPS protocols allowed for SSE"),!1):!0}catch{return true}},j=e=>e?e.includes("text/event-stream")||e.includes("text/plain"):false,O={open:(e,r={})=>{if(!T(e))return {on:()=>{},close:()=>{}};let o={message:[],error:[],open:[]},p=new AbortController,l=(t,a)=>{o[t]?.forEach(i=>i(a));};return (async()=>{try{let t=await fetch(e,{...r,signal:p.signal,headers:{Accept:"text/event-stream",...r.headers||{}}});if(!t.ok)throw new Error(`SSE failed: ${t.statusText}`);let a=t.headers.get("Content-Type");if(!j(a)){console.error(`[dphelper] SSE: Invalid Content-Type "${a}". Expected text/event-stream.`),p.abort(),l("error",new Error(`Invalid Content-Type: ${a}`));return}l("open",{status:t.status});let i=t.body?.getReader(),v=new TextDecoder;if(!i)return;let c="";for(;;){let{done:g,value:w}=await i.read();if(g)break;c+=v.decode(w,{stream:!0});let f=c.split(`
|
|
2
|
+
`);c=f.pop()||"";for(let b of f)if(b.startsWith("data:")){let n=b.replace("data:","").trim();try{(n.includes("[")||n.includes("{"))&&(n=JSON.parse(n));}catch{}l("message",n);}}}catch(t){t.name!=="AbortError"&&l("error",t);}})(),{on:(t,a)=>{o[t]&&o[t].push(a);},close:()=>p.abort()}}};dphelper?.setDescription(S,O);var N=dphelper.sse;export{N as sse};
|
package/modules/svg.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var E={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var w={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...E},configurable:true,writable:true},version:{value:w.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var h=dphelper;Object.defineProperty(h,"setProps",{value:(t,e,n)=>{Object.defineProperty(t,e.name,n||{writable:false,configurable:false,enumerable:false}),n?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(h,"setDescription",{value:(t,e)=>{Object.defineProperties(h,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(n=>(Object.defineProperties(h[t.name],{[n]:{writable:false,configurable:false,enumerable:false}}),null)),h.setProps(h,t,{writable:false,configurable:false,enumerable:false}),h._list.scripts.push(t);}});var A={name:"svg",active:true,subCommand:[{name:"init",version:"0.0.2",example:"dphelper.svg.init(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Initializes an SVG connection between two elements.",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.svg.check(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Checks if SVG support is available.",env:"client",subCommand:[]},{name:"update",version:"0.0.2",example:"dphelper.svg.update(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Updates the SVG connection between two elements.",env:"client",subCommand:[]},{name:"getCurve",version:"0.0.2",example:"dphelper.svg.getCurve(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the curve of the connection between two points.",env:"client",subCommand:[]},{name:"getIntersection",version:"0.0.2",example:"dphelper.svg.getIntersection(...) ",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the intersection point between two elements.",env:"client",subCommand:[]},{name:"setConnector",version:"0.0.2",example:"dphelper.svg.setConnector(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sets a connector on an element.",env:"client",subCommand:[]},{name:"removeConnection",version:"0.0.2",example:"dphelper.svg.removeConnection(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Removes an SVG connection from a container.",env:"client",subCommand:[]},{name:"makeScrollable",version:"0.0.2",example:"dphelper.svg.makeScrollable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG container scrollable.",env:"client",subCommand:[]},{name:"makeDraggable",version:"0.0.2",example:"dphelper.svg.makeDraggable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG element draggable.",env:"client",subCommand:[]},{name:"toggle",version:"0.0.2",example:"dphelper.svg.toggle(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Toggles an SVG connection on or off.",env:"client",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.svg.convert([Object])",author:"Dario Passariello",creationDate:"20190101",lastMod:"20240401",type:"function",active:true,description:"Converts an element to SVG.",env:"client",subCommand:[]}]},L={init:(t,e,n,r)=>{t.querySelector("svg")&&dphelper.svg.removeConnection(t),e=[dphelper.svg.setConnector(e[0],e[1]),e[1]],n=[dphelper.svg.setConnector(n[0],n[1]),n[1]];let l=t.getBoundingClientRect(),o="http://www.w3.org/2000/svg",m=t.offsetWidth*10,c=t.offsetHeight*10,s=document.createElementNS(o,"svg"),p=`conn_${Math.random().toString(36).substring(2,9)}`;s.setAttribute("xmlns",o),s.dataset.dphelper="svg-connection",s.setAttributeNS(null,"viewBox","0 0 "+m+" "+c),s.setAttributeNS(null,"width",String(m)),s.setAttributeNS(null,"height",String(c)),s.style.display="block";let a=document.createElementNS(o,"rect"),i=e[0].getBoundingClientRect();a.setAttributeNS(null,"x",String(i.left-l.left)),a.setAttributeNS(null,"y",String(i.top-l.top)),a.setAttributeNS(null,"width",String(i.width)),a.setAttributeNS(null,"height",String(i.height)),s.appendChild(a);let u=document.createElementNS(o,"rect");i=n[0].getBoundingClientRect(),u.setAttributeNS(null,"x",String(i.left-l.left)),u.setAttributeNS(null,"y",String(i.top-l.top)),u.setAttributeNS(null,"width",String(i.width)),u.setAttributeNS(null,"height",String(i.height)),s.appendChild(u);let d=document.createElementNS(o,"path");d.setAttributeNS(null,"id",p),d.setAttributeNS(null,"marker-end","url(#head)"),s.appendChild(d),t.appendChild(s),dphelper.svg.update(a,u,d),typeof r=="function"&&r(e,n);},check:()=>!!(document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),update:(t,e,n)=>{let r=Number.parseFloat(t.getAttribute("x")||"0"),l=Number.parseFloat(t.getAttribute("y")||"0"),o=Number.parseFloat(e.getAttribute("x")||"0"),m=Number.parseFloat(e.getAttribute("y")||"0"),c=Number.parseFloat(t.getAttribute("width")||"0")/2,s=Number.parseFloat(t.getAttribute("height")||"0")/2,p=Number.parseFloat(e.getAttribute("width")||"0")/2,a=Number.parseFloat(e.getAttribute("height")||"0")/2,i=r+c,u=l+s,d=o+p,v=m+a,g=d-i,f=v-u,b=dphelper.svg.getIntersection(g,f,i,u,c,s),S=dphelper.svg.getIntersection(-g,-f,d,v,p,a),C=S[0]-b[0],M=dphelper.svg.getCurve(b,S,C);n.setAttributeNS(null,"d","M"+i+","+u+M+d+","+v);},getCurve:(t,e,n)=>{let r=n/2;return " C"+(r+t[0])+","+t[1]+" "+(e[0]-r)+","+e[1]+" "},getIntersection:(t,e,n,r,l,o)=>Math.abs(e/t)<o/l?[n+(t>0?l:-l),r+e*l/Math.abs(t)]:[n+t*o/Math.abs(e),r+(e>0?o:-o)],setConnector:(t,e)=>{let n,r=document.createElement("span");switch(t.style.position="relative",r.style.position="absolute",r.style.width="5px",r.style.height="5px",e){case "top":n={left:"50%",top:"2.5px",marginLeft:"2.5px"};break;case "right":n={top:"50%",right:"2.5px",marginTop:"-2.5px"};break;case "bottom":n={left:"50%",bottom:"-2.5px",marginLeft:"2.5px"};break;case "left":n={top:"50%",left:"-2.5px",marginTop:"-2.5px"};break;default:n={};}return Object.assign(r.style,n),t.appendChild(r),r},removeConnection:t=>{t.querySelectorAll("svg[data-dphelper='svg-connection']").forEach(n=>n.remove());},makeScrollable:(t,e,n,r,l,o)=>{let m=t.getBoundingClientRect(),c=[n,r],s=c.length,p=[l,o],a=[];for(let g=0;g<s;g++){let f=c[g],b=p[g];!f||!b||(a[g]=f.getBoundingClientRect(),b.setAttributeNS(null,"x",String(a[g].left-m.left)),b.setAttributeNS(null,"y",String(a[g].top-m.top)),b.setAttributeNS(null,"width",String(a[g].width)),b.setAttributeNS(null,"height",String(a[g].height)));}let i=t.querySelectorAll("rect"),u=i[0],d=i[1],v=document.getElementById("connection");u&&d&&v&&dphelper.svg.update(u,d,v);},makeDraggable:t=>{let e=t.target;function n(p){let a=e.getScreenCTM();return a?{x:(p.clientX-a.e)/a.a,y:(p.clientY-a.f)/a.d}:{x:0,y:0}}let r=null,l=null,o=p=>{if(r&&l){let a=n(p);r.setAttributeNS(null,"x",String(a.x-l.x)),r.setAttributeNS(null,"y",String(a.y-l.y));let i=document.getElementById("connection");i&&dphelper.svg.update(r,r,i);}},m=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",m),r=null,l=null;},c=p=>{p.target.classList.contains("draggable")&&(r=p.target,l=n(p),l.x-=Number.parseFloat(r.getAttributeNS(null,"x")||"0"),l.y-=Number.parseFloat(r.getAttributeNS(null,"y")||"0"),document.addEventListener("mousemove",o),document.addEventListener("mouseup",m));};e.addEventListener("mousedown",c),e.__dphelper_cleanup=()=>{e.removeEventListener("mousedown",c),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",m);};let s=new MutationObserver(()=>{document.contains(e)||(e.__dphelper_cleanup&&e.__dphelper_cleanup(),s.disconnect());});s.observe(document.body,{childList:true,subtree:true});},toggle:(t,e,n,r)=>{let l=t.target;if(l.checked&&n&&r){dphelper.cookie.set({name:`${l.id}`,value:1,time:365});let o=()=>{dphelper.svg.makeScrollable(e,document.getElementById("parts-left-body"),n,r,document.querySelector("#parts svg rect"),document.querySelectorAll("#parts svg rect")[1]);};dphelper.svg.init(e,[n,"right"],[r,"left"],(m,c)=>{let s=document.getElementById("parts-left-body");s&&(s.addEventListener("scroll",o),s.__dphelper_scrollHandler=o);});}else {dphelper.svg.removeConnection(e);let o=document.getElementById("parts-left-body");o&&o.__dphelper_scrollHandler&&(o.removeEventListener("scroll",o.__dphelper_scrollHandler),delete o.__dphelper_scrollHandler),o&&o.replaceWith(o.cloneNode(true)),dphelper.cookie.set({name:`${l.id}`,value:0,time:365});}},convert:({children:t,active:e=true,size:n=[1920,1080],fit:r=["100%","100%"],preserveAspectRatio:l="none",style:o=`width:${r[0]}; height:${r[1]}`,zoom:m=1})=>{if(!t)return "Please pass ID of element for SVG conversion";if(e){let c=d=>d.replace(/[<>"'&]/g,""),s=document.querySelector(t);if(!s)return "Element not found";let p=s.cloneNode(true),a="http://www.w3.org/2000/svg",i=document.createElementNS(a,"svg");i.setAttribute("viewBox",`0 0 ${c(String(n[0]))} ${c(String(n[1]))}`),i.setAttribute("preserveAspectRatio",c(l)),i.setAttribute("xmlns",a),i.setAttribute("style",c(o)+"; zoom:"+c(String(m)));let u=document.createElementNS(a,"foreignObject");u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("width",c(String(r[0]))),u.setAttribute("height",c(String(r[1]))),u.setAttribute("style",c(o)+"; zoom:"+c(String(m))),u.appendChild(p),i.appendChild(u),s.innerHTML="",s.appendChild(i);}}};dphelper?.setDescription(A,L);typeof document<"u"&&dphelper?.svg?.check();var V=dphelper.svg;
|
|
2
|
+
exports.svg=V;
|
package/modules/svg.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
+
export interface SvgTool {
|
|
3
|
+
init: (container: HTMLElement, source1: [HTMLElement, string], source2: [HTMLElement, string], cb?: Function) => void
|
|
4
|
+
check: () => boolean
|
|
5
|
+
update: (rect1: HTMLElement, rect2: HTMLElement, cxn: HTMLElement) => void
|
|
6
|
+
getCurve: (p1: [number, number], p2: [number, number], dx: number) => string
|
|
7
|
+
getIntersection: (dx: number, dy: number, cx: number, cy: number, w: number, h: number) => [number, number]
|
|
8
|
+
setConnector: (source: HTMLElement, side: string) => HTMLElement
|
|
9
|
+
removeConnection: (container: HTMLElement) => void
|
|
10
|
+
makeScrollable: (svgContainer: HTMLElement, scrollContainer: HTMLElement, elm1: HTMLElement, elm2: HTMLElement, rect1: HTMLElement, rect2: HTMLElement) => void
|
|
11
|
+
makeDraggable: (evt: Event) => void
|
|
12
|
+
toggle: (evt: Event, container: HTMLElement, source1: HTMLElement, source2: HTMLElement) => void
|
|
13
|
+
convert: (options: any) => string | void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const svg: SvgTool
|
package/modules/svg.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var w={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var C={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...w},configurable:true,writable:true},version:{value:C.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var h=dphelper;Object.defineProperty(h,"setProps",{value:(t,e,n)=>{Object.defineProperty(t,e.name,n||{writable:false,configurable:false,enumerable:false}),n?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(h,"setDescription",{value:(t,e)=>{Object.defineProperties(h,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(n=>(Object.defineProperties(h[t.name],{[n]:{writable:false,configurable:false,enumerable:false}}),null)),h.setProps(h,t,{writable:false,configurable:false,enumerable:false}),h._list.scripts.push(t);}});var L={name:"svg",active:true,subCommand:[{name:"init",version:"0.0.2",example:"dphelper.svg.init(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Initializes an SVG connection between two elements.",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.svg.check(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Checks if SVG support is available.",env:"client",subCommand:[]},{name:"update",version:"0.0.2",example:"dphelper.svg.update(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Updates the SVG connection between two elements.",env:"client",subCommand:[]},{name:"getCurve",version:"0.0.2",example:"dphelper.svg.getCurve(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the curve of the connection between two points.",env:"client",subCommand:[]},{name:"getIntersection",version:"0.0.2",example:"dphelper.svg.getIntersection(...) ",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the intersection point between two elements.",env:"client",subCommand:[]},{name:"setConnector",version:"0.0.2",example:"dphelper.svg.setConnector(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sets a connector on an element.",env:"client",subCommand:[]},{name:"removeConnection",version:"0.0.2",example:"dphelper.svg.removeConnection(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Removes an SVG connection from a container.",env:"client",subCommand:[]},{name:"makeScrollable",version:"0.0.2",example:"dphelper.svg.makeScrollable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG container scrollable.",env:"client",subCommand:[]},{name:"makeDraggable",version:"0.0.2",example:"dphelper.svg.makeDraggable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG element draggable.",env:"client",subCommand:[]},{name:"toggle",version:"0.0.2",example:"dphelper.svg.toggle(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Toggles an SVG connection on or off.",env:"client",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.svg.convert([Object])",author:"Dario Passariello",creationDate:"20190101",lastMod:"20240401",type:"function",active:true,description:"Converts an element to SVG.",env:"client",subCommand:[]}]},D={init:(t,e,n,r)=>{t.querySelector("svg")&&dphelper.svg.removeConnection(t),e=[dphelper.svg.setConnector(e[0],e[1]),e[1]],n=[dphelper.svg.setConnector(n[0],n[1]),n[1]];let l=t.getBoundingClientRect(),o="http://www.w3.org/2000/svg",m=t.offsetWidth*10,c=t.offsetHeight*10,s=document.createElementNS(o,"svg"),p=`conn_${Math.random().toString(36).substring(2,9)}`;s.setAttribute("xmlns",o),s.dataset.dphelper="svg-connection",s.setAttributeNS(null,"viewBox","0 0 "+m+" "+c),s.setAttributeNS(null,"width",String(m)),s.setAttributeNS(null,"height",String(c)),s.style.display="block";let a=document.createElementNS(o,"rect"),i=e[0].getBoundingClientRect();a.setAttributeNS(null,"x",String(i.left-l.left)),a.setAttributeNS(null,"y",String(i.top-l.top)),a.setAttributeNS(null,"width",String(i.width)),a.setAttributeNS(null,"height",String(i.height)),s.appendChild(a);let u=document.createElementNS(o,"rect");i=n[0].getBoundingClientRect(),u.setAttributeNS(null,"x",String(i.left-l.left)),u.setAttributeNS(null,"y",String(i.top-l.top)),u.setAttributeNS(null,"width",String(i.width)),u.setAttributeNS(null,"height",String(i.height)),s.appendChild(u);let d=document.createElementNS(o,"path");d.setAttributeNS(null,"id",p),d.setAttributeNS(null,"marker-end","url(#head)"),s.appendChild(d),t.appendChild(s),dphelper.svg.update(a,u,d),typeof r=="function"&&r(e,n);},check:()=>!!(document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),update:(t,e,n)=>{let r=Number.parseFloat(t.getAttribute("x")||"0"),l=Number.parseFloat(t.getAttribute("y")||"0"),o=Number.parseFloat(e.getAttribute("x")||"0"),m=Number.parseFloat(e.getAttribute("y")||"0"),c=Number.parseFloat(t.getAttribute("width")||"0")/2,s=Number.parseFloat(t.getAttribute("height")||"0")/2,p=Number.parseFloat(e.getAttribute("width")||"0")/2,a=Number.parseFloat(e.getAttribute("height")||"0")/2,i=r+c,u=l+s,d=o+p,v=m+a,g=d-i,f=v-u,b=dphelper.svg.getIntersection(g,f,i,u,c,s),E=dphelper.svg.getIntersection(-g,-f,d,v,p,a),M=E[0]-b[0],x=dphelper.svg.getCurve(b,E,M);n.setAttributeNS(null,"d","M"+i+","+u+x+d+","+v);},getCurve:(t,e,n)=>{let r=n/2;return " C"+(r+t[0])+","+t[1]+" "+(e[0]-r)+","+e[1]+" "},getIntersection:(t,e,n,r,l,o)=>Math.abs(e/t)<o/l?[n+(t>0?l:-l),r+e*l/Math.abs(t)]:[n+t*o/Math.abs(e),r+(e>0?o:-o)],setConnector:(t,e)=>{let n,r=document.createElement("span");switch(t.style.position="relative",r.style.position="absolute",r.style.width="5px",r.style.height="5px",e){case "top":n={left:"50%",top:"2.5px",marginLeft:"2.5px"};break;case "right":n={top:"50%",right:"2.5px",marginTop:"-2.5px"};break;case "bottom":n={left:"50%",bottom:"-2.5px",marginLeft:"2.5px"};break;case "left":n={top:"50%",left:"-2.5px",marginTop:"-2.5px"};break;default:n={};}return Object.assign(r.style,n),t.appendChild(r),r},removeConnection:t=>{t.querySelectorAll("svg[data-dphelper='svg-connection']").forEach(n=>n.remove());},makeScrollable:(t,e,n,r,l,o)=>{let m=t.getBoundingClientRect(),c=[n,r],s=c.length,p=[l,o],a=[];for(let g=0;g<s;g++){let f=c[g],b=p[g];!f||!b||(a[g]=f.getBoundingClientRect(),b.setAttributeNS(null,"x",String(a[g].left-m.left)),b.setAttributeNS(null,"y",String(a[g].top-m.top)),b.setAttributeNS(null,"width",String(a[g].width)),b.setAttributeNS(null,"height",String(a[g].height)));}let i=t.querySelectorAll("rect"),u=i[0],d=i[1],v=document.getElementById("connection");u&&d&&v&&dphelper.svg.update(u,d,v);},makeDraggable:t=>{let e=t.target;function n(p){let a=e.getScreenCTM();return a?{x:(p.clientX-a.e)/a.a,y:(p.clientY-a.f)/a.d}:{x:0,y:0}}let r=null,l=null,o=p=>{if(r&&l){let a=n(p);r.setAttributeNS(null,"x",String(a.x-l.x)),r.setAttributeNS(null,"y",String(a.y-l.y));let i=document.getElementById("connection");i&&dphelper.svg.update(r,r,i);}},m=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",m),r=null,l=null;},c=p=>{p.target.classList.contains("draggable")&&(r=p.target,l=n(p),l.x-=Number.parseFloat(r.getAttributeNS(null,"x")||"0"),l.y-=Number.parseFloat(r.getAttributeNS(null,"y")||"0"),document.addEventListener("mousemove",o),document.addEventListener("mouseup",m));};e.addEventListener("mousedown",c),e.__dphelper_cleanup=()=>{e.removeEventListener("mousedown",c),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",m);};let s=new MutationObserver(()=>{document.contains(e)||(e.__dphelper_cleanup&&e.__dphelper_cleanup(),s.disconnect());});s.observe(document.body,{childList:true,subtree:true});},toggle:(t,e,n,r)=>{let l=t.target;if(l.checked&&n&&r){dphelper.cookie.set({name:`${l.id}`,value:1,time:365});let o=()=>{dphelper.svg.makeScrollable(e,document.getElementById("parts-left-body"),n,r,document.querySelector("#parts svg rect"),document.querySelectorAll("#parts svg rect")[1]);};dphelper.svg.init(e,[n,"right"],[r,"left"],(m,c)=>{let s=document.getElementById("parts-left-body");s&&(s.addEventListener("scroll",o),s.__dphelper_scrollHandler=o);});}else {dphelper.svg.removeConnection(e);let o=document.getElementById("parts-left-body");o&&o.__dphelper_scrollHandler&&(o.removeEventListener("scroll",o.__dphelper_scrollHandler),delete o.__dphelper_scrollHandler),o&&o.replaceWith(o.cloneNode(true)),dphelper.cookie.set({name:`${l.id}`,value:0,time:365});}},convert:({children:t,active:e=true,size:n=[1920,1080],fit:r=["100%","100%"],preserveAspectRatio:l="none",style:o=`width:${r[0]}; height:${r[1]}`,zoom:m=1})=>{if(!t)return "Please pass ID of element for SVG conversion";if(e){let c=d=>d.replace(/[<>"'&]/g,""),s=document.querySelector(t);if(!s)return "Element not found";let p=s.cloneNode(true),a="http://www.w3.org/2000/svg",i=document.createElementNS(a,"svg");i.setAttribute("viewBox",`0 0 ${c(String(n[0]))} ${c(String(n[1]))}`),i.setAttribute("preserveAspectRatio",c(l)),i.setAttribute("xmlns",a),i.setAttribute("style",c(o)+"; zoom:"+c(String(m)));let u=document.createElementNS(a,"foreignObject");u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("width",c(String(r[0]))),u.setAttribute("height",c(String(r[1]))),u.setAttribute("style",c(o)+"; zoom:"+c(String(m))),u.appendChild(p),i.appendChild(u),s.innerHTML="",s.appendChild(i);}}};dphelper?.setDescription(L,D);typeof document<"u"&&dphelper?.svg?.check();var I=dphelper.svg;
|
|
2
|
+
export{I as svg};
|
package/modules/sync.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var c={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var p={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...c},configurable:true,writable:true},version:{value:p.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var s=dphelper;Object.defineProperty(s,"setProps",{value:(a,r,t)=>{Object.defineProperty(a,r.name,t||{writable:false,configurable:false,enumerable:false}),t?.lock&&Object.freeze(a[r.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(s,"setDescription",{value:(a,r)=>{Object.defineProperties(s,{[a.name]:{value:r,writable:false,configurable:false,enumerable:false}}),Object.keys(r).map(t=>(Object.defineProperties(s[a.name],{[t]:{writable:false,configurable:false,enumerable:false}}),null)),s.setProps(s,a,{writable:false,configurable:false,enumerable:false}),s._list.scripts.push(a);}});var m={name:"sync",active:true,subCommand:[{name:"tab",version:"0.0.2",example:"dphelper.sync.tab('my_channel', (data) => console.debug(data))",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Synchronize data between tabs using BroadcastChannel",env:"client",subCommand:[]},{name:"storageProxy",version:"0.0.2",example:"const proxy = dphelper.sync.storageProxy('user_pref', {theme: 'dark'})",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Create a Proxy object linked to localStorage for auto-sync",env:"client",subCommand:[]},{name:"pulse",version:"0.0.1",example:"dphelper.sync.pulse('chat', (msg) => ...)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Low-latency cross-tab event bus with automatic registration.",env:"client",subCommand:[]}]},h={pulse:(a,r)=>{if(typeof BroadcastChannel>"u")return {emit:()=>{},stop:()=>{}};let t=new BroadcastChannel(`pulse_${a}`);return t.onmessage=o=>{if(o.origin===window.location.origin||!o.origin)try{let e=o.data;e&&typeof e=="object"&&!e.__proto__&&!e.constructor&&r(e);}catch(e){console.warn("[dphelper] Invalid message received in pulse:",e);}},{emit:o=>t.postMessage(o),stop:()=>t.close()}},tab:(a,r)=>{if(typeof BroadcastChannel>"u")return {post:()=>{},close:()=>{}};let t=new BroadcastChannel(a);return t.onmessage=o=>{if(o.origin===window.location.origin||!o.origin)try{let e=o.data;e&&typeof e=="object"&&!e.__proto__&&!e.constructor&&r(e);}catch(e){console.warn("[dphelper] Invalid message received in tab:",e);}},{post:o=>t.postMessage(o),close:()=>t.close()}},storageProxy:async(a,r,t)=>{if(typeof localStorage>"u")return r;let o,e=localStorage.getItem(a);if(e)if(t){let n=await dphelper.security.getEncrypted(a,t);o=n?JSON.parse(n):r;}else try{o=JSON.parse(e);}catch{o=r;}else o=r;return new Proxy(o,{set(n,u,d){n[u]=d;let l=JSON.stringify(n);return t?dphelper.security.saveEncrypted(a,l,t):localStorage.setItem(a,l),true}})}};dphelper?.setDescription(m,h);var S=dphelper.sync;exports.sync=S;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
+
export interface SyncTool {
|
|
3
|
+
/**
|
|
4
|
+
* Synchronize data between tabs using BroadcastChannel.
|
|
5
|
+
*/
|
|
6
|
+
tab: (channelName: string, callback: (data: any) => void) => { post: (data: any) => void, close: () => void }
|
|
7
|
+
/**
|
|
8
|
+
* Create a Proxy object linked to localStorage for auto-sync with optional encryption.
|
|
9
|
+
*/
|
|
10
|
+
storageProxy: <T extends object>(key: string, initialValue: T, secret?: string) => Promise<T>
|
|
11
|
+
/**
|
|
12
|
+
* Low-latency cross-tab event bus.
|
|
13
|
+
*/
|
|
14
|
+
pulse: (channelName: string, callback: (data: any) => void) => { emit: (data: any) => void, stop: () => void }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const sync: SyncTool
|
package/modules/sync.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var u={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...p},configurable:true,writable:true},version:{value:u.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var s=dphelper;Object.defineProperty(s,"setProps",{value:(a,r,t)=>{Object.defineProperty(a,r.name,t||{writable:false,configurable:false,enumerable:false}),t?.lock&&Object.freeze(a[r.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(s,"setDescription",{value:(a,r)=>{Object.defineProperties(s,{[a.name]:{value:r,writable:false,configurable:false,enumerable:false}}),Object.keys(r).map(t=>(Object.defineProperties(s[a.name],{[t]:{writable:false,configurable:false,enumerable:false}}),null)),s.setProps(s,a,{writable:false,configurable:false,enumerable:false}),s._list.scripts.push(a);}});var h={name:"sync",active:true,subCommand:[{name:"tab",version:"0.0.2",example:"dphelper.sync.tab('my_channel', (data) => console.debug(data))",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Synchronize data between tabs using BroadcastChannel",env:"client",subCommand:[]},{name:"storageProxy",version:"0.0.2",example:"const proxy = dphelper.sync.storageProxy('user_pref', {theme: 'dark'})",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Create a Proxy object linked to localStorage for auto-sync",env:"client",subCommand:[]},{name:"pulse",version:"0.0.1",example:"dphelper.sync.pulse('chat', (msg) => ...)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Low-latency cross-tab event bus with automatic registration.",env:"client",subCommand:[]}]},y={pulse:(a,r)=>{if(typeof BroadcastChannel>"u")return {emit:()=>{},stop:()=>{}};let t=new BroadcastChannel(`pulse_${a}`);return t.onmessage=o=>{if(o.origin===window.location.origin||!o.origin)try{let e=o.data;e&&typeof e=="object"&&!e.__proto__&&!e.constructor&&r(e);}catch(e){console.warn("[dphelper] Invalid message received in pulse:",e);}},{emit:o=>t.postMessage(o),stop:()=>t.close()}},tab:(a,r)=>{if(typeof BroadcastChannel>"u")return {post:()=>{},close:()=>{}};let t=new BroadcastChannel(a);return t.onmessage=o=>{if(o.origin===window.location.origin||!o.origin)try{let e=o.data;e&&typeof e=="object"&&!e.__proto__&&!e.constructor&&r(e);}catch(e){console.warn("[dphelper] Invalid message received in tab:",e);}},{post:o=>t.postMessage(o),close:()=>t.close()}},storageProxy:async(a,r,t)=>{if(typeof localStorage>"u")return r;let o,e=localStorage.getItem(a);if(e)if(t){let n=await dphelper.security.getEncrypted(a,t);o=n?JSON.parse(n):r;}else try{o=JSON.parse(e);}catch{o=r;}else o=r;return new Proxy(o,{set(n,d,b){n[d]=b;let c=JSON.stringify(n);return t?dphelper.security.saveEncrypted(a,c,t):localStorage.setItem(a,c),true}})}};dphelper?.setDescription(h,y);var k=dphelper.sync;export{k as sync};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var i={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var n={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...i},configurable:true,writable:true},version:{value:n.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var l=dphelper;Object.defineProperty(l,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(l,"setDescription",{value:(e,t)=>{Object.defineProperties(l,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(l[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),l.setProps(l,e,{writable:false,configurable:false,enumerable:false}),l._list.scripts.push(e);}});var c={name:"system",active:true,subCommand:[{name:"multiSplit",version:"0.0.2",example:"dphelper.system.multiSplit()",author:"Dario Passariello",creationDate:"20231121",lastMod:"20231121",type:"system",active:true,description:"Run only one time when you load your App ... extend the .split with array as argument (example.split([',', ':', ';', '?', '/'])[0])",env:"both",subCommand:[]}]},b={multiSplit:(e,t)=>{if(!e)return [];let r=t[0];if(!r)return [e];let a=e;for(let o=1;o<t.length;++o)a=a.split(t[o]).join(r);return a.split(r)}};dphelper?.setDescription(c,b);var O=dphelper.system;exports.system=O;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var p={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...n},configurable:true,writable:true},version:{value:p.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var l=dphelper;Object.defineProperty(l,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(l,"setDescription",{value:(e,t)=>{Object.defineProperties(l,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(l[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),l.setProps(l,e,{writable:false,configurable:false,enumerable:false}),l._list.scripts.push(e);}});var b={name:"system",active:true,subCommand:[{name:"multiSplit",version:"0.0.2",example:"dphelper.system.multiSplit()",author:"Dario Passariello",creationDate:"20231121",lastMod:"20231121",type:"system",active:true,description:"Run only one time when you load your App ... extend the .split with array as argument (example.split([',', ':', ';', '?', '/'])[0])",env:"both",subCommand:[]}]},m={multiSplit:(e,t)=>{if(!e)return [];let r=t[0];if(!r)return [e];let a=e;for(let o=1;o<t.length;++o)a=a.split(t[o]).join(r);return a.split(r)}};dphelper?.setDescription(b,m);var x=dphelper.system;export{x as system};
|
package/modules/text.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';var l={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var p={version:"4.5.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...l},configurable:true,writable:true},version:{value:p.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var o=dphelper;Object.defineProperty(o,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(o,"setDescription",{value:(e,t)=>{Object.defineProperties(o,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(o[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),o.setProps(o,e,{writable:false,configurable:false,enumerable:false}),o._list.scripts.push(e);}});var d={name:"text",active:true,subCommand:[{name:"trim",version:"0.0.2",example:"dphelper.text.trim(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Trims the specified characters from the start and end of a string.",env:"both",subCommand:[]},{name:"capitalize",version:"0.0.2",example:"dphelper.text.capitalize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Capitalizes the first letter of each word in a string.",env:"both",subCommand:[]},{name:"lower",version:"0.0.2",example:"dphelper.text.lower(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to lowercase.",env:"both",subCommand:[]},{name:"upper",version:"0.0.2",example:"dphelper.text.upper(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to uppercase.",env:"both",subCommand:[]},{name:"nl2br",version:"0.0.2",example:"dphelper.text.nl2br(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts newlines in a string to HTML <br> tags.",env:"both",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.text.sanitize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sanitizes a string by removing HTML tags.",env:"both",subCommand:[]},{name:"camelCase",version:"0.0.2",example:"dphelper.text.camelCase(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to camelCase.",subCommand:[{name:"toSpace",version:"0.0.2",example:"dphelper.text.camelCase.toSpace(...)",type:"function",active:true,description:"Converts camelCase to space-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"toUnderscore",version:"0.0.2",example:"dphelper.text.camelCase.toUnderscore(...)",type:"function",active:true,description:"Converts camelCase to underscore-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"}]},{name:"fitContainer",version:"0.0.2",example:"dphelper.text.fitContainer([element])",type:"function",active:true,description:"Adjusts the font size of an element to fit its container.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"keywords",version:"0.0.2",example:"dphelper.text.keywords([sentence])",type:"function",active:true,description:"Extrapolate keywords from a sentence",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20250601",lastMod:"20250601"},{name:"replaceText",version:"0.0.2",example:"dphelper.text.replaceText([sentence, object])",type:"function",active:true,description:`
|
|
2
|
+
replace all occurrence from sentence using an object as list
|
|
3
|
+
|
|
4
|
+
example:
|
|
5
|
+
|
|
6
|
+
let text = replaceText(
|
|
7
|
+
"Copyright 2022 (c) by dpHelper",
|
|
8
|
+
{
|
|
9
|
+
"(c)": '©',
|
|
10
|
+
"(r)": '®'
|
|
11
|
+
}
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
Copyright text (c) became an html symbol
|
|
15
|
+
`,env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20250612",lastMod:"20250612"}]},b={trim:(e,t,r,a)=>e.charAt(0)===t?e.substring(r,a):e,capitalize:e=>e.toLowerCase().replace(/\b\w/g,t=>t.toUpperCase()),lower:e=>e.toLowerCase(),upper:e=>e.toUpperCase(),nl2br:e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/(?:\r\n|\r|\n)/g,"<br>"),sanitize:e=>e.replace(/<(|\/|[^>\bi]|\/[^>bi]|[^/>][^>]+|\/[^>][^>]+)>/g,""),camelCase:{toSpace:e=>e.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()),toUnderscore:e=>e.replace(/\.?([A-Z])/g,(t,r)=>`_${r.toLowerCase()}`).replace(/^_/,"")},fitContainer:e=>{if(!e)return;function t(r){let a=document.querySelectorAll(r),s=a.length;if(!(s<=0))for(let n=0;n<s;n++){let c=a[n].offsetWidth*.05;a[n].style.fontSize=`${c}px`;}}dphelper.addListenerMulti(window,"load resize",()=>t(e));},keywords:e=>{let t=/\b[A-Z][a-z]+\b/g,r=e.match(t)?.filter(a=>a.length>3)||[];return [...new Set(r.map(a=>a.toLowerCase()))]},replaceText:(e,t)=>{let r=e;for(let a in t)Object.hasOwn(t,a)&&(r=r.replaceAll(a,t[a]||""));return r}};dphelper?.setDescription(d,b);var M=dphelper.text;exports.text=M;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
+
export interface TextTool {
|
|
3
|
+
trim(s: string, c: string, b: number, e: number): string
|
|
4
|
+
capitalize(txt: string): string
|
|
5
|
+
lower(txt: string): string
|
|
6
|
+
upper(txt: string): string
|
|
7
|
+
nl2br(str: string): string
|
|
8
|
+
sanitize(str: string): string
|
|
9
|
+
camelCase: {
|
|
10
|
+
toSpace(string: string): string
|
|
11
|
+
toUnderscore(string: string): string
|
|
12
|
+
}
|
|
13
|
+
fitContainer(el: string): void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const text: TextTool
|