@meeeetup/camera-web 0.7.0 → 0.8.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 +116 -9
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/react/context/MeeeetUpCamProvider.d.ts +30 -10
- package/dist/react/context/MeeeetUpCamProvider.d.ts.map +1 -1
- package/dist/react/context/MeeeetUpCamProvider.js +14 -7
- package/dist/react/context/MeeeetUpCamProvider.js.map +1 -1
- package/dist/react/useAutoUpload.d.ts +17 -0
- package/dist/react/useAutoUpload.d.ts.map +1 -0
- package/dist/react/useAutoUpload.js +46 -0
- package/dist/react/useAutoUpload.js.map +1 -0
- package/llms.txt +15 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@ Browser face-capture SDK for the Meeeetup face-ID service. Detects faces with
|
|
|
4
4
|
MediaPipe BlazeFace, tracks them, picks the best-quality frame per person, and
|
|
5
5
|
hands you the images through a callback.
|
|
6
6
|
|
|
7
|
-
**Transport is yours
|
|
8
|
-
credential: it calls `onBatchCapture` (passive) or
|
|
9
|
-
with base64 JPEG data URLs, and sending them
|
|
7
|
+
**Transport is yours by default.** Without `autoUpload` the SDK makes no
|
|
8
|
+
network request and holds no credential: it calls `onBatchCapture` (passive) or
|
|
9
|
+
`onCapture` (single, interactive) with base64 JPEG data URLs, and sending them
|
|
10
|
+
is your code. Pass the opt-in `autoUpload` prop and the SDK posts the captures
|
|
11
|
+
itself — see [Auto-upload](#auto-upload--opt-in-transport).
|
|
10
12
|
|
|
11
13
|
Requires React 18 or 19. ESM-only. Served over HTTPS or `localhost` —
|
|
12
14
|
`getUserMedia` is a secure-context API.
|
|
@@ -27,7 +29,8 @@ import "@meeeetup/camera-web/styles.css";
|
|
|
27
29
|
|
|
28
30
|
## Passive capture — continuous, batched
|
|
29
31
|
|
|
30
|
-
Faces are flushed to `onBatchCapture`
|
|
32
|
+
Faces are flushed every 10 s — to `onBatchCapture` as below, or straight to the
|
|
33
|
+
SDK's own uploader if you set `autoUpload`.
|
|
31
34
|
|
|
32
35
|
```tsx
|
|
33
36
|
import {
|
|
@@ -96,6 +99,104 @@ export function KioskCamera() {
|
|
|
96
99
|
}
|
|
97
100
|
```
|
|
98
101
|
|
|
102
|
+
## Auto-upload — opt-in transport
|
|
103
|
+
|
|
104
|
+
`autoUpload` is accepted by `MeeeetUpCamProvider` in all three modes
|
|
105
|
+
(`passive`, `single`, `interactive`) and makes the SDK post captures itself.
|
|
106
|
+
Omit it and no capture ever leaves the device — your callback stays the only
|
|
107
|
+
output path. With it, a passive camera needs no transport code at all:
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import {
|
|
111
|
+
MeeeetUpCamProvider,
|
|
112
|
+
CameraViewport,
|
|
113
|
+
FaceCounter,
|
|
114
|
+
FaceGrid,
|
|
115
|
+
} from "@meeeetup/camera-web";
|
|
116
|
+
|
|
117
|
+
export function PassiveCamera({ captureKey }: { captureKey: string }) {
|
|
118
|
+
return (
|
|
119
|
+
<MeeeetUpCamProvider mode="passive" autoUpload={{ captureKey }}>
|
|
120
|
+
<CameraViewport />
|
|
121
|
+
<FaceCounter />
|
|
122
|
+
<FaceGrid />
|
|
123
|
+
</MeeeetUpCamProvider>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Each flush becomes `POST https://api.meeeetup.com/capture` with headers
|
|
129
|
+
`Authorization: Bearer <captureKey>` and `Content-Type: application/json`, and
|
|
130
|
+
a body of `{ images: [{ image, capturedAt }], channelId? }` — the `POST
|
|
131
|
+
/capture` contract of the Meeeetup face-ID API. `capturedAt` is each face's
|
|
132
|
+
`createdAt` as an ISO-8601 string.
|
|
133
|
+
|
|
134
|
+
### `AutoUploadOptions`
|
|
135
|
+
|
|
136
|
+
| Field | Type | Default |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `captureKey` | `string` | required — sent as `Authorization: Bearer <captureKey>` |
|
|
139
|
+
| `endpoint` | `string` | `DEFAULT_CAPTURE_ENDPOINT` (`https://api.meeeetup.com/capture`) |
|
|
140
|
+
| `channelId` | `string` | unset — omitted from the body entirely, not sent empty |
|
|
141
|
+
| `maxRetries` | `number` | `2` — extra attempts after a transient failure |
|
|
142
|
+
| `retryDelayMs` | `number` | `1000` — base backoff, doubled each attempt |
|
|
143
|
+
| `fetch` | `CaptureFetch` | the global `fetch` — override for tests or a proxy |
|
|
144
|
+
| `onUploaded` | `(result: AutoUploadResult) => void` | — fires per accepted request with `{ count, status, attempts }` |
|
|
145
|
+
| `onError` | `(error: unknown) => void` | — fires once per upload that exhausted its attempts |
|
|
146
|
+
|
|
147
|
+
### Capture callbacks become observers
|
|
148
|
+
|
|
149
|
+
With `autoUpload` set, `onBatchCapture` / `onCapture` are optional and purely
|
|
150
|
+
observational — a counter, a preview, analytics. They are fired without being
|
|
151
|
+
awaited, so they can neither delay nor fail the upload, and anything they throw
|
|
152
|
+
surfaces on `autoUpload.onError` rather than in the capture pipeline. Without
|
|
153
|
+
`autoUpload` they are the only output path and behave as before: a rejection
|
|
154
|
+
requeues the batch.
|
|
155
|
+
|
|
156
|
+
In single and interactive mode only the face crop is uploaded.
|
|
157
|
+
`fullCircleImage` is framing for your own UI and never leaves the device.
|
|
158
|
+
|
|
159
|
+
### Retries and failures
|
|
160
|
+
|
|
161
|
+
5xx, 429, 408 and transport-level failures are retried up to `maxRetries`, each
|
|
162
|
+
attempt resending a byte-identical payload after
|
|
163
|
+
`retryDelayMs * 2 ** (attempt - 1)` ms. Any other 4xx fails immediately — the
|
|
164
|
+
server rejected that payload, and resending it unchanged would livelock.
|
|
165
|
+
|
|
166
|
+
Once the attempts are spent the uploader throws `CaptureUploadError`:
|
|
167
|
+
|
|
168
|
+
| Field | Meaning |
|
|
169
|
+
|---|---|
|
|
170
|
+
| `status` | HTTP status; absent when the request never completed |
|
|
171
|
+
| `retryable` | `true` for 408 / 429 / 5xx / transport failure, `false` for any other 4xx |
|
|
172
|
+
| `attempts` | attempts spent before giving up |
|
|
173
|
+
| `cause` | the underlying transport error, when there was one |
|
|
174
|
+
|
|
175
|
+
The passive session reads that flag: a retryable batch is requeued and retried
|
|
176
|
+
on a later flush, a non-retryable one is dropped. Batches reach the uploader
|
|
177
|
+
already chunked to 50 images (`maxFacesPerRequest`), which must not exceed the
|
|
178
|
+
key's `maxImagesPerRequest` from `GET /capture/keys/me`.
|
|
179
|
+
|
|
180
|
+
### Driving the low-level hooks
|
|
181
|
+
|
|
182
|
+
`createAutoUploader`, `CaptureUploadError`, `DEFAULT_CAPTURE_ENDPOINT` and the
|
|
183
|
+
`AutoUpload*` / `Capture*` types are re-exported from this package, so code
|
|
184
|
+
driving the low-level hooks (`usePassiveCamera`, `useSingleCapture`) instead of
|
|
185
|
+
the provider gets the same transport. `uploadFaces` takes `SelectedFace[]` from
|
|
186
|
+
a passive batch; `uploadImages` takes the single-shot data URLs.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { createAutoUploader, useSingleCapture } from "@meeeetup/camera-web";
|
|
190
|
+
|
|
191
|
+
const uploader = createAutoUploader({ captureKey });
|
|
192
|
+
const cam = useSingleCapture({
|
|
193
|
+
onCapture: (faceImage) =>
|
|
194
|
+
uploader.uploadImages([
|
|
195
|
+
{ image: faceImage, capturedAt: new Date().toISOString() },
|
|
196
|
+
]),
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
99
200
|
## Custom UI
|
|
100
201
|
|
|
101
202
|
`useMeeeetUpCam()` exposes everything the built-in components render. Narrow on
|
|
@@ -130,13 +231,14 @@ any ancestor.
|
|
|
130
231
|
|
|
131
232
|
## Provider props
|
|
132
233
|
|
|
133
|
-
|
|
134
|
-
(`cooldownMs` and the three below) are passive-only.
|
|
234
|
+
Every mode accepts `children`, `mediapipeWasmUrl` and `autoUpload`; the capture
|
|
235
|
+
gates (`cooldownMs` and the three below) are passive-only.
|
|
135
236
|
|
|
136
237
|
| Prop | Mode | Type | Default |
|
|
137
238
|
|---|---|---|---|
|
|
138
|
-
| `
|
|
139
|
-
| `
|
|
239
|
+
| `autoUpload` | all | `AutoUploadOptions` | unset — opt in and the SDK posts captures itself |
|
|
240
|
+
| `onBatchCapture` | passive | `(faces: SelectedFace[]) => void \| Promise<void>` | required without `autoUpload`; an optional observer with it |
|
|
241
|
+
| `onCapture` | interactive | `(faceImage: string, fullCircleImage: string) => void \| Promise<void>` | required without `autoUpload`; an optional observer with it |
|
|
140
242
|
| `cooldownMs` | passive | `number` | `10000` — minimum ms between sends for the same face |
|
|
141
243
|
| `mediapipeWasmUrl` | passive | `string` | jsDelivr CDN — point it at a self-hosted WASM directory |
|
|
142
244
|
| `alignmentCaptureDelayMs` | interactive | `number` | `2000` — how long a face must stay aligned before auto-capture |
|
|
@@ -156,7 +258,12 @@ MediaPipe assets are fetched on demand, so the browser must reach:
|
|
|
156
258
|
- `https://cdn.jsdelivr.net` — WASM runtime (override with `mediapipeWasmUrl`)
|
|
157
259
|
- `https://storage.googleapis.com` — the `.tflite` detection model
|
|
158
260
|
|
|
159
|
-
|
|
261
|
+
With `autoUpload` set, and only then, the browser also posts to:
|
|
262
|
+
|
|
263
|
+
- `https://api.meeeetup.com` — capture ingest (override with `autoUpload.endpoint`)
|
|
264
|
+
|
|
265
|
+
A strict CSP needs the asset origins in `connect-src`, plus `script-src
|
|
266
|
+
'wasm-unsafe-eval'`; add the capture origin when you use `autoUpload`.
|
|
160
267
|
|
|
161
268
|
## Licence
|
|
162
269
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type { SelectedFace, LiveFacePreview, PersonResult } from "@meeeetup/camera-core";
|
|
2
|
+
export { createAutoUploader, CaptureUploadError, DEFAULT_CAPTURE_ENDPOINT } from "@meeeetup/camera-core";
|
|
3
|
+
export type { AutoUploader, AutoUploadOptions, AutoUploadResult, CaptureFetch, CaptureImage, } from "@meeeetup/camera-core";
|
|
2
4
|
export { MeeeetUpCamProvider } from "./react/context/MeeeetUpCamProvider.js";
|
|
3
|
-
export type { MeeeetUpCamProviderProps, PassiveCaptureOnlyMeeeetUpCamProviderProps, InteractiveMeeeetUpCamProviderProps, SingleCaptureMeeeetUpCamProviderProps, } from "./react/context/MeeeetUpCamProvider.js";
|
|
5
|
+
export type { MeeeetUpCamProviderProps, PassiveCaptureOnlyMeeeetUpCamProviderProps, InteractiveMeeeetUpCamProviderProps, SingleCaptureMeeeetUpCamProviderProps, SingleCaptureMeta, } from "./react/context/MeeeetUpCamProvider.js";
|
|
4
6
|
export { useMeeeetUpCam } from "./react/context/useMeeeetUpCam.js";
|
|
5
7
|
export type { MeeeetUpCamContextValue, CameraMode, PassiveState, InteractiveState, SingleState } from "./react/context/MeeeetUpCamContext.js";
|
|
6
8
|
export { useSingleCapture, MIN_SCORE_FLOOR, MIN_WINDOW_MS, MAX_WINDOW_MS } from "./react/useSingleCapture.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAMzF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACzG,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAS,wCAAwC,CAAC;AAChF,YAAY,EACV,wBAAwB,EACxB,0CAA0C,EAC1C,mCAAmC,EACnC,qCAAqC,EACrC,iBAAiB,GAClB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAc,mCAAmC,CAAC;AAC3E,YAAY,EAAE,uBAAuB,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAG9I,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9G,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,cAAc,EAAE,MAAc,sCAAsC,CAAC;AAC9E,YAAY,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAiB,mCAAmC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAoB,gCAAgC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAgB,oCAAoC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAgB,oCAAoC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAe,qCAAqC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAe,qCAAqC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// ── Opt-in transport ────────────────────────────────────────────────────────────
|
|
2
|
+
// Pass `autoUpload` to the Provider and the SDK posts captures itself. Omit it
|
|
3
|
+
// and the SDK never touches the network. `createAutoUploader` is the same
|
|
4
|
+
// transport for consumers driving the low-level hooks directly.
|
|
5
|
+
export { createAutoUploader, CaptureUploadError, DEFAULT_CAPTURE_ENDPOINT } from "@meeeetup/camera-core";
|
|
1
6
|
// ── Context API (primary) ───────────────────────────────────────────────────────
|
|
2
7
|
export { MeeeetUpCamProvider } from "./react/context/MeeeetUpCamProvider.js";
|
|
3
8
|
export { useMeeeetUpCam } from "./react/context/useMeeeetUpCam.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,mFAAmF;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAS,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,mFAAmF;AACnF,+EAA+E;AAC/E,0EAA0E;AAC1E,gEAAgE;AAChE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AASzG,mFAAmF;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAS,wCAAwC,CAAC;AAQhF,OAAO,EAAE,cAAc,EAAE,MAAc,mCAAmC,CAAC;AAG3E,kFAAkF;AAClF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAS9G,mFAAmF;AACnF,OAAO,EAAE,cAAc,EAAE,MAAc,sCAAsC,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAE,MAAiB,mCAAmC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAoB,gCAAgC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAgB,oCAAoC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAgB,oCAAoC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAe,qCAAqC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAe,qCAAqC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SelectedFace } from "@meeeetup/camera-core";
|
|
1
|
+
import type { AutoUploadOptions, SelectedFace } from "@meeeetup/camera-core";
|
|
2
2
|
interface SharedProviderProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
/** Override the MediaPipe WASM CDN URL (passive mode). */
|
|
@@ -7,15 +7,32 @@ interface SharedProviderProps {
|
|
|
7
7
|
alignmentCaptureDelayMs?: number;
|
|
8
8
|
/** Dev face URLs for quick testing in interactive mode. */
|
|
9
9
|
devFaces?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Opt in to the SDK's own transport: captures are POSTed to the Meeeetup
|
|
12
|
+
* capture endpoint with this capture key, and no upload code is needed on
|
|
13
|
+
* your side. Omit it and the SDK makes no network call at all — the capture
|
|
14
|
+
* callback stays the only output path.
|
|
15
|
+
*
|
|
16
|
+
* With it set, the capture callback becomes optional and purely an observer:
|
|
17
|
+
* it is fired without being awaited, so logging or previewing cannot delay
|
|
18
|
+
* or fail the upload. Observer failures surface on `autoUpload.onError`.
|
|
19
|
+
*/
|
|
20
|
+
autoUpload?: AutoUploadOptions;
|
|
10
21
|
}
|
|
11
22
|
export interface InteractiveMeeeetUpCamProviderProps extends SharedProviderProps {
|
|
12
23
|
mode: "interactive";
|
|
13
|
-
|
|
24
|
+
/** Optional when `autoUpload` is set — then it observes rather than transports. */
|
|
25
|
+
onCapture?: (faceImage: string, fullCircleImage: string) => void | Promise<void>;
|
|
14
26
|
}
|
|
15
27
|
export interface PassiveCaptureOnlyMeeeetUpCamProviderProps extends SharedProviderProps {
|
|
16
28
|
mode: "passive";
|
|
17
|
-
/**
|
|
18
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Called with the buffered faces when a batch is flushed. Without
|
|
31
|
+
* `autoUpload` this is the only output path and the consumer owns transport
|
|
32
|
+
* (POST /capture with a capture key, or any other sink); with it, the sink
|
|
33
|
+
* is optional and observes the batch the SDK is uploading.
|
|
34
|
+
*/
|
|
35
|
+
onBatchCapture?: (faces: SelectedFace[]) => void | Promise<void>;
|
|
19
36
|
/**
|
|
20
37
|
* Capture gates, forwarded verbatim to `FaceCaptureSession`. They live on
|
|
21
38
|
* the passive props because the interactive flow here is the alignment ring,
|
|
@@ -39,19 +56,22 @@ export interface PassiveCaptureOnlyMeeeetUpCamProviderProps extends SharedProvid
|
|
|
39
56
|
*/
|
|
40
57
|
cooldownMs?: number;
|
|
41
58
|
}
|
|
59
|
+
/** Quality readings published alongside a single-mode capture. */
|
|
60
|
+
export interface SingleCaptureMeta {
|
|
61
|
+
frontalness: number;
|
|
62
|
+
faceSize: number;
|
|
63
|
+
score: number;
|
|
64
|
+
}
|
|
42
65
|
export interface SingleCaptureMeeeetUpCamProviderProps extends SharedProviderProps {
|
|
43
66
|
mode: "single";
|
|
44
67
|
/**
|
|
45
68
|
* Called once with the final best-shot face crop when the capture window
|
|
46
69
|
* closes. `fullCircleImage` is passed through for API compatibility with
|
|
47
70
|
* interactive mode and is an empty string in single mode — the single-mode
|
|
48
|
-
* output is the face crop plus the `meta` block below.
|
|
71
|
+
* output is the face crop plus the `meta` block below. Optional when
|
|
72
|
+
* `autoUpload` is set.
|
|
49
73
|
*/
|
|
50
|
-
onCapture
|
|
51
|
-
frontalness: number;
|
|
52
|
-
faceSize: number;
|
|
53
|
-
score: number;
|
|
54
|
-
}) => void | Promise<void>;
|
|
74
|
+
onCapture?: (faceImage: string, fullCircleImage: string, meta: SingleCaptureMeta) => void | Promise<void>;
|
|
55
75
|
/** Min detector confidence 0–1. Clamped below by MIN_SCORE_FLOOR (0.3). Default 0.9. */
|
|
56
76
|
minDetectionScore?: number;
|
|
57
77
|
/** Min box height / frame height. Default 0.26. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeeeetUpCamProvider.d.ts","sourceRoot":"","sources":["../../../src/react/context/MeeeetUpCamProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Me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E,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qCAAsC,SAAQ,mBAAmB;IAChF,IAAI,EAAE,QAAQ,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,iBAAiB,KACpB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,wFAAwF;IACxF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,wBAAwB,GAChC,mCAAmC,GACnC,0CAA0C,GAC1C,qCAAqC,CAAC;AAI1C,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,+BAIlE"}
|
|
@@ -4,6 +4,7 @@ import { usePassiveCamera } from "../usePassiveCamera.js";
|
|
|
4
4
|
import { useInteractiveCamera } from "../useInteractiveCamera.js";
|
|
5
5
|
import { useSingleCapture } from "../useSingleCapture.js";
|
|
6
6
|
import { useCameraDevices } from "../useCameraDevices.js";
|
|
7
|
+
import { useAutoUploader, useBatchCaptureSink, useSingleCaptureSink } from "../useAutoUpload.js";
|
|
7
8
|
import { MeeeetUpCamContext } from "./MeeeetUpCamContext.js";
|
|
8
9
|
const DEVICE_STORAGE_KEY = "meeeetup-cam:deviceId";
|
|
9
10
|
// ── Provider (entry point) ──────────────────────────────────────────────────────
|
|
@@ -16,7 +17,7 @@ export function MeeeetUpCamProvider(props) {
|
|
|
16
17
|
}
|
|
17
18
|
// ── Passive inner provider ──────────────────────────────────────────────────────
|
|
18
19
|
function PassiveProvider(props) {
|
|
19
|
-
const { children, mediapipeWasmUrl, cooldownMs, minDetectionScore, minFaceHeight, minFrontalness, captureWindowMs, onBatchCapture, } = props;
|
|
20
|
+
const { children, mediapipeWasmUrl, cooldownMs, minDetectionScore, minFaceHeight, minFrontalness, captureWindowMs, onBatchCapture, autoUpload, } = props;
|
|
20
21
|
const { devices } = useCameraDevices();
|
|
21
22
|
const [savedDeviceId, setSavedDeviceId] = useState(() => {
|
|
22
23
|
try {
|
|
@@ -27,8 +28,10 @@ function PassiveProvider(props) {
|
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
const [facingMode, setFacingMode] = useState("user");
|
|
31
|
+
const uploader = useAutoUploader(autoUpload);
|
|
32
|
+
const batchSink = useBatchCaptureSink(uploader, onBatchCapture, autoUpload);
|
|
30
33
|
const cam = usePassiveCamera({
|
|
31
|
-
onBatchCapture,
|
|
34
|
+
onBatchCapture: batchSink,
|
|
32
35
|
sessionType: "passive",
|
|
33
36
|
deviceId: savedDeviceId,
|
|
34
37
|
facingMode,
|
|
@@ -74,7 +77,7 @@ function PassiveProvider(props) {
|
|
|
74
77
|
}
|
|
75
78
|
// ── Single inner provider ──────────────────────────────────────────────────────
|
|
76
79
|
function SingleProvider(props) {
|
|
77
|
-
const { children, mediapipeWasmUrl, onCapture, minDetectionScore, minFaceSize, minFrontalness, captureWindowMs, } = props;
|
|
80
|
+
const { children, mediapipeWasmUrl, onCapture, minDetectionScore, minFaceSize, minFrontalness, captureWindowMs, autoUpload, } = props;
|
|
78
81
|
const { devices } = useCameraDevices();
|
|
79
82
|
const [savedDeviceId, setSavedDeviceId] = useState(() => {
|
|
80
83
|
try {
|
|
@@ -85,8 +88,10 @@ function SingleProvider(props) {
|
|
|
85
88
|
}
|
|
86
89
|
});
|
|
87
90
|
const [facingMode, setFacingMode] = useState("user");
|
|
91
|
+
const uploader = useAutoUploader(autoUpload);
|
|
92
|
+
const captureSink = useSingleCaptureSink(uploader, onCapture, autoUpload);
|
|
88
93
|
const cam = useSingleCapture({
|
|
89
|
-
onCapture,
|
|
94
|
+
onCapture: captureSink,
|
|
90
95
|
deviceId: savedDeviceId,
|
|
91
96
|
facingMode,
|
|
92
97
|
mediapipeWasmUrl,
|
|
@@ -135,14 +140,16 @@ function SingleProvider(props) {
|
|
|
135
140
|
}
|
|
136
141
|
// ── Interactive inner provider ──────────────────────────────────────────────────
|
|
137
142
|
function InteractiveProvider(props) {
|
|
138
|
-
const { children, alignmentCaptureDelayMs = 2000, onCapture, } = props;
|
|
143
|
+
const { children, alignmentCaptureDelayMs = 2000, onCapture, autoUpload, } = props;
|
|
139
144
|
const { devices } = useCameraDevices();
|
|
140
145
|
const [lastResult] = useState(null);
|
|
146
|
+
const uploader = useAutoUploader(autoUpload);
|
|
147
|
+
const captureSink = useSingleCaptureSink(uploader, onCapture, autoUpload);
|
|
141
148
|
const handleCapture = useCallback(async (faceImage, fullCircleImage) => {
|
|
142
149
|
if (!faceImage)
|
|
143
150
|
return;
|
|
144
|
-
await
|
|
145
|
-
}, [
|
|
151
|
+
await captureSink(faceImage, fullCircleImage);
|
|
152
|
+
}, [captureSink]);
|
|
146
153
|
const cam = useInteractiveCamera({
|
|
147
154
|
onCapture: handleCapture,
|
|
148
155
|
autoCapture: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeeeetUpCamProvider.js","sourceRoot":"","sources":["../../../src/react/context/MeeeetUpCamProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAA8D,MAAM,yBAAyB,CAAC;AAEzH,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"MeeeetUpCamProvider.js","sourceRoot":"","sources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AE,GAAG,CAAC,SAAS;QACxB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,OAAO;QACP,eAAe,EAAE,SAAS;QAC1B,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;QACrB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;QAC1C,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,UAAU;KACX,CAAC;IAEF,OAAO,CACL,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACtC,QAAQ,GACmB,CAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type AutoUploadOptions, type AutoUploader, type SelectedFace } from "@meeeetup/camera-core";
|
|
2
|
+
export type { AutoUploadOptions };
|
|
3
|
+
/**
|
|
4
|
+
* Build the opt-in uploader, or `null` when the consumer passed no
|
|
5
|
+
* `autoUpload` block — in which case nothing here ever touches the network.
|
|
6
|
+
*
|
|
7
|
+
* Callbacks route through a ref so a consumer re-creating them inline on every
|
|
8
|
+
* render does not rebuild the uploader. `fetch` is captured when the uploader
|
|
9
|
+
* is built: it is a test/proxy escape hatch, not something a live component
|
|
10
|
+
* swaps mid-session.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useAutoUploader(config: AutoUploadOptions | undefined): AutoUploader | null;
|
|
13
|
+
/** Passive batch sink: upload when opted in, consumer-owned transport otherwise. */
|
|
14
|
+
export declare function useBatchCaptureSink(uploader: AutoUploader | null, onBatchCapture: ((faces: SelectedFace[]) => void | Promise<void>) | undefined, config: AutoUploadOptions | undefined): (faces: SelectedFace[]) => void | Promise<void>;
|
|
15
|
+
/** Single-shot capture sink for interactive and single modes. */
|
|
16
|
+
export declare function useSingleCaptureSink<M extends unknown[]>(uploader: AutoUploader | null, onCapture: ((faceImage: string, fullCircleImage: string, ...meta: M) => void | Promise<void>) | undefined, config: AutoUploadOptions | undefined): (faceImage: string, fullCircleImage: string, ...meta: M) => void | Promise<void>;
|
|
17
|
+
//# sourceMappingURL=useAutoUpload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoUpload.d.ts","sourceRoot":"","sources":["../../src/react/useAutoUpload.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAwB1F;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,GAAG,IAAI,EAC7B,cAAc,EAAE,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,EAC7E,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjD;AAED,iEAAiE;AACjE,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,OAAO,EAAE,EACtD,QAAQ,EAAE,YAAY,GAAG,IAAI,EAC7B,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,EACzG,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAMlF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { composeBatchSink, composeCaptureSink, createAutoUploader, } from "@meeeetup/camera-core";
|
|
3
|
+
/**
|
|
4
|
+
* Build the opt-in uploader, or `null` when the consumer passed no
|
|
5
|
+
* `autoUpload` block — in which case nothing here ever touches the network.
|
|
6
|
+
*
|
|
7
|
+
* Callbacks route through a ref so a consumer re-creating them inline on every
|
|
8
|
+
* render does not rebuild the uploader. `fetch` is captured when the uploader
|
|
9
|
+
* is built: it is a test/proxy escape hatch, not something a live component
|
|
10
|
+
* swaps mid-session.
|
|
11
|
+
*/
|
|
12
|
+
export function useAutoUploader(config) {
|
|
13
|
+
const latest = useRef(config);
|
|
14
|
+
useEffect(() => { latest.current = config; });
|
|
15
|
+
const captureKey = config?.captureKey;
|
|
16
|
+
const endpoint = config?.endpoint;
|
|
17
|
+
const channelId = config?.channelId;
|
|
18
|
+
const maxRetries = config?.maxRetries;
|
|
19
|
+
const retryDelayMs = config?.retryDelayMs;
|
|
20
|
+
const fetchImpl = config?.fetch;
|
|
21
|
+
return useMemo(() => {
|
|
22
|
+
if (!captureKey)
|
|
23
|
+
return null;
|
|
24
|
+
return createAutoUploader({
|
|
25
|
+
captureKey,
|
|
26
|
+
endpoint,
|
|
27
|
+
channelId,
|
|
28
|
+
maxRetries,
|
|
29
|
+
retryDelayMs,
|
|
30
|
+
fetch: fetchImpl,
|
|
31
|
+
onUploaded: (result) => latest.current?.onUploaded?.(result),
|
|
32
|
+
onError: (error) => latest.current?.onError?.(error),
|
|
33
|
+
});
|
|
34
|
+
}, [captureKey, endpoint, channelId, maxRetries, retryDelayMs, fetchImpl]);
|
|
35
|
+
}
|
|
36
|
+
/** Passive batch sink: upload when opted in, consumer-owned transport otherwise. */
|
|
37
|
+
export function useBatchCaptureSink(uploader, onBatchCapture, config) {
|
|
38
|
+
const onObserverError = config?.onError;
|
|
39
|
+
return useMemo(() => composeBatchSink(uploader, onBatchCapture, onObserverError), [uploader, onBatchCapture, onObserverError]);
|
|
40
|
+
}
|
|
41
|
+
/** Single-shot capture sink for interactive and single modes. */
|
|
42
|
+
export function useSingleCaptureSink(uploader, onCapture, config) {
|
|
43
|
+
const onObserverError = config?.onError;
|
|
44
|
+
return useMemo(() => composeCaptureSink(uploader, onCapture, onObserverError), [uploader, onCapture, onObserverError]);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=useAutoUpload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoUpload.js","sourceRoot":"","sources":["../../src/react/useAutoUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GAInB,MAAM,uBAAuB,CAAC;AAI/B;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAAqC;IACnE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9C,MAAM,UAAU,GAAK,MAAM,EAAE,UAAU,CAAC;IACxC,MAAM,QAAQ,GAAO,MAAM,EAAE,QAAQ,CAAC;IACtC,MAAM,SAAS,GAAM,MAAM,EAAE,SAAS,CAAC;IACvC,MAAM,UAAU,GAAK,MAAM,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AAC;AACJ,CAAC"}
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @meeeetup/camera-web
|
|
2
2
|
|
|
3
|
-
> Web half of the Meeeetup camera SDK: MediaPipe BlazeFace detection plus a React provider, hooks and components over `@meeeetup/camera-core`.
|
|
3
|
+
> Web half of the Meeeetup camera SDK: MediaPipe BlazeFace detection plus a React provider, hooks and components over `@meeeetup/camera-core`. Transport is yours by default; pass the opt-in `autoUpload` prop and the SDK posts captures itself.
|
|
4
4
|
|
|
5
5
|
Install: `pnpm add @meeeetup/camera-web`
|
|
6
6
|
|
|
@@ -31,9 +31,23 @@ const conf = {
|
|
|
31
31
|
</MeeeetUpCamProvider>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
Opt-in transport — the provider uploads, so no capture callback is needed:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<MeeeetUpCamProvider mode="passive" autoUpload={{ captureKey }}>
|
|
38
|
+
<CameraViewport />
|
|
39
|
+
<FaceGrid />
|
|
40
|
+
</MeeeetUpCamProvider>
|
|
41
|
+
```
|
|
42
|
+
|
|
34
43
|
## Notes
|
|
35
44
|
|
|
36
45
|
- Exports: `MeeeetUpCamProvider`, `useMeeeetUpCam`, `CameraViewport`, `FaceGrid`, `FaceCounter`, `DevicePicker`, `CameraToggle`, `AlignmentRing`, `CaptureButton`.
|
|
46
|
+
- Transport re-exports from core, for consumers driving `usePassiveCamera` / `useSingleCapture` directly: `createAutoUploader`, `CaptureUploadError`, `DEFAULT_CAPTURE_ENDPOINT`, and the types `AutoUploader`, `AutoUploadOptions`, `AutoUploadResult`, `CaptureFetch`, `CaptureImage`.
|
|
47
|
+
- `autoUpload?: AutoUploadOptions` is a provider prop in all three modes (`passive`, `single`, `interactive`). Set it and captures are POSTed to `endpoint` (default `https://api.meeeetup.com/capture`) with `Authorization: Bearer <captureKey>`, body `{ images: [{ image, capturedAt }], channelId? }`; omit it and the SDK uploads nothing and holds no credential. Options: `captureKey`, `endpoint`, `channelId`, `maxRetries` (default 2), `retryDelayMs` (default 1000), `fetch`, `onUploaded`, `onError`.
|
|
48
|
+
- With `autoUpload` set, `onBatchCapture` / `onCapture` become optional observers: fired without being awaited, so they cannot delay or fail the upload, and their rejections surface on `autoUpload.onError`. Without it, the callback is the only output path and a rejection requeues the batch.
|
|
49
|
+
- In `single` / `interactive` mode only the face crop is uploaded — `fullCircleImage` never leaves the device.
|
|
50
|
+
- Uploads retry on 5xx / 429 / 408 / transport failure and fail immediately on other 4xx; once attempts are exhausted a `CaptureUploadError` (`status`, `retryable`, `attempts`, `cause`) is thrown and retryable batches are requeued.
|
|
37
51
|
- `useMeeeetUpCam()` is a union discriminated on `mode`; narrow before reading mode-specific fields.
|
|
38
52
|
- The capture gates are passive-mode props: interactive capture is decided by the alignment ring, not the tracker's selection pipeline.
|
|
39
53
|
- Components take no props — they read the provider through context. For a custom layout, attach `videoRef` / `overlayRef` yourself.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meeeetup/camera-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Web SDK for meeeetup-cam — MediaPipe BlazeFace + React hooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@mediapipe/tasks-vision": "^0.10.22",
|
|
33
33
|
"lucide-react": "^1.17.0",
|
|
34
|
-
"@meeeetup/camera-core": "0.
|
|
34
|
+
"@meeeetup/camera-core": "0.8.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^18 || ^19",
|