@knowlearning/agents 0.9.61 → 0.9.63

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/agents/deno.js CHANGED
@@ -1,10 +1,10 @@
1
- import { applyPatch } from 'https://esm.sh/fast-json-patch@3.1.1'
1
+ import { applyPatch } from 'npm:fast-json-patch@3.1.1'
2
2
  import Agent from './generic/index.js'
3
3
 
4
4
  const SERVE_HOST = Deno.env.get("SERVE_HOST")
5
5
  const SERVICE_ACCOUNT_TOKEN = Deno.env.get("SERVICE_ACCOUNT_TOKEN")
6
6
 
7
- export default () => new Agent({
7
+ export default new Agent({
8
8
  host: SERVE_HOST,
9
9
  token: () => Deno.readTextFile(SERVICE_ACCOUNT_TOKEN),
10
10
  WebSocket,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.61",
3
+ "version": "0.9.63",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",
@@ -6,46 +6,38 @@
6
6
  </template>
7
7
 
8
8
  <script>
9
+ import { ref, watch, onMounted, onBeforeUnmount } from 'vue'
9
10
 
10
- export default {
11
- props: {
12
- id: String,
13
- path: { type: Array, default: [] },
14
- placeholder: { type: String, default: '' },
15
- metadata: { type: Boolean, default: false }
16
- },
17
- data() {
18
- return {
19
- value: undefined
20
- }
21
- },
22
- watch: {
23
- id() { this.startWatching() },
24
- path: {
25
- deep: true,
26
- handler() { this.startWatching() }
27
- }
28
- },
29
- created() { this.startWatching() },
30
- beforeUnmount() {
31
- if (this.stopWatching) {
32
- this.stopWatchingAttempted = true
33
- this.stopWatching()
34
- }
35
- },
36
- methods: {
37
- async startWatching() {
38
- if (this.stopWatching) this.stopWatching()
39
- if (this.metadata) {
40
- const metadata = await Agent.metadata(this.id)
41
- this.value = this.path.length === 1 ? metadata[this.path[0]] : metadata
42
- }
43
- else this.stopWatching = Agent.watch([this.id, ...this.path], value => {
44
- if (this.stopWatchingAttempted) console.warn('Watcher not stopped for vueScopeComponent')
45
- else this.value = value
11
+ export default {
12
+ props: {
13
+ id: String,
14
+ path: { type: Array, default: [] },
15
+ placeholder: { type: String, default: '' },
16
+ metadata: { type: Boolean, default: false }
17
+ },
18
+ setup(props) {
19
+ const value = ref(undefined)
20
+ let stopWatching
21
+ let stopWatchingAttempted = false
22
+
23
+ const startWatching = async () => {
24
+ if (stopWatching) stopWatching()
25
+ if (props.metadata) {
26
+ const metadata = await Agent.metadata(props.id)
27
+ value.value = props.path.length === 1 ? metadata[props.path[0]] : metadata
28
+ } else {
29
+ stopWatching = Agent.watch([props.id, ...props.path], val => {
30
+ if (stopWatchingAttempted) console.warn('Watcher not stopped for vueScopeComponent')
31
+ else value.value = val
46
32
  })
47
33
  }
48
34
  }
49
- }
50
35
 
51
- </script>
36
+ watch( [() => props.id, () => props.path], startWatching, { deep: true })
37
+ onMounted(() => startWatching())
38
+ onBeforeUnmount(() => stopWatching && stopWatching())
39
+
40
+ return { value }
41
+ }
42
+ };
43
+ </script>