@maccesar/titools 2.10.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS-VERCEL-RESEARCH.md +23 -12
- package/README.md +81 -182
- package/agents/ti-pro.md +8 -14
- package/lib/cleanup.js +13 -0
- package/lib/commands/skills.js +2 -1
- package/lib/commands/update.js +4 -1
- package/lib/config.js +9 -11
- package/lib/platform.js +1 -1
- package/package.json +2 -3
- package/skills/purgetss/SKILL.md +12 -0
- package/skills/purgetss/references/animation-advanced.md +0 -9
- package/skills/purgetss/references/app-branding.md +20 -0
- package/skills/purgetss/references/appearance-module.md +85 -27
- package/skills/purgetss/references/apply-directive.md +60 -0
- package/skills/purgetss/references/arbitrary-values.md +41 -0
- package/skills/purgetss/references/cli-commands.md +52 -17
- package/skills/purgetss/references/custom-rules.md +36 -19
- package/skills/purgetss/references/customization-deep-dive.md +37 -15
- package/skills/purgetss/references/grid-layout.md +45 -26
- package/skills/purgetss/references/icon-fonts.md +27 -25
- package/skills/purgetss/references/installation-setup.md +28 -2
- package/skills/purgetss/references/ios-large-titles.md +31 -15
- package/skills/purgetss/references/multi-density-images.md +57 -0
- package/skills/purgetss/references/opacity-modifier.md +11 -2
- package/skills/purgetss/references/semantic-colors.md +44 -1
- package/skills/purgetss/references/tikit-components.md +1 -3
- package/skills/alloy-guides/SKILL.md +0 -190
- package/skills/alloy-guides/references/CLI_TASKS.md +0 -233
- package/skills/alloy-guides/references/CONCEPTS.md +0 -171
- package/skills/alloy-guides/references/CONTROLLERS.md +0 -279
- package/skills/alloy-guides/references/MODELS.md +0 -1214
- package/skills/alloy-guides/references/PURGETSS.md +0 -46
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +0 -235
- package/skills/alloy-guides/references/VIEWS_STYLES.md +0 -375
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
- package/skills/alloy-guides/references/VIEWS_XML.md +0 -581
- package/skills/alloy-guides/references/WIDGETS.md +0 -160
- package/skills/alloy-howtos/SKILL.md +0 -181
- package/skills/alloy-howtos/references/best_practices.md +0 -121
- package/skills/alloy-howtos/references/cli_reference.md +0 -230
- package/skills/alloy-howtos/references/config_files.md +0 -158
- package/skills/alloy-howtos/references/custom_tags.md +0 -148
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +0 -78
- package/skills/alloy-howtos/references/samples.md +0 -156
- package/skills/ti-api/SKILL.md +0 -109
- package/skills/ti-api/references/api-android.md +0 -675
- package/skills/ti-api/references/api-app-platform.md +0 -636
- package/skills/ti-api/references/api-core.md +0 -764
- package/skills/ti-api/references/api-data-network.md +0 -641
- package/skills/ti-api/references/api-media.md +0 -655
- package/skills/ti-api/references/api-modules-ble-bluetooth.md +0 -657
- package/skills/ti-api/references/api-modules-coremotion-urlsession.md +0 -411
- package/skills/ti-api/references/api-modules-map.md +0 -632
- package/skills/ti-api/references/api-modules-nfc.md +0 -725
- package/skills/ti-api/references/api-modules-social-misc.md +0 -526
- package/skills/ti-api/references/api-services.md +0 -700
- package/skills/ti-api/references/api-ui-android.md +0 -499
- package/skills/ti-api/references/api-ui-extras.md +0 -702
- package/skills/ti-api/references/api-ui-ios-animator.md +0 -378
- package/skills/ti-api/references/api-ui-ios.md +0 -756
- package/skills/ti-api/references/api-ui-lists.md +0 -581
- package/skills/ti-api/references/api-ui-text-input.md +0 -607
- package/skills/ti-api/references/api-ui-views.md +0 -572
- package/skills/ti-api/references/api-ui-windows-navigation.md +0 -676
- package/skills/ti-api/references/api-xml-global.md +0 -743
- package/skills/ti-guides/SKILL.md +0 -75
- package/skills/ti-guides/references/advanced-data-and-images.md +0 -155
- package/skills/ti-guides/references/android-manifest.md +0 -97
- package/skills/ti-guides/references/app-distribution.md +0 -373
- package/skills/ti-guides/references/application-frameworks.md +0 -366
- package/skills/ti-guides/references/cli-reference.md +0 -700
- package/skills/ti-guides/references/coding-best-practices.md +0 -150
- package/skills/ti-guides/references/commonjs-advanced.md +0 -279
- package/skills/ti-guides/references/hello-world.md +0 -99
- package/skills/ti-guides/references/hyperloop-native-access.md +0 -458
- package/skills/ti-guides/references/javascript-primer.md +0 -402
- package/skills/ti-guides/references/reserved-words.md +0 -36
- package/skills/ti-guides/references/resources.md +0 -172
- package/skills/ti-guides/references/style-and-conventions.md +0 -104
- package/skills/ti-guides/references/tiapp-config.md +0 -655
- package/skills/ti-howtos/SKILL.md +0 -143
- package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -609
- package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
- package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
- package/skills/ti-howtos/references/cross-platform-development.md +0 -358
- package/skills/ti-howtos/references/debugging-profiling.md +0 -473
- package/skills/ti-howtos/references/extending-titanium.md +0 -684
- package/skills/ti-howtos/references/google-maps-v2.md +0 -172
- package/skills/ti-howtos/references/ios-map-kit.md +0 -149
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -595
- package/skills/ti-howtos/references/local-data-sources.md +0 -310
- package/skills/ti-howtos/references/location-and-maps.md +0 -267
- package/skills/ti-howtos/references/media-apis.md +0 -268
- package/skills/ti-howtos/references/notification-services.md +0 -539
- package/skills/ti-howtos/references/remote-data-sources.md +0 -339
- package/skills/ti-howtos/references/tutorials.md +0 -552
- package/skills/ti-howtos/references/using-modules.md +0 -182
- package/skills/ti-howtos/references/web-content-integration.md +0 -288
- package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -125
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# Alloy Widgets
|
|
2
|
-
|
|
3
|
-
## Introduction
|
|
4
|
-
|
|
5
|
-
Widgets are self-contained components that can be easily dropped into Alloy-powered Titanium projects. They were conceived as a way to reuse code in multiple applications or to be used multiple times in the same application. Widgets have their own views, controllers, styles and assets and are laid out the same as the `app` directory in the Alloy project.
|
|
6
|
-
|
|
7
|
-
## Using Widgets
|
|
8
|
-
|
|
9
|
-
See [Importing Widgets](./VIEWS_XML.md#importing-widgets) for more information on using widgets in your project.
|
|
10
|
-
|
|
11
|
-
## Creating Widgets
|
|
12
|
-
|
|
13
|
-
Widgets should be built in their own directory in the Alloy project's `app/widgets/` directory. Widgets have their own views, controllers, models, styles and assets and are laid out the same as the `app` directory in the Alloy project. Also, since widgets are self-contained, they should not reference any code or assets not within its path, except for internationalization and localization files, which are located in the `i18n` folder.
|
|
14
|
-
|
|
15
|
-
## Assets and Libs
|
|
16
|
-
|
|
17
|
-
For any files in the `assets` or `libs` folder, use the `WPATH()` macro to automatically map the path relative from the widget's root folder.
|
|
18
|
-
|
|
19
|
-
For example, if you have a library located at `app/widgets/foo/lib/helper.js`, to require it:
|
|
20
|
-
|
|
21
|
-
```javascript
|
|
22
|
-
require(WPATH('helper'))
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
If you have an image located at `app/widgets/foo/assets/images/foo.png`, to reference it:
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
WPATH('images/foo.png')
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Configuration
|
|
32
|
-
|
|
33
|
-
Widgets have their own configuration file called `widget.json` located in the widget's root directory.
|
|
34
|
-
|
|
35
|
-
Example **widget.json**:
|
|
36
|
-
|
|
37
|
-
```json
|
|
38
|
-
{
|
|
39
|
-
"id": "com.example.widget",
|
|
40
|
-
"name": "My Widget",
|
|
41
|
-
"description": "A sample widget",
|
|
42
|
-
"author": "Your Name",
|
|
43
|
-
"version": "1.0",
|
|
44
|
-
"platform": [
|
|
45
|
-
"android",
|
|
46
|
-
"ios"
|
|
47
|
-
],
|
|
48
|
-
"min_alloy": "1.0"
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Controllers
|
|
53
|
-
|
|
54
|
-
The main controller is called `widget.js` instead of `index.js`.
|
|
55
|
-
|
|
56
|
-
To use another view-controller besides `widget.js`/`widget.xml`, use the `Widget.createController(controller_name, [params])` method to create a new instance and the `getView()` method to access the Titanium proxy object.
|
|
57
|
-
|
|
58
|
-
**app/widgets/foo/controllers/widget.js**
|
|
59
|
-
|
|
60
|
-
```javascript
|
|
61
|
-
const button = Widget.createController('button').getView();
|
|
62
|
-
$.widget.add(button);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
All methods in the widget controller are private unless you prefix the method with `$`, which makes it accessible to the Alloy project and other widgets.
|
|
66
|
-
|
|
67
|
-
**app/widgets/foo/controllers/widget.js**
|
|
68
|
-
|
|
69
|
-
```javascript
|
|
70
|
-
$.init = args => {
|
|
71
|
-
$.button.title = args.title || 'Yes';
|
|
72
|
-
$.button.color = args.color || 'black';
|
|
73
|
-
const message = args.message || 'Hello World';
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Then, in the Alloy project:
|
|
78
|
-
|
|
79
|
-
```javascript
|
|
80
|
-
$.foo.init({title:'Yes', color:'gray', message:'I pity the foo.'});
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Models
|
|
84
|
-
|
|
85
|
-
Use models the same way as with a regular Alloy project except to create a model or collection inside a widget controller, use the `Widget.createModel(model_name, [params])` and `Widget.createCollection(model_name, [params])` methods, respectively.
|
|
86
|
-
|
|
87
|
-
You can also use the `Model` and `Collection` tags in widget views.
|
|
88
|
-
|
|
89
|
-
## Styles
|
|
90
|
-
|
|
91
|
-
The main TSS file is called `widget.tss` instead of `index.tss`.
|
|
92
|
-
|
|
93
|
-
## Themes
|
|
94
|
-
|
|
95
|
-
Widget themes work the same as project themes except for the placement of the files. Inside your theme folder (`app/themes/<THEME_NAME>`), create `widgets/<WIDGET_NAME>` folders, where `<THEME_NAME>` is the name of the theme and `<WIDGET_NAME>` is the name of the widget. When using a theme, the files in these folders replace the files in the widget's folders.
|
|
96
|
-
|
|
97
|
-
Create two folders, `assets` and `styles`, to place your custom images and styles for your widget, respectively.
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
app
|
|
101
|
-
├── themes
|
|
102
|
-
│ └── mytheme
|
|
103
|
-
│ └── widgets
|
|
104
|
-
│ └── mywidget
|
|
105
|
-
│ ├── assets
|
|
106
|
-
│ │ ├── ios
|
|
107
|
-
│ │ │ └── star_half.png
|
|
108
|
-
│ │ ├── star.png
|
|
109
|
-
│ │ └── star_off.png
|
|
110
|
-
│ └── styles
|
|
111
|
-
│ ├── ios
|
|
112
|
-
│ │ └── star.tss
|
|
113
|
-
│ └── star.tss
|
|
114
|
-
└── widgets
|
|
115
|
-
└── mywidget
|
|
116
|
-
├── assets
|
|
117
|
-
│ ├── star.png
|
|
118
|
-
│ ├── star_half.png
|
|
119
|
-
│ └── star_off.png
|
|
120
|
-
├── controllers
|
|
121
|
-
│ ├── star.js
|
|
122
|
-
│ └── widget.js
|
|
123
|
-
├── styles
|
|
124
|
-
│ ├── star.tss
|
|
125
|
-
│ └── widget.tss
|
|
126
|
-
├── views
|
|
127
|
-
│ ├── star.xml
|
|
128
|
-
│ └── widget.xml
|
|
129
|
-
└── widget.json
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
To use a theme, in the project's `config.json` file, add the `theme` key with the name of the theme folder as the value.
|
|
133
|
-
|
|
134
|
-
## Views
|
|
135
|
-
|
|
136
|
-
The main view is called `widget.xml` instead of `index.xml`.
|
|
137
|
-
|
|
138
|
-
Specifying the `id` attribute in the XML markup components will make it easier to access and override Titanium object properties. For example, if you have a Button object in a widget view with id `button` and in the Alloy project the widget id is `foo`:
|
|
139
|
-
|
|
140
|
-
```javascript
|
|
141
|
-
Ti.API.info("button state: " + $.foo.button.enabled);
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
For widgets that have multiple view-controllers, to include a widget's view-controller in another widget's view, use the `Widget` tag and assign the `name` attribute with the name of the view-controller minus the file extension. Since Alloy 1.5.0, if you omit the `src` attribute, Alloy assumes you are referencing the current widget. For Alloy 1.4.x and prior, you need to assign the `src` attribute to the widget's name.
|
|
145
|
-
|
|
146
|
-
**app/widgets/foo/views/widget.xml**
|
|
147
|
-
|
|
148
|
-
```xml
|
|
149
|
-
<Alloy>
|
|
150
|
-
<View>
|
|
151
|
-
<Widget src="foo" name="button"/>
|
|
152
|
-
</View>
|
|
153
|
-
</Alloy>
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## Widgets
|
|
157
|
-
|
|
158
|
-
Widgets can also contain other widgets. Follow the same directions from [Importing Widgets](./VIEWS_XML.md#importing-widgets) except the widget's configuration file is called `widget.json` instead of `config.json`.
|
|
159
|
-
|
|
160
|
-
To create a widget inside a widget controller, use the `Widget.createWidget(widget_name, [controller_name], [params])` method.
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: alloy-howtos
|
|
3
|
-
description: "Titanium Alloy CLI and configuration guide. Use when creating, reviewing, analyzing, or examining Alloy projects, running alloy commands (new, generate, compile), configuring alloy.jmk or config.json, debugging compilation errors, creating conditional views, using Backbone.Events for communication, or writing custom XML tags. AUTO-DETECT: If the project has app/views/ + app/controllers/ structure and the task involves Alloy CLI commands, project configuration, or build issues, invoke this skill first."
|
|
4
|
-
argument-hint: "[task]"
|
|
5
|
-
allowed-tools: Read, Grep, Glob, Edit, Write, Bash(alloy *), Bash(node *)
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Titanium Alloy How-tos
|
|
9
|
-
|
|
10
|
-
Practical guide for Alloy MVC projects in the Titanium SDK.
|
|
11
|
-
|
|
12
|
-
## Project detection
|
|
13
|
-
|
|
14
|
-
> **️ℹ️ Auto-detects Alloy projects**
|
|
15
|
-
> This skill checks for Alloy projects when invoked and provides CLI and configuration guidance.
|
|
16
|
-
>
|
|
17
|
-
> Detection is automatic. No manual command is needed.
|
|
18
|
-
>
|
|
19
|
-
> Alloy project indicators:
|
|
20
|
-
> - `app/` folder with Alloy structure
|
|
21
|
-
> - `alloy.jmk` or `config.json` files
|
|
22
|
-
>
|
|
23
|
-
> Behavior based on detection:
|
|
24
|
-
> - Alloy detected -> Provide Alloy CLI command guidance, configuration file help, Alloy-specific troubleshooting
|
|
25
|
-
> - Not detected -> Explain this skill is for Alloy projects only and suggest Alloy guides if the user wants to migrate
|
|
26
|
-
|
|
27
|
-
## Quick reference
|
|
28
|
-
|
|
29
|
-
| Topic | Reference |
|
|
30
|
-
| -------------------------------------------- | ----------------------------------------------------------------------- |
|
|
31
|
-
| Best Practices & Naming Conventions | [best_practices.md](references/best_practices.md) |
|
|
32
|
-
| CLI Commands (new, generate, compile) | [cli_reference.md](references/cli_reference.md) |
|
|
33
|
-
| Configuration Files (alloy.jmk, config.json) | [config_files.md](references/config_files.md) |
|
|
34
|
-
| Custom XML Tags & Reusable Components | [custom_tags.md](references/custom_tags.md) |
|
|
35
|
-
| Debugging & Common Errors | [debugging_troubleshooting.md](references/debugging_troubleshooting.md) |
|
|
36
|
-
| Code Samples & Conditionals | [samples.md](references/samples.md) |
|
|
37
|
-
|
|
38
|
-
## Key practices
|
|
39
|
-
|
|
40
|
-
### Naming conventions
|
|
41
|
-
- **Never use double underscore prefixes** (`__foo`) - reserved for Alloy
|
|
42
|
-
- **Never use JavaScript reserved words as IDs**
|
|
43
|
-
|
|
44
|
-
### Global events - use Backbone.Events
|
|
45
|
-
Avoid `Ti.App.fireEvent` / `Ti.App.addEventListener`. It can cause memory leaks and poor performance.
|
|
46
|
-
|
|
47
|
-
Use the Backbone.Events pattern:
|
|
48
|
-
```javascript
|
|
49
|
-
// In alloy.js
|
|
50
|
-
Alloy.Events = _.clone(Backbone.Events);
|
|
51
|
-
|
|
52
|
-
// Listener
|
|
53
|
-
Alloy.Events.on('updateMainUI', refreshData);
|
|
54
|
-
// Clean up on close
|
|
55
|
-
$.controller.addEventListener('close', () => {
|
|
56
|
-
Alloy.Events.off('updateMainUI');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Trigger
|
|
60
|
-
Alloy.Events.trigger('updateMainUI');
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Global variables in non-controller files
|
|
64
|
-
Always require Alloy modules:
|
|
65
|
-
```javascript
|
|
66
|
-
const Alloy = require('alloy');
|
|
67
|
-
const Backbone = require('alloy/backbone');
|
|
68
|
-
const _ = require('alloy/underscore')._;
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Conditional views
|
|
72
|
-
|
|
73
|
-
Use `if` attributes in XML for conditional rendering (evaluated before render):
|
|
74
|
-
|
|
75
|
-
```xml
|
|
76
|
-
<Alloy>
|
|
77
|
-
<Window>
|
|
78
|
-
<View if="Alloy.Globals.isLoggedIn()" id="notLoggedIn">
|
|
79
|
-
<Label text="Not logged in" />
|
|
80
|
-
</View>
|
|
81
|
-
<View if="!Alloy.Globals.isLoggedIn()" id="loggedIn">
|
|
82
|
-
<Label text="Logged in" />
|
|
83
|
-
</View>
|
|
84
|
-
</Window>
|
|
85
|
-
</Alloy>
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Conditional TSS styles:
|
|
89
|
-
```tss
|
|
90
|
-
"#info[if=Alloy.Globals.isIos7Plus]": {
|
|
91
|
-
font: { textStyle: Ti.UI.TEXT_STYLE_FOOTNOTE }
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Data-binding conditionals:
|
|
96
|
-
```xml
|
|
97
|
-
<TableViewRow if="$model.shouldShowCommentRow()">
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Common error solutions
|
|
101
|
-
|
|
102
|
-
| Error | Solution |
|
|
103
|
-
| --------------------------------------- | ------------------------------------------------------- |
|
|
104
|
-
| `No app.js found` | Run `alloy compile --config platform=<platform>` |
|
|
105
|
-
| Android assets not showing | Use absolute paths (prepend `/`) |
|
|
106
|
-
| `Alloy is not defined` (non-controller) | Add `const Alloy = require('alloy');` |
|
|
107
|
-
| iOS `invalid method passed to UIModule` | Creating Android-only object - use `platform` attribute |
|
|
108
|
-
|
|
109
|
-
## CLI quick reference
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# New project
|
|
113
|
-
alloy new [path] [template]
|
|
114
|
-
|
|
115
|
-
# Generate components
|
|
116
|
-
alloy generate controller <name>
|
|
117
|
-
alloy generate model <name> <adapter> <schema>
|
|
118
|
-
alloy generate style --all
|
|
119
|
-
|
|
120
|
-
# Compile
|
|
121
|
-
alloy compile [--config platform=android,deploytype=test]
|
|
122
|
-
|
|
123
|
-
# Extract i18n strings
|
|
124
|
-
alloy extract-i18n en --apply
|
|
125
|
-
|
|
126
|
-
# Copy/move/remove controllers
|
|
127
|
-
alloy copy <old> <new>
|
|
128
|
-
alloy move <old> <new>
|
|
129
|
-
alloy remove <name>
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Configuration files priority
|
|
133
|
-
|
|
134
|
-
**config.json precedence:** `os:ios` > `env:production` > `global`
|
|
135
|
-
|
|
136
|
-
Access at runtime: `Alloy.CFG.yourKey`
|
|
137
|
-
|
|
138
|
-
## Custom XML tags
|
|
139
|
-
|
|
140
|
-
Create reusable components without widgets. Drop a file in `app/lib/`:
|
|
141
|
-
|
|
142
|
-
**app/lib/checkbox.js**
|
|
143
|
-
```javascript
|
|
144
|
-
exports.createCheckBox = args => {
|
|
145
|
-
const wrapper = Ti.UI.createView({ layout: "horizontal", checked: false });
|
|
146
|
-
const box = Ti.UI.createView({ width: 15, height: 15, borderWidth: 1 });
|
|
147
|
-
// ... build component, return Ti.UI.* object
|
|
148
|
-
return wrapper;
|
|
149
|
-
};
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
**view.xml**
|
|
153
|
-
```xml
|
|
154
|
-
<CheckBox module="checkbox" id="terms" caption="I agree" onChange="onCheck" />
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Key: the `module` attribute points to the file in `app/lib/` (without `.js`). The function must be `create<TagName>`.
|
|
158
|
-
|
|
159
|
-
See [custom_tags.md](references/custom_tags.md) for complete examples.
|
|
160
|
-
|
|
161
|
-
## Resources
|
|
162
|
-
|
|
163
|
-
### references/
|
|
164
|
-
|
|
165
|
-
Reference docs by topic:
|
|
166
|
-
- **best_practices.md** - Coding standards, naming conventions, global events patterns
|
|
167
|
-
- **cli_reference.md** - All CLI commands with options and model schema format
|
|
168
|
-
- **config_files.md** - alloy.jmk tasks, config.json structure, widget.json format
|
|
169
|
-
- **custom_tags.md** - Creating reusable custom XML tags without widgets
|
|
170
|
-
- **debugging_troubleshooting.md** - Common errors with solutions
|
|
171
|
-
- **samples.md** - Controller examples, conditional views, data-binding patterns
|
|
172
|
-
|
|
173
|
-
## Related skills
|
|
174
|
-
|
|
175
|
-
For tasks beyond Alloy CLI and configuration, use these related skills:
|
|
176
|
-
|
|
177
|
-
| Task | Use This Skill |
|
|
178
|
-
| ---------------------------------------- | -------------- |
|
|
179
|
-
| Modern architecture, services, patterns | `ti-expert` |
|
|
180
|
-
| Alloy MVC concepts, models, data binding | `alloy-guides` |
|
|
181
|
-
| SDK config, Hyperloop, app distribution | `ti-guides` |
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# Alloy best practices and recommendations
|
|
2
|
-
|
|
3
|
-
Recommendations for writing Alloy apps. This supplements the Titanium SDK [Best Practices and Recommendations](https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_Guide/Best_Practices_and_Recommendations/) guide and focuses on coding style and conventions.
|
|
4
|
-
|
|
5
|
-
## Titanium-to-Alloy Guidance
|
|
6
|
-
|
|
7
|
-
### Loading Libraries in Alloy
|
|
8
|
-
|
|
9
|
-
If you need global functionality, require modules in all controllers or create a single global reference:
|
|
10
|
-
|
|
11
|
-
**alloy.js**
|
|
12
|
-
```javascript
|
|
13
|
-
// Alloy.Globals.refToYourModule will be available in all controllers
|
|
14
|
-
Alloy.Globals.refToYourModule = require('yourModule');
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Performance Best Practices
|
|
18
|
-
|
|
19
|
-
The same best practices from traditional Titanium development apply to Alloy. Alloy controllers can do what classic controllers can.
|
|
20
|
-
|
|
21
|
-
Use compiler directives to reduce runtime work (see Conditional Code in Alloy Controllers).
|
|
22
|
-
|
|
23
|
-
### Project Organization
|
|
24
|
-
|
|
25
|
-
Decide whether to adapt Alloy to your existing structure, or to adopt Alloy's structure. Alloy standardizes common Titanium patterns and makes projects easier to maintain.
|
|
26
|
-
|
|
27
|
-
## Coding Style Best Practices
|
|
28
|
-
|
|
29
|
-
### Naming Conventions
|
|
30
|
-
|
|
31
|
-
- **Do not use double underscore prefixes** on variables, properties, or function names (e.g., `__foo`). They are reserved for Alloy and may cause conflicts and unexpected behavior.
|
|
32
|
-
- **Do not use JavaScript reserved words as IDs.** See [Titanium SDK Reserved Words](https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_Guide/Best_Practices_and_Recommendations/Reserved_Words/) for the complete list.
|
|
33
|
-
|
|
34
|
-
### Global Variables
|
|
35
|
-
|
|
36
|
-
Avoid declaring globals in app.js and using them in other files. It still works, but it is not recommended and may be deprecated.
|
|
37
|
-
|
|
38
|
-
Instead, declare these in your JS files:
|
|
39
|
-
|
|
40
|
-
```javascript
|
|
41
|
-
const Alloy = require('alloy');
|
|
42
|
-
const Backbone = require('alloy/backbone');
|
|
43
|
-
const _ = require('alloy/underscore')._;
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Safe pattern for non-controller files:
|
|
47
|
-
|
|
48
|
-
```javascript
|
|
49
|
-
if (typeof Alloy === 'undefined') {
|
|
50
|
-
var Alloy = require('alloy');
|
|
51
|
-
}
|
|
52
|
-
if (typeof Backbone === 'undefined') {
|
|
53
|
-
var Backbone = require('alloy/backbone');
|
|
54
|
-
}
|
|
55
|
-
if (typeof _ === 'undefined') {
|
|
56
|
-
var _ = require('alloy/underscore')._;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const loading = Alloy.createWidget("com.titaniumsdk.loading");
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Global Events
|
|
63
|
-
|
|
64
|
-
**Avoid `Ti.App.fireEvent` and `Ti.App.addEventListener`.** It crosses the native-JS bridge and can cause memory leaks and slower execution.
|
|
65
|
-
|
|
66
|
-
#### Use Callbacks for Master-Child Communication
|
|
67
|
-
|
|
68
|
-
**master.js**
|
|
69
|
-
```javascript
|
|
70
|
-
function openChild() {
|
|
71
|
-
Alloy.createController('child', {callback: refreshData});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function refreshData(value) {
|
|
75
|
-
// Refresh master data here
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**child.js**
|
|
80
|
-
```javascript
|
|
81
|
-
const args = arguments[0] || {};
|
|
82
|
-
|
|
83
|
-
function refreshParent() {
|
|
84
|
-
// Pass return value to parent
|
|
85
|
-
args.callback(true);
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
#### Use Backbone.Events for App-Wide Communication
|
|
90
|
-
|
|
91
|
-
**alloy.js**
|
|
92
|
-
```javascript
|
|
93
|
-
Alloy.Events = _.clone(Backbone.Events);
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**controller_a.js** (listener)
|
|
97
|
-
```javascript
|
|
98
|
-
Alloy.Events.on('updateMainUI', refreshData);
|
|
99
|
-
|
|
100
|
-
function refreshData(value) {
|
|
101
|
-
// Do work here
|
|
102
|
-
// Optionally disable one-time events
|
|
103
|
-
// Alloy.Events.off('updateMainUI');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Clean up when closing to avoid memory leaks
|
|
107
|
-
$.controller_a.addEventListener('close', () => {
|
|
108
|
-
Alloy.Events.off('updateMainUI');
|
|
109
|
-
});
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
**controller_b.js** (trigger)
|
|
113
|
-
```javascript
|
|
114
|
-
Alloy.Events.trigger('updateMainUI');
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
**Note:** Alloy controllers are Backbone event dispatchers. You can also use:
|
|
118
|
-
```javascript
|
|
119
|
-
Alloy.createController('child').on('refresh', refreshData);
|
|
120
|
-
```
|
|
121
|
-
This is a simpler way to do cross-controller communication with Backbone events.
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
# Alloy command-line interface reference
|
|
2
|
-
|
|
3
|
-
The Alloy CLI manages and builds Alloy projects.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
The Alloy CLI is installed when you install the `alloy` package.
|
|
8
|
-
|
|
9
|
-
### Manual Installation
|
|
10
|
-
|
|
11
|
-
Install Node.js from [nodejs.org](http://nodejs.org/#download) first, then:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
sudo npm install -g alloy
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
For a specific version:
|
|
18
|
-
```bash
|
|
19
|
-
sudo npm install -g alloy@1.10.0
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Development install
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
git clone https://github.com/tidev/alloy.git
|
|
26
|
-
cd alloy
|
|
27
|
-
[sudo] npm install -g .
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Commands
|
|
31
|
-
|
|
32
|
-
### new
|
|
33
|
-
|
|
34
|
-
Creates a new Alloy project on top of an existing Titanium project (create the classic Titanium project first, then run this command from inside the project directory).
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
alloy new [<project_path>] [<project_template>] [--force] [--no-colors]
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
| Option | Description |
|
|
41
|
-
| -------------------- | --------------------------------------------------------------------------------- |
|
|
42
|
-
| `<project_path>` | Path to skeleton Titanium project (default: current directory) |
|
|
43
|
-
| `<project_template>` | **default** (single pane) or **two_tabbed** (tabbed app) |
|
|
44
|
-
| `--testapp <path>` | Relative path to a test application in the Alloy GitHub repo (under `test/apps/`) |
|
|
45
|
-
| `-f, --force` | Force execution |
|
|
46
|
-
| `-n, --no-colors` | Disable color output |
|
|
47
|
-
|
|
48
|
-
### generate
|
|
49
|
-
|
|
50
|
-
Creates skeleton Alloy components.
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
alloy generate <component> [--widgetname <widget_name>] [--outputPath <output_path>] [--platform <platform>] [--force] [--no-colors]
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
| Component | Description |
|
|
57
|
-
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
58
|
-
| `controller <name>` | Create controller, view and style |
|
|
59
|
-
| `jmk` | Create `alloy.jmk` |
|
|
60
|
-
| `model <name> <adapter> [schema]` | Create model (see Model Format below) |
|
|
61
|
-
| `migration <model_name>` | Create migration file |
|
|
62
|
-
| `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. |
|
|
63
|
-
| `view <name>` | Create view and style |
|
|
64
|
-
| `widget <name>` | Create widget |
|
|
65
|
-
|
|
66
|
-
| Option | Description |
|
|
67
|
-
| ------------------------- | ------------------------------------------------ |
|
|
68
|
-
| `--widgetname <name>` | Create component for specified widget |
|
|
69
|
-
| `-o, --outputPath <path>` | Output path (point to 'app' directory) |
|
|
70
|
-
| `--platform <platform>` | Create platform-specific component (android/ios) |
|
|
71
|
-
| `-f, --force` | Force execution |
|
|
72
|
-
| `-n, --no-colors` | Disable color output |
|
|
73
|
-
|
|
74
|
-
#### Model format
|
|
75
|
-
|
|
76
|
-
Select adapter type:
|
|
77
|
-
- `sql` - SQLite database for Android/iOS (also generates a migration file)
|
|
78
|
-
- `properties` - Local storage in Titanium SDK context
|
|
79
|
-
|
|
80
|
-
Schema format: space-delimited list of `field:type`
|
|
81
|
-
- Example: `name:string age:number sex:varchar dob:date`
|
|
82
|
-
|
|
83
|
-
SQLite type mapping:
|
|
84
|
-
|
|
85
|
-
| Datatype | SQLite Type |
|
|
86
|
-
| ---------------------------------------- | ----------- |
|
|
87
|
-
| string, varchar, text | TEXT |
|
|
88
|
-
| int, tinyint, smallint, bigint, integer | INTEGER |
|
|
89
|
-
| double, float, real | REAL |
|
|
90
|
-
| blob | BLOB |
|
|
91
|
-
| decimal, number, date, datetime, boolean | NUMERIC |
|
|
92
|
-
| null | NULL |
|
|
93
|
-
| unknown | TEXT |
|
|
94
|
-
|
|
95
|
-
### install
|
|
96
|
-
|
|
97
|
-
Installs special Alloy project components.
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
alloy install <module> [<project_path>]
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
| Module | Description |
|
|
104
|
-
| ---------------- | ----------------------------------------- |
|
|
105
|
-
| `plugin` | Install compiler plugin for Studio |
|
|
106
|
-
| `<project_path>` | Project path (default: current directory) |
|
|
107
|
-
|
|
108
|
-
### compile
|
|
109
|
-
|
|
110
|
-
Compiles Alloy code to Titanium SDK code.
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
alloy compile [<project_path>] [--config <compiler_options>] [--no-colors]
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
| Option | Description |
|
|
117
|
-
| ------------------------ | ------------------------------------------------------------------------- |
|
|
118
|
-
| `<project_path>` | Project path (default: current directory) |
|
|
119
|
-
| `-c, --config <options>` | Comma-delimited compiler options (e.g., `beautify=false,deploytype=test`) |
|
|
120
|
-
| `-n, --no-colors` | Disable color output |
|
|
121
|
-
|
|
122
|
-
Compiler options reference the `event.alloyConfig` object in [Build Configuration File (alloy.jmk)](config_files.md).
|
|
123
|
-
|
|
124
|
-
### run
|
|
125
|
-
|
|
126
|
-
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/).
|
|
127
|
-
|
|
128
|
-
> **💡 Common ti build pitfalls**
|
|
129
|
-
>
|
|
130
|
-
> Using `-C` flag without UDID:
|
|
131
|
-
> ```bash
|
|
132
|
-
> # Prompts for simulator selection interactively
|
|
133
|
-
> ti build -p ios -T simulator -C
|
|
134
|
-
> ```
|
|
135
|
-
>
|
|
136
|
-
> Correct approach for simulator:
|
|
137
|
-
> ```bash
|
|
138
|
-
> # Runs on default simulator
|
|
139
|
-
> ti build -p ios -T simulator
|
|
140
|
-
> ```
|
|
141
|
-
>
|
|
142
|
-
> Using `--no-prompt` incorrectly:
|
|
143
|
-
> ```bash
|
|
144
|
-
> # Still may prompt for device selection if not specific
|
|
145
|
-
> ti build -p ios --no-prompt
|
|
146
|
-
> ```
|
|
147
|
-
>
|
|
148
|
-
> Always specify target:
|
|
149
|
-
> ```bash
|
|
150
|
-
> # Clear target specification
|
|
151
|
-
> ti build -p ios -T simulator --no-prompt
|
|
152
|
-
> ```
|
|
153
|
-
>
|
|
154
|
-
> **Common patterns:**
|
|
155
|
-
> ```bash
|
|
156
|
-
> # iOS Simulator (most common during development)
|
|
157
|
-
> ti build -p ios -T simulator
|
|
158
|
-
>
|
|
159
|
-
> # iOS Device (requires UDID)
|
|
160
|
-
> ti build -p ios -T device -V <udid>
|
|
161
|
-
>
|
|
162
|
-
> # Android Emulator
|
|
163
|
-
> ti build -p android -T emulator
|
|
164
|
-
>
|
|
165
|
-
> # Build only (don't run)
|
|
166
|
-
> ti build -p ios -T simulator --build-only
|
|
167
|
-
> ```
|
|
168
|
-
|
|
169
|
-
### i18n-extract
|
|
170
|
-
|
|
171
|
-
Extracts i18n keys from TSS and JS files to strings.xml.
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
alloy extract-i18n [<language>] [--apply]
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
| Option | Description |
|
|
178
|
-
| ------------ | ------------------------------------------ |
|
|
179
|
-
| `<language>` | Two-letter language code (default: **en**) |
|
|
180
|
-
| `--apply` | Write to strings.xml (preview if absent) |
|
|
181
|
-
|
|
182
|
-
Supported functions:
|
|
183
|
-
- `Ti.Locale.getString()`
|
|
184
|
-
- `L()`
|
|
185
|
-
|
|
186
|
-
Usage examples:
|
|
187
|
-
```bash
|
|
188
|
-
# Preview changes for default (English)
|
|
189
|
-
alloy extract-i18n
|
|
190
|
-
|
|
191
|
-
# Write changes to "app/i18n/en/strings.xml"
|
|
192
|
-
alloy extract-i18n --apply
|
|
193
|
-
|
|
194
|
-
# Specify "es" as the language and write the changes to "app/i18n/es/strings.xml"
|
|
195
|
-
alloy extract-i18n es --apply
|
|
196
|
-
|
|
197
|
-
# Preview Spanish changes
|
|
198
|
-
alloy extract-i18n es
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### copy
|
|
202
|
-
|
|
203
|
-
Copy a view-controller (controller, XML, TSS).
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
alloy copy <CONTROLLER_NAME> <COPIED_CONTROLLER_NAME>
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### move
|
|
210
|
-
|
|
211
|
-
Rename a view-controller.
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
alloy move <CONTROLLER_NAME> <NEW_CONTROLLER_NAME>
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### remove
|
|
218
|
-
|
|
219
|
-
Remove a view-controller.
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
alloy remove <CONTROLLER_NAME>
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
## Additional Options
|
|
226
|
-
|
|
227
|
-
| Option | Description |
|
|
228
|
-
| --------------- | --------------------- |
|
|
229
|
-
| `-h, --help` | Output command usage |
|
|
230
|
-
| `-v, --version` | Output version number |
|