Skip to content

Commit

Permalink
Merge pull request #613 from streamich/tree-dump
Browse files Browse the repository at this point in the history
Setup `tree-dump` package
  • Loading branch information
streamich authored May 1, 2024
2 parents d7e1e91 + be44520 commit 5ef7ba9
Show file tree
Hide file tree
Showing 46 changed files with 114 additions and 123 deletions.
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@
"@jsonjoy.com/util": "^1.1.0",
"arg": "^5.0.2",
"hyperdyperid": "^1.2.0",
"sonic-forest": "^1.0.0",
"thingies": "^2.0.0"
"sonic-forest": "^1.0.2",
"thingies": "^2.0.0",
"tree-dump": "^1.0.0"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand All @@ -148,13 +149,6 @@
"typescript": "^5.4.5"
},
"jest": {
"verbose": true,
"testEnvironmentOptions": {
"url": "http://localhost/"
},
"setupFiles": [
"<rootDir>/src/__tests__/setup.js"
],
"moduleFileExtensions": [
"ts",
"js"
Expand Down
2 changes: 0 additions & 2 deletions src/__tests__/setup.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/json-crdt-extensions/cnt/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {delayed} from '../../json-crdt-patch/builder/DelayedValueBuilder';
import {ext} from '../../json-crdt/extensions';
import {ExtensionId} from '../constants';
import {printTree} from '../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {NodeApi} from '../../json-crdt/model/api/nodes';
import type {ExtensionDefinition, ObjNode} from '../../json-crdt';
import type {ITimestampStruct} from '../../json-crdt-patch/clock';
import type {ExtensionJsonNode, JsonNode} from '../../json-crdt';
import type {Printable} from '../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {ExtensionApi} from '../../json-crdt';

const name = 'cnt';
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt-extensions/mval/ValueMv.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {ArrNode} from '../../json-crdt/nodes/arr/ArrNode';
import {printTree} from '../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import type {ITimestampStruct} from '../../json-crdt-patch/clock';
import type {ExtensionJsonNode, JsonNode} from '../../json-crdt';
import type {Printable} from '../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';

export class ValueMv implements ExtensionJsonNode, Printable {
public readonly id: ITimestampStruct;
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt-extensions/peritext/Peritext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {printTree} from 'sonic-forest/lib/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {Anchor} from './rga/constants';
import {Point} from './rga/Point';
import {Range} from './rga/Range';
Expand All @@ -11,7 +11,7 @@ import {interval} from '../../json-crdt-patch/clock';
import {CONST, updateNum} from '../../json-hash';
import type {ITimestampStruct} from '../../json-crdt-patch/clock';
import type {Model} from '../../json-crdt/model';
import type {Printable} from '../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {StringChunk} from './util/types';
import type {SliceType} from './types';
import type {MarkerSlice} from './slice/MarkerSlice';
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-extensions/peritext/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {PersistedSlice} from '../slice/PersistedSlice';
import {Chars} from '../constants';
import type {Range} from '../rga/Range';
import type {Peritext} from '../Peritext';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {Point} from '../rga/Point';
import type {SliceType} from '../types';
import type {MarkerSlice} from '../slice/MarkerSlice';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {Anchor} from '../rga/constants';
import type {AbstractRga} from '../../../json-crdt/nodes/rga';
import type {ITimestampStruct} from '../../../json-crdt-patch/clock';
import type {MarkerSlice} from '../slice/MarkerSlice';
import {printTree} from 'sonic-forest/lib/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';

export class MarkerOverlayPoint extends OverlayPoint {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/json-crdt-extensions/peritext/overlay/Overlay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {printTree} from 'sonic-forest/lib/print/printTree';
import {printBinary} from 'sonic-forest/lib/print/printBinary';
import {printTree} from 'tree-dump/lib/printTree';
import {printBinary} from 'tree-dump/lib/printBinary';
import {first, insertLeft, insertRight, next, prev, remove} from 'sonic-forest/lib/util';
import {splay} from 'sonic-forest/lib/splay/util';
import {Anchor} from '../rga/constants';
Expand All @@ -12,7 +12,7 @@ import {CONST, updateNum} from '../../../json-hash';
import {MarkerSlice} from '../slice/MarkerSlice';
import type {Peritext} from '../Peritext';
import type {Stateful} from '../types';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {MutableSlice, Slice} from '../slice/types';

export class Overlay implements Printable, Stateful {
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt-extensions/peritext/overlay/OverlayPoint.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Point} from '../rga/Point';
import {compare} from '../../../json-crdt-patch/clock';
import {OverlayRef, OverlayRefSliceEnd, OverlayRefSliceStart} from './refs';
import {printTree} from 'sonic-forest/lib/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import type {MarkerSlice} from '../slice/MarkerSlice';
import type {HeadlessNode} from 'sonic-forest/lib/types';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {Slice} from '../slice/types';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-extensions/peritext/rga/Point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {ChunkSlice} from '../util/ChunkSlice';
import {updateId} from '../../../json-crdt/hash';
import type {AbstractRga, Chunk} from '../../../json-crdt/nodes/rga';
import type {Stateful} from '../types';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';

/**
* A "point" in a rich-text Peritext document. It is a combination of a
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-extensions/peritext/rga/Range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Point} from './Point';
import {Anchor} from './constants';
import {updateNum} from '../../../json-hash';
import type {ITimestampStruct} from '../../../json-crdt-patch/clock';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {AbstractRga, Chunk} from '../../../json-crdt/nodes/rga';
import type {Stateful} from '../types';

Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-extensions/peritext/slice/Cursor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Point} from '../rga/Point';
import {CursorAnchor, SliceBehavior, Tags} from './constants';
import {Range} from '../rga/Range';
import {printTree} from '../../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {updateNum} from '../../../json-hash';
import type {ITimestampStruct} from '../../../json-crdt-patch/clock';
import type {Peritext} from '../Peritext';
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt-extensions/peritext/slice/PersistedSlice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Point} from '../rga/Point';
import {Range} from '../rga/Range';
import {updateNode} from '../../../json-crdt/hash';
import {printTree} from '../../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {Anchor} from '../rga/constants';
import {SliceHeaderMask, SliceHeaderShift, SliceBehavior, SliceTupleIndex} from './constants';
import {CONST} from '../../../json-hash';
Expand All @@ -15,7 +15,7 @@ import type {ArrChunk} from '../../../json-crdt/nodes';
import type {MutableSlice, SliceUpdateParams} from './types';
import type {Peritext} from '../Peritext';
import type {SliceDto, SliceType, Stateful} from '../types';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {AbstractRga} from '../../../json-crdt/nodes/rga';

export class PersistedSlice<T = string> extends Range<T> implements MutableSlice<T>, Stateful, Printable {
Expand Down
6 changes: 3 additions & 3 deletions src/json-crdt-extensions/peritext/slice/Slices.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {AvlMap} from 'sonic-forest/lib/avl/AvlMap';
import {printTree} from 'tree-dump/lib/printTree';
import {PersistedSlice} from './PersistedSlice';
import {Timespan, compare, tss} from '../../../json-crdt-patch/clock';
import {Range} from '../rga/Range';
import {updateRga} from '../../../json-crdt/hash';
import {CONST, updateNum} from '../../../json-hash';
import {printTree} from '../../../util/print/printTree';
import {SliceBehavior, SliceHeaderShift, SliceTupleIndex} from './constants';
import {MarkerSlice} from './MarkerSlice';
import {VecNode} from '../../../json-crdt/nodes';
import {AvlMap} from 'sonic-forest/lib/avl/AvlMap';
import type {Slice} from './types';
import type {ITimespanStruct, ITimestampStruct} from '../../../json-crdt-patch/clock';
import type {SliceType, Stateful} from '../types';
import type {Peritext} from '../Peritext';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {ArrChunk, ArrNode} from '../../../json-crdt/nodes';

export class Slices implements Stateful, Printable {
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-extensions/peritext/util/ChunkSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {updateId} from '../../../json-crdt/hash';
import {ITimestampStruct, Timestamp, toDisplayString} from '../../../json-crdt-patch/clock';
import type {IChunkSlice} from './types';
import type {Stateful} from '../types';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {Chunk} from '../../../json-crdt/nodes/rga';

export class ChunkSlice<T = string> implements IChunkSlice<T>, Stateful, Printable {
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-patch/Patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as operations from './operations';
import {ITimestampStruct, ts, toDisplayString} from './clock';
import {SESSION} from './constants';
import {encode, decode} from './codec/binary';
import type {Printable} from '../util/print/types';
import type {Printable} from 'tree-dump/lib/types';

/**
* A union type of all possible JSON CRDT patch operations.
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-patch/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Printable} from '../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {ITimestampStruct} from './clock';
import type {JsonCrdtPatchMnemonic} from './codec/verbose';

Expand Down
6 changes: 3 additions & 3 deletions src/json-crdt/extensions/Extensions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {printTree} from '../../util/print/printTree';
import {Printable} from '../../util/print/types';
import {ExtensionDefinition} from './types';
import {printTree} from 'tree-dump/lib/printTree';
import type {ExtensionDefinition} from './types';
import type {Printable} from 'tree-dump/lib/types';

export class Extensions implements Printable {
protected readonly ext: Record<number, ExtensionDefinition> = {};
Expand Down
8 changes: 4 additions & 4 deletions src/json-crdt/log/Log.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {AvlMap} from 'sonic-forest/lib/avl/AvlMap';
import {first, next} from 'sonic-forest/lib/util';
import {FanOutUnsubscribe} from 'thingies/lib/fanout';
import {printTree} from 'tree-dump/lib/printTree';
import {ITimestampStruct, Patch, compare} from '../../json-crdt-patch';
import {printTree} from '../../util/print/printTree';
import {AvlMap} from 'sonic-forest/lib/avl/AvlMap';
import {Model} from '../model';
import {first, next} from 'sonic-forest/lib/util';
import type {Printable} from '../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {JsonNode} from '../nodes/types';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt/model/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {ORIGIN, SESSION, SYSTEM_SESSION_TIME} from '../../json-crdt-patch/consta
import {randomSessionId} from './util';
import {RootNode, ValNode, VecNode, ObjNode, StrNode, BinNode, ArrNode} from '../nodes';
import {SchemaToJsonNode} from '../schema/types';
import {printTree} from '../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {Extensions} from '../extensions/Extensions';
import {AvlMap} from 'sonic-forest/lib/avl/AvlMap';
import type {JsonNode, JsonNodeView} from '../nodes/types';
import type {Printable} from '../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {NodeBuilder} from '../../json-crdt-patch';
import type {NodeApi} from './api/nodes';

Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt/model/api/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {Path} from '../../../json-pointer';
import {ObjNode, ArrNode, BinNode, ConNode, VecNode, ValNode, StrNode} from '../../nodes';
import {ExtensionApi, ExtensionDefinition, ExtensionJsonNode} from '../../extensions/types';
import {NodeEvents} from './NodeEvents';
import {printTree} from '../../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import type {JsonNode, JsonNodeView} from '../../nodes';
import type * as types from './proxy';
import type {ModelApi} from './ModelApi';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {JsonNodeApi} from './types';

export type ApiPath = string | number | Path | void;
Expand Down
6 changes: 3 additions & 3 deletions src/json-crdt/nodes/arr/ArrNode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {AbstractRga, Chunk} from '../rga/AbstractRga';
import {ITimestampStruct, tick} from '../../../json-crdt-patch/clock';
import {Model} from '../../model';
import {printBinary} from '../../../util/print/printBinary';
import {printTree} from '../../../util/print/printTree';
import {printBinary} from 'tree-dump/lib/printBinary';
import {printTree} from 'tree-dump/lib/printTree';
import type {JsonNode, JsonNodeView} from '..';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';

type E = ITimestampStruct;

Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt/nodes/const/ConNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {type ITimestampStruct, toDisplayString, Timestamp} from '../../../json-crdt-patch/clock';
import type {JsonNode} from '../types';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';

/**
* Represents the `con` type of the JSON CRDT specification.
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt/nodes/obj/ObjNode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {printTree} from 'tree-dump/lib/printTree';
import {compare, ITimestampStruct, toDisplayString} from '../../../json-crdt-patch/clock';
import {printTree} from '../../../util/print/printTree';
import type {Model} from '../../model';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type {JsonNode, JsonNodeView} from '..';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt/nodes/rga/AbstractRga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {rSplay, lSplay, llSplay, rrSplay, lrSplay, rlSplay} from 'sonic-forest/l
import {splay2} from 'sonic-forest/lib/splay/util2';
import {insert2, remove2} from 'sonic-forest/lib/util2';
import {ORIGIN} from '../../../json-crdt-patch/constants';
import {printTree} from '../../../util/print/printTree';
import {printBinary} from '../../../util/print/printBinary';
import {printTree} from 'tree-dump/lib/printTree';
import {printBinary} from 'tree-dump/lib/printBinary';
import {printOctets} from '@jsonjoy.com/util/lib/buffers/printOctets';

/**
Expand Down
3 changes: 1 addition & 2 deletions src/json-crdt/nodes/str/__tests__/StrNodeFuzzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {ITimespanStruct, ITimestampStruct, ClockVector, toDisplayString, ts} fro
import {Fuzzer} from '@jsonjoy.com/util/lib/Fuzzer';
import {randomSessionId} from '../../../model/util';
import {StrNode} from '../StrNode';
import {printTree} from '../../../../util/print/printTree';
import {Printable} from '../../../../util/print/types';
import {printTree, Printable} from 'tree-dump';

const printOp = (op: Op) => {
if ('content' in op) {
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt/nodes/val/ValNode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {compare, ITimestampStruct, toDisplayString} from '../../../json-crdt-patch/clock';
import {SESSION} from '../../../json-crdt-patch/constants';
import {printTree} from '../../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {UNDEFINED} from '../../model/Model';
import type {JsonNode, JsonNodeView} from '..';
import type {Model} from '../../model';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';

/**
* Represents a `val` JSON CRDT node, which is a Last-write-wins (LWW) register.
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt/nodes/vec/VecNode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {ConNode} from '../const/ConNode';
import {CRDT_CONSTANTS} from '../../constants';
import {printTree} from '../../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {compare, ITimestampStruct, toDisplayString} from '../../../json-crdt-patch/clock';
import type {Model} from '../../model';
import type {JsonNode, JsonNodeView} from '..';
import type {Printable} from '../../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';

/**
* Represents a `vec` JSON CRDT node, which is a LWW array.
Expand Down
3 changes: 1 addition & 2 deletions src/json-crdt/nodes/vec/__tests__/VecNode-extension.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {ITimestampStruct, delayed, s} from '../../../../json-crdt-patch';
import {printTree} from '../../../../util/print/printTree';
import {Printable} from '../../../../util/print/types';
import {printTree, Printable} from 'tree-dump';
import {ext} from '../../../extensions';
import {ExtensionApi, ExtensionDefinition, ExtensionJsonNode} from '../../../extensions/types';
import {Model, NodeApi} from '../../../model';
Expand Down
2 changes: 1 addition & 1 deletion src/json-text/toTree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {printTree} from '../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {stringify} from './stringify';

const isPrimitive = (value: unknown): boolean => typeof value !== 'object';
Expand Down
4 changes: 2 additions & 2 deletions src/json-type-value/ObjectValue.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Value} from './Value';
import {toText} from '../json-type/typescript/toText';
import {TypeSystem} from '../json-type/system/TypeSystem';
import {printTree} from 'sonic-forest/lib/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import type {ResolveType} from '../json-type';
import type * as classes from '../json-type/type';
import type * as ts from '../json-type/typescript/types';
import type {TypeBuilder} from '../json-type/type/TypeBuilder';
import type {Printable} from 'sonic-forest/lib/print/types';
import type {Printable} from 'tree-dump/lib/types';

export type UnObjectType<T> = T extends classes.ObjectType<infer U> ? U : never;
export type UnObjectValue<T> = T extends ObjectValue<infer U> ? U : never;
Expand Down
4 changes: 2 additions & 2 deletions src/json-type/system/TypeAlias.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {printTree} from '../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import {ObjectType} from '../type/classes';
import {toText} from '../typescript/toText';
import {JsonSchemaGenericKeywords, JsonSchemaValueNode} from '../../json-schema';
import {TypeExportContext} from './TypeExportContext';
import type {TypeSystem} from '.';
import type {Type} from '../type';
import type {Printable} from '../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';
import type * as ts from '../typescript/types';

export class TypeAlias<K extends string, T extends Type> implements Printable {
Expand Down
4 changes: 2 additions & 2 deletions src/json-type/system/TypeSystem.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {TypeAlias} from './TypeAlias';
import {TypeBuilder} from '../type/TypeBuilder';
import {RefType} from '../type/classes';
import {printTree} from '../../util/print/printTree';
import {printTree} from 'tree-dump/lib/printTree';
import type {CustomValidator} from './types';
import type {Type, TypeMap} from '../type';
import type {Printable} from '../../util/print/types';
import type {Printable} from 'tree-dump/lib/types';

export class TypeSystem implements Printable {
public readonly t = new TypeBuilder(this);
Expand Down
Loading

0 comments on commit 5ef7ba9

Please sign in to comment.