@maccesar/titools 2.0.0
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/AGENTS-TEMPLATE.md +173 -0
- package/README.md +867 -0
- package/agents/ti-researcher.md +108 -0
- package/bin/titools.js +53 -0
- package/lib/commands/agents.js +126 -0
- package/lib/commands/install.js +188 -0
- package/lib/commands/uninstall.js +215 -0
- package/lib/commands/update.js +159 -0
- package/lib/config.js +119 -0
- package/lib/downloader.js +153 -0
- package/lib/installer.js +253 -0
- package/lib/platform.js +108 -0
- package/lib/symlink.js +142 -0
- package/lib/utils.js +270 -0
- package/package.json +67 -0
- package/skills/alloy-expert/SKILL.md +247 -0
- package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
- package/skills/alloy-expert/references/alloy-structure.md +381 -0
- package/skills/alloy-expert/references/anti-patterns.md +133 -0
- package/skills/alloy-expert/references/code-conventions.md +469 -0
- package/skills/alloy-expert/references/contracts.md +280 -0
- package/skills/alloy-expert/references/controller-patterns.md +520 -0
- package/skills/alloy-expert/references/error-handling.md +484 -0
- package/skills/alloy-expert/references/examples.md +735 -0
- package/skills/alloy-expert/references/migration-patterns.md +298 -0
- package/skills/alloy-expert/references/patterns.md +448 -0
- package/skills/alloy-expert/references/performance-patterns.md +855 -0
- package/skills/alloy-expert/references/security-patterns.md +847 -0
- package/skills/alloy-expert/references/state-management.md +779 -0
- package/skills/alloy-expert/references/testing.md +872 -0
- package/skills/alloy-guides/SKILL.md +214 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
- package/skills/alloy-guides/references/CONCEPTS.md +191 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
- package/skills/alloy-guides/references/MODELS.md +1028 -0
- package/skills/alloy-guides/references/PURGETSS.md +56 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
- package/skills/alloy-guides/references/WIDGETS.md +176 -0
- package/skills/alloy-howtos/SKILL.md +203 -0
- package/skills/alloy-howtos/references/best_practices.md +138 -0
- package/skills/alloy-howtos/references/cli_reference.md +253 -0
- package/skills/alloy-howtos/references/config_files.md +87 -0
- package/skills/alloy-howtos/references/custom_tags.md +147 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
- package/skills/alloy-howtos/references/samples.md +167 -0
- package/skills/purgetss/SKILL.md +442 -0
- package/skills/purgetss/assets/purgetss.config.cjs +17 -0
- package/skills/purgetss/references/EXAMPLES.md +247 -0
- package/skills/purgetss/references/animation-system.md +1294 -0
- package/skills/purgetss/references/apply-directive.md +375 -0
- package/skills/purgetss/references/arbitrary-values.md +612 -0
- package/skills/purgetss/references/class-index.md +1350 -0
- package/skills/purgetss/references/cli-commands.md +948 -0
- package/skills/purgetss/references/configurable-properties.md +654 -0
- package/skills/purgetss/references/custom-rules.md +161 -0
- package/skills/purgetss/references/customization-deep-dive.md +722 -0
- package/skills/purgetss/references/dynamic-component-creation.md +489 -0
- package/skills/purgetss/references/grid-layout.md +455 -0
- package/skills/purgetss/references/icon-fonts.md +609 -0
- package/skills/purgetss/references/installation-setup.md +366 -0
- package/skills/purgetss/references/opacity-modifier.md +291 -0
- package/skills/purgetss/references/platform-modifiers.md +479 -0
- package/skills/purgetss/references/smart-mappings.md +42 -0
- package/skills/purgetss/references/titanium-resets.md +359 -0
- package/skills/purgetss/references/ui-ux-design.md +1526 -0
- package/skills/ti-guides/SKILL.md +94 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
- package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
- package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
- package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +258 -0
- package/skills/ti-guides/references/application-frameworks.md +377 -0
- package/skills/ti-guides/references/cli-reference.md +402 -0
- package/skills/ti-guides/references/coding-best-practices.md +102 -0
- package/skills/ti-guides/references/commonjs-advanced.md +134 -0
- package/skills/ti-guides/references/hello-world.md +100 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
- package/skills/ti-guides/references/javascript-primer.md +411 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +183 -0
- package/skills/ti-guides/references/style-and-conventions.md +48 -0
- package/skills/ti-guides/references/tiapp-config.md +609 -0
- package/skills/ti-howtos/SKILL.md +174 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
- package/skills/ti-howtos/references/cross-platform-development.md +348 -0
- package/skills/ti-howtos/references/debugging-profiling.md +543 -0
- package/skills/ti-howtos/references/extending-titanium.md +723 -0
- package/skills/ti-howtos/references/google-maps-v2.md +169 -0
- package/skills/ti-howtos/references/ios-map-kit.md +143 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
- package/skills/ti-howtos/references/local-data-sources.md +301 -0
- package/skills/ti-howtos/references/location-and-maps.md +252 -0
- package/skills/ti-howtos/references/media-apis.md +210 -0
- package/skills/ti-howtos/references/notification-services.md +599 -0
- package/skills/ti-howtos/references/remote-data-sources.md +349 -0
- package/skills/ti-howtos/references/tutorials.md +502 -0
- package/skills/ti-howtos/references/using-modules.md +237 -0
- package/skills/ti-howtos/references/web-content-integration.md +307 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
- package/skills/ti-ui/SKILL.md +179 -0
- package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
- package/skills/ti-ui/references/animation-and-matrices.md +599 -0
- package/skills/ti-ui/references/application-structures.md +655 -0
- package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
- package/skills/ti-ui/references/event-handling.md +393 -0
- package/skills/ti-ui/references/gestures.md +473 -0
- package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
- package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
- package/skills/ti-ui/references/listviews-and-performance.md +619 -0
- package/skills/ti-ui/references/orientation.md +362 -0
- package/skills/ti-ui/references/platform-ui-android.md +635 -0
- package/skills/ti-ui/references/platform-ui-ios.md +469 -0
- package/skills/ti-ui/references/scrolling-views.md +252 -0
- package/skills/ti-ui/references/tableviews.md +568 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Layer Contracts & Interfaces
|
|
2
|
+
|
|
3
|
+
Contracts define the input/output specifications between layers, ensuring consistent communication and easy testing.
|
|
4
|
+
|
|
5
|
+
## API Layer Contracts
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
// lib/api/userApi.js
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} User
|
|
12
|
+
* @property {number} id
|
|
13
|
+
* @property {string} name
|
|
14
|
+
* @property {string} email
|
|
15
|
+
* @property {string} [avatarUrl]
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} UserFilters
|
|
20
|
+
* @property {string} [search] - Search by name or email
|
|
21
|
+
* @property {number} [limit] - Max results (default: 20)
|
|
22
|
+
* @property {number} [offset] - Pagination offset
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
exports.userApi = {
|
|
26
|
+
/**
|
|
27
|
+
* Get paginated list of users
|
|
28
|
+
* @param {UserFilters} [filters]
|
|
29
|
+
* @returns {Promise<{users: User[], total: number}>}
|
|
30
|
+
*/
|
|
31
|
+
async getAll(filters = {}) {
|
|
32
|
+
return apiClient.get('/users', filters)
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get single user by ID
|
|
37
|
+
* @param {number} id
|
|
38
|
+
* @returns {Promise<User>}
|
|
39
|
+
* @throws {NotFoundError} When user doesn't exist
|
|
40
|
+
*/
|
|
41
|
+
async getById(id) {
|
|
42
|
+
return apiClient.get(`/users/${id}`)
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create new user
|
|
47
|
+
* @param {{name: string, email: string}} data
|
|
48
|
+
* @returns {Promise<User>}
|
|
49
|
+
* @throws {ValidationError} When data is invalid
|
|
50
|
+
*/
|
|
51
|
+
async create(data) {
|
|
52
|
+
return apiClient.post('/users', data)
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Update existing user
|
|
57
|
+
* @param {number} id
|
|
58
|
+
* @param {Partial<User>} data
|
|
59
|
+
* @returns {Promise<User>}
|
|
60
|
+
*/
|
|
61
|
+
async update(id, data) {
|
|
62
|
+
return apiClient.put(`/users/${id}`, data)
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Delete user
|
|
67
|
+
* @param {number} id
|
|
68
|
+
* @returns {Promise<void>}
|
|
69
|
+
*/
|
|
70
|
+
async delete(id) {
|
|
71
|
+
return apiClient.delete(`/users/${id}`)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Service Layer Contracts
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
// lib/services/authService.js
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @typedef {Object} LoginResult
|
|
83
|
+
* @property {User} user
|
|
84
|
+
* @property {string} token
|
|
85
|
+
* @property {number} expiresIn - Token expiry in seconds
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {Object} AuthState
|
|
90
|
+
* @property {boolean} isAuthenticated
|
|
91
|
+
* @property {User|null} user
|
|
92
|
+
* @property {boolean} isLoading
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
exports.AuthService = {
|
|
96
|
+
/**
|
|
97
|
+
* Authenticate user with credentials
|
|
98
|
+
* @param {string} email
|
|
99
|
+
* @param {string} password
|
|
100
|
+
* @returns {Promise<LoginResult>}
|
|
101
|
+
* @throws {ValidationError} When credentials format is invalid
|
|
102
|
+
* @throws {AuthError} When credentials are incorrect
|
|
103
|
+
*/
|
|
104
|
+
async login(email, password) { /* ... */ },
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* End user session
|
|
108
|
+
* @returns {Promise<void>}
|
|
109
|
+
*/
|
|
110
|
+
async logout() { /* ... */ },
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Check if user is currently authenticated
|
|
114
|
+
* @returns {boolean}
|
|
115
|
+
*/
|
|
116
|
+
isAuthenticated() { /* ... */ },
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get current auth state
|
|
120
|
+
* @returns {AuthState}
|
|
121
|
+
*/
|
|
122
|
+
getState() { /* ... */ }
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Controller Contracts
|
|
127
|
+
|
|
128
|
+
Document expected inputs and outputs for each controller:
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
// controllers/user/detail.js
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* User Detail Controller
|
|
135
|
+
*
|
|
136
|
+
* @description Displays and allows editing of user details
|
|
137
|
+
*
|
|
138
|
+
* INPUT (via $.args):
|
|
139
|
+
* @param {number} userId - Required. User ID to display
|
|
140
|
+
* @param {boolean} [editable=false] - Allow editing
|
|
141
|
+
*
|
|
142
|
+
* OUTPUT (via events):
|
|
143
|
+
* @fires 'user:updated' - When user data is saved
|
|
144
|
+
* @param {User} user - Updated user object
|
|
145
|
+
*
|
|
146
|
+
* @fires 'user:deleted' - When user is deleted
|
|
147
|
+
* @param {number} userId - Deleted user ID
|
|
148
|
+
*
|
|
149
|
+
* LIFECYCLE:
|
|
150
|
+
* - init() called on creation
|
|
151
|
+
* - cleanup() called on close (removes all listeners)
|
|
152
|
+
*
|
|
153
|
+
* EXAMPLE:
|
|
154
|
+
* const ctrl = Navigation.open('user/detail', { userId: 123, editable: true })
|
|
155
|
+
* ctrl.on('user:updated', (user) => refreshList())
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
function init() {
|
|
159
|
+
if (!$.args.userId) {
|
|
160
|
+
throw new Error('userId is required')
|
|
161
|
+
}
|
|
162
|
+
loadUser($.args.userId)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ...implementation
|
|
166
|
+
|
|
167
|
+
$.cleanup = cleanup
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Navigation Service Contract
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
// lib/services/navigation.js
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @typedef {Object} NavigationOptions
|
|
177
|
+
* @property {boolean} [modal=false] - Open as modal
|
|
178
|
+
* @property {boolean} [animated=true] - Animate transition
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
exports.Navigation = {
|
|
182
|
+
/**
|
|
183
|
+
* Open a new screen
|
|
184
|
+
* @param {string} route - Controller path (e.g., 'user/detail')
|
|
185
|
+
* @param {Object} [params] - Arguments passed to controller
|
|
186
|
+
* @param {NavigationOptions} [options]
|
|
187
|
+
* @returns {Controller} - The opened controller instance
|
|
188
|
+
*/
|
|
189
|
+
open(route, params = {}, options = {}) { /* ... */ },
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Close current screen and go back
|
|
193
|
+
* @returns {void}
|
|
194
|
+
*/
|
|
195
|
+
back() { /* ... */ },
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Replace current screen without animation
|
|
199
|
+
* @param {string} route
|
|
200
|
+
* @param {Object} [params]
|
|
201
|
+
* @returns {Controller}
|
|
202
|
+
*/
|
|
203
|
+
replace(route, params = {}) { /* ... */ },
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Get current navigation stack
|
|
207
|
+
* @returns {string[]} - Array of route names
|
|
208
|
+
*/
|
|
209
|
+
getStack() { /* ... */ }
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Helper Contracts
|
|
214
|
+
|
|
215
|
+
```javascript
|
|
216
|
+
// lib/helpers/formatters.js
|
|
217
|
+
|
|
218
|
+
exports.Formatters = {
|
|
219
|
+
/**
|
|
220
|
+
* Format currency with locale
|
|
221
|
+
* @param {number} amount
|
|
222
|
+
* @param {string} [currency='USD']
|
|
223
|
+
* @returns {string} - e.g., "$1,234.56"
|
|
224
|
+
*/
|
|
225
|
+
currency(amount, currency = 'USD') { /* ... */ },
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Format date relative to now
|
|
229
|
+
* @param {Date|string} date
|
|
230
|
+
* @returns {string} - e.g., "2 hours ago", "Yesterday"
|
|
231
|
+
*/
|
|
232
|
+
relativeTime(date) { /* ... */ },
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Pluralize string based on count
|
|
236
|
+
* @param {number} count
|
|
237
|
+
* @param {string} singular
|
|
238
|
+
* @param {string} [plural] - Defaults to singular + 's'
|
|
239
|
+
* @returns {string} - e.g., "1 item", "5 items"
|
|
240
|
+
*/
|
|
241
|
+
pluralize(count, singular, plural) { /* ... */ }
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Event Bus Contract
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
// lib/services/eventBus.js
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Named events for type safety and discoverability
|
|
252
|
+
*/
|
|
253
|
+
exports.Events = {
|
|
254
|
+
// User events
|
|
255
|
+
USER_LOGGED_IN: 'user:loggedIn', // payload: { user: User }
|
|
256
|
+
USER_LOGGED_OUT: 'user:loggedOut', // payload: none
|
|
257
|
+
USER_UPDATED: 'user:updated', // payload: { user: User }
|
|
258
|
+
|
|
259
|
+
// Data sync events
|
|
260
|
+
SYNC_STARTED: 'sync:started', // payload: none
|
|
261
|
+
SYNC_COMPLETE: 'sync:complete', // payload: { count: number }
|
|
262
|
+
SYNC_FAILED: 'sync:failed', // payload: { error: Error }
|
|
263
|
+
|
|
264
|
+
// Network events
|
|
265
|
+
NETWORK_ONLINE: 'network:online', // payload: none
|
|
266
|
+
NETWORK_OFFLINE: 'network:offline', // payload: none
|
|
267
|
+
|
|
268
|
+
// Cart events (e-commerce example)
|
|
269
|
+
CART_UPDATED: 'cart:updated', // payload: { items: CartItem[], total: number }
|
|
270
|
+
CART_CLEARED: 'cart:cleared' // payload: none
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Contract Enforcement Tips
|
|
275
|
+
|
|
276
|
+
1. **Always validate `$.args`** at controller initialization
|
|
277
|
+
2. **Use TypeScript JSDoc** for IDE autocompletion and error detection
|
|
278
|
+
3. **Document all events** with their payload structure
|
|
279
|
+
4. **Throw specific errors** (ValidationError, NotFoundError, AuthError)
|
|
280
|
+
5. **Return consistent shapes** from API methods
|