@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.
- package/AGENTS-TEMPLATE.md +173 -0
- package/README.md +867 -0
- package/agents/ti-researcher.md +108 -0
- package/bin/titools.js +53 -0
- package/lib/commands/agents.js +126 -0
- package/lib/commands/install.js +188 -0
- package/lib/commands/uninstall.js +215 -0
- package/lib/commands/update.js +159 -0
- package/lib/config.js +119 -0
- package/lib/downloader.js +153 -0
- package/lib/installer.js +253 -0
- package/lib/platform.js +108 -0
- package/lib/symlink.js +142 -0
- package/lib/utils.js +270 -0
- package/package.json +67 -0
- package/skills/alloy-expert/SKILL.md +247 -0
- package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
- package/skills/alloy-expert/references/alloy-structure.md +381 -0
- package/skills/alloy-expert/references/anti-patterns.md +133 -0
- package/skills/alloy-expert/references/code-conventions.md +469 -0
- package/skills/alloy-expert/references/contracts.md +280 -0
- package/skills/alloy-expert/references/controller-patterns.md +520 -0
- package/skills/alloy-expert/references/error-handling.md +484 -0
- package/skills/alloy-expert/references/examples.md +735 -0
- package/skills/alloy-expert/references/migration-patterns.md +298 -0
- package/skills/alloy-expert/references/patterns.md +448 -0
- package/skills/alloy-expert/references/performance-patterns.md +855 -0
- package/skills/alloy-expert/references/security-patterns.md +847 -0
- package/skills/alloy-expert/references/state-management.md +779 -0
- package/skills/alloy-expert/references/testing.md +872 -0
- package/skills/alloy-guides/SKILL.md +214 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
- package/skills/alloy-guides/references/CONCEPTS.md +191 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
- package/skills/alloy-guides/references/MODELS.md +1028 -0
- package/skills/alloy-guides/references/PURGETSS.md +56 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
- package/skills/alloy-guides/references/WIDGETS.md +176 -0
- package/skills/alloy-howtos/SKILL.md +203 -0
- package/skills/alloy-howtos/references/best_practices.md +138 -0
- package/skills/alloy-howtos/references/cli_reference.md +253 -0
- package/skills/alloy-howtos/references/config_files.md +87 -0
- package/skills/alloy-howtos/references/custom_tags.md +147 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
- package/skills/alloy-howtos/references/samples.md +167 -0
- package/skills/purgetss/SKILL.md +442 -0
- package/skills/purgetss/assets/purgetss.config.cjs +17 -0
- package/skills/purgetss/references/EXAMPLES.md +247 -0
- package/skills/purgetss/references/animation-system.md +1294 -0
- package/skills/purgetss/references/apply-directive.md +375 -0
- package/skills/purgetss/references/arbitrary-values.md +612 -0
- package/skills/purgetss/references/class-index.md +1350 -0
- package/skills/purgetss/references/cli-commands.md +948 -0
- package/skills/purgetss/references/configurable-properties.md +654 -0
- package/skills/purgetss/references/custom-rules.md +161 -0
- package/skills/purgetss/references/customization-deep-dive.md +722 -0
- package/skills/purgetss/references/dynamic-component-creation.md +489 -0
- package/skills/purgetss/references/grid-layout.md +455 -0
- package/skills/purgetss/references/icon-fonts.md +609 -0
- package/skills/purgetss/references/installation-setup.md +366 -0
- package/skills/purgetss/references/opacity-modifier.md +291 -0
- package/skills/purgetss/references/platform-modifiers.md +479 -0
- package/skills/purgetss/references/smart-mappings.md +42 -0
- package/skills/purgetss/references/titanium-resets.md +359 -0
- package/skills/purgetss/references/ui-ux-design.md +1526 -0
- package/skills/ti-guides/SKILL.md +94 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
- package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
- package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
- package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +258 -0
- package/skills/ti-guides/references/application-frameworks.md +377 -0
- package/skills/ti-guides/references/cli-reference.md +402 -0
- package/skills/ti-guides/references/coding-best-practices.md +102 -0
- package/skills/ti-guides/references/commonjs-advanced.md +134 -0
- package/skills/ti-guides/references/hello-world.md +100 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
- package/skills/ti-guides/references/javascript-primer.md +411 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +183 -0
- package/skills/ti-guides/references/style-and-conventions.md +48 -0
- package/skills/ti-guides/references/tiapp-config.md +609 -0
- package/skills/ti-howtos/SKILL.md +174 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
- package/skills/ti-howtos/references/cross-platform-development.md +348 -0
- package/skills/ti-howtos/references/debugging-profiling.md +543 -0
- package/skills/ti-howtos/references/extending-titanium.md +723 -0
- package/skills/ti-howtos/references/google-maps-v2.md +169 -0
- package/skills/ti-howtos/references/ios-map-kit.md +143 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
- package/skills/ti-howtos/references/local-data-sources.md +301 -0
- package/skills/ti-howtos/references/location-and-maps.md +252 -0
- package/skills/ti-howtos/references/media-apis.md +210 -0
- package/skills/ti-howtos/references/notification-services.md +599 -0
- package/skills/ti-howtos/references/remote-data-sources.md +349 -0
- package/skills/ti-howtos/references/tutorials.md +502 -0
- package/skills/ti-howtos/references/using-modules.md +237 -0
- package/skills/ti-howtos/references/web-content-integration.md +307 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
- package/skills/ti-ui/SKILL.md +179 -0
- package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
- package/skills/ti-ui/references/animation-and-matrices.md +599 -0
- package/skills/ti-ui/references/application-structures.md +655 -0
- package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
- package/skills/ti-ui/references/event-handling.md +393 -0
- package/skills/ti-ui/references/gestures.md +473 -0
- package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
- package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
- package/skills/ti-ui/references/listviews-and-performance.md +619 -0
- package/skills/ti-ui/references/orientation.md +362 -0
- package/skills/ti-ui/references/platform-ui-android.md +635 -0
- package/skills/ti-ui/references/platform-ui-ios.md +469 -0
- package/skills/ti-ui/references/scrolling-views.md +252 -0
- package/skills/ti-ui/references/tableviews.md +568 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Using Modules
|
|
2
|
+
|
|
3
|
+
Guide for obtaining, installing, and using Titanium modules to extend app functionality.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Using Modules](#using-modules)
|
|
8
|
+
- [Table of Contents](#table-of-contents)
|
|
9
|
+
- [Obtaining Modules](#obtaining-modules)
|
|
10
|
+
- [Sources of Modules](#sources-of-modules)
|
|
11
|
+
- [Installing Modules](#installing-modules)
|
|
12
|
+
- [Single Project Installation](#single-project-installation)
|
|
13
|
+
- [Global Installation (All Projects)](#global-installation-all-projects)
|
|
14
|
+
- [Configuring Your App](#configuring-your-app)
|
|
15
|
+
- [Updating tiapp.xml](#updating-tiappxml)
|
|
16
|
+
- [Selecting Module Versions](#selecting-module-versions)
|
|
17
|
+
- [Enable Debugger (for native modules)](#enable-debugger-for-native-modules)
|
|
18
|
+
- [Using a Module](#using-a-module)
|
|
19
|
+
- [Loading the Module (ES5)](#loading-the-module-es5)
|
|
20
|
+
- [Loading the Module (ES6+)](#loading-the-module-es6)
|
|
21
|
+
- [Using Module Functionality](#using-module-functionality)
|
|
22
|
+
- [Module Patterns](#module-patterns)
|
|
23
|
+
- [Troubleshooting](#troubleshooting)
|
|
24
|
+
- ["Requested module not found"](#requested-module-not-found)
|
|
25
|
+
- [Version Conflicts](#version-conflicts)
|
|
26
|
+
- [Platform-Specific Issues](#platform-specific-issues)
|
|
27
|
+
- [Clean Build](#clean-build)
|
|
28
|
+
- [Best Practices](#best-practices)
|
|
29
|
+
- [Module Development](#module-development)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Obtaining Modules
|
|
34
|
+
|
|
35
|
+
### Sources of Modules
|
|
36
|
+
|
|
37
|
+
**Official Modules:**
|
|
38
|
+
- **Enterprise Extensions**
|
|
39
|
+
- InAppBilling (Android)
|
|
40
|
+
- StoreKit (iOS)
|
|
41
|
+
- Barcode (iOS/Android)
|
|
42
|
+
- Compression (iOS/Android)
|
|
43
|
+
- OpenGL (iOS)
|
|
44
|
+
- AirPrint (iOS)
|
|
45
|
+
|
|
46
|
+
**Open-Source Modules:**
|
|
47
|
+
- **GitHub: tidev/** - Official open-source modules
|
|
48
|
+
- [ti.admob](https://github.com/tidev/ti.admob) - AdMob ads
|
|
49
|
+
- [ti.map](https://github.com/tidev/ti.map) - Native maps
|
|
50
|
+
- And many more
|
|
51
|
+
|
|
52
|
+
**Community Modules:**
|
|
53
|
+
- **From Zero To App** - Lists Titanium modules
|
|
54
|
+
- https://fromzerotoapp.com/modules/
|
|
55
|
+
- Curated list of modules maintained by Michael Gangolf
|
|
56
|
+
|
|
57
|
+
**Marketplace:**
|
|
58
|
+
- Appcelerator Marketplace is no longer in use
|
|
59
|
+
- Contact marketplace-admin@axway.com for previously purchased modules
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Installing Modules
|
|
64
|
+
|
|
65
|
+
### Single Project Installation
|
|
66
|
+
|
|
67
|
+
1. Copy the module ZIP to your app root folder
|
|
68
|
+
2. Add module to `tiapp.xml` (see configuration below)
|
|
69
|
+
3. Build project - ZIP will be extracted automatically
|
|
70
|
+
|
|
71
|
+
### Global Installation (All Projects)
|
|
72
|
+
|
|
73
|
+
Modules are installed to platform-specific locations:
|
|
74
|
+
|
|
75
|
+
| Operating System | Path |
|
|
76
|
+
| ---------------- | ---------------------------------------- |
|
|
77
|
+
| macOS | `~/Library/Application Support/Titanium` |
|
|
78
|
+
| Windows | `%ProgramData%\Titanium\mobilesdk\win32` |
|
|
79
|
+
|
|
80
|
+
**Show hidden Library folder on macOS:**
|
|
81
|
+
```bash
|
|
82
|
+
# Permanently show
|
|
83
|
+
chflags nohidden ~/Library/
|
|
84
|
+
|
|
85
|
+
# Open once
|
|
86
|
+
open ~/Library
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Configuring Your App
|
|
92
|
+
|
|
93
|
+
### Updating tiapp.xml
|
|
94
|
+
|
|
95
|
+
**Using Studio/IDE:**
|
|
96
|
+
1. Open `tiapp.xml`
|
|
97
|
+
2. Go to **Overview** tab
|
|
98
|
+
3. Click **+** button in Modules section
|
|
99
|
+
4. Select module and version
|
|
100
|
+
5. Save
|
|
101
|
+
|
|
102
|
+
**Manually (XML):**
|
|
103
|
+
```xml
|
|
104
|
+
<modules>
|
|
105
|
+
<module version="3.0.2" platform="ios">ti.map</module>
|
|
106
|
+
<module version="5.0.0" platform="android">ti.admob</module>
|
|
107
|
+
</modules>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Attributes:**
|
|
111
|
+
- `version` - Must match module manifest
|
|
112
|
+
- `platform` - "ios" or "android"
|
|
113
|
+
|
|
114
|
+
### Selecting Module Versions
|
|
115
|
+
|
|
116
|
+
When multiple versions are installed, you can select specific versions per platform and build type (development/production).
|
|
117
|
+
|
|
118
|
+
In Studio, double-click the module to open **Module Properties** dialog.
|
|
119
|
+
|
|
120
|
+
### Enable Debugger (for native modules)
|
|
121
|
+
|
|
122
|
+
Required for debugging native modules:
|
|
123
|
+
|
|
124
|
+
```xml
|
|
125
|
+
<ti:app>
|
|
126
|
+
<android xmlns:android="http://schemas.android.com/apk/res/android">
|
|
127
|
+
<manifest>
|
|
128
|
+
<application android:debuggable="true">
|
|
129
|
+
</application>
|
|
130
|
+
</manifest>
|
|
131
|
+
</android>
|
|
132
|
+
</ti:app>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Using a Module
|
|
138
|
+
|
|
139
|
+
### Loading the Module (ES5)
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
const Module = require('module.id');
|
|
143
|
+
// Example: const Map = require('ti.map');
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Loading the Module (ES6+)
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
import Module from 'module.id'
|
|
150
|
+
// Example: import Map from 'ti.map'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Important:** Don't include `.js` extension in the module ID.
|
|
154
|
+
|
|
155
|
+
### Using Module Functionality
|
|
156
|
+
|
|
157
|
+
After requiring, use the module's API:
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
// ES6+ example with ti.admob
|
|
161
|
+
const Admob = require('ti.admob');
|
|
162
|
+
|
|
163
|
+
const adview = Admob.createView({
|
|
164
|
+
top: 0,
|
|
165
|
+
testing: true,
|
|
166
|
+
adBackgroundColor: 'black',
|
|
167
|
+
primaryTextColor: 'blue',
|
|
168
|
+
publisherId: 'YOUR_PUBLISHER_ID'
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
win.add(adview);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Module Patterns
|
|
175
|
+
|
|
176
|
+
**Singleton pattern:**
|
|
177
|
+
```javascript
|
|
178
|
+
const admob = require('ti.admob');
|
|
179
|
+
admob.createView({...});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Constructor pattern:**
|
|
183
|
+
```javascript
|
|
184
|
+
const Map = require('ti.map');
|
|
185
|
+
const view = Map.createView({...});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Refer to module documentation for its specific API.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Troubleshooting
|
|
193
|
+
|
|
194
|
+
### "Requested module not found"
|
|
195
|
+
|
|
196
|
+
**Solutions:**
|
|
197
|
+
1. Check module ID spelling in `require()`
|
|
198
|
+
2. Verify module is added to `tiapp.xml`
|
|
199
|
+
3. Confirm module is installed (check global or local path)
|
|
200
|
+
4. Remove `version` attribute to use latest version
|
|
201
|
+
|
|
202
|
+
### Version Conflicts
|
|
203
|
+
|
|
204
|
+
If multiple versions exist, specify exact version in `tiapp.xml` or remove version attribute to use latest.
|
|
205
|
+
|
|
206
|
+
### Platform-Specific Issues
|
|
207
|
+
|
|
208
|
+
- **iOS:** Module must support iOS SDK version you're using
|
|
209
|
+
- **Android:** Check module's `platform` attribute in manifest matches target
|
|
210
|
+
|
|
211
|
+
### Clean Build
|
|
212
|
+
|
|
213
|
+
Sometimes needed after installing modules:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Clean and rebuild
|
|
217
|
+
ti clean
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Best Practices
|
|
223
|
+
|
|
224
|
+
1. **Version pinning** - Specify exact module versions for production
|
|
225
|
+
2. **Check compatibility** - Verify module supports your Titanium SDK version
|
|
226
|
+
3. **Test on devices** - Modules may behave differently on simulator vs. device
|
|
227
|
+
4. **Keep updated** - Update modules regularly for bug fixes and new features
|
|
228
|
+
5. **Read documentation** - Each module has specific setup and usage patterns
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Module Development
|
|
233
|
+
|
|
234
|
+
If you need to create your own module, see the **extending-titanium.md** reference for:
|
|
235
|
+
- Android Module Development Guide
|
|
236
|
+
- iOS Module Development Guide
|
|
237
|
+
- Module architecture and best practices
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Web Content Integration
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Web Content Integration](#web-content-integration)
|
|
6
|
+
- [Table of Contents](#table-of-contents)
|
|
7
|
+
- [1. The WebView Component](#1-the-webview-component)
|
|
8
|
+
- [WKWebView (Titanium SDK 8.0.0+)](#wkwebview-titanium-sdk-800)
|
|
9
|
+
- [Basic WebView Creation](#basic-webview-creation)
|
|
10
|
+
- [Remote URL](#remote-url)
|
|
11
|
+
- [Local HTML](#local-html)
|
|
12
|
+
- [Inline HTML](#inline-html)
|
|
13
|
+
- [Local Web Content with Assets](#local-web-content-with-assets)
|
|
14
|
+
- [WebView Properties and Methods](#webview-properties-and-methods)
|
|
15
|
+
- [Navigation](#navigation)
|
|
16
|
+
- [Load Control](#load-control)
|
|
17
|
+
- [Data Handling](#data-handling)
|
|
18
|
+
- [Events](#events)
|
|
19
|
+
- [2. Communication Between WebViews and Titanium](#2-communication-between-webviews-and-titanium)
|
|
20
|
+
- [Local Web Content Communication](#local-web-content-communication)
|
|
21
|
+
- [Logging from WebView](#logging-from-webview)
|
|
22
|
+
- [Bidirectional Events with Ti.App](#bidirectional-events-with-tiapp)
|
|
23
|
+
- [Remote Web Content Communication](#remote-web-content-communication)
|
|
24
|
+
- [Using evalJS() for Remote Content](#using-evaljs-for-remote-content)
|
|
25
|
+
- [Passing Data to Remote Content](#passing-data-to-remote-content)
|
|
26
|
+
- [3. Performance and Interaction Concerns](#3-performance-and-interaction-concerns)
|
|
27
|
+
- [WebView Performance](#webview-performance)
|
|
28
|
+
- [WebView in TableViews](#webview-in-tableviews)
|
|
29
|
+
- [WebView in Scrollable Components](#webview-in-scrollable-components)
|
|
30
|
+
- [Viewport Meta Tag](#viewport-meta-tag)
|
|
31
|
+
- [4. WebView Use Cases](#4-webview-use-cases)
|
|
32
|
+
- [Authentication Flows](#authentication-flows)
|
|
33
|
+
- [Canvas and Graphics](#canvas-and-graphics)
|
|
34
|
+
- [5. WKWebView-Specific Considerations](#5-wkwebview-specific-considerations)
|
|
35
|
+
- [Best Practices Summary](#best-practices-summary)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 1. The WebView Component
|
|
40
|
+
|
|
41
|
+
### WKWebView (Titanium SDK 8.0.0+)
|
|
42
|
+
Apple deprecated UIWebView. Titanium now uses WKWebView as the underlying implementation.
|
|
43
|
+
|
|
44
|
+
**Important**: WKWebView has some behavioral differences compared to the original UIWebView.
|
|
45
|
+
|
|
46
|
+
### Basic WebView Creation
|
|
47
|
+
|
|
48
|
+
#### Remote URL
|
|
49
|
+
```javascript
|
|
50
|
+
const webview = Ti.UI.createWebView({
|
|
51
|
+
url: 'https://titaniumsdk.com'
|
|
52
|
+
});
|
|
53
|
+
win.add(webview);
|
|
54
|
+
win.open();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Local HTML
|
|
58
|
+
```javascript
|
|
59
|
+
const webview = Ti.UI.createWebView({
|
|
60
|
+
url: 'local.html' // Relative to Resources or app/assets/app/lib
|
|
61
|
+
});
|
|
62
|
+
win.add(webview);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Inline HTML
|
|
66
|
+
```javascript
|
|
67
|
+
const webview = Ti.UI.createWebView({
|
|
68
|
+
html: '<html><body><h1>Hello</h1></body></html>'
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Local Web Content with Assets
|
|
73
|
+
|
|
74
|
+
Local content can include CSS, JS, and images. Paths are relative to Resources (Classic) or app/assets/app/lib (Alloy).
|
|
75
|
+
|
|
76
|
+
**local.html**:
|
|
77
|
+
```html
|
|
78
|
+
<html>
|
|
79
|
+
<head>
|
|
80
|
+
<link rel="stylesheet" type="text/css" href="local.css"/>
|
|
81
|
+
<script src="local.js"></script>
|
|
82
|
+
</head>
|
|
83
|
+
<body>
|
|
84
|
+
<p>Local content</p>
|
|
85
|
+
</body>
|
|
86
|
+
</html>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### WebView Properties and Methods
|
|
90
|
+
|
|
91
|
+
#### Navigation
|
|
92
|
+
- `canGoBack()` - Returns Boolean if possible to go back
|
|
93
|
+
- `canGoForward()` - Returns Boolean if possible to go forward
|
|
94
|
+
- `goBack()` - Navigate back in history
|
|
95
|
+
- `goForward()` - Navigate forward in history
|
|
96
|
+
|
|
97
|
+
#### Load Control
|
|
98
|
+
- `loading` (Boolean) - Current loading state
|
|
99
|
+
- `reload()` - Refresh the page
|
|
100
|
+
- `stopLoading()` - Stop loading
|
|
101
|
+
- `repaint()` - Force repaint
|
|
102
|
+
|
|
103
|
+
#### Data Handling
|
|
104
|
+
- `url` - Local or remote URL
|
|
105
|
+
- `html` - Inline HTML string
|
|
106
|
+
- `scalesPageToFit` - Boolean to scale content to dimensions
|
|
107
|
+
- `setBasicAuthentication(username, password)` - HTTP authentication
|
|
108
|
+
|
|
109
|
+
#### Events
|
|
110
|
+
- `beforeload` - Fires before loading begins (`e.url` contains the source)
|
|
111
|
+
- `load` - Fires when content has loaded
|
|
112
|
+
- `error` - Fires on load failures (`e.url`, `e.message`)
|
|
113
|
+
|
|
114
|
+
## 2. Communication Between WebViews and Titanium
|
|
115
|
+
|
|
116
|
+
### Local Web Content Communication
|
|
117
|
+
|
|
118
|
+
#### Logging from WebView
|
|
119
|
+
Ti.API methods work inside local HTML:
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<html>
|
|
123
|
+
<body onload="Ti.API.info('Page loaded!');">
|
|
124
|
+
<p>Logging works!</p>
|
|
125
|
+
</body>
|
|
126
|
+
</html>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Bidirectional Events with Ti.App
|
|
130
|
+
|
|
131
|
+
**In local HTML**:
|
|
132
|
+
```html
|
|
133
|
+
<html>
|
|
134
|
+
<head>
|
|
135
|
+
<script>
|
|
136
|
+
// Listen for events from Titanium
|
|
137
|
+
Ti.App.addEventListener('app:fromTitanium', (e) => {
|
|
138
|
+
alert(e.message);
|
|
139
|
+
document.getElementById('output').textContent = e.message;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Send event to Titanium
|
|
143
|
+
function sendToApp() {
|
|
144
|
+
Ti.App.fireEvent('app:fromWebView', {
|
|
145
|
+
message: 'Hello from WebView!'
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
</script>
|
|
149
|
+
</head>
|
|
150
|
+
<body>
|
|
151
|
+
<button onclick="sendToApp()">Send to Titanium</button>
|
|
152
|
+
<div id="output"></div>
|
|
153
|
+
</body>
|
|
154
|
+
</html>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**In Titanium**:
|
|
158
|
+
```javascript
|
|
159
|
+
const webview = Ti.UI.createWebView({ url: 'local.html' });
|
|
160
|
+
|
|
161
|
+
// Listen for events from the WebView
|
|
162
|
+
Ti.App.addEventListener('app:fromWebView', (e) => {
|
|
163
|
+
alert(e.message);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Send event to the WebView
|
|
167
|
+
const button = Ti.UI.createButton({
|
|
168
|
+
title: 'Send to WebView'
|
|
169
|
+
});
|
|
170
|
+
button.addEventListener('click', () => {
|
|
171
|
+
Ti.App.fireEvent('app:fromTitanium', {
|
|
172
|
+
message: 'Hello from Titanium!'
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Remote Web Content Communication
|
|
178
|
+
|
|
179
|
+
**Critical**: Titanium statements (Ti.API, Ti.App) do NOT work in remote HTML content.
|
|
180
|
+
|
|
181
|
+
#### Using evalJS() for Remote Content
|
|
182
|
+
|
|
183
|
+
Inject JavaScript and retrieve results as strings:
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
const webview = Ti.UI.createWebView({ url: 'https://example.com' });
|
|
187
|
+
|
|
188
|
+
webview.addEventListener('load', (e) => {
|
|
189
|
+
// Get the page title
|
|
190
|
+
const title = webview.evalJS('document.title');
|
|
191
|
+
Ti.API.info(`Page title: ${title}`);
|
|
192
|
+
|
|
193
|
+
// Get cookies
|
|
194
|
+
const cookies = webview.evalJS('document.cookie');
|
|
195
|
+
Ti.API.info(`Cookies: ${cookies}`);
|
|
196
|
+
|
|
197
|
+
// Execute a custom function
|
|
198
|
+
webview.evalJS('alert("Hello from Titanium!");');
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**evalJS() Rules**:
|
|
203
|
+
- Must be called from the `load` event (page must be loaded)
|
|
204
|
+
- Pass code as a single string
|
|
205
|
+
- Returns a string (or null)
|
|
206
|
+
- Use `JSON.stringify()` for complex data
|
|
207
|
+
|
|
208
|
+
#### Passing Data to Remote Content
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
webview.addEventListener('load', () => {
|
|
212
|
+
const data = { user: 'John', score: 100 };
|
|
213
|
+
webview.evalJS(`window.appData = ${JSON.stringify(data)};`);
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Then in the remote HTML:
|
|
218
|
+
```html
|
|
219
|
+
<script>
|
|
220
|
+
console.log(window.appData.user); // 'John'
|
|
221
|
+
</script>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## 3. Performance and Interaction Concerns
|
|
225
|
+
|
|
226
|
+
### WebView Performance
|
|
227
|
+
|
|
228
|
+
**WebView consumes many resources**:
|
|
229
|
+
- Each WebView requires its own rendering context
|
|
230
|
+
- Significant memory overhead
|
|
231
|
+
- Load time independent of content simplicity
|
|
232
|
+
|
|
233
|
+
**Best Practice**: If you can recreate the content with native Titanium components, do it.
|
|
234
|
+
|
|
235
|
+
### WebView in TableViews
|
|
236
|
+
|
|
237
|
+
**Anti-Pattern**: Embedding WebViews in TableViewRows causes slow scrolling.
|
|
238
|
+
|
|
239
|
+
### WebView in Scrollable Components
|
|
240
|
+
|
|
241
|
+
WebViews don't work well inside other scrollable containers (ScrollView, TableView). They consume touch events.
|
|
242
|
+
|
|
243
|
+
**Workaround**: Set `touchEnabled: false` on the WebView if inside a scrollable parent:
|
|
244
|
+
|
|
245
|
+
```javascript
|
|
246
|
+
const webview = Ti.UI.createWebView({
|
|
247
|
+
url: 'content.html',
|
|
248
|
+
touchEnabled: false // Allow parent to handle touches
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Viewport Meta Tag
|
|
253
|
+
|
|
254
|
+
For mobile-optimized content, use the viewport meta tag:
|
|
255
|
+
|
|
256
|
+
```html
|
|
257
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## 4. WebView Use Cases
|
|
261
|
+
|
|
262
|
+
### Authentication Flows
|
|
263
|
+
Many OAuth providers use WebView for login (like the Facebook module).
|
|
264
|
+
|
|
265
|
+
```javascript
|
|
266
|
+
const authWebView = Ti.UI.createWebView({
|
|
267
|
+
url: 'https://auth.example.com/oauth'
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
authWebView.addEventListener('load', (e) => {
|
|
271
|
+
// Detect redirect to callback URL with token
|
|
272
|
+
if (e.url.indexOf('myapp://callback') === 0) {
|
|
273
|
+
const token = extractTokenFromUrl(e.url);
|
|
274
|
+
Ti.App.fireEvent('auth:success', { token: token });
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Canvas and Graphics
|
|
280
|
+
For complex graphics, use HTML5 Canvas:
|
|
281
|
+
|
|
282
|
+
**local.html**:
|
|
283
|
+
```html
|
|
284
|
+
<canvas id="myCanvas" width="300" height="200"></canvas>
|
|
285
|
+
<script>
|
|
286
|
+
const ctx = document.getElementById('myCanvas').getContext('2d');
|
|
287
|
+
ctx.fillStyle = 'green';
|
|
288
|
+
ctx.fillRect(10, 10, 150, 100);
|
|
289
|
+
</script>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## 5. WKWebView-Specific Considerations
|
|
293
|
+
|
|
294
|
+
1. **Cookie Management**: WKWebView has separate cookie storage.
|
|
295
|
+
2. **localStorage/SessionStorage**: Not shared with native app.
|
|
296
|
+
3. **Asynchronous evalJS**: In modern iOS versions, async usage is preferred to avoid blocking.
|
|
297
|
+
|
|
298
|
+
For detailed WKWebView information, refer to the official migration guide and specific behaviors.
|
|
299
|
+
|
|
300
|
+
## Best Practices Summary
|
|
301
|
+
|
|
302
|
+
1. **Avoid WebViews when possible** - Use native components.
|
|
303
|
+
2. **Never embed in TableView** - Causes serious scroll issues.
|
|
304
|
+
3. **Use local content for integration** - Only local content supports Ti.App events.
|
|
305
|
+
4. **Use evalJS() for remote** - Only way to interact with remote content.
|
|
306
|
+
5. **Wait for the load event** - Before calling evalJS().
|
|
307
|
+
6. **Configure the viewport** - For proper mobile rendering.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Webpack Build Pipeline
|
|
2
|
+
|
|
3
|
+
Starting with Titanium SDK 9.1.0, Webpack is the default build engine for managing your project's assets and code.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Webpack Build Pipeline](#webpack-build-pipeline)
|
|
8
|
+
- [Table of Contents](#table-of-contents)
|
|
9
|
+
- [1. Key Benefits](#1-key-benefits)
|
|
10
|
+
- [2. The `@` Alias](#2-the--alias)
|
|
11
|
+
- [3. NPM Dependency Management](#3-npm-dependency-management)
|
|
12
|
+
- [4. Platform-Specific Files](#4-platform-specific-files)
|
|
13
|
+
- [5. Diagnostic Web UI](#5-diagnostic-web-ui)
|
|
14
|
+
- [6. Advanced Configuration](#6-advanced-configuration)
|
|
15
|
+
- [7. Known Limitations](#7-known-limitations)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 1. Key Benefits
|
|
20
|
+
- **Lightning-Fast Incremental Builds**: Only what changes is processed.
|
|
21
|
+
- **Native NPM Support**: Install any NPM library in the root and use it directly.
|
|
22
|
+
- **Build-Time Resolution**: `require` calls are resolved during compilation, not at runtime.
|
|
23
|
+
|
|
24
|
+
## 2. The `@` Alias
|
|
25
|
+
Webpack introduces the `@` alias to reference the source code root without using complex relative paths (`../../`).
|
|
26
|
+
|
|
27
|
+
| Project Type | Path mapped by `@` |
|
|
28
|
+
| :----------- | :----------------- |
|
|
29
|
+
| **Alloy** | `app/lib` |
|
|
30
|
+
| **Classic** | `src` |
|
|
31
|
+
|
|
32
|
+
**Usage Example:**
|
|
33
|
+
```javascript
|
|
34
|
+
// Before (without webpack)
|
|
35
|
+
import Utils from '../../utils/helper';
|
|
36
|
+
|
|
37
|
+
// Now (with webpack)
|
|
38
|
+
import Utils from '@/utils/helper';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 3. NPM Dependency Management
|
|
42
|
+
Simply install your favorite package in the project root:
|
|
43
|
+
```bash
|
|
44
|
+
npm install lodash
|
|
45
|
+
```
|
|
46
|
+
And use it in your Titanium code:
|
|
47
|
+
```javascript
|
|
48
|
+
import _ from 'lodash';
|
|
49
|
+
const data = _.chunk(['a', 'b', 'c', 'd'], 2);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 4. Platform-Specific Files
|
|
53
|
+
Webpack automatically detects platform-specific files using the `filename.<platform>.js` pattern.
|
|
54
|
+
|
|
55
|
+
**Example:**
|
|
56
|
+
- `utils.js` (common)
|
|
57
|
+
- `utils.ios.js` (iOS only)
|
|
58
|
+
- `utils.android.js` (Android only)
|
|
59
|
+
|
|
60
|
+
When doing `import { func } from '@/utils'`, Webpack will select the correct version based on the build target.
|
|
61
|
+
|
|
62
|
+
## 5. Diagnostic Web UI
|
|
63
|
+
Webpack includes a web interface to analyze the build and asset sizes.
|
|
64
|
+
Default URL: `http://localhost:1732/webpack/latest/web`
|
|
65
|
+
|
|
66
|
+
## 6. Advanced Configuration
|
|
67
|
+
You can extend the configuration via plugins in `package.json`:
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"appcdWebpackPlugins": [
|
|
71
|
+
"my-local-plugin.js"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 7. Known Limitations
|
|
77
|
+
- **Hyperloop**: Currently not compatible with the Webpack pipeline.
|
|
78
|
+
- **Alloy.jmk**: Older makefiles are ignored by Webpack.
|