@craft-native/react 0.0.72
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 +368 -0
- 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 +648 -0
- package/dist/index.mjs +608 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# @craft-native/react
|
|
2
|
+
|
|
3
|
+
React bindings for the Craft framework. Provides hooks to access native functionality in your React applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @craft-native/react
|
|
9
|
+
# or
|
|
10
|
+
yarn add @craft-native/react
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @craft-native/react
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Core Hooks
|
|
18
|
+
|
|
19
|
+
#### useCraft
|
|
20
|
+
|
|
21
|
+
Access the Craft API:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { useCraft } from '@craft-native/react';
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
const { craft, isReady } = useCraft();
|
|
28
|
+
|
|
29
|
+
if (!isReady) {
|
|
30
|
+
return <div>Loading...</div>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return <div>Craft is ready!</div>;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### usePlatform
|
|
38
|
+
|
|
39
|
+
Get platform information:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { usePlatform } from '@craft-native/react';
|
|
43
|
+
|
|
44
|
+
function PlatformInfo() {
|
|
45
|
+
const { platform, loading } = usePlatform();
|
|
46
|
+
|
|
47
|
+
if (loading) return <div>Loading...</div>;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div>
|
|
51
|
+
Platform: {platform?.platform}
|
|
52
|
+
Version: {platform?.version}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### useDeviceInfo
|
|
59
|
+
|
|
60
|
+
Get device information:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { useDeviceInfo } from '@craft-native/react';
|
|
64
|
+
|
|
65
|
+
function DeviceInfo() {
|
|
66
|
+
const { deviceInfo } = useDeviceInfo();
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div>
|
|
70
|
+
Model: {deviceInfo?.model}
|
|
71
|
+
OS: {deviceInfo?.os_version}
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### UI Hooks
|
|
78
|
+
|
|
79
|
+
#### useToast
|
|
80
|
+
|
|
81
|
+
Show toast notifications:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { useToast } from '@craft-native/react';
|
|
85
|
+
|
|
86
|
+
function ToastExample() {
|
|
87
|
+
const { showToast } = useToast();
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<button onClick={() => showToast('Hello!', 'short')}>
|
|
91
|
+
Show Toast
|
|
92
|
+
</button>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### useHaptic
|
|
98
|
+
|
|
99
|
+
Trigger haptic feedback:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { useHaptic } from '@craft-native/react';
|
|
103
|
+
|
|
104
|
+
function HapticButton() {
|
|
105
|
+
const { haptic } = useHaptic();
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<button onClick={() => haptic('impact_medium')}>
|
|
109
|
+
Tap Me
|
|
110
|
+
</button>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### usePermission
|
|
116
|
+
|
|
117
|
+
Request permissions:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { usePermission } from '@craft-native/react';
|
|
121
|
+
|
|
122
|
+
function CameraPermission() {
|
|
123
|
+
const { granted, request, loading } = usePermission('camera');
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div>
|
|
127
|
+
{granted === null && (
|
|
128
|
+
<button onClick={request} disabled={loading}>
|
|
129
|
+
Request Camera Access
|
|
130
|
+
</button>
|
|
131
|
+
)}
|
|
132
|
+
{granted && <div>Camera access granted!</div>}
|
|
133
|
+
{granted === false && <div>Camera access denied</div>}
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Window Management
|
|
140
|
+
|
|
141
|
+
#### useWindow
|
|
142
|
+
|
|
143
|
+
Manage the application window:
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { useWindow } from '@craft-native/react';
|
|
147
|
+
|
|
148
|
+
function WindowControls() {
|
|
149
|
+
const { maximize, minimize, toggleFullscreen, isFullscreen } = useWindow();
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<div>
|
|
153
|
+
<button onClick={maximize}>Maximize</button>
|
|
154
|
+
<button onClick={minimize}>Minimize</button>
|
|
155
|
+
<button onClick={toggleFullscreen}>
|
|
156
|
+
{isFullscreen ? 'Exit' : 'Enter'} Fullscreen
|
|
157
|
+
</button>
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### System Integration
|
|
164
|
+
|
|
165
|
+
#### useTray
|
|
166
|
+
|
|
167
|
+
Manage system tray icon:
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { useTray } from '@craft-native/react';
|
|
171
|
+
|
|
172
|
+
function TrayManager() {
|
|
173
|
+
const { create, setMenu } = useTray();
|
|
174
|
+
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
create('/path/to/icon.png', 'My App');
|
|
177
|
+
setMenu([
|
|
178
|
+
{ id: 'show', label: 'Show Window' },
|
|
179
|
+
{ id: 'quit', label: 'Quit', type: 'normal' },
|
|
180
|
+
]);
|
|
181
|
+
}, []);
|
|
182
|
+
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### useNotification
|
|
188
|
+
|
|
189
|
+
Send system notifications:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { useNotification } from '@craft-native/react';
|
|
193
|
+
|
|
194
|
+
function NotificationExample() {
|
|
195
|
+
const { send } = useNotification();
|
|
196
|
+
|
|
197
|
+
const notify = () => {
|
|
198
|
+
send({
|
|
199
|
+
title: 'Hello!',
|
|
200
|
+
body: 'This is a notification',
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return <button onClick={notify}>Notify</button>;
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### File System
|
|
209
|
+
|
|
210
|
+
#### useFileSystem
|
|
211
|
+
|
|
212
|
+
Interact with the file system:
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { useFileSystem } from '@craft-native/react';
|
|
216
|
+
|
|
217
|
+
function FileEditor() {
|
|
218
|
+
const { readFile, writeFile, loading, error } = useFileSystem();
|
|
219
|
+
const [content, setContent] = useState('');
|
|
220
|
+
|
|
221
|
+
const load = async () => {
|
|
222
|
+
const data = await readFile('/path/to/file.txt');
|
|
223
|
+
setContent(data);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const save = async () => {
|
|
227
|
+
await writeFile('/path/to/file.txt', content);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
<div>
|
|
232
|
+
<textarea value={content} onChange={(e) => setContent(e.target.value)} />
|
|
233
|
+
<button onClick={load}>Load</button>
|
|
234
|
+
<button onClick={save}>Save</button>
|
|
235
|
+
{loading && <div>Loading...</div>}
|
|
236
|
+
{error && <div>Error: {error.message}</div>}
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Database
|
|
243
|
+
|
|
244
|
+
#### useDatabase
|
|
245
|
+
|
|
246
|
+
Work with SQLite databases:
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import { useDatabase } from '@craft-native/react';
|
|
250
|
+
|
|
251
|
+
function TodoList() {
|
|
252
|
+
const { query, execute } = useDatabase('/path/to/db.sqlite');
|
|
253
|
+
const [todos, setTodos] = useState([]);
|
|
254
|
+
|
|
255
|
+
useEffect(() => {
|
|
256
|
+
loadTodos();
|
|
257
|
+
}, []);
|
|
258
|
+
|
|
259
|
+
const loadTodos = async () => {
|
|
260
|
+
const results = await query('SELECT * FROM todos');
|
|
261
|
+
setTodos(results);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const addTodo = async (title: string) => {
|
|
265
|
+
await execute('INSERT INTO todos (title) VALUES (?)', [title]);
|
|
266
|
+
await loadTodos();
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
return (
|
|
270
|
+
<ul>
|
|
271
|
+
{todos.map((todo) => (
|
|
272
|
+
<li key={todo.id}>{todo.title}</li>
|
|
273
|
+
))}
|
|
274
|
+
</ul>
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### HTTP Requests
|
|
280
|
+
|
|
281
|
+
#### useHttp
|
|
282
|
+
|
|
283
|
+
Make HTTP requests:
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import { useHttp } from '@craft-native/react';
|
|
287
|
+
|
|
288
|
+
function ApiExample() {
|
|
289
|
+
const { fetch, loading } = useHttp();
|
|
290
|
+
const [data, setData] = useState(null);
|
|
291
|
+
|
|
292
|
+
const loadData = async () => {
|
|
293
|
+
const result = await fetch('https://api.example.com/data');
|
|
294
|
+
setData(result);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<div>
|
|
299
|
+
<button onClick={loadData} disabled={loading}>
|
|
300
|
+
Load Data
|
|
301
|
+
</button>
|
|
302
|
+
{data && <pre>{JSON.stringify(data, null, 2)}</pre>}
|
|
303
|
+
</div>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Event Handling
|
|
309
|
+
|
|
310
|
+
#### useCraftEvent
|
|
311
|
+
|
|
312
|
+
Listen to Craft events:
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
import { useCraftEvent } from '@craft-native/react';
|
|
316
|
+
|
|
317
|
+
function EventListener() {
|
|
318
|
+
useCraftEvent('app.ready', () => {
|
|
319
|
+
console.log('App is ready!');
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
useCraftEvent('window.close', () => {
|
|
323
|
+
console.log('Window is closing');
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
return <div>Listening to events...</div>;
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Utility Hooks
|
|
331
|
+
|
|
332
|
+
#### useIsMobile
|
|
333
|
+
|
|
334
|
+
Check if running on mobile:
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
import { useIsMobile } from '@craft-native/react';
|
|
338
|
+
|
|
339
|
+
function ResponsiveComponent() {
|
|
340
|
+
const isMobile = useIsMobile();
|
|
341
|
+
|
|
342
|
+
return <div>{isMobile ? 'Mobile View' : 'Desktop View'}</div>;
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
#### useIsDesktop
|
|
347
|
+
|
|
348
|
+
Check if running on desktop:
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
import { useIsDesktop } from '@craft-native/react';
|
|
352
|
+
|
|
353
|
+
function DesktopOnly() {
|
|
354
|
+
const isDesktop = useIsDesktop();
|
|
355
|
+
|
|
356
|
+
if (!isDesktop) return null;
|
|
357
|
+
|
|
358
|
+
return <div>Desktop-only features</div>;
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## API Reference
|
|
363
|
+
|
|
364
|
+
See the [TypeScript definitions](./dist/index.d.ts) for complete API documentation.
|
|
365
|
+
|
|
366
|
+
## License
|
|
367
|
+
|
|
368
|
+
MIT
|
|
@@ -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,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtF,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5D,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAC7D,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACtC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,KAAK,CAAC,EAAE,QAAQ,CAAC;KAClB;CACF;AAED;;;GAGG;AACH,wBAAgB,QAAQ;;;EAwBvB;AAED;;;GAGG;AACH,wBAAgB,WAAW;;kBAE4B,MAAM;iBAAW,MAAM;;;;EAc7E;AAED;;;GAGG;AACH,wBAAgB,aAAa;;kBAE8B,MAAM;eAAS,MAAM;oBAAc,MAAM;;;;EAcnG;AAED;;;GAGG;AACH,wBAAgB,QAAQ;yBAIJ,MAAM,aAAY,OAAO,GAAG,MAAM;EAWrD;AAED;;;GAGG;AACH,wBAAgB,SAAS;oBAIR,MAAM;EAWtB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM;;;;;EA0B/C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,QAkB9E;AAED;;;GAGG;AACH,wBAAgB,cAAc;qBAIX,MAAM,WAAW,GAAG;;EAUtC;AAED;;;GAGG;AACH,wBAAgB,WAAW,YAO1B;AAED;;;GAGG;AACH,wBAAgB,YAAY,YAO3B;AAGD,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|