@npcify/vue 0.2.0 → 0.3.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 +6 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -2
- package/examples/App.vue +19 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -64,8 +64,12 @@ const reply = async (label) => {
|
|
|
64
64
|
## Component API
|
|
65
65
|
|
|
66
66
|
- `options`: `baseUrl`, `characterId`, `apiKey`, `serverRendering`, and optional
|
|
67
|
-
`assetProfile` (`original` or `web-optimized-v1`)
|
|
68
|
-
|
|
67
|
+
`assetProfile` (`original` or `web-optimized-v1`) and `inputModes` (`'options'`,
|
|
68
|
+
`'text'`, `'voice'`). See Export → Web SDK for the character's configuration.
|
|
69
|
+
These are JavaScript props, never HTML attributes.
|
|
70
|
+
- Voice input: call `bindPushToTalk({ element })` on the ready SDK to talk while
|
|
71
|
+
the player holds a button or Space; the release sends the speech. See the
|
|
72
|
+
`@npcify/web` README (Voice input and input modes).
|
|
69
73
|
- `@ready="handler"` and `@error="handler"` events expose the SDK and errors.
|
|
70
74
|
- `class`/`style` (React: `className`/`style`) customize the outer div. It defaults
|
|
71
75
|
to 100% width and 480px height. Give it a nonzero height.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { PropType } from 'vue';
|
|
3
3
|
import { MountNpcifyOptions, Npcify } from '@npcify/web';
|
|
4
|
-
export { Character, CharacterAnimation, CharacterAnimationPlayOptions, CharacterAudio, CharacterDisposeOptions, CharacterExpressions, CharacterOptions, CharacterShadowOptions, CharacterSpeechState, CharacterTransformOptions, LoadCharacterOptions, Npcify, NpcifyCharacter, NpcifyView, createCharacter, loadCharacter } from '@npcify/web';
|
|
4
|
+
export { Character, CharacterAnimation, CharacterAnimationPlayOptions, CharacterAudio, CharacterDisposeOptions, CharacterExpressions, CharacterOptions, CharacterShadowOptions, CharacterSpeechState, CharacterTransformOptions, InputMode, InputModeError, ListeningOptions, ListeningState, LoadCharacterOptions, Npcify, NpcifyCharacter, NpcifyView, PushToTalkOptions, SpeechInputError, SpeechInputResult, TranscriptEvent, bindPushToTalk, createCharacter, loadCharacter } from '@npcify/web';
|
|
5
5
|
|
|
6
6
|
type NpcifyOptions = Omit<MountNpcifyOptions, 'canvas' | 'onError'>;
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,10 @@ import {
|
|
|
48
48
|
Npcify,
|
|
49
49
|
NpcifyCharacter,
|
|
50
50
|
createCharacter,
|
|
51
|
-
loadCharacter
|
|
51
|
+
loadCharacter,
|
|
52
|
+
InputModeError,
|
|
53
|
+
SpeechInputError,
|
|
54
|
+
bindPushToTalk
|
|
52
55
|
} from "@npcify/web";
|
|
53
56
|
var NpcifyCanvas = defineComponent({
|
|
54
57
|
name: "NpcifyCanvas",
|
|
@@ -70,7 +73,8 @@ var NpcifyCanvas = defineComponent({
|
|
|
70
73
|
() => props.options.characterId,
|
|
71
74
|
() => props.options.apiKey,
|
|
72
75
|
() => props.options.serverRendering,
|
|
73
|
-
() => props.options.assetProfile
|
|
76
|
+
() => props.options.assetProfile,
|
|
77
|
+
() => props.options.inputModes?.join(",")
|
|
74
78
|
],
|
|
75
79
|
() => {
|
|
76
80
|
cleanup?.();
|
|
@@ -98,9 +102,12 @@ var NpcifyCanvas = defineComponent({
|
|
|
98
102
|
});
|
|
99
103
|
export {
|
|
100
104
|
Character,
|
|
105
|
+
InputModeError,
|
|
101
106
|
Npcify,
|
|
102
107
|
NpcifyCanvas,
|
|
103
108
|
NpcifyCharacter,
|
|
109
|
+
SpeechInputError,
|
|
110
|
+
bindPushToTalk,
|
|
104
111
|
createCharacter,
|
|
105
112
|
loadCharacter
|
|
106
113
|
};
|
package/examples/App.vue
CHANGED
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
{{ option.label }}
|
|
8
8
|
</button>
|
|
9
9
|
</div>
|
|
10
|
+
<button v-show="voice" ref="talk" type="button" :disabled="replies.length === 0">
|
|
11
|
+
{{ listening === 'idle' ? 'Hold to talk' : listening === 'recognizing' ? 'Recognizing…' : 'Listening…' }}
|
|
12
|
+
</button>
|
|
10
13
|
<p role="status">{{ status }}</p>
|
|
11
14
|
</template>
|
|
12
15
|
|
|
13
16
|
<script setup>
|
|
14
|
-
import { ref, shallowRef } from 'vue'
|
|
17
|
+
import { onBeforeUnmount, ref, shallowRef } from 'vue'
|
|
15
18
|
import { NpcifyCanvas } from '@npcify/vue'
|
|
16
19
|
|
|
17
20
|
const config = {
|
|
@@ -21,13 +24,27 @@ const config = {
|
|
|
21
24
|
serverRendering: false,
|
|
22
25
|
}
|
|
23
26
|
const npcify = shallowRef(null)
|
|
27
|
+
const talk = ref(null)
|
|
24
28
|
const started = ref(false)
|
|
25
29
|
const replies = ref([])
|
|
30
|
+
const voice = ref(false)
|
|
31
|
+
const listening = ref('idle')
|
|
26
32
|
const status = ref('')
|
|
33
|
+
let unbindTalk = () => {}
|
|
27
34
|
const reportError = (error) => { status.value = error.message }
|
|
28
35
|
const handleReady = (client) => {
|
|
29
36
|
npcify.value = client
|
|
30
37
|
client.onOptionsReady(({ options }) => { replies.value = options })
|
|
38
|
+
// Hold the button, or Space, to talk. The release sends the speech.
|
|
39
|
+
voice.value = client.inputModes.includes('voice')
|
|
40
|
+
client.onListeningState((state) => { listening.value = state })
|
|
41
|
+
client.onTranscript(({ text }) => { status.value = text })
|
|
42
|
+
unbindTalk = client.bindPushToTalk({
|
|
43
|
+
element: talk.value,
|
|
44
|
+
enabled: () => replies.value.length > 0,
|
|
45
|
+
onResult: ({ sent }) => { if (sent) replies.value = [] },
|
|
46
|
+
onError: reportError,
|
|
47
|
+
})
|
|
31
48
|
}
|
|
32
49
|
const start = async () => {
|
|
33
50
|
started.value = true
|
|
@@ -45,4 +62,5 @@ const reply = async (label) => {
|
|
|
45
62
|
try { await npcify.value.sendMessage(label) }
|
|
46
63
|
catch (error) { reportError(error) }
|
|
47
64
|
}
|
|
65
|
+
onBeforeUnmount(() => unbindTalk())
|
|
48
66
|
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npcify/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Vue components for Npcify characters and conversations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"registry": "https://registry.npmjs.org/"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@npcify/web": "^0.
|
|
26
|
+
"@npcify/web": "^0.3.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"vue": "^3.5.0"
|