@bokijonovm/cursorcrew 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +129 -2
- package/dist/chunk-HQWPI64P.js +815 -0
- package/dist/chunk-HQWPI64P.js.map +1 -0
- package/dist/cursorcrew.global.js +27 -0
- package/dist/cursorcrew.global.js.map +1 -0
- package/dist/index.cjs +842 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +124 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +869 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +20 -0
- package/dist/react.d.ts +20 -0
- package/dist/react.js +38 -0
- package/dist/react.js.map +1 -0
- package/package.json +88 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Muhsinjon Bokijonov
|
|
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,3 +1,130 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cursorcrew
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Your page, built live by a crew of multiplayer cursors.
|
|
6
|
+
|
|
7
|
+
Point it at any element. It blanks the content, then a crew of named cursors draws every box, types every line and drops in every image until the real page is back. Zero dependencies, about 8 KB gzipped.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @bokijonovm/cursorcrew
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { assemble } from '@bokijonovm/cursorcrew';
|
|
17
|
+
|
|
18
|
+
const crew = assemble('#app', {
|
|
19
|
+
agents: 5,
|
|
20
|
+
duration: 8,
|
|
21
|
+
trigger: 'viewport',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await crew.finished;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
To avoid a flash of the finished page before the script runs, mark the target as pending and hide it in your CSS:
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<style>[data-assemble-pending]{visibility:hidden}</style>
|
|
31
|
+
<main id="app" data-assemble-pending>…</main>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### React
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
37
|
+
import { Assemble } from '@bokijonovm/cursorcrew/react';
|
|
38
|
+
|
|
39
|
+
export default function Hero() {
|
|
40
|
+
return (
|
|
41
|
+
<Assemble as="section" options={{ agents: 4 }}>
|
|
42
|
+
<h1>Hello world</h1>
|
|
43
|
+
</Assemble>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
There is also a hook, `useAssemble(ref, options)`, which returns a ref holding the crew. Options are read on mount; change the component's `key` to rebuild with new ones. The React entry is marked `"use client"`, so it works in Next.js App Router.
|
|
49
|
+
|
|
50
|
+
### CDN
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<script src="https://cdn.jsdelivr.net/npm/@bokijonovm/cursorcrew@0.1.0/dist/cursorcrew.global.js"></script>
|
|
54
|
+
<script>
|
|
55
|
+
CursorCrew.assemble('#app');
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Options
|
|
60
|
+
|
|
61
|
+
| Option | Default | What it changes |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `agents` | `5` | How many cursors (1–24), or a list of `{ name, color }` |
|
|
64
|
+
| `duration` | natural | Fit the whole build into this many seconds |
|
|
65
|
+
| `speed` | `1` | Playback speed when `duration` is not set |
|
|
66
|
+
| `trigger` | `'immediate'` | `'viewport'` waits until the target scrolls into view |
|
|
67
|
+
| `autoplay` | `true` | Set `false` and call `crew.play()` yourself |
|
|
68
|
+
| `typing` | `'auto'` | `'char'`, `'word'`, or `'auto'` (letters for short text, words for long) |
|
|
69
|
+
| `maxTasks` | `250` | Cap on animated pieces; the smallest nested ones merge into their parent |
|
|
70
|
+
| `cleanup` | `true` | Remove the overlay and restore inline styles when done |
|
|
71
|
+
| `labels` | `true` | Show cursor name tags |
|
|
72
|
+
| `actions` | `true` | Show what each cursor is doing next to its name |
|
|
73
|
+
| `zIndex` | `2147483000` | z-index of the overlay |
|
|
74
|
+
| `reducedMotion` | `'respect'` | `'respect'` skips the animation for `prefers-reduced-motion`; `'ignore'` always plays |
|
|
75
|
+
| `onStart`, `onProgress(p)`, `onComplete` | | Lifecycle callbacks; `p` goes from 0 to 1 |
|
|
76
|
+
|
|
77
|
+
### Attributes
|
|
78
|
+
|
|
79
|
+
| Attribute | Effect |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `data-assemble="skip"` | Leave this element and its children alone |
|
|
82
|
+
| `data-assemble="block"` | Reveal this element as one piece instead of building its insides |
|
|
83
|
+
| `data-assemble-pending` | Hidden until the crew starts (add the CSS rule above) |
|
|
84
|
+
|
|
85
|
+
## The crew object
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
interface Crew {
|
|
89
|
+
timeline: Timeline; // play(), pause(), progress(), timeScale(), duration()
|
|
90
|
+
finished: Promise<void>; // resolves when the build ends or is destroyed
|
|
91
|
+
play(): void;
|
|
92
|
+
pause(): void;
|
|
93
|
+
finish(): void; // jump to the end
|
|
94
|
+
replay(): void; // reset and build again
|
|
95
|
+
destroy(): void; // stop and restore the element as it was
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## How it works
|
|
100
|
+
|
|
101
|
+
1. **Scan.** The target is walked once. Anything that paints a surface (fill, border, shadow) becomes a box; text becomes a typing task; images, SVG, video and canvas become media.
|
|
102
|
+
2. **Schedule.** The cursor that is free soonest takes the nearby task it can start earliest. Children wait for their parent box, so work spreads across the page in reading order.
|
|
103
|
+
3. **Play.** A small built-in timeline drives everything with `requestAnimationFrame`. Cursors and boxes move with `translate3d`, so they stay on the GPU. When a tab stalls, playback resumes where it was instead of jumping ahead.
|
|
104
|
+
4. **Restore.** When the build finishes, inline styles and text nodes go back exactly as they were.
|
|
105
|
+
|
|
106
|
+
## Browser support
|
|
107
|
+
|
|
108
|
+
All evergreen browsers. Draw-box tints use `color-mix()` (Chrome 111, Safari 16.2, Firefox 113). Text is split by grapheme with `Intl.Segmenter` where available, so emoji type as one character.
|
|
109
|
+
|
|
110
|
+
## Development
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm install
|
|
114
|
+
npm test # vitest + jsdom
|
|
115
|
+
npm run build # dist/: ESM, CJS, types, and the CDN bundle
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Open `demo/index.html` after building to see the full demo.
|
|
119
|
+
|
|
120
|
+
### Releasing
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm version patch # or minor / major
|
|
124
|
+
npm publish # runs typecheck, tests, build and package checks first
|
|
125
|
+
git push --follow-tags
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT © Muhsinjon Bokijonov
|