Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and package changes #566

Merged
merged 6 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion bin/jj.js
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion bin/json-pack-test.js
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion bin/json-pack.js
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion bin/json-patch-test.js
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion bin/json-patch.js
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion bin/json-pointer-test.js
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion bin/json-pointer.js
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion bin/json-unpack.js
Original file line number Diff line number Diff line change
@@ -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");
69 changes: 54 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,68 @@
{
"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"
},
"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",
Expand All @@ -27,10 +75,7 @@
},
"files": [
"LICENSE",
"lib/",
"es6/",
"es2020/",
"esm/"
"lib/"
],
"scripts": {
"prettier": "prettier --ignore-path .gitignore --write \"src/**/*.{ts,tsx,js,jsx}\"",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
17 changes: 12 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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/<module>';
*
* // In browser
* import {something} from 'json-joy/lib/<module>';
* ```
*/

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';
4 changes: 2 additions & 2 deletions src/json-crdt/__bench__/profiler/automerge-paper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt/__bench__/profiler/serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/json-equal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/json-expression/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion src/json-hash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/json-ot/__bench__/ot-string.compose-and-transform.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/json-type/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
8 changes: 4 additions & 4 deletions src/util/base64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
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]));
```

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+_');

Expand Down Expand Up @@ -75,15 +75,15 @@ 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])));
```

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+_');

Expand Down
6 changes: 3 additions & 3 deletions src/util/base64/__bench__/decode.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
2 changes: 1 addition & 1 deletion src/util/base64/__bench__/encode.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
2 changes: 1 addition & 1 deletion src/util/buffers/__bench__/bench.decodeUtf8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
});
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"target": "es6",
"module": "commonjs",
"moduleResolution": "Node",
"removeComments": true,
"removeComments": false,
"noImplicitAny": true,
"allowJs": false,
"allowSyntheticDefaultImports": true,
Expand Down
Loading