@maccesar/titools 3.3.0 → 4.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.
- package/README.md +27 -61
- package/lib/cleanup.js +29 -0
- package/lib/commands/agents.js +8 -7
- package/lib/commands/skills.js +118 -23
- package/lib/config.js +13 -15
- package/lib/installer.js +5 -3
- package/lib/utils.js +36 -0
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +188 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +233 -0
- package/skills/alloy-guides/references/CONCEPTS.md +171 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +279 -0
- package/skills/alloy-guides/references/MODELS.md +742 -0
- package/skills/alloy-guides/references/MODELS_ADVANCED.md +482 -0
- package/skills/alloy-guides/references/PURGETSS.md +57 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +235 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +375 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +102 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +581 -0
- package/skills/alloy-guides/references/WIDGETS.md +160 -0
- package/skills/alloy-howtos/SKILL.md +179 -0
- package/skills/alloy-howtos/references/best_practices.md +121 -0
- package/skills/alloy-howtos/references/cli_reference.md +230 -0
- package/skills/alloy-howtos/references/config_files.md +158 -0
- package/skills/alloy-howtos/references/custom_tags.md +148 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +78 -0
- package/skills/alloy-howtos/references/samples.md +156 -0
- package/skills/purgetss/SKILL.md +6 -3
- package/skills/purgetss/references/EXAMPLES.md +8 -6
- package/skills/purgetss/references/app-branding.md +5 -0
- package/skills/purgetss/references/apply-directive.md +1 -1
- package/skills/purgetss/references/class-categories.md +1 -1
- package/skills/purgetss/references/class-index-properties.md +618 -0
- package/skills/purgetss/references/class-index.md +4 -610
- package/skills/purgetss/references/cli-commands.md +15 -0
- package/skills/purgetss/references/custom-fonts.md +39 -36
- package/skills/purgetss/references/custom-rules.md +1 -1
- package/skills/purgetss/references/customization-deep-dive.md +64 -1
- package/skills/purgetss/references/icon-fonts.md +2 -0
- package/skills/purgetss/references/migration-guide.md +53 -1
- package/skills/purgetss/references/multi-density-images.md +53 -2
- package/skills/purgetss/references/svg-pipeline.md +249 -0
- package/skills/purgetss/references/tikit-components.md +2 -2
- package/skills/purgetss/references/titanium-resets.md +2 -2
- package/skills/purgetss/references/ui-ux-design.md +7 -5
- package/skills/purgetss/references/version-history.md +12 -0
- package/skills/ti-api/SKILL.md +128 -0
- package/skills/ti-api/references/api-android.md +675 -0
- package/skills/ti-api/references/api-app-platform.md +636 -0
- package/skills/ti-api/references/api-core.md +764 -0
- package/skills/ti-api/references/api-data-network.md +641 -0
- package/skills/ti-api/references/api-media.md +655 -0
- package/skills/ti-api/references/api-modules-ble-bluetooth.md +657 -0
- package/skills/ti-api/references/api-modules-coremotion-urlsession.md +411 -0
- package/skills/ti-api/references/api-modules-map.md +632 -0
- package/skills/ti-api/references/api-modules-nfc.md +725 -0
- package/skills/ti-api/references/api-modules-social-misc.md +526 -0
- package/skills/ti-api/references/api-services.md +700 -0
- package/skills/ti-api/references/api-ui-android.md +499 -0
- package/skills/ti-api/references/api-ui-extras.md +702 -0
- package/skills/ti-api/references/api-ui-ios-animator.md +378 -0
- package/skills/ti-api/references/api-ui-ios.md +756 -0
- package/skills/ti-api/references/api-ui-lists.md +581 -0
- package/skills/ti-api/references/api-ui-text-input.md +607 -0
- package/skills/ti-api/references/api-ui-views.md +572 -0
- package/skills/ti-api/references/api-ui-windows-navigation.md +676 -0
- package/skills/ti-api/references/api-xml-global.md +743 -0
- package/skills/ti-guides/SKILL.md +82 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +155 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +373 -0
- package/skills/ti-guides/references/application-frameworks.md +366 -0
- package/skills/ti-guides/references/cli-reference.md +700 -0
- package/skills/ti-guides/references/coding-best-practices.md +150 -0
- package/skills/ti-guides/references/commonjs-advanced.md +279 -0
- package/skills/ti-guides/references/hello-world.md +99 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +458 -0
- package/skills/ti-guides/references/javascript-primer.md +402 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +172 -0
- package/skills/ti-guides/references/style-and-conventions.md +104 -0
- package/skills/ti-guides/references/tiapp-config.md +655 -0
- package/skills/ti-howtos/SKILL.md +131 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +609 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +96 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +162 -0
- package/skills/ti-howtos/references/cross-platform-development.md +358 -0
- package/skills/ti-howtos/references/debugging-profiling.md +473 -0
- package/skills/ti-howtos/references/extending-titanium.md +684 -0
- package/skills/ti-howtos/references/google-maps-v2.md +172 -0
- package/skills/ti-howtos/references/ios-map-kit.md +149 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +595 -0
- package/skills/ti-howtos/references/local-data-sources.md +310 -0
- package/skills/ti-howtos/references/location-and-maps.md +267 -0
- package/skills/ti-howtos/references/media-apis.md +268 -0
- package/skills/ti-howtos/references/notification-services.md +539 -0
- package/skills/ti-howtos/references/remote-data-sources.md +339 -0
- package/skills/ti-howtos/references/tutorials.md +552 -0
- package/skills/ti-howtos/references/using-modules.md +182 -0
- package/skills/ti-howtos/references/web-content-integration.md +288 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +125 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Alloy configuration files reference
|
|
2
|
+
|
|
3
|
+
## Build configuration file (alloy.jmk)
|
|
4
|
+
|
|
5
|
+
Alloy exposes hooks to customize compilation with a JS Makefile (JMK).
|
|
6
|
+
|
|
7
|
+
**Location:** `app/alloy.jmk`
|
|
8
|
+
|
|
9
|
+
**Example:**
|
|
10
|
+
```javascript
|
|
11
|
+
task('pre:compile', (event, logger) => {
|
|
12
|
+
logger.showTimestamp = true;
|
|
13
|
+
logger.info(`building project at ${event.dir.project}`);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
task('post:compile', (event, logger) => {
|
|
17
|
+
logger.info('compile finished!');
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Compiler tasks (event names)
|
|
22
|
+
|
|
23
|
+
| Task | When Called |
|
|
24
|
+
| ---------------- | --------------------------------------------------------- |
|
|
25
|
+
| `pre:load` | After project clean, before copying assets to `Resources` |
|
|
26
|
+
| `pre:compile` | Before compiler starts |
|
|
27
|
+
| `post:compile` | After compiler finishes, before exit |
|
|
28
|
+
| `compile:app.js` | After compiling `app.js`, before writing to disk |
|
|
29
|
+
|
|
30
|
+
### Event object
|
|
31
|
+
|
|
32
|
+
| Property | Type | Description |
|
|
33
|
+
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| `adapters` | Array | List of adapters |
|
|
35
|
+
| `alloyConfig` | Object | Compiler config: `platform` (android/ios), `file` (selective compile), `deploytype` (development/test/production), `beautify` (Boolean) |
|
|
36
|
+
| `autoStyle` | Boolean | Autostyle enabled for project |
|
|
37
|
+
| `dependencies` | Object | Value of `dependencies` key in config.json |
|
|
38
|
+
| `dir` | Object | Directory paths: `home` (app path), `project` (root path), `resources`, `resourcesAlloy`, `assets`, `config`, `controllers`, `migrations`, `models`, `styles`, `themes`, `views`, `widgets`, `builtins`, `template` |
|
|
39
|
+
| `sourcemap` | Boolean | If `true`, generates mapping files to link generated Titanium files in `Resources` back to the source files in `app` for debugging. |
|
|
40
|
+
| `theme` | String | Theme name being used |
|
|
41
|
+
| `code` | String | *(compile:app.js only)* Contents of `app.js` |
|
|
42
|
+
| `appJSFile` | String | *(compile:app.js only)* Absolute path to `app.js` |
|
|
43
|
+
|
|
44
|
+
### Logger object
|
|
45
|
+
|
|
46
|
+
The `logger` object controls compilation log output.
|
|
47
|
+
|
|
48
|
+
#### Properties
|
|
49
|
+
|
|
50
|
+
| Property | Type | Description |
|
|
51
|
+
| --------------- | ------- | ----------------------------------------------- |
|
|
52
|
+
| `DEBUG` | Number | READONLY. Output all log messages. |
|
|
53
|
+
| `INFO` | Number | READONLY. Output all except debug messages. |
|
|
54
|
+
| `WARN` | Number | READONLY. Output only warning and error. |
|
|
55
|
+
| `ERROR` | Number | READONLY. Output only error messages. |
|
|
56
|
+
| `NONE` | Number | READONLY. Disable log messages. |
|
|
57
|
+
| `logLevel` | Number | Sets which log messages to output. |
|
|
58
|
+
| `showTimestamp` | Boolean | If `true`, outputs timestamp with log messages. |
|
|
59
|
+
| `stripColors` | Boolean | If `true`, suppresses color output. |
|
|
60
|
+
|
|
61
|
+
#### Methods
|
|
62
|
+
|
|
63
|
+
| Method | Description |
|
|
64
|
+
| -------------------- | ------------------------------ |
|
|
65
|
+
| `debug(msg: String)` | Outputs a debug log message. |
|
|
66
|
+
| `info(msg: String)` | Outputs an info log message. |
|
|
67
|
+
| `warn(msg: String)` | Outputs a warning log message. |
|
|
68
|
+
| `error(msg: String)` | Outputs an error log message. |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Global initializer (alloy.js)
|
|
73
|
+
|
|
74
|
+
**Location:** `app/alloy.js`
|
|
75
|
+
|
|
76
|
+
Runs before any controllers load. Use it to set up globals and singletons.
|
|
77
|
+
|
|
78
|
+
Common uses:
|
|
79
|
+
- Creating `Alloy.Collections` (e.g., `Alloy.Collections.myModel = Alloy.createCollection('myModel');`)
|
|
80
|
+
- Setting up `Alloy.Globals` (shared references, utility functions)
|
|
81
|
+
- Initializing singletons (analytics, logging, network managers)
|
|
82
|
+
- Configuring global event listeners
|
|
83
|
+
|
|
84
|
+
**Example:**
|
|
85
|
+
```javascript
|
|
86
|
+
// app/alloy.js
|
|
87
|
+
Alloy.Globals.loading = Alloy.createWidget('com.example.loading');
|
|
88
|
+
Alloy.Collections.users = Alloy.createCollection('user');
|
|
89
|
+
|
|
90
|
+
// Global utility
|
|
91
|
+
Alloy.Globals.alert = (title, message) => {
|
|
92
|
+
Ti.UI.createAlertDialog({ title, message }).show();
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Project configuration file (config.json)
|
|
99
|
+
|
|
100
|
+
**Location:** `app/config.json`
|
|
101
|
+
|
|
102
|
+
Alloy uses `config.json` for global values, environment and platform overrides, and widget dependencies.
|
|
103
|
+
### Objects
|
|
104
|
+
|
|
105
|
+
| Object | Description |
|
|
106
|
+
| ----------------- | ----------------------------------------------------------- |
|
|
107
|
+
| `global` | Key-value pairs for all environments and platforms |
|
|
108
|
+
| `env:development` | Development builds (simulator/emulator) |
|
|
109
|
+
| `env:test` | Test builds on device |
|
|
110
|
+
| `env:production` | Production builds (after package installation) |
|
|
111
|
+
| `os:android` | Android-specific values |
|
|
112
|
+
| `os:ios` | iOS-specific values |
|
|
113
|
+
| `dependencies` | Widget dependencies (name: version) |
|
|
114
|
+
| `autoStyle` | Enable autostyle for entire project |
|
|
115
|
+
| `backbone` | Backbone.js version: `0.9.2` (default), `1.1.2`, or `1.3.3` |
|
|
116
|
+
|
|
117
|
+
**Precedence:** `os` > `env` > `global`. Combinations (for example, `os:ios env:production`) override single values.
|
|
118
|
+
|
|
119
|
+
**Runtime access:** Values are available at runtime via `Alloy.CFG.<key>`.
|
|
120
|
+
|
|
121
|
+
**Example:**
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"global": { "foo": 1 },
|
|
126
|
+
"env:development": { "foo": 2 },
|
|
127
|
+
"env:test": { "foo": 3 },
|
|
128
|
+
"env:production": { "foo": 4 },
|
|
129
|
+
"os:ios env:production": { "foo": 5 },
|
|
130
|
+
"os:ios env:development": { "foo": 6 },
|
|
131
|
+
"os:ios env:test": { "foo": 7 },
|
|
132
|
+
"os:android": { "foo": 8 },
|
|
133
|
+
"dependencies": {
|
|
134
|
+
"com.foo.widget": "1.0"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Accessing values: `Ti.API.info(Alloy.CFG.foo)` on iPhone simulator returns `6`.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Widget configuration file (widget.json)
|
|
144
|
+
|
|
145
|
+
**Location:** Root directory of the widget. Follows the npm `package.json` format with a few exceptions.
|
|
146
|
+
### Keys
|
|
147
|
+
|
|
148
|
+
| Key | Type | Required | Description |
|
|
149
|
+
| ---------------------- | ------ | -------- | ------------------------------------- |
|
|
150
|
+
| `id` | String | Yes | Must match widget root folder name |
|
|
151
|
+
| `copyright` | String | No | Copyright information |
|
|
152
|
+
| `license` | String | No | License information |
|
|
153
|
+
| `min-alloy-version` | Float | No* | Minimum Alloy version required |
|
|
154
|
+
| `min-titanium-version` | Float | No* | Minimum Titanium version required |
|
|
155
|
+
| `tags` | String | No | Comma-delimited keywords |
|
|
156
|
+
| `platforms` | String | No* | Supported platforms (comma-delimited) |
|
|
157
|
+
|
|
158
|
+
(*) 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,148 @@
|
|
|
1
|
+
# Creating custom tags in Titanium with Alloy
|
|
2
|
+
|
|
3
|
+
Custom tags let you create reusable UI components without the overhead of widgets. You can keep controls in a single file under `app/lib`.
|
|
4
|
+
|
|
5
|
+
## Why use custom tags?
|
|
6
|
+
|
|
7
|
+
When building cross-platform apps, you often need UI controls (like a web-style checkbox) that do not exist natively. You have three approaches:
|
|
8
|
+
|
|
9
|
+
1. **Direct XML/JS:** Copy and paste code into each view. Not reusable and easy to drift.
|
|
10
|
+
2. **Widgets:** Reusable, but require a folder structure and `dependencies` in `config.json`.
|
|
11
|
+
3. **Custom tags:** Single file in `app/lib/`, no config dependency, easy to share. They reduce platform-specific code in views.
|
|
12
|
+
|
|
13
|
+
## Basic setup
|
|
14
|
+
|
|
15
|
+
1. Create a file in `app/lib/` (e.g., `checkbox.js`)
|
|
16
|
+
2. Export a `create<TagName>` function
|
|
17
|
+
3. Use in XML with the `module` attribute
|
|
18
|
+
|
|
19
|
+
**view.xml**
|
|
20
|
+
```xml
|
|
21
|
+
<CheckBox module="checkbox" id="termsAccepted"
|
|
22
|
+
caption="I agree to the terms of use"
|
|
23
|
+
underline="true"
|
|
24
|
+
onCaptionClick="doShowTerms"
|
|
25
|
+
onChange="onCheckChange" />
|
|
26
|
+
```
|
|
27
|
+
The `module` attribute tells Alloy to look in `checkbox.js` for a `createCheckBox` function. Alloy passes the XML/TSS arguments and expects a `Ti.UI.*` component back.
|
|
28
|
+
|
|
29
|
+
## Robust example: CheckBox
|
|
30
|
+
|
|
31
|
+
**app/lib/checkbox.js**
|
|
32
|
+
```javascript
|
|
33
|
+
exports.createCheckBox = args => {
|
|
34
|
+
// Wrapper view for all components
|
|
35
|
+
const wrapper = Ti.UI.createView({
|
|
36
|
+
top: args.top || 5,
|
|
37
|
+
width: Ti.UI.SIZE,
|
|
38
|
+
height: Ti.UI.SIZE,
|
|
39
|
+
layout: "horizontal",
|
|
40
|
+
left: args.left || 20,
|
|
41
|
+
right: args.right || null,
|
|
42
|
+
checked: args.checked || false
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// The box itself
|
|
46
|
+
const box = Ti.UI.createView({
|
|
47
|
+
width: 15,
|
|
48
|
+
height: 15,
|
|
49
|
+
borderWidth: 1,
|
|
50
|
+
borderColor: "#02A9F4"
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Attributed string for styled caption (e.g. underline)
|
|
54
|
+
const attr = Ti.UI.createAttributedString({
|
|
55
|
+
text: args.caption
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (args.underline) {
|
|
59
|
+
attr.applyProperties({
|
|
60
|
+
attributes: [{
|
|
61
|
+
type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,
|
|
62
|
+
value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
|
|
63
|
+
range: [0, args.caption.length]
|
|
64
|
+
}]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const caption = Ti.UI.createLabel({
|
|
69
|
+
color: "#000",
|
|
70
|
+
attributedString: attr,
|
|
71
|
+
left: 10,
|
|
72
|
+
text: args.caption,
|
|
73
|
+
font: { fontSize: 10 }
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// The tick (using Unicode to avoid assets)
|
|
77
|
+
const tick = Ti.UI.createLabel({
|
|
78
|
+
text: "\u2713",
|
|
79
|
+
left: 1,
|
|
80
|
+
color: "#02A9F4",
|
|
81
|
+
font: { fontWeight: "bold" },
|
|
82
|
+
visible: args.checked || false
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Handle clicks
|
|
86
|
+
caption.addEventListener("click", () => {
|
|
87
|
+
wrapper.fireEvent("captionClick");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
box.addEventListener("click", () => {
|
|
91
|
+
tick.visible = !tick.visible;
|
|
92
|
+
wrapper.checked = !wrapper.checked;
|
|
93
|
+
wrapper.fireEvent("change", { checked: wrapper.checked });
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
box.add(tick);
|
|
97
|
+
wrapper.add(box);
|
|
98
|
+
wrapper.add(caption);
|
|
99
|
+
|
|
100
|
+
return wrapper;
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Global module override
|
|
105
|
+
|
|
106
|
+
Apply a module to all tags in a view by updating the `Alloy` tag. Alloy checks your file for tag creation overrides before using default implementations:
|
|
107
|
+
|
|
108
|
+
```xml
|
|
109
|
+
<Alloy module="ui">
|
|
110
|
+
<Window>
|
|
111
|
+
<CustomButton /> <!-- Looks for createCustomButton in app/lib/ui.js -->
|
|
112
|
+
<Label /> <!-- Checks ui.js for createLabel first -->
|
|
113
|
+
</Window>
|
|
114
|
+
</Alloy>
|
|
115
|
+
```
|
|
116
|
+
This is useful for adding default colors or properties (for example, a black default color for Android Labels) across a project.
|
|
117
|
+
|
|
118
|
+
## Key points
|
|
119
|
+
|
|
120
|
+
| Aspect | Description |
|
|
121
|
+
| ------------- | ------------------------------------------------------------- |
|
|
122
|
+
| File location | `app/lib/<module_name>.js` |
|
|
123
|
+
| Function name | `create<TagName>` (e.g., `createCheckBox` for `<CheckBox>`) |
|
|
124
|
+
| Return value | Must return a `Ti.UI.*` component (View, Button, Label, etc.) |
|
|
125
|
+
| Arguments | Receives all XML/TSS attributes in a single `args` object |
|
|
126
|
+
|
|
127
|
+
## Using Custom Tags Without Alloy XML
|
|
128
|
+
|
|
129
|
+
You can also use custom tags from plain JavaScript via `require()`:
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
const checkbox = require("checkbox").createCheckBox({
|
|
133
|
+
caption: "I agree",
|
|
134
|
+
underline: true
|
|
135
|
+
});
|
|
136
|
+
win.add(checkbox);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
This works because custom tags are standard CommonJS modules. The `module` attribute in XML is a convenience.
|
|
140
|
+
|
|
141
|
+
## Custom tags vs widgets
|
|
142
|
+
|
|
143
|
+
| Custom Tags | Widgets |
|
|
144
|
+
| ------------------------------------- | ---------------------------------------- |
|
|
145
|
+
| Single file in `app/lib/` | Separate folder structure |
|
|
146
|
+
| No `config.json` dependency needed | Requires `dependencies` in `config.json` |
|
|
147
|
+
| Simpler for single-component controls | Better for complex multi-view components |
|
|
148
|
+
| Easier to share across projects | More formal packaging |
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Alloy debugging and troubleshooting
|
|
2
|
+
|
|
3
|
+
## Debugging
|
|
4
|
+
|
|
5
|
+
### Compiler error messages
|
|
6
|
+
|
|
7
|
+
The Alloy compiler reports syntax errors in JavaScript, JSON, TSS, and XML. Error messages include:
|
|
8
|
+
- File path
|
|
9
|
+
- Line and character position
|
|
10
|
+
- Description of the error
|
|
11
|
+
|
|
12
|
+
## Troubleshooting
|
|
13
|
+
|
|
14
|
+
### Error: No app.js found
|
|
15
|
+
|
|
16
|
+
**Error:** `[ERROR] No app.js found. Ensure the app.js file exists in your project's Resources directory.`
|
|
17
|
+
|
|
18
|
+
**Solution:** If part of the contents of your `Resources` folder were deleted, run:
|
|
19
|
+
```bash
|
|
20
|
+
alloy compile --config platform=<platform>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Android: images, HTML, and assets not displaying
|
|
24
|
+
|
|
25
|
+
**Problem:** Assets display on iOS and Mobile Web but not Android.
|
|
26
|
+
|
|
27
|
+
**Solution:** Android requires absolute paths. Precede asset paths with a slash ('/'). iOS and Mobile Web accept both relative and absolute paths.
|
|
28
|
+
|
|
29
|
+
### Android runtime error: cannot call method of undefined
|
|
30
|
+
|
|
31
|
+
**Error:** `Uncaught TypeError: Cannot call method xxx of undefined`
|
|
32
|
+
|
|
33
|
+
**Causes:**
|
|
34
|
+
1. Creating an iOS-only Titanium object. Use the `platform` attribute in views to enforce platform-specific objects.
|
|
35
|
+
2. Top-level UI component has an assigned ID. The controller cannot use `$.<controller_name>` to reference it; use the assigned ID instead.
|
|
36
|
+
|
|
37
|
+
### Android runtime error: Alloy is not defined
|
|
38
|
+
|
|
39
|
+
**Error:** `Uncaught ReferenceError: Alloy is not defined`
|
|
40
|
+
|
|
41
|
+
**Cause:** Non-controller JavaScript files are not automatically wrapped by Alloy. See [best_practices.md](best_practices.md) for the safe require pattern for non-controller files.
|
|
42
|
+
|
|
43
|
+
**Solution:** Require the 'alloy' module:
|
|
44
|
+
```javascript
|
|
45
|
+
const Alloy = require('alloy');
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### iOS application error: invalid method passed to UIModule
|
|
49
|
+
|
|
50
|
+
**Error:** `invalid method (xxx) passed to UIModule (unknown file)`
|
|
51
|
+
|
|
52
|
+
**Cause:** Trying to create an Android-only Titanium object.
|
|
53
|
+
|
|
54
|
+
**Solution:** Use the `platform` attribute in the view to enforce platform-specific objects.
|
|
55
|
+
|
|
56
|
+
### iOS application error: undefined is not an object
|
|
57
|
+
|
|
58
|
+
**Error:** `undefined is not an object (evaluating $.xxx.open) (unknown file)`
|
|
59
|
+
|
|
60
|
+
**Cause:** Top-level UI component has an assigned ID in XML markup.
|
|
61
|
+
|
|
62
|
+
**Solution:** The controller cannot use `$.<controller_name>` to reference it; use the assigned ID instead.
|
|
63
|
+
|
|
64
|
+
## Getting help
|
|
65
|
+
|
|
66
|
+
Use the [TiDev Community Slack](https://slack.tidev.io/) or [GitHub Discussions](https://github.com/tidev/titanium-sdk/discussions):
|
|
67
|
+
- Include 'alloy' as a tag
|
|
68
|
+
- Include the Alloy version (run `alloy --version`)
|
|
69
|
+
- Include platform information
|
|
70
|
+
|
|
71
|
+
## Submitting a bug report
|
|
72
|
+
|
|
73
|
+
Search [existing issues](https://github.com/tidev/alloy/issues) first to avoid duplicates. If none match, create a new issue:
|
|
74
|
+
- Select 'Alloy' as the component
|
|
75
|
+
- Include Alloy version (`alloy --version`)
|
|
76
|
+
- Include environment information
|
|
77
|
+
|
|
78
|
+
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/).
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Alloy samples
|
|
2
|
+
|
|
3
|
+
## Kitchen sink
|
|
4
|
+
|
|
5
|
+
See the [KitchenSink-v2 application on GitHub](https://github.com/tidev/kitchensink-v2) for Alloy samples in a full app.
|
|
6
|
+
|
|
7
|
+
## Controller sample
|
|
8
|
+
|
|
9
|
+
**index.js**
|
|
10
|
+
```javascript
|
|
11
|
+
// These "builtin" requires are detected by alloy compile process
|
|
12
|
+
// Automatically included as Resources/alloy/animation.js and Resources/alloy/string.js
|
|
13
|
+
const animation = require('alloy/animation');
|
|
14
|
+
const string = require('alloy/string');
|
|
15
|
+
|
|
16
|
+
function shake(e) {
|
|
17
|
+
animation.shake($.mover, 0, () => {
|
|
18
|
+
alert("Shake ended.");
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function flash(e) {
|
|
23
|
+
animation.flash($.mover);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function trim(e) {
|
|
27
|
+
$.label.text = string.trim($.label.text);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (OS_IOS) {
|
|
31
|
+
function flip(e) {
|
|
32
|
+
let front, back;
|
|
33
|
+
e.bubbleParent = false;
|
|
34
|
+
if (e.source === $.back) {
|
|
35
|
+
front = $.back;
|
|
36
|
+
back = $.front;
|
|
37
|
+
} else {
|
|
38
|
+
front = $.front;
|
|
39
|
+
back = $.back;
|
|
40
|
+
}
|
|
41
|
+
animation.flipHorizontal(front, back, 500, (e) => {
|
|
42
|
+
Ti.API.info('flipped');
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
$.index.open();
|
|
48
|
+
|
|
49
|
+
// Runtime unit tests
|
|
50
|
+
if (!ENV_PROD) {
|
|
51
|
+
require('specs/index')($);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Conditional statements in views
|
|
56
|
+
|
|
57
|
+
Alloy separates business logic (controllers) from UI definition (XML/TSS). A common challenge is showing or hiding content based on app state (for example, login status).
|
|
58
|
+
|
|
59
|
+
> **💡 TSS defaults**
|
|
60
|
+
> The samples below assume some additional TSS: views and windows use a vertical layout, and the `View` tag has a default height and width of `Ti.UI.SIZE`.
|
|
61
|
+
|
|
62
|
+
### Problems with traditional approaches
|
|
63
|
+
|
|
64
|
+
**Approach 1: show/hide (in controller)**
|
|
65
|
+
```javascript
|
|
66
|
+
if (Alloy.Globals.isLoggedIn()) {
|
|
67
|
+
$.loggedIn.show();
|
|
68
|
+
$.notLoggedIn.hide();
|
|
69
|
+
} else {
|
|
70
|
+
$.loggedIn.hide();
|
|
71
|
+
$.notLoggedIn.show();
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
**Problem:** Both views render when the window opens. If the user isn't logged in, there is empty space where the logged-in view was.
|
|
75
|
+
|
|
76
|
+
**Approach 2: setHeight (in controller)**
|
|
77
|
+
```javascript
|
|
78
|
+
if (Alloy.Globals.isLoggedIn()) {
|
|
79
|
+
$.loggedIn.setHeight(Ti.UI.SIZE);
|
|
80
|
+
$.notLoggedIn.setHeight(0);
|
|
81
|
+
} else {
|
|
82
|
+
$.loggedIn.setHeight(0);
|
|
83
|
+
$.notLoggedIn.setHeight(Ti.UI.SIZE);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
**Problem:** This works, but it forces you to manage height values (`Ti.UI.SIZE`) in JavaScript instead of TSS.
|
|
87
|
+
|
|
88
|
+
### Solution: IF attributes in XML
|
|
89
|
+
|
|
90
|
+
Use `if` attributes directly in the XML view. These conditions are evaluated before rendering.
|
|
91
|
+
|
|
92
|
+
**index.xml**
|
|
93
|
+
```xml
|
|
94
|
+
<Alloy>
|
|
95
|
+
<Window>
|
|
96
|
+
<View>
|
|
97
|
+
<!-- Only one of these will ever be rendered -->
|
|
98
|
+
<View if="Alloy.Globals.isLoggedIn()" id="notLoggedIn" class="vertical">
|
|
99
|
+
<Label text="Not logged in" />
|
|
100
|
+
</View>
|
|
101
|
+
<View if="!Alloy.Globals.isLoggedIn()" id="loggedIn" class="vertical">
|
|
102
|
+
<Label text="Logged in" />
|
|
103
|
+
</View>
|
|
104
|
+
</View>
|
|
105
|
+
</Window>
|
|
106
|
+
</Alloy>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Benefits:
|
|
110
|
+
- Only the view that matches the condition is rendered.
|
|
111
|
+
- The UI is correct from the first frame.
|
|
112
|
+
- No visibility logic in controllers.
|
|
113
|
+
|
|
114
|
+
### Conditional queries in TSS
|
|
115
|
+
|
|
116
|
+
Use `if` attributes in TSS definitions:
|
|
117
|
+
|
|
118
|
+
```tss
|
|
119
|
+
"#info[if=Alloy.Globals.isIos7Plus]": {
|
|
120
|
+
font: {
|
|
121
|
+
textStyle: Ti.UI.TEXT_STYLE_FOOTNOTE
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"#title[if=Alloy.Globals.isIos7Plus]": {
|
|
125
|
+
top: "25dp",
|
|
126
|
+
font: {
|
|
127
|
+
textStyle: Ti.UI.TEXT_STYLE_HEADLINE
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"#content[if=Alloy.Globals.isIos7Plus]": {
|
|
131
|
+
font: {
|
|
132
|
+
textStyle: Ti.UI.TEXT_STYLE_CAPTION1
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"ScrollView[if=Alloy.Globals.iPhoneTall]": {
|
|
136
|
+
height: "500dp"
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Data-binding with conditional queries
|
|
141
|
+
|
|
142
|
+
Define custom methods in models and render based on those methods:
|
|
143
|
+
|
|
144
|
+
**Model Method:** `shouldShowCommentRow()` returns `true`
|
|
145
|
+
|
|
146
|
+
**XML View:**
|
|
147
|
+
```xml
|
|
148
|
+
<Alloy>
|
|
149
|
+
<TableViewRow id="commentRow" hasChild="false" if="$model.shouldShowCommentRow()" onClick="onSelectComment">
|
|
150
|
+
<Label id="commentPlaceholderLabel" class="commentRowPreviewLabel placeholderLabel" text="Ti.App.L('AddComment')" />
|
|
151
|
+
<Label id="commentRowLabel" class="commentRowPreviewLabel" text="{Comment}" />
|
|
152
|
+
</TableViewRow>
|
|
153
|
+
</Alloy>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
See `VIEWS_STYLES.md` in the `alloy-guides` skill (Custom Query Styles section) for more details.
|
package/skills/purgetss/SKILL.md
CHANGED
|
@@ -22,6 +22,7 @@ SKILL.md is not enough.**
|
|
|
22
22
|
| Choosing utility classes | [references/class-index.md](references/class-index.md) |
|
|
23
23
|
| Layout (horizontal/vertical/composite, grid) | [references/grid-layout.md](references/grid-layout.md), [references/ui-ux-design.md](references/ui-ux-design.md) |
|
|
24
24
|
| Dynamic components in controllers | [references/dynamic-component-creation.md](references/dynamic-component-creation.md) |
|
|
25
|
+
| SVG / multi-density image assets | [references/svg-pipeline.md](references/svg-pipeline.md), [references/multi-density-images.md](references/multi-density-images.md) |
|
|
25
26
|
| Custom values / arbitrary syntax | [references/arbitrary-values.md](references/arbitrary-values.md) |
|
|
26
27
|
| Platform-specific styles (`ios:`, `android:`) | [references/platform-modifiers.md](references/platform-modifiers.md) |
|
|
27
28
|
| Dark/Light mode | [references/semantic-colors.md](references/semantic-colors.md), [references/appearance-module.md](references/appearance-module.md) |
|
|
@@ -357,7 +358,7 @@ Always verify a class exists before suggesting it.
|
|
|
357
358
|
### Verification Steps
|
|
358
359
|
|
|
359
360
|
1. **Check if it's a KNOWN anti-pattern**
|
|
360
|
-
- See [PROHIBITED Classes](references/class-index.md#prohibited-
|
|
361
|
+
- See [PROHIBITED Classes](references/class-index.md#prohibited-css-classes-do-not-exist)
|
|
361
362
|
- Common mistakes: `flex-row`, `justify-between`, `p-4` on Views (p-* not supported on Views)
|
|
362
363
|
|
|
363
364
|
2. **Check the Class Index**
|
|
@@ -397,7 +398,8 @@ Always verify a class exists before suggesting it.
|
|
|
397
398
|
Load these only when needed:
|
|
398
399
|
|
|
399
400
|
### Essential References
|
|
400
|
-
- **[Class Index](references/class-index.md)** - Naming conventions,
|
|
401
|
+
- **[Class Index](references/class-index.md)** - Naming conventions, prohibited classes, prefix inventory, verification commands (LOAD FIRST when unsure about a class)
|
|
402
|
+
- **[Class Index — Properties (A–Z)](references/class-index-properties.md)** - Full A–Z table of every Titanium property and its PurgeTSS class prefix
|
|
401
403
|
- **[Class Categories](references/class-categories.md)** - Complete prefix inventory by category (layout, colors, typography, states, etc.)
|
|
402
404
|
- **[Dynamic Component Creation](references/dynamic-component-creation.md)** - `$.UI.create()` and `Alloy.createStyle()` for creating components in Controllers (READ FIRST for dynamic components)
|
|
403
405
|
- **[Appearance Module](references/appearance-module.md)** - Light/Dark/System mode switching with persistence (v7.5.3)
|
|
@@ -432,6 +434,7 @@ Load these only when needed:
|
|
|
432
434
|
### App Assets
|
|
433
435
|
- [App Branding](references/app-branding.md) - `brand` command for launcher icons, adaptive, iOS 18+ Dark/Tinted, marketplace assets (v7.6.0)
|
|
434
436
|
- [Multi-Density Images](references/multi-density-images.md) - `images` command for Android res-*dpi + iPhone @1x/@2x/@3x UI images (v7.6.0)
|
|
437
|
+
- [SVG Pipeline](references/svg-pipeline.md) - SVG-aware compile-time image pipeline: `.svg` refs + numeric `w-*`/`h-*` classes compile to 8 density PNGs; `images.files`/`images.autoSync` (v7.11.0–v7.11.1)
|
|
435
438
|
|
|
436
439
|
### Performance
|
|
437
440
|
- [Performance Tips](references/performance-tips.md) - Optimizing PurgeTSS apps (bridge crossings, ListView, animations)
|
|
@@ -446,7 +449,7 @@ Load these only when needed:
|
|
|
446
449
|
- [Animation Advanced](references/animation-advanced.md) - Property inheritance, utility classes, implementation rules, complex UI example
|
|
447
450
|
|
|
448
451
|
### Release Notes
|
|
449
|
-
- [Version History](references/version-history.md) - Release-by-release feature additions and behavior changes (v7.4.0 → v7.
|
|
452
|
+
- [Version History](references/version-history.md) - Release-by-release feature additions and behavior changes (v7.4.0 → v7.11.1)
|
|
450
453
|
|
|
451
454
|
> **💡 TEXT FONTS (Google Fonts, Roboto, etc.)**
|
|
452
455
|
> For text fonts, see [Custom Fonts](references/custom-fonts.md).
|
|
@@ -47,11 +47,12 @@ The examples below catalog anti-patterns observed in real Titanium + PurgeTSS pr
|
|
|
47
47
|
</View>
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
**✅ CORRECT (Composite layout
|
|
50
|
+
**✅ CORRECT (Composite layout, no positioning on the child):**
|
|
51
51
|
```xml
|
|
52
|
-
<!-- Parent defaults to composite, no layout class needed
|
|
52
|
+
<!-- Parent defaults to composite, no layout class needed.
|
|
53
|
+
A child with no top/left/bottom/right centers itself. -->
|
|
53
54
|
<View class="h-screen w-screen">
|
|
54
|
-
<Label text="Centered"
|
|
55
|
+
<Label text="Centered" />
|
|
55
56
|
</View>
|
|
56
57
|
```
|
|
57
58
|
|
|
@@ -95,8 +96,9 @@ The examples below catalog anti-patterns observed in real Titanium + PurgeTSS pr
|
|
|
95
96
|
**✅ CORRECT (Composite + positioning):**
|
|
96
97
|
```xml
|
|
97
98
|
<View class="h-14 w-screen">
|
|
98
|
-
|
|
99
|
-
<Label class="
|
|
99
|
+
<!-- Omitting top/bottom lets each child center vertically in the composite bar -->
|
|
100
|
+
<Label text="Title" class="left-4 font-bold" />
|
|
101
|
+
<Label class="fas fa-bars right-4" />
|
|
100
102
|
</View>
|
|
101
103
|
```
|
|
102
104
|
|
|
@@ -392,7 +394,7 @@ module.exports = {
|
|
|
392
394
|
| `flex-row` | Flexbox not supported | `horizontal` |
|
|
393
395
|
| `flex-col` | Flexbox not supported | `vertical` |
|
|
394
396
|
| `justify-*` | Flexbox not supported | Use margins/positioning |
|
|
395
|
-
| `items-center` |
|
|
397
|
+
| `items-center` | Exists but maps to fill, not centering — avoid for centering | Use layout + positioning |
|
|
396
398
|
| `p-4` on View | No padding on containers | `m-4` on children |
|
|
397
399
|
| `w-full` | Percentage-based | `w-screen` (Ti.UI.FILL) |
|
|
398
400
|
| `rounded-full` | Needs size suffix | `rounded-full-12` |
|
|
@@ -356,6 +356,11 @@ Since v7.7.0, PurgeTSS regenerates `app/assets/android/default.png` in Alloy pro
|
|
|
356
356
|
|
|
357
357
|
That file still matters as a fallback on older Titanium Android splash paths, which is why `cleanup-legacy` no longer removes it.
|
|
358
358
|
|
|
359
|
+
> **INFO**
|
|
360
|
+
>
|
|
361
|
+
> Older Android splash theme assets are left out on purpose
|
|
362
|
+
> The older Android splash **theme** assets `background.png` / `background.9.png` are intentionally **not** part of the normal `brand` flow. `brand` targets the modern Titanium icon pipeline (iOS app icons, Android adaptive icons, optional Android 12+ splash artwork), so if a project still depends on those legacy nine-patch theme assets, manage them manually. (Source: upstream `app-assets/1-app-icons-and-branding.md` ~lines 334, 386.)
|
|
363
|
+
|
|
359
364
|
## iOS 18+ Dark and Tinted variants
|
|
360
365
|
|
|
361
366
|
iOS 18 added two appearance variants on top of the standard app icon: **Dark** (for the dark appearance of the Home Screen) and **Tinted** (for the user-accent-colored mode).
|
|
@@ -85,7 +85,7 @@ module.exports = {
|
|
|
85
85
|
|
|
86
86
|
`./purgetss/styles/utilities.tss`
|
|
87
87
|
```tss
|
|
88
|
-
'.close-button': { color: '#374151', textColor: '#374151', width: 48, height: 48, font: { fontFamily: 'FontAwesome7Free-Solid' }, text: '
|
|
88
|
+
'.close-button': { color: '#374151', textColor: '#374151', width: 48, height: 48, font: { fontFamily: 'FontAwesome7Free-Solid' }, text: '\uf057', title: '\uf057' }
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
The same lookup runs for `mi-*`, `ms-*`, and `f7-*` classes. If the project ships its own `purgetss/styles/fontawesome.tss` (for example, FontAwesome Pro or Beta), that file takes precedence over the bundled default — matching the precedence order used when the same icon class appears directly in XML.
|
|
@@ -65,7 +65,7 @@ Complete inventory of all class prefixes organized by functional category. For n
|
|
|
65
65
|
|
|
66
66
|
| Prefix | Count | Examples |
|
|
67
67
|
| --- | --- | --- |
|
|
68
|
-
| `bg-` | **1,688** | `bg-white`, `bg-gray-*` (50-950), all 22 Tailwind colors. Each color has 11 shades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950. Plus: `bg-black`, `bg-white`, `bg-transparent
|
|
68
|
+
| `bg-` | **1,688** | `bg-white`, `bg-gray-*` (50-950), all 22 Tailwind colors. Each color has 11 shades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950. Plus: `bg-black`, `bg-white`, `bg-transparent` |
|
|
69
69
|
| `active-tint-*` | ~24 | `active-tint-*` (all colors) |
|
|
70
70
|
| `selected-bg-*` | ~264 | `selected-bg-*` (selected state backgrounds) |
|
|
71
71
|
| `badge-bg-*` | ~264 | `badge-bg-*` (badge backgrounds) |
|