@knowlearning/agents 0.1.2 → 0.1.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/vue/3/component.js +15 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "package/node.js",
6
6
  "browser": "package/browser.js",
@@ -8,7 +8,7 @@ function isScopeSerializable(v) {
8
8
  )
9
9
  }
10
10
 
11
- export default async function (module) {
11
+ export default async function (module, props) {
12
12
  const component = module.default ? { ...module.default } : { ...module } // copy component since we will mess with mounted and data functions
13
13
 
14
14
  if (!component.ephemeral) {
@@ -29,30 +29,32 @@ export default async function (module) {
29
29
  const isReactiveRef = r => r && r.__v_isRef
30
30
  component.setup = function setupProxy(a, b) { // need to specifically add this here, otherwise second argument not passed in arguments array (probably because of webpack optimization...)
31
31
  const refs = origSetupFn.call(this, a, b)
32
+
32
33
  if (state) {
33
34
  Object
34
35
  .entries(state)
35
36
  .filter(([k]) => isReactiveRef(refs[k]))
36
37
  .forEach(([k, v]) => refs[k].value = v)
37
38
  }
38
- watchEffect(() => {
39
- interact(
40
- Object
41
- .entries(refs)
42
- .filter(([_,r]) => isReactiveRef(r) && isScopeSerializable(r.value) )
43
- .reduce((acc, [key, ref]) => {
44
- acc[key] = ref.value
45
- return acc
46
- }, {})
47
- )
48
- })
39
+
40
+ Object
41
+ .entries(refs)
42
+ .filter(([_,r]) => isReactiveRef(r) && isScopeSerializable(r.value))
43
+ .forEach(([key, ref]) => {
44
+ watchEffect(() => {
45
+ if (state[key] !== ref.value) {
46
+ state[key] = ref.value
47
+ }
48
+ })
49
+ })
50
+
49
51
  return refs
50
52
  }
51
53
  }
52
54
  }
53
55
 
54
56
  document.body.innerHTML = ''
55
- const app = createApp(component)
57
+ const app = createApp(component, props)
56
58
  app.component('Content', content)
57
59
  app.mount(document.body)
58
60
  }