@knowlearning/agents 0.9.20 → 0.9.22

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/generic.js CHANGED
@@ -329,7 +329,7 @@ export default function Agent({ host, token, WebSocket, protocol='ws', uuid, fet
329
329
 
330
330
  const unwatch = watch(id, ({ state }) => {
331
331
  if (references.length === 0) {
332
- callback(value)
332
+ callback(state)
333
333
  return
334
334
  }
335
335
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.20",
3
+ "version": "0.9.22",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",
@@ -1,6 +1,8 @@
1
1
  <template>
2
2
  <iframe
3
- :ref="el => setup(el)"
3
+ :v-if="resolvedId"
4
+ :key="resolvedId"
5
+ :ref="el => setup(el, resolvedId)"
4
6
  class="wrapper"
5
7
  allow="camera;microphone"
6
8
  />
@@ -12,30 +14,46 @@ export default {
12
14
  id: {
13
15
  type: String,
14
16
  required: true
17
+ },
18
+ path: {
19
+ type: Array,
20
+ default: []
15
21
  }
16
22
  },
23
+ data() {
24
+ return {
25
+ resolvedId: null
26
+ }
27
+ },
28
+ async created() {
29
+ this.startWatching()
30
+ },
31
+ watch: {
32
+ id() { this.startWatching() },
33
+ path: { deep: true, handler() { this.startWatching() } }
34
+ },
17
35
  unmounted() {
18
36
  if (this.embedding) this.embedding.remove()
19
37
  },
20
38
  methods: {
21
- setup(iframe) {
39
+ startWatching() {
40
+ if (this.stopWatching) this.stopWatching()
41
+ if (this.path.length) {
42
+ this.stopWatching = await Agent.watch([this.id, ...this.path], value => {
43
+ // TODO: ensure resolved value is uuid or URL
44
+ this.resolvedId = value
45
+ })
46
+ }
47
+ else this.resolvedId = this.id
48
+ },
49
+ async setup(iframe, id) {
22
50
  if (!iframe || this.iframe === iframe) return
23
51
 
24
- const { id } = this
25
52
  this.iframe = iframe
26
53
  this.embedding = Agent.embed({ id }, iframe)
27
54
  this.embedding.on('state', e => this.$emit('state', e))
28
55
  this.embedding.on('mutate', e => this.$emit('mutate', e))
29
56
  this.embedding.on('close', e => this.$emit('close', e))
30
-
31
- /*
32
- const { handle } = this.embedding
33
- // if save or edit are listened to, attach handler
34
- if (this.$attrs.onSave) {
35
- handle('save', () => new Promise((resolve, reject) => this.$emit('save', { resolve, reject })))
36
- }
37
- if (this.$attrs.onEdit) handle('edit', () => this.$emit('edit'))
38
- */
39
57
  }
40
58
  }
41
59
  }