Skip to content

Commit 0dc2b30

Browse files
committed
Fix export to respect ESM syntax
1 parent 952bf0a commit 0dc2b30

File tree

4 files changed

+70
-41
lines changed

4 files changed

+70
-41
lines changed

javascript/src/api.ts

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,39 @@ 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.
200-
*
201-
* @param key Key to get from the metadata
202198
* @returns Notebook's metadata.
203199
*/
204-
getMetadata(key?: string): nbformat.INotebookMetadata;
205-
206-
/**
207-
* Sets some metadata associated with the notebook.
208-
*
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.
211-
*
212-
* @param metadata All Notebook's metadata or the key to set.
213-
* @param value New metadata value
214-
*/
215-
setMetadata(
216-
metadata: nbformat.INotebookMetadata | string,
217-
value?: PartialJSONValue
218-
): void;
200+
getMetadata(): nbformat.INotebookMetadata;
201+
202+
/**
203+
* Returns a metadata associated with the notebook.
204+
*
205+
* @param key Key to get from the metadata
206+
* @returns Notebook's metadata.
207+
*/
208+
getMetadata(key: string): PartialJSONValue | undefined;
209+
210+
/**
211+
* Sets all metadata associated with the notebook.
212+
*
213+
* @param metadata All Notebook's metadata.
214+
*/
215+
setMetadata(
216+
metadata: nbformat.INotebookMetadata,
217+
): void;
218+
219+
/**
220+
* Sets a metadata associated with the notebook.
221+
*
222+
* @param metadata The key to set.
223+
* @param value New metadata value
224+
*/
225+
setMetadata(
226+
metadata: string,
227+
value: PartialJSONValue
228+
): void;
219229

220230
/**
221231
* Updates the metadata associated with the notebook.
@@ -427,27 +437,38 @@ export interface ISharedBaseCell<
427437
deleteMetadata(key: string): void;
428438

429439
/**
430-
* Returns some metadata associated with the cell.
440+
* Returns all metadata associated with the cell.
431441
*
432-
* If a `key` is provided, returns the metadata value.
433-
* Otherwise returns all metadata
442+
* @returns Cell's metadata.
443+
*/
444+
getMetadata(): Partial<Metadata>;
445+
446+
/**
447+
* Returns a metadata associated with the cell.
434448
*
449+
* @param key Metadata key to get
435450
* @returns Cell's metadata.
436451
*/
437-
getMetadata(key?: string): Partial<Metadata>;
452+
getMetadata(key: string): PartialJSONValue | undefined;
438453

439454
/**
440455
* Sets some cell metadata.
441456
*
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.
457+
* @param metadata Cell's metadata.
458+
*/
459+
setMetadata(
460+
metadata: Partial<Metadata>,
461+
): void;
462+
463+
/**
464+
* Sets a cell metadata.
444465
*
445-
* @param metadata Cell's metadata or key.
466+
* @param metadata Cell's metadata key.
446467
* @param value Metadata value
447468
*/
448469
setMetadata(
449-
metadata: Partial<Metadata> | string,
450-
value?: PartialJSONValue
470+
metadata: string,
471+
value: PartialJSONValue
451472
): void;
452473

453474
/**

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)