@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.
Files changed (120) hide show
  1. package/AGENTS-TEMPLATE.md +173 -0
  2. package/README.md +867 -0
  3. package/agents/ti-researcher.md +108 -0
  4. package/bin/titools.js +53 -0
  5. package/lib/commands/agents.js +126 -0
  6. package/lib/commands/install.js +188 -0
  7. package/lib/commands/uninstall.js +215 -0
  8. package/lib/commands/update.js +159 -0
  9. package/lib/config.js +119 -0
  10. package/lib/downloader.js +153 -0
  11. package/lib/installer.js +253 -0
  12. package/lib/platform.js +108 -0
  13. package/lib/symlink.js +142 -0
  14. package/lib/utils.js +270 -0
  15. package/package.json +67 -0
  16. package/skills/alloy-expert/SKILL.md +247 -0
  17. package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
  18. package/skills/alloy-expert/references/alloy-structure.md +381 -0
  19. package/skills/alloy-expert/references/anti-patterns.md +133 -0
  20. package/skills/alloy-expert/references/code-conventions.md +469 -0
  21. package/skills/alloy-expert/references/contracts.md +280 -0
  22. package/skills/alloy-expert/references/controller-patterns.md +520 -0
  23. package/skills/alloy-expert/references/error-handling.md +484 -0
  24. package/skills/alloy-expert/references/examples.md +735 -0
  25. package/skills/alloy-expert/references/migration-patterns.md +298 -0
  26. package/skills/alloy-expert/references/patterns.md +448 -0
  27. package/skills/alloy-expert/references/performance-patterns.md +855 -0
  28. package/skills/alloy-expert/references/security-patterns.md +847 -0
  29. package/skills/alloy-expert/references/state-management.md +779 -0
  30. package/skills/alloy-expert/references/testing.md +872 -0
  31. package/skills/alloy-guides/SKILL.md +214 -0
  32. package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
  33. package/skills/alloy-guides/references/CONCEPTS.md +191 -0
  34. package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
  35. package/skills/alloy-guides/references/MODELS.md +1028 -0
  36. package/skills/alloy-guides/references/PURGETSS.md +56 -0
  37. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
  38. package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
  39. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
  40. package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
  41. package/skills/alloy-guides/references/WIDGETS.md +176 -0
  42. package/skills/alloy-howtos/SKILL.md +203 -0
  43. package/skills/alloy-howtos/references/best_practices.md +138 -0
  44. package/skills/alloy-howtos/references/cli_reference.md +253 -0
  45. package/skills/alloy-howtos/references/config_files.md +87 -0
  46. package/skills/alloy-howtos/references/custom_tags.md +147 -0
  47. package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
  48. package/skills/alloy-howtos/references/samples.md +167 -0
  49. package/skills/purgetss/SKILL.md +442 -0
  50. package/skills/purgetss/assets/purgetss.config.cjs +17 -0
  51. package/skills/purgetss/references/EXAMPLES.md +247 -0
  52. package/skills/purgetss/references/animation-system.md +1294 -0
  53. package/skills/purgetss/references/apply-directive.md +375 -0
  54. package/skills/purgetss/references/arbitrary-values.md +612 -0
  55. package/skills/purgetss/references/class-index.md +1350 -0
  56. package/skills/purgetss/references/cli-commands.md +948 -0
  57. package/skills/purgetss/references/configurable-properties.md +654 -0
  58. package/skills/purgetss/references/custom-rules.md +161 -0
  59. package/skills/purgetss/references/customization-deep-dive.md +722 -0
  60. package/skills/purgetss/references/dynamic-component-creation.md +489 -0
  61. package/skills/purgetss/references/grid-layout.md +455 -0
  62. package/skills/purgetss/references/icon-fonts.md +609 -0
  63. package/skills/purgetss/references/installation-setup.md +366 -0
  64. package/skills/purgetss/references/opacity-modifier.md +291 -0
  65. package/skills/purgetss/references/platform-modifiers.md +479 -0
  66. package/skills/purgetss/references/smart-mappings.md +42 -0
  67. package/skills/purgetss/references/titanium-resets.md +359 -0
  68. package/skills/purgetss/references/ui-ux-design.md +1526 -0
  69. package/skills/ti-guides/SKILL.md +94 -0
  70. package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
  71. package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
  72. package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
  73. package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
  74. package/skills/ti-guides/references/android-manifest.md +97 -0
  75. package/skills/ti-guides/references/app-distribution.md +258 -0
  76. package/skills/ti-guides/references/application-frameworks.md +377 -0
  77. package/skills/ti-guides/references/cli-reference.md +402 -0
  78. package/skills/ti-guides/references/coding-best-practices.md +102 -0
  79. package/skills/ti-guides/references/commonjs-advanced.md +134 -0
  80. package/skills/ti-guides/references/hello-world.md +100 -0
  81. package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
  82. package/skills/ti-guides/references/javascript-primer.md +411 -0
  83. package/skills/ti-guides/references/reserved-words.md +36 -0
  84. package/skills/ti-guides/references/resources.md +183 -0
  85. package/skills/ti-guides/references/style-and-conventions.md +48 -0
  86. package/skills/ti-guides/references/tiapp-config.md +609 -0
  87. package/skills/ti-howtos/SKILL.md +174 -0
  88. package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
  89. package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
  90. package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
  91. package/skills/ti-howtos/references/cross-platform-development.md +348 -0
  92. package/skills/ti-howtos/references/debugging-profiling.md +543 -0
  93. package/skills/ti-howtos/references/extending-titanium.md +723 -0
  94. package/skills/ti-howtos/references/google-maps-v2.md +169 -0
  95. package/skills/ti-howtos/references/ios-map-kit.md +143 -0
  96. package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
  97. package/skills/ti-howtos/references/local-data-sources.md +301 -0
  98. package/skills/ti-howtos/references/location-and-maps.md +252 -0
  99. package/skills/ti-howtos/references/media-apis.md +210 -0
  100. package/skills/ti-howtos/references/notification-services.md +599 -0
  101. package/skills/ti-howtos/references/remote-data-sources.md +349 -0
  102. package/skills/ti-howtos/references/tutorials.md +502 -0
  103. package/skills/ti-howtos/references/using-modules.md +237 -0
  104. package/skills/ti-howtos/references/web-content-integration.md +307 -0
  105. package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
  106. package/skills/ti-ui/SKILL.md +179 -0
  107. package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
  108. package/skills/ti-ui/references/animation-and-matrices.md +599 -0
  109. package/skills/ti-ui/references/application-structures.md +655 -0
  110. package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
  111. package/skills/ti-ui/references/event-handling.md +393 -0
  112. package/skills/ti-ui/references/gestures.md +473 -0
  113. package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
  114. package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
  115. package/skills/ti-ui/references/listviews-and-performance.md +619 -0
  116. package/skills/ti-ui/references/orientation.md +362 -0
  117. package/skills/ti-ui/references/platform-ui-android.md +635 -0
  118. package/skills/ti-ui/references/platform-ui-ios.md +469 -0
  119. package/skills/ti-ui/references/scrolling-views.md +252 -0
  120. package/skills/ti-ui/references/tableviews.md +568 -0
@@ -0,0 +1,377 @@
1
+ # Application Frameworks
2
+
3
+ Framework options and architectural patterns for Titanium applications.
4
+
5
+ ## Table of Contents
6
+ 1. [Alloy Framework](#alloy-framework)
7
+ 2. [Classic Titanium](#classic-titanium)
8
+ 3. [Choosing a Framework](#choosing-a-framework)
9
+ 4. [Architecture Patterns](#architecture-patterns)
10
+
11
+ ---
12
+
13
+ ## Alloy Framework
14
+
15
+ **Alloy** is the official MVC framework for Titanium, developed by TiDev.
16
+
17
+ ### What is Alloy?
18
+
19
+ Alloy provides:
20
+ - **MVC Architecture** - Separate models, views, and controllers
21
+ - **Built-in Libraries** - Backbone.js, Underscore.js
22
+ - **XML Views** - Declarative UI markup
23
+ - **TSS Styling** - CSS-like styling system
24
+ - **Data Binding** - Automatic view-to-model synchronization
25
+ - **Widgets** - Reusable UI components
26
+ - **Model/Collection Sync** - Built-in REST and SQL adapters
27
+
28
+ ### Project Structure
29
+
30
+ ```
31
+ app/
32
+ ├── controllers/ # UI logic
33
+ ├── models/ # Data models
34
+ ├── views/ # XML view definitions
35
+ ├── styles/ # TSS style sheets
36
+ ├── assets/ # Images, fonts
37
+ ├── lib/ # CommonJS libraries
38
+ ├── themes/ # Theming support
39
+ ├── config.json # App configuration
40
+ └── alloy.js # Entry point
41
+ ```
42
+
43
+ ### Sample Alloy Code
44
+
45
+ **View (XML):**
46
+ ```xml
47
+ <Alloy>
48
+ <Window class="container">
49
+ <Label id="title" onClick="doClick">Click Me</Label>
50
+ </Window>
51
+ </Alloy>
52
+ ```
53
+
54
+ **Style (TSS):**
55
+ ```css
56
+ ".container": {
57
+ backgroundColor: "#fff"
58
+ }
59
+
60
+ "#title": {
61
+ color: "#000",
62
+ font: { fontSize: 18 }
63
+ }
64
+ ```
65
+
66
+ **Controller (JS):**
67
+ ```javascript
68
+ const doClick = (e) => {
69
+ alert('Clicked!');
70
+ };
71
+
72
+ $.index.open();
73
+ ```
74
+
75
+ ### Alloy Resources
76
+
77
+ - **Alloy Guides:** See the `alloy-guides` skill
78
+ - **Alloy CLI:** See `alloy-cli-advanced.md`
79
+ - **Alloy Data:** See `alloy-data-mastery.md`
80
+ - **Alloy Widgets:** See `alloy-widgets-and-themes.md`
81
+
82
+ ### When to Use Alloy
83
+
84
+ ✅ **Use Alloy for:**
85
+ - New projects (default choice)
86
+ - Teams wanting MVC structure
87
+ - Projects needing data binding
88
+ - Rapid development with XML views
89
+ - Reusable components (widgets)
90
+
91
+ ❌ **Consider alternatives for:**
92
+ - Very simple apps (overkill)
93
+ - Teams preferring pure JavaScript
94
+ - Projects with unique architectural needs
95
+
96
+ ---
97
+
98
+ ## Classic Titanium
99
+
100
+ Classic Titanium refers to building apps without Alloy, using pure JavaScript and CommonJS modules.
101
+
102
+ ### Project Structure
103
+
104
+ ```
105
+ Resources/
106
+ ├── app.js # Entry point
107
+ ├── ui/ # UI components
108
+ │ ├── ApplicationWindow.js
109
+ │ └── ...
110
+ ├── models/ # Data models
111
+ ├── lib/ # Utilities
112
+ └── assets/ # Images, etc.
113
+ ```
114
+
115
+ ### Sample Classic Code
116
+
117
+ **app.js:**
118
+ ```javascript
119
+ // Single namespace pattern
120
+ const app = {};
121
+
122
+ // Include components (Legacy)
123
+ Ti.include('ui/ApplicationWindow.js');
124
+
125
+ // Create and open window
126
+ app.mainWindow = app.ui.createApplicationWindow();
127
+ app.mainWindow.open();
128
+ ```
129
+
130
+ **ui/ApplicationWindow.js:**
131
+ ```javascript
132
+ // Extend namespace
133
+ app.ui = app.ui || {};
134
+
135
+ app.ui.createApplicationWindow = () => {
136
+ const win = Ti.UI.createWindow({
137
+ backgroundColor: 'white',
138
+ title: 'My App'
139
+ });
140
+
141
+ const label = Ti.UI.createLabel({
142
+ text: 'Hello World',
143
+ color: '#000'
144
+ });
145
+
146
+ win.add(label);
147
+ return win;
148
+ };
149
+ ```
150
+
151
+ ### CommonJS Pattern (Recommended)
152
+
153
+ **myModule.js:**
154
+ ```javascript
155
+ // Private variables
156
+ const privateData = 'secret';
157
+
158
+ // Public API
159
+ exports.createWindow = () => {
160
+ return Ti.UI.createWindow({
161
+ backgroundColor: 'white'
162
+ });
163
+ };
164
+
165
+ exports.getData = () => {
166
+ return privateData;
167
+ };
168
+ ```
169
+
170
+ **app.js:**
171
+ ```javascript
172
+ const myModule = require('myModule');
173
+ const win = myModule.createWindow();
174
+ win.open();
175
+ ```
176
+
177
+ ### When to Use Classic
178
+
179
+ ✅ **Use Classic for:**
180
+ - Simple projects
181
+ - Developers who prefer pure JavaScript
182
+ - Migrating from older Titanium projects
183
+ - Fine-grained control over UI creation
184
+ - Learning the Titanium API directly
185
+
186
+ ❌ **Consider Alloy for:**
187
+ - Large teams
188
+ - Complex apps with many screens
189
+ - Projects needing built-in MVC
190
+ - Data-heavy applications
191
+
192
+ ---
193
+
194
+ ## Choosing a Framework
195
+
196
+ ### Comparison
197
+
198
+ | Feature | Alloy | Classic |
199
+ | ------------------ | ----------------------- | ------------------ |
200
+ | **Learning Curve** | Steeper (XML, TSS, MVC) | Easier (just JS) |
201
+ | **Boilerplate** | Less (declarative) | More (imperative) |
202
+ | **Structure** | Enforced (MVC) | Manual |
203
+ | **Data Binding** | Built-in | Manual |
204
+ | **Styling** | TSS (CSS-like) | Inline JS |
205
+ | **Team Size** | Better for large teams | Flexible |
206
+ | **Rapid Dev** | Faster (once learned) | Slower (more code) |
207
+
208
+ ### Recommendation
209
+
210
+ **Start with Alloy** - It's the default for new projects and provides:
211
+ - Built-in best practices
212
+ - MVC structure from day one
213
+ - Less code to write
214
+ - Better team collaboration
215
+ - Official support and updates
216
+
217
+ **Switch to Classic** if:
218
+ - Alloy feels too complex for your needs
219
+ - You prefer pure JavaScript
220
+ - Your app is very simple
221
+
222
+ ---
223
+
224
+ ## Architecture Patterns
225
+
226
+ ### Namespaced Pattern
227
+
228
+ Classic Titanium pattern with single global namespace:
229
+
230
+ ```javascript
231
+ const app = {
232
+ models: {},
233
+ views: {},
234
+ controllers: {},
235
+
236
+ init() {
237
+ // Initialize app
238
+ },
239
+
240
+ run() {
241
+ // Run app
242
+ }
243
+ };
244
+
245
+ app.init();
246
+ app.run();
247
+ ```
248
+
249
+ ### CommonJS Modules
250
+
251
+ Modern JavaScript pattern for Titanium:
252
+
253
+ **models/user.js:**
254
+ ```javascript
255
+ exports.create = (attrs) => {
256
+ return {
257
+ name: attrs.name,
258
+ email: attrs.email,
259
+ save() {
260
+ // Save to database
261
+ }
262
+ };
263
+ };
264
+ ```
265
+
266
+ **controllers/user.js:**
267
+ ```javascript
268
+ const User = require('models/user');
269
+
270
+ exports.register = (data) => {
271
+ const user = User.create(data);
272
+ user.save();
273
+ return user;
274
+ };
275
+ ```
276
+
277
+ ### MVC with Alloy (Built-in)
278
+
279
+ Alloy enforces MVC:
280
+
281
+ ```
282
+ app/
283
+ ├── controllers/userController.js # Logic
284
+ ├── models/userModel.js # Data
285
+ └── views/userView.xml # Presentation
286
+ ```
287
+
288
+ ### Repository Pattern
289
+
290
+ Separate data access from business logic:
291
+
292
+ **repositories/userRepository.js:**
293
+ ```javascript
294
+ exports.findById = (id) => {
295
+ // Database call
296
+ return db.query('SELECT * FROM users WHERE id = ?', [id]);
297
+ };
298
+
299
+ exports.save = (user) => {
300
+ // Insert/update
301
+ return db.execute('INSERT INTO users ...');
302
+ };
303
+ ```
304
+
305
+ **services/userService.js:**
306
+ ```javascript
307
+ const repo = require('repositories/userRepository');
308
+
309
+ exports.register = (data) => {
310
+ // Business logic
311
+ if (!data.email) {
312
+ throw new Error('Email required');
313
+ }
314
+ return repo.save(data);
315
+ };
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Framework Interoperability
321
+
322
+ ### Mix Alloy and Classic
323
+
324
+ You can use Alloy and include Classic CommonJS modules:
325
+
326
+ ```javascript
327
+ // In Alloy controller
328
+ var classicModule = require('lib/myClassicModule');
329
+ var data = classicModule.getData();
330
+ $.label.text = data;
331
+ ```
332
+
333
+ ### Migrate Classic to Alloy
334
+
335
+ 1. Create new Alloy project
336
+ 2. Move business logic to `controllers/` or `lib/`
337
+ 3. Convert UI creation to `views/` (XML)
338
+ 4. Create `styles/` (TSS) from inline styles
339
+ 5. Update data access to use `models/`
340
+
341
+ ---
342
+
343
+ ## Best Practices
344
+
345
+ ### For Alloy Projects
346
+
347
+ 1. **Follow MVC strictly** - Keep models/models, views/views, controllers/logic
348
+ 2. **Use data binding** - Avoid manual view updates
349
+ 3. **Leverage widgets** - Reusable components
350
+ 4. **Use themes** - For styling variations
351
+ 5. **Keep controllers lean** - Move business logic to lib/
352
+
353
+ ### For Classic Projects
354
+
355
+ 1. **Use CommonJS modules** - Not `Ti.include()`
356
+ 2. **Single namespace** - One global variable maximum
357
+ 3. **Protect global scope** - Use IIFEs
358
+ 4. **Separate concerns** - Models, views, controllers folders
359
+ 5. **Document patterns** - Make architecture clear to team
360
+
361
+ ### For Both
362
+
363
+ 1. **Memory management** - Clean up listeners, null objects
364
+ 2. **Error handling** - Try/catch around critical code
365
+ 3. **Logging** - Use Ti.API for debugging
366
+ 4. **Code style** - Follow `style-and-conventions.md`
367
+ 5. **Testing** - Write unit tests for business logic
368
+
369
+ ---
370
+
371
+ ## Resources
372
+
373
+ - **Alloy Guides:** See the `alloy-guides` skill
374
+ - **CommonJS Advanced:** See `commonjs-advanced.md`
375
+ - **Coding Best Practices:** See `coding-best-practices.md`
376
+ - **JavaScript Primer:** See `javascript-primer.md`
377
+ - **Alloy CLI:** See `alloy-cli-advanced.md`