@maccesar/titools 3.2.0 → 4.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/README.md +27 -61
- package/lib/cleanup.js +29 -0
- package/lib/commands/agents.js +8 -7
- package/lib/commands/skills.js +118 -23
- package/lib/config.js +13 -15
- package/lib/installer.js +5 -3
- package/lib/utils.js +36 -0
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +188 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +233 -0
- package/skills/alloy-guides/references/CONCEPTS.md +171 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +279 -0
- package/skills/alloy-guides/references/MODELS.md +742 -0
- package/skills/alloy-guides/references/MODELS_ADVANCED.md +482 -0
- package/skills/alloy-guides/references/PURGETSS.md +57 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +235 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +375 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +102 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +581 -0
- package/skills/alloy-guides/references/WIDGETS.md +160 -0
- package/skills/alloy-howtos/SKILL.md +179 -0
- package/skills/alloy-howtos/references/best_practices.md +121 -0
- package/skills/alloy-howtos/references/cli_reference.md +230 -0
- package/skills/alloy-howtos/references/config_files.md +158 -0
- package/skills/alloy-howtos/references/custom_tags.md +148 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +78 -0
- package/skills/alloy-howtos/references/samples.md +156 -0
- package/skills/purgetss/SKILL.md +184 -181
- package/skills/purgetss/references/EXAMPLES.md +8 -6
- package/skills/purgetss/references/app-branding.md +5 -0
- package/skills/purgetss/references/apply-directive.md +1 -1
- package/skills/purgetss/references/class-categories.md +1 -1
- package/skills/purgetss/references/class-index-properties.md +618 -0
- package/skills/purgetss/references/class-index.md +4 -610
- package/skills/purgetss/references/cli-commands.md +41 -410
- package/skills/purgetss/references/custom-fonts.md +292 -0
- package/skills/purgetss/references/custom-rules.md +1 -1
- package/skills/purgetss/references/customization-deep-dive.md +64 -1
- package/skills/purgetss/references/icon-fonts.md +208 -118
- package/skills/purgetss/references/installation-setup.md +4 -4
- package/skills/purgetss/references/migration-guide.md +53 -1
- package/skills/purgetss/references/multi-density-images.md +53 -2
- package/skills/purgetss/references/svg-pipeline.md +249 -0
- package/skills/purgetss/references/tikit-components.md +2 -2
- package/skills/purgetss/references/titanium-resets.md +2 -2
- package/skills/purgetss/references/ui-ux-design.md +7 -5
- package/skills/purgetss/references/version-history.md +71 -82
- package/skills/ti-api/SKILL.md +128 -0
- package/skills/ti-api/references/api-android.md +675 -0
- package/skills/ti-api/references/api-app-platform.md +636 -0
- package/skills/ti-api/references/api-core.md +764 -0
- package/skills/ti-api/references/api-data-network.md +641 -0
- package/skills/ti-api/references/api-media.md +655 -0
- package/skills/ti-api/references/api-modules-ble-bluetooth.md +657 -0
- package/skills/ti-api/references/api-modules-coremotion-urlsession.md +411 -0
- package/skills/ti-api/references/api-modules-map.md +632 -0
- package/skills/ti-api/references/api-modules-nfc.md +725 -0
- package/skills/ti-api/references/api-modules-social-misc.md +526 -0
- package/skills/ti-api/references/api-services.md +700 -0
- package/skills/ti-api/references/api-ui-android.md +499 -0
- package/skills/ti-api/references/api-ui-extras.md +702 -0
- package/skills/ti-api/references/api-ui-ios-animator.md +378 -0
- package/skills/ti-api/references/api-ui-ios.md +756 -0
- package/skills/ti-api/references/api-ui-lists.md +581 -0
- package/skills/ti-api/references/api-ui-text-input.md +607 -0
- package/skills/ti-api/references/api-ui-views.md +572 -0
- package/skills/ti-api/references/api-ui-windows-navigation.md +676 -0
- package/skills/ti-api/references/api-xml-global.md +743 -0
- package/skills/ti-guides/SKILL.md +82 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +155 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +373 -0
- package/skills/ti-guides/references/application-frameworks.md +366 -0
- package/skills/ti-guides/references/cli-reference.md +700 -0
- package/skills/ti-guides/references/coding-best-practices.md +150 -0
- package/skills/ti-guides/references/commonjs-advanced.md +279 -0
- package/skills/ti-guides/references/hello-world.md +99 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +458 -0
- package/skills/ti-guides/references/javascript-primer.md +402 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +172 -0
- package/skills/ti-guides/references/style-and-conventions.md +104 -0
- package/skills/ti-guides/references/tiapp-config.md +655 -0
- package/skills/ti-howtos/SKILL.md +131 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +609 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +96 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +162 -0
- package/skills/ti-howtos/references/cross-platform-development.md +358 -0
- package/skills/ti-howtos/references/debugging-profiling.md +473 -0
- package/skills/ti-howtos/references/extending-titanium.md +684 -0
- package/skills/ti-howtos/references/google-maps-v2.md +172 -0
- package/skills/ti-howtos/references/ios-map-kit.md +149 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +595 -0
- package/skills/ti-howtos/references/local-data-sources.md +310 -0
- package/skills/ti-howtos/references/location-and-maps.md +267 -0
- package/skills/ti-howtos/references/media-apis.md +268 -0
- package/skills/ti-howtos/references/notification-services.md +539 -0
- package/skills/ti-howtos/references/remote-data-sources.md +339 -0
- package/skills/ti-howtos/references/tutorials.md +552 -0
- package/skills/ti-howtos/references/using-modules.md +182 -0
- package/skills/ti-howtos/references/web-content-integration.md +288 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +125 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# Application frameworks
|
|
2
|
+
|
|
3
|
+
Framework options and architecture patterns for Titanium applications.
|
|
4
|
+
|
|
5
|
+
## Alloy framework
|
|
6
|
+
|
|
7
|
+
Alloy is the official MVC framework for Titanium. It was developed by Appcelerator and is now maintained by TiDev.
|
|
8
|
+
|
|
9
|
+
### What Alloy provides
|
|
10
|
+
|
|
11
|
+
- MVC structure with models, views, and controllers
|
|
12
|
+
- Built-in libraries (Backbone.js, Underscore.js)
|
|
13
|
+
- XML views for declarative UI
|
|
14
|
+
- TSS for CSS-like styling
|
|
15
|
+
- Data binding between views and models
|
|
16
|
+
- Widgets for reusable UI components
|
|
17
|
+
- Model and collection sync with REST and SQL adapters
|
|
18
|
+
|
|
19
|
+
### Project structure
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
app/
|
|
23
|
+
├── controllers/ # UI logic
|
|
24
|
+
├── models/ # Data models
|
|
25
|
+
├── views/ # XML view definitions
|
|
26
|
+
├── styles/ # TSS style sheets
|
|
27
|
+
├── assets/ # Images, fonts
|
|
28
|
+
├── lib/ # CommonJS libraries
|
|
29
|
+
├── themes/ # Theming support
|
|
30
|
+
├── config.json # App configuration
|
|
31
|
+
└── alloy.js # Entry point
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Sample Alloy code
|
|
35
|
+
|
|
36
|
+
View (XML):
|
|
37
|
+
```xml
|
|
38
|
+
<Alloy>
|
|
39
|
+
<Window class="container">
|
|
40
|
+
<Label id="title" onClick="doClick">Click Me</Label>
|
|
41
|
+
</Window>
|
|
42
|
+
</Alloy>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Style (TSS):
|
|
46
|
+
```css
|
|
47
|
+
".container": {
|
|
48
|
+
backgroundColor: "#fff"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
"#title": {
|
|
52
|
+
color: "#000",
|
|
53
|
+
font: { fontSize: 18 }
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Controller (JS):
|
|
58
|
+
```javascript
|
|
59
|
+
const doClick = (e) => {
|
|
60
|
+
alert('Clicked!');
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
$.index.open();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Alloy resources
|
|
67
|
+
|
|
68
|
+
- Alloy guides: see the `alloy-guides` skill
|
|
69
|
+
- Alloy CLI: see `alloy-cli-advanced.md`
|
|
70
|
+
- Alloy data: see `alloy-data-mastery.md`
|
|
71
|
+
- Alloy widgets: see `alloy-widgets-and-themes.md`
|
|
72
|
+
|
|
73
|
+
### Angular integration
|
|
74
|
+
|
|
75
|
+
Angular integration with Titanium SDK was under development but is no longer maintained.
|
|
76
|
+
|
|
77
|
+
### React community framework
|
|
78
|
+
|
|
79
|
+
A community React integration exists at https://github.com/nicolomonili/react-titanium (experimental).
|
|
80
|
+
|
|
81
|
+
### When to use Alloy
|
|
82
|
+
|
|
83
|
+
Use Alloy for:
|
|
84
|
+
- New projects (default choice)
|
|
85
|
+
- Teams that want MVC structure
|
|
86
|
+
- Projects that need data binding
|
|
87
|
+
- Rapid development with XML views
|
|
88
|
+
- Reusable components (widgets)
|
|
89
|
+
|
|
90
|
+
Consider alternatives for:
|
|
91
|
+
- Very simple apps
|
|
92
|
+
- Teams that prefer pure JavaScript
|
|
93
|
+
- Projects with unique architectural needs
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Classic Titanium
|
|
98
|
+
|
|
99
|
+
Classic Titanium means building apps without Alloy, using JavaScript and CommonJS modules.
|
|
100
|
+
|
|
101
|
+
### Project structure
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Resources/
|
|
105
|
+
├── app.js # Entry point
|
|
106
|
+
├── ui/ # UI components
|
|
107
|
+
│ ├── ApplicationWindow.js
|
|
108
|
+
│ └── ...
|
|
109
|
+
├── models/ # Data models
|
|
110
|
+
├── lib/ # Utilities
|
|
111
|
+
└── assets/ # Images, etc.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Sample Classic code
|
|
115
|
+
|
|
116
|
+
app.js:
|
|
117
|
+
```javascript
|
|
118
|
+
// Single namespace pattern
|
|
119
|
+
const app = {};
|
|
120
|
+
|
|
121
|
+
// Load components via require (Ti.include is deprecated)
|
|
122
|
+
const AppWindow = require('ui/ApplicationWindow');
|
|
123
|
+
|
|
124
|
+
// Create and open window
|
|
125
|
+
app.mainWindow = AppWindow.createApplicationWindow();
|
|
126
|
+
app.mainWindow.open();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
ui/ApplicationWindow.js:
|
|
130
|
+
```javascript
|
|
131
|
+
// Extend namespace
|
|
132
|
+
app.ui = app.ui || {};
|
|
133
|
+
|
|
134
|
+
app.ui.createApplicationWindow = () => {
|
|
135
|
+
const win = Ti.UI.createWindow({
|
|
136
|
+
backgroundColor: 'white',
|
|
137
|
+
title: 'My App'
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const label = Ti.UI.createLabel({
|
|
141
|
+
text: 'Hello World',
|
|
142
|
+
color: '#000'
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
win.add(label);
|
|
146
|
+
return win;
|
|
147
|
+
};
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### CommonJS pattern (recommended)
|
|
151
|
+
|
|
152
|
+
myModule.js:
|
|
153
|
+
```javascript
|
|
154
|
+
// Private variables
|
|
155
|
+
const privateData = 'secret';
|
|
156
|
+
|
|
157
|
+
// Public API
|
|
158
|
+
exports.createWindow = () => {
|
|
159
|
+
return Ti.UI.createWindow({
|
|
160
|
+
backgroundColor: 'white'
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
exports.getData = () => {
|
|
165
|
+
return privateData;
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
app.js:
|
|
170
|
+
```javascript
|
|
171
|
+
const myModule = require('myModule');
|
|
172
|
+
const win = myModule.createWindow();
|
|
173
|
+
win.open();
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### When to use Classic
|
|
177
|
+
|
|
178
|
+
Use Classic for:
|
|
179
|
+
- Simple projects
|
|
180
|
+
- Developers who prefer pure JavaScript
|
|
181
|
+
- Migrating from older Titanium projects
|
|
182
|
+
- Fine-grained control over UI creation
|
|
183
|
+
- Learning the Titanium API directly
|
|
184
|
+
|
|
185
|
+
Consider Alloy for:
|
|
186
|
+
- Large teams
|
|
187
|
+
- Complex apps with many screens
|
|
188
|
+
- Projects that need built-in MVC
|
|
189
|
+
- Data-heavy applications
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Choosing a framework
|
|
194
|
+
|
|
195
|
+
### Comparison
|
|
196
|
+
|
|
197
|
+
| Feature | Alloy | Classic |
|
|
198
|
+
| ----------------- | ----------------------- | ------------------ |
|
|
199
|
+
| Learning curve | Steeper (XML, TSS, MVC) | Easier (just JS) |
|
|
200
|
+
| Boilerplate | Less (declarative) | More (imperative) |
|
|
201
|
+
| Structure | Enforced (MVC) | Manual |
|
|
202
|
+
| Data binding | Built-in | Manual |
|
|
203
|
+
| Styling | TSS (CSS-like) | Inline JS |
|
|
204
|
+
| Team size | Better for large teams | Flexible |
|
|
205
|
+
| Rapid development | Faster once learned | Slower (more code) |
|
|
206
|
+
|
|
207
|
+
### Recommendation
|
|
208
|
+
|
|
209
|
+
Start with Alloy if you are building a new app or expect multiple contributors. If Alloy feels like overhead or the app is very small, Classic is fine.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Architecture patterns
|
|
214
|
+
|
|
215
|
+
### Namespaced pattern
|
|
216
|
+
|
|
217
|
+
Classic Titanium pattern with a single global namespace:
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
const app = {
|
|
221
|
+
models: {},
|
|
222
|
+
views: {},
|
|
223
|
+
controllers: {},
|
|
224
|
+
|
|
225
|
+
init() {
|
|
226
|
+
// Initialize app
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
run() {
|
|
230
|
+
// Run app
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
app.init();
|
|
235
|
+
app.run();
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### CommonJS modules
|
|
239
|
+
|
|
240
|
+
Modern JavaScript pattern for Titanium:
|
|
241
|
+
|
|
242
|
+
models/user.js:
|
|
243
|
+
```javascript
|
|
244
|
+
exports.create = (attrs) => {
|
|
245
|
+
return {
|
|
246
|
+
name: attrs.name,
|
|
247
|
+
email: attrs.email,
|
|
248
|
+
save() {
|
|
249
|
+
// Save to database
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
controllers/user.js:
|
|
256
|
+
```javascript
|
|
257
|
+
const User = require('models/user');
|
|
258
|
+
|
|
259
|
+
exports.register = (data) => {
|
|
260
|
+
const user = User.create(data);
|
|
261
|
+
user.save();
|
|
262
|
+
return user;
|
|
263
|
+
};
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### MVC with Alloy (built-in)
|
|
267
|
+
|
|
268
|
+
Alloy enforces MVC:
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
app/
|
|
272
|
+
├── controllers/userController.js # Logic
|
|
273
|
+
├── models/userModel.js # Data
|
|
274
|
+
└── views/userView.xml # Presentation
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Repository pattern
|
|
278
|
+
|
|
279
|
+
Separate data access from business logic:
|
|
280
|
+
|
|
281
|
+
repositories/userRepository.js:
|
|
282
|
+
```javascript
|
|
283
|
+
exports.findById = (id) => {
|
|
284
|
+
// Database call
|
|
285
|
+
return db.query('SELECT * FROM users WHERE id = ?', [id]);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
exports.save = (user) => {
|
|
289
|
+
// Insert/update
|
|
290
|
+
return db.execute('INSERT INTO users ...');
|
|
291
|
+
};
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
services/userService.js:
|
|
295
|
+
```javascript
|
|
296
|
+
const repo = require('repositories/userRepository');
|
|
297
|
+
|
|
298
|
+
exports.register = (data) => {
|
|
299
|
+
// Business logic
|
|
300
|
+
if (!data.email) {
|
|
301
|
+
throw new Error('Email required');
|
|
302
|
+
}
|
|
303
|
+
return repo.save(data);
|
|
304
|
+
};
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Framework interoperability
|
|
310
|
+
|
|
311
|
+
### Mix Alloy and Classic
|
|
312
|
+
|
|
313
|
+
You can use Alloy and include Classic CommonJS modules:
|
|
314
|
+
|
|
315
|
+
```javascript
|
|
316
|
+
// In Alloy controller
|
|
317
|
+
var classicModule = require('lib/myClassicModule');
|
|
318
|
+
var data = classicModule.getData();
|
|
319
|
+
$.label.text = data;
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Migrate Classic to Alloy
|
|
323
|
+
|
|
324
|
+
1. Create a new Alloy project.
|
|
325
|
+
2. Move business logic to `controllers/` or `lib/`.
|
|
326
|
+
3. Convert UI creation to `views/` (XML).
|
|
327
|
+
4. Create `styles/` (TSS) from inline styles.
|
|
328
|
+
5. Update data access to use `models/`.
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Best practices
|
|
333
|
+
|
|
334
|
+
### For Alloy projects
|
|
335
|
+
|
|
336
|
+
1. Follow MVC strictly. Keep models in `models/`, views in `views/`, and controller logic in `controllers/`.
|
|
337
|
+
2. Use data binding and avoid manual view updates.
|
|
338
|
+
3. Use widgets for reusable UI.
|
|
339
|
+
4. Use themes for styling variants.
|
|
340
|
+
5. Keep controllers lean and move business logic to `lib/`.
|
|
341
|
+
|
|
342
|
+
### For Classic projects
|
|
343
|
+
|
|
344
|
+
1. Use CommonJS modules instead of `Ti.include()`.
|
|
345
|
+
2. Keep a single global namespace.
|
|
346
|
+
3. Protect global scope with IIFEs.
|
|
347
|
+
4. Separate concerns with `models/`, `views/`, and `controllers/` folders.
|
|
348
|
+
5. Document patterns so the team shares the same structure.
|
|
349
|
+
|
|
350
|
+
### For both
|
|
351
|
+
|
|
352
|
+
1. Clean up listeners and null heavy objects.
|
|
353
|
+
2. Add try/catch around critical code paths.
|
|
354
|
+
3. Use `Ti.API` for logging.
|
|
355
|
+
4. Follow `style-and-conventions.md` for code style.
|
|
356
|
+
5. Write unit tests for business logic.
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Resources
|
|
361
|
+
|
|
362
|
+
- Alloy guides: see the `alloy-guides` skill
|
|
363
|
+
- CommonJS advanced: see `commonjs-advanced.md`
|
|
364
|
+
- Coding best practices: see `coding-best-practices.md`
|
|
365
|
+
- JavaScript primer: see `javascript-primer.md`
|
|
366
|
+
- Alloy CLI: see `alloy-cli-advanced.md`
|