js.foresight-devtools 0.0.1 → 0.0.3
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 +21 -0
- package/README.md +57 -13
- package/dist/Debugger/DebuggerControlPanel.js +751 -0
- package/dist/Debugger/ForesightDebugger.d.ts +2 -2
- package/dist/Debugger/ForesightDebugger.js +341 -0
- package/dist/Debugger/helpers/createAndAppend.js +16 -0
- package/dist/Debugger/helpers/getIntersectingIcon.js +3 -0
- package/dist/Debugger/helpers/objectToMethodCall.js +65 -0
- package/dist/Debugger/helpers/removeOldDebuggers.js +7 -0
- package/dist/Debugger/helpers/updateElementOverlays.js +18 -0
- package/dist/devtools.test.d.ts +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/dist/src/Debugger/DebuggerControlPanel.d.ts +82 -0
- package/dist/src/Debugger/DebuggerControlPanel.d.ts.map +1 -0
- package/dist/src/Debugger/ForesightDebugger.d.ts +50 -0
- package/dist/src/Debugger/ForesightDebugger.d.ts.map +1 -0
- package/dist/src/Debugger/constants.d.ts +17 -0
- package/dist/src/Debugger/constants.d.ts.map +1 -0
- package/dist/src/Debugger/helpers/createAndAppend.d.ts +9 -0
- package/dist/src/Debugger/helpers/createAndAppend.d.ts.map +1 -0
- package/dist/src/Debugger/helpers/evaluateRegistrationConditions.d.ts +4 -0
- package/dist/src/Debugger/helpers/evaluateRegistrationConditions.d.ts.map +1 -0
- package/dist/src/Debugger/helpers/getIntersectingIcon.d.ts +2 -0
- package/dist/src/Debugger/helpers/getIntersectingIcon.d.ts.map +1 -0
- package/dist/src/Debugger/helpers/objectToMethodCall.d.ts +14 -0
- package/dist/src/Debugger/helpers/objectToMethodCall.d.ts.map +1 -0
- package/dist/src/Debugger/helpers/removeOldDebuggers.d.ts +5 -0
- package/dist/src/Debugger/helpers/removeOldDebuggers.d.ts.map +1 -0
- package/dist/src/Debugger/helpers/shouldUpdateSetting.d.ts +2 -0
- package/dist/src/Debugger/helpers/shouldUpdateSetting.d.ts.map +1 -0
- package/dist/src/Debugger/helpers/updateElementOverlays.d.ts +4 -0
- package/dist/src/Debugger/helpers/updateElementOverlays.d.ts.map +1 -0
- package/dist/src/devtools.test.d.ts +2 -0
- package/dist/src/devtools.test.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/types.d.ts +70 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.js +1 -0
- package/package.json +22 -17
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
|
|
1
|
+
# ForesightJS Development Tools
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/js.foresight-devtools)
|
|
4
4
|
[](http://www.typescriptlang.org/)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
|
|
7
|
-
Visual
|
|
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
|
|
9
|
+
## What are the ForesightJS Development Tools?
|
|
10
10
|
|
|
11
|
-
The ForesightJS
|
|
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
|
-

|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
pnpm add -D js.foresight-devtools
|
|
25
25
|
# or
|
|
26
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|