@npcify/web 0.1.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 +113 -0
- package/dist/index.d.ts +970 -0
- package/dist/index.js +8314 -0
- package/examples/index.html +5 -0
- package/examples/main.js +40 -0
- package/package.json +45 -0
package/examples/main.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// main.js
|
|
2
|
+
import { mountNpcify } from '@npcify/web'
|
|
3
|
+
|
|
4
|
+
const start = document.querySelector('#start')
|
|
5
|
+
const replies = document.querySelector('#replies')
|
|
6
|
+
const status = document.querySelector('#status')
|
|
7
|
+
const view = await mountNpcify({
|
|
8
|
+
canvas: document.querySelector('#npc'),
|
|
9
|
+
baseUrl: 'https://api.npcify.ai',
|
|
10
|
+
characterId: 'YOUR_CHARACTER_ID',
|
|
11
|
+
apiKey: 'YOUR_SCOPED_API_KEY',
|
|
12
|
+
serverRendering: false, // Use the setting from Export → Web SDK.
|
|
13
|
+
onError: (error) => { status.textContent = error.message },
|
|
14
|
+
})
|
|
15
|
+
const { npcify } = view
|
|
16
|
+
npcify.onOptionsReady(({ options }) => {
|
|
17
|
+
replies.replaceChildren()
|
|
18
|
+
for (const option of options) {
|
|
19
|
+
const button = document.createElement('button')
|
|
20
|
+
button.textContent = option.label
|
|
21
|
+
button.onclick = async () => {
|
|
22
|
+
replies.replaceChildren()
|
|
23
|
+
try { await npcify.sendMessage(option.label) }
|
|
24
|
+
catch (error) { status.textContent = error.message }
|
|
25
|
+
}
|
|
26
|
+
replies.append(button)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
start.disabled = false
|
|
30
|
+
start.onclick = async () => {
|
|
31
|
+
start.disabled = true
|
|
32
|
+
try {
|
|
33
|
+
await npcify.unlockAudio()
|
|
34
|
+
await npcify.createConversation()
|
|
35
|
+
} catch (error) {
|
|
36
|
+
status.textContent = error.message
|
|
37
|
+
start.disabled = false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
window.addEventListener('pagehide', () => { void view.dispose() }, { once: true })
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@npcify/web",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-independent Npcify characters, live conversations and baked performances for the web",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"homepage": "https://npcify.ai",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"examples"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org/"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@opentelemetry/api": "^1.9.0",
|
|
27
|
+
"@pixiv/three-vrm": "^3.4.4",
|
|
28
|
+
"@pixiv/three-vrm-animation": "^3.4.4",
|
|
29
|
+
"socket.io-client": "^4.8.3",
|
|
30
|
+
"three": "^0.180.0",
|
|
31
|
+
"three-stdlib": "^2.36.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/three": "^0.180.0",
|
|
35
|
+
"tsup": "^8.5.0",
|
|
36
|
+
"typescript": "^5.9.3",
|
|
37
|
+
"@npcify/shared": "^0.1.0",
|
|
38
|
+
"@npcify/vrm-renderer": "^0.1.0",
|
|
39
|
+
"@npcify/web-client": "^0.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "pnpm -F @npcify/shared build && pnpm -F @npcify/vrm-renderer build && pnpm -F @npcify/web-client build && tsup",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
44
|
+
}
|
|
45
|
+
}
|