@maccesar/titools 2.0.7 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/{AGENTS-TEMPLATE.md → AGENTS-VERCEL-RESEARCH.md} +16 -18
  2. package/README.md +250 -168
  3. package/agents/{ti-researcher.md → ti-pro.md} +10 -10
  4. package/bin/titools.js +16 -12
  5. package/lib/cleanup.js +95 -0
  6. package/lib/commands/agents.js +146 -70
  7. package/lib/commands/skills.js +349 -0
  8. package/lib/commands/uninstall.js +189 -154
  9. package/lib/commands/update.js +104 -21
  10. package/lib/config.js +26 -20
  11. package/lib/downloader.js +1 -1
  12. package/lib/installer.js +37 -97
  13. package/lib/platform.js +9 -5
  14. package/lib/prompts/checkboxCancel.js +264 -0
  15. package/lib/prompts/selectCancel.js +204 -0
  16. package/lib/symlink.js +19 -7
  17. package/lib/utils.js +17 -17
  18. package/package.json +10 -10
  19. package/skills/alloy-guides/SKILL.md +8 -30
  20. package/skills/alloy-guides/references/CLI_TASKS.md +14 -24
  21. package/skills/alloy-guides/references/CONCEPTS.md +5 -25
  22. package/skills/alloy-guides/references/CONTROLLERS.md +2 -19
  23. package/skills/alloy-guides/references/MODELS.md +40 -10
  24. package/skills/alloy-guides/references/PURGETSS.md +1 -11
  25. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +8 -14
  26. package/skills/alloy-guides/references/VIEWS_STYLES.md +14 -25
  27. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +2 -8
  28. package/skills/alloy-guides/references/VIEWS_XML.md +29 -40
  29. package/skills/alloy-guides/references/WIDGETS.md +1 -17
  30. package/skills/alloy-howtos/SKILL.md +1 -22
  31. package/skills/alloy-howtos/references/best_practices.md +0 -17
  32. package/skills/alloy-howtos/references/cli_reference.md +1 -23
  33. package/skills/alloy-howtos/references/config_files.md +86 -15
  34. package/skills/alloy-howtos/references/custom_tags.md +14 -13
  35. package/skills/alloy-howtos/references/debugging_troubleshooting.md +3 -22
  36. package/skills/alloy-howtos/references/samples.md +4 -14
  37. package/skills/purgetss/SKILL.md +11 -37
  38. package/skills/purgetss/references/EXAMPLES.md +106 -17
  39. package/skills/purgetss/references/animation-system.md +0 -67
  40. package/skills/purgetss/references/apply-directive.md +0 -18
  41. package/skills/purgetss/references/arbitrary-values.md +0 -25
  42. package/skills/purgetss/references/class-index.md +0 -46
  43. package/skills/purgetss/references/cli-commands.md +0 -41
  44. package/skills/purgetss/references/configurable-properties.md +0 -55
  45. package/skills/purgetss/references/custom-rules.md +0 -14
  46. package/skills/purgetss/references/customization-deep-dive.md +0 -49
  47. package/skills/purgetss/references/dynamic-component-creation.md +56 -37
  48. package/skills/purgetss/references/grid-layout.md +0 -32
  49. package/skills/purgetss/references/icon-fonts.md +0 -50
  50. package/skills/purgetss/references/installation-setup.md +61 -32
  51. package/skills/purgetss/references/migration-guide.md +127 -0
  52. package/skills/purgetss/references/opacity-modifier.md +0 -34
  53. package/skills/purgetss/references/performance-tips.md +261 -0
  54. package/skills/purgetss/references/platform-modifiers.md +0 -46
  55. package/skills/purgetss/references/smart-mappings.md +0 -12
  56. package/skills/purgetss/references/tikit-components.md +393 -0
  57. package/skills/purgetss/references/titanium-resets.md +1 -27
  58. package/skills/purgetss/references/ui-ux-design.md +467 -117
  59. package/skills/{alloy-expert → ti-expert}/SKILL.md +45 -54
  60. package/skills/ti-expert/references/alloy-builtins.md +387 -0
  61. package/skills/{alloy-expert → ti-expert}/references/alloy-structure.md +147 -40
  62. package/skills/ti-expert/references/anti-patterns.md +90 -0
  63. package/skills/ti-expert/references/cli-expert.md +109 -0
  64. package/skills/{alloy-expert → ti-expert}/references/code-conventions.md +182 -49
  65. package/skills/{alloy-expert → ti-expert}/references/controller-patterns.md +103 -93
  66. package/skills/{alloy-expert → ti-expert}/references/error-handling.md +12 -12
  67. package/skills/{alloy-expert → ti-expert}/references/examples.md +144 -85
  68. package/skills/{alloy-expert → ti-expert}/references/migration-patterns.md +38 -36
  69. package/skills/{alloy-expert → ti-expert}/references/patterns.md +8 -8
  70. package/skills/ti-expert/references/performance-listview.md +251 -0
  71. package/skills/{alloy-expert/references/performance-patterns.md → ti-expert/references/performance-optimization.md} +67 -283
  72. package/skills/{alloy-expert/references/security-patterns.md → ti-expert/references/security-device.md} +12 -295
  73. package/skills/ti-expert/references/security-fundamentals.md +284 -0
  74. package/skills/{alloy-expert → ti-expert}/references/state-management.md +10 -10
  75. package/skills/ti-expert/references/testing-e2e-ci.md +432 -0
  76. package/skills/ti-expert/references/testing-unit.md +433 -0
  77. package/skills/ti-expert/references/theming.md +394 -0
  78. package/skills/ti-guides/SKILL.md +1 -14
  79. package/skills/ti-guides/references/advanced-data-and-images.md +126 -10
  80. package/skills/ti-guides/references/app-distribution.md +48 -10
  81. package/skills/ti-guides/references/application-frameworks.md +9 -2
  82. package/skills/ti-guides/references/cli-reference.md +338 -82
  83. package/skills/ti-guides/references/coding-best-practices.md +14 -4
  84. package/skills/ti-guides/references/commonjs-advanced.md +103 -6
  85. package/skills/ti-guides/references/hello-world.md +5 -2
  86. package/skills/ti-guides/references/hyperloop-native-access.md +439 -46
  87. package/skills/ti-guides/references/javascript-primer.md +4 -3
  88. package/skills/ti-guides/references/resources.md +0 -1
  89. package/skills/ti-guides/references/style-and-conventions.md +57 -9
  90. package/skills/ti-guides/references/tiapp-config.md +48 -6
  91. package/skills/ti-howtos/SKILL.md +2 -27
  92. package/skills/ti-howtos/references/android-platform-deep-dives.md +41 -90
  93. package/skills/ti-howtos/references/automation-fastlane-appium.md +15 -14
  94. package/skills/ti-howtos/references/buffer-codec-streams.md +22 -22
  95. package/skills/ti-howtos/references/cross-platform-development.md +68 -37
  96. package/skills/ti-howtos/references/debugging-profiling.md +8 -53
  97. package/skills/ti-howtos/references/extending-titanium.md +12 -51
  98. package/skills/ti-howtos/references/google-maps-v2.md +30 -29
  99. package/skills/ti-howtos/references/ios-map-kit.md +19 -25
  100. package/skills/ti-howtos/references/ios-platform-deep-dives.md +95 -283
  101. package/skills/ti-howtos/references/local-data-sources.md +45 -37
  102. package/skills/ti-howtos/references/location-and-maps.md +47 -28
  103. package/skills/ti-howtos/references/media-apis.md +84 -27
  104. package/skills/ti-howtos/references/notification-services.md +40 -89
  105. package/skills/ti-howtos/references/remote-data-sources.md +21 -36
  106. package/skills/ti-howtos/references/tutorials.md +79 -39
  107. package/skills/ti-howtos/references/using-modules.md +4 -30
  108. package/skills/ti-howtos/references/web-content-integration.md +28 -45
  109. package/skills/ti-howtos/references/webpack-build-pipeline.md +54 -18
  110. package/skills/ti-ui/SKILL.md +1 -21
  111. package/skills/ti-ui/references/accessibility-deep-dive.md +71 -25
  112. package/skills/ti-ui/references/animation-and-matrices.md +0 -47
  113. package/skills/ti-ui/references/application-structures.md +0 -46
  114. package/skills/ti-ui/references/custom-fonts-styling.md +9 -57
  115. package/skills/ti-ui/references/event-handling.md +32 -40
  116. package/skills/ti-ui/references/gestures.md +0 -40
  117. package/skills/ti-ui/references/icons-and-splash-screens.md +21 -44
  118. package/skills/ti-ui/references/layouts-and-positioning.md +47 -39
  119. package/skills/ti-ui/references/listviews-and-performance.md +187 -73
  120. package/skills/ti-ui/references/orientation.md +57 -71
  121. package/skills/ti-ui/references/platform-ui-android.md +114 -48
  122. package/skills/ti-ui/references/platform-ui-ios.md +63 -38
  123. package/skills/ti-ui/references/scrolling-views.md +14 -23
  124. package/skills/ti-ui/references/tableviews.md +6 -56
  125. package/lib/commands/install.js +0 -188
  126. package/skills/alloy-expert/references/anti-patterns.md +0 -133
  127. package/skills/alloy-expert/references/testing.md +0 -872
  128. package/skills/ti-guides/references/alloy-cli-advanced.md +0 -84
  129. package/skills/ti-guides/references/alloy-data-mastery.md +0 -29
  130. package/skills/ti-guides/references/alloy-widgets-and-themes.md +0 -19
  131. /package/skills/{alloy-expert → ti-expert}/assets/ControllerAutoCleanup.js +0 -0
  132. /package/skills/{alloy-expert → ti-expert}/references/contracts.md +0 -0
@@ -2,42 +2,6 @@
2
2
 
3
3
  Strategies and techniques for building Titanium apps that work on iOS and Android from a single codebase.
4
4
 
5
- ## Table of Contents
6
-
7
- - [Cross-Platform Development](#cross-platform-development)
8
- - [Table of Contents](#table-of-contents)
9
- - [Philosophy](#philosophy)
10
- - ["Write Once, Adapt Everywhere"](#write-once-adapt-everywhere)
11
- - [Embrace the Platform](#embrace-the-platform)
12
- - [Platform Identification](#platform-identification)
13
- - [Platform Properties](#platform-properties)
14
- - [Best Practice: Cache Platform Checks](#best-practice-cache-platform-checks)
15
- - [Anti-Pattern: Don't Assume Binary](#anti-pattern-dont-assume-binary)
16
- - [Coding Strategies](#coding-strategies)
17
- - [1. Branching (For Mostly Similar Code)](#1-branching-for-mostly-similar-code)
18
- - [2. Platform-Specific Files (For Mostly Different Code)](#2-platform-specific-files-for-mostly-different-code)
19
- - [3. Single Execution Context (Recommended)](#3-single-execution-context-recommended)
20
- - [Platform-Specific Resources](#platform-specific-resources)
21
- - [Resource Overrides System](#resource-overrides-system)
22
- - [Assets (Alloy)](#assets-alloy)
23
- - [5. Webpack Build Pipeline (TiSDK 9.1.0+)](#5-webpack-build-pipeline-tisdk-910)
24
- - [`@` Alias](#-alias)
25
- - [NPM Support](#npm-support)
26
- - [6. Internationalization (i18n)](#6-internationalization-i18n)
27
- - [Using Localized Strings](#using-localized-strings)
28
- - [Date and Currency Formatting](#date-and-currency-formatting)
29
- - [Testing Localizations](#testing-localizations)
30
- - [Platform-Specific APIs](#platform-specific-apis)
31
- - [Example: Platform-Specific Properties](#example-platform-specific-properties)
32
- - [Common Cross-Platform Patterns](#common-cross-platform-patterns)
33
- - [Tab Groups](#tab-groups)
34
- - [Navigation](#navigation)
35
- - [Platform-Specific Event Handling](#platform-specific-event-handling)
36
- - [Best Practices](#best-practices)
37
- - [Resources](#resources)
38
-
39
- ---
40
-
41
5
  ## Philosophy
42
6
 
43
7
  ### "Write Once, Adapt Everywhere"
@@ -66,6 +30,19 @@ Best-of-breed apps feel **native** on each platform:
66
30
 
67
31
  **Develop for both platforms from the start** - much more efficient than porting later.
68
32
 
33
+ ### Android Platform Key Concepts
34
+ - **Screen sizes**: Classified as small, normal, large, xlarge (measured in dp). Use density-independent resources.
35
+ - **Screen densities**: ldpi (~120 dpi), mdpi (~160 dpi), hdpi (~240 dpi), xhdpi (~320 dpi), xxhdpi (~480 dpi), xxxhdpi (~640 dpi)
36
+ - **Activities**: Each heavy-weight Window maps to an Android Activity. Titanium auto-manages the Activity lifecycle.
37
+ - **Intents**: Used for inter-app and intra-app communication. See [android-platform-deep-dives.md](android-platform-deep-dives.md).
38
+ - **Back button**: Hardware/software back button closes current Window by default. Override with `window.addEventListener('androidback', ...)`.
39
+
40
+ ### iOS Platform Key Concepts
41
+ - **Human Interface Guidelines**: Apple enforces design standards through App Store review. Follow iOS conventions for navigation, tab bars, and gestures.
42
+ - **One-button design**: No hardware back or menu buttons — all navigation must be in the UI (NavigationWindow, back buttons).
43
+ - **Frameworks**: Titanium wraps UIKit, Foundation, MapKit, and other Cocoa Touch frameworks. Access additional frameworks via Hyperloop.
44
+ - **Developer account**: Requires paid Apple Developer Program membership for device testing and App Store distribution.
45
+
69
46
  ---
70
47
 
71
48
  ## Platform Identification
@@ -149,7 +126,14 @@ const ui = require('ui');
149
126
  // Carga: /android/ui.js en Android, /iphone/ui.js en iOS
150
127
  ```
151
128
 
152
- ### 3. Single Execution Context (Recommended)
129
+ ### 3. Execution Contexts
130
+
131
+ Titanium supports single-context and multi-context applications:
132
+
133
+ - **Single context (recommended)**: All windows share one JavaScript runtime. Use `require()` for modules and `Alloy.createController()` for views.
134
+ - **Multi-context (legacy)**: Using `Ti.UI.createWindow({ url: 'other.js' })` creates a separate JavaScript context. Variables are NOT shared between contexts.
135
+
136
+ > **Avoid multi-context apps.** Use CommonJS modules and `require()` instead. If you must communicate across contexts, use `Ti.App.fireEvent()` and `Ti.App.addEventListener()`.
153
137
 
154
138
  **Avoid multiple contexts:**
155
139
  ```javascript
@@ -217,6 +201,30 @@ For more details on optimization, diagnostics, and build Web UI, see:
217
201
 
218
202
  ## 6. Internationalization (i18n)
219
203
 
204
+ ### i18n Directory Structure
205
+ ```
206
+ i18n/
207
+ ├── en/
208
+ │ ├── strings.xml <!-- Default language -->
209
+ │ └── app.xml <!-- App name localization (Android) -->
210
+ ├── es/
211
+ │ ├── strings.xml
212
+ │ └── app.xml
213
+ └── ja/
214
+ └── strings.xml
215
+ ```
216
+
217
+ Use ISO 639-1 language codes (en, es, ja) and optionally ISO 3166-1 region codes (en-GB, pt-BR).
218
+
219
+ ### strings.xml Format
220
+ ```xml
221
+ <?xml version="1.0" encoding="UTF-8"?>
222
+ <resources>
223
+ <string name="welcome_message">Welcome to my app</string>
224
+ <string name="login_button">Log In</string>
225
+ </resources>
226
+ ```
227
+
220
228
  ### Using Localized Strings
221
229
 
222
230
  **Basic usage:**
@@ -224,6 +232,15 @@ For more details on optimization, diagnostics, and build Web UI, see:
224
232
  // Two equivalent methods
225
233
  const str1 = L('welcome_message');
226
234
  const str2 = Ti.Locale.getString('welcome_message');
235
+
236
+ // With a default fallback
237
+ const withDefault = L('missing_key', 'Default text');
238
+ ```
239
+
240
+ **In Alloy XML views — use `titleid` instead of `title`:**
241
+ ```xml
242
+ <Button titleid="login_button" />
243
+ <Label textid="welcome_message" />
227
244
  ```
228
245
 
229
246
  **String formatting:**
@@ -237,6 +254,18 @@ const formatted = String.format(L('ordered'), 'Jeff', 'Kevin');
237
254
  // Result: "Hi Jeff, my name is Kevin"
238
255
  ```
239
256
 
257
+ ### Localizing the App Name
258
+
259
+ **iOS (SDK 3.2.0+)**: Set `<key>CFBundleDisplayName</key>` in `i18n/LANG/app.xml`
260
+
261
+ **Android**: Use `<string name="appname">Mi App</string>` in `i18n/LANG/strings.xml`
262
+
263
+ ### Localizing Images and Files
264
+
265
+ Two approaches:
266
+ 1. **Platform folders**: Place localized images in `app/assets/iphone/LANG.lproj/` (iOS) or `app/assets/android/images/` with language qualifiers (Android)
267
+ 2. **Code-based**: Load different assets based on `Ti.Locale.currentLanguage`
268
+
240
269
  ### Date and Currency Formatting
241
270
 
242
271
  ```javascript
@@ -252,6 +281,8 @@ const price = String.formatCurrency(1234.56);
252
281
  const amount = String.formatDecimal(1234.56);
253
282
  ```
254
283
 
284
+ > **Warning (Android)**: `String.formatDate()` may produce incorrect translations or field ordering on some Android versions. Consider using JavaScript's `Date` methods directly as a workaround.
285
+
255
286
  ### Testing Localizations
256
287
 
257
288
  **iOS:**
@@ -2,54 +2,6 @@
2
2
 
3
3
  Comprehensive guide for debugging Titanium apps, managing memory, finding leaks, and using native debugging tools.
4
4
 
5
- ## Table of Contents
6
-
7
- - [Debugging and Profiling](#debugging-and-profiling)
8
- - [Table of Contents](#table-of-contents)
9
- - [Debugging Overview](#debugging-overview)
10
- - [Essential Elements of Debugging](#essential-elements-of-debugging)
11
- - [Debugging Techniques](#debugging-techniques)
12
- - [Memory Management](#memory-management)
13
- - [How JavaScript Manages Memory](#how-javascript-manages-memory)
14
- - [How Titanium Manages Memory](#how-titanium-manages-memory)
15
- - [Releasing Memory Properly](#releasing-memory-properly)
16
- - [Parent-Child Relationships](#parent-child-relationships)
17
- - [Platform Memory Limits](#platform-memory-limits)
18
- - [Memory Leak Detection](#memory-leak-detection)
19
- - [Common Leak Sources](#common-leak-sources)
20
- - [Debugging Memory on iOS (Instruments)](#debugging-memory-on-ios-instruments)
21
- - [Debugging Memory on Android (DDMS)](#debugging-memory-on-android-ddms)
22
- - [Android Debugging Tools](#android-debugging-tools)
23
- - [DDMS (Dalvik Debug Monitor Service)](#ddms-dalvik-debug-monitor-service)
24
- - [Log Output with DDMS](#log-output-with-ddms)
25
- - [Simulate Network Conditions](#simulate-network-conditions)
26
- - [Simulate Calls/SMS](#simulate-callssms)
27
- - [Set GPS Coordinates](#set-gps-coordinates)
28
- - [File System Exploration](#file-system-exploration)
29
- - [Memory Monitoring](#memory-monitoring)
30
- - [ADB (Android Debug Bridge)](#adb-android-debug-bridge)
31
- - [Log Output](#log-output)
32
- - [File System](#file-system)
33
- - [Transfer Files](#transfer-files)
34
- - [Access SQLite Databases](#access-sqlite-databases)
35
- - [Creating Emulators](#creating-emulators)
36
- - [Modifying Emulators](#modifying-emulators)
37
- - [iOS Debugging Tools](#ios-debugging-tools)
38
- - [Instruments](#instruments)
39
- - [Xcode Build Debugging](#xcode-build-debugging)
40
- - [Console Logs](#console-logs)
41
- - [6. Automation and UI Testing](#6-automation-and-ui-testing)
42
- - [Best Practices](#best-practices)
43
- - [Memory Management](#memory-management-1)
44
- - [Debugging](#debugging)
45
- - [Performance](#performance)
46
- - [Platform-Specific Notes](#platform-specific-notes)
47
- - [Android](#android)
48
- - [iOS](#ios)
49
- - [Resources](#resources)
50
-
51
- ---
52
-
53
5
  ## Debugging Overview
54
6
 
55
7
  ### Essential Elements of Debugging
@@ -165,6 +117,8 @@ button = null; // Now button is destroyed
165
117
  - "Jetsam" process can terminate your app
166
118
  - "Jetsam" in crash logs = memory issue
167
119
 
120
+ > **Important**: Memory ≠ storage. A 16GB device doesn't mean 16GB for your app. These limits may be higher on newer devices but always optimize for the lowest common denominator.
121
+
168
122
  ---
169
123
 
170
124
  ## Memory Leak Detection
@@ -455,11 +409,12 @@ window scale 0.75
455
409
 
456
410
  ### Instruments
457
411
 
458
- **Common Templates:**
459
- - **Allocations** - Memory usage
460
- - **Leaks** - Detect memory leaks
461
- - **Time Profiler** - CPU usage
462
- - **System Trace** - System-level events
412
+ **Key Templates for Titanium Debugging:**
413
+ - **Allocations** Track object creation and live object counts. Look at "Persistent Bytes" (or "Live Bytes") and "#Persistent" (or "#Living") columns to track memory growth.
414
+ - **Leaks** Detect memory leaks in real-time. Shows objects that are allocated but never released.
415
+ - **Time Profiler** Identify CPU-intensive operations and bottlenecks.
416
+ - **System Trace** System-level events and thread activity.
417
+ - **Zombies** — Detect messages sent to deallocated objects (debug builds only). Useful for tracking over-released objects.
463
418
 
464
419
  ### Xcode Build Debugging
465
420
 
@@ -1,56 +1,5 @@
1
1
  # Extending Titanium
2
2
 
3
- ## Table of Contents
4
-
5
- - [Extending Titanium](#extending-titanium)
6
- - [Table of Contents](#table-of-contents)
7
- - [1. Module Architecture (Core Concepts)](#1-module-architecture-core-concepts)
8
- - [Proxy-View Relationship](#proxy-view-relationship)
9
- - [2. Module Debugging in Xcode (iOS)](#2-module-debugging-in-xcode-ios)
10
- - [3. Upgrading to SDK 9.0.0+ (Android)](#3-upgrading-to-sdk-900-android)
11
- - [4. Hyperloop](#4-hyperloop)
12
- - [What is Hyperloop?](#what-is-hyperloop)
13
- - [Prerequisites](#prerequisites)
14
- - [Hyperloop Basics](#hyperloop-basics)
15
- - [iOS Hyperloop Examples](#ios-hyperloop-examples)
16
- - [Access iOS Frameworks](#access-ios-frameworks)
17
- - [Access UIKit](#access-uikit)
18
- - [Make Native HTTP Request](#make-native-http-request)
19
- - [Access CoreBluetooth (Bluetooth LE)](#access-corebluetooth-bluetooth-le)
20
- - [Access AVFoundation (Camera/Video)](#access-avfoundation-cameravideo)
21
- - [Access Address Book (Contacts)](#access-address-book-contacts)
22
- - [Access CoreLocation (Enhanced)](#access-corelocation-enhanced)
23
- - [Android Hyperloop Examples](#android-hyperloop-examples)
24
- - [Access Android Frameworks](#access-android-frameworks)
25
- - [Access Vibrator](#access-vibrator)
26
- - [Access TelephonyManager](#access-telephonymanager)
27
- - [Access WiFi Manager](#access-wifi-manager)
28
- - [Access PackageManager](#access-packagemanager)
29
- - [Hyperloop Best Practices](#hyperloop-best-practices)
30
- - [3. Native Module Development](#3-native-module-development)
31
- - [When to Create Native Modules](#when-to-create-native-modules)
32
- - [Android Module Development](#android-module-development)
33
- - [Quick Start](#quick-start)
34
- - [Use in Titanium app](#use-in-titanium-app)
35
- - [Common Android Module Patterns](#common-android-module-patterns)
36
- - [iOS Module Development](#ios-module-development)
37
- - [Quick Start](#quick-start-1)
38
- - [Common iOS Module Patterns](#common-ios-module-patterns)
39
- - [Module Distribution](#module-distribution)
40
- - [Packaging](#packaging)
41
- - [Installing Module](#installing-module)
42
- - [Module Configuration in tiapp.xml](#module-configuration-in-tiappxml)
43
- - [4. Choosing Between Hyperloop and Native Modules](#4-choosing-between-hyperloop-and-native-modules)
44
- - [Use Hyperloop When](#use-hyperloop-when)
45
- - [Use Native Modules When](#use-native-modules-when)
46
- - [5. Finding and Using Third-Party Modules](#5-finding-and-using-third-party-modules)
47
- - [Ti\_slack Marketplace](#ti_slack-marketplace)
48
- - [Popular Third-Party Modules](#popular-third-party-modules)
49
- - [Using Third-Party Modules](#using-third-party-modules)
50
- - [Best Practices Summary](#best-practices-summary)
51
-
52
- ---
53
-
54
3
  ## 1. Module Architecture (Core Concepts)
55
4
 
56
5
  Titanium modules are based on a native class hierarchy that communicates with JavaScript:
@@ -63,6 +12,18 @@ Titanium modules are based on a native class hierarchy that communicates with Ja
63
12
  ### Proxy-View Relationship
64
13
  The `ViewProxy` maintains properties in JS even if the native view does not exist yet. When the view is added to the hierarchy, the Proxy instantiates the native `View` and passes all accumulated properties to it.
65
14
 
15
+ ### Threading Considerations
16
+ - JavaScript in Titanium is **single-threaded**. All JS callbacks execute on the JS runtime thread.
17
+ - Native modules can use background threads for heavy work, but UI operations must happen on the main/UI thread.
18
+ - On iOS, each Window with a `url` property gets its own JavaScript context and thread — avoid this pattern.
19
+ - Use `@Kroll.method(runOnUiThread=true)` (Android) to ensure a method runs on the UI thread.
20
+
21
+ ### Key Android Kroll Annotations
22
+ - `@Kroll.method` — expose a Java method to JavaScript
23
+ - `@Kroll.getProperty` / `@Kroll.setProperty` — expose getter/setter properties
24
+ - `@Kroll.onAppCreate` — annotate a static method to run when the app process starts
25
+ - `propertyAccessors` element in `@Kroll.proxy` — auto-generate getter/setter methods
26
+
66
27
  ## 2. Module Debugging in Xcode (iOS)
67
28
 
68
29
  You can debug your native module directly within a Titanium project:
@@ -2,27 +2,6 @@
2
2
 
3
3
  Guide for implementing native maps on Android using the `ti.map` module (v2).
4
4
 
5
- ## Table of Contents
6
-
7
- - [Google Maps v2 for Android](#google-maps-v2-for-android)
8
- - [Table of Contents](#table-of-contents)
9
- - [1. Initial Configuration](#1-initial-configuration)
10
- - [Module Installation](#module-installation)
11
- - [Obtaining an API Key (Google Cloud Console)](#obtaining-an-api-key-google-cloud-console)
12
- - [Get SHA-1 (Debug)](#get-sha-1-debug)
13
- - [Configure tiapp.xml](#configure-tiappxml)
14
- - [2. Google Play Services Verification](#2-google-play-services-verification)
15
- - [3. Using the Map View](#3-using-the-map-view)
16
- - [Basic Creation](#basic-creation)
17
- - [Map Types](#map-types)
18
- - [4. Advanced Annotations (Pins)](#4-advanced-annotations-pins)
19
- - [Available Pin Colors](#available-pin-colors)
20
- - [5. Routes (Polylines)](#5-routes-polylines)
21
- - [6. Critical Events](#6-critical-events)
22
- - [7. Limitations and Troubleshooting](#7-limitations-and-troubleshooting)
23
-
24
- ---
25
-
26
5
  ## 1. Initial Configuration
27
6
 
28
7
  ### Module Installation
@@ -66,16 +45,20 @@ const rc = MapModule.isGooglePlayServicesAvailable();
66
45
 
67
46
  switch (rc) {
68
47
  case MapModule.SUCCESS:
69
- Ti.API.info('Google Play services is installed.');
48
+ Ti.API.info('Google Play Services available');
70
49
  break;
71
50
  case MapModule.SERVICE_MISSING:
72
- alert('Google Play services is missing. Please install it.');
51
+ Ti.API.error('Google Play Services is missing');
73
52
  break;
74
53
  case MapModule.SERVICE_VERSION_UPDATE_REQUIRED:
75
- alert('Google Play services is out of date. Please update.');
54
+ Ti.API.error('Google Play Services needs update');
55
+ break;
56
+ case MapModule.SERVICE_DISABLED:
57
+ Ti.API.error('Google Play Services is disabled');
58
+ break;
59
+ case MapModule.SERVICE_INVALID:
60
+ Ti.API.error('Google Play Services is invalid');
76
61
  break;
77
- default:
78
- alert(`Google Play services error: ${rc}`);
79
62
  }
80
63
  ```
81
64
 
@@ -122,6 +105,13 @@ const opera = MapModule.createAnnotation({
122
105
  mapView.addAnnotation(opera);
123
106
  ```
124
107
 
108
+ ### Additional Annotation Properties
109
+ - `customView` — a `Ti.UI.View` that replaces the entire annotation (takes precedence over `image`)
110
+ - `centerOffset` — `{x, y}` point to offset the annotation from the coordinate
111
+ - `canShowCallout` — whether tapping shows the info bubble (default: `true`)
112
+
113
+ > **Precedence**: `customView` > `image` > default pin. For buttons: `leftView`/`rightView` take precedence over `leftButton`/`rightButton`.
114
+
125
115
  ### Available Pin Colors
126
116
  `ANNOTATION_AZURE`, `BLUE`, `CYAN`, `GREEN`, `MAGENTA`, `ORANGE`, `RED`, `ROSE`, `VIOLET`, `YELLOW`.
127
117
 
@@ -152,10 +142,17 @@ mapView.addEventListener('click', (e) => {
152
142
 
153
143
  // Detect drag state changes
154
144
  mapView.addEventListener('pinchangedragstate', (e) => {
155
- if (e.newState === MapModule.ANNOTATION_DRAG_STATE_END) {
156
- Ti.API.info(`New position: ${e.annotation.latitude}`);
145
+ if (e.annotation.dragState === MapModule.ANNOTATION_DRAG_STATE_END) {
146
+ Ti.API.info(`Dropped at: ${e.annotation.latitude}, ${e.annotation.longitude}`);
157
147
  }
158
148
  });
149
+ // Drag states: ANNOTATION_DRAG_STATE_START, ANNOTATION_DRAG_STATE_DRAG,
150
+ // ANNOTATION_DRAG_STATE_CANCEL, ANNOTATION_DRAG_STATE_END
151
+
152
+ // Detect region changes
153
+ mapView.addEventListener('regionchanged', (e) => {
154
+ Ti.API.info(`New region: ${e.latitude}, ${e.longitude} (delta: ${e.latitudeDelta}, ${e.longitudeDelta})`);
155
+ });
159
156
 
160
157
  // Detect complete rendering
161
158
  mapView.addEventListener('complete', (e) => {
@@ -163,7 +160,11 @@ mapView.addEventListener('complete', (e) => {
163
160
  });
164
161
  ```
165
162
 
166
- ## 7. Limitations and Troubleshooting
163
+ ## 7. Migration from Legacy Titanium.Map
164
+
165
+ > **Note**: The `ti.map` module replaced the legacy `Titanium.Map` API. Key differences: use `NORMAL_TYPE` instead of `STANDARD_TYPE`, `ANNOTATION_VIOLET` instead of `ANNOTATION_PURPLE`, and routes are created with `Map.createRoute()` instead of abstract data types. Multiple MapView instances are supported.
166
+
167
+ ## 8. Limitations and Troubleshooting
167
168
  - **Single Map:** Android (legacy) only allows one MapView instance per application. v2 allows multiple views.
168
169
  - **Blank Map:** Verify the API Key is correct and that `android:anyDensity` is NOT set to true in the manifest if using old resolutions.
169
170
  - **Simulator:** Google Maps v2 is NOT compatible with the standard emulator without x86 Google Play Services. Real device testing is recommended.
@@ -2,25 +2,6 @@
2
2
 
3
3
  Guide for implementing native maps on iOS using the `ti.map` module.
4
4
 
5
- ## Table of Contents
6
-
7
- - [iOS Map Kit](#ios-map-kit)
8
- - [Table of Contents](#table-of-contents)
9
- - [1. Initial Configuration](#1-initial-configuration)
10
- - [Module Installation](#module-installation)
11
- - [Location Permissions (Info.plist)](#location-permissions-infoplist)
12
- - [2. Using the Map View](#2-using-the-map-view)
13
- - [Basic Creation](#basic-creation)
14
- - [3. 3D Camera (Perspective)](#3-3d-camera-perspective)
15
- - [4. iOS Annotations](#4-ios-annotations)
16
- - [System Buttons and Callouts](#system-buttons-and-callouts)
17
- - [Center Offset](#center-offset)
18
- - [5. Advanced Routes](#5-advanced-routes)
19
- - [Overlay Levels](#overlay-levels)
20
- - [6. Events](#6-events)
21
-
22
- ---
23
-
24
5
  ## 1. Initial Configuration
25
6
 
26
7
  ### Module Installation
@@ -46,13 +27,15 @@ Add the mandatory usage descriptions in `tiapp.xml`:
46
27
  </ios>
47
28
  ```
48
29
 
30
+ > **iOS 11+**: You must include both `NSLocationWhenInUseUsageDescription` AND `NSLocationAlwaysAndWhenInUseUsageDescription` in your plist. Users can choose "When in Use" even when your app requests "Always" authorization.
31
+
49
32
  ## 2. Using the Map View
50
33
 
51
34
  ### Basic Creation
52
35
  ```javascript
53
36
  const MapModule = require('ti.map');
54
37
  const mapView = MapModule.createView({
55
- mapType: MapModule.NORMAL_TYPE,
38
+ mapType: MapModule.NORMAL_TYPE, // Also: SATELLITE_TYPE, HYBRID_TYPE, STANDARD_TYPE (alias for NORMAL_TYPE with labels)
56
39
  userLocation: true,
57
40
  rotatesEnabled: true, // Allow two-finger rotation
58
41
  region: {
@@ -68,6 +51,8 @@ const mapView = MapModule.createView({
68
51
 
69
52
  iOS allows tilting and rotating the map programmatically for 3D views.
70
53
 
54
+ > **Important**: The map view must be visible on screen before using camera APIs. Wait for the map's `complete` event before calling `animateCamera()` or setting camera properties.
55
+
71
56
  ```javascript
72
57
  const myCam = MapModule.createCamera({
73
58
  altitude: 300, // Meters above ground
@@ -103,7 +88,7 @@ const bridge = MapModule.createAnnotation({
103
88
  // iOS system buttons in the callout
104
89
  leftButton: Ti.UI.iOS.SystemButton.INFO_DARK,
105
90
  rightButton: Ti.UI.iOS.SystemButton.CONTACT_ADD,
106
- canShowCallout: true // Default is true
91
+ canShowCallout: true // Controls whether tapping the annotation shows the callout bubble (default: true)
107
92
  });
108
93
 
109
94
  mapView.addAnnotation(bridge);
@@ -124,15 +109,18 @@ const customPin = MapModule.createAnnotation({
124
109
  Control if the route goes above labels or above roads.
125
110
  ```javascript
126
111
  const route = MapModule.createRoute({
127
- points: [...],
128
- color: 'blue',
112
+ points: routePoints,
113
+ color: '#00f',
129
114
  width: 4,
130
- // OVERLAY_LEVEL_ABOVE_LABELS or OVERLAY_LEVEL_ABOVE_ROADS
131
- level: MapModule.OVERLAY_LEVEL_ABOVE_LABELS
115
+ level: MapModule.OVERLAY_LEVEL_ABOVE_LABELS // default
116
+ // or MapModule.OVERLAY_LEVEL_ABOVE_ROADS (below labels)
132
117
  });
133
118
  ```
134
119
 
135
120
  ## 6. Events
121
+
122
+ Key map events: `click`, `complete` (map loaded), `regionchanged`, `pinchangedragstate`.
123
+
136
124
  Same as Android, but with specialized `clicksource` for system buttons:
137
125
  ```javascript
138
126
  mapView.addEventListener('click', (e) => {
@@ -140,4 +128,10 @@ mapView.addEventListener('click', (e) => {
140
128
  Ti.API.info('Callout button clicked');
141
129
  }
142
130
  });
131
+
132
+ mapView.addEventListener('pinchangedragstate', (e) => {
133
+ if (e.annotation.dragState === MapModule.ANNOTATION_DRAG_STATE_END) {
134
+ Ti.API.info(`Dropped at: ${e.annotation.latitude}, ${e.annotation.longitude}`);
135
+ }
136
+ });
143
137
  ```