dphelper 3.0.6 → 3.0.7
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/dphelper.umd.js +26 -26
- package/index.js +13 -13
- package/package.json +5 -4
- package/postinstall.mjs +23 -0
- package/tools/ai/interface.d.ts +12 -0
- package/tools/anchor/interface.d.ts +7 -0
- package/tools/array/interface.d.ts +22 -0
- package/tools/audio/interface.d.ts +11 -0
- package/tools/avoid/interface.d.ts +3 -0
- package/tools/browser/interface.d.ts +11 -0
- package/tools/check/interface.d.ts +5 -0
- package/tools/color/interface.d.ts +7 -0
- package/tools/cookie/interface.d.ts +13 -0
- package/tools/coords/interface.d.ts +9 -0
- package/tools/credits/interface.d.ts +12 -0
- package/tools/date/interface.d.ts +26 -0
- package/tools/disable/interface.d.ts +9 -0
- package/tools/dispatch/interface.d.ts +5 -0
- package/tools/elements/interface.d.ts +4 -0
- package/tools/events/interface.d.ts +7 -0
- package/tools/fetch/interface.d.ts +16 -0
- package/tools/form/interface.d.ts +14 -0
- package/tools/format/interface.d.ts +4 -0
- package/tools/json/interface.d.ts +9 -0
- package/tools/load/interface.d.ts +9 -0
- package/tools/logging/interface.d.ts +9 -0
- package/tools/math/interface.d.ts +14 -0
- package/tools/memory/interface.d.ts +4 -0
- package/tools/navigation/interface.d.ts +5 -0
- package/tools/objects/interface.d.ts +16 -0
- package/tools/path/interface.d.ts +5 -0
- package/tools/promise/interface.d.ts +4 -0
- package/tools/sanitize/interface.d.ts +3 -0
- package/tools/screen/interface.d.ts +12 -0
- package/tools/scrollbar/interface.d.ts +10 -0
- package/tools/security/interface.d.ts +12 -0
- package/tools/shortcut/interface.d.ts +3 -0
- package/tools/socket/interface.d.ts +13 -0
- package/tools/sse/interface.d.ts +9 -0
- package/tools/svg/interface.d.ts +13 -0
- package/tools/sync/interface.d.ts +14 -0
- package/tools/system/interface.d.ts +3 -0
- package/tools/text/interface.d.ts +13 -0
- package/tools/timer/interface.d.ts +4 -0
- package/tools/tools/interface.d.ts +6 -0
- package/tools/translators/interface.d.ts +3 -0
- package/tools/triggers/interface.d.ts +5 -0
- package/tools/types/interface.d.ts +6 -0
- package/tools/ui/interface.d.ts +4 -0
- package/tools/window/interface.d.ts +10 -0
- package/types/dphelper.d.ts +578 -139
- package/types/index.d.ts +1 -47
- package/types/tools/navigation/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dphelper",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"browser": "./dist/dphelper.umd.js",
|
|
7
7
|
"description": "dphelper devtools for developers",
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"types": "./types/
|
|
9
|
+
"types": "./types/dphelper.d.ts",
|
|
10
10
|
"typings": "./types/*",
|
|
11
11
|
"copyright": "Dario Passariello",
|
|
12
12
|
"homepage": "https://a51.gitbook.io/dphelper",
|
|
@@ -65,17 +65,18 @@
|
|
|
65
65
|
],
|
|
66
66
|
"exports": {
|
|
67
67
|
".": {
|
|
68
|
-
"types": "./types/
|
|
68
|
+
"types": "./types/dphelper.d.ts",
|
|
69
69
|
"import": "./index.js",
|
|
70
70
|
"default": "./index.js"
|
|
71
71
|
},
|
|
72
72
|
"./types/*": "./types/*"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
|
-
"build": "rimraf dist && npm run generate-imports && node esbuild.config.mjs && node node_modules/typescript/bin/tsc -p tsconfig.json --emitDeclarationOnly",
|
|
75
|
+
"build": "rimraf dist && npm run generate-imports && node esbuild.config.mjs && node node_modules/typescript/bin/tsc -p tsconfig.json --emitDeclarationOnly && node scripts/patch-dist.mjs",
|
|
76
76
|
"dev": "npm run generate-imports && node esbuild.config.mjs --watch-and-serve",
|
|
77
77
|
"npm:pack": "npm run build && cd dist && npm pack",
|
|
78
78
|
"npm:publish": "npm run build && npm publish ./dist --access public",
|
|
79
|
+
"postinstall": "node postinstall.mjs",
|
|
79
80
|
"test": "cd tests && npm run test",
|
|
80
81
|
"lint": "cd tests && npm run lint",
|
|
81
82
|
"tsc": "cd tests && tsc --noEmit",
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// dphelper postinstall
|
|
2
|
+
// Creates node_modules/@types/dphelper/index.d.ts automatically so TypeScript
|
|
3
|
+
// discovers dphelper's global types without any configuration in the consumer project.
|
|
4
|
+
import fs from 'node:fs'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
|
|
8
|
+
const
|
|
9
|
+
__dirname = path.dirname(fileURLToPath(import.meta.url)),
|
|
10
|
+
// When postinstall runs, cwd is the consuming project root.
|
|
11
|
+
// __dirname is node_modules/dphelper/
|
|
12
|
+
atTypesDir = path.join(__dirname, '..', '@types', 'dphelper'),
|
|
13
|
+
atTypesFile = path.join(atTypesDir, 'index.d.ts'),
|
|
14
|
+
reference = '/// <reference path="../../dphelper/types/dphelper.d.ts" />\n'
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
fs.mkdirSync(atTypesDir, { recursive: true })
|
|
18
|
+
fs.writeFileSync(atTypesFile, reference, 'utf8')
|
|
19
|
+
console.debug('[dphelper] Global types registered at node_modules/@types/dphelper/index.d.ts')
|
|
20
|
+
} catch (e) {
|
|
21
|
+
// Non-fatal: types can still be referenced manually
|
|
22
|
+
console.debug('[dphelper] Could not auto-register types:', e)
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface AiTool {
|
|
2
|
+
tokenCount: (data: any) => number
|
|
3
|
+
smartSanitize: (text: string) => string
|
|
4
|
+
toon: (data: any) => string
|
|
5
|
+
toonToJson: (toon: string) => any
|
|
6
|
+
chunker: (text: string, options?: { size?: number, overlap?: number }) => string[]
|
|
7
|
+
similarity: (a: number[], b: number[]) => number
|
|
8
|
+
extractReasoning: (text: string) => { reasoning: string, content: string }
|
|
9
|
+
prompt: (template: string, vars: Record<string, any>) => string
|
|
10
|
+
schema: (data: any) => string
|
|
11
|
+
snapshot: () => string
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface ArrayTool {
|
|
2
|
+
find<T>(array: T[], key: any): T | any
|
|
3
|
+
unique<T>(array: T[]): T[]
|
|
4
|
+
delete<T>(array: T[], key: keyof T): void
|
|
5
|
+
merge<T>(arrayA: T[], arrayB: T[]): T[]
|
|
6
|
+
mergeByKey<T extends Record<string, any>>(arrayA: T[], arrayB: T[], key: keyof T): T[]
|
|
7
|
+
asc<T>(array: T[]): T[]
|
|
8
|
+
desc<T>(array: T[]): T[]
|
|
9
|
+
duplicates<T>(array: T[]): T[]
|
|
10
|
+
even<T>(array: T[]): T[]
|
|
11
|
+
odd<T>(array: T[]): T[]
|
|
12
|
+
toObj<T>(array: T[]): Record<string, T>
|
|
13
|
+
sumColumn(array: number[][], column: number): number
|
|
14
|
+
shuffle<T>(array: T[]): T[]
|
|
15
|
+
generate(num: number): number[]
|
|
16
|
+
testArrayInt(array: unknown[]): number[]
|
|
17
|
+
rand32(number: number): number
|
|
18
|
+
findindex<T>(array: T[], key: any): number
|
|
19
|
+
pathToJson(array: string[], separator?: string): Record<string, unknown>
|
|
20
|
+
deepClone<T>(src: T): T
|
|
21
|
+
match(arrayWords: string[], arrayToCheck: string[]): boolean
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface AudioTool {
|
|
2
|
+
/**
|
|
3
|
+
* Plays an audio file if it is not already playing.
|
|
4
|
+
* If no file is specified, removes all audio elements from the document.
|
|
5
|
+
*
|
|
6
|
+
* @param file - The name of the audio file to play.
|
|
7
|
+
* @param path - The path to the audio file.
|
|
8
|
+
* @param loop - Whether the audio should loop.
|
|
9
|
+
*/
|
|
10
|
+
play: (file?: string, path?: string, loop?: boolean) => void
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface BrowserTool {
|
|
2
|
+
state(state: any, title: any, url: any): void
|
|
3
|
+
forw(times: number): void
|
|
4
|
+
back(times: number): void
|
|
5
|
+
reload(): void
|
|
6
|
+
href(url: string): void
|
|
7
|
+
offLine(text?: string): void
|
|
8
|
+
zoom(): number
|
|
9
|
+
status(code: number): string
|
|
10
|
+
interlock(onUpdate: (tabs: number) => void): void
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface CoordsTool {
|
|
2
|
+
degreesToRadians: (degrees: any) => any
|
|
3
|
+
latToMeters: (points: any) => any
|
|
4
|
+
toVector: (points: any) => any
|
|
5
|
+
convertToDecDegrees: (deg: any, minutes: any, sec: any, direction: any) => any
|
|
6
|
+
distance: (point1: any, point2: any) => any
|
|
7
|
+
polarToCartesian: (centerX: any, centerY: any, radius: any, angleInDegrees: any) => any
|
|
8
|
+
mapDegreesToPixels: (degree: number, minDegree: number, maxDegree: number, minPixel: number, maxPixel: number, padding: number) => number
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface DateTool {
|
|
2
|
+
days: (lang?: string) => string[]
|
|
3
|
+
months: (lang?: string) => string[]
|
|
4
|
+
year: () => number
|
|
5
|
+
toIso: (value: any, int?: string) => string | null
|
|
6
|
+
toMMDDYYYY: (value: any) => string
|
|
7
|
+
toYYYYMMDD: (value: any) => string | undefined
|
|
8
|
+
toHuman: (value: any) => string
|
|
9
|
+
convert: (value: any, format: string[]) => string | null
|
|
10
|
+
iso2Epoch: (value: any) => number
|
|
11
|
+
localIsoTime: (value: any) => string
|
|
12
|
+
utc: () => string
|
|
13
|
+
parse: (value: any, separator?: string) => string | null
|
|
14
|
+
addDays: (date: any, days: number) => Date
|
|
15
|
+
dateTimeToString: (dateObject: any) => string
|
|
16
|
+
isoToHuman: (value: any, symbol?: string) => string | null
|
|
17
|
+
fullDate: () => string
|
|
18
|
+
epoch: () => number
|
|
19
|
+
diffInDays: (d1: any, d2: any) => number
|
|
20
|
+
diffInWeeks: (d1: any, d2: any) => number
|
|
21
|
+
diffInMonths: (d1: any, d2: any) => number
|
|
22
|
+
diffInYears: (d1: any, d2: any) => number
|
|
23
|
+
dateToYMD: (date: any) => string
|
|
24
|
+
collection: (params: { date?: Date; type: string; locale?: string }) => string | undefined
|
|
25
|
+
timeZones: () => string[]
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface EventsTool {
|
|
2
|
+
list: (el: Element) => any
|
|
3
|
+
multi: (element: Element, eventNames: string, listener: EventListener) => void
|
|
4
|
+
copy: (el: string) => void
|
|
5
|
+
onDrag: (elem: string) => void
|
|
6
|
+
keys: (e: KeyboardEvent) => { key: string; ctrl: boolean; alt: boolean; shift: boolean }
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface FetchTool {
|
|
2
|
+
/**
|
|
3
|
+
* Perform a resilient fetch with automatic retries and exponential backoff.
|
|
4
|
+
*/
|
|
5
|
+
(url: string, options?: any, retries?: number, backoff?: number): Promise<Response>
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Perform a GET request.
|
|
9
|
+
*/
|
|
10
|
+
get: (url: string, options?: any) => Promise<Response>
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Perform a POST request with optional JSON body auto-serialization.
|
|
14
|
+
*/
|
|
15
|
+
post: (url: string, body: any, options?: any) => Promise<Response>
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface FormTool {
|
|
2
|
+
serialize: (form: HTMLFormElement) => { [key: string]: any }
|
|
3
|
+
confirmType: (type: string, value: any) => boolean
|
|
4
|
+
required: (value: any) => string | undefined
|
|
5
|
+
minLength: (value: any, num?: number) => string | undefined
|
|
6
|
+
maxLength: (value: any, num?: number) => string | undefined
|
|
7
|
+
maxPhoneNumber: (value: any, num?: number) => string | undefined
|
|
8
|
+
isNumeric: (value: any) => boolean
|
|
9
|
+
isEmail: (value: any) => boolean
|
|
10
|
+
pattern: (e: Event) => void
|
|
11
|
+
noSpecialChars: (e: Event) => void
|
|
12
|
+
table: (size: [number, number], id: string, elem: HTMLElement) => void
|
|
13
|
+
sanitize: (str: string) => string | undefined
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface JsonTool {
|
|
2
|
+
counter: (json: any, key?: string, val?: any) => number | null
|
|
3
|
+
toCsv: (jsonInput: any) => string
|
|
4
|
+
saveCsvAs: (csvData: string, fileName: string) => void
|
|
5
|
+
is: (str: string) => boolean
|
|
6
|
+
parse: (file: string) => any
|
|
7
|
+
sanitize: (str: string) => string
|
|
8
|
+
sanitizeJsonValue: (str: string) => string
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface LoadTool {
|
|
2
|
+
all: (context: any, cacheName?: string) => void
|
|
3
|
+
file: (filePath: string) => Promise<string>
|
|
4
|
+
fileToElement: (elementSelector: string, filePath: string) => Promise<void>
|
|
5
|
+
json: (filePath: string) => Promise<any>
|
|
6
|
+
remote: (path: string, method?: string, headers?: HeadersInit) => Promise<any>
|
|
7
|
+
script: (scripts: string[], elementSelector?: string) => void
|
|
8
|
+
toJson: (context: any, cacheName?: string) => void
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface MathTool {
|
|
2
|
+
rnd: () => number
|
|
3
|
+
tmr: () => number
|
|
4
|
+
add: (a: number, b: number) => number
|
|
5
|
+
sub: (a: number, b: number) => number
|
|
6
|
+
multi: (a: number, b: number) => number
|
|
7
|
+
div: (a: number, b: number) => number
|
|
8
|
+
rem: (a: number, b: number) => number
|
|
9
|
+
exp: (a: number, b: number) => number
|
|
10
|
+
isOdd: (a: number) => boolean
|
|
11
|
+
float2int: (a: number) => number
|
|
12
|
+
percent: (n: number, tot: number) => number
|
|
13
|
+
isPrime: (n: number) => boolean
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface ObjectsTool {
|
|
2
|
+
toArray: (object: Record<string, any>) => [string, any][]
|
|
3
|
+
replaceNullObjects: (data: Record<string, any>) => Record<string, any>
|
|
4
|
+
serialize: (value: any) => any
|
|
5
|
+
deSerialize: (valueNew: any) => any
|
|
6
|
+
sort: (o: Record<string, any>) => Record<string, any>
|
|
7
|
+
toXML: (obj: Record<string, any>) => string
|
|
8
|
+
find: (array: any[], key: string, value: any) => any
|
|
9
|
+
instance: (obj: any) => any
|
|
10
|
+
updateByKey: (obj: Record<string, any>, key: string, newValue: any) => Record<string, any>
|
|
11
|
+
findindex: (array: any[], key: string) => number
|
|
12
|
+
parse: (val: any) => any
|
|
13
|
+
isObject: (val: any) => boolean
|
|
14
|
+
diff: (obj1: Record<string, any>, obj2: Record<string, any>) => Record<string, { obj1: any, obj2: any }>
|
|
15
|
+
path: (prop: string, array: string[], separator?: string) => string
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface ScrollbarTool {
|
|
2
|
+
custom: (el: string, options: any) => void
|
|
3
|
+
indicator: (props: any) => void
|
|
4
|
+
position: {
|
|
5
|
+
get: (el: any) => void
|
|
6
|
+
set: (el: any) => void
|
|
7
|
+
}
|
|
8
|
+
smooth: (target: any, speed: any, smooth: any) => void
|
|
9
|
+
scrollTo: (container: string, element: string, gap?: number) => void
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface SecurityTool {
|
|
2
|
+
uuid: {
|
|
3
|
+
byVal: (string: string) => string
|
|
4
|
+
v4: string
|
|
5
|
+
v5: string
|
|
6
|
+
}
|
|
7
|
+
hashPass: (u: string, p: string, t?: string) => Promise<string>
|
|
8
|
+
crypt: (u: string, p: string, mode?: string) => string
|
|
9
|
+
deCrypt: (u: string, p: string, mode?: string) => string
|
|
10
|
+
AES_KeyGen: (passKey?: string) => string
|
|
11
|
+
SHA256_Hex: (passKey: string) => string
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface SocketTool {
|
|
2
|
+
info: () => string
|
|
3
|
+
start: (element: any, server: any, name: string) => void
|
|
4
|
+
conn: (id: any, server: any, name: string) => void
|
|
5
|
+
connect: (server: any, name: string) => void
|
|
6
|
+
open: (id: any, server: any, name: string) => void
|
|
7
|
+
send: (mex: any, type?: string) => void
|
|
8
|
+
ping: (name: string) => void
|
|
9
|
+
receive: (el?: any, name?: string) => void
|
|
10
|
+
keepAlive: (name: string) => void
|
|
11
|
+
check: () => void
|
|
12
|
+
list: () => WebSocket[]
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface SvgTool {
|
|
2
|
+
init: (container: HTMLElement, source1: [HTMLElement, string], source2: [HTMLElement, string], cb?: Function) => void
|
|
3
|
+
check: () => boolean
|
|
4
|
+
update: (rect1: HTMLElement, rect2: HTMLElement, cxn: HTMLElement) => void
|
|
5
|
+
getCurve: (p1: [number, number], p2: [number, number], dx: number) => string
|
|
6
|
+
getIntersection: (dx: number, dy: number, cx: number, cy: number, w: number, h: number) => [number, number]
|
|
7
|
+
setConnector: (source: HTMLElement, side: string) => HTMLElement
|
|
8
|
+
removeConnection: (container: HTMLElement) => void
|
|
9
|
+
makeScrollable: (svgContainer: HTMLElement, scrollContainer: HTMLElement, elm1: HTMLElement, elm2: HTMLElement, rect1: HTMLElement, rect2: HTMLElement) => void
|
|
10
|
+
makeDraggable: (evt: Event) => void
|
|
11
|
+
toggle: (evt: Event, container: HTMLElement, source1: HTMLElement, source2: HTMLElement) => void
|
|
12
|
+
convert: (options: any) => string | void
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface SyncTool {
|
|
2
|
+
/**
|
|
3
|
+
* Synchronize data between tabs using BroadcastChannel.
|
|
4
|
+
*/
|
|
5
|
+
tab: (channelName: string, callback: (data: any) => void) => { post: (data: any) => void, close: () => void }
|
|
6
|
+
/**
|
|
7
|
+
* Create a Proxy object linked to localStorage for auto-sync.
|
|
8
|
+
*/
|
|
9
|
+
storageProxy: <T extends object>(key: string, initialValue: T) => T
|
|
10
|
+
/**
|
|
11
|
+
* Low-latency cross-tab event bus.
|
|
12
|
+
*/
|
|
13
|
+
pulse: (channelName: string, callback: (data: any) => void) => { emit: (data: any) => void, stop: () => void }
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface TextTool {
|
|
2
|
+
trim(s: string, c: string, b: number, e: number): string
|
|
3
|
+
capitalize(txt: string): string
|
|
4
|
+
lower(txt: string): string
|
|
5
|
+
upper(txt: string): string
|
|
6
|
+
nl2br(str: string): string
|
|
7
|
+
sanitize(str: string): string
|
|
8
|
+
camelCase: {
|
|
9
|
+
toSpace(string: string): string
|
|
10
|
+
toUnderscore(string: string): string
|
|
11
|
+
}
|
|
12
|
+
fitContainer(el: string): void
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface WindowTool {
|
|
2
|
+
enhancement(): void
|
|
3
|
+
animationframe(): any
|
|
4
|
+
center(params: { url: string; title: string; name: string; w: number; h: number }): void
|
|
5
|
+
onBeforeUnLoad(e: any): void
|
|
6
|
+
purge(d?: Document, time?: number): void
|
|
7
|
+
stopZoomWheel(e: any): void
|
|
8
|
+
setZoom(element?: string, zoom?: number): string
|
|
9
|
+
getZoom(element?: string): number
|
|
10
|
+
}
|