@maccesar/titools 5.2.5 → 5.4.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 (138) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +58 -97
  3. package/agents/ti-pro.md +4 -2
  4. package/commands/ti-audit.md +7 -5
  5. package/docs/examples.md +24 -13
  6. package/docs/knowledge-index.md +2 -1
  7. package/lib/config.js +1 -0
  8. package/package.json +1 -1
  9. package/skills/alloy-guides/SKILL.md +18 -179
  10. package/skills/alloy-guides/references/CLI_TASKS.md +17 -216
  11. package/skills/alloy-guides/references/CONCEPTS.md +27 -162
  12. package/skills/alloy-guides/references/CONTROLLERS.md +38 -236
  13. package/skills/alloy-guides/references/MODELS.md +47 -723
  14. package/skills/alloy-guides/references/MODELS_ADVANCED.md +21 -482
  15. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +12 -222
  16. package/skills/alloy-guides/references/VIEWS_STYLES.md +39 -358
  17. package/skills/alloy-guides/references/VIEWS_XML.md +36 -552
  18. package/skills/alloy-guides/references/WIDGETS.md +49 -127
  19. package/skills/alloy-howtos/SKILL.md +14 -169
  20. package/skills/alloy-howtos/references/best_practices.md +9 -113
  21. package/skills/alloy-howtos/references/cli_reference.md +18 -223
  22. package/skills/alloy-howtos/references/config_files.md +50 -133
  23. package/skills/alloy-howtos/references/debugging_troubleshooting.md +19 -63
  24. package/skills/alloy-howtos/references/samples.md +21 -138
  25. package/skills/ti-api/SKILL.md +10 -2
  26. package/skills/ti-api/references/api-android.md +36 -2
  27. package/skills/ti-api/references/api-app-platform.md +39 -3
  28. package/skills/ti-api/references/api-core.md +50 -18
  29. package/skills/ti-api/references/api-data-network.md +49 -35
  30. package/skills/ti-api/references/api-media.md +45 -27
  31. package/skills/ti-api/references/api-services.md +39 -9
  32. package/skills/ti-api/references/api-ui-android.md +33 -13
  33. package/skills/ti-api/references/api-ui-extras.md +41 -15
  34. package/skills/ti-api/references/api-ui-ios-animator.md +42 -26
  35. package/skills/ti-api/references/api-ui-ios.md +74 -2
  36. package/skills/ti-api/references/api-ui-lists.md +32 -16
  37. package/skills/ti-api/references/api-ui-text-input.md +34 -17
  38. package/skills/ti-api/references/api-ui-views.md +27 -1
  39. package/skills/ti-api/references/api-ui-windows-navigation.md +32 -18
  40. package/skills/ti-api/references/api-xml-global.md +66 -16
  41. package/skills/ti-create-release/SKILL.md +98 -0
  42. package/skills/ti-create-release/references/module-discovery.md +69 -0
  43. package/skills/ti-expert/references/adaptive-layouts.md +1 -1
  44. package/skills/ti-guides/SKILL.md +37 -76
  45. package/skills/ti-guides/references/advanced-data-and-images.md +122 -126
  46. package/skills/ti-guides/references/android-manifest.md +24 -83
  47. package/skills/ti-guides/references/app-distribution.md +31 -377
  48. package/skills/ti-guides/references/application-frameworks.md +127 -335
  49. package/skills/ti-guides/references/cli-reference.md +184 -633
  50. package/skills/ti-guides/references/commonjs-advanced.md +81 -231
  51. package/skills/ti-guides/references/compatibility-matrix.md +36 -75
  52. package/skills/ti-guides/references/hello-world.md +95 -70
  53. package/skills/ti-guides/references/hyperloop-native-access.md +52 -448
  54. package/skills/ti-guides/references/resources.md +174 -142
  55. package/skills/ti-guides/references/sdk-release-notes.md +28 -71
  56. package/skills/ti-guides/references/tiapp-config.md +222 -598
  57. package/skills/ti-howtos/SKILL.md +23 -123
  58. package/skills/ti-howtos/references/cross-platform-development.md +119 -324
  59. package/skills/ti-howtos/references/debugging-profiling.md +77 -445
  60. package/skills/ti-howtos/references/extending-titanium.md +199 -673
  61. package/skills/ti-howtos/references/local-data-sources.md +87 -300
  62. package/skills/ti-howtos/references/location-and-maps.md +86 -213
  63. package/skills/ti-howtos/references/media-apis.md +103 -223
  64. package/skills/ti-howtos/references/notification-services.md +86 -506
  65. package/skills/ti-howtos/references/remote-data-sources.md +97 -316
  66. package/skills/ti-howtos/references/using-modules.md +77 -133
  67. package/skills/ti-synthengine/SKILL.md +62 -111
  68. package/skills/ti-synthengine/assets/example/README.md +50 -59
  69. package/skills/ti-synthengine/assets/example/app.js +67 -65
  70. package/skills/ti-synthengine/assets/example/lib/sequenceOwner.js +39 -40
  71. package/skills/ti-synthengine/assets/example/lib/soundPreset.js +34 -0
  72. package/skills/ti-synthengine/assets/index.d.ts +122 -2
  73. package/skills/ti-synthengine/references/advanced-examples.md +4 -4
  74. package/skills/ti-synthengine/references/api.md +40 -18
  75. package/skills/ti-synthengine/references/audio-engine.md +15 -57
  76. package/skills/ti-synthengine/references/examples.md +63 -6
  77. package/skills/ti-synthengine/references/guide.md +61 -57
  78. package/skills/ti-synthengine/references/instruments-and-effects.md +15 -15
  79. package/skills/ti-synthengine/references/native-variation.md +53 -14
  80. package/skills/ti-synthengine/references/recipes-interaction.md +25 -20
  81. package/skills/ti-synthengine/references/recipes.md +19 -16
  82. package/skills/ti-synthengine/references/recommendations.md +12 -12
  83. package/skills/ti-synthengine/references/sound-api.md +197 -0
  84. package/skills/ti-synthengine/references/sound-design.md +7 -7
  85. package/skills/ti-synthengine/references/source-notes.md +62 -172
  86. package/skills/ti-synthengine/references/troubleshooting.md +17 -19
  87. package/skills/ti-synthengine/references/upgrade-2.0.0.md +40 -0
  88. package/skills/ti-ui/SKILL.md +28 -143
  89. package/skills/ti-ui/references/icons-and-splash-screens.md +74 -403
  90. package/skills/ti-ui/references/layouts-and-positioning.md +175 -402
  91. package/skills/ti-ui/references/listviews-and-performance.md +100 -703
  92. package/skills/ti-ui/references/platform-conventions.md +180 -0
  93. package/skills/ti-ui/references/user-interface.md +43 -0
  94. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
  95. package/skills/alloy-howtos/references/custom_tags.md +0 -148
  96. package/skills/ti-guides/references/coding-best-practices.md +0 -149
  97. package/skills/ti-guides/references/javascript-primer.md +0 -414
  98. package/skills/ti-guides/references/reserved-words.md +0 -36
  99. package/skills/ti-guides/references/style-and-conventions.md +0 -103
  100. package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -624
  101. package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
  102. package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
  103. package/skills/ti-howtos/references/google-maps-v2.md +0 -172
  104. package/skills/ti-howtos/references/ios-map-kit.md +0 -149
  105. package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -611
  106. package/skills/ti-howtos/references/tutorials.md +0 -565
  107. package/skills/ti-howtos/references/web-content-integration.md +0 -287
  108. package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -124
  109. package/skills/ti-synthengine/references/android-sim80-correction-evidence.zip +0 -0
  110. package/skills/ti-synthengine/references/android-sim80-correction.json +0 -162
  111. package/skills/ti-synthengine/references/audio-pipeline-validation.md +0 -19
  112. package/skills/ti-synthengine/references/bypass-physical-recheck-evidence.zip +0 -0
  113. package/skills/ti-synthengine/references/frontier-android-evidence.zip +0 -0
  114. package/skills/ti-synthengine/references/frontier-ipad-evidence.zip +0 -0
  115. package/skills/ti-synthengine/references/frontier-physical-validation.json +0 -1918
  116. package/skills/ti-synthengine/references/native-tone-repetition-validation.md +0 -59
  117. package/skills/ti-synthengine/references/native-variation-proposal.md +0 -182
  118. package/skills/ti-synthengine/references/native-variation-validation.md +0 -63
  119. package/skills/ti-synthengine/references/performance-review-evidence.zip +0 -0
  120. package/skills/ti-synthengine/references/performance-review.json +0 -1146
  121. package/skills/ti-synthengine/references/physical-validation.json +0 -1457
  122. package/skills/ti-synthengine/references/source-snapshot.json +0 -542
  123. package/skills/ti-synthengine/references/stats-performance.json +0 -2992
  124. package/skills/ti-synthengine/references/stats-performance.md +0 -82
  125. package/skills/ti-synthengine/references/studio-validation.json +0 -6202
  126. package/skills/ti-synthengine/references/unified-bypass-performance.json +0 -22425
  127. package/skills/ti-synthengine/references/unified-validation.json +0 -314
  128. package/skills/ti-ui/references/accessibility-deep-dive.md +0 -288
  129. package/skills/ti-ui/references/animation-and-matrices.md +0 -569
  130. package/skills/ti-ui/references/application-structures.md +0 -626
  131. package/skills/ti-ui/references/custom-fonts-styling.md +0 -549
  132. package/skills/ti-ui/references/event-handling.md +0 -401
  133. package/skills/ti-ui/references/gestures.md +0 -448
  134. package/skills/ti-ui/references/orientation.md +0 -374
  135. package/skills/ti-ui/references/platform-ui-android.md +0 -727
  136. package/skills/ti-ui/references/platform-ui-ios.md +0 -576
  137. package/skills/ti-ui/references/scrolling-views.md +0 -288
  138. package/skills/ti-ui/references/tableviews.md +0 -542
@@ -1,479 +1,83 @@
1
- # Hyperloop: native API access
1
+ # Hyperloop
2
2
 
3
- Hyperloop lets you access native APIs (iOS Objective-C/Swift and Android Java/Kotlin) directly from JavaScript. It ships with the Titanium SDK and works as a native module.
4
3
 
5
- <!-- TOC-START -->
6
- ## Contents
4
+ Hyperloop lets JavaScript call native classes directly. Instead of writing a
5
+ module to wrap `UIImpactFeedbackGenerator`, you require it and use it.
7
6
 
8
- - [1. Requirements](#1-requirements)
9
- - [2. Enabling Hyperloop](#2-enabling-hyperloop)
10
- - [3. Framework namespace conventions](#3-framework-namespace-conventions)
11
- - [4. iOS (Objective-C)](#4-ios-objective-c)
12
- - [5. iOS: creating custom classes](#5-ios-creating-custom-classes)
13
- - [6. iOS: CocoaPods support](#6-ios-cocoapods-support)
14
- - [7. iOS: Swift support](#7-ios-swift-support)
15
- - [8. iOS: XIB and Storyboards](#8-ios-xib-and-storyboards)
16
- - [9. iOS: customizing the Xcode build](#9-ios-customizing-the-xcode-build)
17
- - [10. Android (Java)](#10-android-java)
18
- - [11. Android: native XML layouts](#11-android-native-xml-layouts)
19
- - [12. Android: third-party libraries](#12-android-third-party-libraries)
20
- - [13. Debugging Hyperloop](#13-debugging-hyperloop)
21
- - [14. Performance tips](#14-performance-tips)
22
- - [15. Sample projects](#15-sample-projects)
7
+ ```js
8
+ const UIImpactFeedbackGenerator = require('UIKit/UIImpactFeedbackGenerator');
23
9
 
24
- <!-- TOC-END -->
25
-
26
- ## 1. Requirements
27
-
28
- - Titanium SDK: 9.0.0+
29
- - Titanium CLI: 7.0.0+
30
- - Alloy (optional): 1.8.0+
31
- - CocoaPods (optional, iOS only): 1.0.0+
32
- - Xcode location: must be at `/Applications/Xcode.app`. Hyperloop uses a bundled Xcode library to inspect native APIs. If Xcode is in a non-default location while another installation exists in the default folder, metadata errors can occur.
33
-
34
- ## 2. Enabling Hyperloop
35
-
36
- Add the Hyperloop module to your `tiapp.xml`:
37
-
38
- ```xml
39
- <modules>
40
- <module>hyperloop</module>
41
- </modules>
42
- ```
43
-
44
- The `run-on-main-thread` property should already be in `tiapp.xml` by default:
45
- ```xml
46
- <property name="run-on-main-thread" type="bool">true</property>
47
- ```
48
-
49
- Do not name your app "Hyperloop" in `tiapp.xml`. It is a reserved word and will cause build failures.
50
-
51
- ## 3. Framework namespace conventions
52
-
53
- Each platform uses different `require()` conventions.
54
-
55
- iOS: use `Framework/Class` with a forward slash:
56
- ```javascript
57
- const UIView = require('UIKit/UIView');
58
- const NSBundle = require('Foundation/NSBundle');
59
- const UIColor = require('UIKit/UIColor');
60
- ```
61
-
62
- Android: use the full Java package with dots:
63
- ```javascript
64
- const View = require('android.view.View');
65
- const Activity = require('android.app.Activity');
66
- const Context = require('android.content.Context');
67
- ```
68
-
69
- ## 4. iOS (Objective-C)
70
-
71
- ### Instantiation: `new` vs `alloc().init()`
72
-
73
- - `new Class()` is equivalent to `alloc().init()`. It only calls the default initializer (`init`).
74
- - `Class.alloc().initWith*()` is for special initializers that take arguments.
75
-
76
- ```javascript
77
- const UIView = require('UIKit/UIView');
78
-
79
- // Default initializer (both are equivalent)
80
- const view1 = new UIView();
81
- const view2 = UIView.alloc().init();
82
-
83
- // Special initializer with arguments
84
- const CGRectMake = require('CoreGraphics').CGRectMake;
85
- const view3 = UIView.alloc().initWithFrame(CGRectMake(0, 0, 100, 100));
86
- ```
87
-
88
- ### Named methods (selector concatenation)
89
-
90
- Selectors with multiple parameters are camel-cased and colons are removed. Arguments are passed in the same order as in Objective-C.
91
-
92
- Selector `addAttribute:value:range:` becomes `addAttributeValueRange(attr, val, range)`.
93
-
94
- ```javascript
95
- // Objective-C: [myView insertSubview:anotherView atIndex:0]
96
- myView.insertSubviewAtIndex(anotherView, 0);
97
-
98
- // Objective-C: [UIView animateWithDuration:1.0 animations:^{} completion:^(BOOL){}]
99
- UIView.animateWithDurationAnimationsCompletion(1.0, () => {
100
- view.layer.opacity = 0.0;
101
- }, (finished) => {
102
- // Animation completed
103
- });
104
- ```
105
-
106
- ### Properties
107
-
108
- Objective-C properties map to JavaScript property accessors. Auto-generated setters are also available:
109
- ```javascript
110
- view.backgroundColor = UIColor.redColor;
111
- // or
112
- view.setBackgroundColor(UIColor.redColor);
113
- ```
114
-
115
- ### Casting
116
-
117
- Use `Class.cast(object)` to convert a generic return type (`NSObject` / `id`) or a Titanium proxy to a native view:
118
- ```javascript
119
- const UIView = require('UIKit/UIView');
120
-
121
- // Cast a generic object
122
- const view = UIView.cast(someObject);
123
-
124
- // Cast a Titanium view to its native equivalent
125
- const tiView = Ti.UI.createView({ backgroundColor: 'red' });
126
- const nativeView = UIView.cast(tiView);
127
- ```
128
-
129
- Be careful with casting. Casting to the wrong type can crash.
130
-
131
- ### Blocks
132
-
133
- Blocks are translated to JavaScript callback functions:
134
- ```javascript
135
- const UIView = require('UIKit/UIView');
136
-
137
- UIView.animateWithDurationAnimationsCompletion(1.0, () => {
138
- view.layer.opacity = 0.0;
139
- }, (done) => {
140
- // Animation completed
141
- });
142
- ```
143
-
144
- ### Constants, enumerations, and functions
145
-
146
- Framework-level constants and enums are accessed by requiring the framework itself:
147
- ```javascript
148
- const UIKit = require('UIKit');
149
- const unspecified = UIKit.UISemanticContentAttributeUnspecified;
150
- view.semanticContentAttribute = unspecified;
151
- ```
152
-
153
- ### TiApp utility class
154
-
155
- Access Titanium's app instance for the app delegate, key window, and app-level properties:
156
- ```javascript
157
- const TiApp = require('TiApp/TiApp');
158
- const app = TiApp.app();
159
- ```
160
-
161
- ## 5. iOS: creating custom classes
162
-
163
- Use `Hyperloop.defineClass()` to create Objective-C classes at runtime:
164
-
165
- ```javascript
166
- // defineClass(className, superClass, protocolsArray)
167
- const MyView = Hyperloop.defineClass('MyView', 'UIView', ['UIAppearance']);
168
- ```
169
-
170
- Add methods with `addMethod()`:
171
- ```javascript
172
- MyView.addMethod({
173
- selector: 'drawRect:',
174
- instance: true,
175
- arguments: ['CGRect'],
176
- callback: function(rect) {
177
- // Called when drawRect: is invoked
178
- }
179
- });
180
- ```
181
-
182
- Methods with multiple arguments and return types:
183
- ```javascript
184
- MyView.addMethod({
185
- selector: 'foo:bar:hello:',
186
- instance: true,
187
- returnType: 'void',
188
- arguments: ['int', 'float', 'id'],
189
- callback: function(a, b, c) {
190
- // Invoked when the method is called
191
- }
192
- });
193
- ```
194
-
195
- `addMethod` properties:
196
- - `selector`: Objective-C selector string
197
- - `instance`: `true` for instance methods, `false` for class methods
198
- - `arguments`: array or string of argument types (Objective-C encoding types or general types like `float`, `int`, `id`)
199
- - `returnType`: string return type (omit for `void`)
200
- - `callback`: JavaScript implementation
201
-
202
- Instantiate the custom class normally:
203
- ```javascript
204
- const myView = new MyView();
205
- ```
206
-
207
- ## 6. iOS: CocoaPods support
208
-
209
- ### Installation
210
-
211
- Install CocoaPods if needed:
212
- ```bash
213
- sudo gem install cocoapods
214
- ```
215
-
216
- ### Podfile configuration
217
-
218
- Create a `Podfile` in your Titanium project root:
219
- ```ruby
220
- # Required for CocoaPods 1.x
221
- install! 'cocoapods',
222
- :integrate_targets => false
223
-
224
- platform :ios, '12.0'
225
- target 'YourProjectName' do
226
- pod 'SomeLibrary'
227
- end
228
- ```
229
-
230
- Replace `YourProjectName` with your Titanium project name.
231
-
232
- ### Using the pod
233
-
234
- ```javascript
235
- const JBBarChartView = require('JBChartView/JBBarChartView');
236
- const chart = new JBBarChartView();
237
- chart.minimumValue = 1;
238
- chart.maximumValue = 100;
239
- ```
240
-
241
- ### Bitcode handling for Ad Hoc builds
242
-
243
- If your build fails due to mixed Bitcode frameworks, disable Bitcode in your Podfile:
244
- ```ruby
245
- post_install do |installer|
246
- installer.pods_project.targets.each do |target|
247
- target.build_configurations.each do |config|
248
- config.build_settings['ENABLE_BITCODE'] = 'NO'
249
- end
250
- end
251
- end
252
- ```
253
-
254
- ### Custom frameworks (without CocoaPods)
255
-
256
- Drop native iOS frameworks (static or dynamic) into `app/platform/ios` (Alloy) or `platform/ios` (Classic). They will be detected and linked.
257
-
258
- ## 7. iOS: Swift support
259
-
260
- Hyperloop supports Swift classes alongside Objective-C:
261
- - Swift and Objective-C classes can be mixed in the same app
262
- - Use the same `require()` syntax for Swift classes
263
- - For Swift frameworks via CocoaPods, use the `use_frameworks!` flag in your Podfile
264
-
265
- ## 8. iOS: XIB and Storyboards
266
-
267
- XIB files and Storyboards must be loaded programmatically. Place them in `app/assets/iphone` (Alloy) or `Resources/iphone` (Classic) and they will be compiled automatically.
268
-
269
- ```javascript
270
- const NSBundle = require('Foundation/NSBundle');
271
- const UINib = require('UIKit/UINib');
272
-
273
- const nib = UINib.nibWithNibNameBundle('MyView', NSBundle.mainBundle);
274
- const objects = nib.instantiateWithOwnerOptions(null, null);
275
- ```
276
-
277
- The following resources are compiled automatically: `*.storyboard`, `*.xcdatamodel`, `*.xcdatamodeld`, `*.xcmappingmodel`, `*.xib`.
278
-
279
- ## 9. iOS: customizing the Xcode build
280
-
281
- > **⚠️ Legacy: `appc.js`**
282
- > The `appc.js` file was an Appcelerator/AMPLIFY Platform hook. It is no longer supported. For modern Titanium projects, use `tiapp.xml` or native Xcode project settings for build customization.
283
-
284
- For historical reference, `appc.js` at the project root passed custom flags to `xcodebuild`:
285
- ```javascript
286
- module.exports = {
287
- hyperloop: {
288
- ios: {
289
- xcodebuild: {
290
- flags: {
291
- GCC_PREPROCESSOR_DEFINITIONS: 'foo=bar'
292
- }
293
- }
294
- }
295
- }
296
- };
297
- ```
298
-
299
- ## 10. Android (Java)
300
-
301
- ### Activity context
302
-
303
- Most Android view constructors require an Activity context:
304
- ```javascript
305
- const Activity = require('android.app.Activity');
306
- const activity = new Activity(Ti.Android.currentActivity);
307
- ```
308
-
309
- ### Methods and fields
310
-
311
- Java methods map to JavaScript functions. Java fields map to JavaScript property accessors. Static methods and constants are attached to the class type:
312
- ```javascript
313
- const View = require('android.view.View');
314
- const generatedId = View.generateViewId();
315
- ```
316
-
317
- ### Method overloading
318
-
319
- Hyperloop selects the matching overload based on parameter types. It is slightly more liberal with numeric primitives because JavaScript numbers are all `Number`.
320
-
321
- ### Casting
322
-
323
- Pass the object to the constructor of the target type:
324
- ```javascript
325
- const View = require('android.view.View');
326
-
327
- // Cast a generic Object to a View
328
- const view = new View(someObject);
329
-
330
- // Cast a Titanium view to native
331
- const tiView = Ti.UI.createView({ backgroundColor: 'red' });
332
- const nativeView = new View(tiView);
333
- ```
334
-
335
- ### Interfaces
336
-
337
- Implement Java interfaces by passing a JavaScript object with matching method names:
338
- ```javascript
339
- const OnTouchListener = require('android.view.View.OnTouchListener');
340
- const listener = new OnTouchListener({
341
- onTouch: (v, event) => {
342
- // Handle touch
343
- return true;
344
- }
345
- });
10
+ const generator = UIImpactFeedbackGenerator.alloc().init();
11
+ generator.impactOccurred();
346
12
  ```
347
13
 
348
- ### Creating custom classes (Android)
14
+ ```js
15
+ const Toast = require('android.widget.Toast');
16
+ const Activity = Ti.Android.currentActivity;
349
17
 
350
- Use `.extend()` on the class to subclass, passing an object with method overrides:
351
- ```javascript
352
- const Activity = require('android.app.Activity');
353
- const View = require('android.view.View');
354
- const activity = new Activity(Ti.Android.currentActivity);
355
-
356
- const MyView = View.extend({
357
- onDraw: function(canvas) {
358
- this.super.onDraw(canvas);
359
- // Custom drawing implementation
360
- }
361
- });
362
- const customView = new MyView(activity);
18
+ Toast.makeText(Activity, 'Saved', Toast.LENGTH_SHORT).show();
363
19
  ```
364
20
 
365
- ## 11. Android: native XML layouts
366
-
367
- ### Creating the layout
21
+ It is a module, maintained by TiDev, and still current: 8.0.1 is the release
22
+ against SDK 13.4.
368
23
 
369
- Place XML layout files in `app/platform/android/res/layout/` (Alloy) or `platform/android/res/layout/` (Classic).
24
+ ## Install
370
25
 
371
- Example `main_content.xml`:
372
26
  ```xml
373
- <androidx.coordinatorlayout.widget.CoordinatorLayout
374
- android:id="@+id/main_content"
375
- xmlns:android="http://schemas.android.com/apk/res/android"
376
- xmlns:app="http://schemas.android.com/apk/res-auto"
377
- android:layout_width="match_parent"
378
- android:layout_height="match_parent">
379
-
380
- <ListView
381
- android:id="@+id/lvToDoList"
382
- android:layout_width="match_parent"
383
- android:layout_height="match_parent" />
384
-
385
- <com.google.android.material.floatingactionbutton.FloatingActionButton
386
- android:layout_width="wrap_content"
387
- android:layout_height="wrap_content"
388
- android:layout_gravity="bottom|right"
389
- android:layout_margin="16dp" />
390
- </androidx.coordinatorlayout.widget.CoordinatorLayout>
391
- ```
392
-
393
- ### Inflating the layout
394
-
395
- ```javascript
396
- const Activity = require('android.app.Activity');
397
- const Context = require('android.content.Context');
398
- const Inflater = require('android.view.LayoutInflater');
399
-
400
- const activity = new Activity(Ti.Android.currentActivity);
401
- const inflater = Inflater.cast(
402
- activity.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)
403
- );
404
-
405
- // getIdentifier(name, defType, defPackage) retrieves the R.layout.* ID
406
- const resId = activity.getResources().getIdentifier('main_content', 'layout', activity.getPackageName());
407
- const view = inflater.inflate(resId, null);
408
-
409
- // Add to a Titanium view
410
- $.myView.add(view);
27
+ <modules>
28
+ <module platform="android">hyperloop</module>
29
+ <module platform="iphone">hyperloop</module>
30
+ </modules>
411
31
  ```
412
32
 
413
- `getIdentifier()` also works for other resource types: `R.color.*`, `R.string.*`, `R.drawable.*`, and others.
33
+ The module is unpacked like any other - see
34
+ [using modules](https://titaniumsdk.com/docs/build/modules).
414
35
 
415
- ## 12. Android: third-party libraries
36
+ ## How the require works
416
37
 
417
- ### AndroidX requirement
38
+ The path is the native type's own name.
418
39
 
419
- As of Titanium SDK 9.0.0, you must use AndroidX libraries. The deprecated Support libraries (`android.support.*`) are not supported.
40
+ | Platform | Form | Example |
41
+ | -------- | --------------------- | --------------------------------- |
42
+ | iOS | `Framework/Class` | `require('UIKit/UIView')` |
43
+ | Android | Fully-qualified class | `require('android.widget.Toast')` |
420
44
 
421
- ### Gradle dependencies (preferred)
45
+ Hyperloop generates a JavaScript wrapper for each type you require, at build
46
+ time, by reading the platform's own metadata. That is why a type you have not
47
+ required costs nothing.
422
48
 
423
- Add a `build.gradle` file to `app/platform/android/` (Alloy) or `platform/android/` (Classic):
424
-
425
- ```groovy
426
- dependencies {
427
- implementation 'com.google.android.material:material:1.1.0'
428
- }
429
- ```
49
+ ## Hyperloop or a module
430
50
 
431
- ### Local JAR/AAR dependencies
51
+ **Hyperloop** for a handful of calls, for something a single app needs, and for
52
+ trying an API out. No native toolchain knowledge and no separate build.
432
53
 
433
- Place JAR and AAR files directly in `app/platform/android/` (Alloy) or `platform/android/` (Classic). Hyperloop will:
434
- - Load Java classes and generate bindings
435
- - For AARs, extract resources, assets, `*.so` libraries, and merge `AndroidManifest.xml`
54
+ **A module** for something several apps need, for anything with real native
55
+ logic behind it, and when you want to ship a versioned artifact. See
56
+ [native modules](https://titaniumsdk.com/docs/extend/modules).
436
57
 
437
- ### Third-party library example
58
+ The wrong choice in one direction is a module for three lines. In the other, it
59
+ is the same Hyperloop code pasted into four apps.
438
60
 
439
- ```javascript
440
- // After adding the AAR to app/platform/android/
441
- const Activity = require('android.app.Activity');
442
- const ParkedTextView = require('com.goka.parkedtextview.ParkedTextView');
61
+ ## What it costs
443
62
 
444
- const activity = new Activity(Ti.Android.currentActivity);
445
- const parkedView = new ParkedTextView(activity);
446
- parkedView.setParkedText('.slack.com');
447
- parkedView.setHintText('your-team');
448
-
449
- // Listen to events via interfaces
450
- const TextWatcher = require('android.text.TextWatcher');
451
- const watcher = new TextWatcher({
452
- onTextChanged: () => { console.log('Changed'); },
453
- afterTextChanged: (s) => { console.log('After:', s); },
454
- beforeTextChanged: () => { console.log('Before'); }
455
- });
456
- parkedView.addTextChangedListener(watcher);
457
-
458
- $.myView.add(parkedView);
459
- ```
63
+ **Build time.** Hyperloop scans your JavaScript for requires and generates
64
+ wrappers for each. A build with many is measurably slower.
460
65
 
461
- ## 13. Debugging Hyperloop
66
+ **Every call crosses the bridge.** Native code called in a loop from JavaScript
67
+ pays per iteration. Keep native work on the native side.
462
68
 
463
- - iOS: use Safari Web Inspector to debug Hyperloop code up to the native transition point
464
- - Android: use Chrome DevTools for JavaScript debugging
465
- - Breakpoints may not hit correctly because Hyperloop modifies source files during the build process
466
- - No source maps are available for processed Alloy controllers
69
+ **You are using the platform API directly**, so there is no cross-platform
70
+ shape and no Titanium safety net. Guard with `OS_IOS` and `OS_ANDROID`, or
71
+ `Ti.Platform.osname`.
467
72
 
468
- ## 14. Performance tips
73
+ **The API is the platform's**, so its documentation is Apple's and Google's.
74
+ Titanium's reference does not describe it.
469
75
 
470
- - Do not use Hyperloop for things Titanium already does well.
471
- - Use it for specialized APIs: custom UI components, hardware access not covered by modules, or native third-party library integration.
472
- - Existing Titanium modules (Java for Android, Objective-C for iOS) continue to be supported alongside Hyperloop.
76
+ ## Next
473
77
 
474
- ## 15. Sample projects
78
+ [CLI plugins](https://titaniumsdk.com/docs/extend/cli-plugins) is the other extension point: changing
79
+ the build rather than the app.
475
80
 
476
- The cross-platform example app demonstrates native APIs for iOS and Android, including CocoaPods, Android AAR packages, UICollectionView, Beacons, BottomNavigationView, native XML layouts, Storyboards, XIBs, and more.
81
+ ## Platform guards in Classic and Alloy
477
82
 
478
- - Repository: https://github.com/tidev/hyperloop-examples
479
- - Community modules: https://github.com/hyperloop-modules (JavaScript wrappers around native APIs such as Speech, Mapbox, Snackbar)
83
+ Use Alloy compile-time constants only in Alloy source. In Classic use `Ti.Platform.osname` or a supported platform directory; otherwise `OS_IOS`/`OS_ANDROID` are undefined. Native method availability is controlled by the installed OS/framework, so check platform documentation and guard optional APIs. SDK 14-only changes remain outside this released baseline.