@knowlearning/agents 0.5.11 → 0.5.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",
@@ -11,12 +11,15 @@ async function scopeIsUninitialized(scope) {
11
11
 
12
12
  export default async function (storeDefinition, scope=window.location.host) {
13
13
  let state = copy(await Agent.state(scope))
14
-
15
14
  const scopedPaths = getScopedPaths(storeDefinition)
16
15
  const stateAttachedStore = await attachModuleState(state, storeDefinition, scopedPaths)
17
16
  const s = stateAttachedStore.state
18
17
  const originalState = s instanceof Function ? s() : s
19
- const handlePatch = patch => Agent.interact(scope, patch)
18
+
19
+ const handlePatch = patch => {
20
+ patch.forEach(({ path }) => path.unshift('active'))
21
+ return Agent.interact(scope, patch)
22
+ }
20
23
 
21
24
  if (await scopeIsUninitialized(scope)) {
22
25
  state = copy(originalState)
@@ -73,8 +76,7 @@ async function attachModuleState(state, module, scopedPaths, path='') {
73
76
  }
74
77
  return { ...module, state: () => state }
75
78
  }
76
- else return module
77
-
79
+ else return state ? { ...module, state: () => state } : module
78
80
  }
79
81
 
80
82
  function getScopedPaths(module, path="", paths={}) {