Skip to content

Commit bb34a2d

Browse files
committed
docs: add component docs
1 parent 0ffbedb commit bb34a2d

File tree

11 files changed

+259
-32
lines changed

11 files changed

+259
-32
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
workflow_dispatch:
66

7-
87
jobs:
98
# Build job
109
test:

build.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default defineBuildConfig({
2727
],
2828
entries: [
2929
// *.vue -> *.vue
30-
{ builder: 'mkdist', input: './src',pattern: ['**/*.vue'], loaders: ['vue'] },
30+
{ builder: 'mkdist', input: './src', pattern: ['**/*.vue'], loaders: ['vue'] },
3131
{ builder: 'mkdist', input: './src', pattern: ['**/*.ts'], format: 'cjs', ext: 'cjs', loaders: ['js'] },
3232
{ builder: 'mkdist', input: './src', pattern: ['**/*.ts'], format: 'esm', ext: 'mjs', loaders: ['js'] },
3333
],

docs/.vitepress/config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default defineConfig({
2020
// https://vitepress.dev/reference/default-theme-config
2121
nav: [
2222
{ text: 'Installation', link: '/installation' },
23-
{ text: 'Usage', link: '/usage' },
23+
{ text: 'Composables', link: '/composables' },
2424
{ text: 'Examples', link: '/examples' },
2525
],
2626

@@ -30,8 +30,12 @@ export default defineConfig({
3030
link: '/installation',
3131
},
3232
{
33-
text: 'Usage',
34-
link: '/usage',
33+
text: 'Composables',
34+
link: '/composables',
35+
},
36+
{
37+
text: 'Components',
38+
link: '/components',
3539
},
3640
{
3741
text: 'Examples',

docs/basic-example.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function handleStartClick() {
4343
const audio = computed(() => {
4444
if (!data.value?.length || state.value !== 'inactive')
4545
return
46-
const blob = new Blob(data.value, {type: mimeType.value})
46+
const blob = new Blob(data.value, { type: mimeType.value })
4747
return URL.createObjectURL(blob)
4848
})
4949
</script>

docs/components.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# API
6+
7+
## Props
8+
9+
### `constraints`
10+
11+
- Type: `MediaStreamConstraints`
12+
- Required: `true`
13+
14+
The constraints parameter is a MediaStreamConstraints object specifying the types of media to request, along with any
15+
requirements for each type.
16+
17+
### `mediaRecorderOptions`
18+
19+
- Type: `MediaRecorderOptions`
20+
- Default: `{}`
21+
22+
Options to pass to the MediaRecorder constructor. [See MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/MediaRecorder#options)
23+
24+
## Events
25+
26+
```ts
27+
defineEmits<{
28+
start: [ev: Event]
29+
stop: [ev: Event]
30+
pause: [ev: Event]
31+
resume: [ev: Event]
32+
error: [ev: Event]
33+
}>()
34+
```
35+
36+
Analog to the MediaRecorder events (`onstart`, `onpause`,...).
37+
38+
### `@start`
39+
40+
Emitted when the MediaRecorder starts recording.
41+
42+
### `@pause`
43+
44+
Emitted when the MediaRecorder pauses recording.
45+
46+
### `@resume`
47+
48+
Emitted when the MediaRecorder resumes recording.
49+
50+
### `@stop`
51+
52+
Emitted when the MediaRecorder stops recording.
53+
54+
### `@error`
55+
56+
Emitted when an error occurs.
57+
58+
## Slots
59+
60+
### `default`
61+
62+
The default slot is used to render the component's content.
63+
64+
#### slopProps
65+
66+
##### `data`
67+
68+
- Type: `Ref<Blob[]>`
69+
- Initial value: `ref([])`
70+
71+
An array of Blobs that are created by the MediaRecorder. The Blobs are created when the MediaRecorder is stopped. Or
72+
when the timeslice is set and the timeslice is reached.
73+
74+
##### `stream`
75+
76+
- Type: `ShallowRef<MediaStream | undefined>`
77+
- Initial value: `shallowRef()`
78+
79+
##### `state`
80+
81+
- Type: `ShallowRef<MediaRecorderState | undefined>`
82+
- Initial value: `shallowRef()`
83+
84+
The current state of the MediaRecorder. The state can be one of the following:
85+
86+
- `undefined` - The MediaRecorder is not initialized.
87+
- `'inactive'` - The MediaRecorder is not recording.
88+
- `'recording'` - The MediaRecorder is recording data.
89+
- `'paused'` - The MediaRecorder is paused.
90+
91+
##### `mimeType`
92+
93+
- Type: `ComputedRef<string | undefined>`
94+
- Initial value: `computed(()=>{})`
95+
96+
The mimeType of the MediaRecorder. The mimeType is set when the MediaRecorder is initialized and the stream is
97+
available. You can also set the mimeType manually via [`mediaRecorderOptions.mimeType`](#mediarecorderoptions).
98+
99+
::: warning
100+
If you set the mimeType manually (not recommended), make sure that the mimeType is supported by the browser. You can
101+
check if the mimeType
102+
is supported via [`isMimeTypeSupported`](#ismimetypesupported).
103+
:::
104+
105+
##### `isMimeTypeSupported`
106+
107+
- Type: `ComputedRef<boolean>`
108+
109+
If you set the mimeType manually, you can check if the mimeType is supported by the browser via this computed ref.
110+
111+
##### `isSupported`
112+
113+
- Type: `ComputedRef<boolean>`
114+
115+
If the MediaRecorder API (and the selected MIME type) is supported by the browser.
116+
117+
##### `mediaRecorder`
118+
119+
- Type: `ComputedRef<MediaRecorder | undefined>`
120+
- Initial value: `computed(()=>{})`
121+
122+
The MediaRecorder instance. The MediaRecorder is created when the stream is available.
123+
124+
##### `start`
125+
126+
- Type: `(timeslice: number | undefined) => Promise<void>`
127+
- MDN: [MediaRecorder.start()](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/start)
128+
129+
Creates the stream and the MediaRecorder instance. The stream is created with the constraints object. The MediaRecorder
130+
is created with the stream and the mediaRecorderOptions object.
131+
132+
##### `pause`
133+
134+
- Type: `() => void`
135+
- MDN: [MediaRecorder.pause()](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/pause)
136+
137+
##### `resume`
138+
139+
- Type: `() => void`
140+
- MDN: [MediaRecorder.resume()](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/resume)
141+
142+
##### `stop`
143+
144+
- Type: `() => void`
145+
- MDN: [MediaRecorder.stop()](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/stop)
146+
147+
## Methods
148+
149+
`UseMediaRecorder` does expose the following methods:
150+
151+
### `start(timeslice: number | undefined): Promise<void>`
152+
153+
- MDN: [MediaRecorder.start()](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/start)
154+
155+
Creates the stream and the MediaRecorder instance. The stream is created with the constraints object. The MediaRecorder
156+
is created with the stream and the mediaRecorderOptions object.
157+
158+
### `pause(): void`
159+
160+
- MDN: [MediaRecorder.pause()](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/pause)
161+
162+
### `resume(): void`
163+
164+
- MDN: [MediaRecorder.resume()](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/resume)
165+
166+
### `stop(): void`
167+
168+
- MDN: [MediaRecorder.stop()](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/stop)
169+
170+
### Usage
171+
172+
```vue
173+
<script setup>
174+
import { ref } from 'vue'
175+
const mr = ref() // or template ref
176+
177+
mr.value.start()
178+
</script>
179+
180+
<template>
181+
<UseMediaRecorder ref="mr" />
182+
</template>
183+
```

0 commit comments

Comments
 (0)