@live-change/dao-vue3 0.8.102 → 0.8.104

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/lib/freezable.js +10 -4
  2. package/package.json +3 -3
package/lib/freezable.js CHANGED
@@ -1,5 +1,10 @@
1
1
  import { ref, onUnmounted, getCurrentInstance, unref, reactive, isRef, shallowRef, watch, computed } from 'vue'
2
2
 
3
+ function deepUnref(value) {
4
+ if(isRef(value)) return deepUnref(value.value)
5
+ return value
6
+ }
7
+
3
8
  export default function freezable(source) {
4
9
  if(typeof window === 'undefined') return {
5
10
  output: source,
@@ -10,16 +15,17 @@ export default function freezable(source) {
10
15
  const frozen = ref(false)
11
16
  function freeze() {
12
17
  if(frozen.value) return
13
- frozen.value = JSON.parse(JSON.stringify(source.value))
18
+ frozen.value = JSON.parse(JSON.stringify(deepUnref(source.value)))
14
19
  }
15
20
  function unfreeze() {
16
21
  frozen.value = false
17
22
  }
18
23
  const output = computed(() => {
19
- if(frozen.value) return frozen.value
24
+ if(frozen.value) return deepUnref(frozen.value)
20
25
  return source.value
21
26
  })
22
- console.log("FREEZABLE TEST", unref(source), unref(output))
23
- const changed = computed(() => JSON.stringify(unref(output)) !== JSON.stringify(unref(source)))
27
+ const changed = computed(() => {
28
+ return JSON.stringify(deepUnref(output)) !== JSON.stringify(deepUnref(source))
29
+ })
24
30
  return { output, freeze, unfreeze, changed }
25
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/dao-vue3",
3
- "version": "0.8.102",
3
+ "version": "0.8.104",
4
4
  "author": {
5
5
  "email": "m8@em8.pl",
6
6
  "name": "Michał Łaszczewski",
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/live-change/live-change-stack/issues"
11
11
  },
12
12
  "dependencies": {
13
- "@live-change/dao": "^0.8.102"
13
+ "@live-change/dao": "^0.8.104"
14
14
  },
15
15
  "type": "module",
16
16
  "description": "Vue.js integration for live-change dao",
@@ -32,5 +32,5 @@
32
32
  "scripts": {
33
33
  "compileTests": "webpack test/*.js tests-bundle.js"
34
34
  },
35
- "gitHead": "48f0f33881894e7036fe3cec501fe9ac6c103918"
35
+ "gitHead": "cb3692471fdd1ccd482eaa14a85b0cf1aa4a2efb"
36
36
  }