diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 03cf8a4495..f4c1ef4ef7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -2,7 +2,7 @@ name: Node.js CI on: pull_request: - branches: [ master ] + branches: [ master, next ] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -36,7 +36,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: yarn - run: yarn install --frozen-lockfile - - run: yarn build + - run: yarn build:all - run: yarn lint - run: yarn prettier:check - run: yarn test:cli:pointer diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 81b0cbb276..a3a75ce95f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: - run: yarn demo:json-pointer - run: yarn test:reactive-rpc - name: Semantic Release - uses: cycjimmy/semantic-release-action@v4 + run: npx semantic-release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/bin/jj.js b/bin/jj.js index a731488d33..775b5e7822 100755 --- a/bin/jj.js +++ b/bin/jj.js @@ -1,4 +1,4 @@ #!/usr/bin/env node // eslint-disable-next-line import/no-unassigned-import -require("../es2020/json-cli/jj"); +require("../lib/json-cli/jj"); diff --git a/bin/json-pack-test.js b/bin/json-pack-test.js index 46ec116e9c..ff7b364f1c 100755 --- a/bin/json-pack-test.js +++ b/bin/json-pack-test.js @@ -1,4 +1,4 @@ #!/usr/bin/env node // eslint-disable-next-line import/no-unassigned-import -require("../es2020/json-cli/json-pack-test"); +require("../lib/json-cli/json-pack-test"); diff --git a/bin/json-pack.js b/bin/json-pack.js index 1bbc68ce44..de89dc8a8e 100755 --- a/bin/json-pack.js +++ b/bin/json-pack.js @@ -1,4 +1,4 @@ #!/usr/bin/env node // eslint-disable-next-line import/no-unassigned-import -require("../es2020/json-cli/json-pack"); +require("../lib/json-cli/json-pack"); diff --git a/bin/json-patch-test.js b/bin/json-patch-test.js index 21022ab68b..2ed448b7fd 100755 --- a/bin/json-patch-test.js +++ b/bin/json-patch-test.js @@ -1,4 +1,4 @@ #!/usr/bin/env node // eslint-disable-next-line import/no-unassigned-import -require("../es2020/json-cli/json-patch-test"); +require("../lib/json-cli/json-patch-test"); diff --git a/bin/json-patch.js b/bin/json-patch.js index 3ab7511833..47fdb2b77f 100755 --- a/bin/json-patch.js +++ b/bin/json-patch.js @@ -1,4 +1,4 @@ #!/usr/bin/env node // eslint-disable-next-line import/no-unassigned-import -require("../es2020/json-cli/json-patch"); +require("../lib/json-cli/json-patch"); diff --git a/bin/json-pointer-test.js b/bin/json-pointer-test.js index 684a802347..89db474ae2 100755 --- a/bin/json-pointer-test.js +++ b/bin/json-pointer-test.js @@ -1,4 +1,4 @@ #!/usr/bin/env node // eslint-disable-next-line import/no-unassigned-import -require("../es2020/json-cli/json-pointer-test"); +require("../lib/json-cli/json-pointer-test"); diff --git a/bin/json-pointer.js b/bin/json-pointer.js index 946d18e710..25faf60073 100755 --- a/bin/json-pointer.js +++ b/bin/json-pointer.js @@ -1,4 +1,4 @@ #!/usr/bin/env node // eslint-disable-next-line import/no-unassigned-import -require("../es2020/json-cli/json-pointer"); +require("../lib/json-cli/json-pointer"); diff --git a/bin/json-unpack.js b/bin/json-unpack.js index aad20bc983..5f9c2e8de4 100755 --- a/bin/json-unpack.js +++ b/bin/json-unpack.js @@ -1,4 +1,4 @@ #!/usr/bin/env node // eslint-disable-next-line import/no-unassigned-import -require("../es2020/json-cli/json-unpack"); +require("../lib/json-cli/json-unpack"); diff --git a/package.json b/package.json index 44e31bb21c..dccf7ab964 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "json-joy", "version": "11.2.0", - "description": "", + "description": "Collection of libraries for building collaborative editing apps.", "author": { "name": "streamich", "url": "https://github.com/streamich" @@ -9,12 +9,60 @@ "homepage": "https://github.com/streamich/json-joy", "repository": "streamich/json-joy", "license": "Apache-2.0", - "funding": "https://github.com/sponsors/streamich", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, "engines": { "node": ">=10.0" }, + "keywords": [ + "collaborative", + "multiplayer", + "local-first", + "localfirst", + "crdt", + "rdt", + "ot", + "operational-transformation", + "replicated", + "sync", + "synchronization", + "distributed-state", + "rpc", + "reactive-rpc", + "marshaling", + "serializations", + "json-patch", + "json-binary", + "json-brand", + "json-cli", + "json-clone", + "json-crdt-patch", + "json-crdt-extensions", + "json-crdt-peritext-ui", + "json-crdt", + "json-equal", + "json-expression", + "json-hash", + "json-ot", + "json-pack", + "json-patch-multicore", + "json-patch-ot", + "json-patch", + "json-pointer", + "json-random", + "json-schema", + "json-size", + "json-stable", + "json-text", + "json-type", + "json-type-value", + "json-walk" + ], "main": "lib/index.js", - "module": "esm/index.js", + "types": "lib/index.d.ts", + "typings": "lib/index.d.ts", "bin": { "jj": "./bin/jj.js", "json-pack": "./bin/json-pack.js", @@ -27,10 +75,7 @@ }, "files": [ "LICENSE", - "lib/", - "es6/", - "es2020/", - "esm/" + "lib/" ], "scripts": { "prettier": "prettier --ignore-path .gitignore --write \"src/**/*.{ts,tsx,js,jsx}\"", @@ -39,11 +84,8 @@ "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", - "build:cjs": "tsc --project tsconfig.build.json", - "build:es6": "tsc --project tsconfig.build.json --module commonjs --target es6 --outDir es6", - "build:es2020": "tsc --project tsconfig.build.json --module commonjs --target es2020 --outDir es2020", - "build:esm": "tsc --project tsconfig.build.json --module ESNext --target ESNEXT --outDir esm", - "build:all": "concurrently \"yarn build:cjs\" \"yarn build:es6\" \"yarn build:es2020\" \"yarn build:esm\"", + "build:es2020": "tsc --project tsconfig.build.json --module commonjs --target es2020 --outDir lib", + "build:all": "concurrently \"yarn build:es2020\"", "build": "yarn build:es2020", "jest": "node -r ts-node/register ./node_modules/.bin/jest", "test": "jest --maxWorkers 7", @@ -65,7 +107,6 @@ "publish-coverage-and-typedocs": "yarn typedoc && yarn coverage && yarn build:pages && yarn deploy:pages", "jj": "ts-node src/json-cli/jj.ts" }, - "keywords": [], "peerDependencies": { "quill-delta": "^5", "rxjs": "7", @@ -176,8 +217,6 @@ "yjs": "13.6.9", "ywasm": "0.16.10" }, - "types": "lib/index.d.ts", - "typings": "lib/index.d.ts", "jest": { "verbose": true, "testEnvironmentOptions": { diff --git a/src/index.ts b/src/index.ts index d4c02daad6..c09f80ac22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,18 @@ /** - * json-joy is a collection of modules. Import from reach module directly. + * json-joy is a collection of sub-libraries. Import from reach sub-library directly: * * ```ts - * // In Nodejs - * import {something} from 'json-joy/es2020/'; - * - * // In browser * import {something} from 'json-joy/lib/'; * ``` */ + +export type * from './json-binary/types'; +export type * from './json-brand/types'; +export type * from './json-crdt'; +export type * from './json-crdt-patch'; +export type * from './json-crdt-extensions'; +export type * from './json-expression/types'; +export type * from './json-pack/types'; +export type * from './json-patch/types'; +export type * from './json-pointer/types'; +export type * from './json-schema/types'; diff --git a/src/json-crdt/__bench__/profiler/automerge-paper.js b/src/json-crdt/__bench__/profiler/automerge-paper.js index 9e2f4d8b5d..b530a7ce1c 100644 --- a/src/json-crdt/__bench__/profiler/automerge-paper.js +++ b/src/json-crdt/__bench__/profiler/automerge-paper.js @@ -4,8 +4,8 @@ */ const {traces} = require('../../data/editing-traces'); -const {StrNode} = require('../../../es2020/json-crdt/types/str/StrNode'); -const {ts} = require('../../../es2020/json-crdt-patch/clock/logical'); +const {StrNode} = require('../../../lib/json-crdt/types/str/StrNode'); +const {ts} = require('../../../lib/json-crdt-patch/clock/logical'); const patches = traces.get('automerge-paper').txns.map((txn) => txn.patches[0]); const length = patches.length; diff --git a/src/json-crdt/__bench__/profiler/serialization.js b/src/json-crdt/__bench__/profiler/serialization.js index b4c190af29..67c94d76ef 100644 --- a/src/json-crdt/__bench__/profiler/serialization.js +++ b/src/json-crdt/__bench__/profiler/serialization.js @@ -3,7 +3,7 @@ * node --prof-process isolate-0xnnnnnnnnnnnn-v8.log */ -const {Model} = require('../../../es2020/json-crdt'); +const {Model} = require('../../../lib/json-crdt'); const json = require('../../data/json6'); const doc1 = Model.withLogicalClock(); diff --git a/src/json-equal/README.md b/src/json-equal/README.md index 1467ea9324..d82945245b 100644 --- a/src/json-equal/README.md +++ b/src/json-equal/README.md @@ -15,7 +15,7 @@ This library contains the fastest JSON deep comparison algorithms. ### `deepEqual` ```ts -import {deepEqual} from 'json-joy/{lib,es6,esm,es2020}/json-equal/deepEqual'; +import {deepEqual} from 'json-joy/lib/json-equal/deepEqual'; deepEqual(a, b); // true/false ``` @@ -24,7 +24,7 @@ deepEqual(a, b); // true/false ### `$$deepEqual` ```ts -import {$$deepEqual} from 'json-joy/{lib,es6,esm,es2020}/json-equal/$$deepEqual'; +import {$$deepEqual} from 'json-joy/lib/json-equal/$$deepEqual'; const js = $$deepEqual(a); const fn = eval(js); diff --git a/src/json-expression/README.md b/src/json-expression/README.md index b2be1148d4..f8a292b3cd 100644 --- a/src/json-expression/README.md +++ b/src/json-expression/README.md @@ -73,7 +73,7 @@ an order of magnitude faster. Evaluating expression immediately as-is. ```ts -import {evaluate} from 'json-joy/{lib,es2020}/json-expression'; +import {evaluate} from 'json-joy/lib/json-expression'; const expression = ['+', 1, ['$', '/foo']]; const data = {foo: 2}; @@ -84,7 +84,7 @@ evaluate(expression, {data}); // 3 Pre-compiling expression to an optimized function. ```ts -import {JsonExpressionCodegen} from 'json-joy/{lib,es2020}/json-expression'; +import {JsonExpressionCodegen} from 'json-joy/lib/json-expression'; const expression = ['+', 1, ['$', '/foo']]; const codegen = new JsonExpressionCodegen({expression}); diff --git a/src/json-hash/README.md b/src/json-hash/README.md index 7dedd52826..fe423a3792 100644 --- a/src/json-hash/README.md +++ b/src/json-hash/README.md @@ -6,7 +6,7 @@ with different key orders will have the same hash. Implements DJB2 hash function. ```ts -import {hash} from 'json-joy/es2020/json-hash'; +import {hash} from 'json-joy/lib/json-hash'; const num1 = hash({ foo: 1, diff --git a/src/json-ot/__bench__/ot-string.compose-and-transform.js b/src/json-ot/__bench__/ot-string.compose-and-transform.js index e0c2ffe510..9bbeec0796 100644 --- a/src/json-ot/__bench__/ot-string.compose-and-transform.js +++ b/src/json-ot/__bench__/ot-string.compose-and-transform.js @@ -1,11 +1,11 @@ const Benchmark = require('benchmark'); -const {validate, apply, compose, transform} = require('../../../es2020/json-ot/types/ot-string'); +const {validate, apply, compose, transform} = require('../../../lib/json-ot/types/ot-string'); const { validate: validate2, apply: apply2, compose: compose2, transform: transform2, -} = require('../../../es2020/json-ot/types/ot-string-irreversible'); +} = require('../../../lib/json-ot/types/ot-string-irreversible'); const {type} = require('ot-text'); const {type: type2} = require('ot-text-unicode'); const {delta: d} = require('./util'); diff --git a/src/json-type/README.md b/src/json-type/README.md index a5fd23655d..b53310e669 100644 --- a/src/json-type/README.md +++ b/src/json-type/README.md @@ -3,7 +3,7 @@ Type builder for JSON and MessagePack. ```ts -import {t} from 'json-joy/es2020/json-type'; +import {t} from 'json-joy/lib/json-type'; t.String(); // { __t: 'str' } t.String({const: 'add'}); // { __t: 'str', const: 'add' } diff --git a/src/util/base64/README.md b/src/util/base64/README.md index 49e6ce371f..ba368cec0a 100644 --- a/src/util/base64/README.md +++ b/src/util/base64/README.md @@ -15,7 +15,7 @@ Use encoder compatible with Node's Buffer: ```ts -import {toBase64} from 'json-joy/{lib,es2020}/util/base64'; +import {toBase64} from 'json-joy/lib/util/base64'; toBase64(new Uint8Array([1, 2, 3])); ``` @@ -23,7 +23,7 @@ toBase64(new Uint8Array([1, 2, 3])); Create your custom encoder: ```ts -import {createToBase64} from 'json-joy/{lib,es2020}/util/base64'; +import {createToBase64} from 'json-joy/lib/util/base64'; const encode = createToBase64('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_'); @@ -75,7 +75,7 @@ Fastest is json-joy/util/base64 fromBase64(str) Use decoder compatible with Node's Buffer: ```ts -import {toBase64, fromBase64} from 'json-joy/{lib,es2020}/util/base64'; +import {toBase64, fromBase64} from 'json-joy/lib/util/base64'; fromBase64(toBase64(new Uint8Array([1, 2, 3]))); ``` @@ -83,7 +83,7 @@ fromBase64(toBase64(new Uint8Array([1, 2, 3]))); Create your custom encoder: ```ts -import {createFromBase64} from 'json-joy/{lib,es2020}/util/base64'; +import {createFromBase64} from 'json-joy/lib/util/base64'; const decoder = createFromBase64('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_'); diff --git a/src/util/base64/__bench__/decode.js b/src/util/base64/__bench__/decode.js index 14bce78288..9b6de6dfa0 100644 --- a/src/util/base64/__bench__/decode.js +++ b/src/util/base64/__bench__/decode.js @@ -1,7 +1,7 @@ const Benchmark = require('benchmark'); -const toBase64 = require('../../../../es2020/util/base64').toBase64; -const {bufferToUint8Array} = require('../../../../es2020/util/buffers/bufferToUint8Array'); -const {fromBase64, createFromBase64} = require('../../../../es2020/util/base64'); +const toBase64 = require('../../../../lib/util/base64').toBase64; +const {bufferToUint8Array} = require('../../../../lib/util/buffers/bufferToUint8Array'); +const {fromBase64, createFromBase64} = require('../../../../lib/util/base64'); const {toByteArray} = require('base64-js'); const {decode: decodeJsBase64} = require('js-base64'); diff --git a/src/util/base64/__bench__/encode.js b/src/util/base64/__bench__/encode.js index c89d2931a1..07fbd4edde 100644 --- a/src/util/base64/__bench__/encode.js +++ b/src/util/base64/__bench__/encode.js @@ -1,5 +1,5 @@ const Benchmark = require('benchmark'); -const {toBase64, createToBase64} = require('../../../../es2020/util/base64'); +const {toBase64, createToBase64} = require('../../../../lib/util/base64'); const {fromByteArray} = require('base64-js'); const {encode: encodeJsBase64} = require('js-base64'); diff --git a/src/util/buffers/__bench__/bench.decodeUtf8.ts b/src/util/buffers/__bench__/bench.decodeUtf8.ts index 1255b2a3d8..0baee0ff6d 100644 --- a/src/util/buffers/__bench__/bench.decodeUtf8.ts +++ b/src/util/buffers/__bench__/bench.decodeUtf8.ts @@ -12,7 +12,7 @@ const prepare = (str: string) => { const runner = (v: number, name: string) => ({ name: `${name} (v${v})`, setup: () => { - const decode = require('../../../../es2020/util/buffers/utf8/decodeUtf8/v' + v).default; + const decode = require('../../../../lib/util/buffers/utf8/decodeUtf8/v' + v).default; return (data: any) => decode(data, 0, data.length); }, }); diff --git a/tsconfig.json b/tsconfig.json index 789e5a07aa..dd0384430b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "target": "es6", "module": "commonjs", "moduleResolution": "Node", - "removeComments": true, + "removeComments": false, "noImplicitAny": true, "allowJs": false, "allowSyntheticDefaultImports": true,