@npcify/web 0.4.0 → 0.5.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.
@@ -2,5 +2,6 @@
2
2
  <button id="start" disabled>Start conversation</button>
3
3
  <div id="replies"></div>
4
4
  <button id="talk" type="button" hidden disabled>Hold to talk</button>
5
+ <button id="see" type="button" hidden disabled>Let the character see you</button>
5
6
  <p id="status" role="status"></p>
6
7
  <script type="module" src="/main.js"></script>
package/examples/main.js CHANGED
@@ -10,6 +10,7 @@ const config = {
10
10
  const start = document.querySelector('#start')
11
11
  const replies = document.querySelector('#replies')
12
12
  const talk = document.querySelector('#talk')
13
+ const see = document.querySelector('#see')
13
14
  const status = document.querySelector('#status')
14
15
  const report = (error) => { status.textContent = error.message }
15
16
  const view = await mountNpcify({
@@ -56,12 +57,33 @@ character.onListeningState((state) => {
56
57
  { listening: 'Listening…', recognizing: 'Recognizing…' }[state] ?? 'Hold to talk'
57
58
  })
58
59
  character.onTranscript(({ text }) => { status.textContent = text })
60
+ // The character sees the camera when its owner turned sight on (the Sight
61
+ // tab). The first click asks for the camera permission.
62
+ const showSight = (state) => {
63
+ see.hidden = state === 'unavailable'
64
+ see.textContent =
65
+ { starting: 'Opening the camera…', on: 'Stop the camera' }[state] ?? 'Let the character see you'
66
+ }
67
+ showSight(character.sightState)
68
+ character.onSightState((state, error) => {
69
+ showSight(state)
70
+ if (error) report(error)
71
+ })
72
+ character.onSight(({ summary }) => { status.textContent = `The character sees: ${summary}` })
73
+ see.onclick = () => {
74
+ if (character.sightState === 'off') {
75
+ character.startSight().catch(report)
76
+ } else {
77
+ character.stopSight()
78
+ }
79
+ }
59
80
  start.disabled = false
60
81
  start.onclick = async () => {
61
82
  start.disabled = true
62
83
  try {
63
84
  await character.unlockAudio()
64
85
  await character.createConversation()
86
+ see.disabled = false
65
87
  } catch (error) {
66
88
  report(error)
67
89
  start.disabled = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npcify/web",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Framework-independent Npcify characters, live conversations and baked performances for the web",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -35,8 +35,8 @@
35
35
  "tsup": "^8.5.0",
36
36
  "typescript": "^5.9.3",
37
37
  "@npcify/shared": "^0.1.0",
38
- "@npcify/web-client": "^0.0.0",
39
- "@npcify/vrm-renderer": "^0.1.0"
38
+ "@npcify/vrm-renderer": "^0.1.0",
39
+ "@npcify/web-client": "^0.0.0"
40
40
  },
41
41
  "repository": {
42
42
  "type": "git",