Skip to content

Commit aa10620

Browse files
committed
feat: init
0 parents  commit aa10620

14 files changed

Lines changed: 3925 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v6
12+
- uses: actions/setup-node@v6
13+
with:
14+
node-version: 24
15+
cache: npm
16+
- run: npm i
17+
- run: npm test

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
.DS_Store
3+
npm-debug.log*
4+
5+
# llm
6+
AGENTS.md
7+
.claude/

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[![test][test-badge]][test]
2+
3+
# pointerdriver
4+
5+
> Synthesizes and dispatches events.
6+
> Mimics the event stream as if it were executed
7+
> by an actual human driving the interaction.
8+
9+
```sh
10+
npm i github:TheProfs/pointerdriver
11+
```
12+
13+
## Usage
14+
15+
```js
16+
import { PointerDriver } from 'pointerdriver'
17+
18+
const driver = new PointerDriver('#el')
19+
20+
// Pencil
21+
await driver.stroke([[30, 50, 0], [60, 80, 16]]) // pen drag
22+
23+
// Mouse
24+
await driver.drag([[30, 50, 0], [60, 80, 16]]) // mouse drag
25+
26+
// Touch
27+
await driver.glide([[
28+
30, 50, 0], [60, 80, 16]
29+
]]) // one-finger drag
30+
await driver.pinch(2) // two-finger pinch
31+
await driver.swipe(80, 0) // two-finger swipe
32+
await driver.twist() // two-finger twist
33+
```
34+
35+
### Text strokes
36+
37+
`stroke()` accepts a string,
38+
but you must provide an SVG font URL in the constructor.
39+
40+
```js
41+
const driver = new PointerDriver('#el', {
42+
font: 'http://127.0.0.1:5619/fonts/EMS_Elfin_Smooth.svg',
43+
})
44+
45+
await driver.stroke('Hello', { fontSize: 48 })
46+
```
47+
48+
## Server
49+
50+
Run a local static server:
51+
52+
```bash
53+
npx github:TheProfs/pointerdriver
54+
```
55+
56+
Open `http://127.0.0.1:5619/`.
57+
58+
## Test
59+
60+
```bash
61+
npm test
62+
```
63+
64+
## License
65+
66+
MIT
67+
68+
[test-badge]: https://github.com/TheProfs/pointerdriver/actions/workflows/test.yml/badge.svg
69+
[test]: https://github.com/TheProfs/pointerdriver/actions/workflows/test.yml

bin/pointerdriver.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env node
2+
import { spawn } from 'node:child_process'
3+
import { resolve } from 'node:path'
4+
import { fileURLToPath } from 'node:url'
5+
6+
const here = fileURLToPath(new URL('.', import.meta.url))
7+
const root = resolve(here, '..')
8+
9+
const host = '127.0.0.1'
10+
const port = 5619
11+
12+
const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx'
13+
14+
const args = [
15+
'--yes',
16+
'serve',
17+
'--listen',
18+
`tcp://${host}:${port}`,
19+
'--cors',
20+
root,
21+
]
22+
23+
const child = spawn(npx, args, { stdio: 'inherit' })
24+
25+
const exit = code =>
26+
process.exit(typeof code === 'number' ? code : 1)
27+
28+
process.on('SIGINT', () => child.kill('SIGINT'))
29+
process.on('SIGTERM', () => child.kill('SIGTERM'))
30+
31+
child.on('error', err => {
32+
console.error(err?.message ?? String(err))
33+
exit(1)
34+
})
35+
36+
child.on('exit', (code, signal) => {
37+
if (signal) exit(1)
38+
exit(code)
39+
})

fonts/EMS_Elfin_Smooth.svg

Lines changed: 187 additions & 0 deletions
Loading

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { PointerDriver } from './src/driver.js'

0 commit comments

Comments
 (0)