@npcify/vue 0.4.1 → 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 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`) and `inputModes` (`'options'`,
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,13 @@ 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.
81
+ - Sight: call `startSight()` on the ready SDK after the conversation starts to
82
+ let the character see the player's camera, and `stopSight()` to close it.
83
+ `sightState` is `'unavailable'` until the owner turns sight on in the Sight
84
+ tab. See the `@npcify/web` README (Sight).
75
85
  - `@ready="handler"` and `@error="handler"` events expose the SDK and errors.
76
86
  - `class`/`style` (React: `className`/`style`) customize the outer div. It defaults
77
87
  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, InputMode, InputModeError, ListeningOptions, ListeningState, LoadCharacterOptions, Npcify, NpcifyCharacter, NpcifyView, PushToTalkOptions, 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 { mountNpcify } from "@npcify/web";
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 dispose;
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
- dispose = () => view.dispose();
37
+ mountedView = view;
38
+ view.setMemoryIdentifier(latestMemoryIdentifier);
35
39
  callbacks.onReady?.(view.npcify);
36
40
  }).catch(report);
37
- return () => {
38
- active = false;
39
- canvas.remove();
40
- void dispose?.().catch((error) => console.error(error));
41
- dispose = void 0;
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,7 +59,10 @@ import {
49
59
  NpcifyCharacter,
50
60
  createCharacter,
51
61
  loadCharacter,
62
+ DEFAULT_VARIANT_KEY,
63
+ NUDE_VARIANT_KEY,
52
64
  InputModeError,
65
+ SightError,
53
66
  SpeechInputError,
54
67
  bindPushToTalk
55
68
  } from "@npcify/web";
@@ -65,21 +78,23 @@ var NpcifyCanvas = defineComponent({
65
78
  },
66
79
  setup(props, { attrs, emit }) {
67
80
  const host = ref(null);
68
- let cleanup;
81
+ let attached;
69
82
  onMounted(() => {
70
83
  watch(
71
84
  [
72
85
  () => props.options.baseUrl,
73
86
  () => props.options.characterId,
74
87
  () => props.options.apiKey,
88
+ () => props.options.apiToken,
75
89
  () => props.options.serverRendering,
76
90
  () => props.options.assetProfile,
91
+ () => props.options.normalizeIdleOrientation,
77
92
  () => props.options.inputModes?.join(",")
78
93
  ],
79
94
  () => {
80
- cleanup?.();
95
+ attached?.dispose();
81
96
  if (host.value) {
82
- cleanup = attachCharacter(
97
+ attached = attachCharacter(
83
98
  host.value,
84
99
  { ...props.options },
85
100
  {
@@ -91,8 +106,14 @@ var NpcifyCanvas = defineComponent({
91
106
  },
92
107
  { immediate: true }
93
108
  );
109
+ watch(
110
+ () => props.options.memoryIdentifier,
111
+ (memoryIdentifier) => {
112
+ attached?.setMemoryIdentifier(memoryIdentifier);
113
+ }
114
+ );
94
115
  });
95
- onBeforeUnmount(() => cleanup?.());
116
+ onBeforeUnmount(() => attached?.dispose());
96
117
  return () => h("div", {
97
118
  ...attrs,
98
119
  ref: host,
@@ -102,10 +123,13 @@ var NpcifyCanvas = defineComponent({
102
123
  });
103
124
  export {
104
125
  Character,
126
+ DEFAULT_VARIANT_KEY,
105
127
  InputModeError,
128
+ NUDE_VARIANT_KEY,
106
129
  Npcify,
107
130
  NpcifyCanvas,
108
131
  NpcifyCharacter,
132
+ SightError,
109
133
  SpeechInputError,
110
134
  bindPushToTalk,
111
135
  createCharacter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npcify/vue",
3
- "version": "0.4.1",
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.4.1"
26
+ "@npcify/web": "^0.7.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "vue": "^3.5.0"