@maccesar/titools 2.10.0 → 3.1.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 (99) hide show
  1. package/AGENTS-VERCEL-RESEARCH.md +23 -12
  2. package/README.md +81 -182
  3. package/agents/ti-pro.md +8 -14
  4. package/lib/cleanup.js +13 -0
  5. package/lib/commands/skills.js +2 -1
  6. package/lib/commands/update.js +4 -1
  7. package/lib/config.js +9 -11
  8. package/lib/platform.js +1 -1
  9. package/package.json +2 -3
  10. package/skills/purgetss/SKILL.md +12 -0
  11. package/skills/purgetss/references/animation-advanced.md +0 -9
  12. package/skills/purgetss/references/app-branding.md +20 -0
  13. package/skills/purgetss/references/appearance-module.md +85 -27
  14. package/skills/purgetss/references/apply-directive.md +60 -0
  15. package/skills/purgetss/references/arbitrary-values.md +41 -0
  16. package/skills/purgetss/references/cli-commands.md +52 -17
  17. package/skills/purgetss/references/custom-rules.md +36 -19
  18. package/skills/purgetss/references/customization-deep-dive.md +37 -15
  19. package/skills/purgetss/references/grid-layout.md +45 -26
  20. package/skills/purgetss/references/icon-fonts.md +27 -25
  21. package/skills/purgetss/references/installation-setup.md +28 -2
  22. package/skills/purgetss/references/ios-large-titles.md +31 -15
  23. package/skills/purgetss/references/multi-density-images.md +57 -0
  24. package/skills/purgetss/references/opacity-modifier.md +11 -2
  25. package/skills/purgetss/references/semantic-colors.md +44 -1
  26. package/skills/purgetss/references/tikit-components.md +1 -3
  27. package/skills/alloy-guides/SKILL.md +0 -190
  28. package/skills/alloy-guides/references/CLI_TASKS.md +0 -233
  29. package/skills/alloy-guides/references/CONCEPTS.md +0 -171
  30. package/skills/alloy-guides/references/CONTROLLERS.md +0 -279
  31. package/skills/alloy-guides/references/MODELS.md +0 -1214
  32. package/skills/alloy-guides/references/PURGETSS.md +0 -46
  33. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +0 -235
  34. package/skills/alloy-guides/references/VIEWS_STYLES.md +0 -375
  35. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
  36. package/skills/alloy-guides/references/VIEWS_XML.md +0 -581
  37. package/skills/alloy-guides/references/WIDGETS.md +0 -160
  38. package/skills/alloy-howtos/SKILL.md +0 -181
  39. package/skills/alloy-howtos/references/best_practices.md +0 -121
  40. package/skills/alloy-howtos/references/cli_reference.md +0 -230
  41. package/skills/alloy-howtos/references/config_files.md +0 -158
  42. package/skills/alloy-howtos/references/custom_tags.md +0 -148
  43. package/skills/alloy-howtos/references/debugging_troubleshooting.md +0 -78
  44. package/skills/alloy-howtos/references/samples.md +0 -156
  45. package/skills/ti-api/SKILL.md +0 -109
  46. package/skills/ti-api/references/api-android.md +0 -675
  47. package/skills/ti-api/references/api-app-platform.md +0 -636
  48. package/skills/ti-api/references/api-core.md +0 -764
  49. package/skills/ti-api/references/api-data-network.md +0 -641
  50. package/skills/ti-api/references/api-media.md +0 -655
  51. package/skills/ti-api/references/api-modules-ble-bluetooth.md +0 -657
  52. package/skills/ti-api/references/api-modules-coremotion-urlsession.md +0 -411
  53. package/skills/ti-api/references/api-modules-map.md +0 -632
  54. package/skills/ti-api/references/api-modules-nfc.md +0 -725
  55. package/skills/ti-api/references/api-modules-social-misc.md +0 -526
  56. package/skills/ti-api/references/api-services.md +0 -700
  57. package/skills/ti-api/references/api-ui-android.md +0 -499
  58. package/skills/ti-api/references/api-ui-extras.md +0 -702
  59. package/skills/ti-api/references/api-ui-ios-animator.md +0 -378
  60. package/skills/ti-api/references/api-ui-ios.md +0 -756
  61. package/skills/ti-api/references/api-ui-lists.md +0 -581
  62. package/skills/ti-api/references/api-ui-text-input.md +0 -607
  63. package/skills/ti-api/references/api-ui-views.md +0 -572
  64. package/skills/ti-api/references/api-ui-windows-navigation.md +0 -676
  65. package/skills/ti-api/references/api-xml-global.md +0 -743
  66. package/skills/ti-guides/SKILL.md +0 -75
  67. package/skills/ti-guides/references/advanced-data-and-images.md +0 -155
  68. package/skills/ti-guides/references/android-manifest.md +0 -97
  69. package/skills/ti-guides/references/app-distribution.md +0 -373
  70. package/skills/ti-guides/references/application-frameworks.md +0 -366
  71. package/skills/ti-guides/references/cli-reference.md +0 -700
  72. package/skills/ti-guides/references/coding-best-practices.md +0 -150
  73. package/skills/ti-guides/references/commonjs-advanced.md +0 -279
  74. package/skills/ti-guides/references/hello-world.md +0 -99
  75. package/skills/ti-guides/references/hyperloop-native-access.md +0 -458
  76. package/skills/ti-guides/references/javascript-primer.md +0 -402
  77. package/skills/ti-guides/references/reserved-words.md +0 -36
  78. package/skills/ti-guides/references/resources.md +0 -172
  79. package/skills/ti-guides/references/style-and-conventions.md +0 -104
  80. package/skills/ti-guides/references/tiapp-config.md +0 -655
  81. package/skills/ti-howtos/SKILL.md +0 -143
  82. package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -609
  83. package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
  84. package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
  85. package/skills/ti-howtos/references/cross-platform-development.md +0 -358
  86. package/skills/ti-howtos/references/debugging-profiling.md +0 -473
  87. package/skills/ti-howtos/references/extending-titanium.md +0 -684
  88. package/skills/ti-howtos/references/google-maps-v2.md +0 -172
  89. package/skills/ti-howtos/references/ios-map-kit.md +0 -149
  90. package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -595
  91. package/skills/ti-howtos/references/local-data-sources.md +0 -310
  92. package/skills/ti-howtos/references/location-and-maps.md +0 -267
  93. package/skills/ti-howtos/references/media-apis.md +0 -268
  94. package/skills/ti-howtos/references/notification-services.md +0 -539
  95. package/skills/ti-howtos/references/remote-data-sources.md +0 -339
  96. package/skills/ti-howtos/references/tutorials.md +0 -552
  97. package/skills/ti-howtos/references/using-modules.md +0 -182
  98. package/skills/ti-howtos/references/web-content-integration.md +0 -288
  99. package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -125
@@ -1,473 +0,0 @@
1
- # Debugging and profiling
2
-
3
- Guide to debugging Titanium apps, managing memory, finding leaks, and using native tools.
4
-
5
- ## Debugging overview
6
-
7
- ### Essential elements of debugging
8
-
9
- 1. Gather information: clear, accurate description of the problem
10
- 2. Reproduce: consistent steps to recreate the issue
11
- 3. Deduce: logical reasoning to isolate the cause
12
- 4. Experiment: try fixes iteratively, track what works
13
- 5. Be tenacious: methodical persistence wins
14
- 6. Track work: document bugs and solutions
15
-
16
- ### Debugging techniques
17
-
18
- 1. Print tracing (logging)
19
- ```javascript
20
- Ti.API.info(`Variable value: ${myVar}`);
21
- Ti.API.warn('Warning message');
22
- Ti.API.error('Error occurred');
23
- Ti.API.log('info', 'Custom level message');
24
- Ti.API.debug('Debug info'); // Only in dev mode
25
- ```
26
-
27
- 2. Crash log evaluation
28
- - Build logs (compilation errors)
29
- - Runtime logs (app crashes)
30
- - Simulator/Emulator logs
31
- - Device logs
32
-
33
- 3. Interactive debugging
34
- - Breakpoints in Studio/IDE
35
- - Variable inspection
36
- - Step-through execution
37
-
38
- ## Memory management
39
-
40
- ### How JavaScript manages memory
41
-
42
- Garbage collection: JavaScript uses automatic mark-and-sweep.
43
-
44
- 1. Interpreter scans memory periodically
45
- 2. Marks objects with active references
46
- 3. Destroys unmarked objects
47
- 4. Frees their memory
48
-
49
- Implication: objects with no references are cleaned up automatically.
50
-
51
- ### How Titanium manages memory
52
-
53
- Titanium bridges JavaScript and native OS objects:
54
-
55
- ```javascript
56
- // JavaScript object + Native proxy
57
- const button = Ti.UI.createButton({ title: 'Click me' });
58
- ```
59
-
60
- Key rule: setting a JavaScript object to `null` destroys both the JavaScript object and the native proxy.
61
-
62
- ### Releasing memory properly
63
-
64
- Complete cleanup:
65
- ```javascript
66
- let view = Ti.UI.createView({ backgroundColor: 'white' });
67
- win.add(view);
68
-
69
- // Later: remove and nullify
70
- win.remove(view);
71
- view = null; // Destroys native proxy
72
- ```
73
-
74
- Incomplete cleanup (memory leak):
75
- ```javascript
76
- let view = Ti.UI.createView({ backgroundColor: 'white' });
77
- win.add(view);
78
-
79
- // Later: only remove
80
- win.remove(view); // view object still exists in memory
81
- ```
82
-
83
- ### Parent-child relationships
84
-
85
- ```javascript
86
- // Good: children not referenced elsewhere
87
- let view = Ti.UI.createView({
88
- backgroundColor: 'white'
89
- });
90
- view.add(Ti.UI.createButton({ title: 'Click' })); // Anonymous child
91
-
92
- win.remove(view);
93
- view = null; // Destroys view and button
94
-
95
- // Bad: children referenced separately
96
- const button = Ti.UI.createButton({ title: 'Click' });
97
- let view = Ti.UI.createView({ backgroundColor: 'white' });
98
- view.add(button);
99
-
100
- win.remove(view);
101
- view = null; // Destroys view, but button still exists
102
- button = null; // Now button is destroyed
103
- ```
104
-
105
- ### Platform memory limits
106
-
107
- | Platform | Memory limit |
108
- | -------- | -------------------------------------- |
109
- | iPhone | ~10% of system memory |
110
- | iPad | 30-50 MB (smaller is better) |
111
- | Android | 24-32 MB heap (128 MB with large heap) |
112
-
113
- Notes for iOS:
114
- - Apple does not publish exact limits
115
- - The jetsam process can terminate your app
116
- - "Jetsam" in crash logs often means a memory issue
117
-
118
- Important: memory is not storage. A 16GB device does not mean 16GB for your app. Limits may be higher on newer devices, but optimize for the lowest common denominator.
119
-
120
- ## Memory leak detection
121
-
122
- ### Common leak sources
123
-
124
- 1. Global event listeners
125
- ```javascript
126
- // Leak: listener keeps reference to window
127
- Ti.App.addEventListener('custom:event', (e) => {
128
- // Uses window variables
129
- });
130
- ```
131
-
132
- Fix: remove listeners when closing window
133
- ```javascript
134
- const myHandler = (e) => {
135
- // Handle event
136
- };
137
-
138
- Ti.App.addEventListener('custom:event', myHandler);
139
-
140
- win.addEventListener('close', () => {
141
- Ti.App.removeEventListener('custom:event', myHandler);
142
- });
143
- ```
144
-
145
- 2. Objects in closures
146
- ```javascript
147
- // Leak: closure retains object reference
148
- function createWindow() {
149
- const data = []; // Large array
150
- return Ti.UI.createWindow({
151
- listener: () => {
152
- data.push('more'); // Closure reference
153
- }
154
- });
155
- }
156
- ```
157
-
158
- Fix: pass data as an argument instead of keeping it in a closure.
159
-
160
- 3. Hidden views
161
- ```javascript
162
- // Leak: hidden view still consumes memory
163
- view.visible = false; // Not enough
164
- ```
165
-
166
- Fix: remove and nullify when not needed
167
- ```javascript
168
- view.visible = false;
169
- parent.remove(view);
170
- view = null;
171
- ```
172
-
173
- ### Debugging memory on iOS (Instruments)
174
-
175
- Setup:
176
- 1. Open app in iOS Simulator
177
- 2. Xcode → Open Developer Tool → Instruments
178
- 3. Choose Allocations template
179
- 4. Choose Target → Your App
180
- 5. Click Record
181
-
182
- Key columns:
183
- | Column | What it shows |
184
- | ----------------------------- | ------------------------ |
185
- | Persistent Bytes (Live Bytes) | Memory currently in use |
186
- | #Persistent (#Living) | Active object count |
187
- | #Transient (#Transitory) | Ready to garbage collect |
188
-
189
- Identifying leaks:
190
- 1. Filter for `Ti` prefix (Titanium objects)
191
- 2. Watch #Living as you use the app
192
- 3. If it grows continuously, you have a leak
193
- 4. #Transitory growing is fine (will be GC'd)
194
-
195
- Example workflow:
196
- ```
197
- 1. Filter: "TiUITableView" (table views)
198
- 2. Open/close a table view screen
199
- 3. Click "Cause GC" (garbage collection)
200
- 4. Check if #Living returns to previous value
201
- 5. If not, the leak is in that screen
202
- ```
203
-
204
- ### Debugging memory on Android (DDMS)
205
-
206
- Setup:
207
- 1. Add to `tiapp.xml`:
208
- ```xml
209
- <android xmlns:android="http://schemas.android.com/apk/res/android">
210
- <manifest>
211
- <application android:debuggable="true">
212
- </application>
213
- </manifest>
214
- </android>
215
- ```
216
-
217
- 2. Build app for emulator
218
- 3. Open DDMS (Android Device Monitor)
219
-
220
- Monitoring:
221
- 1. Select your app process
222
- 2. Click Update Heap
223
- 3. Click Cause GC to force garbage collection
224
- 4. Watch Allocated and # Objects values
225
-
226
- Identifying leaks:
227
- 1. Note initial values after GC
228
- 2. Exercise app (open/close screens)
229
- 3. Click Cause GC again
230
- 4. If values do not return to baseline, there is a leak
231
-
232
- ## Android debugging tools
233
-
234
- ### DDMS (Dalvik Debug Monitor Service)
235
-
236
- Features:
237
- - View log output
238
- - Explore file system
239
- - Simulate network conditions
240
- - Simulate calls/SMS
241
- - Set GPS coordinates
242
- - Monitor memory
243
-
244
- #### Log output with DDMS
245
-
246
- 1. Open DDMS
247
- 2. Select device/emulator
248
- 3. View log in lower pane
249
- 4. Add filter: Log Tag = `TiAPI`
250
-
251
- #### Simulate network conditions
252
-
253
- Emulator Control panel:
254
- - Voice/Data state (home, roaming)
255
- - Data speed and latency
256
- - Test app behavior in poor conditions
257
-
258
- #### Simulate calls/SMS
259
-
260
- Emulator Control → Telephony Actions:
261
- - Incoming voice call
262
- - Incoming SMS message
263
- - Test app interruption handling
264
-
265
- #### Set GPS coordinates
266
-
267
- Emulator Control → Location Controls:
268
- - Enter latitude/longitude
269
- - Click Send
270
- - Emulator uses these as current location
271
-
272
- #### File system exploration
273
-
274
- Device → File Explorer:
275
- - Browse entire file system
276
- - Pull files (copy to computer)
277
- - Push files (copy to device)
278
- - Delete files
279
-
280
- #### Memory monitoring
281
-
282
- Less useful for Titanium (JavaScript runs in one process), but it can show overall memory trends.
283
-
284
- ### ADB (Android Debug Bridge)
285
-
286
- #### Log output
287
-
288
- ```bash
289
- # View all logs
290
- adb logcat
291
-
292
- # Device only
293
- adb -d logcat
294
-
295
- # Emulator only
296
- adb -e logcat
297
-
298
- # Specific device
299
- adb -s emulator-5556 logcat
300
-
301
- # Filter for Titanium
302
- adb logcat -s TiAPI
303
- # or
304
- adb logcat | grep TiAPI
305
- ```
306
-
307
- #### File system
308
-
309
- ```bash
310
- # Open shell
311
- adb shell
312
-
313
- # List files
314
- ls -la
315
- cd /some/path
316
-
317
- # Exit shell
318
- exit
319
- ```
320
-
321
- #### Transfer files
322
-
323
- ```bash
324
- # Copy file TO device
325
- adb push local.txt /sdcard/local.txt
326
-
327
- # Copy file FROM device
328
- adb pull /sdcard/remote.txt local.txt
329
- ```
330
-
331
- #### Access SQLite databases
332
-
333
- ```bash
334
- adb shell
335
-
336
- # List databases
337
- ls /data/data/com.example.app/databases/
338
-
339
- # Open database
340
- sqlite3 /data/data/com.example.app/databases/mydb.sqlite
341
-
342
- # Query
343
- SELECT * FROM tablename;
344
-
345
- # Exit
346
- .exit
347
- ```
348
-
349
- ### Creating emulators
350
-
351
- > **⚠️ AVD Manager moved to Android Studio**
352
- > The legacy `android` CLI (`android create avd`, `android avd`) was removed in Android SDK Tools 25.3. Use Android Studio's built-in **AVD Manager** (Tools → Device Manager) or the command-line `avdmanager` tool instead.
353
-
354
- Command line (modern):
355
- ```bash
356
- # List available system images
357
- sdkmanager --list | grep system-images
358
-
359
- # Create AVD with avdmanager
360
- avdmanager create avd -n my_emulator -k "system-images;android-34;google_apis;x86_64"
361
-
362
- # Launch emulator
363
- emulator -avd my_emulator
364
- ```
365
-
366
- Android Studio (GUI): Tools → Device Manager → Create Device.
367
-
368
- ### Modifying emulators
369
-
370
- Increase disk space:
371
- Edit `~/.android/avd/<NAME>.avd/config.ini`:
372
- ```
373
- disk.dataPartition.size=1024m
374
- ```
375
-
376
- Scale on-the-fly:
377
- ```bash
378
- # Get emulator port
379
- adb devices
380
- # emulator-5560
381
-
382
- # Connect with telnet
383
- telnet localhost 5560
384
-
385
- # Scale to 75%
386
- window scale 0.75
387
- ```
388
-
389
- ## iOS debugging tools
390
-
391
- ### Instruments
392
-
393
- Key templates for Titanium debugging:
394
- - Allocations: track object creation and live object counts. Look at Persistent Bytes (Live Bytes) and #Persistent (#Living).
395
- - Leaks: detect memory leaks in real time. Shows objects that are allocated but never released.
396
- - Time Profiler: identify CPU-intensive operations and bottlenecks.
397
- - System Trace: system-level events and thread activity.
398
- - Zombies: detect messages sent to deallocated objects (debug builds only). Useful for over-released objects.
399
-
400
- ### Xcode build debugging
401
-
402
- For native debugging, open the Xcode project in `build/iphone`:
403
- 1. Product → Profile
404
- 2. Choose Instruments template
405
- 3. More accurate than attaching to a running process
406
-
407
- ### Console logs
408
-
409
- Viewing in Studio:
410
- - Console panel shows build/run output
411
-
412
- Viewing separately:
413
- ```bash
414
- # For running apps
415
- tail -f ~/Library/Logs/CoreSimulator/<SIMULATOR_ID>/system.log
416
- ```
417
-
418
- ## 6. Automation and UI testing
419
-
420
- For CI/CD pipelines, automated deployment, and functional testing, see:
421
-
422
- - Automation with Fastlane and Appium: `automation-fastlane-appium.md`
423
-
424
- ## Best practices
425
-
426
- ### Memory management
427
-
428
- 1. Always nullify objects after removing them from the view hierarchy.
429
- 2. Remove event listeners when closing windows.
430
- 3. Avoid global variables; use namespaces or CommonJS.
431
- 4. Use a single execution context, not multiple URL-based windows.
432
- 5. Be careful with closures; they retain references.
433
- 6. Hide vs remove: hide for temporary, remove/nullify for permanent.
434
-
435
- ### Debugging
436
-
437
- 1. Log strategically and remove sensitive logs before production.
438
- 2. Use descriptive log messages and include variable values.
439
- 3. Test on real devices; simulators miss issues.
440
- 4. Profile early and often; do not wait for crashes.
441
- 5. Reproduce consistently; you cannot fix what you cannot reproduce.
442
- 6. Keep track of bugs; use an issue tracker.
443
-
444
- ### Performance
445
-
446
- 1. Avoid excessive polling; use events when possible.
447
- 2. Defer loading; load data as needed.
448
- 3. Optimize images; compress and use appropriate sizes.
449
- 4. Minimize bridge crossings; cache platform checks.
450
- 5. Test on slow networks; simulate poor conditions.
451
- 6. Profile before optimizing; measure first, then fix hotspots.
452
-
453
- ## Platform-specific notes
454
-
455
- ### Android
456
-
457
- - Debuggable flag: required for native debugging
458
- - Large heap: enable in `tiapp.xml` if needed
459
- - ProGuard: can obfuscate and optimize code
460
- - Multidex: may be needed for very large apps
461
-
462
- ### iOS
463
-
464
- - Instruments: most powerful tool for iOS profiling
465
- - Zombies: Instruments tool to find over-released objects
466
- - Allocation tracker: shows object creation and lifecycle
467
- - Time Profiler: identifies CPU bottlenecks
468
-
469
- ## Resources
470
-
471
- - Video: Your Apps are Leaking (Codestrong 2011)
472
- - Android DDMS docs: https://minimum-viable-product.github.io/marshmallow-docs/tools/debugging/ddms.html
473
- - iOS Instruments guide: Apple Developer Documentation