@maccesar/titools 2.0.7 → 2.2.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 (132) hide show
  1. package/{AGENTS-TEMPLATE.md → AGENTS-VERCEL-RESEARCH.md} +16 -18
  2. package/README.md +250 -168
  3. package/agents/{ti-researcher.md → ti-pro.md} +10 -10
  4. package/bin/titools.js +16 -12
  5. package/lib/cleanup.js +95 -0
  6. package/lib/commands/agents.js +146 -70
  7. package/lib/commands/skills.js +349 -0
  8. package/lib/commands/uninstall.js +189 -154
  9. package/lib/commands/update.js +104 -21
  10. package/lib/config.js +26 -20
  11. package/lib/downloader.js +1 -1
  12. package/lib/installer.js +37 -97
  13. package/lib/platform.js +9 -5
  14. package/lib/prompts/checkboxCancel.js +264 -0
  15. package/lib/prompts/selectCancel.js +204 -0
  16. package/lib/symlink.js +19 -7
  17. package/lib/utils.js +17 -17
  18. package/package.json +10 -10
  19. package/skills/alloy-guides/SKILL.md +8 -30
  20. package/skills/alloy-guides/references/CLI_TASKS.md +14 -24
  21. package/skills/alloy-guides/references/CONCEPTS.md +5 -25
  22. package/skills/alloy-guides/references/CONTROLLERS.md +2 -19
  23. package/skills/alloy-guides/references/MODELS.md +40 -10
  24. package/skills/alloy-guides/references/PURGETSS.md +1 -11
  25. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +8 -14
  26. package/skills/alloy-guides/references/VIEWS_STYLES.md +14 -25
  27. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +2 -8
  28. package/skills/alloy-guides/references/VIEWS_XML.md +29 -40
  29. package/skills/alloy-guides/references/WIDGETS.md +1 -17
  30. package/skills/alloy-howtos/SKILL.md +1 -22
  31. package/skills/alloy-howtos/references/best_practices.md +0 -17
  32. package/skills/alloy-howtos/references/cli_reference.md +1 -23
  33. package/skills/alloy-howtos/references/config_files.md +86 -15
  34. package/skills/alloy-howtos/references/custom_tags.md +14 -13
  35. package/skills/alloy-howtos/references/debugging_troubleshooting.md +3 -22
  36. package/skills/alloy-howtos/references/samples.md +4 -14
  37. package/skills/purgetss/SKILL.md +11 -37
  38. package/skills/purgetss/references/EXAMPLES.md +106 -17
  39. package/skills/purgetss/references/animation-system.md +0 -67
  40. package/skills/purgetss/references/apply-directive.md +0 -18
  41. package/skills/purgetss/references/arbitrary-values.md +0 -25
  42. package/skills/purgetss/references/class-index.md +0 -46
  43. package/skills/purgetss/references/cli-commands.md +0 -41
  44. package/skills/purgetss/references/configurable-properties.md +0 -55
  45. package/skills/purgetss/references/custom-rules.md +0 -14
  46. package/skills/purgetss/references/customization-deep-dive.md +0 -49
  47. package/skills/purgetss/references/dynamic-component-creation.md +56 -37
  48. package/skills/purgetss/references/grid-layout.md +0 -32
  49. package/skills/purgetss/references/icon-fonts.md +0 -50
  50. package/skills/purgetss/references/installation-setup.md +61 -32
  51. package/skills/purgetss/references/migration-guide.md +127 -0
  52. package/skills/purgetss/references/opacity-modifier.md +0 -34
  53. package/skills/purgetss/references/performance-tips.md +261 -0
  54. package/skills/purgetss/references/platform-modifiers.md +0 -46
  55. package/skills/purgetss/references/smart-mappings.md +0 -12
  56. package/skills/purgetss/references/tikit-components.md +393 -0
  57. package/skills/purgetss/references/titanium-resets.md +1 -27
  58. package/skills/purgetss/references/ui-ux-design.md +467 -117
  59. package/skills/{alloy-expert → ti-expert}/SKILL.md +45 -54
  60. package/skills/ti-expert/references/alloy-builtins.md +387 -0
  61. package/skills/{alloy-expert → ti-expert}/references/alloy-structure.md +147 -40
  62. package/skills/ti-expert/references/anti-patterns.md +90 -0
  63. package/skills/ti-expert/references/cli-expert.md +109 -0
  64. package/skills/{alloy-expert → ti-expert}/references/code-conventions.md +182 -49
  65. package/skills/{alloy-expert → ti-expert}/references/controller-patterns.md +103 -93
  66. package/skills/{alloy-expert → ti-expert}/references/error-handling.md +12 -12
  67. package/skills/{alloy-expert → ti-expert}/references/examples.md +144 -85
  68. package/skills/{alloy-expert → ti-expert}/references/migration-patterns.md +38 -36
  69. package/skills/{alloy-expert → ti-expert}/references/patterns.md +8 -8
  70. package/skills/ti-expert/references/performance-listview.md +251 -0
  71. package/skills/{alloy-expert/references/performance-patterns.md → ti-expert/references/performance-optimization.md} +67 -283
  72. package/skills/{alloy-expert/references/security-patterns.md → ti-expert/references/security-device.md} +12 -295
  73. package/skills/ti-expert/references/security-fundamentals.md +284 -0
  74. package/skills/{alloy-expert → ti-expert}/references/state-management.md +10 -10
  75. package/skills/ti-expert/references/testing-e2e-ci.md +432 -0
  76. package/skills/ti-expert/references/testing-unit.md +433 -0
  77. package/skills/ti-expert/references/theming.md +394 -0
  78. package/skills/ti-guides/SKILL.md +1 -14
  79. package/skills/ti-guides/references/advanced-data-and-images.md +126 -10
  80. package/skills/ti-guides/references/app-distribution.md +48 -10
  81. package/skills/ti-guides/references/application-frameworks.md +9 -2
  82. package/skills/ti-guides/references/cli-reference.md +338 -82
  83. package/skills/ti-guides/references/coding-best-practices.md +14 -4
  84. package/skills/ti-guides/references/commonjs-advanced.md +103 -6
  85. package/skills/ti-guides/references/hello-world.md +5 -2
  86. package/skills/ti-guides/references/hyperloop-native-access.md +439 -46
  87. package/skills/ti-guides/references/javascript-primer.md +4 -3
  88. package/skills/ti-guides/references/resources.md +0 -1
  89. package/skills/ti-guides/references/style-and-conventions.md +57 -9
  90. package/skills/ti-guides/references/tiapp-config.md +48 -6
  91. package/skills/ti-howtos/SKILL.md +2 -27
  92. package/skills/ti-howtos/references/android-platform-deep-dives.md +41 -90
  93. package/skills/ti-howtos/references/automation-fastlane-appium.md +15 -14
  94. package/skills/ti-howtos/references/buffer-codec-streams.md +22 -22
  95. package/skills/ti-howtos/references/cross-platform-development.md +68 -37
  96. package/skills/ti-howtos/references/debugging-profiling.md +8 -53
  97. package/skills/ti-howtos/references/extending-titanium.md +12 -51
  98. package/skills/ti-howtos/references/google-maps-v2.md +30 -29
  99. package/skills/ti-howtos/references/ios-map-kit.md +19 -25
  100. package/skills/ti-howtos/references/ios-platform-deep-dives.md +95 -283
  101. package/skills/ti-howtos/references/local-data-sources.md +45 -37
  102. package/skills/ti-howtos/references/location-and-maps.md +47 -28
  103. package/skills/ti-howtos/references/media-apis.md +84 -27
  104. package/skills/ti-howtos/references/notification-services.md +40 -89
  105. package/skills/ti-howtos/references/remote-data-sources.md +21 -36
  106. package/skills/ti-howtos/references/tutorials.md +79 -39
  107. package/skills/ti-howtos/references/using-modules.md +4 -30
  108. package/skills/ti-howtos/references/web-content-integration.md +28 -45
  109. package/skills/ti-howtos/references/webpack-build-pipeline.md +54 -18
  110. package/skills/ti-ui/SKILL.md +1 -21
  111. package/skills/ti-ui/references/accessibility-deep-dive.md +71 -25
  112. package/skills/ti-ui/references/animation-and-matrices.md +0 -47
  113. package/skills/ti-ui/references/application-structures.md +0 -46
  114. package/skills/ti-ui/references/custom-fonts-styling.md +9 -57
  115. package/skills/ti-ui/references/event-handling.md +32 -40
  116. package/skills/ti-ui/references/gestures.md +0 -40
  117. package/skills/ti-ui/references/icons-and-splash-screens.md +21 -44
  118. package/skills/ti-ui/references/layouts-and-positioning.md +47 -39
  119. package/skills/ti-ui/references/listviews-and-performance.md +187 -73
  120. package/skills/ti-ui/references/orientation.md +57 -71
  121. package/skills/ti-ui/references/platform-ui-android.md +114 -48
  122. package/skills/ti-ui/references/platform-ui-ios.md +63 -38
  123. package/skills/ti-ui/references/scrolling-views.md +14 -23
  124. package/skills/ti-ui/references/tableviews.md +6 -56
  125. package/lib/commands/install.js +0 -188
  126. package/skills/alloy-expert/references/anti-patterns.md +0 -133
  127. package/skills/alloy-expert/references/testing.md +0 -872
  128. package/skills/ti-guides/references/alloy-cli-advanced.md +0 -84
  129. package/skills/ti-guides/references/alloy-data-mastery.md +0 -29
  130. package/skills/ti-guides/references/alloy-widgets-and-themes.md +0 -19
  131. /package/skills/{alloy-expert → ti-expert}/assets/ControllerAutoCleanup.js +0 -0
  132. /package/skills/{alloy-expert → ti-expert}/references/contracts.md +0 -0
@@ -0,0 +1,261 @@
1
+ # Performance Tips with PurgeTSS
2
+
3
+ Best practices for optimizing performance in Titanium apps using PurgeTSS utility classes.
4
+
5
+ ## PurgeTSS Classes vs Inline Styles
6
+
7
+ Using PurgeTSS classes reduces bridge crossings compared to inline styling:
8
+
9
+ ```xml
10
+ <!-- BAD: Multiple inline attributes = more bridge crossings -->
11
+ <Label text="Hello" width="200" height="40" color="#000" font="{fontSize:16}" />
12
+
13
+ <!-- GOOD: Single class application, fewer bridge crossings -->
14
+ <Label text="Hello" class="h-10 w-1/2 text-base text-black" />
15
+ ```
16
+
17
+ PurgeTSS generates optimized TSS that Alloy applies in a single batch during view creation.
18
+
19
+ ## ListView Performance
20
+
21
+ ### Critical Rules
22
+
23
+ 1. **NEVER use `Ti.UI.SIZE` in ListView items** — causes layout recalculation on every scroll
24
+ 2. **ALWAYS use fixed heights** on `<ItemTemplate>` — enables fast scrolling
25
+ 3. **USE templates** — reuse view instances instead of creating new ones
26
+
27
+ ### Optimized Template
28
+
29
+ ```xml
30
+ <ListView class="wh-screen">
31
+ <Templates>
32
+ <!-- FIXED HEIGHT is critical -->
33
+ <ItemTemplate name="userTemplate" height="64">
34
+ <View class="horizontal h-16 w-screen">
35
+ <ImageView bindId="avatar" class="rounded-full-12 ml-4" />
36
+ <View class="vertical ml-3">
37
+ <Label bindId="name" class="text-base font-bold" />
38
+ <Label bindId="email" class="text-sm text-gray-500" />
39
+ </View>
40
+ </View>
41
+ </ItemTemplate>
42
+ </Templates>
43
+
44
+ <ListSection id="section" dataCollection="users">
45
+ <ListItem template="userTemplate"
46
+ avatar:image="{avatar}"
47
+ name:text="{name}"
48
+ email:text="{email}"
49
+ />
50
+ </ListSection>
51
+ </ListView>
52
+ ```
53
+
54
+ ### Efficient Data Binding
55
+
56
+ ```javascript
57
+ function renderItems(items) {
58
+ // Pre-format data to avoid calculation during render
59
+ $.section.items = items.map(item => ({
60
+ template: 'feedTemplate',
61
+ properties: { itemId: item.id, searchableText: `${item.title} ${item.description}` },
62
+ title: { text: item.title },
63
+ timestamp: { text: formatTimestamp(item.created_at) }
64
+ }))
65
+ }
66
+
67
+ // Cache formatted values
68
+ const timestampCache = new Map()
69
+
70
+ function formatTimestamp(timestamp) {
71
+ if (timestampCache.has(timestamp)) return timestampCache.get(timestamp)
72
+ const formatted = new Date(timestamp).toLocaleString()
73
+ timestampCache.set(timestamp, formatted)
74
+ return formatted
75
+ }
76
+ ```
77
+
78
+ ### Lazy Loading (Infinite Scroll)
79
+
80
+ ```javascript
81
+ const PAGE_SIZE = 20
82
+ let currentPage = 1
83
+ let isLoading = false
84
+ let hasMore = true
85
+
86
+ function init() {
87
+ loadPage(1)
88
+ $.listView.addEventListener('marker', onMarker)
89
+ }
90
+
91
+ function onMarker(e) {
92
+ if (!hasMore || isLoading) return
93
+ const totalItems = $.section.items?.length || 0
94
+ if (e.itemIndex >= totalItems - 5) loadNextPage()
95
+ }
96
+
97
+ async function loadNextPage() {
98
+ if (isLoading || !hasMore) return
99
+ isLoading = true
100
+ try {
101
+ const items = await api.getFeedPage(++currentPage, PAGE_SIZE)
102
+ if (items.length < PAGE_SIZE) hasMore = false
103
+ $.section.appendItems(items)
104
+ } catch (error) {
105
+ currentPage--
106
+ } finally {
107
+ isLoading = false
108
+ }
109
+ }
110
+ ```
111
+
112
+ ## Bridge Optimization
113
+
114
+ Every JavaScript → Native call crosses a bridge. Minimize these:
115
+
116
+ ```javascript
117
+ // BAD: Multiple bridge crossings
118
+ const width = Ti.Platform.displayCaps.platformWidth
119
+ const height = Ti.Platform.displayCaps.platformHeight
120
+ const dpi = Ti.Platform.displayCaps.dpi
121
+
122
+ // GOOD: Cache properties locally
123
+ const displayCaps = Ti.Platform.displayCaps
124
+ const { platformWidth, platformHeight, dpi } = displayCaps
125
+ ```
126
+
127
+ ## Animation Performance
128
+
129
+ ### Use PurgeTSS Animation Component (Not JavaScript Intervals)
130
+
131
+ ```javascript
132
+ // BAD: JavaScript-driven animation (60 bridge crossings/second!)
133
+ let x = 0
134
+ setInterval(() => {
135
+ x += 1
136
+ $.view.left = x
137
+ }, 16)
138
+
139
+ // GOOD: PurgeTSS native animation
140
+ ```
141
+
142
+ ```xml
143
+ <Animation id="slideIn" module="purgetss.ui"
144
+ class="close:translate-x-full duration-300 open:translate-x-0" />
145
+ ```
146
+
147
+ ### Hardware-Accelerated Properties
148
+
149
+ Fast (GPU-accelerated):
150
+ - `opacity` — use for fade effects
151
+ - `transform` (translate, scale, rotate)
152
+
153
+ Slow (triggers layout recalculation):
154
+ - `width`, `height`
155
+ - `top`, `left`, `right`, `bottom`
156
+ - `visible`
157
+
158
+ ```xml
159
+ <!-- GOOD: Animate with GPU-friendly properties -->
160
+ <Animation id="fadeIn" module="purgetss.ui" class="close:opacity-0 duration-300 open:opacity-100" />
161
+ <Animation id="scalePress" module="purgetss.ui" class="close:scale-100 duration-150 open:scale-95" />
162
+
163
+ <!-- AVOID: Layout property animations when possible -->
164
+ ```
165
+
166
+ ## Batch UI Updates
167
+
168
+ ```javascript
169
+ // BAD: Multiple bridge crossings
170
+ $.nameLabel.text = user.name
171
+ $.nameLabel.color = '#000'
172
+ $.nameLabel.font = { fontSize: 16 }
173
+
174
+ // GOOD: Single applyProperties call
175
+ $.nameLabel.applyProperties({
176
+ text: user.name,
177
+ color: '#000',
178
+ font: { fontSize: 16 }
179
+ })
180
+ ```
181
+
182
+ ### Dynamic Class Changes
183
+
184
+ ```javascript
185
+ // Change styles dynamically using classes array
186
+ $.statusLabel.applyProperties({
187
+ classes: isActive ? ['text-green-500'] : ['text-red-500'],
188
+ text: isActive ? L('active') : L('inactive')
189
+ })
190
+ ```
191
+
192
+ ## Debouncing and Throttling
193
+
194
+ ### Debounce (Wait for User to Stop)
195
+
196
+ ```javascript
197
+ // lib/helpers/timing.js
198
+ exports.debounce = function(fn, delay = 300) {
199
+ let timeoutId = null
200
+ const debounced = function(...args) {
201
+ clearTimeout(timeoutId)
202
+ timeoutId = setTimeout(() => fn.apply(this, args), delay)
203
+ }
204
+ debounced.cancel = () => { clearTimeout(timeoutId); timeoutId = null }
205
+ return debounced
206
+ }
207
+ ```
208
+
209
+ ### Throttle (Limit Execution Rate)
210
+
211
+ ```javascript
212
+ exports.throttle = function(fn, limit = 100) {
213
+ let lastRun = 0
214
+ let timeoutId = null
215
+ const throttled = function(...args) {
216
+ const now = Date.now()
217
+ const remaining = limit - (now - lastRun)
218
+ if (remaining <= 0) {
219
+ lastRun = now
220
+ fn.apply(this, args)
221
+ } else if (!timeoutId) {
222
+ timeoutId = setTimeout(() => {
223
+ lastRun = Date.now()
224
+ timeoutId = null
225
+ fn.apply(this, args)
226
+ }, remaining)
227
+ }
228
+ }
229
+ throttled.cancel = () => { clearTimeout(timeoutId); timeoutId = null }
230
+ return throttled
231
+ }
232
+ ```
233
+
234
+ ### Common Use Cases
235
+
236
+ | Pattern | Use Case | Delay |
237
+ | -------- | ----------------- | ------------ |
238
+ | Debounce | Search input | 300ms |
239
+ | Debounce | Auto-save | 1000ms |
240
+ | Debounce | Window resize | 150ms |
241
+ | Throttle | Scroll events | 50-100ms |
242
+ | Throttle | Touch/move events | 16ms (60fps) |
243
+ | Throttle | API polling | 5000ms+ |
244
+
245
+ ## Performance Checklist
246
+
247
+ | Area | Check |
248
+ | ------------- | ------------------------------------------------------ |
249
+ | **ListView** | Fixed heights on all templates |
250
+ | **ListView** | Using templates, not dynamic views |
251
+ | **ListView** | Image pre-sizing and caching |
252
+ | **Bridge** | Cached `Ti.Platform` properties |
253
+ | **Bridge** | Using `applyProperties` for batch updates |
254
+ | **Bridge** | PurgeTSS classes instead of inline styles |
255
+ | **Memory** | All global listeners cleaned up in `$.cleanup` |
256
+ | **Memory** | Heavy objects nulled in cleanup |
257
+ | **Memory** | Images resized appropriately |
258
+ | **Animation** | Using PurgeTSS Animation component |
259
+ | **Animation** | Animating GPU-friendly properties (opacity, transform) |
260
+ | **Events** | Search inputs debounced (300ms) |
261
+ | **Events** | Scroll handlers throttled (50-100ms) |
@@ -2,52 +2,6 @@
2
2
 
3
3
  Platform and Device modifiers (also called variants or prefixes) allow you to specify different styles for an element depending on the platform (iOS or Android) and device (tablet or handheld) that the app is running on.
4
4
 
5
- ## Table of Contents
6
-
7
- - [Platform and Device Modifiers](#platform-and-device-modifiers)
8
- - [Table of Contents](#table-of-contents)
9
- - [🚨 CRITICAL: Platform-Specific Properties Require Modifiers](#-critical-platform-specific-properties-require-modifiers)
10
- - [Available Modifiers](#available-modifiers)
11
- - [Platform Modifiers](#platform-modifiers)
12
- - [Device (Form Factor) Modifiers](#device-form-factor-modifiers)
13
- - [Usage in XML](#usage-in-xml)
14
- - [Basic Platform Targeting](#basic-platform-targeting)
15
- - [Combining with Arbitrary Values](#combining-with-arbitrary-values)
16
- - [Multiple Modifiers on Same Element](#multiple-modifiers-on-same-element)
17
- - [Generated TSS Output](#generated-tss-output)
18
- - [Custom Conditional Modifiers](#custom-conditional-modifiers)
19
- - [Syntax](#syntax)
20
- - [Example with iPhone X Notch](#example-with-iphone-x-notch)
21
- - [Setting Up Conditional Variables](#setting-up-conditional-variables)
22
- - [Modifiers in config.cjs](#modifiers-in-configcjs)
23
- - [Custom Class with Platform Variants](#custom-class-with-platform-variants)
24
- - [Ti Element with Platform and Device Variants](#ti-element-with-platform-and-device-variants)
25
- - [Complex Example with All Variants](#complex-example-with-all-variants)
26
- - [Platform-Specific Properties](#platform-specific-properties)
27
- - [iOS-Specific Properties](#ios-specific-properties)
28
- - [Android-Specific Properties](#android-specific-properties)
29
- - [Interaction Modifiers](#interaction-modifiers)
30
- - [Active State Modifier](#active-state-modifier)
31
- - [Best Practices](#best-practices)
32
- - [1. Use Modifiers for Platform Differences](#1-use-modifiers-for-platform-differences)
33
- - [2. Combine with Default Styles](#2-combine-with-default-styles)
34
- - [3. Use Device Modifiers for Layout Adaptation](#3-use-device-modifiers-for-layout-adaptation)
35
- - [4. Leverage config.cjs for Complex Platform Logic](#4-leverage-configcjs-for-complex-platform-logic)
36
- - [Common Patterns](#common-patterns)
37
- - [iOS Shadow / Android Elevation](#ios-shadow--android-elevation)
38
- - [Different Font Sizes per Platform](#different-font-sizes-per-platform)
39
- - [Safe Area Handling for iPhone X](#safe-area-handling-for-iphone-x)
40
- - [Adaptive Spacing](#adaptive-spacing)
41
- - [Platform-Specific Colors](#platform-specific-colors)
42
- - [Troubleshooting](#troubleshooting)
43
- - [Modifiers Not Applying](#modifiers-not-applying)
44
- - [Conditional Modifiers Not Working](#conditional-modifiers-not-working)
45
- - [Platform Detection Issues](#platform-detection-issues)
46
- - [Modifier Reference Table](#modifier-reference-table)
47
- - [Complete Example](#complete-example)
48
-
49
- ---
50
-
51
5
  ## 🚨 CRITICAL: Platform-Specific Properties Require Modifiers
52
6
 
53
7
  :::danger NEVER use platform-specific properties directly
@@ -2,18 +2,6 @@
2
2
 
3
3
  PurgeTSS maps CSS-like utilities to native Titanium properties. Understanding these "Smart Mappings" is key to predictable layouts and cross-platform consistency.
4
4
 
5
- ## Table of Contents
6
-
7
- - [Smart Mappings \& Platform Realities](#smart-mappings--platform-realities)
8
- - [Table of Contents](#table-of-contents)
9
- - [1. The "Gap" Utility (Double Spacing)](#1-the-gap-utility-double-spacing)
10
- - [2. Hybrid Shadows (iOS vs. Android)](#2-hybrid-shadows-ios-vs-android)
11
- - [3. Grid Container Width](#3-grid-container-width)
12
- - [4. Native Rotations](#4-native-rotations)
13
- - [5. Z-Index vs Stacking Order](#5-z-index-vs-stacking-order)
14
-
15
- ---
16
-
17
5
  ## 1. The "Gap" Utility (Double Spacing)
18
6
  In PurgeTSS, `gap` is mapped to **external margins** (`top`, `right`, `bottom`, `left`) because Titanium lacks a native CSS-style gap property.
19
7
  - **Behavior**: `.gap-4` adds 16dp to **all** sides of the element.