@octane-xplat/media 0.9.0 → 0.11.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # `@octane-xplat/media`
2
2
 
3
+ ```sh
4
+ pnpm add @octane-xplat/media
5
+ ```
6
+
3
7
  Still-image picking and OS camera capture for Octane xplat apps. iOS runs
4
8
  `@nativescript/imagepicker` + `@nativescript/camera`, Android the same
5
9
  plugins over its photo picker/camera intent; web uses `<input
@@ -7,10 +11,6 @@ type="file">` (with the `capture` attribute for camera shots, which mobile
7
11
  browsers route to the camera app); the macOS AppKit dev host reports
8
12
  `unsupported`.
9
13
 
10
- ```sh
11
- pnpm add @octane-xplat/media
12
- ```
13
-
14
14
  ```ts
15
15
  import { media } from '@octane-xplat/media'
16
16
 
@@ -25,10 +25,31 @@ resolves `null` (or `[]` for `pickImages`), so check the result rather
25
25
  than catching. `ensure('camera' | 'photos')` resolves
26
26
  `'granted' | 'denied' | 'unsupported'`.
27
27
 
28
+ ```tsx
29
+ import { useState } from 'octane'
30
+ import { Button, Image } from '@octane-xplat/ui'
31
+ import { media } from '@octane-xplat/media'
32
+
33
+ export function PhotoPicker() {
34
+ const [preview, setPreview] = useState<string | null>(null)
35
+ async function pickPhoto() {
36
+ if ((await media.ensure('photos')) !== 'granted') return
37
+ const photo = await media.pickImage()
38
+ if (photo) setPreview(photo.dataUrl)
39
+ }
40
+ return (
41
+ <>
42
+ <Button onPress={pickPhoto}>Choose photo</Button>
43
+ {preview && <Image src={preview} alt="Selected photo" />}
44
+ </>
45
+ )
46
+ }
47
+ ```
48
+
28
49
  For a live preview surface instead of one-shot capture, use
29
50
  [`@octane-xplat/camera`](../camera/README.md)'s `CameraView`.
30
51
 
31
- Guide: [Using device features](../../docs/platform-services.md);
32
- per-target availability: [platform notes](../../docs/platform-notes.md).
52
+ Guide: [Using device features](../../docs/platform/platform-services.md);
53
+ per-target availability: [platform notes](../../docs/notes/platform-notes.md).
33
54
  Exercised by the harness `Services` screen and
34
55
  [`CameraDemo`](../demos/src/CameraDemo.tsrx).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octane-xplat/media",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Image picking and OS camera capture for Octane xplat — matching web + NativeScript implementations",
5
5
  "keywords": [
6
6
  "android",
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- /** Optional capability — never throws for absence (docs/platform-services.md). */
1
+ /** Optional capability — never throws for absence (docs/platform/platform-services.md). */
2
2
  export interface Capability<T> {
3
3
  supported: boolean
4
4
  ensure(): Promise<'granted' | 'denied' | 'unsupported'>