@ourroadmaps/web-sdk 0.3.0
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 +314 -0
- package/dist/chunk-4DE2IREA.cjs +9 -0
- package/dist/chunk-4DE2IREA.cjs.map +1 -0
- package/dist/chunk-KGQKTDB4.cjs +537 -0
- package/dist/chunk-KGQKTDB4.cjs.map +1 -0
- package/dist/chunk-MKPDPQXT.js +534 -0
- package/dist/chunk-MKPDPQXT.js.map +1 -0
- package/dist/chunk-V6TY7KAL.js +7 -0
- package/dist/chunk-V6TY7KAL.js.map +1 -0
- package/dist/chunk-XFAAEDJK.js +1251 -0
- package/dist/chunk-XFAAEDJK.js.map +1 -0
- package/dist/chunk-ZPPQHIRO.cjs +1254 -0
- package/dist/chunk-ZPPQHIRO.cjs.map +1 -0
- package/dist/feedback/index.cjs +13 -0
- package/dist/feedback/index.cjs.map +1 -0
- package/dist/feedback/index.d.cts +20 -0
- package/dist/feedback/index.d.ts +20 -0
- package/dist/feedback/index.js +4 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/feedback.global.js +389 -0
- package/dist/feedback.global.js.map +1 -0
- package/dist/index.cjs +64 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/overlay/index.cjs +17 -0
- package/dist/overlay/index.cjs.map +1 -0
- package/dist/overlay/index.d.cts +205 -0
- package/dist/overlay/index.d.ts +205 -0
- package/dist/overlay/index.js +4 -0
- package/dist/overlay/index.js.map +1 -0
- package/dist/overlay.global.js +123 -0
- package/dist/overlay.global.js.map +1 -0
- package/dist/types-CEewztln.d.cts +11 -0
- package/dist/types-CEewztln.d.ts +11 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# @ourroadmaps/web-sdk
|
|
2
|
+
|
|
3
|
+
Interactive overlay system and feedback widget for OurRoadmaps. Create guided walkthroughs, cursor animations, and annotations for prototypes and demos.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### CDN (Recommended for Prototypes)
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<script src="https://unpkg.com/@ourroadmaps/web-sdk"></script>
|
|
11
|
+
<script>
|
|
12
|
+
const { createOverlay } = OurRoadmaps;
|
|
13
|
+
|
|
14
|
+
const overlay = createOverlay();
|
|
15
|
+
overlay.play({
|
|
16
|
+
version: 1,
|
|
17
|
+
cursor: { name: 'Guide', color: '#6366f1' },
|
|
18
|
+
actions: [
|
|
19
|
+
{ type: 'move', target: { selector: '#my-button' }, duration: 800 },
|
|
20
|
+
{ type: 'click' },
|
|
21
|
+
{ type: 'wait', duration: 1000 }
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### npm
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @ourroadmaps/web-sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import { createOverlay } from '@ourroadmaps/web-sdk'
|
|
35
|
+
|
|
36
|
+
const overlay = createOverlay()
|
|
37
|
+
await overlay.play(script)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Overlay System
|
|
41
|
+
|
|
42
|
+
The overlay system provides cursor animations and annotations for creating guided walkthroughs.
|
|
43
|
+
|
|
44
|
+
### Creating an Overlay
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
const overlay = createOverlay({
|
|
48
|
+
cursor: {
|
|
49
|
+
name: 'Guide', // Label shown next to cursor
|
|
50
|
+
color: '#6366f1', // Cursor color
|
|
51
|
+
visible: true // Initial visibility
|
|
52
|
+
},
|
|
53
|
+
annotations: {
|
|
54
|
+
color: '#ef4444', // Default annotation color
|
|
55
|
+
strokeWidth: 3 // Default stroke width
|
|
56
|
+
},
|
|
57
|
+
zIndex: 9999 // Stack order
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Script Format
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const script = {
|
|
65
|
+
version: 1,
|
|
66
|
+
cursor: { name: 'Guide', color: '#6366f1' },
|
|
67
|
+
annotations: { color: '#ef4444' },
|
|
68
|
+
actions: [
|
|
69
|
+
// Move cursor to element
|
|
70
|
+
{ type: 'move', target: { selector: '#button' }, duration: 800 },
|
|
71
|
+
|
|
72
|
+
// Click at current position
|
|
73
|
+
{ type: 'click' },
|
|
74
|
+
|
|
75
|
+
// Wait
|
|
76
|
+
{ type: 'wait', duration: 2000 },
|
|
77
|
+
|
|
78
|
+
// Show annotations
|
|
79
|
+
{
|
|
80
|
+
type: 'showAnnotations',
|
|
81
|
+
annotations: [
|
|
82
|
+
{ type: 'badge', target: { selector: '#step-1' }, number: 1 },
|
|
83
|
+
{ type: 'label', target: { selector: '#step-1' }, text: 'Start here', position: 'right' }
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
// Hide all annotations
|
|
88
|
+
{ type: 'hideAnnotations' },
|
|
89
|
+
|
|
90
|
+
// Change cursor appearance
|
|
91
|
+
{ type: 'setCursor', name: 'Done', color: '#22c55e' }
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Actions
|
|
97
|
+
|
|
98
|
+
| Action | Description | Properties |
|
|
99
|
+
|--------|-------------|------------|
|
|
100
|
+
| `move` | Move cursor to target | `target`, `duration?` (default 600ms) |
|
|
101
|
+
| `click` | Animate a click | `target?` (defaults to current position) |
|
|
102
|
+
| `wait` | Pause playback | `duration` (ms) |
|
|
103
|
+
| `showAnnotations` | Display annotations | `annotations[]` |
|
|
104
|
+
| `hideAnnotations` | Remove annotations | `ids?` (specific IDs, or all if omitted) |
|
|
105
|
+
| `setCursor` | Change cursor appearance | `visible?`, `name?`, `color?` |
|
|
106
|
+
|
|
107
|
+
### Targeting
|
|
108
|
+
|
|
109
|
+
Target elements using CSS selectors with optional anchor points:
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
// Basic selector
|
|
113
|
+
{ selector: '#my-element' }
|
|
114
|
+
|
|
115
|
+
// With anchor point
|
|
116
|
+
{ selector: '#my-element', anchor: 'top-right' }
|
|
117
|
+
|
|
118
|
+
// With offset
|
|
119
|
+
{ selector: '#my-element', anchor: 'center', offset: { x: 10, y: -5 } }
|
|
120
|
+
|
|
121
|
+
// Fallback coordinates if element not found
|
|
122
|
+
{ selector: '#my-element', fallback: { x: 100, y: 200 } }
|
|
123
|
+
|
|
124
|
+
// Absolute coordinates
|
|
125
|
+
{ x: 500, y: 300 }
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Anchor options: `center`, `top`, `bottom`, `left`, `right`, `top-left`, `top-right`, `bottom-left`, `bottom-right`
|
|
129
|
+
|
|
130
|
+
### Annotations
|
|
131
|
+
|
|
132
|
+
#### Badge
|
|
133
|
+
Numbered circle for step indicators:
|
|
134
|
+
```javascript
|
|
135
|
+
{ type: 'badge', target: { selector: '#step' }, number: 1, color: '#6366f1' }
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Label
|
|
139
|
+
Text callout with positioning:
|
|
140
|
+
```javascript
|
|
141
|
+
{
|
|
142
|
+
type: 'label',
|
|
143
|
+
target: { selector: '#element' },
|
|
144
|
+
text: 'Click here',
|
|
145
|
+
position: 'right', // top, bottom, left, right, top-left, top-right, bottom-left, bottom-right
|
|
146
|
+
gap: 8 // Distance from target in pixels
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Box
|
|
151
|
+
Highlight rectangle around element:
|
|
152
|
+
```javascript
|
|
153
|
+
{
|
|
154
|
+
type: 'box',
|
|
155
|
+
target: { selector: '#element' },
|
|
156
|
+
padding: 8, // Extra space around element
|
|
157
|
+
dashed: true // Dashed border style
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### Circle
|
|
162
|
+
Highlight ellipse around element:
|
|
163
|
+
```javascript
|
|
164
|
+
{ type: 'circle', target: { selector: '#element' }, padding: 12 }
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Arrow
|
|
168
|
+
Connecting line between two points:
|
|
169
|
+
```javascript
|
|
170
|
+
{
|
|
171
|
+
type: 'arrow',
|
|
172
|
+
from: { selector: '#start' },
|
|
173
|
+
to: { selector: '#end' }
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
All annotations support:
|
|
178
|
+
- `id` - Unique identifier for selective hiding
|
|
179
|
+
- `color` - Override default color
|
|
180
|
+
- `delay` - Milliseconds before appearing
|
|
181
|
+
- `duration` - Auto-hide after milliseconds (0 = permanent)
|
|
182
|
+
|
|
183
|
+
### Controller API
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
const overlay = createOverlay()
|
|
187
|
+
|
|
188
|
+
// Playback
|
|
189
|
+
await overlay.play(script) // Returns promise when complete
|
|
190
|
+
overlay.stop() // Stop playback
|
|
191
|
+
overlay.isPlaying // Current playback state
|
|
192
|
+
overlay.currentActionIndex // Current action (null if not playing)
|
|
193
|
+
|
|
194
|
+
// Validation
|
|
195
|
+
const result = overlay.validate(script)
|
|
196
|
+
// { valid: boolean, errors: string[], warnings: string[] }
|
|
197
|
+
|
|
198
|
+
// Events
|
|
199
|
+
const unsubscribe = overlay.on('start', () => {})
|
|
200
|
+
overlay.on('complete', () => {})
|
|
201
|
+
overlay.on('stop', () => {})
|
|
202
|
+
overlay.on('error', (error) => {})
|
|
203
|
+
overlay.on('action', (action, index, phase) => {})
|
|
204
|
+
|
|
205
|
+
// Direct cursor control
|
|
206
|
+
overlay.cursor.moveTo({ selector: '#target' }, { duration: 500 })
|
|
207
|
+
overlay.cursor.click()
|
|
208
|
+
overlay.cursor.show()
|
|
209
|
+
overlay.cursor.hide()
|
|
210
|
+
overlay.cursor.setName('Helper')
|
|
211
|
+
overlay.cursor.setColor('#22c55e')
|
|
212
|
+
overlay.cursor.position // { x, y } or null
|
|
213
|
+
overlay.cursor.isVisible
|
|
214
|
+
|
|
215
|
+
// Direct annotation control
|
|
216
|
+
const id = overlay.annotations.badge({ selector: '#el' }, 1)
|
|
217
|
+
overlay.annotations.label({ selector: '#el' }, 'Hello', { position: 'top' })
|
|
218
|
+
overlay.annotations.box({ selector: '#el' })
|
|
219
|
+
overlay.annotations.circle({ selector: '#el' })
|
|
220
|
+
overlay.annotations.arrow({ selector: '#from' }, { selector: '#to' })
|
|
221
|
+
overlay.annotations.hide(id)
|
|
222
|
+
overlay.annotations.hideAll()
|
|
223
|
+
overlay.annotations.activeIds // Currently visible annotation IDs
|
|
224
|
+
|
|
225
|
+
// Cleanup
|
|
226
|
+
overlay.destroy()
|
|
227
|
+
overlay.isDestroyed
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Error Handling
|
|
231
|
+
|
|
232
|
+
```javascript
|
|
233
|
+
overlay.on('error', (error) => {
|
|
234
|
+
console.log(error.code) // ELEMENT_NOT_FOUND, ANIMATION_FAILED, etc.
|
|
235
|
+
console.log(error.message) // Human-readable description
|
|
236
|
+
console.log(error.action) // The action that failed
|
|
237
|
+
console.log(error.target) // The target that couldn't be resolved
|
|
238
|
+
})
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Error codes:
|
|
242
|
+
- `ELEMENT_NOT_FOUND` - CSS selector matched no elements
|
|
243
|
+
- `ANIMATION_FAILED` - Animation couldn't complete
|
|
244
|
+
- `SCROLL_FAILED` - Couldn't scroll element into view
|
|
245
|
+
- `INVALID_SCRIPT` - Script failed validation
|
|
246
|
+
- `INVALID_TARGET` - Target specification is malformed
|
|
247
|
+
- `TIMEOUT` - Operation exceeded time limit
|
|
248
|
+
|
|
249
|
+
## Feedback Widget
|
|
250
|
+
|
|
251
|
+
The feedback widget displays a development-only feedback form.
|
|
252
|
+
|
|
253
|
+
```javascript
|
|
254
|
+
import { init, destroy } from '@ourroadmaps/web-sdk'
|
|
255
|
+
|
|
256
|
+
// Initialize (only renders in development mode)
|
|
257
|
+
init({ apiKey: 'your_api_key' })
|
|
258
|
+
|
|
259
|
+
// Remove widget
|
|
260
|
+
destroy()
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
The widget only renders when:
|
|
264
|
+
- `NODE_ENV !== 'production'`
|
|
265
|
+
- Running on `localhost` or `127.0.0.1`
|
|
266
|
+
|
|
267
|
+
## Module Imports
|
|
268
|
+
|
|
269
|
+
```javascript
|
|
270
|
+
// Everything from main entry
|
|
271
|
+
import { createOverlay, init, destroy } from '@ourroadmaps/web-sdk'
|
|
272
|
+
|
|
273
|
+
// Just overlay
|
|
274
|
+
import { createOverlay } from '@ourroadmaps/web-sdk/overlay'
|
|
275
|
+
|
|
276
|
+
// Just feedback
|
|
277
|
+
import { init, destroy } from '@ourroadmaps/web-sdk/feedback'
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## CDN URLs
|
|
281
|
+
|
|
282
|
+
```html
|
|
283
|
+
<!-- Latest version (for prototypes) -->
|
|
284
|
+
<script src="https://unpkg.com/@ourroadmaps/web-sdk"></script>
|
|
285
|
+
|
|
286
|
+
<!-- Pinned version (for production) -->
|
|
287
|
+
<script src="https://unpkg.com/@ourroadmaps/web-sdk@0.3.0"></script>
|
|
288
|
+
|
|
289
|
+
<!-- Alternative: jsDelivr -->
|
|
290
|
+
<script src="https://cdn.jsdelivr.net/npm/@ourroadmaps/web-sdk"></script>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
The CDN build exposes `window.OurRoadmaps` with:
|
|
294
|
+
- `createOverlay()` - Create overlay instance
|
|
295
|
+
- `init()` - Initialize feedback widget
|
|
296
|
+
- `destroy()` - Remove feedback widget
|
|
297
|
+
|
|
298
|
+
## TypeScript
|
|
299
|
+
|
|
300
|
+
Full type definitions included. Import types directly:
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
import type {
|
|
304
|
+
OverlayScript,
|
|
305
|
+
OverlayController,
|
|
306
|
+
Action,
|
|
307
|
+
Annotation,
|
|
308
|
+
Target
|
|
309
|
+
} from '@ourroadmaps/web-sdk'
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## License
|
|
313
|
+
|
|
314
|
+
Proprietary - OurRoadmaps
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
|
|
7
|
+
exports.__publicField = __publicField;
|
|
8
|
+
//# sourceMappingURL=chunk-4DE2IREA.cjs.map
|
|
9
|
+
//# sourceMappingURL=chunk-4DE2IREA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-4DE2IREA.cjs"}
|