@maccesar/titools 2.2.3 → 2.2.8

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 (96) hide show
  1. package/README.md +28 -27
  2. package/lib/commands/update.js +80 -101
  3. package/package.json +1 -1
  4. package/skills/alloy-guides/SKILL.md +31 -31
  5. package/skills/alloy-guides/references/CONCEPTS.md +3 -3
  6. package/skills/alloy-guides/references/CONTROLLERS.md +1 -1
  7. package/skills/alloy-guides/references/MODELS.md +6 -6
  8. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +1 -1
  9. package/skills/alloy-guides/references/VIEWS_XML.md +1 -1
  10. package/skills/alloy-guides/references/WIDGETS.md +1 -1
  11. package/skills/alloy-howtos/SKILL.md +27 -27
  12. package/skills/alloy-howtos/references/best_practices.md +9 -9
  13. package/skills/alloy-howtos/references/cli_reference.md +14 -14
  14. package/skills/alloy-howtos/references/config_files.md +16 -16
  15. package/skills/alloy-howtos/references/custom_tags.md +16 -16
  16. package/skills/alloy-howtos/references/debugging_troubleshooting.md +11 -15
  17. package/skills/alloy-howtos/references/samples.md +19 -19
  18. package/skills/purgetss/SKILL.md +11 -1
  19. package/skills/purgetss/references/animation-system.md +1 -1
  20. package/skills/purgetss/references/cli-commands.md +3 -3
  21. package/skills/purgetss/references/customization-deep-dive.md +1 -1
  22. package/skills/purgetss/references/dynamic-component-creation.md +1 -1
  23. package/skills/purgetss/references/icon-fonts.md +4 -0
  24. package/skills/purgetss/references/installation-setup.md +8 -1
  25. package/skills/purgetss/references/migration-guide.md +4 -0
  26. package/skills/purgetss/references/tikit-components.md +193 -204
  27. package/skills/purgetss/references/ui-ux-design.md +1 -1
  28. package/skills/ti-expert/SKILL.md +78 -118
  29. package/skills/ti-expert/references/alloy-builtins.md +18 -18
  30. package/skills/ti-expert/references/alloy-structure.md +21 -21
  31. package/skills/ti-expert/references/anti-patterns.md +15 -15
  32. package/skills/ti-expert/references/cli-expert.md +15 -15
  33. package/skills/ti-expert/references/code-conventions.md +38 -38
  34. package/skills/ti-expert/references/contracts.md +8 -8
  35. package/skills/ti-expert/references/controller-patterns.md +14 -14
  36. package/skills/ti-expert/references/error-handling.md +11 -11
  37. package/skills/ti-expert/references/examples.md +12 -12
  38. package/skills/ti-expert/references/migration-patterns.md +24 -24
  39. package/skills/ti-expert/references/patterns.md +10 -10
  40. package/skills/ti-expert/references/performance-listview.md +16 -16
  41. package/skills/ti-expert/references/performance-optimization.md +41 -41
  42. package/skills/ti-expert/references/security-device.md +22 -22
  43. package/skills/ti-expert/references/security-fundamentals.md +19 -19
  44. package/skills/ti-expert/references/state-management.md +33 -33
  45. package/skills/ti-expert/references/testing-e2e-ci.md +25 -25
  46. package/skills/ti-expert/references/testing-unit.md +24 -24
  47. package/skills/ti-expert/references/theming.md +15 -15
  48. package/skills/ti-guides/SKILL.md +58 -60
  49. package/skills/ti-guides/references/advanced-data-and-images.md +33 -33
  50. package/skills/ti-guides/references/android-manifest.md +15 -15
  51. package/skills/ti-guides/references/app-distribution.md +70 -166
  52. package/skills/ti-guides/references/application-frameworks.md +96 -114
  53. package/skills/ti-guides/references/cli-reference.md +294 -294
  54. package/skills/ti-guides/references/coding-best-practices.md +42 -33
  55. package/skills/ti-guides/references/commonjs-advanced.md +57 -51
  56. package/skills/ti-guides/references/hello-world.md +36 -36
  57. package/skills/ti-guides/references/hyperloop-native-access.md +66 -66
  58. package/skills/ti-guides/references/javascript-primer.md +83 -101
  59. package/skills/ti-guides/references/reserved-words.md +9 -9
  60. package/skills/ti-guides/references/resources.md +75 -83
  61. package/skills/ti-guides/references/style-and-conventions.md +35 -28
  62. package/skills/ti-guides/references/tiapp-config.md +110 -74
  63. package/skills/ti-howtos/SKILL.md +88 -92
  64. package/skills/ti-howtos/references/android-platform-deep-dives.md +104 -104
  65. package/skills/ti-howtos/references/automation-fastlane-appium.md +39 -39
  66. package/skills/ti-howtos/references/buffer-codec-streams.md +60 -60
  67. package/skills/ti-howtos/references/cross-platform-development.md +115 -136
  68. package/skills/ti-howtos/references/debugging-profiling.md +167 -181
  69. package/skills/ti-howtos/references/extending-titanium.md +121 -121
  70. package/skills/ti-howtos/references/google-maps-v2.md +84 -82
  71. package/skills/ti-howtos/references/ios-map-kit.md +65 -60
  72. package/skills/ti-howtos/references/ios-platform-deep-dives.md +123 -123
  73. package/skills/ti-howtos/references/local-data-sources.md +79 -78
  74. package/skills/ti-howtos/references/location-and-maps.md +116 -120
  75. package/skills/ti-howtos/references/media-apis.md +87 -86
  76. package/skills/ti-howtos/references/notification-services.md +250 -260
  77. package/skills/ti-howtos/references/remote-data-sources.md +98 -93
  78. package/skills/ti-howtos/references/tutorials.md +226 -216
  79. package/skills/ti-howtos/references/using-modules.md +73 -102
  80. package/skills/ti-howtos/references/web-content-integration.md +101 -103
  81. package/skills/ti-howtos/references/webpack-build-pipeline.md +52 -44
  82. package/skills/ti-ui/SKILL.md +85 -85
  83. package/skills/ti-ui/references/accessibility-deep-dive.md +57 -57
  84. package/skills/ti-ui/references/animation-and-matrices.md +79 -79
  85. package/skills/ti-ui/references/application-structures.md +96 -99
  86. package/skills/ti-ui/references/custom-fonts-styling.md +99 -99
  87. package/skills/ti-ui/references/event-handling.md +58 -58
  88. package/skills/ti-ui/references/gestures.md +62 -64
  89. package/skills/ti-ui/references/icons-and-splash-screens.md +88 -88
  90. package/skills/ti-ui/references/layouts-and-positioning.md +87 -97
  91. package/skills/ti-ui/references/listviews-and-performance.md +107 -107
  92. package/skills/ti-ui/references/orientation.md +87 -88
  93. package/skills/ti-ui/references/platform-ui-android.md +87 -81
  94. package/skills/ti-ui/references/platform-ui-ios.md +63 -61
  95. package/skills/ti-ui/references/scrolling-views.md +29 -29
  96. package/skills/ti-ui/references/tableviews.md +56 -56
@@ -1,14 +1,14 @@
1
- # Remote Data Sources
1
+ # Remote data sources
2
2
 
3
- ## 1. HTTPClient and Request Lifecycle
3
+ ## 1. HTTPClient and request lifecycle
4
4
 
5
- ### Basic Pattern
6
- `Ti.Network.HTTPClient` mirrors XHR (XMLHttpRequest) API. Always handle both success and error cases.
5
+ ### Basic pattern
6
+ `Ti.Network.HTTPClient` mirrors the XHR (XMLHttpRequest) API. Always handle both success and error paths.
7
7
 
8
8
  ```javascript
9
9
  const xhr = Ti.Network.createHTTPClient({
10
10
  onload: (e) => {
11
- // this.responseText - raw text (for JSON/text)
11
+ // this.responseText - raw text (JSON/text)
12
12
  // this.responseXML - XML document (including SOAP)
13
13
  // this.responseData - binary data (Blob)
14
14
  Ti.API.debug(xhr.responseText);
@@ -22,13 +22,13 @@ xhr.open('GET', 'https://api.example.com/data');
22
22
  xhr.send();
23
23
  ```
24
24
 
25
- ### HTTP Methods
25
+ ### HTTP methods
26
26
  - GET: `xhr.open('GET', url)` then `xhr.send()`
27
27
  - POST: `xhr.open('POST', url)` then `xhr.send({key: 'value'})`
28
- - PUT/DELETE/PATCH: All supported (PATCH since 4.1.0 on Android)
28
+ - PUT/DELETE/PATCH: all supported (PATCH since 4.1.0 on Android)
29
29
 
30
- ### Setting Headers
31
- **Critical**: Headers must be set AFTER `open()` but BEFORE `send()`
30
+ ### Setting headers
31
+ Headers must be set after `open()` but before `send()`.
32
32
 
33
33
  ```javascript
34
34
  const client = Ti.Network.createHTTPClient();
@@ -38,17 +38,17 @@ client.setRequestHeader('Authorization', `Bearer ${token}`);
38
38
  client.send('data');
39
39
  ```
40
40
 
41
- ### XHR Lifecycle States
41
+ ### XHR lifecycle states
42
42
  Monitor with `onreadystatechange`:
43
- - `UNSENT` - Object constructed
43
+ - `UNSENT` - object constructed
44
44
  - `OPENED` - `open()` called successfully
45
- - `HEADERS_RECEIVED` - All redirects followed, headers received
46
- - `LOADING` - Response body being received
47
- - `DONE` - Transfer complete or error occurred
45
+ - `HEADERS_RECEIVED` - all redirects followed, headers received
46
+ - `LOADING` - response body being received
47
+ - `DONE` - transfer complete or error occurred
48
48
 
49
49
  ```javascript
50
50
  xhr.onreadystatechange = (e) => {
51
- switch(xhr.readyState) {
51
+ switch (xhr.readyState) {
52
52
  case Ti.Network.HTTPClient.HEADERS_RECEIVED:
53
53
  Ti.API.info(`Headers: ${xhr.getResponseHeader('Content-Type')}`);
54
54
  break;
@@ -59,9 +59,9 @@ xhr.onreadystatechange = (e) => {
59
59
  };
60
60
  ```
61
61
 
62
- ### Progress Monitoring
63
- - `onsendstream`: Upload progress (0.0-1.0)
64
- - `ondatastream`: Download progress (0.0-1.0)
62
+ ### Progress monitoring
63
+ - `onsendstream`: upload progress (0.0-1.0)
64
+ - `ondatastream`: download progress (0.0-1.0)
65
65
 
66
66
  ```javascript
67
67
  xhr.onsendstream = (e) => {
@@ -72,7 +72,7 @@ xhr.ondatastream = (e) => {
72
72
  };
73
73
  ```
74
74
 
75
- ## 2. Working with JSON Data
75
+ ## 2. Working with JSON data
76
76
 
77
77
  ### Receiving JSON
78
78
  ```javascript
@@ -83,15 +83,15 @@ xhr.onload = () => {
83
83
  ```
84
84
 
85
85
  ### Sending JSON
86
- `send()` automatically stringifies objects:
86
+ `send()` stringifies objects for you.
87
87
 
88
88
  ```javascript
89
89
  const postData = { title: 'My Post', body: 'Content' };
90
90
  xhr.open('POST', 'http://blog.com/api/posts');
91
- xhr.send(postData); // Auto-stringified
91
+ xhr.send(postData); // Auto-stringified
92
92
  ```
93
93
 
94
- For GET querystrings, manually stringify and encode:
94
+ For GET query strings, stringify and encode yourself.
95
95
 
96
96
  ```javascript
97
97
  const data = { search: 'titanium' };
@@ -100,13 +100,13 @@ xhr.open('GET', `http://api.com/search?q=${queryString}`);
100
100
  xhr.send();
101
101
  ```
102
102
 
103
- ### Important Limitation
104
- JSON cannot represent methods. Attempting to stringify Titanium objects returns empty representation.
103
+ ### Important limitation
104
+ JSON cannot represent methods. Stringifying Titanium objects returns an empty representation.
105
105
 
106
- ## 3. Working with XML Data
106
+ ## 3. Working with XML data
107
107
 
108
108
  ### Parsing XML
109
- Titanium provides XML DOM Level 2 implementation. Auto-serializes if Content-Type is XML.
109
+ Titanium provides XML DOM Level 2. If the response is XML and the server sends the correct Content-Type, Titanium auto-parses it.
110
110
 
111
111
  ```javascript
112
112
  xhr.onload = () => {
@@ -121,19 +121,19 @@ xhr.onload = () => {
121
121
  };
122
122
  ```
123
123
 
124
- ### Common DOM Methods
125
- - `getElementsByTagName(name)` - Returns array of nodes
126
- - `item(index)` - Select specific node from array
127
- - `getAttribute(name)` - Get attribute value
128
- - `textContent` / `nodeValue` - Get leaf node value
124
+ ### Common DOM methods
125
+ - `getElementsByTagName(name)` - returns array of nodes
126
+ - `item(index)` - selects a specific node from the array
127
+ - `getAttribute(name)` - gets an attribute value
128
+ - `textContent` / `nodeValue` - gets a leaf node value
129
129
 
130
- ### Important: Know Your DTD
130
+ ### Important: know your DTD
131
131
  You must understand the XML structure (node hierarchy) to parse correctly. Use tools like apigee.com to inspect API responses.
132
132
 
133
- ## 4. File Uploads and Downloads
133
+ ## 4. File uploads and downloads
134
134
 
135
- ### File Upload
136
- Pass a Blob to `send()`:
135
+ ### File upload
136
+ Pass a Blob to `send()`.
137
137
 
138
138
  ```javascript
139
139
  Ti.Media.openPhotoGallery({
@@ -145,7 +145,7 @@ Ti.Media.openPhotoGallery({
145
145
  });
146
146
  xhr.open('POST', 'https://server.com/upload');
147
147
  xhr.send({
148
- file: event.media, // Blob from gallery
148
+ file: event.media, // Blob from gallery
149
149
  username: 'user'
150
150
  });
151
151
  }
@@ -153,6 +153,7 @@ Ti.Media.openPhotoGallery({
153
153
  ```
154
154
 
155
155
  For file uploads with actual file contents:
156
+
156
157
  ```javascript
157
158
  const file = Ti.Filesystem.getFile(event.media.nativePath);
158
159
  if (file.exists()) {
@@ -160,11 +161,11 @@ if (file.exists()) {
160
161
  }
161
162
  ```
162
163
 
163
- > **Note**: When uploading from the photo gallery, `event.media` returns a Blob. For file uploads from the filesystem, use `Ti.Filesystem.getFile(path).read()` to get the Blob.
164
+ Note: when uploading from the photo gallery, `event.media` is a Blob. For filesystem uploads, use `Ti.Filesystem.getFile(path).read()` to get a Blob.
164
165
 
165
- ### File Download (Cross-Platform)
166
+ ### File download (cross-platform)
166
167
 
167
- **Option 1**: Write manually to filesystem
168
+ Option 1: write manually to the filesystem.
168
169
 
169
170
  ```javascript
170
171
  const xhr = Ti.Network.createHTTPClient({
@@ -182,9 +183,8 @@ xhr.open('GET', 'http://example.com/image.png');
182
183
  xhr.send();
183
184
  ```
184
185
 
185
- **Option 2**: iOS-only automatic saving with `file` property
186
+ Option 2 (iOS only): set `xhr.file` to save directly without buffering.
186
187
 
187
- **iOS-only**: Use `xhr.file` to save downloads directly to a file without buffering in memory:
188
188
  ```javascript
189
189
  xhr.file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'download.zip');
190
190
  ```
@@ -203,24 +203,24 @@ xhr.file = Ti.Filesystem.getFile(
203
203
  xhr.send();
204
204
  ```
205
205
 
206
- ### File Storage Locations
207
- - `applicationDataDirectory` - Primary read/write location for app files
208
- - `resourcesDirectory` - Read-only app resources (writeable in simulator only)
209
- - `tempDirectory` - Temporary files, OS may delete when app closes
206
+ ### File storage locations
207
+ - `applicationDataDirectory` - primary read/write location for app files
208
+ - `resourcesDirectory` - read-only app resources (writeable in simulator only)
209
+ - `tempDirectory` - temporary files, OS may delete when app closes
210
210
  - `externalCacheDirectory` - Android SD card cache (check `isExternalStoragePresent()`)
211
- - `applicationCacheDirectory` - Cache data, persists but OS may clean
211
+ - `applicationCacheDirectory` - cache data, persists but OS may clean it up
212
212
 
213
213
  ## 5. Sockets
214
214
 
215
- Titanium supports TCP socket connections via `Ti.Network.Socket`.
215
+ Titanium supports TCP sockets via `Ti.Network.Socket`.
216
216
 
217
- ### Creating a TCP Socket
217
+ ### Creating a TCP socket
218
218
 
219
219
  ```javascript
220
220
  const socket = Ti.Network.Socket.createTCP({
221
221
  host: 'example.com',
222
222
  port: 80,
223
- connected: function(e) {
223
+ connected: function (e) {
224
224
  Ti.API.info('Socket connected');
225
225
  // Write data
226
226
  this.write(Ti.createBuffer({
@@ -235,77 +235,81 @@ const socket = Ti.Network.Socket.createTCP({
235
235
  socket.connect();
236
236
  ```
237
237
 
238
- ### Socket Listening (Android/iOS)
238
+ ### Socket listening (Android/iOS)
239
239
  To create a socket server that accepts connections:
240
+
240
241
  ```javascript
241
242
  const listenSocket = Ti.Network.Socket.createTCP({
242
- host: '127.0.0.1', // localhost
243
- port: 40404,
244
- accepted: (e) => {
245
- Ti.API.info(`Incoming connection accepted: ${e.inbound}`);
246
- e.inbound.close();
247
- }
243
+ host: '127.0.0.1', // localhost
244
+ port: 40404,
245
+ accepted: (e) => {
246
+ Ti.API.info(`Incoming connection accepted: ${e.inbound}`);
247
+ e.inbound.close();
248
+ }
248
249
  });
249
250
  listenSocket.listen();
250
251
  listenSocket.accept(); // Asynchronous, waits for next connection
251
252
  ```
252
253
 
253
- > **Platform Note**: On iOS, `Ti.Platform.address` returns the WiFi interface address. On Android, only the loopback address (`127.0.0.1`) is available for listening sockets.
254
+ Platform note: on iOS, `Ti.Platform.address` returns the WiFi interface address. On Android, only the loopback address (`127.0.0.1`) is available for listening sockets.
254
255
 
255
- ## 6. Dealing with SOAP Web Services
256
+ ## 6. Dealing with SOAP web services
256
257
 
257
- Although JSON is recommended, you can consume legacy SOAP services using a "low-tech" approach by sending the XML envelope manually.
258
+ JSON is recommended, but you can consume legacy SOAP services by sending the XML envelope manually.
258
259
 
259
- ### Manual Approach (SOAP Envelope)
260
+ ### Manual approach (SOAP envelope)
260
261
  ```javascript
261
262
  const client = Ti.Network.createHTTPClient();
262
263
  client.onload = () => {
263
- const doc = client.responseXML.documentElement;
264
- // Parse the response XML manually
264
+ const doc = client.responseXML.documentElement;
265
+ // Parse the response XML manually
265
266
  };
266
267
 
267
268
  const soapRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" +
268
- "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n" +
269
- "<SOAP-ENV:Body> \n" +
270
- " <GetUserDetailsReq> \n" +
271
- " <SessionToken>XXXX</SessionToken> \n" +
272
- " </GetUserDetailsReq> \n" +
273
- "</SOAP-ENV:Body> \n" +
274
- "</SOAP-ENV:Envelope>";
269
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n" +
270
+ "<SOAP-ENV:Body> \n" +
271
+ " <GetUserDetailsReq> \n" +
272
+ " <SessionToken>XXXX</SessionToken> \n" +
273
+ " </GetUserDetailsReq> \n" +
274
+ "</SOAP-ENV:Body> \n" +
275
+ "</SOAP-ENV:Envelope>";
275
276
 
276
277
  client.open('POST', 'https://server.com/service.asmx');
277
278
  client.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
278
279
  client.send({ xml: soapRequest });
279
280
  ```
280
281
 
281
- ## 7. SSL Certificate & Security Manager
282
+ ## 7. SSL certificate and SecurityManager
282
283
 
283
- For robust security (SSL Pinning), use the `securityManager` property.
284
+ For SSL pinning, use the `securityManager` property.
284
285
 
285
- ### SSL Pinning (TiSDK 3.3.0+)
286
- Unlike standard certificate validation, Pinning ensures the app only communicates with a server having a specific certificate.
286
+ ### SSL pinning (TiSDK 3.3.0+)
287
+ Pinning ensures the app only communicates with a server that presents a specific certificate.
287
288
 
288
289
  ```javascript
289
290
  const xhr = Ti.Network.createHTTPClient({
290
- validatesSecureCertificate: true,
291
- // securityManager allows implementing custom validation logic
292
- securityManager: mySecurityModule
291
+ validatesSecureCertificate: true,
292
+ // securityManager allows custom validation logic
293
+ securityManager: mySecurityModule
293
294
  });
294
295
  ```
295
296
 
296
- ### SSL Certificate Store (Android)
297
+ ### SSL certificate store (Android)
297
298
  ```javascript
298
299
  const certificateStore = require('ti.certificatestore');
299
300
  const httpClient = Ti.Network.createHTTPClient({
300
- securityManager: certificateStore.createX509CertificatePinningSecurityManager([{
301
- url: 'https://api.example.com',
302
- serverCertificate: 'api_cert.der'
303
- }])
301
+ securityManager: certificateStore.createX509CertificatePinningSecurityManager([
302
+ {
303
+ url: 'https://api.example.com',
304
+ serverCertificate: 'api_cert.der'
305
+ }
306
+ ])
304
307
  });
305
308
  ```
306
309
 
307
310
  ### Android: addTrustManager
308
- Allows adding custom certificates for development environments or private networks:
311
+ Use this for development environments or private networks with custom certs.
312
+
309
313
  ```javascript
310
314
  const certificateStore = require('ti.certificatestore');
311
315
  const xhr = Ti.Network.createHTTPClient();
@@ -313,22 +317,23 @@ const xhr = Ti.Network.createHTTPClient();
313
317
  certificateStore.addCertificate('server.p12', 'password');
314
318
  xhr.addTrustManager(certificateStore.getTrustManager());
315
319
 
316
- xhr.open("GET", url);
320
+ xhr.open('GET', url);
317
321
  xhr.send();
318
322
  ```
319
- ## CORS Considerations for Mobile Web
323
+
324
+ ## 8. CORS considerations for Mobile Web
320
325
 
321
326
  For Mobile Web targets accessing cross-domain resources:
322
- - Enable CORS headers on server
327
+ - Enable CORS headers on the server
323
328
  - Or configure a proxy service
324
329
  - Use custom `Ti.Network.httpURLFormatter`
325
330
 
326
- ## Best Practices
331
+ ## Best practices
327
332
 
328
- 1. **Always set timeouts** to prevent hanging requests
329
- 2. **Handle both `onload` and `onerror`** - never assume success
330
- 3. **Use progress callbacks** for large file operations
331
- 4. **Save large downloads directly to disk** using `file` property (iOS) or `write()` to avoid memory exhaustion
332
- 5. **For complex JSON**, validate schema before parsing
333
- 6. **For XML**, always test with actual API response to verify node hierarchy
334
- 7. **Use `onsendstream`/`ondatastream`** to provide user feedback during transfers
333
+ 1. Set timeouts to prevent hanging requests.
334
+ 2. Handle both `onload` and `onerror`.
335
+ 3. Use progress callbacks for large file operations.
336
+ 4. Save large downloads to disk using `file` (iOS) or `write()` to avoid memory exhaustion.
337
+ 5. For complex JSON, validate schema before parsing.
338
+ 6. For XML, test with real responses to verify node hierarchy.
339
+ 7. Use `onsendstream` and `ondatastream` for user feedback during transfers.