@maccesar/titools 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/AGENTS-TEMPLATE.md +173 -0
  2. package/README.md +867 -0
  3. package/agents/ti-researcher.md +108 -0
  4. package/bin/titools.js +53 -0
  5. package/lib/commands/agents.js +126 -0
  6. package/lib/commands/install.js +188 -0
  7. package/lib/commands/uninstall.js +215 -0
  8. package/lib/commands/update.js +159 -0
  9. package/lib/config.js +119 -0
  10. package/lib/downloader.js +153 -0
  11. package/lib/installer.js +253 -0
  12. package/lib/platform.js +108 -0
  13. package/lib/symlink.js +142 -0
  14. package/lib/utils.js +270 -0
  15. package/package.json +67 -0
  16. package/skills/alloy-expert/SKILL.md +247 -0
  17. package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
  18. package/skills/alloy-expert/references/alloy-structure.md +381 -0
  19. package/skills/alloy-expert/references/anti-patterns.md +133 -0
  20. package/skills/alloy-expert/references/code-conventions.md +469 -0
  21. package/skills/alloy-expert/references/contracts.md +280 -0
  22. package/skills/alloy-expert/references/controller-patterns.md +520 -0
  23. package/skills/alloy-expert/references/error-handling.md +484 -0
  24. package/skills/alloy-expert/references/examples.md +735 -0
  25. package/skills/alloy-expert/references/migration-patterns.md +298 -0
  26. package/skills/alloy-expert/references/patterns.md +448 -0
  27. package/skills/alloy-expert/references/performance-patterns.md +855 -0
  28. package/skills/alloy-expert/references/security-patterns.md +847 -0
  29. package/skills/alloy-expert/references/state-management.md +779 -0
  30. package/skills/alloy-expert/references/testing.md +872 -0
  31. package/skills/alloy-guides/SKILL.md +214 -0
  32. package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
  33. package/skills/alloy-guides/references/CONCEPTS.md +191 -0
  34. package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
  35. package/skills/alloy-guides/references/MODELS.md +1028 -0
  36. package/skills/alloy-guides/references/PURGETSS.md +56 -0
  37. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
  38. package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
  39. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
  40. package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
  41. package/skills/alloy-guides/references/WIDGETS.md +176 -0
  42. package/skills/alloy-howtos/SKILL.md +203 -0
  43. package/skills/alloy-howtos/references/best_practices.md +138 -0
  44. package/skills/alloy-howtos/references/cli_reference.md +253 -0
  45. package/skills/alloy-howtos/references/config_files.md +87 -0
  46. package/skills/alloy-howtos/references/custom_tags.md +147 -0
  47. package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
  48. package/skills/alloy-howtos/references/samples.md +167 -0
  49. package/skills/purgetss/SKILL.md +442 -0
  50. package/skills/purgetss/assets/purgetss.config.cjs +17 -0
  51. package/skills/purgetss/references/EXAMPLES.md +247 -0
  52. package/skills/purgetss/references/animation-system.md +1294 -0
  53. package/skills/purgetss/references/apply-directive.md +375 -0
  54. package/skills/purgetss/references/arbitrary-values.md +612 -0
  55. package/skills/purgetss/references/class-index.md +1350 -0
  56. package/skills/purgetss/references/cli-commands.md +948 -0
  57. package/skills/purgetss/references/configurable-properties.md +654 -0
  58. package/skills/purgetss/references/custom-rules.md +161 -0
  59. package/skills/purgetss/references/customization-deep-dive.md +722 -0
  60. package/skills/purgetss/references/dynamic-component-creation.md +489 -0
  61. package/skills/purgetss/references/grid-layout.md +455 -0
  62. package/skills/purgetss/references/icon-fonts.md +609 -0
  63. package/skills/purgetss/references/installation-setup.md +366 -0
  64. package/skills/purgetss/references/opacity-modifier.md +291 -0
  65. package/skills/purgetss/references/platform-modifiers.md +479 -0
  66. package/skills/purgetss/references/smart-mappings.md +42 -0
  67. package/skills/purgetss/references/titanium-resets.md +359 -0
  68. package/skills/purgetss/references/ui-ux-design.md +1526 -0
  69. package/skills/ti-guides/SKILL.md +94 -0
  70. package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
  71. package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
  72. package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
  73. package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
  74. package/skills/ti-guides/references/android-manifest.md +97 -0
  75. package/skills/ti-guides/references/app-distribution.md +258 -0
  76. package/skills/ti-guides/references/application-frameworks.md +377 -0
  77. package/skills/ti-guides/references/cli-reference.md +402 -0
  78. package/skills/ti-guides/references/coding-best-practices.md +102 -0
  79. package/skills/ti-guides/references/commonjs-advanced.md +134 -0
  80. package/skills/ti-guides/references/hello-world.md +100 -0
  81. package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
  82. package/skills/ti-guides/references/javascript-primer.md +411 -0
  83. package/skills/ti-guides/references/reserved-words.md +36 -0
  84. package/skills/ti-guides/references/resources.md +183 -0
  85. package/skills/ti-guides/references/style-and-conventions.md +48 -0
  86. package/skills/ti-guides/references/tiapp-config.md +609 -0
  87. package/skills/ti-howtos/SKILL.md +174 -0
  88. package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
  89. package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
  90. package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
  91. package/skills/ti-howtos/references/cross-platform-development.md +348 -0
  92. package/skills/ti-howtos/references/debugging-profiling.md +543 -0
  93. package/skills/ti-howtos/references/extending-titanium.md +723 -0
  94. package/skills/ti-howtos/references/google-maps-v2.md +169 -0
  95. package/skills/ti-howtos/references/ios-map-kit.md +143 -0
  96. package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
  97. package/skills/ti-howtos/references/local-data-sources.md +301 -0
  98. package/skills/ti-howtos/references/location-and-maps.md +252 -0
  99. package/skills/ti-howtos/references/media-apis.md +210 -0
  100. package/skills/ti-howtos/references/notification-services.md +599 -0
  101. package/skills/ti-howtos/references/remote-data-sources.md +349 -0
  102. package/skills/ti-howtos/references/tutorials.md +502 -0
  103. package/skills/ti-howtos/references/using-modules.md +237 -0
  104. package/skills/ti-howtos/references/web-content-integration.md +307 -0
  105. package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
  106. package/skills/ti-ui/SKILL.md +179 -0
  107. package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
  108. package/skills/ti-ui/references/animation-and-matrices.md +599 -0
  109. package/skills/ti-ui/references/application-structures.md +655 -0
  110. package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
  111. package/skills/ti-ui/references/event-handling.md +393 -0
  112. package/skills/ti-ui/references/gestures.md +473 -0
  113. package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
  114. package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
  115. package/skills/ti-ui/references/listviews-and-performance.md +619 -0
  116. package/skills/ti-ui/references/orientation.md +362 -0
  117. package/skills/ti-ui/references/platform-ui-android.md +635 -0
  118. package/skills/ti-ui/references/platform-ui-ios.md +469 -0
  119. package/skills/ti-ui/references/scrolling-views.md +252 -0
  120. package/skills/ti-ui/references/tableviews.md +568 -0
@@ -0,0 +1,253 @@
1
+ # Alloy Command-Line Interface Reference
2
+
3
+ The Alloy CLI is a command-line tool for managing and building Alloy projects.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Alloy Command-Line Interface Reference](#alloy-command-line-interface-reference)
8
+ - [Table of Contents](#table-of-contents)
9
+ - [Installation](#installation)
10
+ - [Manual Installation](#manual-installation)
11
+ - [Bleeding Edge Installation](#bleeding-edge-installation)
12
+ - [Commands](#commands)
13
+ - [new](#new)
14
+ - [generate](#generate)
15
+ - [Model Format](#model-format)
16
+ - [install](#install)
17
+ - [compile](#compile)
18
+ - [run](#run)
19
+ - [i18n-extract](#i18n-extract)
20
+ - [copy](#copy)
21
+ - [move](#move)
22
+ - [remove](#remove)
23
+ - [Additional Options](#additional-options)
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ The Alloy CLI is automatically installed when installing the `alloy` package.
30
+
31
+ ### Manual Installation
32
+
33
+ Install Node.js from [nodejs.org](http://nodejs.org/#download) first, then:
34
+
35
+ ```bash
36
+ sudo npm install -g alloy
37
+ ```
38
+
39
+ For a specific version:
40
+ ```bash
41
+ sudo npm install -g alloy@1.10.0
42
+ ```
43
+
44
+ ### Bleeding Edge Installation
45
+
46
+ ```bash
47
+ git clone https://github.com/tidev/alloy.git
48
+ cd alloy
49
+ [sudo] npm install -g .
50
+ ```
51
+
52
+ ## Commands
53
+
54
+ ### new
55
+
56
+ Creates a new Alloy project on an existing Titanium project.
57
+
58
+ ```bash
59
+ alloy new [<project_path>] [<project_template>] [--force] [--no-colors]
60
+ ```
61
+
62
+ | Option | Description |
63
+ | -------------------- | --------------------------------------------------------------------------------- |
64
+ | `<project_path>` | Path to skeleton Titanium project (default: current directory) |
65
+ | `<project_template>` | **default** (single pane) or **two_tabbed** (tabbed app) |
66
+ | `--testapp <path>` | Relative path to a test application in the Alloy GitHub repo (under `test/apps/`) |
67
+ | `-f, --force` | Force execution |
68
+ | `-n, --no-colors` | Disable color output |
69
+
70
+ ### generate
71
+
72
+ Creates skeleton Alloy components.
73
+
74
+ ```bash
75
+ alloy generate <component> [--widgetname <widget_name>] [--outputPath <output_path>] [--platform <platform>] [--force] [--no-colors]
76
+ ```
77
+
78
+ | Component | Description |
79
+ | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
+ | `controller <name>` | Create controller, view and style |
81
+ | `jmk` | Create `alloy.jmk` |
82
+ | `model <name> <adapter> [schema]` | Create model (see Model Format below) |
83
+ | `migration <model_name>` | Create migration file |
84
+ | `style <name>` or `--all` | Create style file (or all styles). If name matches a view-controller, it populates using IDs/classes from markup. Running again updates existing files with new attributes. |
85
+ | `view <name>` | Create view and style |
86
+ | `widget <name>` | Create widget |
87
+
88
+ | Option | Description |
89
+ | ------------------------- | ------------------------------------------------ |
90
+ | `--widgetname <name>` | Create component for specified widget |
91
+ | `-o, --outputPath <path>` | Output path (point to 'app' directory) |
92
+ | `--platform <platform>` | Create platform-specific component (android/ios) |
93
+ | `-f, --force` | Force execution |
94
+ | `-n, --no-colors` | Disable color output |
95
+
96
+ #### Model Format
97
+
98
+ Select adapter type:
99
+ - `sql` - SQLite database for Android/iOS (also generates a migration file)
100
+ - `properties` - Local storage in Titanium SDK context
101
+
102
+ Schema format: space-delimited list of `field:type`
103
+ - Example: `name:string age:number sex:varchar dob:date`
104
+
105
+ SQLite type mapping:
106
+
107
+ | Datatype | SQLite Type |
108
+ | ---------------------------------------- | ----------- |
109
+ | string, varchar, text | TEXT |
110
+ | int, tinyint, smallint, bigint, integer | INTEGER |
111
+ | double, float, real | REAL |
112
+ | blob | BLOB |
113
+ | decimal, number, date, datetime, boolean | NUMERIC |
114
+ | null | NULL |
115
+ | unknown | TEXT |
116
+
117
+ ### install
118
+
119
+ Installs special Alloy project components.
120
+
121
+ ```bash
122
+ alloy install <module> [<project_path>]
123
+ ```
124
+
125
+ | Module | Description |
126
+ | ---------------- | ----------------------------------------- |
127
+ | `plugin` | Install compiler plugin for Studio |
128
+ | `<project_path>` | Project path (default: current directory) |
129
+
130
+ ### compile
131
+
132
+ Compiles Alloy code to Titanium SDK code.
133
+
134
+ ```bash
135
+ alloy compile [<project_path>] [--config <compiler_options>] [--no-colors]
136
+ ```
137
+
138
+ | Option | Description |
139
+ | ------------------------ | ------------------------------------------------------------------------- |
140
+ | `<project_path>` | Project path (default: current directory) |
141
+ | `-c, --config <options>` | Comma-delimited compiler options (e.g., `beautify=false,deploytype=test`) |
142
+ | `-n, --no-colors` | Disable color output |
143
+
144
+ Compiler options reference the `event.alloyConfig` object in [Build Configuration File (alloy.jmk)](config_files.md).
145
+
146
+ ### run
147
+
148
+ Use `titanium build` command to run Alloy projects. See [Titanium Command-Line Interface Reference](https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_Guide/Titanium_Command-Line_Interface_Reference/).
149
+
150
+ :::tip COMMON ti build PITFALLS
151
+
152
+ **❌ Using `-C` flag without UDID:**
153
+ ```bash
154
+ # WRONG - Prompts for simulator selection interactively
155
+ ti build -p ios -T simulator -C
156
+ ```
157
+
158
+ **✅ Correct approach for simulator:**
159
+ ```bash
160
+ # GOOD - Runs on default simulator
161
+ ti build -p ios -T simulator
162
+ ```
163
+
164
+ **❌ Using `--no-prompt` incorrectly:**
165
+ ```bash
166
+ # Still may prompt for device selection if not specific
167
+ ti build -p ios --no-prompt
168
+ ```
169
+
170
+ **✅ Always specify target:**
171
+ ```bash
172
+ # GOOD - Clear target specification
173
+ ti build -p ios -T simulator --no-prompt
174
+ ```
175
+
176
+ **Common patterns:**
177
+ ```bash
178
+ # iOS Simulator (most common during development)
179
+ ti build -p ios -T simulator
180
+
181
+ # iOS Device (requires UDID)
182
+ ti build -p ios -T device -V <udid>
183
+
184
+ # Android Emulator
185
+ ti build -p android -T emulator
186
+
187
+ # Build only (don't run)
188
+ ti build -p ios -T simulator --build-only
189
+ ```
190
+ :::
191
+
192
+ ### i18n-extract
193
+
194
+ Extracts i18n keys from TSS and JS files to strings.xml.
195
+
196
+ ```bash
197
+ alloy extract-i18n [<language>] [--apply]
198
+ ```
199
+
200
+ | Option | Description |
201
+ | ------------ | ------------------------------------------ |
202
+ | `<language>` | Two-letter language code (default: **en**) |
203
+ | `--apply` | Write to strings.xml (preview if absent) |
204
+
205
+ Supported functions:
206
+ - `Ti.Locale.getString()`
207
+ - `L()`
208
+
209
+ Usage Examples:
210
+ ```bash
211
+ # Preview changes for default (English)
212
+ alloy extract-i18n
213
+
214
+ # Write changes to "app/i18n/en/strings.xml"
215
+ alloy extract-i18n --apply
216
+
217
+ # Specify "es" as the language and write the changes to "app/i18n/es/strings.xml"
218
+ alloy extract-i18n es --apply
219
+
220
+ # Preview Spanish changes
221
+ alloy extract-i18n es
222
+ ```
223
+
224
+ ### copy
225
+
226
+ Copy a view-controller (controller, XML, TSS).
227
+
228
+ ```bash
229
+ alloy copy <CONTROLLER_NAME> <COPIED_CONTROLLER_NAME>
230
+ ```
231
+
232
+ ### move
233
+
234
+ Rename a view-controller.
235
+
236
+ ```bash
237
+ alloy move <CONTROLLER_NAME> <NEW_CONTROLLER_NAME>
238
+ ```
239
+
240
+ ### remove
241
+
242
+ Remove a view-controller.
243
+
244
+ ```bash
245
+ alloy remove <CONTROLLER_NAME>
246
+ ```
247
+
248
+ ## Additional Options
249
+
250
+ | Option | Description |
251
+ | --------------- | --------------------- |
252
+ | `-h, --help` | Output command usage |
253
+ | `-v, --version` | Output version number |
@@ -0,0 +1,87 @@
1
+ # Alloy Configuration Files Reference
2
+
3
+ ## Table of Contents
4
+
5
+ - [Alloy Configuration Files Reference](#alloy-configuration-files-reference)
6
+ - [Table of Contents](#table-of-contents)
7
+ - [Build Configuration File (alloy.jmk)](#build-configuration-file-alloyjmk)
8
+ - [Compiler Tasks (Event Names)](#compiler-tasks-event-names)
9
+ - [Event Object](#event-object)
10
+ - [Logger Object](#logger-object)
11
+ - [Objects](#objects)
12
+ - [Keys](#keys)
13
+
14
+ ---
15
+
16
+ ## Build Configuration File (alloy.jmk)
17
+
18
+ Alloy provides hooks to customize compilation using a JS Makefile (JMK).
19
+
20
+ **Location:** `app/alloy.jmk`
21
+
22
+ **Example:**
23
+ ```javascript
24
+ task('pre:compile', (event, logger) => {
25
+ logger.showTimestamp = true;
26
+ logger.info(`building project at ${event.dir.project}`);
27
+ });
28
+
29
+ task('post:compile', (event, logger) => {
30
+ logger.info('compile finished!');
31
+ });
32
+ ```
33
+
34
+ ### Compiler Tasks (Event Names)
35
+
36
+ | Task | When Called |
37
+ | ---------------- | --------------------------------------------------------- |
38
+ | `pre:load` | After project clean, before copying assets to `Resources` |
39
+ | `pre:compile` | Before compiler starts |
40
+ | `post:compile` | After compiler finishes, before exit |
41
+ | `compile:app.js` | After compiling `app.js`, before writing to disk |
42
+
43
+ ### Event Object
44
+
45
+ | Property | Type | Description |
46
+ | -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
47
+ | `adapters` | Array | List of adapters |
48
+ | `alloyConfig` | Object | Compiler config: `platform` (android/ios), `file` (selective compile), `deploytype` (development/test/production), `beautify` (Boolean) |
49
+ | `autoStyle` | Boolean | Autostyle enabled for project |
50
+ | `dependencies` | Object | Value of `dependencies` key in config.json |
51
+ | `dir` | Object | Directory paths: `home` (app path), `project` (root path), `resources`, `resourcesAlloy`, `assets`, `config`, `controllers`, `migrations`, `models`, `styles`, `themes`, `views`, `widgets`, `builtins`, `template` |
52
+ | `sourcemap` | Boolean | If `true`, generates mapping files to link generated Titanium files in `Resources` back to the source files in `app` for debugging. |
53
+ | `theme` | String | Theme name being used |
54
+ | `code` | String | *(compile:app.js only)* Contents of `app.js` |
55
+ | `appJSFile` | String | *(compile:app.js only)* Absolute path to `app.js` |
56
+
57
+ ### Logger Object
58
+ ...
59
+ ### Objects
60
+
61
+ | Object | Description |
62
+ | ----------------- | ----------------------------------------------------------- |
63
+ | `global` | Key-value pairs for all environments and platforms |
64
+ | `env:development` | Development builds (simulator/emulator) |
65
+ | `env:test` | Test builds on device |
66
+ | `env:production` | Production builds (after package installation) |
67
+ | `os:android` | Android-specific values |
68
+ | `os:ios` | iOS-specific values |
69
+ | `dependencies` | Widget dependencies (name: version) |
70
+ | `autoStyle` | Enable autostyle for entire project |
71
+ | `backbone` | Backbone.js version: `0.9.2` (default), `1.1.2`, or `1.3.3` |
72
+
73
+ **Precedence:** `os` > `env` > `global`. Combinations (e.g., `os:ios env:production`) override single values.
74
+ ...
75
+ ### Keys
76
+
77
+ | Key | Type | Required | Description |
78
+ | ---------------------- | ------ | -------- | ------------------------------------- |
79
+ | `id` | String | Yes | Must match widget root folder name |
80
+ | `copyright` | String | No | Copyright information |
81
+ | `license` | String | No | License information |
82
+ | `min-alloy-version` | Float | No* | Minimum Alloy version required |
83
+ | `min-titanium-version` | Float | No* | Minimum Titanium version required |
84
+ | `tags` | String | No | Comma-delimited keywords |
85
+ | `platforms` | String | No* | Supported platforms (comma-delimited) |
86
+
87
+ (*) Currently, `min-alloy-version`, `min-titanium-version`, and `platforms` are not strictly enforced, but Alloy will perform checks against these in future versions.
@@ -0,0 +1,147 @@
1
+ # Creating Custom Tags in Titanium with Alloy
2
+
3
+ Custom tags allow you to create reusable UI components without the overhead of widgets. They are an incredibly fast way to build a suite of controls that are as easy to use as dropping a file into the `app/lib` folder.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Creating Custom Tags in Titanium with Alloy](#creating-custom-tags-in-titanium-with-alloy)
8
+ - [Table of Contents](#table-of-contents)
9
+ - [Why Use Custom Tags?](#why-use-custom-tags)
10
+ - [Basic Setup](#basic-setup)
11
+ - [Robust Example: CheckBox](#robust-example-checkbox)
12
+ - [Global Module Override](#global-module-override)
13
+ - [Key Points](#key-points)
14
+ - [Custom Tags vs Widgets](#custom-tags-vs-widgets)
15
+
16
+ ---
17
+
18
+ ## Why Use Custom Tags?
19
+
20
+ When building cross-platform applications, you often need specific UI controls (like a web-style checkbox) that don't exist natively. You have three main approaches:
21
+
22
+ 1. **Direct XML/JS:** Copy-pasting code into every view. Not reusable and messy.
23
+ 2. **Widgets:** Highly reusable but requires a folder structure and `dependencies` in `config.json`.
24
+ 3. **Custom Tags:** Single file in `app/lib/`, no config dependency, and very simple to share. They reduce the amount of platform-specific code in your views, keeping them simple and readable.
25
+
26
+ ## Basic Setup
27
+
28
+ 1. Create a file in `app/lib/` (e.g., `checkbox.js`)
29
+ 2. Export a `create<TagName>` function
30
+ 3. Use in XML with the `module` attribute
31
+
32
+ **view.xml**
33
+ ```xml
34
+ <CheckBox module="checkbox" id="termsAccepted"
35
+ caption="I agree to the terms of use"
36
+ underline="true"
37
+ onCaptionClick="doShowTerms"
38
+ onChange="onCheckChange" />
39
+ ```
40
+ The `module` attribute tells Alloy to look in `checkbox.js` for a `createCheckBox` function, pass it the arguments from XML/TSS, and expect a `Ti.UI.*` component back.
41
+
42
+ ## Robust Example: CheckBox
43
+
44
+ **app/lib/checkbox.js**
45
+ ```javascript
46
+ exports.createCheckBox = args => {
47
+ // Wrapper view for all components
48
+ const wrapper = Ti.UI.createView({
49
+ top: args.top || 5,
50
+ width: Ti.UI.SIZE,
51
+ height: Ti.UI.SIZE,
52
+ layout: "horizontal",
53
+ left: args.left || 20,
54
+ right: args.right || null,
55
+ checked: args.checked || false
56
+ });
57
+
58
+ // The box itself
59
+ const box = Ti.UI.createView({
60
+ width: 15,
61
+ height: 15,
62
+ borderWidth: 1,
63
+ borderColor: "#02A9F4"
64
+ });
65
+
66
+ // Attributed string for styled caption (e.g. underline)
67
+ const attr = Ti.UI.createAttributedString({
68
+ text: args.caption
69
+ });
70
+
71
+ if (args.underline) {
72
+ attr.applyProperties({
73
+ attributes: [{
74
+ type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,
75
+ value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
76
+ range: [0, args.caption.length]
77
+ }]
78
+ });
79
+ }
80
+
81
+ const caption = Ti.UI.createLabel({
82
+ color: "#000",
83
+ attributedString: attr,
84
+ left: 10,
85
+ text: args.caption,
86
+ font: { fontSize: 10 }
87
+ });
88
+
89
+ // The tick (using Unicode to avoid assets)
90
+ const tick = Ti.UI.createLabel({
91
+ text: "\u2713",
92
+ left: 1,
93
+ color: "#02A9F4",
94
+ font: { fontWeight: "bold" },
95
+ visible: args.checked || false
96
+ });
97
+
98
+ // Handle clicks
99
+ caption.addEventListener("click", () => {
100
+ wrapper.fireEvent("captionClick");
101
+ });
102
+
103
+ box.addEventListener("click", () => {
104
+ tick.visible = !tick.visible;
105
+ wrapper.checked = !wrapper.checked;
106
+ wrapper.fireEvent("change", { checked: wrapper.checked });
107
+ });
108
+
109
+ box.add(tick);
110
+ wrapper.add(box);
111
+ wrapper.add(caption);
112
+
113
+ return wrapper;
114
+ };
115
+ ```
116
+
117
+ ## Global Module Override
118
+
119
+ Apply a module to all tags in a view by updating the `Alloy` tag. Alloy will check your specified file for any tag creation overrides before falling back to default implementations:
120
+
121
+ ```xml
122
+ <Alloy module="ui">
123
+ <Window>
124
+ <CustomButton /> <!-- Looks for createCustomButton in app/lib/ui.js -->
125
+ <Label /> <!-- Checks ui.js for createLabel first -->
126
+ </Window>
127
+ </Alloy>
128
+ ```
129
+ This is powerful for adding default colors or properties (like a black default color for Android Labels) across an entire project.
130
+
131
+ ## Key Points
132
+
133
+ | Aspect | Description |
134
+ | ------------- | ------------------------------------------------------------- |
135
+ | File location | `app/lib/<module_name>.js` |
136
+ | Function name | `create<TagName>` (e.g., `createCheckBox` for `<CheckBox>`) |
137
+ | Return value | Must return a `Ti.UI.*` component (View, Button, Label, etc.) |
138
+ | Arguments | Receives all XML/TSS attributes in a single `args` object |
139
+
140
+ ## Custom Tags vs Widgets
141
+
142
+ | Custom Tags | Widgets |
143
+ | ------------------------------------- | ---------------------------------------- |
144
+ | Single file in `app/lib/` | Separate folder structure |
145
+ | No `config.json` dependency needed | Requires `dependencies` in `config.json` |
146
+ | Simpler for single-component controls | Better for complex multi-view components |
147
+ | Easier to share across projects | More formal packaging |
@@ -0,0 +1,101 @@
1
+ # Alloy Debugging and Troubleshooting
2
+
3
+ ## Table of Contents
4
+
5
+ - [Alloy Debugging and Troubleshooting](#alloy-debugging-and-troubleshooting)
6
+ - [Table of Contents](#table-of-contents)
7
+ - [Overview](#overview)
8
+ - [Debugging](#debugging)
9
+ - [Compiler Error Messages](#compiler-error-messages)
10
+ - [Troubleshooting](#troubleshooting)
11
+ - [Error: No app.js Found](#error-no-appjs-found)
12
+ - [Android: Images, HTML and Assets Not Displaying](#android-images-html-and-assets-not-displaying)
13
+ - [Android Runtime Error: Cannot Call Method of Undefined](#android-runtime-error-cannot-call-method-of-undefined)
14
+ - [Android Runtime Error: Alloy is Not Defined](#android-runtime-error-alloy-is-not-defined)
15
+ - [iOS Application Error: Invalid Method Passed to UIModule](#ios-application-error-invalid-method-passed-to-uimodule)
16
+ - [iOS Application Error: Undefined is Not an Object](#ios-application-error-undefined-is-not-an-object)
17
+ - [Getting Help](#getting-help)
18
+ - [Submitting a Bug Report](#submitting-a-bug-report)
19
+
20
+ ---
21
+
22
+ ## Overview
23
+
24
+ This guide covers debugging and troubleshooting Alloy applications.
25
+
26
+ ## Debugging
27
+
28
+ ### Compiler Error Messages
29
+
30
+ The Alloy compiler generates error messages for syntax errors in JavaScript, JSON, TSS and XML files. Error messages report:
31
+ - File path
32
+ - Line and character position
33
+ - Description of the error
34
+
35
+ ## Troubleshooting
36
+
37
+ ### Error: No app.js Found
38
+
39
+ **Error:** `[ERROR] No app.js found. Ensure the app.js file exists in your project's Resources directory.`
40
+
41
+ **Solution:** If part of the contents of your `Resources` folder were deleted, run:
42
+ ```bash
43
+ alloy compile --config platform=<platform>
44
+ ```
45
+
46
+ ### Android: Images, HTML and Assets Not Displaying
47
+
48
+ **Problem:** Assets display on iOS and Mobile Web but not Android.
49
+
50
+ **Solution:** Android requires absolute paths. Precede asset paths with a slash ('/'). iOS and Mobile Web accept both relative and absolute paths.
51
+
52
+ ### Android Runtime Error: Cannot Call Method of Undefined
53
+
54
+ **Error:** `Uncaught TypeError: Cannot call method xxx of undefined`
55
+
56
+ **Causes:**
57
+ 1. Creating an iOS-only Titanium object. Use the `platform` attribute in views to enforce platform-specific objects.
58
+ 2. Top-level UI component has an assigned ID. The controller cannot use `$.<controller_name>` to reference it; use the assigned ID instead.
59
+
60
+ ### Android Runtime Error: Alloy is Not Defined
61
+
62
+ **Error:** `Uncaught ReferenceError: Alloy is not defined`
63
+
64
+ **Cause:** Non-controller JavaScript files are not automatically wrapped by Alloy.
65
+
66
+ **Solution:** Require the 'alloy' module:
67
+ ```javascript
68
+ const Alloy = require('alloy');
69
+ ```
70
+
71
+ ### iOS Application Error: Invalid Method Passed to UIModule
72
+
73
+ **Error:** `invalid method (xxx) passed to UIModule (unknown file)`
74
+
75
+ **Cause:** Trying to create an Android-only Titanium object.
76
+
77
+ **Solution:** Use the `platform` attribute in the view to enforce platform-specific objects.
78
+
79
+ ### iOS Application Error: Undefined is Not an Object
80
+
81
+ **Error:** `undefined is not an object (evaluating $.xxx.open) (unknown file)`
82
+
83
+ **Cause:** Top-level UI component has an assigned ID in XML markup.
84
+
85
+ **Solution:** The controller cannot use `$.<controller_name>` to reference it; use the assigned ID instead.
86
+
87
+ ## Getting Help
88
+
89
+ Use the [Titanium Community Questions and Answers Forum](https://developer.axway.com/develop-apps#DevelopApps_Engage):
90
+ - Include 'alloy' as a tag
91
+ - Include the Alloy version (run `alloy --version`)
92
+ - Include platform information
93
+
94
+ ## Submitting a Bug Report
95
+
96
+ Use [GitHub Issues](https://github.com/tidev/alloy/issues):
97
+ - Select 'Alloy' as the component
98
+ - Include Alloy version (`alloy --version`)
99
+ - Include environment information
100
+
101
+ For detailed instructions, see [How to Report a Bug or Make a Feature Request](https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_Guide/Contributing_to_Titanium/How_to_Report_a_Bug_or_Make_a_Feature_Request/).