The examples in this page use the Prototype library, which is included by default inside a portal. However, the same concepts may be applied using other implementations.
These set of actions can retrieve a Titanium Modules information from the Studio. The actions support both Mobile modules and Desktop modules.
This command is executed immediately in a synchronous way.
The following dispatch call will get the Titanium Mobile Modules information:
The returned mobules information JSON is a Map object that has two roots:
- global_modules - Holds the modules that were installed into the Titanium SDK folder (<sdk-dir>/modules).
- project_modules - Holds the modules that were installed into the opened Titanium Mobile Projects in the workspace.
As described above, the Global Modules are the modules that were installed into the Titanium SDK modules directory.
The hash value for the global_modules key holds an array of module-descriptions. Each item in this array is a hash that holds the following information:
The name of the module
The platforms that this module has support for (an array)
The versions that this module has support for (an array)
The module-type ('global' or 'project', and in this case - only 'global')
The Studio collects all the modules information from the Titanium Mobile Projects in the workspace. Modules that were located under a modules directory in a project are considered as installed-modules for that project.
The hash value for the project_modules key holds a hash that maps from a project-name to an array of modules. Each module in that array holds the same information as described above, with the minor difference in the 'type' field.
JSON Structure Illustration
Here is an illustration that describes the form of the returned JSON object.
Installing a Module
You can download and install a Mobile Module by using the 'installModule' action.
The "target" and the "project-name" are optional arguments.
The 'target' can be one of global_modules or project_modules.
When a 'global_modules' string is passed in, there is no need for the last argument, and the module will be downloaded and installed into the global space (the Titanium SDK modules directory).
The 'project_modules' argument required a third argument that specify the project name that the module will be deployed into.
When the given URL is null or empty, the Studio will display a module-deployment dialog that will allow the user to input a valid URL and select the deployment target. The the URL is the only argument given here, the Studio will display the same dialog, but this time without the URL field (just the deployment-target selection).
The following dispatch call will get the Titanium Desktop Modules information:
The returned mobules information JSON is a Map object that holds the versions of the installed modules as keys, and holds an array of module-names as values.
Sample of use
See studio3-sdk repository (modules.js)