dphelper 3.0.7 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dphelper",
3
- "version": "3.0.7",
3
+ "version": "3.1.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "browser": "./dist/dphelper.umd.js",
@@ -76,7 +76,6 @@
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",
80
79
  "test": "cd tests && npm run test",
81
80
  "lint": "cd tests && npm run lint",
82
81
  "tsc": "cd tests && tsc --noEmit",
@@ -84,7 +83,7 @@
84
83
  },
85
84
  "devDependencies": {
86
85
  "@types/crypto-js": "4.2.2",
87
- "@types/node": "^25.3.0",
86
+ "@types/node": "^25.3.1",
88
87
  "crypto-js": "4.2.0",
89
88
  "esbuild": "0.27.3",
90
89
  "esbuild-node-externals": "1.20.1",
@@ -9,4 +9,4 @@ interface AiTool {
9
9
  prompt: (template: string, vars: Record<string, any>) => string
10
10
  schema: (data: any) => string
11
11
  snapshot: () => string
12
- }
12
+ }
@@ -1,5 +1,44 @@
1
1
  interface TriggersTool {
2
- click(elem: string): void
3
- change(elem: string): void
4
- input(elem: string): void
5
- }
2
+ /**
3
+ * Add a trigger for custom events.
4
+ * @param event - The event name
5
+ * @param callback - The callback to execute when the event is triggered
6
+ */
7
+ add: (event: string, callback: (...args: any[]) => void) => void
8
+
9
+ /**
10
+ * Listen for a trigger event (alias for add).
11
+ */
12
+ on: (event: string, callback: (...args: any[]) => void) => void
13
+
14
+ /**
15
+ * Emit a trigger event and call all registered callbacks.
16
+ * @param event - The event name
17
+ * @param args - Arguments to pass to the callbacks
18
+ */
19
+ emit: (event: string, ...args: any[]) => void
20
+
21
+ /**
22
+ * Remove a trigger event and all its callbacks.
23
+ * @param event - The event name
24
+ */
25
+ remove: (event: string) => void
26
+
27
+ /**
28
+ * Remove a specific callback from an event.
29
+ * @param event - The event name
30
+ * @param callback - The callback to remove
31
+ */
32
+ off: (event: string, callback: (...args: any[]) => void) => void
33
+
34
+ /**
35
+ * Clear all triggers.
36
+ */
37
+ clear: () => void
38
+
39
+ /**
40
+ * List all registered trigger events.
41
+ * @returns Array of event names
42
+ */
43
+ list: () => string[]
44
+ }
@@ -486,9 +486,48 @@ declare global {
486
486
 
487
487
  // --- triggers ---
488
488
  interface TriggersTool {
489
- click(elem: string): void
490
- change(elem: string): void
491
- input(elem: string): void
489
+ /**
490
+ * Add a trigger for custom events.
491
+ * @param event - The event name
492
+ * @param callback - The callback to execute when the event is triggered
493
+ */
494
+ add: (event: string, callback: (...args: any[]) => void) => void
495
+
496
+ /**
497
+ * Listen for a trigger event (alias for add).
498
+ */
499
+ on: (event: string, callback: (...args: any[]) => void) => void
500
+
501
+ /**
502
+ * Emit a trigger event and call all registered callbacks.
503
+ * @param event - The event name
504
+ * @param args - Arguments to pass to the callbacks
505
+ */
506
+ emit: (event: string, ...args: any[]) => void
507
+
508
+ /**
509
+ * Remove a trigger event and all its callbacks.
510
+ * @param event - The event name
511
+ */
512
+ remove: (event: string) => void
513
+
514
+ /**
515
+ * Remove a specific callback from an event.
516
+ * @param event - The event name
517
+ * @param callback - The callback to remove
518
+ */
519
+ off: (event: string, callback: (...args: any[]) => void) => void
520
+
521
+ /**
522
+ * Clear all triggers.
523
+ */
524
+ clear: () => void
525
+
526
+ /**
527
+ * List all registered trigger events.
528
+ * @returns Array of event names
529
+ */
530
+ list: () => string[]
492
531
  }
493
532
 
494
533
  // --- types ---
package/postinstall.mjs DELETED
@@ -1,23 +0,0 @@
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
- }