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

Bump dependencies and yarn #151

Merged
merged 13 commits into from
Mar 20, 2023
Merged
15 changes: 7 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ jobs:
with:
miniforge-variant: Mambaforge
miniforge-version: latest
python-version: "3.7"
python-version: "3.11"

- name: Install dependencies
run: |
mamba install python=${{ matrix.python-version }} pip nodejs=16 yarn
pip install .[test]
mamba install pip nodejs=18
pip install ".[test]"

- name: Build JavaScript assets
working-directory: javascript
run: |
yarn
yarn build
cd ../tests; npm install

- name: Linter check
if: ${{ !contains(matrix.os, 'windows') }}
Expand All @@ -78,12 +77,12 @@ jobs:
exit 1
fi

- name: Run Python tests
run: |
pytest -v

- name: Run JS tests
working-directory: javascript
run: |
yarn build:test
yarn test:cov

- name: Run Python tests
run: |
python -m pytest -v
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,12 @@ javascript/tsconfig.tsbuildinfo
javascript/.eslintcache
javascript/coverage/
jupyter_ydoc/_version.py

# Yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repos:
- id: forbid-new-submodules
- id: check-builtin-literals
- id: trailing-whitespace
exclude: ^\.yarn

- repo: https://github.com/psf/black
rev: 23.1.0
Expand Down
873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.4.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarnPath: .yarn/releases/yarn-3.4.1.cjs
nodeLinker: node-modules
3 changes: 0 additions & 3 deletions javascript/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
* Distributed under the terms of the Modified BSD License.
*/

const esModules = ['lib0', 'y-protocols', 'y-websocket', 'yjs'].join('|');

module.exports = {
testEnvironment: 'node',
testRegex: 'lib/test/.*.spec.js[x]?$',

};
17 changes: 8 additions & 9 deletions javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"watch": "tsc -b --watch"
},
"dependencies": {
"@jupyterlab/nbformat": "^3.0.0 || ^4.0.0-alpha.15",
"@lumino/coreutils": "^1.11.0 || ^2.0.0-alpha.6",
"@lumino/disposable": "^1.10.0 || ^2.0.0-alpha.6",
"@lumino/signaling": "^1.10.0 || ^2.0.0-alpha.6",
"@jupyterlab/nbformat": "^3.0.0 || ^4.0.0-alpha.21 || ^4.0.0",
"@lumino/coreutils": "^1.11.0 || ^2.0.0",
"@lumino/disposable": "^1.10.0 || ^2.0.0",
"@lumino/signaling": "^1.10.0 || ^2.0.0",
"y-protocols": "^1.0.5",
"yjs": "^13.5.40"
},
Expand All @@ -56,12 +56,11 @@
"eslint-plugin-jest": "^27.0.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^29.0.0",
"prettier": "^2.6.0",
"process": "0.11.10",
"rimraf": "^3.0.0",
"prettier": "^2.8.4",
"rimraf": "^4.4.0",
"tsc-esm-fix": "^2.20.0",
"typedoc": "^0.23.21",
"typescript": "^4.8.0",
"tsc-esm-fix": "^2.20.0"
"typescript": "^4.9.5"
},
"publishConfig": {
"access": "public"
Expand Down
5 changes: 3 additions & 2 deletions javascript/src/ycell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
*
* @param ymodel Cell map
* @param ysource Cell source
* @param options { notebook?: The notebook the cell is attached to }
* @param options \{ notebook?: The notebook the cell is attached to \}
* @param ymetadata Cell metadata
*/
constructor(
Expand Down Expand Up @@ -705,7 +705,8 @@ export class YCodeCell
* @param ymodel Cell map
* @param ysource Cell source
* @param youtputs Code cell outputs
* @param options { notebook?: The notebook the cell is attached to }
* @param options \{ notebook?: The notebook the cell is attached to \}
* @param ymetadata Cell metadata
*/
constructor(
ymodel: Y.Map<any>,
Expand Down
8 changes: 7 additions & 1 deletion javascript/src/ydocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,13 @@ export class YDocument<T extends DocumentChange> implements ISharedDocument {
private _disposed = new Signal<this, void>(this);
}

namespace YDocument {
/**
* YDocument namespace
*/
export namespace YDocument {
/**
* YDocument constructor options
*/
export interface IOptions {
/**
* The optional YJS document for YDocument.
Expand Down
34 changes: 18 additions & 16 deletions javascript/src/ynotebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,22 +485,24 @@ export class YNotebook
});
break;
case 'update':
const newValue = ymetadata.get(key);
const oldValue = change.oldValue;
let equal = true;
if (typeof oldValue == 'object' && typeof newValue == 'object') {
equal = JSONExt.deepEqual(oldValue, newValue);
} else {
equal = oldValue === newValue;
}

if (!equal) {
this._metadataChanged.emit({
key,
type: 'change',
oldValue,
newValue
});
{
const newValue = ymetadata.get(key);
const oldValue = change.oldValue;
let equal = true;
if (typeof oldValue == 'object' && typeof newValue == 'object') {
equal = JSONExt.deepEqual(oldValue, newValue);
} else {
equal = oldValue === newValue;
}

if (!equal) {
this._metadataChanged.emit({
key,
type: 'change',
oldValue,
newValue
});
}
}
break;
}
Expand Down
8 changes: 8 additions & 0 deletions javascript/test/ycell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
import { IMapChange, YCodeCell, YNotebook } from '../src';

describe('@jupyter/ydoc', () => {
// Fix awareness timeout open handle
beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.clearAllTimers();
});

describe('YCell standalone', () => {
test('should set source', () => {
const codeCell = YCodeCell.create();
Expand Down
8 changes: 8 additions & 0 deletions javascript/test/ynotebook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import type * as nbformat from '@jupyterlab/nbformat';
import { IMapChange, NotebookChange, YNotebook } from '../src';

describe('@jupyter/ydoc', () => {
// Fix awareness timeout open handle
beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.clearAllTimers();
});

describe('YNotebook', () => {
describe('#constructor', () => {
test('should create a notebook without arguments', () => {
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
"tests"
],
"scripts": {
"build": "lerna run build",
"test": "lerna run build:test && lerna run test"
"build": "cd javascript && yarn run build",
"test": "cd javascript && yarn run build:test && yarn run test"
},
"devDependencies": {
"lerna": "^6.3.0"
}
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def yjs_client(request):
client_id = request.param
p = subprocess.Popen(
[
"yarn",
"node",
"--experimental-specifier-resolution=node",
f"{here / 'yjs_client_'}{client_id}.js",
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@jupyter/ydoc-test",
"version": "0.0.1",
"private": "true",
"private": true,
"type": "module",
"dependencies": {
"@jupyter/ydoc": "file:../javascript",
"@jupyter/ydoc": "workspace:javascript",
"ws": "^8.5.0",
"y-websocket": "^1.4.1"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ypy_yjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def test_ypy_yjs_0(yws_server, yjs_client):
WebsocketProvider(ydoc, websocket)
nb = stringify_source(json.loads((files_dir / "nb0.ipynb").read_text()))
ynotebook.source = nb
ytest = YTest(ydoc)
ytest = YTest(ydoc, 3.0)
await ytest.change()
assert ytest.source == nb

Expand Down
Loading