@knowlearning/agents 0.9.126 → 0.9.128

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.
@@ -18,8 +18,8 @@ export default function browserAgent(options={}) {
18
18
 
19
19
  const originalUpload = newAgent.upload
20
20
  newAgent.upload = async info => {
21
- if (info && info.browser) {
22
- const file = await selectFile()
21
+ if (info?.browser) {
22
+ const file = await selectFile(info)
23
23
  if (!file) return
24
24
 
25
25
  info.data = await file.arrayBuffer()
@@ -151,10 +151,6 @@ function embed(environment, iframe) {
151
151
  }
152
152
  })
153
153
 
154
- // write in a temporary loading notification while frame loads
155
- const cw = iframe.contentWindow
156
- if (cw) cw.document.body.innerHTML = 'Loading...'
157
-
158
154
  // TODO: make sure content security policy headers for embedded domain always restrict iframe
159
155
  // src to only self for embedded domain
160
156
  iframe.onload = () => {
@@ -1,7 +1,8 @@
1
- export default async function selectFile() {
1
+ export default async function selectFile({ accept }) {
2
2
  return new Promise((resolve, reject) => {
3
3
  const input = document.createElement('input')
4
4
  input.type = 'file'
5
+ input.accept = accept
5
6
 
6
7
  input.addEventListener('change', async (event) => {
7
8
  const file = event.target.files[0]
package/agents/watch.js CHANGED
@@ -80,9 +80,13 @@ export default function({ metadata, environment, state, watchers, synced, sentUp
80
80
  }
81
81
 
82
82
  function removeWatcher(key, fn) {
83
+ if (!watchers[key]) {
84
+ console.warn('NO WATCHERS FOR KEY', key, fn)
85
+ return
86
+ }
83
87
  const watcherIndex = watchers[key].findIndex(x => x === fn)
84
88
  if (watcherIndex > -1) watchers[key].splice(watcherIndex, 1)
85
- else console.warn('TRIED TO REMOVE WATCHER THAT DOES NOT EXIST')
89
+ else console.warn('TRIED TO REMOVE WATCHER THAT DOES NOT EXIST', key, fn)
86
90
  }
87
91
 
88
92
  return [ watch, removeWatcher ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.126",
3
+ "version": "0.9.128",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",