@knowlearning/agents 0.9.141 → 0.9.143
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/browser/initialize.js +11 -7
- package/download-url-registry.js +1 -0
- package/package.json +1 -1
- package/vue/image.vue +31 -0
- package/vue.js +1 -0
|
@@ -5,6 +5,12 @@ import selectFile from './select-file.js'
|
|
|
5
5
|
|
|
6
6
|
let Agent
|
|
7
7
|
|
|
8
|
+
function getNamespacedScope(namespace, scope) {
|
|
9
|
+
const allow = namespace?.allow || []
|
|
10
|
+
const prefix = typeof namespace === 'string' ? namespace : namespace?.prefix
|
|
11
|
+
return prefix && !validateUUID(scope) && !allow.some(allowPrefix => scope.startsWith(allowPrefix)) ? `${prefix}/${scope}` : scope
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
export default function browserAgent(options={}) {
|
|
9
15
|
if (Agent && !options.unique) return Agent
|
|
10
16
|
|
|
@@ -80,16 +86,14 @@ function embed(environment, iframe) {
|
|
|
80
86
|
}
|
|
81
87
|
else if (type === 'interact') {
|
|
82
88
|
let { scope, patch } = message
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
await Agent.interact(scope, patch, false)
|
|
87
|
-
if (listeners.mutate) listeners.mutate({ scope })
|
|
89
|
+
const namespacedScope = getNamespacedScope(environment.namespace, scope)
|
|
90
|
+
await Agent.interact(namespacedScope, patch, false)
|
|
91
|
+
if (listeners.mutate) listeners.mutate({ scope: namespacedScope })
|
|
88
92
|
sendDown({}) // TODO: might want to send down the interaction index
|
|
89
93
|
}
|
|
90
94
|
else if (type === 'metadata') {
|
|
91
95
|
const { scope, user, domain } = message
|
|
92
|
-
const namespacedScope = environment.namespace
|
|
96
|
+
const namespacedScope = getNamespacedScope(environment.namespace, scope)
|
|
93
97
|
|
|
94
98
|
sendDown(await Agent.metadata(namespacedScope, user, domain))
|
|
95
99
|
}
|
|
@@ -100,7 +104,7 @@ function embed(environment, iframe) {
|
|
|
100
104
|
}
|
|
101
105
|
else if (type === 'state') {
|
|
102
106
|
const { scope, user, domain } = message
|
|
103
|
-
const namespacedScope = environment.namespace
|
|
107
|
+
const namespacedScope = getNamespacedScope(environment.namespace, scope)
|
|
104
108
|
|
|
105
109
|
const statePromise = Agent.state(namespacedScope, user, domain)
|
|
106
110
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {}
|
package/package.json
CHANGED
package/vue/image.vue
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<image
|
|
3
|
+
:key="downloadURL"
|
|
4
|
+
:src="downloadURL"
|
|
5
|
+
/>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
import { ref } from 'vue'
|
|
10
|
+
import downloadURLRegistry from '../download-url-registry.js'
|
|
11
|
+
|
|
12
|
+
const props = defineProps({ id: String })
|
|
13
|
+
|
|
14
|
+
downloadURL = ref(downloadURLRegistry[props.id])
|
|
15
|
+
|
|
16
|
+
if (!downloadURL.value) setDownloadURL()
|
|
17
|
+
|
|
18
|
+
watch(props, setDownloadURL)
|
|
19
|
+
|
|
20
|
+
let latestRequest = 0
|
|
21
|
+
async function setDownloadURL() {
|
|
22
|
+
downloadURL.value = null
|
|
23
|
+
latestRequest += 1
|
|
24
|
+
|
|
25
|
+
const thisRequest = latestRequest
|
|
26
|
+
const newURL = downloadURLRegistry[props.id] || await Agent.download(props.id).url()
|
|
27
|
+
|
|
28
|
+
downloadURLRegistry[props.id] = newURL
|
|
29
|
+
if (latestRequest === thisRequest) downloadURL.value = newURL
|
|
30
|
+
}
|
|
31
|
+
</script>
|
package/vue.js
CHANGED
|
@@ -3,3 +3,4 @@ export { default as vuePersistentComponent } from './vue/3/persist/component.js'
|
|
|
3
3
|
export { default as vueEmbedComponent } from './vue/3/components/embed.vue'
|
|
4
4
|
export { default as vueNameComponent } from './vue/3/components/name.vue'
|
|
5
5
|
export { default as vueScopeComponent } from './vue/3/components/scope.vue'
|
|
6
|
+
export { default as UUIDImage } from './vue/image.vue'
|