@knowlearning/agents 0.9.60 → 0.9.62

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/browser.js CHANGED
@@ -1,2 +1,3 @@
1
- export { default as GenericAgent } from './agents/generic/index.js'
2
- export { default as browserAgent } from './agents/browser/initialize.js'
1
+ import browserAgent from './agents/browser/initialize.js'
2
+
3
+ export default browserAgent()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.60",
3
+ "version": "0.9.62",
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>
@@ -1,5 +1,5 @@
1
1
  import { watchEffect, defineAsyncComponent } from 'vue'
2
- import { browserAgent } from '../../../browser.js'
2
+ import browserAgent from '../../../agents/browser/initialize.js'
3
3
 
4
4
  // TODO: probably want to make this a util, and better fleshed out (with white instead of blacklist)
5
5
  function isScopeSerializable(v) {