@maccesar/titools 3.2.0 → 4.0.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.
- package/README.md +27 -61
- package/lib/cleanup.js +29 -0
- package/lib/commands/agents.js +8 -7
- package/lib/commands/skills.js +118 -23
- package/lib/config.js +13 -15
- package/lib/installer.js +5 -3
- package/lib/utils.js +36 -0
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +188 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +233 -0
- package/skills/alloy-guides/references/CONCEPTS.md +171 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +279 -0
- package/skills/alloy-guides/references/MODELS.md +742 -0
- package/skills/alloy-guides/references/MODELS_ADVANCED.md +482 -0
- package/skills/alloy-guides/references/PURGETSS.md +57 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +235 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +375 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +102 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +581 -0
- package/skills/alloy-guides/references/WIDGETS.md +160 -0
- package/skills/alloy-howtos/SKILL.md +179 -0
- package/skills/alloy-howtos/references/best_practices.md +121 -0
- package/skills/alloy-howtos/references/cli_reference.md +230 -0
- package/skills/alloy-howtos/references/config_files.md +158 -0
- package/skills/alloy-howtos/references/custom_tags.md +148 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +78 -0
- package/skills/alloy-howtos/references/samples.md +156 -0
- package/skills/purgetss/SKILL.md +184 -181
- package/skills/purgetss/references/EXAMPLES.md +8 -6
- package/skills/purgetss/references/app-branding.md +5 -0
- package/skills/purgetss/references/apply-directive.md +1 -1
- package/skills/purgetss/references/class-categories.md +1 -1
- package/skills/purgetss/references/class-index-properties.md +618 -0
- package/skills/purgetss/references/class-index.md +4 -610
- package/skills/purgetss/references/cli-commands.md +41 -410
- package/skills/purgetss/references/custom-fonts.md +292 -0
- package/skills/purgetss/references/custom-rules.md +1 -1
- package/skills/purgetss/references/customization-deep-dive.md +64 -1
- package/skills/purgetss/references/icon-fonts.md +208 -118
- package/skills/purgetss/references/installation-setup.md +4 -4
- package/skills/purgetss/references/migration-guide.md +53 -1
- package/skills/purgetss/references/multi-density-images.md +53 -2
- package/skills/purgetss/references/svg-pipeline.md +249 -0
- package/skills/purgetss/references/tikit-components.md +2 -2
- package/skills/purgetss/references/titanium-resets.md +2 -2
- package/skills/purgetss/references/ui-ux-design.md +7 -5
- package/skills/purgetss/references/version-history.md +71 -82
- package/skills/ti-api/SKILL.md +128 -0
- package/skills/ti-api/references/api-android.md +675 -0
- package/skills/ti-api/references/api-app-platform.md +636 -0
- package/skills/ti-api/references/api-core.md +764 -0
- package/skills/ti-api/references/api-data-network.md +641 -0
- package/skills/ti-api/references/api-media.md +655 -0
- package/skills/ti-api/references/api-modules-ble-bluetooth.md +657 -0
- package/skills/ti-api/references/api-modules-coremotion-urlsession.md +411 -0
- package/skills/ti-api/references/api-modules-map.md +632 -0
- package/skills/ti-api/references/api-modules-nfc.md +725 -0
- package/skills/ti-api/references/api-modules-social-misc.md +526 -0
- package/skills/ti-api/references/api-services.md +700 -0
- package/skills/ti-api/references/api-ui-android.md +499 -0
- package/skills/ti-api/references/api-ui-extras.md +702 -0
- package/skills/ti-api/references/api-ui-ios-animator.md +378 -0
- package/skills/ti-api/references/api-ui-ios.md +756 -0
- package/skills/ti-api/references/api-ui-lists.md +581 -0
- package/skills/ti-api/references/api-ui-text-input.md +607 -0
- package/skills/ti-api/references/api-ui-views.md +572 -0
- package/skills/ti-api/references/api-ui-windows-navigation.md +676 -0
- package/skills/ti-api/references/api-xml-global.md +743 -0
- package/skills/ti-guides/SKILL.md +82 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +155 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +373 -0
- package/skills/ti-guides/references/application-frameworks.md +366 -0
- package/skills/ti-guides/references/cli-reference.md +700 -0
- package/skills/ti-guides/references/coding-best-practices.md +150 -0
- package/skills/ti-guides/references/commonjs-advanced.md +279 -0
- package/skills/ti-guides/references/hello-world.md +99 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +458 -0
- package/skills/ti-guides/references/javascript-primer.md +402 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +172 -0
- package/skills/ti-guides/references/style-and-conventions.md +104 -0
- package/skills/ti-guides/references/tiapp-config.md +655 -0
- package/skills/ti-howtos/SKILL.md +131 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +609 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +96 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +162 -0
- package/skills/ti-howtos/references/cross-platform-development.md +358 -0
- package/skills/ti-howtos/references/debugging-profiling.md +473 -0
- package/skills/ti-howtos/references/extending-titanium.md +684 -0
- package/skills/ti-howtos/references/google-maps-v2.md +172 -0
- package/skills/ti-howtos/references/ios-map-kit.md +149 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +595 -0
- package/skills/ti-howtos/references/local-data-sources.md +310 -0
- package/skills/ti-howtos/references/location-and-maps.md +267 -0
- package/skills/ti-howtos/references/media-apis.md +268 -0
- package/skills/ti-howtos/references/notification-services.md +539 -0
- package/skills/ti-howtos/references/remote-data-sources.md +339 -0
- package/skills/ti-howtos/references/tutorials.md +552 -0
- package/skills/ti-howtos/references/using-modules.md +182 -0
- package/skills/ti-howtos/references/web-content-integration.md +288 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +125 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# Media APIs
|
|
2
|
+
|
|
3
|
+
## 1. Audio APIs
|
|
4
|
+
|
|
5
|
+
### Playing basic sounds (Ti.Media.Sound)
|
|
6
|
+
- Use for short effects, beeps, ambient audio
|
|
7
|
+
- The entire file loads into memory. Use `preload=true` to reduce delay.
|
|
8
|
+
- Methods: `play()`, `pause()`, `stop()`, `setVolume()`
|
|
9
|
+
- `allowBackground=true` keeps playback going when the app closes
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
const sound = Ti.Media.createSound({
|
|
13
|
+
url: 'beep.mp3',
|
|
14
|
+
preload: true
|
|
15
|
+
});
|
|
16
|
+
sound.play();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Streaming audio (Ti.Media.AudioPlayer)
|
|
20
|
+
- Use for streaming web URLs (MP3, HLS)
|
|
21
|
+
- Supports pseudo-streaming and HLS
|
|
22
|
+
- Handle interruptions (phone calls) with app-level events:
|
|
23
|
+
- `pause`: call `setPaused(true)` or `pause()`
|
|
24
|
+
- `resume`: call `setPaused(false)` or `start()`
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
const streamer = Ti.Media.createAudioPlayer({ url: 'https://example.com/stream.mp3' });
|
|
28
|
+
streamer.start();
|
|
29
|
+
|
|
30
|
+
Ti.App.addEventListener('pause', () => { streamer.setPaused(true); });
|
|
31
|
+
Ti.App.addEventListener('resume', () => { streamer.setPaused(false); });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Recording audio (Ti.Media.AudioRecorder)
|
|
35
|
+
- Requires microphone permission
|
|
36
|
+
- Properties:
|
|
37
|
+
- `compression`: `Ti.Media.AUDIO_FORMAT_ULAW` (low-fi) or `AUDIO_FORMAT_LINEAR_PCM` (hi-fi)
|
|
38
|
+
- `format`: `Ti.Media.AUDIO_FILEFORMAT_WAVE`
|
|
39
|
+
- Methods: `start()`, `pause()`/`resume()`, `stop()`
|
|
40
|
+
|
|
41
|
+
## 2. Video APIs (Ti.Media.VideoPlayer)
|
|
42
|
+
|
|
43
|
+
### Cross-platform considerations
|
|
44
|
+
- Android: must be fullscreen (Intent-based, not a view proxy)
|
|
45
|
+
- iOS: can be embedded or fullscreen; set `height` and `width` for embedded
|
|
46
|
+
|
|
47
|
+
### Basic usage
|
|
48
|
+
- `url`: local file path or remote URL
|
|
49
|
+
- `autoplay=true`: auto-start when rendered
|
|
50
|
+
- `movieControlStyle`: `Ti.Media.VIDEO_CONTROL_EMBEDDED` for embedded controls
|
|
51
|
+
- `scalingMode`: control fill/fit behavior
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
const videoPlayer = Ti.Media.createVideoPlayer({
|
|
55
|
+
url: 'movie.mp4',
|
|
56
|
+
scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FIT // or ASPECT_FILL, MODE_FILL, NONE
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
const player = Ti.Media.createVideoPlayer({
|
|
62
|
+
url: 'movie.mp4',
|
|
63
|
+
movieControlStyle: Ti.Media.VIDEO_CONTROL_EMBEDDED,
|
|
64
|
+
autoplay: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// iOS only: add to window
|
|
68
|
+
if (Ti.Platform.osname === 'iphone' || Ti.Platform.osname === 'ipad') {
|
|
69
|
+
win.add(player);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Stop when window closes
|
|
73
|
+
win.addEventListener('close', () => { player.stop(); });
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Key events
|
|
77
|
+
- `complete`: playback ended (check `e.reason` vs `Ti.Media.VIDEO_FINISH_REASON_PLAYBACK_ENDED`)
|
|
78
|
+
- `load`: movie finished loading
|
|
79
|
+
- `fullscreen`: entered/exited fullscreen (check `e.entering`)
|
|
80
|
+
|
|
81
|
+
## 3. Camera and photo gallery APIs
|
|
82
|
+
|
|
83
|
+
### Camera availability and permissions
|
|
84
|
+
Always check device support and permissions before opening the camera:
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
if (!Ti.Media.isCameraSupported) {
|
|
88
|
+
Ti.API.warn('No camera available on this device');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (Ti.Media.hasCameraPermissions()) {
|
|
93
|
+
openCamera();
|
|
94
|
+
} else {
|
|
95
|
+
Ti.Media.requestCameraPermissions((e) => {
|
|
96
|
+
if (e.success) {
|
|
97
|
+
openCamera();
|
|
98
|
+
} else {
|
|
99
|
+
Ti.API.error('Camera permission denied');
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Required `tiapp.xml` keys (iOS):
|
|
106
|
+
|
|
107
|
+
```xml
|
|
108
|
+
<key>NSCameraUsageDescription</key>
|
|
109
|
+
<string>We need camera access to take photos</string>
|
|
110
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
111
|
+
<string>We need photo library access to save photos</string>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Camera (Ti.Media.showCamera)
|
|
115
|
+
- Requires camera permission and usage descriptions
|
|
116
|
+
- Success callback provides `event.media` (Blob)
|
|
117
|
+
- Use `saveToPhotoGallery: true` to auto-save
|
|
118
|
+
- Handle `cancel` and `error` callbacks
|
|
119
|
+
|
|
120
|
+
### Front and rear camera
|
|
121
|
+
```javascript
|
|
122
|
+
const cameras = Ti.Media.availableCameras;
|
|
123
|
+
|
|
124
|
+
// Check if front camera exists
|
|
125
|
+
if (cameras.indexOf(Ti.Media.CAMERA_FRONT) !== -1) {
|
|
126
|
+
Ti.Media.showCamera({
|
|
127
|
+
whichCamera: Ti.Media.CAMERA_FRONT,
|
|
128
|
+
// ... other options
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Switch camera programmatically
|
|
133
|
+
Ti.Media.switchCamera(Ti.Media.CAMERA_REAR);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Advanced camera options (iOS)
|
|
137
|
+
| Property | Description |
|
|
138
|
+
| ---------------------- | ----------------------------------------------- |
|
|
139
|
+
| `autohide` | Auto-hide camera after capture (default: true) |
|
|
140
|
+
| `animated` | Animate camera appearance |
|
|
141
|
+
| `allowEditing` | Allow user to crop/edit after capture |
|
|
142
|
+
| `mediaTypes` | Array: `MEDIA_TYPE_PHOTO`, `MEDIA_TYPE_VIDEO` |
|
|
143
|
+
| `videoMaximumDuration` | Max video duration in milliseconds |
|
|
144
|
+
| `videoQuality` | `QUALITY_HIGH`, `QUALITY_MEDIUM`, `QUALITY_LOW` |
|
|
145
|
+
| `overlay` | Custom `Ti.UI.View` overlay on camera |
|
|
146
|
+
| `showControls` | Show/hide default camera controls |
|
|
147
|
+
|
|
148
|
+
When using a custom overlay, call `Ti.Media.takePicture()` to capture and `Ti.Media.hideCamera()` to dismiss.
|
|
149
|
+
|
|
150
|
+
### Gallery (Ti.Media.openPhotoGallery)
|
|
151
|
+
- Success callback provides `event.media` (Blob)
|
|
152
|
+
- Note: `event.media` may only contain file info. Use `Ti.Filesystem.getFile(event.media.nativePath)` to access the actual file.
|
|
153
|
+
|
|
154
|
+
### iPad-specific gallery options
|
|
155
|
+
On iPad, the photo gallery opens as a popover. Configure its position:
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
Ti.Media.openPhotoGallery({
|
|
159
|
+
popoverView: myButton, // Anchor popover to this view
|
|
160
|
+
arrowDirection: Ti.UI.iPad.POPOVER_ARROW_DIRECTION_UP,
|
|
161
|
+
success: (e) => { /* ... */ }
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Memory management
|
|
166
|
+
Use `imageAsResized()` on blobs to avoid memory exhaustion. Resize to target dimensions before assigning to an ImageView.
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
Ti.Media.showCamera({
|
|
170
|
+
success: (event) => {
|
|
171
|
+
const blob = event.media.imageAsResized(800, 600);
|
|
172
|
+
imageView.image = blob;
|
|
173
|
+
},
|
|
174
|
+
cancel: () => { Ti.API.info('Camera canceled'); },
|
|
175
|
+
error: (e) => { Ti.API.error(`Camera error: ${e.error}`); }
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 4. Images and ImageView APIs
|
|
180
|
+
|
|
181
|
+
### Background images
|
|
182
|
+
- Scaled to fit component dimensions by default
|
|
183
|
+
- iOS: use `backgroundLeftCap` and `backgroundTopCap` to control stretch regions
|
|
184
|
+
- Android: supports remote URLs as background images; iOS does not
|
|
185
|
+
|
|
186
|
+
### Image stretching (background images)
|
|
187
|
+
When using small images as backgrounds, iOS and Android stretch differently:
|
|
188
|
+
- `backgroundLeftCap` (iOS): pixels from the left that are not stretched. The middle section stretches.
|
|
189
|
+
- `backgroundTopCap` (iOS): pixels from the top that are not stretched.
|
|
190
|
+
- Android: supports remote URLs for background images; iOS does not.
|
|
191
|
+
|
|
192
|
+
### ImageView component
|
|
193
|
+
- `image` accepts: URL, local path, or `Ti.Filesystem.File`
|
|
194
|
+
- Scaling behavior:
|
|
195
|
+
- Both `height` and `width` specified: unproportional scale (aspect ratio not maintained)
|
|
196
|
+
- Only one dimension specified: proportional scale (aspect ratio maintained)
|
|
197
|
+
- `defaultImage`: local image to show while remote image loads
|
|
198
|
+
|
|
199
|
+
### Density-specific images
|
|
200
|
+
|
|
201
|
+
Android: place in resolution-specific directories:
|
|
202
|
+
- `res-ldpi`, `res-mdpi`, `res-hdpi`, `res-xhdpi`, `res-xxhdpi`, `res-xxxhdpi`
|
|
203
|
+
|
|
204
|
+
iOS: use naming convention:
|
|
205
|
+
- `foo.png` - non-retina
|
|
206
|
+
- `foo@2x.png` - retina
|
|
207
|
+
- `foo@3x.png` - iPhone 6 Plus
|
|
208
|
+
- `foo~iphone.png` - iPhone-specific
|
|
209
|
+
- `foo~ipad.png` - iPad-specific
|
|
210
|
+
|
|
211
|
+
For remote density-specific images on iOS:
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
const density = Ti.Platform.displayCaps.logicalDensityFactor;
|
|
215
|
+
const url = `https://example.com/image@${density}x.png`;
|
|
216
|
+
const imageView = Ti.UI.createImageView({
|
|
217
|
+
image: url,
|
|
218
|
+
hires: true // Indicates high-resolution remote image
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Flipbook animations
|
|
223
|
+
- Assign an array of images to `images`
|
|
224
|
+
- `duration`: milliseconds between frames
|
|
225
|
+
- `repeatCount`: 0 = infinite, >1 = specific count
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
const frames = [];
|
|
229
|
+
for (let i = 1; i < 18; i++) {
|
|
230
|
+
frames.push(`frame${i}.png`);
|
|
231
|
+
}
|
|
232
|
+
const animationView = Ti.UI.createImageView({
|
|
233
|
+
images: frames,
|
|
234
|
+
duration: 100,
|
|
235
|
+
repeatCount: 0
|
|
236
|
+
});
|
|
237
|
+
// animationView.stop() / animationView.start() to control
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Permissions checklist
|
|
241
|
+
|
|
242
|
+
### iOS (tiapp.xml)
|
|
243
|
+
```xml
|
|
244
|
+
<ios>
|
|
245
|
+
<plist>
|
|
246
|
+
<dict>
|
|
247
|
+
<key>NSCameraUsageDescription</key>
|
|
248
|
+
<string>Need camera to take photos</string>
|
|
249
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
250
|
+
<string>Need photo library access</string>
|
|
251
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
252
|
+
<string>Need microphone for audio recording</string>
|
|
253
|
+
</dict>
|
|
254
|
+
</plist>
|
|
255
|
+
</ios>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Android (tiapp.xml)
|
|
259
|
+
```xml
|
|
260
|
+
<android>
|
|
261
|
+
<manifest>
|
|
262
|
+
<uses-permission android:name="android.permission.CAMERA"/>
|
|
263
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
264
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
265
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
266
|
+
</manifest>
|
|
267
|
+
</android>
|
|
268
|
+
```
|