craft-native 0.0.112 → 0.0.115

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/types.d.ts CHANGED
@@ -32,7 +32,7 @@
32
32
  * Windows Hello | - | - | ✓ | - | -
33
33
  * Toast Notifications | - | - | ✓ | - | -
34
34
  * Biometrics | - | - | - | ✓ | ✓
35
- * Haptic Feedback | - | - | - | ✓ | ✓
35
+ * Haptic Feedback | ✓ | - | - | ✓ | ✓
36
36
  * Secure Storage | - | - | - | ✓ | ✓
37
37
  * Location | - | - | - | ✓ | ✓
38
38
  * Share Sheet | - | - | - | ✓ | ✓
@@ -45,6 +45,10 @@
45
45
  * Work Manager | - | - | - | - | ✓
46
46
  * Predictive Back | - | - | - | - | ✓
47
47
  *
48
+ * Haptic Feedback on macOS is the Force Touch trackpad (NSHapticFeedbackManager):
49
+ * the same `haptics.*` calls, played only while a finger is on the trackpad and
50
+ * the app is active. Linux and Windows have no haptics API to call.
51
+ *
48
52
  * Mobile-only bridge APIs (window.craft, defined in types/craft.d.ts):
49
53
  * AR (ARKit/ARCore), ML (Core ML/ML Kit), Deep Links, OTA Updates,
50
54
  * Widgets, Auth Persistence, Contacts, Calendar, Health/Fitness,
@@ -1204,6 +1208,22 @@ export interface CraftBridgeAPI {
1204
1208
  * Screen-sharing and screen-recording detection (macOS)
1205
1209
  */
1206
1210
  screenSharing?: CraftScreenSharingAPI;
1211
+ /**
1212
+ * Trigger one haptic tap on a Force Touch trackpad (macOS), as
1213
+ * `window.craft.haptic` does on iOS and Android.
1214
+ *
1215
+ * Resolves `true` once AppKit has taken the call, which is not a promise
1216
+ * anything was felt: AppKit plays feedback only while a finger is on the
1217
+ * trackpad and the app is active. Rejects `PLATFORM_NOT_SUPPORTED` on Linux
1218
+ * and Windows.
1219
+ */
1220
+ haptic?: (style?: string) => Promise<boolean>;
1221
+ /**
1222
+ * Haptic feedback with the shape the mobile bridges give it (macOS: Force
1223
+ * Touch trackpad). Use `haptics` from `craft-native` rather than this
1224
+ * directly. See `CraftHapticsAPI`.
1225
+ */
1226
+ haptics?: CraftHapticsAPI;
1207
1227
  /**
1208
1228
  * System-wide hotkeys (macOS).
1209
1229
  *
@@ -1547,6 +1567,25 @@ export interface ScreenSharingState {
1547
1567
  };
1548
1568
  sources: ScreenSharingSource[];
1549
1569
  }
1570
+ /**
1571
+ * `window.craft.haptics` in a desktop window.
1572
+ *
1573
+ * Feedback, not a capability check: on a host with nothing to play (Linux,
1574
+ * Windows) every method resolves without doing anything, as the mobile
1575
+ * bridges do for an app built without haptics. Use `craft.haptic()` to find
1576
+ * out instead.
1577
+ *
1578
+ * A trackpad has three patterns, not the phone's range, so styles are folded:
1579
+ * `selection` plays Alignment, `heavy` and `error` play LevelChange, and
1580
+ * everything else plays Generic.
1581
+ */
1582
+ export interface CraftHapticsAPI {
1583
+ impact(style?: string): Promise<void>;
1584
+ notification(type?: 'success' | 'warning' | 'error'): Promise<void>;
1585
+ selection(): Promise<void>;
1586
+ /** One tap if the pattern fires at all: a trackpad tap has no duration. */
1587
+ vibrate(pattern?: number[]): Promise<void>;
1588
+ }
1550
1589
  /**
1551
1590
  * Screen-sharing detection. Matches the sharing *indicator* a conferencing app
1552
1591
  * shows while a share is live, never the mere presence of the app — see
@@ -1604,6 +1643,47 @@ export interface CraftFileSystemAPI {
1604
1643
  * @param path - Path to check
1605
1644
  */
1606
1645
  exists(path: string): Promise<boolean>;
1646
+ /**
1647
+ * Watch a file or directory (desktop bridge). Resolves once native has
1648
+ * registered the watch; `callback` hears the `craft:fs:change` events for
1649
+ * this watch only. On macOS each watch is an FSEvents stream; it lasts
1650
+ * until `unwatch`, until the page navigates, or until its window is
1651
+ * destroyed, and the path must exist (`NOT_FOUND` otherwise). Rejects with
1652
+ * `PLATFORM_NOT_SUPPORTED` on Linux and Windows.
1653
+ * @param path - Path to watch
1654
+ * @param callback - Called with each change to this watch
1655
+ * @param options - `recursive` defaults to false
1656
+ */
1657
+ watch?: (path: string, callback?: (event: CraftFsWatchEvent) => void, options?: {
1658
+ recursive?: boolean;
1659
+ }) => Promise<CraftFsWatchHandle>;
1660
+ /**
1661
+ * Stop a watch by its id. The same as the handle's `unwatch()`.
1662
+ * @param id - The `id` of the handle `watch` resolved with
1663
+ */
1664
+ unwatch?: (id: string) => Promise<void>;
1665
+ }
1666
+ /**
1667
+ * One change to a watched path, as the `craft:fs:change` event's detail.
1668
+ */
1669
+ export interface CraftFsWatchEvent {
1670
+ /** The id of the watch it belongs to */
1671
+ id: string;
1672
+ /**
1673
+ * What happened. Both ends of a rename report `rename`; the old name is the
1674
+ * one that no longer exists.
1675
+ */
1676
+ type: 'create' | 'modify' | 'delete' | 'rename';
1677
+ /** The path that changed */
1678
+ path: string;
1679
+ }
1680
+ /**
1681
+ * A registered watch. `unwatch()` stops it; calling it again does nothing.
1682
+ */
1683
+ export interface CraftFsWatchHandle {
1684
+ /** The id the page generated and native registered the watch under */
1685
+ id: string;
1686
+ unwatch(): Promise<void>;
1607
1687
  }
1608
1688
  /**
1609
1689
  * Database API (SQLite)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "craft-native",
3
- "version": "0.0.112",
3
+ "version": "0.0.115",
4
4
  "type": "module",
5
5
  "description": "Build desktop apps with web languages - TypeScript SDK for Craft",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",