@deibid/no-hands-react 0.0.4 → 0.0.5

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/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React$1 from 'react';
2
2
  import React__default, { PropsWithChildren } from 'react';
3
- import { Point, Rect, CreateEventDispatcherOpts, EventDispatcher, FaceTracker } from '@deibid/no-hands';
4
- export { NHEvent } from '@deibid/no-hands';
3
+ import { Point, Listener, Rect, FilterFn, CreateEventDispatcherOpts, EventDispatcher, FaceTracker } from '@deibid/no-hands';
4
+ export { FilterFn, Filters, NHEvent, Point } from '@deibid/no-hands';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface NHEventProps {
@@ -28,6 +28,13 @@ declare function useCamera(): {
28
28
  error: Error | null;
29
29
  };
30
30
  declare function useNHPoint(): Point | null;
31
+ interface UseNHEventNotificationProps {
32
+ onNHMouseEnter?: Listener<'nh:mouseenter'>;
33
+ onNHMouseLeave?: Listener<'nh:mouseleave'>;
34
+ onNHClickGestureBegin?: Listener<'nh:click-gesture-begin'>;
35
+ onNHClickGestureEnd?: Listener<'nh:click-gesture-end'>;
36
+ }
37
+ declare function useNHEventNotification({ onNHClickGestureBegin, onNHClickGestureEnd, onNHMouseEnter, onNHMouseLeave }: UseNHEventNotificationProps): void;
31
38
  declare function useWindowSize(): {
32
39
  width: number;
33
40
  height: number;
@@ -41,11 +48,14 @@ interface INHContext {
41
48
  faceTracker: FaceTracker | null;
42
49
  loading: boolean;
43
50
  videoStream: MediaStream | null;
51
+ detectionBounds?: Rect | null;
52
+ projectionBounds?: Rect | null;
44
53
  }
45
54
  interface NHProviderOptions {
46
55
  faceTrackerOpts?: {
47
56
  detectionBounds?: Rect;
48
57
  projectionBounds?: Rect;
58
+ filterFn?: FilterFn;
49
59
  };
50
60
  eventDispatcherOpts?: CreateEventDispatcherOpts;
51
61
  }
@@ -55,14 +65,13 @@ declare function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }:
55
65
  declare function useNH(): INHContext;
56
66
 
57
67
  interface DetectionBoundsDisplayProps {
58
- detectionBounds: Rect;
59
68
  style?: React.CSSProperties;
60
69
  }
61
- declare function DetectionBoundsDisplay({ detectionBounds, style }: DetectionBoundsDisplayProps): react_jsx_runtime.JSX.Element;
70
+ declare function DetectionBoundsDisplay({ style }: DetectionBoundsDisplayProps): react_jsx_runtime.JSX.Element | undefined;
62
71
 
63
72
  interface PointerProps extends React.PropsWithChildren {
64
73
  style?: React.CSSProperties;
65
74
  }
66
75
  declare function Pointer({ children, style }: PointerProps): react_jsx_runtime.JSX.Element;
67
76
 
68
- export { DetectionBoundsDisplay, NH, NHProvider, Pointer, useCamera, useEvents, useNH, useNHPoint, useWindowSize };
77
+ export { DetectionBoundsDisplay, NH, NHProvider, Pointer, useCamera, useEvents, useNH, useNHEventNotification, useNHPoint, useWindowSize };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React$1 from 'react';
2
2
  import React__default, { PropsWithChildren } from 'react';
3
- import { Point, Rect, CreateEventDispatcherOpts, EventDispatcher, FaceTracker } from '@deibid/no-hands';
4
- export { NHEvent } from '@deibid/no-hands';
3
+ import { Point, Listener, Rect, FilterFn, CreateEventDispatcherOpts, EventDispatcher, FaceTracker } from '@deibid/no-hands';
4
+ export { FilterFn, Filters, NHEvent, Point } from '@deibid/no-hands';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface NHEventProps {
@@ -28,6 +28,13 @@ declare function useCamera(): {
28
28
  error: Error | null;
29
29
  };
30
30
  declare function useNHPoint(): Point | null;
31
+ interface UseNHEventNotificationProps {
32
+ onNHMouseEnter?: Listener<'nh:mouseenter'>;
33
+ onNHMouseLeave?: Listener<'nh:mouseleave'>;
34
+ onNHClickGestureBegin?: Listener<'nh:click-gesture-begin'>;
35
+ onNHClickGestureEnd?: Listener<'nh:click-gesture-end'>;
36
+ }
37
+ declare function useNHEventNotification({ onNHClickGestureBegin, onNHClickGestureEnd, onNHMouseEnter, onNHMouseLeave }: UseNHEventNotificationProps): void;
31
38
  declare function useWindowSize(): {
32
39
  width: number;
33
40
  height: number;
@@ -41,11 +48,14 @@ interface INHContext {
41
48
  faceTracker: FaceTracker | null;
42
49
  loading: boolean;
43
50
  videoStream: MediaStream | null;
51
+ detectionBounds?: Rect | null;
52
+ projectionBounds?: Rect | null;
44
53
  }
45
54
  interface NHProviderOptions {
46
55
  faceTrackerOpts?: {
47
56
  detectionBounds?: Rect;
48
57
  projectionBounds?: Rect;
58
+ filterFn?: FilterFn;
49
59
  };
50
60
  eventDispatcherOpts?: CreateEventDispatcherOpts;
51
61
  }
@@ -55,14 +65,13 @@ declare function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }:
55
65
  declare function useNH(): INHContext;
56
66
 
57
67
  interface DetectionBoundsDisplayProps {
58
- detectionBounds: Rect;
59
68
  style?: React.CSSProperties;
60
69
  }
61
- declare function DetectionBoundsDisplay({ detectionBounds, style }: DetectionBoundsDisplayProps): react_jsx_runtime.JSX.Element;
70
+ declare function DetectionBoundsDisplay({ style }: DetectionBoundsDisplayProps): react_jsx_runtime.JSX.Element | undefined;
62
71
 
63
72
  interface PointerProps extends React.PropsWithChildren {
64
73
  style?: React.CSSProperties;
65
74
  }
66
75
  declare function Pointer({ children, style }: PointerProps): react_jsx_runtime.JSX.Element;
67
76
 
68
- export { DetectionBoundsDisplay, NH, NHProvider, Pointer, useCamera, useEvents, useNH, useNHPoint, useWindowSize };
77
+ export { DetectionBoundsDisplay, NH, NHProvider, Pointer, useCamera, useEvents, useNH, useNHEventNotification, useNHPoint, useWindowSize };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  DetectionBoundsDisplay: () => DetectionBoundsDisplay,
34
+ Filters: () => import_no_hands3.Filters,
34
35
  NH: () => NH,
35
36
  NHEvent: () => import_no_hands3.NHEvent,
36
37
  NHProvider: () => NHProvider,
@@ -38,6 +39,7 @@ __export(index_exports, {
38
39
  useCamera: () => useCamera,
39
40
  useEvents: () => useEvents,
40
41
  useNH: () => useNH,
42
+ useNHEventNotification: () => useNHEventNotification,
41
43
  useNHPoint: () => useNHPoint,
42
44
  useWindowSize: () => useWindowSize
43
45
  });
@@ -59,7 +61,9 @@ var NHContext = (0, import_react.createContext)({
59
61
  eventDispatcher: null,
60
62
  faceTracker: null,
61
63
  loading: false,
62
- videoStream: null
64
+ videoStream: null,
65
+ detectionBounds: null,
66
+ projectionBounds: null
63
67
  });
64
68
  function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }) {
65
69
  const [faceTracker, setFaceTracker] = (0, import_react.useState)(null);
@@ -85,7 +89,8 @@ function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }) {
85
89
  localFaceTracker = await (0, import_no_hands.createFaceTracker)({
86
90
  videoElement,
87
91
  detectionBounds: faceTrackerOptsRef.current?.detectionBounds,
88
- projectionBounds: faceTrackerOptsRef.current?.projectionBounds
92
+ projectionBounds: faceTrackerOptsRef.current?.projectionBounds,
93
+ filterFn: faceTrackerOptsRef.current?.filterFn
89
94
  });
90
95
  if (!ftActive) {
91
96
  localFaceTracker.stop();
@@ -126,9 +131,11 @@ function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }) {
126
131
  eventDispatcher,
127
132
  faceTracker,
128
133
  loading,
129
- videoStream: stream
134
+ videoStream: stream,
135
+ detectionBounds: faceTrackerOpts?.detectionBounds,
136
+ projectionBounds: faceTrackerOpts?.projectionBounds
130
137
  }),
131
- [error, eventDispatcher, faceTracker, loading, stream]
138
+ [error, eventDispatcher, faceTracker, faceTrackerOpts, loading, stream]
132
139
  );
133
140
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(NHContext.Provider, { value: contextValue, children: [
134
141
  children,
@@ -413,9 +420,12 @@ var NH = htmlElementTags.reduce((result, tag) => {
413
420
  // src/detection-bounds-display.tsx
414
421
  var import_jsx_runtime2 = require("react/jsx-runtime");
415
422
  function DetectionBoundsDisplay({
416
- detectionBounds,
417
423
  style
418
424
  }) {
425
+ const { detectionBounds } = useNH();
426
+ if (!detectionBounds) {
427
+ return;
428
+ }
419
429
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
420
430
  "div",
421
431
  {
@@ -464,7 +474,6 @@ function Pointer({
464
474
  ...point === null && { visibility: "hidden" },
465
475
  ...point !== null && { left: point.x, top: point.y },
466
476
  ...style
467
- // backgroundColor: color,
468
477
  },
469
478
  children: children ?? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DefaultPointerIndicator, {})
470
479
  }
@@ -475,8 +484,8 @@ function DefaultPointerIndicator() {
475
484
  "div",
476
485
  {
477
486
  style: {
478
- height: 24,
479
- width: 24,
487
+ height: 28,
488
+ width: 28,
480
489
  borderRadius: "50%",
481
490
  transform: "translate(-50%, -50%)",
482
491
  boxShadow: "rgba(0, 0, 0, 0.24) 0px 3px 8px",
@@ -491,6 +500,7 @@ var import_no_hands3 = require("@deibid/no-hands");
491
500
  // Annotate the CommonJS export names for ESM import in node:
492
501
  0 && (module.exports = {
493
502
  DetectionBoundsDisplay,
503
+ Filters,
494
504
  NH,
495
505
  NHEvent,
496
506
  NHProvider,
@@ -498,6 +508,7 @@ var import_no_hands3 = require("@deibid/no-hands");
498
508
  useCamera,
499
509
  useEvents,
500
510
  useNH,
511
+ useNHEventNotification,
501
512
  useNHPoint,
502
513
  useWindowSize
503
514
  });
package/dist/index.mjs CHANGED
@@ -24,7 +24,9 @@ var NHContext = createContext({
24
24
  eventDispatcher: null,
25
25
  faceTracker: null,
26
26
  loading: false,
27
- videoStream: null
27
+ videoStream: null,
28
+ detectionBounds: null,
29
+ projectionBounds: null
28
30
  });
29
31
  function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }) {
30
32
  const [faceTracker, setFaceTracker] = useState(null);
@@ -50,7 +52,8 @@ function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }) {
50
52
  localFaceTracker = await createFaceTracker({
51
53
  videoElement,
52
54
  detectionBounds: faceTrackerOptsRef.current?.detectionBounds,
53
- projectionBounds: faceTrackerOptsRef.current?.projectionBounds
55
+ projectionBounds: faceTrackerOptsRef.current?.projectionBounds,
56
+ filterFn: faceTrackerOptsRef.current?.filterFn
54
57
  });
55
58
  if (!ftActive) {
56
59
  localFaceTracker.stop();
@@ -91,9 +94,11 @@ function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }) {
91
94
  eventDispatcher,
92
95
  faceTracker,
93
96
  loading,
94
- videoStream: stream
97
+ videoStream: stream,
98
+ detectionBounds: faceTrackerOpts?.detectionBounds,
99
+ projectionBounds: faceTrackerOpts?.projectionBounds
95
100
  }),
96
- [error, eventDispatcher, faceTracker, loading, stream]
101
+ [error, eventDispatcher, faceTracker, faceTrackerOpts, loading, stream]
97
102
  );
98
103
  return /* @__PURE__ */ jsxs(NHContext.Provider, { value: contextValue, children: [
99
104
  children,
@@ -378,9 +383,12 @@ var NH = htmlElementTags.reduce((result, tag) => {
378
383
  // src/detection-bounds-display.tsx
379
384
  import { jsx as jsx2 } from "react/jsx-runtime";
380
385
  function DetectionBoundsDisplay({
381
- detectionBounds,
382
386
  style
383
387
  }) {
388
+ const { detectionBounds } = useNH();
389
+ if (!detectionBounds) {
390
+ return;
391
+ }
384
392
  return /* @__PURE__ */ jsx2(
385
393
  "div",
386
394
  {
@@ -429,7 +437,6 @@ function Pointer({
429
437
  ...point === null && { visibility: "hidden" },
430
438
  ...point !== null && { left: point.x, top: point.y },
431
439
  ...style
432
- // backgroundColor: color,
433
440
  },
434
441
  children: children ?? /* @__PURE__ */ jsx3(DefaultPointerIndicator, {})
435
442
  }
@@ -440,8 +447,8 @@ function DefaultPointerIndicator() {
440
447
  "div",
441
448
  {
442
449
  style: {
443
- height: 24,
444
- width: 24,
450
+ height: 28,
451
+ width: 28,
445
452
  borderRadius: "50%",
446
453
  transform: "translate(-50%, -50%)",
447
454
  boxShadow: "rgba(0, 0, 0, 0.24) 0px 3px 8px",
@@ -452,9 +459,13 @@ function DefaultPointerIndicator() {
452
459
  }
453
460
 
454
461
  // src/index.ts
455
- import { NHEvent as NHEvent2 } from "@deibid/no-hands";
462
+ import {
463
+ Filters,
464
+ NHEvent as NHEvent2
465
+ } from "@deibid/no-hands";
456
466
  export {
457
467
  DetectionBoundsDisplay,
468
+ Filters,
458
469
  NH,
459
470
  NHEvent2 as NHEvent,
460
471
  NHProvider,
@@ -462,6 +473,7 @@ export {
462
473
  useCamera,
463
474
  useEvents,
464
475
  useNH,
476
+ useNHEventNotification,
465
477
  useNHPoint,
466
478
  useWindowSize
467
479
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deibid/no-hands-react",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "React adapter for @deibid/no-hands",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,7 +17,7 @@
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
19
  "react-merge-refs": "^3.0.2",
20
- "@deibid/no-hands": "0.0.4"
20
+ "@deibid/no-hands": "0.0.5"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "react": ">=18.0.0"
@@ -25,6 +25,8 @@ const NHContext = createContext<INHContext>({
25
25
  faceTracker: null,
26
26
  loading: false,
27
27
  videoStream: null,
28
+ detectionBounds: null,
29
+ projectionBounds: null,
28
30
  });
29
31
 
30
32
 
@@ -62,6 +64,7 @@ export function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }: N
62
64
  videoElement,
63
65
  detectionBounds: faceTrackerOptsRef.current?.detectionBounds,
64
66
  projectionBounds: faceTrackerOptsRef.current?.projectionBounds,
67
+ filterFn: faceTrackerOptsRef.current?.filterFn
65
68
  });
66
69
 
67
70
  if (!ftActive) {
@@ -119,8 +122,10 @@ export function NHProvider({ children, eventDispatcherOpts, faceTrackerOpts }: N
119
122
  faceTracker,
120
123
  loading,
121
124
  videoStream: stream,
125
+ detectionBounds: faceTrackerOpts?.detectionBounds,
126
+ projectionBounds: faceTrackerOpts?.projectionBounds
122
127
  }),
123
- [error, eventDispatcher, faceTracker, loading, stream]);
128
+ [error, eventDispatcher, faceTracker, faceTrackerOpts, loading, stream]);
124
129
 
125
130
  return (
126
131
  <NHContext.Provider value={contextValue}>
@@ -2,6 +2,7 @@ import type {
2
2
  CreateEventDispatcherOpts,
3
3
  EventDispatcher,
4
4
  FaceTracker,
5
+ FilterFn,
5
6
  Rect
6
7
  } from "@deibid/no-hands";
7
8
 
@@ -11,12 +12,15 @@ export interface INHContext {
11
12
  faceTracker: FaceTracker | null;
12
13
  loading: boolean;
13
14
  videoStream: MediaStream | null;
15
+ detectionBounds?: Rect | null;
16
+ projectionBounds?: Rect | null;
14
17
  }
15
18
 
16
19
  export interface NHProviderOptions {
17
20
  faceTrackerOpts?: {
18
21
  detectionBounds?: Rect;
19
22
  projectionBounds?: Rect;
23
+ filterFn?: FilterFn;
20
24
  };
21
25
  eventDispatcherOpts?: CreateEventDispatcherOpts;
22
26
  }
@@ -1,14 +1,19 @@
1
- import { Rect } from "@deibid/no-hands";
1
+ import { useNH } from "./context";
2
2
 
3
3
  interface DetectionBoundsDisplayProps {
4
- detectionBounds: Rect;
5
4
  style?: React.CSSProperties;
6
5
  }
7
6
 
8
7
  export default function DetectionBoundsDisplay({
9
- detectionBounds,
10
8
  style
11
9
  }: DetectionBoundsDisplayProps) {
10
+
11
+ const { detectionBounds } = useNH();
12
+
13
+ if (!detectionBounds) {
14
+ return;
15
+ }
16
+
12
17
  return (
13
18
  <div
14
19
  style={{
package/src/index.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { NH } from './nhcomponent';
2
- import { useEvents, useCamera, useNHPoint, useWindowSize } from "./hooks";
2
+ import { useEvents, useCamera, useNHPoint, useWindowSize, useNHEventNotification } from "./hooks";
3
3
  import { NHProvider, useNH } from "./context";
4
4
  import DetectionBoundsDisplay from "./detection-bounds-display";
5
5
  import Pointer from "./pointer";
6
- import { NHEvent } from "@deibid/no-hands";
6
+ import {
7
+ type FilterFn,
8
+ type Point,
9
+ Filters,
10
+ NHEvent
11
+ } from "@deibid/no-hands";
7
12
 
8
13
 
9
14
  export {
@@ -15,10 +20,14 @@ export {
15
20
  useNH,
16
21
  useNHPoint,
17
22
  useWindowSize,
23
+ useNHEventNotification,
18
24
  // components
19
25
  NH,
20
26
  DetectionBoundsDisplay,
21
27
  Pointer,
22
28
  // re-exports from core package
29
+ FilterFn,
30
+ Point,
31
+ Filters,
23
32
  NHEvent
24
33
  }
package/src/pointer.tsx CHANGED
@@ -36,7 +36,6 @@ export default function Pointer({
36
36
  ...(point === null && { visibility: 'hidden' }),
37
37
  ...(point !== null && { left: point.x, top: point.y }),
38
38
  ...style,
39
- // backgroundColor: color,
40
39
  }}
41
40
  >
42
41
  {children ?? <DefaultPointerIndicator />}
@@ -49,8 +48,8 @@ function DefaultPointerIndicator() {
49
48
 
50
49
  return <div
51
50
  style={{
52
- height: 24,
53
- width: 24,
51
+ height: 28,
52
+ width: 28,
54
53
  borderRadius: '50%',
55
54
  transform: 'translate(-50%, -50%)',
56
55
  boxShadow: 'rgba(0, 0, 0, 0.24) 0px 3px 8px',