Skip to content

Commit 0aab4b0

Browse files
authored
use abstract class (#968)
* use abstract class * include source map in dist
1 parent b1951cc commit 0aab4b0

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/client/packages/@reactpy/client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"name": "@reactpy/client",
88
"type": "module",
9-
"version": "0.3.0",
9+
"version": "0.3.1",
1010
"dependencies": {
1111
"event-to-object": "^0.1.2",
1212
"json-pointer": "^0.6.2"

src/client/packages/@reactpy/client/src/reactpy-client.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ export interface ReactPyClient {
2121
*
2222
* @param message The message to send. Messages must have a `type` property.
2323
*/
24-
sendMessage: (message: any) => void;
24+
sendMessage(message: any): void;
2525

2626
/**
2727
* Load a module from the server.
2828
* @param moduleName The name of the module to load.
2929
* @returns A promise that resolves to the module.
3030
*/
31-
loadModule: (moduleName: string) => Promise<ReactPyModule>;
31+
loadModule(moduleName: string): Promise<ReactPyModule>;
3232
}
3333

34-
export class BaseReactPyClient implements Partial<ReactPyClient> {
34+
export abstract class BaseReactPyClient implements ReactPyClient {
3535
private readonly handlers: { [key: string]: ((message: any) => void)[] } = {};
3636
protected readonly ready: Promise<void>;
3737
private resolveReady: (value: undefined) => void;
@@ -49,6 +49,9 @@ export class BaseReactPyClient implements Partial<ReactPyClient> {
4949
};
5050
}
5151

52+
abstract sendMessage(message: any): void;
53+
abstract loadModule(moduleName: string): Promise<ReactPyModule>;
54+
5255
/**
5356
* Handle an incoming message.
5457
*

src/client/tsconfig.package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
"allowSyntheticDefaultImports": true,
55
"declaration": true,
66
"declarationMap": true,
7-
"esModuleInterop": false,
7+
"esModuleInterop": true,
88
"forceConsistentCasingInFileNames": true,
99
"isolatedModules": true,
1010
"jsx": "react",
1111
"lib": ["DOM", "DOM.Iterable", "esnext"],
1212
"module": "esnext",
1313
"moduleResolution": "node",
14+
"noEmitOnError": true,
15+
"noUnusedLocals": true,
1416
"resolveJsonModule": true,
1517
"skipLibCheck": false,
18+
"sourceMap": true,
1619
"strict": true,
1720
"target": "esnext"
1821
}

0 commit comments

Comments
 (0)