@graffy/common 0.15.14 → 0.15.15-alpha.1

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/index.cjs CHANGED
@@ -643,9 +643,10 @@ function wrap(children, path, version = 0, prefix = false) {
643
643
  children = [__spreadProps(__spreadValues({}, encode$2(path[i--])), { version, children })];
644
644
  return children;
645
645
  }
646
- function unwrap(children, path) {
646
+ function unwrap(tree, path) {
647
647
  if (!Array.isArray(path))
648
648
  throw Error("unwrap.path_not_array " + path);
649
+ let children = tree;
649
650
  let node = { children };
650
651
  for (let i = 0; i < path.length; i++) {
651
652
  const { key } = encode$2(path[i]);
@@ -657,6 +658,8 @@ function unwrap(children, path) {
657
658
  return void 0;
658
659
  if (isRange(node))
659
660
  return null;
661
+ if (node.path)
662
+ return unwrap(tree, node.path.concat(path.slice(i + 1)));
660
663
  }
661
664
  return getNodeValue(node);
662
665
  }
package/index.mjs CHANGED
@@ -635,9 +635,10 @@ function wrap(children, path, version = 0, prefix = false) {
635
635
  children = [__spreadProps(__spreadValues({}, encode$2(path[i--])), { version, children })];
636
636
  return children;
637
637
  }
638
- function unwrap(children, path) {
638
+ function unwrap(tree, path) {
639
639
  if (!Array.isArray(path))
640
640
  throw Error("unwrap.path_not_array " + path);
641
+ let children = tree;
641
642
  let node = { children };
642
643
  for (let i = 0; i < path.length; i++) {
643
644
  const { key } = encode$2(path[i]);
@@ -649,6 +650,8 @@ function unwrap(children, path) {
649
650
  return void 0;
650
651
  if (isRange(node))
651
652
  return null;
653
+ if (node.path)
654
+ return unwrap(tree, node.path.concat(path.slice(i + 1)));
652
655
  }
653
656
  return getNodeValue(node);
654
657
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graffy/common",
3
3
  "description": "Common libraries that used by various Graffy modules.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.15.14",
5
+ "version": "0.15.15-alpha.1",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "lodash": "^4.17.19",
20
20
  "nanoid": "^3.1.25",
21
- "@graffy/stream": "0.15.14",
22
- "merge-async-iterators": "^0.2.1"
21
+ "merge-async-iterators": "^0.2.1",
22
+ "@graffy/stream": "0.15.15-alpha.1"
23
23
  }
24
24
  }
@@ -1,6 +1,6 @@
1
1
  export function wrapValue(value: any, path: any, version?: number): any;
2
2
  export function wrap(children: any, path: any, version?: number, prefix?: boolean): any;
3
- export function unwrap(children: any, path: any): any;
3
+ export function unwrap(tree: any, path: any): any;
4
4
  export function getNodeValue(node: any): any;
5
5
  export function remove(children: any, path: any): any;
6
6
  export const IS_VAL: unique symbol;