@ray-js/t-agent 0.2.0-beta-13 → 0.2.0-beta-15

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.
@@ -67,8 +67,8 @@ export default class ChatMessage {
67
67
  return;
68
68
  }
69
69
  await this.agent.hooks.callHook('onMessageChange:before', 'show', this);
70
- await this.agent.hooks.callHook('onMessageChange', 'show', this);
71
70
  this._isShow = true;
71
+ await this.agent.hooks.callHook('onMessageChange', 'show', this);
72
72
  this.agent.session.bindMessage(this);
73
73
  await this.agent.hooks.callHook('onMessageChange:after', 'show', this);
74
74
  });
@@ -3,6 +3,7 @@ export default class StreamResponse implements StreamResponseInstance {
3
3
  private partStream;
4
4
  private reader;
5
5
  private aborted;
6
+ private released;
6
7
  get started(): boolean;
7
8
  /**
8
9
  * Create a new StreamResponse instance.
@@ -15,6 +15,7 @@ export default class StreamResponse {
15
15
  constructor(partStream) {
16
16
  _defineProperty(this, "reader", null);
17
17
  _defineProperty(this, "aborted", false);
18
+ _defineProperty(this, "released", false);
18
19
  this.partStream = partStream;
19
20
  }
20
21
 
@@ -61,6 +62,7 @@ export default class StreamResponse {
61
62
  yield value;
62
63
  }
63
64
  } finally {
65
+ resp.released = true;
64
66
  reader.releaseLock();
65
67
  }
66
68
  })();
@@ -73,11 +75,10 @@ export default class StreamResponse {
73
75
  *
74
76
  * @param reason
75
77
  */
76
- cancel(reason) {
78
+ async cancel(reason) {
77
79
  this.aborted = true;
78
- if (this.reader) {
79
- return this.reader.cancel(reason);
80
+ if (this.reader && !this.released) {
81
+ await this.reader.cancel(reason);
80
82
  }
81
- throw new Error('cancel() can only be called after parts()');
82
83
  }
83
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent",
3
- "version": "0.2.0-beta-13",
3
+ "version": "0.2.0-beta-15",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -26,5 +26,5 @@
26
26
  "build": "ray build --type=component --output dist",
27
27
  "clean": "rimraf ./dist"
28
28
  },
29
- "gitHead": "ad4d4b4637a4a5396bcf5adf21adcbf215561436"
29
+ "gitHead": "f6fabb33ac8ef9cb264fbde8bec12dacc1d63ed7"
30
30
  }