@vnejs/plugins.canvas.child.sprite.speak 0.2.4 → 0.2.6

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.
@@ -5,7 +5,7 @@ export declare class LayerSpriteSpeak extends ModuleCore<SpriteSpeakPluginEvents
5
5
  name: string;
6
6
  currentSpeaker: string | null;
7
7
  subscribe: () => void;
8
- onStart: () => Promise<import("@vnejs/shared").EmitResults<"vne:layer_sprite_speak:option_set"> | undefined>;
9
8
  onEnd: () => Promise<false | import("@vnejs/shared").EmitResults<"vne:layer_sprite_speak:option_set"> | undefined>;
9
+ onStart: () => Promise<import("@vnejs/shared").EmitResults<"vne:layer_sprite_speak:option_set"> | undefined>;
10
10
  onSpeaker: ({ speaker }?: SpriteSpeakSpeakerPayload) => Promise<void>;
11
11
  }
@@ -7,18 +7,18 @@ export class LayerSpriteSpeak extends ModuleCore {
7
7
  this.on(this.EVENTS.LAYER_SPRITE_SPEAK.START, this.onStart);
8
8
  this.on(this.EVENTS.LAYER_SPRITE_SPEAK.SPEAKER, this.onSpeaker);
9
9
  };
10
- onStart = async () => {
10
+ onEnd = async () => {
11
11
  if (!this.currentSpeaker)
12
12
  return;
13
13
  const sprite = (await this.emitOne(this.EVENTS.LAYER_SPRITE_SPEAK.SPRITE_GET, { speaker: this.currentSpeaker }));
14
- return sprite && this.emit(this.EVENTS.LAYER_SPRITE_SPEAK.OPTION_SET, { sprite, value: true });
14
+ this.currentSpeaker = null;
15
+ return sprite?.args?.options?.speak && this.emit(this.EVENTS.LAYER_SPRITE_SPEAK.OPTION_SET, { sprite, value: false });
15
16
  };
16
- onEnd = async () => {
17
+ onStart = async () => {
17
18
  if (!this.currentSpeaker)
18
19
  return;
19
20
  const sprite = (await this.emitOne(this.EVENTS.LAYER_SPRITE_SPEAK.SPRITE_GET, { speaker: this.currentSpeaker }));
20
- this.currentSpeaker = null;
21
- return sprite?.args?.options?.speak && this.emit(this.EVENTS.LAYER_SPRITE_SPEAK.OPTION_SET, { sprite, value: false });
21
+ return sprite && this.emit(this.EVENTS.LAYER_SPRITE_SPEAK.OPTION_SET, { sprite, value: true });
22
22
  };
23
23
  onSpeaker = async ({ speaker = "" } = {}) => {
24
24
  if (this.currentSpeaker && this.currentSpeaker !== speaker) {
@@ -18,7 +18,7 @@ export class LayerSpriteSpeakStaff extends ModuleCore {
18
18
  onOptionSet = async ({ sprite, value = false } = {}) => {
19
19
  if (!sprite)
20
20
  return;
21
- const args = await this.emitClone(sprite.args);
21
+ const args = structuredClone(sprite.args ?? {});
22
22
  if (!args.options)
23
23
  args.options = {};
24
24
  args.options.speak = value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.canvas.child.sprite.speak",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,22 +14,22 @@ export class LayerSpriteSpeak extends ModuleCore<SpriteSpeakPluginEvents, Sprite
14
14
  this.on(this.EVENTS.LAYER_SPRITE_SPEAK.SPEAKER, this.onSpeaker);
15
15
  };
16
16
 
17
- onStart = async () => {
17
+ onEnd = async () => {
18
18
  if (!this.currentSpeaker) return;
19
19
 
20
20
  const sprite = (await this.emitOne(this.EVENTS.LAYER_SPRITE_SPEAK.SPRITE_GET, { speaker: this.currentSpeaker })) as SpriteSpeakRecord | undefined;
21
21
 
22
- return sprite && this.emit(this.EVENTS.LAYER_SPRITE_SPEAK.OPTION_SET, { sprite, value: true });
22
+ this.currentSpeaker = null;
23
+
24
+ return sprite?.args?.options?.speak && this.emit(this.EVENTS.LAYER_SPRITE_SPEAK.OPTION_SET, { sprite, value: false });
23
25
  };
24
26
 
25
- onEnd = async () => {
27
+ onStart = async () => {
26
28
  if (!this.currentSpeaker) return;
27
29
 
28
30
  const sprite = (await this.emitOne(this.EVENTS.LAYER_SPRITE_SPEAK.SPRITE_GET, { speaker: this.currentSpeaker })) as SpriteSpeakRecord | undefined;
29
31
 
30
- this.currentSpeaker = null;
31
-
32
- return sprite?.args?.options?.speak && this.emit(this.EVENTS.LAYER_SPRITE_SPEAK.OPTION_SET, { sprite, value: false });
32
+ return sprite && this.emit(this.EVENTS.LAYER_SPRITE_SPEAK.OPTION_SET, { sprite, value: true });
33
33
  };
34
34
 
35
35
  onSpeaker = async ({ speaker = "" }: SpriteSpeakSpeakerPayload = {}) => {
@@ -33,7 +33,7 @@ export class LayerSpriteSpeakStaff extends ModuleCore<SpriteSpeakPluginEvents, S
33
33
  onOptionSet = async ({ sprite, value = false }: SpriteSpeakSetOptionPayload = {}) => {
34
34
  if (!sprite) return;
35
35
 
36
- const args = await this.emitClone<SpriteSpeakArgs>(sprite.args);
36
+ const args = structuredClone(sprite.args ?? {});
37
37
 
38
38
  if (!args.options) args.options = {};
39
39
  args.options.speak = value;