@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 +2 -2
- package/package.json +1 -1
- package/vue/3/components/scope.vue +30 -38
package/agents/deno.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { applyPatch } from '
|
|
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
|
|
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
|
@@ -6,46 +6,38 @@
|
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script>
|
|
9
|
+
import { ref, watch, onMounted, onBeforeUnmount } from 'vue'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
36
|
+
watch( [() => props.id, () => props.path], startWatching, { deep: true })
|
|
37
|
+
onMounted(() => startWatching())
|
|
38
|
+
onBeforeUnmount(() => stopWatching && stopWatching())
|
|
39
|
+
|
|
40
|
+
return { value }
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
</script>
|