Skip to content

Commit b7bf137

Browse files
authored
Merge pull request #89 from fcollonval/fix/export-symbol
Fix export to respect ESM syntax
2 parents 952bf0a + 893cc57 commit b7bf137

File tree

11 files changed

+964
-3421
lines changed

11 files changed

+964
-3421
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ node_modules/
132132
tests/package-lock.json
133133
javascript/tsconfig.tsbuildinfo
134134
javascript/.eslintcache
135+
javascript/coverage/

javascript/babel.config.cjs

Lines changed: 0 additions & 17 deletions
This file was deleted.

javascript/jest.config.cjs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,10 @@
33
* Distributed under the terms of the Modified BSD License.
44
*/
55

6-
const path = require('path');
76
const esModules = ['lib0', 'y-protocols', 'y-websocket', 'yjs'].join('|');
87

98
module.exports = {
10-
preset: 'ts-jest/presets/js-with-babel',
11-
testTimeout: 10000,
12-
testPathIgnorePatterns: ['/lib/', '/node_modules/'],
13-
moduleFileExtensions: [
14-
'ts',
15-
'tsx',
16-
'js',
17-
'jsx',
18-
'json',
19-
'node',
20-
'mjs',
21-
'cjs'
22-
],
23-
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`],
24-
reporters: ['default'],
25-
coverageReporters: ['json', 'lcov', 'text', 'html'],
26-
coverageDirectory: path.join(__dirname, 'coverage'),
27-
testRegex: '/test/.*.spec.ts[x]?$',
28-
globals: {
29-
'ts-jest': {
30-
tsconfig: `./tsconfig.test.json`
31-
}
32-
}
9+
testEnvironment: 'node',
10+
testRegex: 'lib/test/.*.spec.js[x]?$',
11+
3312
};

javascript/package.json

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,17 @@
4747
"yjs": "^13.5.40"
4848
},
4949
"devDependencies": {
50-
"@babel/core": "^7.10.2",
51-
"@babel/preset-env": "^7.10.2",
52-
"@types/jest": "^26.0.10",
53-
"@typescript-eslint/eslint-plugin": "~5.28.0",
54-
"@typescript-eslint/parser": "~5.28.0",
55-
"eslint": "~8.17.0",
56-
"eslint-config-prettier": "~8.5.0",
57-
"eslint-plugin-jest": "~26.5.3",
58-
"eslint-plugin-prettier": "~4.0.0",
59-
"eslint-plugin-react": "~7.29.4",
60-
"jest": "^26.4.2",
61-
"prettier": "~2.6.0",
62-
"rimraf": "~3.0.0",
63-
"ts-jest": "^26.3.0",
64-
"typescript": "~4.7.3"
50+
"@types/jest": "^29.0.0",
51+
"@typescript-eslint/eslint-plugin": "^5.36.0",
52+
"@typescript-eslint/parser": "^5.36.0",
53+
"eslint": "^8.17.0",
54+
"eslint-config-prettier": "^8.5.0",
55+
"eslint-plugin-jest": "^27.0.0",
56+
"eslint-plugin-prettier": "^4.0.0",
57+
"jest": "^29.0.0",
58+
"prettier": "^2.6.0",
59+
"rimraf": "^3.0.0",
60+
"typescript": "^4.8.0"
6561
},
6662
"publishConfig": {
6763
"access": "public"

javascript/src/api.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,34 @@ export interface ISharedNotebook extends ISharedDocument {
193193
deleteMetadata(key: string): void;
194194

195195
/**
196-
* Returns some metadata associated with the notebook.
196+
* Returns all metadata associated with the notebook.
197197
*
198-
* If no `key` is provided, it will return all metadata.
199-
* Else it will return the value for that key.
198+
* @returns Notebook's metadata.
199+
*/
200+
getMetadata(): nbformat.INotebookMetadata;
201+
202+
/**
203+
* Returns a metadata associated with the notebook.
200204
*
201205
* @param key Key to get from the metadata
202206
* @returns Notebook's metadata.
203207
*/
204-
getMetadata(key?: string): nbformat.INotebookMetadata;
208+
getMetadata(key: string): PartialJSONValue | undefined;
205209

206210
/**
207-
* Sets some metadata associated with the notebook.
211+
* Sets all metadata associated with the notebook.
208212
*
209-
* If only one argument is provided, it will override all notebook metadata.
210-
* Otherwise a single key will be set to a new value.
213+
* @param metadata All Notebook's metadata.
214+
*/
215+
setMetadata(metadata: nbformat.INotebookMetadata): void;
216+
217+
/**
218+
* Sets a metadata associated with the notebook.
211219
*
212-
* @param metadata All Notebook's metadata or the key to set.
220+
* @param metadata The key to set.
213221
* @param value New metadata value
214222
*/
215-
setMetadata(
216-
metadata: nbformat.INotebookMetadata | string,
217-
value?: PartialJSONValue
218-
): void;
223+
setMetadata(metadata: string, value: PartialJSONValue): void;
219224

220225
/**
221226
* Updates the metadata associated with the notebook.
@@ -427,28 +432,34 @@ export interface ISharedBaseCell<
427432
deleteMetadata(key: string): void;
428433

429434
/**
430-
* Returns some metadata associated with the cell.
435+
* Returns all metadata associated with the cell.
431436
*
432-
* If a `key` is provided, returns the metadata value.
433-
* Otherwise returns all metadata
437+
* @returns Cell's metadata.
438+
*/
439+
getMetadata(): Partial<Metadata>;
440+
441+
/**
442+
* Returns a metadata associated with the cell.
434443
*
444+
* @param key Metadata key to get
435445
* @returns Cell's metadata.
436446
*/
437-
getMetadata(key?: string): Partial<Metadata>;
447+
getMetadata(key: string): PartialJSONValue | undefined;
438448

439449
/**
440450
* Sets some cell metadata.
441451
*
442-
* If only one argument is provided, it will override all cell metadata.
443-
* Otherwise a single key will be set to a new value.
452+
* @param metadata Cell's metadata.
453+
*/
454+
setMetadata(metadata: Partial<Metadata>): void;
455+
456+
/**
457+
* Sets a cell metadata.
444458
*
445-
* @param metadata Cell's metadata or key.
459+
* @param metadata Cell's metadata key.
446460
* @param value Metadata value
447461
*/
448-
setMetadata(
449-
metadata: Partial<Metadata> | string,
450-
value?: PartialJSONValue
451-
): void;
462+
setMetadata(metadata: string, value: PartialJSONValue): void;
452463

453464
/**
454465
* Serialize the model to JSON.

javascript/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
|----------------------------------------------------------------------------*/
55
/**
66
* @packageDocumentation
7-
* @module shared-models
7+
* @module ydoc
88
*/
99

10-
export * from './api';
11-
export * from './ymodels';
12-
export * from './utils';
10+
export * from './api.js';
11+
export * from './ymodels.js';
12+
export * from './utils.js';

javascript/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
|----------------------------------------------------------------------------*/
55

66
import * as Y from 'yjs';
7-
import * as models from './api';
7+
import * as models from './api.js';
88

99
export function convertYMapEventToMapChange(
1010
event: Y.YMapEvent<any>

javascript/src/ymodels.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import type {
3333
NotebookChange,
3434
SharedCell,
3535
StateChange
36-
} from './api';
36+
} from './api.js';
3737

3838
/**
3939
* Abstract interface to define Shared Models that can be bound to a text editor using any existing
@@ -709,12 +709,14 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
709709
}
710710

711711
/**
712-
* Returns the metadata associated with the cell.
712+
* Returns all or a single metadata associated with the cell.
713713
*
714-
* @param key
715-
* @returns Cell metadata.
714+
* @param key The metadata key
715+
* @returns cell's metadata.
716716
*/
717-
getMetadata(key?: string): Partial<Metadata> {
717+
getMetadata(): Partial<Metadata>;
718+
getMetadata(key: string): PartialJSONValue | undefined;
719+
getMetadata(key?: string): Partial<Metadata> | PartialJSONValue | undefined {
718720
// Transiently the metadata can be missing - like during destruction
719721
const metadata = this.ymodel.get('metadata') ?? {};
720722

@@ -729,14 +731,16 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
729731
}
730732

731733
/**
732-
* Sets some cell metadata.
734+
* Sets all or a single cell metadata.
733735
*
734736
* If only one argument is provided, it will override all cell metadata.
735737
* Otherwise a single key will be set to a new value.
736738
*
737-
* @param metadata Cell's metadata or key.
739+
* @param metadata Cell's metadata key or cell's metadata.
738740
* @param value Metadata value
739741
*/
742+
setMetadata(metadata: Partial<Metadata>): void;
743+
setMetadata(metadata: string, value: PartialJSONValue): void;
740744
setMetadata(
741745
metadata: Partial<Metadata> | string,
742746
value?: PartialJSONValue
@@ -1467,6 +1471,8 @@ export class YNotebook
14671471
* @param key Key to get from the metadata
14681472
* @returns Notebook's metadata.
14691473
*/
1474+
getMetadata(): nbformat.INotebookMetadata;
1475+
getMetadata(key: string): PartialJSONValue | undefined;
14701476
getMetadata(key?: string): nbformat.INotebookMetadata {
14711477
const meta = this.ymeta.get('metadata') ?? {};
14721478

@@ -1489,6 +1495,8 @@ export class YNotebook
14891495
* @param metadata All Notebook's metadata or the key to set.
14901496
* @param value New metadata value
14911497
*/
1498+
setMetadata(metadata: nbformat.INotebookMetadata): void;
1499+
setMetadata(metadata: string, value: PartialJSONValue): void;
14921500
setMetadata(
14931501
metadata: nbformat.INotebookMetadata | string,
14941502
value?: PartialJSONValue

0 commit comments

Comments
 (0)