@maccesar/titools 2.10.0 → 3.1.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 (99) hide show
  1. package/AGENTS-VERCEL-RESEARCH.md +23 -12
  2. package/README.md +81 -182
  3. package/agents/ti-pro.md +8 -14
  4. package/lib/cleanup.js +13 -0
  5. package/lib/commands/skills.js +2 -1
  6. package/lib/commands/update.js +4 -1
  7. package/lib/config.js +9 -11
  8. package/lib/platform.js +1 -1
  9. package/package.json +2 -3
  10. package/skills/purgetss/SKILL.md +12 -0
  11. package/skills/purgetss/references/animation-advanced.md +0 -9
  12. package/skills/purgetss/references/app-branding.md +20 -0
  13. package/skills/purgetss/references/appearance-module.md +85 -27
  14. package/skills/purgetss/references/apply-directive.md +60 -0
  15. package/skills/purgetss/references/arbitrary-values.md +41 -0
  16. package/skills/purgetss/references/cli-commands.md +52 -17
  17. package/skills/purgetss/references/custom-rules.md +36 -19
  18. package/skills/purgetss/references/customization-deep-dive.md +37 -15
  19. package/skills/purgetss/references/grid-layout.md +45 -26
  20. package/skills/purgetss/references/icon-fonts.md +27 -25
  21. package/skills/purgetss/references/installation-setup.md +28 -2
  22. package/skills/purgetss/references/ios-large-titles.md +31 -15
  23. package/skills/purgetss/references/multi-density-images.md +57 -0
  24. package/skills/purgetss/references/opacity-modifier.md +11 -2
  25. package/skills/purgetss/references/semantic-colors.md +44 -1
  26. package/skills/purgetss/references/tikit-components.md +1 -3
  27. package/skills/alloy-guides/SKILL.md +0 -190
  28. package/skills/alloy-guides/references/CLI_TASKS.md +0 -233
  29. package/skills/alloy-guides/references/CONCEPTS.md +0 -171
  30. package/skills/alloy-guides/references/CONTROLLERS.md +0 -279
  31. package/skills/alloy-guides/references/MODELS.md +0 -1214
  32. package/skills/alloy-guides/references/PURGETSS.md +0 -46
  33. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +0 -235
  34. package/skills/alloy-guides/references/VIEWS_STYLES.md +0 -375
  35. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
  36. package/skills/alloy-guides/references/VIEWS_XML.md +0 -581
  37. package/skills/alloy-guides/references/WIDGETS.md +0 -160
  38. package/skills/alloy-howtos/SKILL.md +0 -181
  39. package/skills/alloy-howtos/references/best_practices.md +0 -121
  40. package/skills/alloy-howtos/references/cli_reference.md +0 -230
  41. package/skills/alloy-howtos/references/config_files.md +0 -158
  42. package/skills/alloy-howtos/references/custom_tags.md +0 -148
  43. package/skills/alloy-howtos/references/debugging_troubleshooting.md +0 -78
  44. package/skills/alloy-howtos/references/samples.md +0 -156
  45. package/skills/ti-api/SKILL.md +0 -109
  46. package/skills/ti-api/references/api-android.md +0 -675
  47. package/skills/ti-api/references/api-app-platform.md +0 -636
  48. package/skills/ti-api/references/api-core.md +0 -764
  49. package/skills/ti-api/references/api-data-network.md +0 -641
  50. package/skills/ti-api/references/api-media.md +0 -655
  51. package/skills/ti-api/references/api-modules-ble-bluetooth.md +0 -657
  52. package/skills/ti-api/references/api-modules-coremotion-urlsession.md +0 -411
  53. package/skills/ti-api/references/api-modules-map.md +0 -632
  54. package/skills/ti-api/references/api-modules-nfc.md +0 -725
  55. package/skills/ti-api/references/api-modules-social-misc.md +0 -526
  56. package/skills/ti-api/references/api-services.md +0 -700
  57. package/skills/ti-api/references/api-ui-android.md +0 -499
  58. package/skills/ti-api/references/api-ui-extras.md +0 -702
  59. package/skills/ti-api/references/api-ui-ios-animator.md +0 -378
  60. package/skills/ti-api/references/api-ui-ios.md +0 -756
  61. package/skills/ti-api/references/api-ui-lists.md +0 -581
  62. package/skills/ti-api/references/api-ui-text-input.md +0 -607
  63. package/skills/ti-api/references/api-ui-views.md +0 -572
  64. package/skills/ti-api/references/api-ui-windows-navigation.md +0 -676
  65. package/skills/ti-api/references/api-xml-global.md +0 -743
  66. package/skills/ti-guides/SKILL.md +0 -75
  67. package/skills/ti-guides/references/advanced-data-and-images.md +0 -155
  68. package/skills/ti-guides/references/android-manifest.md +0 -97
  69. package/skills/ti-guides/references/app-distribution.md +0 -373
  70. package/skills/ti-guides/references/application-frameworks.md +0 -366
  71. package/skills/ti-guides/references/cli-reference.md +0 -700
  72. package/skills/ti-guides/references/coding-best-practices.md +0 -150
  73. package/skills/ti-guides/references/commonjs-advanced.md +0 -279
  74. package/skills/ti-guides/references/hello-world.md +0 -99
  75. package/skills/ti-guides/references/hyperloop-native-access.md +0 -458
  76. package/skills/ti-guides/references/javascript-primer.md +0 -402
  77. package/skills/ti-guides/references/reserved-words.md +0 -36
  78. package/skills/ti-guides/references/resources.md +0 -172
  79. package/skills/ti-guides/references/style-and-conventions.md +0 -104
  80. package/skills/ti-guides/references/tiapp-config.md +0 -655
  81. package/skills/ti-howtos/SKILL.md +0 -143
  82. package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -609
  83. package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
  84. package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
  85. package/skills/ti-howtos/references/cross-platform-development.md +0 -358
  86. package/skills/ti-howtos/references/debugging-profiling.md +0 -473
  87. package/skills/ti-howtos/references/extending-titanium.md +0 -684
  88. package/skills/ti-howtos/references/google-maps-v2.md +0 -172
  89. package/skills/ti-howtos/references/ios-map-kit.md +0 -149
  90. package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -595
  91. package/skills/ti-howtos/references/local-data-sources.md +0 -310
  92. package/skills/ti-howtos/references/location-and-maps.md +0 -267
  93. package/skills/ti-howtos/references/media-apis.md +0 -268
  94. package/skills/ti-howtos/references/notification-services.md +0 -539
  95. package/skills/ti-howtos/references/remote-data-sources.md +0 -339
  96. package/skills/ti-howtos/references/tutorials.md +0 -552
  97. package/skills/ti-howtos/references/using-modules.md +0 -182
  98. package/skills/ti-howtos/references/web-content-integration.md +0 -288
  99. package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -125
@@ -1,279 +0,0 @@
1
- # Alloy Controllers
2
-
3
- ## Overview
4
-
5
- This topic covers how to write controller code as well as other JavaScript files excluding models. Some traditional Titanium development is required, since Alloy controllers make direct calls to the Titanium SDK API to manipulate UI objects and access non-UI APIs.
6
-
7
- ## Controllers
8
-
9
- In Alloy, controllers contain the application logic used to control the UI and communicate with the model. The following code contains the presentation logic (`index.js`) associated with the view (`index.xml`).
10
-
11
- **app/controllers/index.js**
12
-
13
- ```javascript
14
- function doClick(e) {
15
- alert($.label.text);
16
- }
17
-
18
- $.index.open();
19
- ```
20
-
21
- **app/views/index.xml**
22
-
23
- ```xml
24
- <Alloy>
25
- <Window class="container">
26
- <Label id="label" onClick="doClick">Hello, World</Label>
27
- </Window>
28
- </Alloy>
29
- ```
30
-
31
- All UI elements which have an `id` attribute in a view are automatically defined and available as a property prefixed by the special variable `$` in the controller. The `$` is a reference to the controller. For example, the `$.label` prefix in the controller is used to access the `Ti.UI.Label` object instance in the view. This reference is used to directly access properties or methods of this object. For example, calling `$.label.hide()` hides the label from the view or you can change the label text with `$.label.text`.
32
-
33
- To access external controllers and views, use the `Alloy.createController` and `Controller.getView` methods, respectively.
34
-
35
- If the top-level UI object does not have an ID defined, reference it using the name of the controller prefixed by the `$`. Since the Window object in the view does not contain an ID, the controller uses `$.index` to grab the top-level UI object from the view. However, if an `id` attribute was defined, for example, `<Window id='window'>`, the controller needs to use `$.window` to gain access to the Window object; `$.index` will be undefined and the application will throw an error when calling `$.index.open()`.
36
-
37
- ### Events
38
-
39
- Controllers extend `BackBone.Events` and as such can dispatch events.
40
-
41
- For example, our index view could also require another controller to deliver the label and listen to an event:
42
-
43
- **app/views/index.xml**
44
-
45
- ```xml
46
- <Alloy>
47
- <Window class="container">
48
- <Require id="label" src="label" onNotify="doSomething" />
49
- </Window>
50
- </Alloy>
51
- ```
52
-
53
- The view of the required label-controller would listen to the `click` event of the label itself:
54
-
55
- **app/views/label.xml**
56
-
57
- ```xml
58
- <Alloy>
59
- <Label id="label" onClick="passClick">Hello, World</Label>
60
- </Alloy>
61
- ```
62
-
63
- And that label-controller would in turn fire the notify event on itself so the index controller will receive it:
64
-
65
- **app/controllers/label.js**
66
-
67
- ```javascript
68
- function passClick(e) {
69
- $.trigger('notify');
70
- }
71
- ```
72
-
73
- ### Inheritance
74
-
75
- Controllers can inherit from other controllers by assigning them as a base (parent) controller: `exports.baseController = 'baseControllerName'`. As in the CommonJS model, the controller inherits any exported functions from the base controller. These functions can also be overwritten.
76
-
77
- For example, the animal view-controller defines a label object with a speak method:
78
-
79
- **app/controllers/animal.js**
80
-
81
- ```javascript
82
- exports.speak = () => {
83
- alert("Yelp!");
84
- };
85
- ```
86
-
87
- **app/views/animal.xml**
88
-
89
- ```xml
90
- <Alloy>
91
- <Label id="animalLabel">Animal</Label>
92
- </Alloy>
93
- ```
94
-
95
- Then, the following code inherits from the animal view-controller and overrides the speak method and label text property to customize it for a dog controller.
96
-
97
- **app/controllers/dog.js**
98
-
99
- ```javascript
100
- exports.baseController = "animal";
101
- $.animalLabel.text = "Dog";
102
- exports.speak = () => {
103
- alert("Bark!");
104
- };
105
- ```
106
-
107
- ### Conditional Code
108
-
109
- Alloy introduces a set of special variables that act like compiler directives. Using these compiler constants optimizes the code at generation/compilation and any non-reachable code is removed.
110
-
111
- The following are the constants defined by Alloy for use in the controller code:
112
-
113
- * `OS_ANDROID` : true if the current compiler target is Android
114
- * `OS_IOS` : true if the current compiler target is iOS
115
- * `ENV_DEV` : true if the current compiler target is built for development (running in the simulator or emulator)
116
- * `ENV_TEST` : true if the current compiler target is built for testing on a device
117
- * `ENV_PRODUCTION` : true if the current compiler target is built for production (running after a packaged installation)
118
- * `DIST_ADHOC` (since Alloy 1.4.0) : true if the current compiler target is built for iOS Ad Hoc distribution, for example, if you set the `-T dist-adhoc` option when building with the Titanium CLI. Note that `ENV_PRODUCTION` will be true too since this deployment is only for production builds.
119
- * `DIST_STORE` (since Alloy 1.4.0) : true if the current compiler target is built for deployment to the Google Play Store or iTunes App Store, for example, if you set the `-T dist-store` option when building with the Titanium CLI. Note that `ENV_PRODUCTION` will be true too since this deployment is only for production builds.
120
-
121
- For example, since iOS devices do not include a back button, the application can conditionally add one to a window controller:
122
-
123
- ```javascript
124
- if (OS_IOS) {
125
- const closeButton = Ti.UI.createButton({
126
- title: 'Close'
127
- });
128
-
129
- closeButton.addEventListener('click', () => {
130
- $.window.close();
131
- });
132
-
133
- $.window.leftNavButton = closeButton;
134
- }
135
- ```
136
-
137
- ### Passing Arguments
138
-
139
- When initializing an external controller, you can pass arguments to customize it, for instance, `const controller = Alloy.createController('controller', {args1: 'foo'})`. In the external controller, the special variable `$.args` is used to receive the arguments. Before Alloy 1.6, you needed to use `arguments[0]`. For example, suppose you want to add multiple TableViewRow objects to a TableView object.
140
-
141
- For the TableViewRow object, called 'row', the view contains only the object, and the controller contains only a few lines of code to parse the arguments:
142
-
143
- **app/views/row.xml**
144
-
145
- ```xml
146
- <Alloy>
147
- <TableViewRow id="rowView"/>
148
- </Alloy>
149
- ```
150
-
151
- **app/controllers/row.js (Alloy 1.6+)**
152
-
153
- ```
154
- $.rowView.title = $.args.title || '';
155
- $.rowView.url = $.args.url || '';
156
- ```
157
-
158
- **app/controllers/row.js (Alloy <1.6)**
159
-
160
- ```javascript
161
- const args = arguments[0] || {};
162
- ```
163
-
164
- In a separate controller containing the TableView object, called 'tableView', the code is cycling through an array of data and creating new instances of 'row' to supply it to 'tableView.'
165
-
166
- **app/controllers/index.js**
167
-
168
- ```javascript
169
- const data = [];
170
- for (let i=0; i<source.length; i++) {
171
- const arg = {
172
- title: source[i].postTitle,
173
- url: source[i].postLink
174
- };
175
- data.push(Alloy.createController('row', arg).getView());
176
- }
177
- $.tableView.setData(data);
178
- ```
179
-
180
- As seen in the example above, the controller is passing different arguments to the 'row' controller, creating unique instances of 'row'.
181
-
182
- ### Global Namespace
183
-
184
- Controllers can store and access global variables using the `Alloy.Globals` namespace. For example, you can store an instance of a parent window in Globals and access it in another window.
185
-
186
- Store the parent window:
187
-
188
- ```
189
- $.index.open();
190
- Alloy.Globals.parent = $.index;
191
- ```
192
-
193
- Access the parent window in another controller:
194
-
195
- ```javascript
196
- const parent = Alloy.Globals.parent;
197
- parent.close();
198
- ```
199
-
200
- Other non-controller JavaScript code can access the Globals variable but need to require the Alloy module. See [Extending Alloy](#extending-alloy-underscorejs-and-backbonejs) below.
201
-
202
- ## Initializer File (alloy.js)
203
-
204
- The initializer file `app/alloy.js` can be used to execute some code near the beginning of the application's lifecycle. The contents of this file will be executed right before the initial `index.js` controller is loaded, allowing you to execute code before any UI components are loaded and to override built-in Alloy functions before they are executed. The code in this file also has access to the `Alloy` namespace.
205
-
206
- For instance, the default `isTablet` method returns true if it is identified as an iPad, an Android device in the large or extra large group, or if either dimension exceeds 400 dp for Mobile Web application. To override that behavior, you can add the following code to `alloy.js`.
207
-
208
- ```
209
- Alloy.isTablet = () => {
210
- return !(Math.min(Ti.Platform.displayCaps.platformHeight, Ti.Platform.displayCaps.platformWidth) < 600);
211
- }
212
- ```
213
-
214
- ## Library Code and CommonJS Modules
215
-
216
- Some JavaScript code might not be suitable as controller code, since it does not have an associated view, or you want to separate it from the MVC framework for easier reusability. Create a folder called `lib` in the `app` directory of your Alloy project. Add your CommonJS modules or JavaScript code using the CommonJS format into the `lib` folder. These files are copied to the `Resources` folder, when compiling your Alloy project.
217
-
218
- To use the library or CommonJS module, require it with the library name or module name without the 'app/lib' path and '.js' extension:
219
-
220
- ```javascript
221
- const lib = require('library_name');
222
- lib.foo();
223
- ```
224
-
225
- > **⚠️ ⚠️ Warning**
226
- > Titanium and Alloy do not support the Node.js concept of "folders as modules". That is, requiring a folder name does not automatically load the `index.js` or `index.json` file inside the folder, or use the `package.json` file to locate the main entry point. You need to explicitly require the file that serves as the main entry point to the library.
227
-
228
- ### Specs Folder
229
-
230
- Starting with Alloy 1.2.0, you can add the `specs` folder to your project. Like the `lib` folder, use the `specs` folder to add files to your project, except the files are only used when the deployment type is **not** production.
231
-
232
- Create a folder called `specs` in the `app` directory of your Alloy project. Add your files to the specs folder. These files are copied to the `Resources` folder, when compiling your Alloy project if the deployment type is **not** production.
233
-
234
- Use the `ENV_PROD` variable to check if the application is running as a production target or not, before using the files in the `specs` folder.
235
-
236
- ```
237
- if (!ENV_PROD) {
238
- // Executes the fooFunction from the foo module
239
- require('specs/foo').fooFuntion();
240
- }
241
- ```
242
-
243
- ### Platform-Specific Library Folders
244
-
245
- Starting with Alloy 1.5.0, you can also create platform-specific subfolders in the `lib` directory. Just add a folder named **android** or **ios** under the component folder and add your platform-specific files for Android or iOS into the folder, respectively. Do not include the platform-specific folder name when referencing the file.
246
-
247
- ```
248
- app/
249
- ├──lib
250
- │ ├──ios
251
- │ │ └── library_name.js
252
- │ └── library_name.js
253
- ├──models
254
- ├──styles
255
- └──views
256
- └── index.xml
257
- ```
258
-
259
- ### Extending Alloy, Underscore.js and Backbone.js
260
-
261
- To access the Alloy API methods, such as `createController` and `createModel`, as well as Underscore.js and Backbone.js in CommonJS modules and JavaScript files in `app/lib`, you need to load those modules in to the library:
262
-
263
- ```javascript
264
- const Alloy = require('alloy'), _ = require("alloy/underscore")._, Backbone = require("alloy/backbone");
265
-
266
- // Alloy extended
267
- Alloy.createController('foo').getView().open();
268
-
269
- // Underscore extended
270
- const even = _.find([1, 2, 3, 4, 5, 6], num => num % 2 === 0);
271
- Ti.API.info(even);
272
-
273
- // Backbone extended
274
- const Book = Backbone.Model.extend();
275
- const book = new Book({title: 'Ulysses', author: 'James Joyce'});
276
- Ti.API.info(JSON.stringify(book));
277
- ```
278
-
279
- Currently, these modules are automatically available in the global scope and these APIs can be used without loading the modules. Referencing these modules without loading them first with the `require` method is discouraged and this behavior may be deprecated in the future. To ensure compatibility with future releases, always use the `require` method to load and use these modules.