@glasshome/widget-sdk 0.3.6 → 0.3.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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Haptic feedback for gesture transitions.
3
+ *
4
+ * Resolution order at runtime:
5
+ * 1. Capacitor Haptics plugin (Android/iOS native) — richer patterns
6
+ * 2. `navigator.vibrate` (Android Chrome/WebView)
7
+ * 3. silent (desktop, iOS Safari)
8
+ *
9
+ * No build-time dependency on @capacitor/haptics — the host app installs the
10
+ * plugin; we probe `window.Capacitor.Plugins.Haptics` at call time.
11
+ */
12
+ export declare const haptics: {
13
+ /** Light confirmation — fires when slide gesture arms after user holds still. */
14
+ tick(): void;
15
+ /** Medium bump — fires when hold gesture commits (detail opening). */
16
+ bump(): void;
17
+ /** Stronger pulse — reserved for edit-mode pickup (future use). */
18
+ pulse(): void;
19
+ };
@@ -1,32 +1,22 @@
1
1
  /**
2
- * Widget Gestures Hook
2
+ * Widget Gestures Hook — Mobile-aware
3
3
  *
4
- * Provides gesture handling for widgets with automatic conflict resolution.
5
- * Ported from React reference, adapted for SolidJS:
6
- * - Uses mutable state object instead of useRef (imperative gesture tracking)
7
- * - Accepts config/orientation as accessors for reactivity
8
- * - Returns native PointerEvent handlers (not React.PointerEvent)
9
- * - Callers bind via on:pointerdown={handlers.onPointerDown}
4
+ * Two grammars by pointer type:
10
5
  *
11
- * @example
12
- * ```tsx
13
- * const gestures = useWidgetGestures(
14
- * () => ({
15
- * tap: handleTap,
16
- * hold: { action: handleHold, delay: 300 },
17
- * slide: {
18
- * value: brightness(),
19
- * onChange: setBrightness,
20
- * min: 0,
21
- * max: 100,
22
- * orientation: "auto",
23
- * },
24
- * }),
25
- * () => ctx.orientation(),
26
- * );
6
+ * TOUCH (phone, tablet):
7
+ * - tap → primary action
8
+ * - hold → detail dialog (with haptic bump)
9
+ * - slide → DISABLED. Fine control lives in the detail dialog instead.
10
+ * This eliminates the slide-vs-page-scroll conflict that makes mobile
11
+ * gestures fragile. `touch-action: manipulation` ensures the browser
12
+ * handles scroll natively without our interference.
27
13
  *
28
- * return <div on:pointerdown={gestures.onPointerDown} on:pointermove={gestures.onPointerMove} on:pointerup={gestures.onPointerUp} on:pointercancel={gestures.onPointerCancel}>...</div>;
29
- * ```
14
+ * MOUSE / PEN (desktop, hybrid devices):
15
+ * - tap, hold, slide all active. Slide arms immediately on pointerdown —
16
+ * no scroll conflict to worry about (mouse uses wheel for scroll).
17
+ *
18
+ * Pointer type is decided per press at pointerdown. A hybrid device (tablet
19
+ * + bluetooth mouse) gets the right grammar based on which input fired.
30
20
  */
31
21
  import type { GestureConfig, WidgetOrientation } from "../types";
32
22
  export interface GestureHandlers {
@@ -43,24 +33,12 @@ export interface GestureHandlers {
43
33
  */
44
34
  bindElement: (el: HTMLElement) => void;
45
35
  /**
46
- * CSS `touch-action` value for the gesture root. Horizontal slide `pan-y`
47
- * (page scrolls vertically, slider owns horizontal). Vertical slide `pan-x`.
48
- * Tap/hold only `manipulation`. Without this, mobile browsers cancel the
49
- * pointer mid-slide once they decide the touch is a pan.
36
+ * CSS `touch-action` for the gesture root. Always `manipulation` when any
37
+ * gesture is configured mobile slide is intentionally dropped, so the
38
+ * browser owns scroll completely on touch surfaces.
50
39
  */
51
40
  touchAction: () => string;
52
- /** Cancel any pending hold/slide timers. Call on component unmount via onCleanup. */
41
+ /** Cancel any pending hold timer. Call on component unmount via onCleanup. */
53
42
  dispose: () => void;
54
43
  }
55
- /**
56
- * Widget gestures hook with conflict resolution
57
- *
58
- * Features:
59
- * - Axis locking: Once slide direction is detected, locks to that axis
60
- * - Scroll prevention: Blocks page scroll when sliding along widget axis
61
- * - Tap/hold/slide gesture support with automatic conflict resolution
62
- *
63
- * @param config - Accessor returning gesture configuration
64
- * @param orientation - Accessor returning widget orientation (for auto slide orientation)
65
- */
66
44
  export declare function useWidgetGestures(config: () => GestureConfig, orientation?: () => WidgetOrientation): GestureHandlers;