reptree 0.8.1 → 0.9.0

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/dist/index.js CHANGED
@@ -462,7 +462,7 @@ function bindVertex(tree, id, schemaOrOptions) {
462
462
  }
463
463
 
464
464
  // src/Vertex.ts
465
- var Vertex = class _Vertex {
465
+ var Vertex = class {
466
466
  constructor(tree, state) {
467
467
  this.state = state;
468
468
  this._tree = tree;
@@ -540,19 +540,11 @@ var Vertex = class _Vertex {
540
540
  }
541
541
  /** Creates a new child vertex of this vertex. */
542
542
  newChild(props) {
543
- if (props && typeof props === "object" && "children" in props) {
544
- throw new Error("Passing children inside props is not supported at the moment");
545
- }
546
- const normalized = _Vertex.normalizePropsForCreation(props);
547
- return this.tree.newVertex(this.id, normalized);
543
+ return this.tree.newVertex(this.id, props);
548
544
  }
549
545
  /** Creates a new named child vertex of this vertex. */
550
546
  newNamedChild(name, props) {
551
- if (props && typeof props === "object" && "children" in props) {
552
- throw new Error("Passing children inside props is not supported at the moment");
553
- }
554
- const normalized = _Vertex.normalizePropsForCreation(props);
555
- return this.tree.newNamedVertex(this.id, name, normalized);
547
+ return this.tree.newNamedVertex(this.id, name, props);
556
548
  }
557
549
  /** Sets a property on this vertex. */
558
550
  setProperty(key, value) {
@@ -633,58 +625,6 @@ var Vertex = class _Vertex {
633
625
  bind(schemaOrOptions) {
634
626
  return bindVertex(this.tree, this.id, schemaOrOptions);
635
627
  }
636
- /**
637
- * Normalizes an input props object for vertex creation:
638
- * - Filters unsupported field types with a console warning
639
- * - When a name param is provided to newNamedChild, ignores conflicting name in props
640
- */
641
- static normalizePropsForCreation(props) {
642
- if (!props) return null;
643
- const input = props;
644
- const out = {};
645
- const skipped = [];
646
- const isJsonValue2 = (v) => {
647
- if (v === null) return true;
648
- const t = typeof v;
649
- if (t === "string" || t === "number" || t === "boolean") return true;
650
- if (Array.isArray(v)) return v.every(isJsonValue2);
651
- if (t === "object") {
652
- const proto = Object.getPrototypeOf(v);
653
- if (proto !== Object.prototype && proto !== null) return false;
654
- for (const val of Object.values(v)) {
655
- if (!isJsonValue2(val)) return false;
656
- }
657
- return true;
658
- }
659
- return false;
660
- };
661
- for (const [rawKey, rawValue] of Object.entries(input)) {
662
- if (rawValue === void 0) {
663
- continue;
664
- }
665
- if (rawKey === "children") continue;
666
- let key = rawKey;
667
- let value = rawValue;
668
- if (key === "_c") {
669
- if (value instanceof Date) {
670
- value = value.toISOString();
671
- } else if (typeof value === "string") {
672
- } else {
673
- skipped.push(rawKey);
674
- continue;
675
- }
676
- }
677
- if (!isJsonValue2(value)) {
678
- skipped.push(rawKey);
679
- continue;
680
- }
681
- out[key] = value;
682
- }
683
- if (skipped.length > 0) {
684
- throw new Error(`Unsupported property types for keys: ${skipped.join(", ")}`);
685
- }
686
- return Object.keys(out).length > 0 ? out : null;
687
- }
688
628
  };
689
629
 
690
630
  // src/StateVector.ts