@npcify/vue 0.5.0 → 0.7.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 +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -64,7 +64,10 @@ 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`)
|
|
67
|
+
`assetProfile` (`original` or `web-optimized-v1`), `memoryIdentifier` (player
|
|
68
|
+
memory identifier when **SDK Player Memory** is enabled in **Export → Web SDK**;
|
|
69
|
+
leave empty or `null` to share the character owner's **Dashboard → Memory**
|
|
70
|
+
bucket, and update in place without remounting the canvas), and `inputModes` (`'options'`,
|
|
68
71
|
`'text'`, `'voice'`; `'voice'` needs the character's voice input, which the
|
|
69
72
|
owner turns on in the STT tab). See Export → Web SDK for the character's
|
|
70
73
|
configuration.
|
|
@@ -72,6 +75,9 @@ const reply = async (label) => {
|
|
|
72
75
|
- Voice input: call `bindPushToTalk({ element })` on the ready SDK to talk while
|
|
73
76
|
the player holds a button or Space; the release sends the speech. See the
|
|
74
77
|
`@npcify/web` README (Voice input and input modes).
|
|
78
|
+
- Typing: call `notifyUserTyping(true)` on the ready SDK from your text
|
|
79
|
+
field's `input` event, so that the character looks at the player while
|
|
80
|
+
they type.
|
|
75
81
|
- Sight: call `startSight()` on the ready SDK after the conversation starts to
|
|
76
82
|
let the character see the player's camera, and `stopSight()` to close it.
|
|
77
83
|
`sightState` is `'unavailable'` until the owner turns sight on in the Sight
|
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, InputMode, InputModeError, ListeningOptions, ListeningState, LoadCharacterOptions, Npcify, NpcifyCharacter, NpcifyView, PushToTalkOptions, SightError, SightObservationEvent, SightOptions, SightState, SpeechInputError, SpeechInputResult, TranscriptEvent, bindPushToTalk, createCharacter, loadCharacter } from '@npcify/web';
|
|
4
|
+
export { AvatarVariantSummary, Character, CharacterAnimation, CharacterAnimationPlayOptions, CharacterAudio, CharacterDisposeOptions, CharacterExpressions, CharacterOptions, CharacterShadowOptions, CharacterSpeechState, CharacterTransformOptions, CharacterVariantChangeEvent, DEFAULT_VARIANT_KEY, InputMode, InputModeError, ListeningOptions, ListeningState, LoadCharacterOptions, NUDE_VARIANT_KEY, Npcify, NpcifyCharacter, NpcifyEventMap, NpcifyEventName, NpcifyView, PushToTalkOptions, SightError, SightObservationEvent, SightOptions, SightState, SpeechInputError, SpeechInputResult, StagingToolCall, StagingToolCallResult, TranscriptEvent, VariantChangeEvent, bindPushToTalk, createCharacter, loadCharacter } from '@npcify/web';
|
|
5
5
|
|
|
6
6
|
type NpcifyOptions = Omit<MountNpcifyOptions, 'canvas' | 'onError'>;
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -9,13 +9,16 @@ import {
|
|
|
9
9
|
} from "vue";
|
|
10
10
|
|
|
11
11
|
// ../framework-bindings/lifecycle.ts
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
mountNpcify
|
|
14
|
+
} from "@npcify/web";
|
|
13
15
|
var attachCharacter = function(host, options, callbacks) {
|
|
14
16
|
const canvas = document.createElement("canvas");
|
|
15
17
|
canvas.style.cssText = "display:block;width:100%;height:100%;touch-action:none";
|
|
16
18
|
host.append(canvas);
|
|
17
19
|
let active = true;
|
|
18
|
-
let
|
|
20
|
+
let mountedView;
|
|
21
|
+
let latestMemoryIdentifier = options.memoryIdentifier;
|
|
19
22
|
const report = (value) => {
|
|
20
23
|
const error = value instanceof Error ? value : new Error(String(value));
|
|
21
24
|
if (active) {
|
|
@@ -31,14 +34,21 @@ var attachCharacter = function(host, options, callbacks) {
|
|
|
31
34
|
await view.dispose();
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
|
-
|
|
37
|
+
mountedView = view;
|
|
38
|
+
view.setMemoryIdentifier(latestMemoryIdentifier);
|
|
35
39
|
callbacks.onReady?.(view.npcify);
|
|
36
40
|
}).catch(report);
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
return {
|
|
42
|
+
setMemoryIdentifier: (memoryIdentifier) => {
|
|
43
|
+
latestMemoryIdentifier = memoryIdentifier;
|
|
44
|
+
mountedView?.setMemoryIdentifier(memoryIdentifier);
|
|
45
|
+
},
|
|
46
|
+
dispose: () => {
|
|
47
|
+
active = false;
|
|
48
|
+
canvas.remove();
|
|
49
|
+
void mountedView?.dispose().catch((error) => console.error(error));
|
|
50
|
+
mountedView = void 0;
|
|
51
|
+
}
|
|
42
52
|
};
|
|
43
53
|
};
|
|
44
54
|
|
|
@@ -49,6 +59,8 @@ import {
|
|
|
49
59
|
NpcifyCharacter,
|
|
50
60
|
createCharacter,
|
|
51
61
|
loadCharacter,
|
|
62
|
+
DEFAULT_VARIANT_KEY,
|
|
63
|
+
NUDE_VARIANT_KEY,
|
|
52
64
|
InputModeError,
|
|
53
65
|
SightError,
|
|
54
66
|
SpeechInputError,
|
|
@@ -66,21 +78,23 @@ var NpcifyCanvas = defineComponent({
|
|
|
66
78
|
},
|
|
67
79
|
setup(props, { attrs, emit }) {
|
|
68
80
|
const host = ref(null);
|
|
69
|
-
let
|
|
81
|
+
let attached;
|
|
70
82
|
onMounted(() => {
|
|
71
83
|
watch(
|
|
72
84
|
[
|
|
73
85
|
() => props.options.baseUrl,
|
|
74
86
|
() => props.options.characterId,
|
|
75
87
|
() => props.options.apiKey,
|
|
88
|
+
() => props.options.apiToken,
|
|
76
89
|
() => props.options.serverRendering,
|
|
77
90
|
() => props.options.assetProfile,
|
|
91
|
+
() => props.options.normalizeIdleOrientation,
|
|
78
92
|
() => props.options.inputModes?.join(",")
|
|
79
93
|
],
|
|
80
94
|
() => {
|
|
81
|
-
|
|
95
|
+
attached?.dispose();
|
|
82
96
|
if (host.value) {
|
|
83
|
-
|
|
97
|
+
attached = attachCharacter(
|
|
84
98
|
host.value,
|
|
85
99
|
{ ...props.options },
|
|
86
100
|
{
|
|
@@ -92,8 +106,14 @@ var NpcifyCanvas = defineComponent({
|
|
|
92
106
|
},
|
|
93
107
|
{ immediate: true }
|
|
94
108
|
);
|
|
109
|
+
watch(
|
|
110
|
+
() => props.options.memoryIdentifier,
|
|
111
|
+
(memoryIdentifier) => {
|
|
112
|
+
attached?.setMemoryIdentifier(memoryIdentifier);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
95
115
|
});
|
|
96
|
-
onBeforeUnmount(() =>
|
|
116
|
+
onBeforeUnmount(() => attached?.dispose());
|
|
97
117
|
return () => h("div", {
|
|
98
118
|
...attrs,
|
|
99
119
|
ref: host,
|
|
@@ -103,7 +123,9 @@ var NpcifyCanvas = defineComponent({
|
|
|
103
123
|
});
|
|
104
124
|
export {
|
|
105
125
|
Character,
|
|
126
|
+
DEFAULT_VARIANT_KEY,
|
|
106
127
|
InputModeError,
|
|
128
|
+
NUDE_VARIANT_KEY,
|
|
107
129
|
Npcify,
|
|
108
130
|
NpcifyCanvas,
|
|
109
131
|
NpcifyCharacter,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npcify/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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.7.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"vue": "^3.5.0"
|