Skip to content

Commit

Permalink
Merge pull request #597 from streamich/simplify-deps
Browse files Browse the repository at this point in the history
Simplify installed dependencies
  • Loading branch information
streamich authored Apr 26, 2024
2 parents 3a4bd9c + 1e879f4 commit c0e5d83
Show file tree
Hide file tree
Showing 20 changed files with 648 additions and 3,435 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,19 @@ jobs:
- run: yarn test:cli:pack
- run: yarn demo:json-patch
- run: yarn demo:json-pointer
typedoc:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn typedoc



94 changes: 45 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,41 +76,47 @@
"lib/"
],
"scripts": {
"prettier": "prettier --ignore-path .gitignore --write \"src/**/*.{ts,tsx,js,jsx}\"",
"prettier:check": "prettier --ignore-path .gitignore --list-different 'src/**/*.{ts,tsx,js,jsx}'",
"prettier": "npx prettier@3.2.5 --ignore-path .gitignore --write \"src/**/*.{ts,tsx,js,jsx}\"",
"prettier:check": "npx prettier@3.2.5 --ignore-path .gitignore --list-different 'src/**/*.{ts,tsx,js,jsx}'",
"lint": "yarn tslint",
"lint:fix": "yarn tslint --fix",
"tslint": "tslint 'src/**/*.{js,jsx,ts,tsx}' -t verbose --project .",
"clean": "rimraf lib es6 es2019 es2020 esm typedocs coverage gh-pages yarn-error.log",
"clean": "npx rimraf@5.0.5 lib es6 es2019 es2020 esm typedocs coverage gh-pages yarn-error.log src/**/__bench__/node_modules src/**/__bench__/yarn-error.log",
"build:es2020": "tsc --project tsconfig.build.json --module commonjs --target es2020 --outDir lib",
"build:all": "concurrently \"yarn build:es2020\"",
"build:all": "npx concurrently@8.2.2 \"yarn build:es2020\"",
"build": "yarn build:es2020",
"jest": "node -r ts-node/register ./node_modules/.bin/jest",
"jest": "jest",
"test": "jest --maxWorkers 7",
"test:all": "yarn lint && yarn test && yarn build:all && yarn test:cli:pointer && yarn test:cli:patch && yarn test:cli:pack && yarn demo:json-patch && yarn demo:json-pointer",
"test:ci": "yarn jest --maxWorkers 3 --no-cache",
"test:cli": "yarn test:cli:pointer && yarn test:cli:patch && yarn test:cli:pack",
"test:cli:pointer": "./bin/json-pointer-test.js ./bin/json-pointer.js",
"test:cli:patch": "./bin/json-patch-test.js ./bin/json-patch.js",
"test:cli:pack": "./bin/json-pack-test.js ./bin/json-pack.js",
"demo:json-patch": "ts-node src/json-patch/__demos__/json-patch.ts",
"demo:json-pointer": "ts-node src/json-pointer/__demos__/json-pointer.ts",
"demo:json-patch": "npx ts-node src/json-patch/__demos__/json-patch.ts",
"demo:json-pointer": "npx ts-node src/json-pointer/__demos__/json-pointer.ts",
"bench:json-crdt:traces:crdt-libs": "cd src/json-crdt/__bench__ && yarn && yarn bench:traces:crdt-libs",
"bench:json-crdt:traces:non-crdt-libs": "cd src/json-crdt/__bench__ && yarn && yarn bench:traces:non-crdt-libs",
"bench:json-crdt:concurrent-traces": "cd src/json-crdt/__bench__ && yarn && yarn bench:concurrent-traces",
"bench:json-crdt:codecs:encoding": "cd src/json-crdt/__bench__ && yarn && yarn bench:codecs:encoding",
"bench:json-crdt:codecs:decoding": "cd src/json-crdt/__bench__ && yarn && yarn bench:codecs:decoding",
"bench:json-crdt:codecs:encoding:json": "cd src/json-crdt/__bench__ && yarn && yarn bench:codecs:encoding:json",
"bench:json-crdt:codecs:encoding:libs": "cd src/json-crdt/__bench__ && yarn && yarn bench:codecs:encoding:libs",
"bench:json-crdt:codecs:sizes": "cd src/json-crdt/__bench__ && yarn && yarn bench:codecs:sizes",
"bench:json-ot:ot-string:apply": "cd src/json-ot/__bench__ && yarn && yarn bench:ot-string:apply",
"bench:json-ot:ot-string:compose-and-transform": "yarn build && cd src/json-ot/__bench__ && yarn && yarn bench:ot-string:compose-and-transform",
"coverage": "yarn test --collectCoverage",
"typedoc": "typedoc",
"build:pages": "rimraf gh-pages && mkdir -p gh-pages && cp -r typedocs/* gh-pages && cp -r coverage gh-pages/coverage",
"typedoc": "npx typedoc@0.25.13 --tsconfig tsconfig.build.json",
"build:pages": "npx rimraf@5.0.5 gh-pages && mkdir -p gh-pages && cp -r typedocs/* gh-pages && cp -r coverage gh-pages/coverage",
"deploy:pages": "gh-pages -d gh-pages",
"publish-coverage-and-typedocs": "yarn typedoc && yarn coverage && yarn build:pages && yarn deploy:pages",
"jj": "ts-node src/json-cli/jj.ts"
"jj": "npx ts-node src/json-cli/jj.ts"
},
"peerDependencies": {
"quill-delta": "^5",
"rxjs": "7",
"tslib": "2"
},
"peerDependenciesMeta": {
"quill-delta": {
"optional": true
},
"rxjs": {
"optional": true
}
Expand All @@ -125,52 +131,21 @@
"thingies": "^1.20.0"
},
"devDependencies": {
"@automerge/automerge": "2.1.13",
"@collabs/collabs": "0.13.4",
"@exodus/schemasafe": "^1.0.0-rc.6",
"@types/benchmark": "^2.1.2",
"@types/jest": "^29.5.12",
"@types/quill": "^2.0.14",
"ajv": "^8.11.0",
"app-root-path": "^3.1.0",
"axios": "^1.3.5",
"benchmark": "^2.1.4",
"concurrently": "^8.0.1",
"diamond-types-node": "1.0.2",
"config-housekeeping": "https://github.com/streamich/housekeeping#3532d2abeac159315ddf403d70517859d079c801",
"editing-traces": "https://github.com/streamich/editing-traces#6494020428530a6e382378b98d1d7e31334e2d7b",
"fast-json-patch": "^3.0.0-1",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"gh-pages": "^5.0.0",
"html-webpack-plugin": "^5.5.1",
"husky": "^8.0.3",
"isomorphic-ws": "^5.0.0",
"jest": "^29.7.0",
"json-crdt-traces": "https://github.com/streamich/json-crdt-traces#ec825401dc05cbb74b9e0b3c4d6527399f54d54d",
"json-logic-js": "^2.0.1",
"loro-crdt": "^0.4.1",
"nodemon": "^3.0.0",
"ot-text": "^1.0.2",
"ot-text-unicode": "^4.0.0",
"p4-css": "^1.5.1",
"prettier": "^3.2.5",
"pretty-quick": "^3.1.3",
"quill-delta": "^5.0.0",
"rimraf": "^5.0.0",
"rope.js": "0.1.0",
"tinybench": "^2.4.0",
"rxjs": "^7.8.1",
"ts-jest": "^29.1.2",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"tslint": "^6.1.3",
"tslint-config-common": "^1.6.2",
"typedoc": "^0.25.13",
"typescript": "^5.4.4",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4",
"yjs": "13.6.14",
"ywasm": "0.16.10"
"typescript": "^5.4.4"
},
"jest": {
"verbose": true,
Expand All @@ -187,7 +162,9 @@
"transform": {
"^.+\\.ts$": "ts-jest"
},
"transformIgnorePatterns": [],
"transformIgnorePatterns": [
".*/node_modules/.*"
],
"testRegex": ".*/(__tests__|__jest__|demo)/.*\\.(test|spec)\\.ts$"
},
"prettier": {
Expand Down Expand Up @@ -230,5 +207,24 @@
]
}
}
},
"release": {
"branches": [
"master",
{
"name": "next",
"prerelease": true
}
],
"prepare": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
],
"verifyConditions": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx ts-node src/json-crdt/__bench__/bench.json.encoding.ts
// npx ts-node src/json-crdt/__bench__/bench.codecs.encoding.json.ts

import {payloads} from '../../__bench__/payloads';
import {IBenchmark, runBenchmarkAndSave} from '../../__bench__/runBenchmark';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx ts-node src/json-crdt/__bench__/bench.json.libs.encoding.ts
// npx ts-node src/json-crdt/__bench__/bench.codecs.encoding.libs.ts

import {payloads} from '../../__bench__/payloads';
import {IBenchmark, runBenchmarkAndSave} from '../../__bench__/runBenchmark';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* tslint:disable no-console */
// npx ts-node src/json-crdt/__bench__/bench.sizes.ts
// npx ts-node src/json-crdt/__bench__/bench.codecs.sizes.ts

import {payloads} from '../../__bench__/payloads';
import {StructuralEditors, structuralEditors} from './util/structural-editors';
Expand Down
21 changes: 21 additions & 0 deletions src/json-crdt/__bench__/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"scripts": {
"bench:traces:crdt-libs": "npx ts-node bench.traces.crdt-libs.ts",
"bench:traces:non-crdt-libs": "npx ts-node bench.traces.non-crdt-libs.ts",
"bench:concurrent-traces": "npx ts-node bench.concurrent-traces.ts",
"bench:codecs:encoding": "npx ts-node bench.codecs.encoding.ts",
"bench:codecs:decoding": "npx ts-node bench.codecs.decoding.ts",
"bench:codecs:encoding:json": "npx ts-node bench.codecs.encoding.json.ts",
"bench:codecs:encoding:libs": "npx ts-node bench.codecs.encoding.libs.ts",
"bench:codecs:sizes": "npx ts-node bench.codecs.sizes.ts"
},
"devDependencies": {
"@automerge/automerge": "2.1.13",
"@collabs/collabs": "0.13.4",
"diamond-types-node": "1.0.2",
"loro-crdt": "^0.4.1",
"rope.js": "0.1.0",
"yjs": "13.6.14",
"ywasm": "0.16.10"
}
}
Original file line number Diff line number Diff line change
@@ -1,56 +1,13 @@
import {Timestamp} from '../../../json-crdt-patch/clock';
import {StrNode} from '../../nodes';
import {Model} from '../../model';
import {editorJsonJoy, editorStrNode} from './json-joy';
import {Doc} from 'diamond-types-node';
import * as Y from 'yjs';
import Yrs from 'ywasm';
import * as Automerge from '@automerge/automerge';
import {CRuntime, CText} from '@collabs/collabs';
import {Loro} from 'loro-crdt';
import type {SequentialTraceEditor} from './types';
import type {SequentialTraceEditor} from '../types';
const Rope = require('rope.js');

const editorStrNode: SequentialTraceEditor = {
name: 'StrNode (json-joy)',
factory: () => {
let time = 0;
const rga = new StrNode(new Timestamp(1, time++));
return {
ins: (pos: number, insert: string) => {
rga.insAt(pos, new Timestamp(1, time), insert);
time += insert.length;
},
del: (pos: number, len: number) => {
rga.delete(rga.findInterval(pos, len));
},
get: () => rga.view(),
len: () => rga.length(),
chunks: () => rga.size(),
};
},
};

const editorJsonJoy: SequentialTraceEditor = {
name: 'json-joy',
factory: () => {
const model = Model.withLogicalClock();
model.api.root('');
const str = model.api.str([]);
return {
ins: (pos: number, insert: string) => {
str.ins(pos, insert);
},
del: (pos: number, len: number) => {
str.del(pos, len);
},
get: () => str.view(),
len: () => str.view().length,
chunks: () => str.node.size(),
toBlob: () => model.toBinary(),
};
},
};

const editorYjs: SequentialTraceEditor = {
name: 'Y.js',
factory: () => {
Expand Down
45 changes: 45 additions & 0 deletions src/json-crdt/__bench__/util/editors/json-joy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {Timestamp} from '../../../../json-crdt-patch/clock';
import {StrNode} from '../../../nodes';
import {Model} from '../../../model';
import type {SequentialTraceEditor} from '../types';

export const editorStrNode: SequentialTraceEditor = {
name: 'StrNode (json-joy)',
factory: () => {
let time = 0;
const rga = new StrNode(new Timestamp(1, time++));
return {
ins: (pos: number, insert: string) => {
rga.insAt(pos, new Timestamp(1, time), insert);
time += insert.length;
},
del: (pos: number, len: number) => {
rga.delete(rga.findInterval(pos, len));
},
get: () => rga.view(),
len: () => rga.length(),
chunks: () => rga.size(),
};
},
};

export const editorJsonJoy: SequentialTraceEditor = {
name: 'json-joy',
factory: () => {
const model = Model.withLogicalClock();
model.api.root('');
const str = model.api.str([]);
return {
ins: (pos: number, insert: string) => {
str.ins(pos, insert);
},
del: (pos: number, len: number) => {
str.del(pos, len);
},
get: () => str.view(),
len: () => str.view().length,
chunks: () => str.node.size(),
toBlob: () => model.toBinary(),
};
},
};
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
import * as os from 'os';
import {traces} from './traces';
import type {SequentialTrace, SequentialTraceEditor, SequentialTraceName} from './types';
import {editors, type SequentialEditorName} from './editors';
import {traces} from '../traces';
import {editors, type SequentialEditorName} from '../editors';
import {runTrace} from './runTrace';
import type {SequentialTraceName} from '../types';

/* tslint:disable no-console */

function numberWithCommas(x: number) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}

export const runTrace = (trace: SequentialTrace, editor: SequentialTraceEditor) => {
const txns = trace.txns;
const txnsLength = txns.length;
const editorInstance = editor.factory();
if (trace.startContent) editorInstance.ins(0, trace.startContent);
for (let i = 0; i < txnsLength; i++) {
const transaction = txns[i];
const patches = transaction.patches;
const length = patches.length;
for (let j = 0; j < length; j++) {
const patch = patches[j];
const pos = patch[0];
const del = patch[1];
const insert = patch[2];
if (del) editorInstance.del(pos, del);
if (insert) editorInstance.ins(pos, insert);
}
}
return editorInstance;
};

export const runTraceWithEditor = (
traceName: SequentialTraceName,
editorName: SequentialEditorName,
Expand Down
24 changes: 24 additions & 0 deletions src/json-crdt/__bench__/util/execute/runTrace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type {SequentialTrace, SequentialTraceEditor} from '../types';

/* tslint:disable no-console */

export const runTrace = (trace: SequentialTrace, editor: SequentialTraceEditor) => {
const txns = trace.txns;
const txnsLength = txns.length;
const editorInstance = editor.factory();
if (trace.startContent) editorInstance.ins(0, trace.startContent);
for (let i = 0; i < txnsLength; i++) {
const transaction = txns[i];
const patches = transaction.patches;
const length = patches.length;
for (let j = 0; j < length; j++) {
const patch = patches[j];
const pos = patch[0];
const del = patch[1];
const insert = patch[2];
if (del) editorInstance.del(pos, del);
if (insert) editorInstance.ins(pos, insert);
}
}
return editorInstance;
};
Loading

0 comments on commit c0e5d83

Please sign in to comment.