@maccesar/titools 2.2.11 → 2.3.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/README.md +255 -713
  2. package/bin/titools.js +1 -1
  3. package/lib/commands/update.js +5 -6
  4. package/lib/config.js +1 -0
  5. package/lib/downloader.js +10 -0
  6. package/package.json +1 -1
  7. package/skills/alloy-guides/SKILL.md +46 -48
  8. package/skills/alloy-guides/references/CONTROLLERS.md +4 -6
  9. package/skills/alloy-guides/references/MODELS.md +340 -184
  10. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +3 -4
  11. package/skills/alloy-guides/references/VIEWS_STYLES.md +44 -46
  12. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +4 -5
  13. package/skills/alloy-guides/references/VIEWS_XML.md +51 -17
  14. package/skills/alloy-guides/references/WIDGETS.md +1 -1
  15. package/skills/alloy-howtos/SKILL.md +12 -13
  16. package/skills/alloy-howtos/references/cli_reference.md +40 -41
  17. package/skills/alloy-howtos/references/samples.md +3 -4
  18. package/skills/purgetss/SKILL.md +369 -356
  19. package/skills/purgetss/references/EXAMPLES.md +24 -25
  20. package/skills/purgetss/references/animation-advanced.md +555 -0
  21. package/skills/purgetss/references/animation-system.md +395 -995
  22. package/skills/purgetss/references/apply-directive.md +111 -141
  23. package/skills/purgetss/references/arbitrary-values.md +206 -480
  24. package/skills/purgetss/references/class-categories.md +277 -0
  25. package/skills/purgetss/references/class-index.md +1 -420
  26. package/skills/purgetss/references/cli-commands.md +446 -556
  27. package/skills/purgetss/references/configurable-properties.md +163 -599
  28. package/skills/purgetss/references/custom-rules.md +33 -76
  29. package/skills/purgetss/references/customization-deep-dive.md +319 -518
  30. package/skills/purgetss/references/dynamic-component-creation.md +33 -37
  31. package/skills/purgetss/references/grid-layout.md +42 -371
  32. package/skills/purgetss/references/icon-fonts.md +82 -475
  33. package/skills/purgetss/references/installation-setup.md +159 -331
  34. package/skills/purgetss/references/migration-guide.md +54 -109
  35. package/skills/purgetss/references/opacity-modifier.md +25 -222
  36. package/skills/purgetss/references/performance-tips.md +2 -2
  37. package/skills/purgetss/references/platform-modifiers.md +21 -407
  38. package/skills/purgetss/references/tikit-components.md +237 -104
  39. package/skills/purgetss/references/titanium-resets.md +20 -21
  40. package/skills/purgetss/references/ui-ux-design.md +171 -1702
  41. package/skills/ti-api/SKILL.md +109 -0
  42. package/skills/ti-api/references/api-android.md +675 -0
  43. package/skills/ti-api/references/api-app-platform.md +636 -0
  44. package/skills/ti-api/references/api-core.md +764 -0
  45. package/skills/ti-api/references/api-data-network.md +641 -0
  46. package/skills/ti-api/references/api-media.md +655 -0
  47. package/skills/ti-api/references/api-modules-ble-bluetooth.md +657 -0
  48. package/skills/ti-api/references/api-modules-coremotion-urlsession.md +411 -0
  49. package/skills/ti-api/references/api-modules-map.md +632 -0
  50. package/skills/ti-api/references/api-modules-nfc.md +725 -0
  51. package/skills/ti-api/references/api-modules-social-misc.md +526 -0
  52. package/skills/ti-api/references/api-services.md +700 -0
  53. package/skills/ti-api/references/api-ui-android.md +499 -0
  54. package/skills/ti-api/references/api-ui-extras.md +702 -0
  55. package/skills/ti-api/references/api-ui-ios-animator.md +378 -0
  56. package/skills/ti-api/references/api-ui-ios.md +756 -0
  57. package/skills/ti-api/references/api-ui-lists.md +581 -0
  58. package/skills/ti-api/references/api-ui-text-input.md +607 -0
  59. package/skills/ti-api/references/api-ui-views.md +572 -0
  60. package/skills/ti-api/references/api-ui-windows-navigation.md +676 -0
  61. package/skills/ti-api/references/api-xml-global.md +743 -0
  62. package/skills/ti-expert/SKILL.md +106 -138
  63. package/skills/ti-expert/references/adaptive-layouts.md +414 -0
  64. package/skills/ti-expert/references/alloy-builtins.md +16 -20
  65. package/skills/ti-expert/references/alloy-structure.md +40 -42
  66. package/skills/ti-expert/references/anti-patterns.md +34 -0
  67. package/skills/ti-expert/references/architecture-tiers.md +248 -0
  68. package/skills/ti-expert/references/code-conventions.md +5 -3
  69. package/skills/ti-expert/references/error-handling.md +14 -7
  70. package/skills/ti-expert/references/examples.md +4 -2
  71. package/skills/ti-expert/references/performance-optimization.md +26 -24
  72. package/skills/ti-expert/references/security-device.md +17 -14
  73. package/skills/ti-expert/references/security-fundamentals.md +60 -101
  74. package/skills/ti-expert/references/state-management.md +15 -14
  75. package/skills/ti-expert/references/testing-e2e-ci.md +30 -21
  76. package/skills/ti-expert/references/theming.md +12 -20
  77. package/skills/ti-guides/SKILL.md +13 -17
  78. package/skills/ti-guides/references/advanced-data-and-images.md +30 -10
  79. package/skills/ti-guides/references/application-frameworks.md +3 -3
  80. package/skills/ti-guides/references/coding-best-practices.md +31 -2
  81. package/skills/ti-guides/references/commonjs-advanced.md +46 -4
  82. package/skills/ti-guides/references/hello-world.md +9 -13
  83. package/skills/ti-guides/references/hyperloop-native-access.md +4 -1
  84. package/skills/ti-guides/references/javascript-primer.md +13 -5
  85. package/skills/ti-guides/references/resources.md +0 -2
  86. package/skills/ti-guides/references/style-and-conventions.md +1 -0
  87. package/skills/ti-guides/references/tiapp-config.md +0 -32
  88. package/skills/ti-howtos/SKILL.md +43 -45
  89. package/skills/ti-howtos/references/buffer-codec-streams.md +25 -3
  90. package/skills/ti-howtos/references/debugging-profiling.md +14 -25
  91. package/skills/ti-howtos/references/google-maps-v2.md +3 -3
  92. package/skills/ti-howtos/references/ios-map-kit.md +8 -1
  93. package/skills/ti-howtos/references/notification-services.md +0 -1
  94. package/skills/ti-howtos/references/webpack-build-pipeline.md +3 -0
  95. package/skills/ti-ui/SKILL.md +47 -49
  96. package/skills/ti-ui/references/application-structures.md +3 -2
  97. package/skills/ti-ui/references/orientation.md +17 -9
  98. package/skills/ti-ui/references/platform-ui-ios.md +63 -0
  99. package/skills/ti-ui/references/scrolling-views.md +39 -0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ti-expert
3
- description: "Titanium SDK architecture and implementation expert. Use when designing, reviewing, analyzing, or examining Titanium project structure (Alloy or Classic), creating controllers/views/services, choosing models vs collections, implementing communication patterns, handling memory cleanup, testing, auditing code, or migrating legacy apps. Automatically identifies project type."
3
+ description: "Titanium SDK architecture and implementation expert. Use when designing, reviewing, analyzing, or examining Titanium project structure (Alloy or Classic), creating controllers/views/services, choosing models vs collections, implementing communication patterns, handling memory cleanup, testing, auditing code, migrating legacy apps, or building adaptive/responsive layouts for tablets, foldables, and large screens. Automatically identifies project type."
4
4
  argument-hint: "[architecture-topic]"
5
5
  allowed-tools: Read, Grep, Glob, Edit, Write, Bash(git *), Bash(node *)
6
6
  ---
@@ -11,23 +11,22 @@ Practical architecture and implementation guidance for Titanium SDK apps (Alloy
11
11
 
12
12
  ## Project detection
13
13
 
14
- :::info Auto-detects Alloy vs Classic projects
15
- This skill detects project type automatically and tailors guidance.
16
-
17
- Alloy indicators:
18
- - `app/` folder (MVC structure)
19
- - `app/views/`, `app/controllers/` folders
20
- - `alloy.jmk` or `config.json` files
21
-
22
- Classic indicators:
23
- - `Resources/` folder with `app.js` at root
24
- - No `app/` folder structure
25
-
26
- Behavior:
27
- - Alloy detected: provides Alloy MVC patterns and Backbone.js guidance
28
- - Classic detected: avoids Alloy-only patterns and recommends Classic options or migration
29
- - Unknown: asks the user to clarify the project type
30
- :::
14
+ > **️ℹ️ Auto-detects Alloy vs Classic projects**
15
+ > This skill detects project type automatically and tailors guidance.
16
+ >
17
+ > Alloy indicators:
18
+ > - `app/` folder (MVC structure)
19
+ > - `app/views/`, `app/controllers/` folders
20
+ > - `alloy.jmk` or `config.json` files
21
+ >
22
+ > Classic indicators:
23
+ > - `Resources/` folder with `app.js` at root
24
+ > - No `app/` folder structure
25
+ >
26
+ > Behavior:
27
+ > - Alloy detected: provides Alloy MVC patterns and Backbone.js guidance
28
+ > - Classic detected: avoids Alloy-only patterns and recommends Classic options or migration
29
+ > - Unknown: asks the user to clarify the project type
31
30
 
32
31
  ## Workflow
33
32
 
@@ -38,6 +37,32 @@ Behavior:
38
37
  5. Quality: testing, error handling, logging, performance
39
38
  6. Cleanup: implement a `cleanup()` pattern for memory management
40
39
 
40
+ ## Architectural Maturity Tiers
41
+
42
+ Choose the appropriate tier based on project complexity:
43
+
44
+ ### Tier 1: Basic (Rapid Prototyping)
45
+ - **Best for**: Simple utility apps or developers transitioning from Classic.
46
+ - **Structure**: Logic resides directly within `index.js`.
47
+ - **UI Access**: Direct usage of the `$` object throughout the file.
48
+ - **Pros**: Zero boilerplate, extremely fast start.
49
+ - **Cons**: Unmaintainable beyond 500 lines of code.
50
+
51
+ ### Tier 2: Intermediate (Modular Alloy)
52
+ - **Best for**: Standard commercial applications.
53
+ - **Structure**: Business logic extracted to `app/lib/` using a flat technical-type organization.
54
+ - **Pattern**: Slim Controllers that `require()` services.
55
+ - **Memory**: Mandatory implementation of `$.cleanup = cleanup`.
56
+
57
+ ### Tier 3: Advanced / Enterprise (Service-Oriented)
58
+ - **Best for**: High-complexity apps (IDEs like TiDesigner, multi-state platforms).
59
+ - **Architecture**: Dependency Injection via a `ServiceRegistry`.
60
+ - **ID Scoping**: Services do not receive the entire `$` object. They receive a "Scoped UI" object containing only relevant IDs.
61
+ - **Cognitive Load**: "Black Box" logic—encapsulated units that reduce mental fatigue.
62
+ - **Observability**: Structured logging with a mandatory `service` context.
63
+
64
+ Detailed examples and full implementation samples are available in: [Architectural Tiers Detail](references/architecture-tiers.md)
65
+
41
66
  ## Organization policy (low freedom)
42
67
 
43
68
  - Use technical-type organization in `lib` (for example: `api`, `services`, `actions`, `repositories`, `helpers`, `policies`, `providers`).
@@ -45,76 +70,13 @@ Behavior:
45
70
  - Do not recommend deep nesting like `lib/services/auth/session/login.js`.
46
71
  - Keep UI layers aligned by screen (`controllers/`, `views/`, `styles/`) and avoid unnecessary depth.
47
72
 
48
- ## Quick start example
49
-
50
- Minimal example that matches the conventions:
51
-
52
- View (`views/userCard.xml`)
53
- ```xml
54
- <Alloy>
55
- <View id="cardContainer">
56
- <View id="headerRow">
57
- <ImageView id="userIcon" image="/images/user.png" />
58
- <Label id="name" />
59
- </View>
60
- <Button id="viewProfileBtn"
61
- title="L('view_profile')"
62
- onClick="onViewProfile"
63
- />
64
- </View>
65
- </Alloy>
66
- ```
67
-
68
- Styles (`styles/userCard.tss`)
69
- ```tss
70
- "#cardContainer": { left: 8, right: 8, top: 8, height: Ti.UI.SIZE, borderRadius: 12, backgroundColor: '#fff' }
71
- "#headerRow": { layout: 'horizontal', left: 12, right: 12, top: 12, height: Ti.UI.SIZE, width: Ti.UI.FILL }
72
- "#userIcon": { width: 32, height: 32 }
73
- "#name": { left: 12, font: { fontSize: 18, fontWeight: 'bold' } }
74
- "#viewProfileBtn": { left: 12, right: 12, bottom: 12, height: 40, width: Ti.UI.FILL, borderRadius: 6, backgroundColor: '#2563eb', color: '#fff' }
75
- ```
76
-
77
- Controller (`controllers/userCard.js`)
78
- ```javascript
79
- const { Navigation } = require('services/navigation')
80
-
81
- function init() {
82
- const user = $.args.user
83
- $.name.text = user.name
84
- }
85
-
86
- function onViewProfile() {
87
- Navigation.open('userProfile', { userId: $.args.user.id })
88
- }
89
-
90
- function cleanup() {
91
- $.destroy()
92
- }
93
-
94
- $.cleanup = cleanup
95
- ```
96
-
97
- Service (`lib/services/navigation.js`)
98
- ```javascript
99
- exports.Navigation = {
100
- open(route, params = {}) {
101
- const controller = Alloy.createController(route, params)
102
- const view = controller.getView()
103
-
104
- view.addEventListener('close', function() {
105
- if (controller.cleanup) controller.cleanup()
106
- })
107
-
108
- view.open()
109
- return controller
110
- }
111
- }
112
- ```
113
73
 
114
74
  ## Code standards (low freedom)
115
75
 
116
76
  - No semicolons: let ASI handle it
117
77
  - Modern syntax: `const/let`, destructuring, template literals
78
+ - Prefer stable property ordering in JS objects and `applyProperties()` calls
79
+ - Default to alphabetical property order when it does not break a meaningful semantic grouping
118
80
  - `applyProperties()`: batch UI updates to reduce bridge crossings
119
81
  - Memory cleanup: any controller with global listeners must set `$.cleanup = cleanup`
120
82
  - Error handling: use AppError classes, log with context, never swallow errors
@@ -122,33 +84,32 @@ exports.Navigation = {
122
84
 
123
85
  ## Titanium style sheets rules (low freedom)
124
86
 
125
- :::danger Critical: platform-specific properties require modifiers
126
- Using `Ti.UI.iOS.*` or `Ti.UI.Android.*` properties without platform modifiers breaks cross-platform builds.
127
-
128
- Example of the damage:
129
- ```tss
130
- // Wrong: adds Ti.UI.iOS to Android project
131
- "#mainWindow": {
132
- statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
133
- }
134
- ```
135
-
136
- Correct: always use platform modifiers
137
- ```tss
138
- // Correct: only adds to iOS
139
- "#mainWindow[platform=ios]": {
140
- statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
141
- }
142
- ```
143
-
144
- Properties that always need platform modifiers:
145
- - iOS: `statusBarStyle`, `modalStyle`, `modalTransitionStyle`, any `Ti.UI.iOS.*`
146
- - Android: `actionBar` configuration, any `Ti.UI.Android.*` constant
147
-
148
- Available modifiers: `[platform=ios]`, `[platform=android]`, `[formFactor=handheld]`, `[formFactor=tablet]`, `[if=Alloy.Globals.customVar]`
149
-
150
- For more platform-specific patterns, see the `ti-ui` skill.
151
- :::
87
+ > **🚨 Critical: platform-specific properties require modifiers**
88
+ > Using `Ti.UI.iOS.*` or `Ti.UI.Android.*` properties without platform modifiers breaks cross-platform builds.
89
+ >
90
+ > Example of the damage:
91
+ > ```tss
92
+ > // Wrong: adds Ti.UI.iOS to Android project
93
+ > "#mainWindow": {
94
+ > statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
95
+ > }
96
+ > ```
97
+ >
98
+ > Correct: always use platform modifiers
99
+ > ```tss
100
+ > // Correct: only adds to iOS
101
+ > "#mainWindow[platform=ios]": {
102
+ > statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
103
+ > }
104
+ > ```
105
+ >
106
+ > Properties that always need platform modifiers:
107
+ > - iOS: `statusBarStyle`, `modalStyle`, `modalTransitionStyle`, any `Ti.UI.iOS.*`
108
+ > - Android: `actionBar` configuration, any `Ti.UI.Android.*` constant
109
+ >
110
+ > Available modifiers: `[platform=ios]`, `[platform=android]`, `[formFactor=handheld]`, `[formFactor=tablet]`, `[if=Alloy.Globals.customVar]`
111
+ >
112
+ > For more platform-specific patterns, see the `ti-ui` skill.
152
113
 
153
114
  Titanium layout system:
154
115
  - Three layout modes: `layout: 'horizontal'`, `layout: 'vertical'`, and composite (default, no `layout` needed)
@@ -166,41 +127,48 @@ For the complete reference with examples, see [Alloy builtins and globals](refer
166
127
 
167
128
  | Question | Answer |
168
129
  | ---------------------------------- | -------------------------------------------------------------- |
169
- | How to create a new Alloy project? | `ti create -t app --alloy` (not `--classic` + `alloy new`) |
130
+ | How to create a new Alloy project? | `ti create -t app --alloy` (not `--classic` + `alloy new`) |
170
131
  | Fastest way to build? | `tn <recipe>` (using TiNy CLI wrapper) |
132
+ | Controller > 100 lines? | Extract to Tier 2 (Services) |
133
+ | More than 50 IDs in XML? | Use Tier 3 (ID Scoping) |
171
134
  | Where does API call go? | `lib/api/` |
172
135
  | Where does business logic go? | `lib/services/` |
173
- | How deep should `lib` folders be? | One level: `lib/<type>/<file>.js` |
136
+ | How deep should `lib` folders be? | One level: `lib/<type>/<file>.js` |
174
137
  | Where do I store auth tokens? | Keychain (iOS) / KeyStore (Android) via service |
175
138
  | Models or Collections? | Collections for API data, Models for SQLite persistence |
176
139
  | Ti.App.fireEvent or EventBus? | Always EventBus (Backbone.Events) |
177
140
  | Direct navigation or service? | Always Navigation service (auto cleanup) |
178
- | Inline styles or TSS files? | Always TSS files (per-controller + `app.tss` for global) |
179
- | Controller 100+ lines? | Extract logic to services |
141
+ | Inline styles or TSS files? | Always TSS files (per-controller + `app.tss` for global) |
180
142
 
181
143
  ## Reference guides (progressive disclosure)
182
144
 
183
- Architecture
184
- - [CLI expert and TiNy](references/cli-expert.md): advanced build workflows, LiveView, TiNy (`tn`) recipes
185
- - [Structure and organization](references/alloy-structure.md): models vs collections, folder maps, widget patterns, automatic cleanup
186
- - [Alloy builtins and globals](references/alloy-builtins.md): `OS_IOS`/`OS_ANDROID`, `Alloy.CFG`, `Alloy.Globals`, `$.args`, compiler directives
187
- - [ControllerAutoCleanup.js](assets/ControllerAutoCleanup.js): drop-in utility for automatic controller cleanup
188
- - [Architectural patterns](references/patterns.md): repository, service layer, event bus, factory, singleton
189
- - [Contracts and communication](references/contracts.md): layer interaction examples and JSDoc specs
190
- - [Anti-patterns](references/anti-patterns.md): fat controllers, memory leaks, inline styling, direct API calls
191
-
192
- Implementation
193
- - [Code conventions](references/code-conventions.md): ES6 features, TSS design system, accessibility
194
- - [Theming and dark mode](references/theming.md): theme system, Alloy.Globals palette, runtime switching, design tokens
195
- - [Controller patterns](references/controller-patterns.md): templates, animation, dynamic styling
196
- - [Examples](references/examples.md): API clients, SQL models, full screen examples
197
-
198
- Quality and reliability
199
- - [Unit and integration testing](references/testing-unit.md): unit testing, mocking patterns, controller testing, test helpers
200
- - [E2E testing and CI/CD](references/testing-e2e-ci.md): Appium, WebdriverIO, GitHub Actions, Fastlane
201
- - [Error handling and logging](references/error-handling.md): AppError classes, Logger service, validation
202
-
203
- Performance and security
204
- - [ListView and ScrollView performance](references/performance-listview.md): ListView templates, data binding, image caching, ScrollView optimization
205
- - [Performance optimization](references/performance-optimization.md): bridge crossings, memory management, animations, debounce/throttle, database
206
- - [Security fundamentals](references/security-fundamentals.md): token storage, certificate pinning, encryption, HTTPS, OWASP
145
+ ### Architecture & Patterns
146
+ - [Architectural Tiers Detail](references/architecture-tiers.md)
147
+ - [Architectural Patterns](references/patterns.md) (Factory, Singleton, Repository)
148
+ - [Structure & Organization](references/alloy-structure.md)
149
+ - [Contracts & Communication](references/contracts.md)
150
+ - [State Management](references/state-management.md)
151
+ - [Anti-patterns to Avoid](references/anti-patterns.md)
152
+ - [Adaptive Layouts](references/adaptive-layouts.md) (responsive breakpoints, tablet/foldable/desktop support, Android 17 resizability compliance)
153
+
154
+ ### Implementation & API
155
+ - [Alloy Builtins & Globals](references/alloy-builtins.md)
156
+ - [Code Conventions](references/code-conventions.md)
157
+ - [Controller Patterns](references/controller-patterns.md)
158
+ - [Theming & Dark Mode](references/theming.md)
159
+ - [Migration Patterns](references/migration-patterns.md)
160
+ - [Examples Collection](references/examples.md)
161
+
162
+ ### Quality & Performance
163
+ - [Performance Optimization](references/performance-optimization.md)
164
+ - [ListView & ScrollView Performance](references/performance-listview.md)
165
+ - [Error Handling & Logging](references/error-handling.md)
166
+ - [Unit & Integration Testing](references/testing-unit.md)
167
+ - [E2E Testing & CI/CD](references/testing-e2e-ci.md)
168
+
169
+ ### Security
170
+ - [Security Fundamentals](references/security-fundamentals.md)
171
+ - [Device Security](references/security-device.md)
172
+
173
+ ### Tools
174
+ - [CLI Expert & TiNy](references/cli-expert.md)