@knowlearning/agents 0.9.166 → 0.9.168

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.
@@ -101,8 +101,21 @@ function embed(environment, iframe) {
101
101
  else if (type === 'interact') {
102
102
  let { scope, patch } = message
103
103
  const namespacedScope = getNamespacedScope(environment.namespace, scope)
104
+ let before, after
105
+ if (listeners.mutate) before = copy(await Agent.state(namespacedScope))
104
106
  await Agent.interact(namespacedScope, patch, false)
105
- if (listeners.mutate) listeners.mutate({ scope: namespacedScope })
107
+ if (listeners.mutate) after = copy(await Agent.state(namespacedScope))
108
+ if (listeners.mutate) {
109
+ const patchCopy = copy(patch)
110
+ patchCopy.forEach(op => op.path.shift()) // remove "active" path prefix
111
+ listeners
112
+ .mutate({
113
+ scope: namespacedScope,
114
+ before,
115
+ after,
116
+ patch: patchCopy
117
+ })
118
+ }
106
119
  sendDown({}) // TODO: might want to send down the interaction index
107
120
  }
108
121
  else if (type === 'metadata') {
@@ -6,9 +6,9 @@ import GenericAgent from '../generic/index.js'
6
6
  const TEST_DOMAIN = 'tests.knowlearning.systems'
7
7
  const LANGUAGES = [...navigator.languages]
8
8
 
9
- //const API_HOST = localStorage.getItem('API_HOST') || 'api.knowlearning.systems'
9
+ const API_HOST = localStorage.getItem('API_HOST') || 'api.knowlearning.systems'
10
10
  // const API_HOST = 'api-test.knowlearning.systems'
11
- const API_HOST = 'localhost:8765'
11
+ //const API_HOST = 'localhost:8765'
12
12
 
13
13
  // TODO: remove this hack when we can set partitioned sid cookie through websocket handshake
14
14
  // deno is partly in the way on teh set side, and browser support is in the way for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.166",
3
+ "version": "0.9.168",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",
@@ -39,7 +39,7 @@
39
39
  }
40
40
  </script>
41
41
 
42
- <style>
42
+ <style scoped>
43
43
  span
44
44
  {
45
45
  cursor: grab;