@crup/react-timer-hook 0.0.1-alpha.6 โ†’ 0.0.1-alpha.7

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.
Files changed (2) hide show
  1. package/README.md +42 -63
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @crup/react-timer-hook
2
2
 
3
- > Deterministic React timer primitives for countdowns, stopwatches, clocks, schedules, and many independent timers.
3
+ > Reliable React timer hooks for countdowns, stopwatches, clocks, polling schedules, and many independent timer lifecycles.
4
4
 
5
5
  [![npm alpha](https://img.shields.io/npm/v/%40crup%2Freact-timer-hook/alpha?label=npm%20alpha&color=00b894)](https://www.npmjs.com/package/@crup/react-timer-hook?activeTab=versions)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/%40crup%2Freact-timer-hook?color=0f766e)](https://www.npmjs.com/package/@crup/react-timer-hook)
@@ -8,44 +8,45 @@
8
8
  [![Docs](https://github.com/crup/react-timer-hook/actions/workflows/docs.yml/badge.svg)](https://github.com/crup/react-timer-hook/actions/workflows/docs.yml)
9
9
  [![Size](https://github.com/crup/react-timer-hook/actions/workflows/size.yml/badge.svg)](https://github.com/crup/react-timer-hook/actions/workflows/size.yml)
10
10
  [![license](https://img.shields.io/npm/l/%40crup%2Freact-timer-hook?color=111827)](./LICENSE)
11
- [![types](https://img.shields.io/npm/types/%40crup%2Freact-timer-hook?color=2563eb)](./dist/index.d.ts)
11
+ [![types](https://img.shields.io/npm/types/%40crup%2Freact-timer-hook?color=2563eb)](https://www.npmjs.com/package/@crup/react-timer-hook)
12
+ [![React](https://img.shields.io/npm/dependency-version/%40crup%2Freact-timer-hook/peer/react?label=react&color=149eca)](https://react.dev/)
12
13
 
13
- ๐Ÿ“š Docs: https://crup.github.io/react-timer-hook/
14
+ ๐Ÿ“š Docs and live examples: https://crup.github.io/react-timer-hook/
14
15
 
15
- ## Docs and live examples
16
+ ## Why this exists
16
17
 
17
- The documentation site is built with Docusaurus and includes live React playgrounds for 15 recipes:
18
+ Timer hooks look simple until real apps need pause/resume semantics, Strict Mode cleanup, async callbacks, polling that does not overlap, and lists with dozens of independent timers.
18
19
 
19
- - Basic: clock, stopwatch, absolute countdown, pausable countdown, manual controls
20
- - Intermediate: once-only `onEnd`, polling, poll-and-cancel, backend events, debug logs
21
- - Advanced: many display timers, timer groups, global controls, per-item polling, dynamic items
20
+ `@crup/react-timer-hook` keeps the API small and lets your app decide what time means:
22
21
 
23
- Open: https://crup.github.io/react-timer-hook/
24
-
25
- ## Why it is different
26
-
27
- Most timer libraries mix scheduling, lifecycle, formatting, and app behavior. This package keeps the core small:
28
-
29
- - โฑ๏ธ `useTimer()` for one lifecycle.
22
+ - โฑ๏ธ `useTimer()` for one lifecycle: stopwatch, countdown, clock, schedule, or custom flow.
30
23
  - ๐Ÿงญ `useTimerGroup()` for many keyed lifecycles with one shared scheduler.
31
- - ๐Ÿงฉ `durationParts()` for display-friendly duration math.
32
- - ๐Ÿงผ No timezone, locale, or formatting opinions.
33
- - ๐Ÿงช Built around React Strict Mode, rerenders, async callbacks, and cleanup.
34
- - ๐Ÿค– AI-friendly docs via `llms.txt`, `llms-full.txt`, and a tiny local MCP docs utility.
24
+ - ๐Ÿงฉ `durationParts()` for display math without locale or timezone opinions.
25
+ - ๐Ÿงผ No formatting, timezone, audio, retry, cache, or data-fetching policy baked in.
26
+ - ๐Ÿงช Built for rerenders, Strict Mode, async callbacks, cleanup, and many timers.
27
+ - ๐Ÿค– Agent-friendly docs through hosted `llms.txt`, `llms-full.txt`, and an optional MCP docs helper.
35
28
 
36
29
  ## Install
37
30
 
38
- Alpha is the only intended release channel until stable publishing is explicitly unlocked.
31
+ The project is currently in alpha while the API receives feedback.
39
32
 
40
33
  ```sh
41
34
  npm install @crup/react-timer-hook@alpha
42
35
  pnpm add @crup/react-timer-hook@alpha
43
36
  ```
44
37
 
45
- ```ts
38
+ ```tsx
46
39
  import { durationParts, useTimer, useTimerGroup } from '@crup/react-timer-hook';
47
40
  ```
48
41
 
42
+ ## Live recipes
43
+
44
+ Each recipe has a live playground and a focused code sample:
45
+
46
+ - Basic: [wall clock](https://crup.github.io/react-timer-hook/recipes/basic/wall-clock/), [stopwatch](https://crup.github.io/react-timer-hook/recipes/basic/stopwatch/), [absolute countdown](https://crup.github.io/react-timer-hook/recipes/basic/absolute-countdown/), [pausable countdown](https://crup.github.io/react-timer-hook/recipes/basic/pausable-countdown/), [manual controls](https://crup.github.io/react-timer-hook/recipes/basic/manual-controls/)
47
+ - Intermediate: [once-only onEnd](https://crup.github.io/react-timer-hook/recipes/intermediate/once-only-on-end/), [polling schedule](https://crup.github.io/react-timer-hook/recipes/intermediate/polling-schedule/), [poll and cancel](https://crup.github.io/react-timer-hook/recipes/intermediate/poll-and-cancel/), [backend event stop](https://crup.github.io/react-timer-hook/recipes/intermediate/backend-event-stop/), [debug logs](https://crup.github.io/react-timer-hook/recipes/intermediate/debug-logs/)
48
+ - Advanced: [many display countdowns](https://crup.github.io/react-timer-hook/recipes/advanced/many-display-countdowns/), [timer group](https://crup.github.io/react-timer-hook/recipes/advanced/timer-group/), [group controls](https://crup.github.io/react-timer-hook/recipes/advanced/group-controls/), [per-item polling](https://crup.github.io/react-timer-hook/recipes/advanced/per-item-polling/), [dynamic items](https://crup.github.io/react-timer-hook/recipes/advanced/dynamic-items/)
49
+
49
50
  ## Quick examples
50
51
 
51
52
  ### Stopwatch
@@ -58,17 +59,17 @@ export function Stopwatch() {
58
59
 
59
60
  return (
60
61
  <>
61
- <output>{Math.floor(timer.elapsedMilliseconds / 1000)}s</output>
62
- <button onClick={timer.start}>Start</button>
63
- <button onClick={timer.pause}>Pause</button>
64
- <button onClick={timer.resume}>Resume</button>
62
+ <output>{(timer.elapsedMilliseconds / 1000).toFixed(1)}s</output>
63
+ <button disabled={!timer.isIdle} onClick={timer.start}>Start</button>
64
+ <button disabled={!timer.isRunning} onClick={timer.pause}>Pause</button>
65
+ <button disabled={!timer.isPaused} onClick={timer.resume}>Resume</button>
65
66
  <button onClick={timer.restart}>Restart</button>
66
67
  </>
67
68
  );
68
69
  }
69
70
  ```
70
71
 
71
- ### Absolute countdown
72
+ ### Auction countdown
72
73
 
73
74
  Use `now` for wall-clock deadlines from a server, auction, reservation, or job expiry.
74
75
 
@@ -93,7 +94,7 @@ export function AuctionTimer({ auctionId, expiresAt }: {
93
94
  }
94
95
  ```
95
96
 
96
- ### Polling with early cancel
97
+ ### Poll and cancel early
97
98
 
98
99
  Schedules run while the timer is active. Slow async work is skipped by default with `overlap: 'skip'`.
99
100
 
@@ -134,7 +135,7 @@ const timers = useTimerGroup({
134
135
 
135
136
  ## Bundle size
136
137
 
137
- Current local build:
138
+ Current build:
138
139
 
139
140
  | File | Raw | Gzip | Brotli |
140
141
  | --- | ---: | ---: | ---: |
@@ -142,21 +143,16 @@ Current local build:
142
143
  | `dist/index.cjs` | 12.94 kB | 3.79 kB | 3.42 kB |
143
144
  | `dist/index.d.ts` | 3.95 kB | 992 B | 888 B |
144
145
 
145
- CI writes a size summary to the GitHub Actions UI and posts a bundle-size comment on pull requests.
146
+ CI writes a size summary to the GitHub Actions UI and posts bundle-size reports on pull requests.
146
147
 
147
- ## AI-friendly
148
+ ## AI-friendly docs
148
149
 
149
- End users do not need these files. They are for coding agents, docs-aware IDEs, and MCP clients.
150
+ Agents and docs-aware IDEs can use:
150
151
 
151
- ### MCP setup
152
+ - https://crup.github.io/react-timer-hook/llms.txt
153
+ - https://crup.github.io/react-timer-hook/llms-full.txt
152
154
 
153
- Clone the repo, install dependencies, and point your MCP client at the local stdio server:
154
-
155
- ```sh
156
- git clone https://github.com/crup/react-timer-hook.git
157
- cd react-timer-hook
158
- pnpm install
159
- ```
155
+ Optional local MCP docs server:
160
156
 
161
157
  ```json
162
158
  {
@@ -169,7 +165,7 @@ pnpm install
169
165
  }
170
166
  ```
171
167
 
172
- The MCP server exposes:
168
+ It exposes:
173
169
 
174
170
  ```txt
175
171
  react-timer-hook://package
@@ -177,29 +173,12 @@ react-timer-hook://api
177
173
  react-timer-hook://recipes
178
174
  ```
179
175
 
180
- Agents can use hosted context:
181
-
182
- - https://crup.github.io/react-timer-hook/llms.txt
183
- - https://crup.github.io/react-timer-hook/llms-full.txt
184
-
185
- Local MCP/docs helpers:
186
-
187
- ```sh
188
- pnpm ai:context
189
- pnpm mcp:docs
190
- ```
191
-
192
- The MCP utility is repo-local and excluded from the published npm package.
193
-
194
- ## Release policy
176
+ ## Contributing
195
177
 
196
- - Published versions must stay `0.0.1-alpha.x` until stable release is explicitly unlocked.
197
- - `@alpha` is the documented install tag right now.
198
- - Npm requires a `latest` dist-tag, so the workflow keeps `latest` pointing at the current alpha until stable publishing is unlocked.
178
+ Issues, recipes, docs improvements, and focused bug reports are welcome.
199
179
 
200
- ## Links
180
+ - Read the docs: https://crup.github.io/react-timer-hook/
181
+ - Open an issue: https://github.com/crup/react-timer-hook/issues
182
+ - See the contributing guide: ./CONTRIBUTING.md
201
183
 
202
- - ๐Ÿ“š Docs: https://crup.github.io/react-timer-hook/
203
- - ๐Ÿ“ฆ npm: https://www.npmjs.com/package/@crup/react-timer-hook
204
- - ๐Ÿงต Issues: https://github.com/crup/react-timer-hook/issues
205
- - ๐Ÿค Contributing: ./CONTRIBUTING.md
184
+ The package targets Node 24 for development and React 18+ as a peer dependency.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crup/react-timer-hook",
3
- "version": "0.0.1-alpha.6",
4
- "description": "Deterministic React timer lifecycle hooks for timers, schedules, and many independent timers.",
3
+ "version": "0.0.1-alpha.7",
4
+ "description": "Reliable React timer lifecycle hooks for countdowns, stopwatches, schedules, and many independent timers.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",