js.foresight-devtools 0.0.1 → 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Bart Spaans
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
- # ForesightJS Debugger
1
+ # ForesightJS Development Tools
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@js.foresight/debugger.svg)](https://www.npmjs.com/package/@js.foresight/debugger)
3
+ [![npm version](https://img.shields.io/npm/v/js.foresight-devtools.svg)](https://www.npmjs.com/package/js.foresight-devtools)
4
4
  [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
- Visual debugging tools for [ForesightJS](https://foresightjs.com/) - a library that predicts user intent by analyzing mouse movements, scroll behavior, and keyboard navigation to enable proactive actions like prefetching.
7
+ Visual development tools for [ForesightJS](https://foresightjs.com/) - a library that predicts user intent by analyzing mouse movements, scroll behavior, and keyboard navigation to enable proactive actions like prefetching.
8
8
 
9
- ## What is the ForesightJS Debugger?
9
+ ## What are the ForesightJS Development Tools?
10
10
 
11
- The ForesightJS Debugger is a plugin development tool that provides visual debugging capabilities for ForesightJS implementations. It helps developers understand and tune how ForesightJS is working in their applications by providing real-time visualization of:
11
+ The ForesightJS Development Tools are a companion development package that provides visual development capabilities for ForesightJS implementations. They help developers understand and tune how ForesightJS is working in their applications by providing real-time visualization of:
12
12
 
13
13
  - **Mouse trajectory predictions** - See predicted cursor paths and intersection points
14
14
  - **Element bounds and hit slop areas** - Visualize registered elements and their interaction zones
@@ -16,16 +16,16 @@ The ForesightJS Debugger is a plugin development tool that provides visual debug
16
16
  - **Callback execution** - Monitor when and why prediction callbacks fire
17
17
  - **Real-time settings control** - Adjust ForesightJS parameters on the fly
18
18
 
19
- ![ForesightJS Debugger Demo](https://github.com/user-attachments/assets/36c81a82-fee7-43d6-ba1e-c48214136f90)
19
+ ![ForesightJS Development Tools Demo](https://github.com/user-attachments/assets/36c81a82-fee7-43d6-ba1e-c48214136f90)
20
20
 
21
21
  ## Installation
22
22
 
23
23
  ```bash
24
- npm install js.foresight-devtools
24
+ pnpm add -D js.foresight-devtools
25
25
  # or
26
- pnpm add js.foresight-devtools
26
+ npm install -D js.foresight-devtools
27
27
  # or
28
- yarn add js.foresight-devtools
28
+ yarn add -D js.foresight-devtools
29
29
  ```
30
30
 
31
31
  ## Basic Usage
@@ -37,14 +37,14 @@ import { ForesightDebugger } from "js.foresight-devtools"
37
37
  // Initialize ForesightJS
38
38
  ForesightManager.initialize()
39
39
 
40
- // Initialize debugger
40
+ // Initialize development tools
41
41
  ForesightDebugger.initialize(ForesightManager.instance)
42
42
  ```
43
43
 
44
44
  ## Configuration Options
45
45
 
46
46
  ```typescript
47
- type DebuggerSettings = {
47
+ type DevelopmentToolsSettings = {
48
48
  showDebugger?: boolean
49
49
  isControlPanelDefaultMinimized?: boolean
50
50
  showNameTags?: boolean // Show element names on overlays
@@ -52,9 +52,53 @@ type DebuggerSettings = {
52
52
  }
53
53
  ```
54
54
 
55
+ ### Available Development Tools Settings
56
+
57
+ **TypeScript Type:** `DevelopmentToolsSettings`
58
+
59
+ | Setting | Type | Default | Description |
60
+ | -------------------------------- | ----------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
61
+ | `showDebugger` | `boolean` | `true` | Controls whether the development tools are visible and active |
62
+ | `isControlPanelDefaultMinimized` | `boolean` | `false` | When true, the development tools control panel will be minimized on page load |
63
+ | `showNameTags` | `boolean` | `true` | Shows the element `name` (or `id` if no `name` is given) above registered elements |
64
+ | `sortElementList` | `SortElementList` | `visibility` | Controls element sorting in control panel: `visibility` sorts by viewport visibility, `documentOrder` sorts by HTML structure order, `insertionOrder` sorts by registration order |
65
+
66
+ ### Usage Example with All Options
67
+
68
+ ```javascript
69
+ import { ForesightManager } from "js.foresight"
70
+ import { ForesightDebugger } from "js.foresight-devtools"
71
+
72
+ // Initialize ForesightJS
73
+ ForesightManager.initialize({
74
+ trajectoryPredictionTime: 100,
75
+ defaultHitSlop: { top: 10, right: 10, bottom: 10, left: 10 },
76
+ enableMousePrediction: true,
77
+ enableTabPrediction: true,
78
+ enableScrollPrediction: true,
79
+ })
80
+
81
+ // Initialize development tools with custom settings
82
+ ForesightDebugger.initialize(ForesightManager.instance, {
83
+ showDebugger: true,
84
+ isControlPanelDefaultMinimized: false,
85
+ showNameTags: true,
86
+ sortElementList: "visibility",
87
+ })
88
+
89
+ // Register elements as usual
90
+ ForesightManager.instance.register({
91
+ element: document.getElementById("my-button"),
92
+ callback: () => {
93
+ console.log("Prediction triggered!")
94
+ },
95
+ name: "my-button", // This name will appear in the development tools
96
+ })
97
+ ```
98
+
55
99
  ## Development Workflow
56
100
 
57
- The debugger is particularly useful when:
101
+ The development tools are particularly useful when:
58
102
 
59
103
  1. **Setting up ForesightJS** for the first time in an application
60
104
  2. **Fine-tuning prediction parameters** for specific UI components
@@ -64,7 +108,7 @@ The debugger is particularly useful when:
64
108
 
65
109
  ## Framework Integration
66
110
 
67
- Since both ForesightJS and the debugger are framework-agnostic, you can use them together in any JavaScript environment:
111
+ Since both ForesightJS and the development tools are framework-agnostic, you can use them together in any JavaScript environment:
68
112
 
69
113
  - React / Next.js
70
114
  - Vue / Nuxt