@maccesar/titools 2.0.7 → 2.2.1

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 (133) hide show
  1. package/AGENTS-VERCEL-RESEARCH.md +172 -0
  2. package/README.md +408 -389
  3. package/agents/{ti-researcher.md → ti-pro.md} +14 -13
  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/AGENTS-TEMPLATE.md +0 -174
  126. package/lib/commands/install.js +0 -188
  127. package/skills/alloy-expert/references/anti-patterns.md +0 -133
  128. package/skills/alloy-expert/references/testing.md +0 -872
  129. package/skills/ti-guides/references/alloy-cli-advanced.md +0 -84
  130. package/skills/ti-guides/references/alloy-data-mastery.md +0 -29
  131. package/skills/ti-guides/references/alloy-widgets-and-themes.md +0 -19
  132. /package/skills/{alloy-expert → ti-expert}/assets/ControllerAutoCleanup.js +0 -0
  133. /package/skills/{alloy-expert → ti-expert}/references/contracts.md +0 -0
@@ -1,174 +0,0 @@
1
- # Why AGENTS.md? (Based on Vercel's Research)
2
-
3
- This document explains why we use AGENTS.md/CLAUDE.md with compressed documentation indexes instead of relying solely on skills for AI coding assistants.
4
-
5
- ## The Problem: Skills Alone Underperform
6
-
7
- Based on [Vercel's research](https://vercel.com/blog/agents-md-outperforms-skills-in-our-agent-evals), using skills alone achieves only a **53-79% pass rate** on coding tasks.
8
-
9
- ### Why Skills Underperform
10
-
11
- | Issue | Description |
12
- | ------------------- | ----------------------------------------------------- |
13
- | **Decision point** | AI must decide WHEN to invoke a skill (often doesn't) |
14
- | **Async loading** | Skills loaded on-demand, not always available |
15
- | **Ordering issues** | "Explore first vs read docs first" dilemma |
16
- | **Fragile prompts** | Performance depends on exact prompt wording |
17
-
18
- ## The Solution: AGENTS.md with Compressed Index
19
-
20
- Vercel found that using AGENTS.md with a compressed documentation index achieves **100% pass rate**.
21
-
22
- ### Why It Works
23
-
24
- 1. **No decision point** - Information is always present, no need to invoke skills
25
- 2. **Consistent availability** - Available in every turn, not async-loaded
26
- 3. **No ordering issues** - No "read docs first vs explore project first" dilemma
27
- 4. **Passive context** - Already in context, doesn't depend on prompt wording
28
-
29
- ### Performance Comparison
30
-
31
- | Approach | Pass Rate |
32
- | ------------------- | --------- |
33
- | No documentation | 53% |
34
- | Skills only | 53-79% |
35
- | **AGENTS.md index** | **100%** |
36
-
37
- ## Implementation for Titanium SDK
38
-
39
- ### The Compressed Index Format
40
-
41
- The index uses a compressed format that maps skills to their reference documentation:
42
-
43
- ```
44
- [Titanium SDK Docs Index]|root: ~/.agents/skills
45
- |alloy-expert/references:{alloy-structure.md,anti-patterns.md,...}
46
- |purgetss/references:{animation-system.md,apply-directive.md,...}
47
- |ti-ui/references:{listviews-and-performance.md,layouts-and-positioning.md,...}
48
- ```
49
-
50
- **How the AI uses it:**
51
- - Need ListView performance tips? Read `~/.agents/skills/ti-ui/references/listviews-and-performance.md`
52
- - Need PurgeTSS grid system? Read `~/.agents/skills/purgetss/references/grid-layout.md`
53
- - Need Backbone.Models patterns? Read `~/.agents/skills/alloy-guides/references/MODELS.md`
54
-
55
- ### Skill Overview
56
-
57
- | Skill | Purpose | Best For |
58
- | ---------------- | ----------------------------- | --------------------------------------------- |
59
- | **alloy-expert** | Architecture + Implementation | Starting point for most Alloy tasks |
60
- | **purgetss** | Utility-first styling | UI styling, animations, grid layouts |
61
- | **ti-ui** | UI/UX patterns | Layouts, ListViews, gestures, platform UI |
62
- | **ti-howtos** | Native feature integration | Location, Push, Media, platform-specific APIs |
63
- | **ti-guides** | SDK fundamentals | Hyperloop, distribution, tiapp.xml, CLI |
64
- | **alloy-guides** | Alloy MVC reference | Models, Views, Controllers, Widgets |
65
- | **alloy-howtos** | Alloy CLI & debugging | Project setup, CLI commands, errors |
66
-
67
- ### For Complex Workflows
68
-
69
- The **ti-researcher** agent (installed in `~/.claude/agents/`) handles:
70
- - Codebase architecture analysis
71
- - Multi-feature research across Titanium APIs
72
- - Cross-referencing framework patterns
73
- - Platform-specific differences investigation
74
-
75
- It preloads all 7 titanium-* skills for comprehensive analysis.
76
-
77
- ## How to Use
78
-
79
- ### For Titanium Projects
80
-
81
- Run the `titools agents` command in your Titanium project root:
82
-
83
- ```bash
84
- cd /path/to/your/titanium/project
85
- titools agents
86
- ```
87
-
88
- This creates/updates:
89
- - `CLAUDE.md` (for Claude Code)
90
- - `GEMINI.md` (for Gemini CLI)
91
- - `AGENTS.md` (for Cursor/Copilot)
92
-
93
- ### What Gets Generated
94
-
95
- The generated file contains:
96
-
97
- 1. **Version marker** - Tracks which version of the docs
98
- 2. **Compressed index** - Maps all skills to their reference files
99
- 3. **Block boundaries** - For automatic updates
100
-
101
- Example output:
102
-
103
- ```html
104
- <!-- TITANIUM-KNOWLEDGE-START -->
105
- <!-- Version: v2.0.7 -->
106
- <!--
107
- Titanium SDK Knowledge Index
108
- Generated by titools -->
109
- Based on Vercel's research: https://vercel.com/blog/agents-md-outperforms-skills-in-our-agent-evals
110
-
111
- IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning when working with Titanium SDK.
112
- Always consult the documentation files below rather than relying on training data, which may be outdated.
113
-
114
- This knowledge index is based on the latest Titanium SDK documentation.
115
- -->
116
-
117
- ## Compressed Documentation Index
118
-
119
- ```
120
- [Titanium SDK Docs Index]|root: ~/.agents/skills
121
- |IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning when working with Titanium SDK...
122
- |alloy-expert/references:{alloy-structure.md,anti-patterns.md,code-conventions.md,...}
123
- ...
124
- ```
125
-
126
- <!-- END-TITANIUM-KNOWLEDGE -->
127
- ```
128
-
129
- ### Updating the Index
130
-
131
- When you update titools, simply re-run the command:
132
-
133
- ```bash
134
- titools update # Update skills and docs
135
- titools agents # Regenerate index in your project
136
- ```
137
-
138
- The old block is automatically replaced with the new version.
139
-
140
- ## Version Notice
141
-
142
- The knowledge index is based on the **latest Titanium SDK documentation**.
143
-
144
- **To check your project's version:**
145
- ```bash
146
- grep -A 1 "<sdk-version>" tiapp.xml
147
- ```
148
-
149
- **If there's a version mismatch:**
150
- - Newer APIs may not exist in your version
151
- - Older deprecated patterns may still be valid for you
152
- - Always verify against your version's official docs: https://titaniumsdk.com/guide
153
-
154
- ## Key Takeaways from Vercel's Research
155
-
156
- 1. **Passive context > Active retrieval** - Information that's always present outperforms information that must be actively loaded
157
- 2. **No activation needed** - The AI doesn't need to decide when to use a skill
158
- 3. **Consistent behavior** - Same information every time, regardless of prompt wording
159
- 4. **100% pass rate** - AGENTS.md approach achieves perfect performance on evaluated tasks
160
-
161
- ## References
162
-
163
- - [Vercel's Blog: agents.md Outperforms Skills in Our Agent Evals](https://vercel.com/blog/agents-md-outperforms-skills-in-our-agent-evals)
164
- - [Repository: macCesar/titools](https://github.com/macCesar/titools)
165
-
166
- ## Maintenance
167
-
168
- This approach is maintained in the [titools](https://github.com/macCesar/titools) project.
169
-
170
- To update your installation:
171
- ```bash
172
- npm update -g @maccesar/titools
173
- titools update
174
- ```
@@ -1,188 +0,0 @@
1
- /**
2
- * Install command
3
- * Installs skills and agents to AI coding assistant directories
4
- */
5
-
6
- import inquirer from 'inquirer';
7
- import chalk from 'chalk';
8
- import ora from 'ora';
9
- import {
10
- SKILLS,
11
- AGENTS,
12
- REPO_URL,
13
- } from '../config.js';
14
- import {
15
- detectPlatforms,
16
- detectOS,
17
- } from '../platform.js';
18
- import {
19
- installSkills,
20
- installAgents,
21
- installAgentsTemplate,
22
- getLocalRepoDir,
23
- } from '../installer.js';
24
- import { downloadRepoArchive } from '../downloader.js';
25
- import { createSkillSymlinks } from '../symlink.js';
26
- import { formatList } from '../utils.js';
27
- import { mkdtemp } from 'fs/promises';
28
- import { join } from 'path';
29
- import { tmpdir } from 'os';
30
-
31
- /**
32
- * Install command handler
33
- * @param {Object} options - Command options
34
- */
35
- export async function installCommand(options) {
36
- console.log('');
37
- console.log(chalk.bold.blue('Titanium SDK Skills Installer'));
38
- console.log('');
39
-
40
- // Detect installed platforms
41
- const detectedPlatforms = detectPlatforms();
42
-
43
- if (detectedPlatforms.length === 0 && !options.path) {
44
- console.log(chalk.yellow('No AI coding assistants detected.'));
45
- console.log('Install one of: Claude Code, Gemini CLI, or Codex CLI');
46
- console.log('Or use: titools install --path /custom/path');
47
- process.exit(1);
48
- }
49
-
50
- // Show detected platforms
51
- for (const platform of detectedPlatforms) {
52
- console.log(chalk.green('✓'), `${platform.displayName} detected`);
53
- }
54
- console.log('');
55
-
56
- // Select platforms to install
57
- let selectedPlatforms = [];
58
-
59
- if (options.path) {
60
- // Custom path mode - skip platform selection
61
- selectedPlatforms = [];
62
- } else if (options.all) {
63
- // Install to all detected platforms
64
- selectedPlatforms = detectedPlatforms;
65
- } else {
66
- // Interactive selection
67
- const answers = await inquirer.prompt([
68
- {
69
- type: 'list',
70
- name: 'platform',
71
- message: 'Select platform to install:',
72
- choices: [
73
- { name: 'All detected platforms', value: 'all' },
74
- ...detectedPlatforms.map((p) => ({
75
- name: `${p.displayName} only`,
76
- value: p.name,
77
- })),
78
- { name: 'Cancel', value: 'cancel' },
79
- ],
80
- },
81
- ]);
82
-
83
- if (answers.platform === 'cancel') {
84
- console.log('Cancelled.');
85
- process.exit(0);
86
- }
87
-
88
- if (answers.platform === 'all') {
89
- selectedPlatforms = detectedPlatforms;
90
- } else {
91
- selectedPlatforms = detectedPlatforms.filter(
92
- (p) => p.name === answers.platform
93
- );
94
- }
95
- }
96
-
97
- if (selectedPlatforms.length === 0 && !options.path) {
98
- console.log('No platforms selected.');
99
- process.exit(0);
100
- }
101
-
102
- // Get repository directory (local or download)
103
- const spinner = ora();
104
- let repoDir = getLocalRepoDir();
105
-
106
- if (!repoDir) {
107
- // Download from GitHub
108
- spinner.start('Downloading from GitHub...');
109
- try {
110
- const tempDir = tmpdir();
111
- repoDir = await mkdtemp(join(tempDir, 'titanium-skills-'));
112
- await downloadRepoArchive(repoDir);
113
- spinner.succeed('Downloaded from GitHub');
114
- } catch (error) {
115
- spinner.fail('Failed to download');
116
- console.error(chalk.red(error.message));
117
- process.exit(1);
118
- }
119
- } else {
120
- console.log(chalk.green('Using local repository'));
121
- }
122
-
123
- try {
124
- // Install skills
125
- spinner.start('Installing skills...');
126
- const skillsResult = await installSkills(repoDir);
127
- spinner.succeed(
128
- `Skills: ${formatList(skillsResult.installed)}`
129
- );
130
-
131
- // Install agents
132
- spinner.start('Installing agents...');
133
- const agentsResult = await installAgents(repoDir);
134
- if (agentsResult.installed.length > 0) {
135
- spinner.succeed(
136
- `Agents: ${formatList(agentsResult.installed)}`
137
- );
138
- } else {
139
- spinner.info('No agents to install (Claude Code not detected)');
140
- }
141
-
142
- // Install AGENTS-TEMPLATE.md
143
- spinner.start('Installing AGENTS-TEMPLATE.md...');
144
- const templateInstalled = await installAgentsTemplate(repoDir);
145
- if (templateInstalled) {
146
- spinner.succeed('AGENTS-TEMPLATE.md installed');
147
- } else {
148
- spinner.warn('AGENTS-TEMPLATE.md not found');
149
- }
150
-
151
- // Create symlinks for selected platforms
152
- for (const platform of selectedPlatforms) {
153
- spinner.start(`Linking ${platform.displayName}...`);
154
- const symlinkResult = await createSkillSymlinks(
155
- platform.skillsDir,
156
- SKILLS
157
- );
158
- if (symlinkResult.linked.length === SKILLS.length) {
159
- spinner.succeed(`${platform.displayName} linked`);
160
- } else {
161
- spinner.warn(
162
- `${platform.displayName}: ${symlinkResult.linked.length}/${SKILLS.length} linked`
163
- );
164
- }
165
- }
166
-
167
- // Summary
168
- console.log('');
169
- console.log(chalk.green('✓ Installation complete!'));
170
- console.log('');
171
- console.log(chalk.bold('▸'), 'Add AGENTS.md to your project:', chalk.cyan('titools agents'));
172
- console.log(chalk.bold('▸'), 'Improves AI:', chalk.red('53%'), '→', chalk.green('100%'));
173
- console.log('');
174
-
175
- if (detectOS() === 'windows') {
176
- console.log(chalk.yellow('▸'), 'Windows: Ensure ~/bin is in your PATH');
177
- console.log('');
178
- }
179
-
180
- } finally {
181
- // Clean up temp directory if we downloaded
182
- if (repoDir !== getLocalRepoDir() && repoDir.startsWith(tmpdir())) {
183
- await import('fs-extra').then(({ remove }) => remove(repoDir));
184
- }
185
- }
186
- }
187
-
188
- export default installCommand;
@@ -1,133 +0,0 @@
1
- # Titanium Alloy + PurgeTSS Anti-Patterns
2
-
3
- ## 1. Manual Styling (Legacy & Overwrite Risk)
4
- **Symptom:** Editing `app.tss` manually or using inline attributes like `backgroundColor="#fff"`.
5
- **Problem:** PurgeTSS will overwrite manual changes in `app.tss`. Inline attributes make theme changes impossible.
6
- **Solution:** Use **PurgeTSS classes** in XML.
7
-
8
- ## 2. Fat Controllers
9
- **Symptom:** Controllers with 100+ lines handling logic, API, and UI.
10
- **Solution:** Delegate business logic to `lib/services/` and API calls to `lib/api/`.
11
-
12
- ## 3. Memory Leaks (Missing Cleanup)
13
- **Symptom:** Adding `Ti.App` or `Alloy.Collections` listeners without a `cleanup()` function.
14
- **Solution:** Always implement `$.cleanup = cleanup` and remove listeners there.
15
-
16
- ## 4. Direct Native Module Calls
17
- **Symptom:** Calling `require('ti.module')` directly in a controller.
18
- **Solution:** Wrap it in a service in `lib/services/` (e.g., `audioService.js`).
19
-
20
- ## 5. Direct Controller Navigation
21
- **Symptom:** `Alloy.createController('name').getView().open()`.
22
- **Solution:** Use a Navigation Service to centralize `open/close` and trigger the `cleanup()` function automatically.
23
-
24
- ## 6. Complex Matrix Animations
25
- **Symptom:** Manual use of `Ti.UI.create2DMatrix()`.
26
- **Solution:** Use the **PurgeTSS Animation Module** with state modifiers (`class="close:opacity-0 open:opacity-100"`).
27
-
28
- ## 7. Hardcoded Strings & Missing a11y
29
- **Symptom:** `text="Login"` instead of `text="L('login')"`, or missing `accessibilityLabel`.
30
- **Solution:** Always use i18n and accessibility properties.
31
-
32
- ## 8. Logic in TSS
33
- **Symptom:** Using conditionals or calculations inside TSS.
34
- **Solution:** Keep styling declarative through PurgeTSS classes.
35
-
36
- ---
37
-
38
- ## PurgeTSS-Specific Anti-Patterns
39
-
40
- ## 9. Flexbox Classes (Don't Exist)
41
- **Symptom:** Using `flex-row`, `flex-col`, `justify-between`, `justify-center`, `items-center`.
42
- **Problem:** Titanium does NOT support CSS Flexbox. These classes don't exist in PurgeTSS.
43
- **Solution:** Use Titanium layout modes:
44
- ```xml
45
- <!-- WRONG -->
46
- <View class="flex-row justify-between">
47
-
48
- <!-- CORRECT -->
49
- <View class="horizontal">
50
- ```
51
-
52
- ## 10. Padding on Container Views
53
- **Symptom:** Using `p-4`, `px-2`, `py-3` on View, Window, ScrollView, or TableView.
54
- **Problem:** Base container elements don't support padding in Titanium.
55
- **Solution:** Use margins on children instead:
56
- ```xml
57
- <!-- WRONG -->
58
- <View class="p-4">
59
- <Label text="Hello" />
60
- </View>
61
-
62
- <!-- CORRECT -->
63
- <View>
64
- <Label class="m-4" text="Hello" />
65
- </View>
66
- ```
67
-
68
- ## 11. Confusing `w-full` with `w-screen`
69
- **Symptom:** Using `w-full` when `w-screen` is needed.
70
- **Difference:** `w-full` sets `width: '100%'` (100% of parent), while `w-screen` sets `width: Ti.UI.FILL` (fills available space).
71
- **Solution:** Use `w-screen` for full-width elements that should fill space. `w-full` is useful when you need percentage-based sizing.
72
-
73
- ## 12. Using `rounded-full` Without Size
74
- **Symptom:** Using `rounded-full` expecting a circle.
75
- **Problem:** `rounded-full` (without number) doesn't exist. You need `rounded-full-XX` where XX × 4 = element size.
76
- **Note:** `rounded-full-XX` already includes width and height. Don't add `w-XX h-XX` with it.
77
- **Solution:** For a 48×48 circle, use `rounded-full-12` (includes size). For percentage-based, use `w-12 h-12 rounded-full`.
78
-
79
- ## 13. Adding `composite` Class Explicitly
80
- **Symptom:** Adding `class="composite"` to Views.
81
- **Problem:** Composite (absolute positioning) is the DEFAULT layout. Adding it is redundant.
82
- **Solution:** Omit layout class for composite, only use `horizontal` or `vertical` when needed.
83
-
84
- ## 14. Square Brackets for Arbitrary Values
85
- **Symptom:** Using `w-[100px]` or `bg-[#ff0000]` with square brackets.
86
- **Problem:** PurgeTSS uses parentheses, not square brackets.
87
- **Solution:** Use parentheses: `w-(100px)`, `bg-(#ff0000)`.
88
-
89
- ## 15. Creating Manual .tss Files Per Controller
90
- **Symptom:** Creating `app/styles/login.tss`, `app/styles/profile.tss`, etc.
91
- **Problem:** Defeats the purpose of PurgeTSS which auto-generates a single optimized `app.tss`.
92
- **Solution:** Use ONLY utility classes in XML. Delete all manual `.tss` files except `_app.tss`.
93
-
94
- ## 16. Using `lib/` Prefix in Require Statements
95
- **Symptom:** `const service = require('lib/services/picsum')`
96
- **Problem:** Alloy flattens the `lib/` folder during build. Files in `app/lib/services/` become `Resources/iphone/services/`.
97
- **Solution:** Omit the `lib/` prefix: `const service = require('services/picsum')`
98
-
99
- ## 17. Wrong Window ID in Controller
100
- **Symptom:** Using `$.index.open()` when the Window has `id="mainWindow"`.
101
- **Problem:** Alloy generates `$` references from XML IDs. If Window is `id="mainWindow"`, `$.index` doesn't exist.
102
- **Solution:** Match the ID: `$.mainWindow.open()`
103
-
104
- ## 18. Using `Ti.UI.createNotification`
105
- **Symptom:** `Ti.UI.createNotification({ message: 'Hi' }).show()`
106
- **Problem:** This API doesn't exist in Titanium. Causes "invalid method" error.
107
- **Solution:** Use `Ti.UI.createAlertDialog` for simple messages, or create custom toast views.
108
-
109
- ## 19. Using Nonexistent iOS Share APIs
110
- **Symptom:** `Ti.UI.iOS.createActivityPopover` or `alloy/social` with wrong methods.
111
- **Problem:** These APIs either don't exist or have changed. Causes runtime errors.
112
- **Solution:**
113
- - iOS: Use `Ti.UI.iOS.createDocumentViewer` for files, or simple `Ti.UI.createOptionDialog` + `Ti.UI.Clipboard` for links
114
- - Android: Use `Ti.Android.createIntent` with ACTION_SEND
115
-
116
- ---
117
-
118
- ## Quick Reference Table
119
-
120
- | Anti-Pattern | Why It Fails | Correct Approach |
121
- | -------------------- | ------------------------ | ----------------------- |
122
- | `flex-row` | Flexbox not supported | `horizontal` |
123
- | `flex-col` | Flexbox not supported | `vertical` |
124
- | `justify-*` | Flexbox not supported | Use margins/positioning |
125
- | `p-4` on View | No padding on containers | `m-4` on children |
126
- | `w-full` | Doesn't exist | `w-screen` |
127
- | `rounded-full` | Needs size suffix | `rounded-full-12` |
128
- | `composite` class | Already default | Omit it |
129
- | `w-[100px]` | Wrong syntax | `w-(100px)` |
130
- | Manual `.tss` | Overwritten by PurgeTSS | Use utility classes |
131
- | `lib/` prefix | lib/ is flattened | Use path without lib/ |
132
- | `$.index.open()` | Wrong ID reference | Use actual Window ID |
133
- | `createNotification` | API doesn't exist | `createAlertDialog` |