@craft-native/react 0.0.92 → 0.0.94
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/hooks/useDatabase.d.ts +13 -0
- package/dist/hooks/useDatabase.d.ts.map +1 -0
- package/dist/hooks/useFileSystem.d.ts +15 -0
- package/dist/hooks/useFileSystem.d.ts.map +1 -0
- package/dist/hooks/useHttp.d.ts +21 -0
- package/dist/hooks/useHttp.d.ts.map +1 -0
- package/dist/hooks/useNotification.d.ts +20 -0
- package/dist/hooks/useNotification.d.ts.map +1 -0
- package/dist/hooks/useTray.d.ts +22 -0
- package/dist/hooks/useTray.d.ts.map +1 -0
- package/dist/hooks/useWindow.d.ts +19 -0
- package/dist/hooks/useWindow.d.ts.map +1 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +652 -0
- package/dist/index.mjs +612 -0
- package/package.json +3 -3
- package/LICENSE.md +0 -21
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to interact with SQLite database
|
|
3
|
+
*/
|
|
4
|
+
export declare function useDatabase(dbPath: string): {
|
|
5
|
+
execute: (sql: string, params?: any[]) => Promise<any>;
|
|
6
|
+
query: <T = any>(sql: string, params?: any[]) => Promise<T[]>;
|
|
7
|
+
transaction: (callback: (tx: {
|
|
8
|
+
execute: (sql: string, params?: any[]) => Promise<any>;
|
|
9
|
+
}) => Promise<void>) => Promise<void>;
|
|
10
|
+
loading: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDatabase.d.ts","sourceRoot":"","sources":["../../src/hooks/useDatabase.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM;mBAM1B,MAAM,WAAU,GAAG,EAAE;YAoB1B,CAAC,aAAa,MAAM,WAAU,GAAG,EAAE,KAAQ,OAAO,CAAC,CAAC,EAAE,CAAC;4BAoB7C,CAAC,EAAE,EAAE;QAAE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC;;;EAqCrG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to interact with the file system
|
|
3
|
+
*/
|
|
4
|
+
export declare function useFileSystem(): {
|
|
5
|
+
readFile: (path: string, encoding?: 'utf8' | 'binary') => Promise<any>;
|
|
6
|
+
writeFile: (path: string, data: string | Uint8Array, encoding?: 'utf8' | 'binary') => Promise<void>;
|
|
7
|
+
readDir: (path: string) => Promise<any>;
|
|
8
|
+
mkdir: (path: string, recursive?: boolean) => Promise<void>;
|
|
9
|
+
remove: (path: string, recursive?: boolean) => Promise<void>;
|
|
10
|
+
exists: (path: string) => Promise<any>;
|
|
11
|
+
stat: (path: string) => Promise<any>;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
error: Error | null;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useFileSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFileSystem.d.ts","sourceRoot":"","sources":["../../src/hooks/useFileSystem.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa;qBAMZ,MAAM,aAAY,MAAM,GAAG,QAAQ;sBAoBnC,MAAM,QAAQ,MAAM,GAAG,UAAU,aAAY,MAAM,GAAG,QAAQ;oBAmB9D,MAAM;kBAoBN,MAAM;mBAmBN,MAAM;mBAmBN,MAAM;iBAeN,MAAM;;;EA8BtB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface HttpOptions {
|
|
2
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
3
|
+
headers?: Record<string, string>;
|
|
4
|
+
body?: any;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
interface DownloadOptions {
|
|
8
|
+
onProgress?: (progress: number) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Hook to make HTTP requests
|
|
12
|
+
*/
|
|
13
|
+
export declare function useHttp(): {
|
|
14
|
+
fetch: <T = any>(url: string, options?: HttpOptions) => Promise<T>;
|
|
15
|
+
download: (url: string, path: string, options?: DownloadOptions) => Promise<void>;
|
|
16
|
+
upload: (url: string, filePath: string, options?: HttpOptions & DownloadOptions) => Promise<any>;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
error: Error | null;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=useHttp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHttp.d.ts","sourceRoot":"","sources":["../../src/hooks/useHttp.ts"],"names":[],"mappings":"AAGA,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,eAAe;IACvB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED;;GAEG;AACH,wBAAgB,OAAO;YAMZ,CAAC,aAAa,MAAM,YAAW,WAAW,KAAQ,OAAO,CAAC,CAAC,CAAC;oBAoBvD,MAAM,QAAQ,MAAM,YAAW,eAAe;kBA4B9C,MAAM,YAAY,MAAM,YAAW,WAAW,GAAG,eAAe;;;EAmC/E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface NotificationOptions {
|
|
2
|
+
title: string;
|
|
3
|
+
body?: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
silent?: boolean;
|
|
6
|
+
tag?: string;
|
|
7
|
+
actions?: Array<{
|
|
8
|
+
action: string;
|
|
9
|
+
title: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Hook to send system notifications
|
|
14
|
+
*/
|
|
15
|
+
export declare function useNotification(): {
|
|
16
|
+
send: (options: NotificationOptions) => Promise<void>;
|
|
17
|
+
requestPermission: () => Promise<boolean>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=useNotification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotification.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotification.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,wBAAgB,eAAe;oBAIX,mBAAmB;;EAiBtC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface TrayMenuItem {
|
|
2
|
+
label: string;
|
|
3
|
+
id: string;
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
type?: 'normal' | 'separator' | 'checkbox';
|
|
7
|
+
submenu?: TrayMenuItem[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook to manage system tray icon
|
|
11
|
+
*/
|
|
12
|
+
export declare function useTray(): {
|
|
13
|
+
isVisible: boolean;
|
|
14
|
+
create: (icon?: string, tooltip?: string) => Promise<void>;
|
|
15
|
+
destroy: () => Promise<void>;
|
|
16
|
+
setIcon: (icon: string) => Promise<void>;
|
|
17
|
+
setTooltip: (tooltip: string) => Promise<void>;
|
|
18
|
+
setMenu: (menu: TrayMenuItem[]) => Promise<void>;
|
|
19
|
+
setTitle: (title: string) => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=useTray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTray.d.ts","sourceRoot":"","sources":["../../src/hooks/useTray.ts"],"names":[],"mappings":"AAGA,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;IAC3C,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,OAAO;;oBAKL,MAAM,YAAY,MAAM;;oBAezB,MAAM;0BAQH,MAAM;oBAQT,YAAY,EAAE;sBAQb,MAAM;EAgBvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to manage application window
|
|
3
|
+
*/
|
|
4
|
+
export declare function useWindow(): {
|
|
5
|
+
isFullscreen: boolean;
|
|
6
|
+
isMaximized: boolean;
|
|
7
|
+
isMinimized: boolean;
|
|
8
|
+
setTitle: (title: string) => Promise<void>;
|
|
9
|
+
setSize: (width: number, height: number) => Promise<void>;
|
|
10
|
+
setPosition: (x: number, y: number) => Promise<void>;
|
|
11
|
+
maximize: () => Promise<void>;
|
|
12
|
+
minimize: () => Promise<void>;
|
|
13
|
+
restore: () => Promise<void>;
|
|
14
|
+
toggleFullscreen: () => Promise<void>;
|
|
15
|
+
close: () => Promise<void>;
|
|
16
|
+
center: () => Promise<void>;
|
|
17
|
+
setAlwaysOnTop: (alwaysOnTop: boolean) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=useWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindow.d.ts","sourceRoot":"","sources":["../../src/hooks/useWindow.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,wBAAgB,SAAS;;;;sBAOP,MAAM;qBAQN,MAAM,UAAU,MAAM;qBAQ1B,MAAM,KAAK,MAAM;;;;;;;kCA2CP,OAAO;EAsB9B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
interface CraftAPI {
|
|
2
|
+
getPlatform(): Promise<{
|
|
3
|
+
platform: string;
|
|
4
|
+
version: string;
|
|
5
|
+
}>;
|
|
6
|
+
getDeviceInfo(): Promise<{
|
|
7
|
+
platform: string;
|
|
8
|
+
model: string;
|
|
9
|
+
os_version: string;
|
|
10
|
+
}>;
|
|
11
|
+
showToast(message: string, duration: 'short' | 'long'): Promise<void>;
|
|
12
|
+
haptic(type: string): Promise<void>;
|
|
13
|
+
requestPermission(permission: string): Promise<{
|
|
14
|
+
granted: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
on(event: string, callback: (...args: any[]) => void): void;
|
|
18
|
+
off(event: string, callback: (...args: any[]) => void): void;
|
|
19
|
+
emit(event: string, data?: any): void;
|
|
20
|
+
invoke(method: string, params?: any): Promise<any>;
|
|
21
|
+
}
|
|
22
|
+
declare global {
|
|
23
|
+
interface Window {
|
|
24
|
+
craft?: CraftAPI;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook to access the Craft API
|
|
29
|
+
* @returns The Craft API object or null if not available
|
|
30
|
+
*/
|
|
31
|
+
export declare function useCraft(): {
|
|
32
|
+
craft: CraftAPI | null;
|
|
33
|
+
isReady: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Hook to get platform information
|
|
37
|
+
* @returns Platform information and loading state
|
|
38
|
+
*/
|
|
39
|
+
export declare function usePlatform(): {
|
|
40
|
+
platform: {
|
|
41
|
+
platform: string;
|
|
42
|
+
version: string;
|
|
43
|
+
} | null;
|
|
44
|
+
loading: boolean;
|
|
45
|
+
error: Error | null;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Hook to get device information
|
|
49
|
+
* @returns Device information and loading state
|
|
50
|
+
*/
|
|
51
|
+
export declare function useDeviceInfo(): {
|
|
52
|
+
deviceInfo: {
|
|
53
|
+
platform: string;
|
|
54
|
+
model: string;
|
|
55
|
+
os_version: string;
|
|
56
|
+
} | null;
|
|
57
|
+
loading: boolean;
|
|
58
|
+
error: Error | null;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Hook to show toast notifications
|
|
62
|
+
* @returns Function to show toast
|
|
63
|
+
*/
|
|
64
|
+
export declare function useToast(): {
|
|
65
|
+
showToast: (message: string, duration?: 'short' | 'long') => Promise<void>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Hook to trigger haptic feedback
|
|
69
|
+
* @returns Function to trigger haptic
|
|
70
|
+
*/
|
|
71
|
+
export declare function useHaptic(): {
|
|
72
|
+
haptic: (type?: string) => Promise<void>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Hook to request permissions
|
|
76
|
+
* @returns Function to request permission and permission state
|
|
77
|
+
*/
|
|
78
|
+
export declare function usePermission(permission: string): {
|
|
79
|
+
granted: boolean | null;
|
|
80
|
+
request: () => Promise<void>;
|
|
81
|
+
loading: boolean;
|
|
82
|
+
error: Error | null;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Hook to listen to Craft events
|
|
86
|
+
* @param event Event name to listen to
|
|
87
|
+
* @param callback Callback function
|
|
88
|
+
*/
|
|
89
|
+
export declare function useCraftEvent(event: string, callback: (...args: any[]) => void): void;
|
|
90
|
+
/**
|
|
91
|
+
* Hook to invoke Craft methods
|
|
92
|
+
* @returns Function to invoke methods
|
|
93
|
+
*/
|
|
94
|
+
export declare function useCraftInvoke(): {
|
|
95
|
+
invoke: (method: string, params?: any) => Promise<any>;
|
|
96
|
+
isReady: boolean;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Hook to check if running on mobile
|
|
100
|
+
* @returns Whether running on mobile platform
|
|
101
|
+
*/
|
|
102
|
+
export declare function useIsMobile(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Hook to check if running on desktop
|
|
105
|
+
* @returns Whether running on desktop platform
|
|
106
|
+
*/
|
|
107
|
+
export declare function useIsDesktop(): boolean;
|
|
108
|
+
export * from './hooks/useWindow';
|
|
109
|
+
export * from './hooks/useTray';
|
|
110
|
+
export * from './hooks/useNotification';
|
|
111
|
+
export * from './hooks/useFileSystem';
|
|
112
|
+
export * from './hooks/useDatabase';
|
|
113
|
+
export * from './hooks/useHttp';
|
|
114
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,UAAU,QAAQ;IAChB,WAAW,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,aAAa,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClF,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,iBAAiB,CAAC,UAAU,EA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