deskforge 1.0.0 → 1.0.1
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/COMPLETION_REPORT.md +426 -0
- package/COMPONENT_API.md +529 -0
- package/DELIVERY_SUMMARY.md +455 -0
- package/IMPLEMENTATION_GUIDE.md +385 -0
- package/IMPORT_GUIDE.md +404 -0
- package/QUICK_REFERENCE.md +352 -0
- package/README.md +245 -31
- package/README_UI_COMPLETE.md +395 -0
- package/TYPE_DEFINITIONS.md +671 -0
- package/UI_GETTING_STARTED.md +523 -0
- package/examples/deskforge-app/App.ts +7 -11
- package/examples/deskforge-app/screens/CounterApp.ts +181 -0
- package/examples/deskforge-app/screens/GalleryApp.ts +267 -0
- package/examples/deskforge-app/screens/NotesApp.ts +376 -0
- package/examples/deskforge-app/screens/SettingsApp.ts +226 -0
- package/examples/deskforge-app/screens/TodoApp.ts +288 -0
- package/examples/deskforge-app/screens/index.ts +50 -0
- package/package.json +1 -1
- package/packages/cli/dist/commands/start.d.ts +7 -1
- package/packages/cli/dist/commands/start.d.ts.map +1 -1
- package/packages/cli/dist/commands/start.js +75 -21
- package/packages/cli/dist/commands/start.js.map +1 -1
- package/packages/cli/src/commands/start.ts +93 -21
- package/packages/cli/test/start.test.js +24 -0
- package/packages/core/dist/index.d.ts +1 -0
- package/packages/core/dist/index.d.ts.map +1 -1
- package/packages/core/dist/index.js +1 -0
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/style/StyleObject.d.ts +115 -0
- package/packages/core/dist/style/StyleObject.d.ts.map +1 -0
- package/packages/core/dist/style/StyleObject.js +6 -0
- package/packages/core/dist/style/StyleObject.js.map +1 -0
- package/packages/core/dist/style/StyleSheet.d.ts +7 -0
- package/packages/core/dist/style/StyleSheet.d.ts.map +1 -0
- package/packages/core/dist/style/StyleSheet.js +13 -0
- package/packages/core/dist/style/StyleSheet.js.map +1 -0
- package/packages/core/dist/style/index.d.ts +3 -0
- package/packages/core/dist/style/index.d.ts.map +1 -0
- package/packages/core/dist/style/index.js +21 -0
- package/packages/core/dist/style/index.js.map +1 -0
- package/packages/core/src/index.ts +2 -1
- package/packages/core/src/style/StyleObject.ts +134 -0
- package/packages/core/src/style/StyleSheet.ts +19 -0
- package/packages/core/src/style/index.ts +5 -0
- package/packages/db/src/db.ts +4 -4
- package/packages/deskforge/src/index.ts +95 -0
- package/packages/file/dist/file.d.ts +1 -1
- package/packages/file/dist/file.d.ts.map +1 -1
- package/packages/file/dist/file.js +75 -3
- package/packages/file/dist/file.js.map +1 -1
- package/packages/file/src/file.ts +96 -4
- package/packages/file/test/file.test.js +23 -0
- package/packages/router/dist/index.d.ts +1 -0
- package/packages/router/dist/index.d.ts.map +1 -1
- package/packages/router/dist/index.js +1 -0
- package/packages/router/dist/index.js.map +1 -1
- package/packages/router/dist/navigation.d.ts +23 -0
- package/packages/router/dist/navigation.d.ts.map +1 -0
- package/packages/router/dist/navigation.js +61 -0
- package/packages/router/dist/navigation.js.map +1 -0
- package/packages/router/src/index.ts +2 -1
- package/packages/router/src/navigation.ts +86 -0
- package/packages/router/test/router.test.js +21 -1
- package/packages/theme/src/theme.ts +23 -0
- package/packages/ui/src/base/Button.ts +67 -0
- package/packages/ui/src/base/Image.ts +59 -0
- package/packages/ui/src/base/Pressable.ts +69 -0
- package/packages/ui/src/base/Text.ts +42 -0
- package/packages/ui/src/base/TextInput.ts +113 -0
- package/packages/ui/src/base/TouchableOpacity.ts +52 -0
- package/packages/ui/src/base/View.ts +43 -0
- package/packages/ui/src/index.ts +40 -25
- package/packages/ui/src/input/CheckBox.ts +69 -0
- package/packages/ui/src/input/Slider.ts +19 -2
- package/packages/ui/src/input/Switch.ts +68 -0
- package/packages/ui/src/layout/KeyboardAvoidingView.ts +65 -0
- package/packages/ui/src/layout/SafeAreaView.ts +58 -0
- package/packages/ui/src/list/FlatList.ts +111 -0
- package/packages/ui/src/list/ScrollView.ts +80 -0
- package/packages/ui/src/list/SectionList.ts +120 -0
- package/packages/ui/src/overlay/ActivityIndicator.ts +70 -0
- package/packages/ui/src/overlay/Modal.ts +28 -6
- package/packages/ui/src/platform/Platform.ts +119 -0
- package/packages/ui/src/platform/StatusBar.ts +63 -0
package/IMPORT_GUIDE.md
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeskForge - Import Guide
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive guide to importing from DeskForge packages
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
# DeskForge Import Guide
|
|
8
|
+
|
|
9
|
+
## Monorepo Structure
|
|
10
|
+
|
|
11
|
+
DeskForge is organized as a monorepo with scoped packages under `@deskforge`:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
packages/
|
|
15
|
+
├── core/ → @deskforge/core
|
|
16
|
+
├── ui/ → @deskforge/ui
|
|
17
|
+
├── state/ → @deskforge/state
|
|
18
|
+
├── router/ → @deskforge/router
|
|
19
|
+
├── db/ → @deskforge/db
|
|
20
|
+
├── notifications/ → @deskforge/notifications
|
|
21
|
+
├── theme/ → @deskforge/theme
|
|
22
|
+
├── file/ → @deskforge/file
|
|
23
|
+
├── network/ → @deskforge/network
|
|
24
|
+
├── ai/ → @deskforge/ai
|
|
25
|
+
├── security/ → @deskforge/security
|
|
26
|
+
├── bridge/ → @deskforge/bridge
|
|
27
|
+
├── background/ → @deskforge/background
|
|
28
|
+
├── payments/ → @deskforge/payments
|
|
29
|
+
├── i18n/ → @deskforge/i18n
|
|
30
|
+
├── logger/ → @deskforge/logger
|
|
31
|
+
├── updater/ → @deskforge/updater
|
|
32
|
+
├── cli/ → @deskforge/cli
|
|
33
|
+
└── deskforge/ → Main barrel export (re-exports everything)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Import Patterns
|
|
39
|
+
|
|
40
|
+
### Option 1: Import Everything from Main Package ⭐ Recommended for Most Apps
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import {
|
|
44
|
+
// UI Components
|
|
45
|
+
View,
|
|
46
|
+
Text,
|
|
47
|
+
Button,
|
|
48
|
+
FlatList,
|
|
49
|
+
|
|
50
|
+
// State Management
|
|
51
|
+
State,
|
|
52
|
+
Computed,
|
|
53
|
+
Effect,
|
|
54
|
+
|
|
55
|
+
// Other packages
|
|
56
|
+
DB,
|
|
57
|
+
Toast,
|
|
58
|
+
Router,
|
|
59
|
+
} from 'deskforge'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Use Case:** Simple apps that use multiple packages. One import statement gets everything.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### Option 2: Import from Specific Packages ⭐ Recommended for Libraries/Large Apps
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// UI Components
|
|
70
|
+
import { View, Text, Button, StyleSheet } from '@deskforge/ui'
|
|
71
|
+
|
|
72
|
+
// State Management
|
|
73
|
+
import { State, Computed, Effect, Watch } from '@deskforge/state'
|
|
74
|
+
|
|
75
|
+
// Router
|
|
76
|
+
import { Router, Screen } from '@deskforge/router'
|
|
77
|
+
|
|
78
|
+
// Database
|
|
79
|
+
import { DB } from '@deskforge/db'
|
|
80
|
+
|
|
81
|
+
// Notifications
|
|
82
|
+
import { Toast, Notify } from '@deskforge/notifications'
|
|
83
|
+
|
|
84
|
+
// Theme
|
|
85
|
+
import { Theme } from '@deskforge/theme'
|
|
86
|
+
|
|
87
|
+
// File System
|
|
88
|
+
import { File } from '@deskforge/file'
|
|
89
|
+
|
|
90
|
+
// Networking
|
|
91
|
+
import { Network, P2P } from '@deskforge/network'
|
|
92
|
+
|
|
93
|
+
// AI
|
|
94
|
+
import { createBrain } from '@deskforge/ai'
|
|
95
|
+
|
|
96
|
+
// Security
|
|
97
|
+
import { Biometric, Encrypt } from '@deskforge/security'
|
|
98
|
+
|
|
99
|
+
// Bridge
|
|
100
|
+
import { Bridge } from '@deskforge/bridge'
|
|
101
|
+
|
|
102
|
+
// Background Tasks
|
|
103
|
+
import { Background, Schedule } from '@deskforge/background'
|
|
104
|
+
|
|
105
|
+
// Payments
|
|
106
|
+
import { Payment } from '@deskforge/payments'
|
|
107
|
+
|
|
108
|
+
// Internationalization
|
|
109
|
+
import { i18n } from '@deskforge/i18n'
|
|
110
|
+
|
|
111
|
+
// Logger
|
|
112
|
+
import { Logger } from '@deskforge/logger'
|
|
113
|
+
|
|
114
|
+
// Updater
|
|
115
|
+
import { Updater } from '@deskforge/updater'
|
|
116
|
+
|
|
117
|
+
// CLI (Node.js/CLI contexts only)
|
|
118
|
+
import { CLI } from '@deskforge/cli'
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Use Case:**
|
|
122
|
+
- Large applications where you want explicit imports
|
|
123
|
+
- Libraries where you need specific features
|
|
124
|
+
- When you want to avoid loading unused code
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Common Import Patterns
|
|
129
|
+
|
|
130
|
+
### Simple App
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { View, Text, Button, State, StyleSheet } from 'deskforge'
|
|
134
|
+
|
|
135
|
+
const MyApp = () => {
|
|
136
|
+
const state = State({ count: 0 })
|
|
137
|
+
|
|
138
|
+
return View({ flex: 1 }, [
|
|
139
|
+
Text(`Count: ${state.count}`),
|
|
140
|
+
Button('Increment', {}, { onPress: () => state.count++ }),
|
|
141
|
+
])
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Complex App with Multiple Packages
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import {
|
|
149
|
+
View,
|
|
150
|
+
Text,
|
|
151
|
+
FlatList,
|
|
152
|
+
StyleSheet,
|
|
153
|
+
Platform,
|
|
154
|
+
} from '@deskforge/ui'
|
|
155
|
+
|
|
156
|
+
import {
|
|
157
|
+
State,
|
|
158
|
+
Computed,
|
|
159
|
+
Effect,
|
|
160
|
+
} from '@deskforge/state'
|
|
161
|
+
|
|
162
|
+
import { DB } from '@deskforge/db'
|
|
163
|
+
import { Toast } from '@deskforge/notifications'
|
|
164
|
+
import { Router } from '@deskforge/router'
|
|
165
|
+
import { Theme } from '@deskforge/theme'
|
|
166
|
+
|
|
167
|
+
export const ComplexApp = () => {
|
|
168
|
+
const state = State({ items: [], loading: false })
|
|
169
|
+
const itemCount = Computed(() => state.items.length)
|
|
170
|
+
|
|
171
|
+
Effect(() => {
|
|
172
|
+
// Load items on mount
|
|
173
|
+
DB.query('items').then(items => {
|
|
174
|
+
state.items = items
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
return View({ flex: 1 }, [
|
|
179
|
+
Text(`Items: ${itemCount.value}`),
|
|
180
|
+
FlatList(state.items, item => renderItem(item)),
|
|
181
|
+
])
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Library Using Specific Packages
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
// utils.ts - Utility library
|
|
189
|
+
import type { DFNode, StyleObject } from '@deskforge/ui'
|
|
190
|
+
import { View } from '@deskforge/ui'
|
|
191
|
+
import { State } from '@deskforge/state'
|
|
192
|
+
|
|
193
|
+
export const createCounter = () => {
|
|
194
|
+
const state = State({ count: 0 })
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
get: () => state.count,
|
|
198
|
+
increment: () => state.count++,
|
|
199
|
+
decrement: () => state.count--,
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Type Imports
|
|
207
|
+
|
|
208
|
+
### Import Types from Specific Packages
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import type {
|
|
212
|
+
DFNode,
|
|
213
|
+
StyleObject,
|
|
214
|
+
PressHandlers,
|
|
215
|
+
TextInputProps,
|
|
216
|
+
FlatListProps,
|
|
217
|
+
} from '@deskforge/ui'
|
|
218
|
+
|
|
219
|
+
import type {
|
|
220
|
+
StateProxy,
|
|
221
|
+
ComputedRef,
|
|
222
|
+
WatchHandle,
|
|
223
|
+
EffectHandle,
|
|
224
|
+
} from '@deskforge/state'
|
|
225
|
+
|
|
226
|
+
// Use types in your code
|
|
227
|
+
const handler: PressHandlers = {
|
|
228
|
+
onPress: () => console.log('pressed'),
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const style: StyleObject = {
|
|
232
|
+
flex: 1,
|
|
233
|
+
backgroundColor: '#fff',
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Import Types from Main Package
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import type {
|
|
241
|
+
DFNode,
|
|
242
|
+
StyleObject,
|
|
243
|
+
PressHandlers,
|
|
244
|
+
} from 'deskforge'
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Tree-Shaking Friendly
|
|
250
|
+
|
|
251
|
+
All imports are tree-shaking friendly. Only the code you import will be included in your bundle:
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
// Only View, Text, and State will be bundled
|
|
255
|
+
import { View, Text, State } from 'deskforge'
|
|
256
|
+
|
|
257
|
+
// Router, DB, and other unused packages won't be included
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Package Purposes
|
|
263
|
+
|
|
264
|
+
| Package | Purpose | Common Exports |
|
|
265
|
+
|---------|---------|----------------|
|
|
266
|
+
| **@deskforge/ui** | UI Components | View, Text, Button, FlatList, etc. |
|
|
267
|
+
| **@deskforge/state** | State Management | State, Computed, Effect, Watch, Ref |
|
|
268
|
+
| **@deskforge/router** | Navigation | Router, Screen, Navigation |
|
|
269
|
+
| **@deskforge/db** | Database | DB, query, insert, update, delete |
|
|
270
|
+
| **@deskforge/notifications** | Alerts & Toasts | Toast, Push, SMS, Email |
|
|
271
|
+
| **@deskforge/theme** | Theming | Theme, useTheme |
|
|
272
|
+
| **@deskforge/file** | File Operations | File, read, write, delete |
|
|
273
|
+
| **@deskforge/network** | Networking | Network, P2P, mDNS |
|
|
274
|
+
| **@deskforge/ai** | AI Integration | createBrain, chat |
|
|
275
|
+
| **@deskforge/security** | Security | Biometric, Encrypt, Decrypt |
|
|
276
|
+
| **@deskforge/bridge** | Language Bridge | Bridge, call C/Go/Rust/etc |
|
|
277
|
+
| **@deskforge/background** | Background Tasks | Background, Schedule |
|
|
278
|
+
| **@deskforge/payments** | Payments | Payment, processPayment |
|
|
279
|
+
| **@deskforge/i18n** | Translations | i18n, t, locale |
|
|
280
|
+
| **@deskforge/logger** | Logging | Logger, log, warn, error |
|
|
281
|
+
| **@deskforge/updater** | App Updates | Updater, checkUpdate |
|
|
282
|
+
| **@deskforge/cli** | CLI Tools | CLI, command (Node only) |
|
|
283
|
+
| **@deskforge/core** | Core Utilities | createNode, StyleSheet, DFNode |
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Best Practices
|
|
288
|
+
|
|
289
|
+
### ✅ DO
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
// Group imports by package
|
|
293
|
+
import { View, Text, Button } from '@deskforge/ui'
|
|
294
|
+
import { State, Computed } from '@deskforge/state'
|
|
295
|
+
|
|
296
|
+
// Use specific imports
|
|
297
|
+
import { View } from '@deskforge/ui' // Good
|
|
298
|
+
import * as ui from '@deskforge/ui' // Also fine
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### ❌ DON'T
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
// Don't mix import styles in same file
|
|
305
|
+
import { View } from '@deskforge/ui'
|
|
306
|
+
import * as state from 'deskforge/state' // Inconsistent
|
|
307
|
+
|
|
308
|
+
// Don't use unscoped imports
|
|
309
|
+
import { View } from 'deskforge/ui' // Wrong
|
|
310
|
+
import { State } from 'deskforge/state' // Wrong
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Monorepo Development
|
|
316
|
+
|
|
317
|
+
If you're developing within the DeskForge monorepo:
|
|
318
|
+
|
|
319
|
+
### Building Package After Changes
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Build UI package after changes
|
|
323
|
+
yarn build @deskforge/ui
|
|
324
|
+
|
|
325
|
+
# Build all packages
|
|
326
|
+
yarn build
|
|
327
|
+
|
|
328
|
+
# Build and watch
|
|
329
|
+
yarn dev
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Testing Package Changes
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
# Test UI package
|
|
336
|
+
yarn test @deskforge/ui
|
|
337
|
+
|
|
338
|
+
# Test all
|
|
339
|
+
yarn test
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Publishing Changes
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Publish all changed packages
|
|
346
|
+
yarn publish
|
|
347
|
+
|
|
348
|
+
# Publish specific package
|
|
349
|
+
yarn publish @deskforge/ui
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Environment-Specific Imports
|
|
355
|
+
|
|
356
|
+
### Browser/Mobile App
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
// Works everywhere
|
|
360
|
+
import { View, Text, State } from 'deskforge'
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### Node.js/Backend
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
// Regular imports work
|
|
367
|
+
import { DB, Logger } from 'deskforge'
|
|
368
|
+
|
|
369
|
+
// CLI-specific imports
|
|
370
|
+
import { CLI } from '@deskforge/cli'
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Electron/Desktop
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
// All desktop packages available
|
|
377
|
+
import { View, File, Background, Bridge } from 'deskforge'
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Quick Reference
|
|
383
|
+
|
|
384
|
+
| Need | Import |
|
|
385
|
+
|------|--------|
|
|
386
|
+
| Quick app | `from 'deskforge'` |
|
|
387
|
+
| Specific package | `from '@deskforge/package'` |
|
|
388
|
+
| Types only | `import type { ... }` |
|
|
389
|
+
| Multiple packages | Import from each `@deskforge/...` |
|
|
390
|
+
| Build new component | Import from `@deskforge/ui` |
|
|
391
|
+
| Manage state | Import from `@deskforge/state` |
|
|
392
|
+
| Handle persistence | Import from `@deskforge/db` |
|
|
393
|
+
| Show notifications | Import from `@deskforge/notifications` |
|
|
394
|
+
| Navigate screens | Import from `@deskforge/router` |
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Summary
|
|
399
|
+
|
|
400
|
+
- **For most apps:** `from 'deskforge'`
|
|
401
|
+
- **For libraries:** `from '@deskforge/package'`
|
|
402
|
+
- **For types:** `import type { ... }`
|
|
403
|
+
- **Always use scoped:** `@deskforge` not `deskforge/package`
|
|
404
|
+
- **Group related imports** by package for readability
|