jupyterpack 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/document/widgetFactory.js +3 -1
- package/lib/pythonServer/baseServer.d.ts +82 -0
- package/lib/pythonServer/baseServer.js +141 -0
- package/lib/pythonServer/dash/dashServer.d.ts +2 -12
- package/lib/pythonServer/dash/dashServer.js +8 -21
- package/lib/pythonServer/index.d.ts +3 -3
- package/lib/pythonServer/index.js +5 -1
- package/lib/pythonServer/kernelExecutor.d.ts +2 -58
- package/lib/pythonServer/kernelExecutor.js +0 -72
- package/lib/pythonServer/shiny/shinyServer.d.ts +14 -0
- package/lib/pythonServer/shiny/shinyServer.js +49 -0
- package/lib/pythonServer/starlette/starletteServer.d.ts +13 -0
- package/lib/pythonServer/starlette/starletteServer.js +49 -0
- package/lib/pythonServer/streamlit/streamlitServer.d.ts +0 -1
- package/lib/pythonServer/streamlit/streamlitServer.js +7 -11
- package/lib/pythonServer/tornado/tornadoServer.d.ts +2 -24
- package/lib/pythonServer/tornado/tornadoServer.js +10 -35
- package/lib/swConnection/mainConnectionManager.d.ts +4 -4
- package/lib/swConnection/mainConnectionManager.js +23 -12
- package/lib/tools.d.ts +1 -0
- package/lib/tools.js +8 -0
- package/lib/type.d.ts +12 -3
- package/lib/type.js +2 -0
- package/lib/websocket/websocket.js +5 -1
- package/package.json +1 -1
- package/src/document/widgetFactory.ts +3 -1
- package/src/pythonServer/baseServer.ts +245 -0
- package/src/pythonServer/dash/dashServer.ts +10 -29
- package/src/pythonServer/index.ts +9 -5
- package/src/pythonServer/kernelExecutor.ts +3 -156
- package/src/pythonServer/shiny/shinyServer.ts +62 -0
- package/src/pythonServer/starlette/starletteServer.ts +59 -0
- package/src/pythonServer/streamlit/streamlitServer.ts +7 -9
- package/src/pythonServer/tornado/tornadoServer.ts +11 -55
- package/src/pythonWidget/pythonWidgetModel.ts +2 -2
- package/src/swConnection/mainConnectionManager.ts +28 -20
- package/src/tools.ts +9 -0
- package/src/type.ts +17 -6
- package/src/websocket/websocket.ts +9 -1
package/src/type.ts
CHANGED
|
@@ -26,7 +26,9 @@ export enum JupyterPackFramework {
|
|
|
26
26
|
REACT = 'react',
|
|
27
27
|
DASH = 'dash',
|
|
28
28
|
STREAMLIT = 'streamlit',
|
|
29
|
-
TORNADO = 'tornado'
|
|
29
|
+
TORNADO = 'tornado',
|
|
30
|
+
SHINY = 'shiny',
|
|
31
|
+
STARLETTE = 'starlette'
|
|
30
32
|
}
|
|
31
33
|
export interface IJupyterPackFileFormat {
|
|
32
34
|
entry: string;
|
|
@@ -49,7 +51,15 @@ export interface IKernelExecutorParams {
|
|
|
49
51
|
params?: string;
|
|
50
52
|
requestBody?: ArrayBuffer;
|
|
51
53
|
}
|
|
54
|
+
|
|
52
55
|
export interface IKernelExecutor extends IDisposable {
|
|
56
|
+
executeCode(
|
|
57
|
+
code: KernelMessage.IExecuteRequestMsg['content'],
|
|
58
|
+
waitForResult?: boolean
|
|
59
|
+
): Promise<string | null>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface IBasePythonServer extends IDisposable {
|
|
53
63
|
getResponse(options: IKernelExecutorParams): Promise<IDict>;
|
|
54
64
|
openWebsocket(options: {
|
|
55
65
|
instanceId: string;
|
|
@@ -57,16 +67,17 @@ export interface IKernelExecutor extends IDisposable {
|
|
|
57
67
|
wsUrl: string;
|
|
58
68
|
protocol?: string;
|
|
59
69
|
}): Promise<void>;
|
|
70
|
+
closeWebsocket(options: {
|
|
71
|
+
instanceId: string;
|
|
72
|
+
kernelId: string;
|
|
73
|
+
wsUrl: string;
|
|
74
|
+
}): Promise<void>;
|
|
60
75
|
sendWebsocketMessage(options: {
|
|
61
76
|
instanceId: string;
|
|
62
77
|
kernelId: string;
|
|
63
78
|
wsUrl: string;
|
|
64
79
|
message: string;
|
|
65
80
|
}): Promise<void>;
|
|
66
|
-
executeCode(
|
|
67
|
-
code: KernelMessage.IExecuteRequestMsg['content'],
|
|
68
|
-
waitForResult?: boolean
|
|
69
|
-
): Promise<string | null>;
|
|
70
81
|
init(options: {
|
|
71
82
|
entryPath?: string;
|
|
72
83
|
initCode?: string;
|
|
@@ -89,7 +100,7 @@ export interface IKernelExecutor extends IDisposable {
|
|
|
89
100
|
|
|
90
101
|
export interface IConnectionManager {
|
|
91
102
|
registerConnection(
|
|
92
|
-
kernelExecutor:
|
|
103
|
+
kernelExecutor: IBasePythonServer
|
|
93
104
|
): Promise<{ instanceId: string; kernelClientId: string }>;
|
|
94
105
|
generateResponse(
|
|
95
106
|
option: { kernelClientId: string } & IKernelExecutorParams
|
|
@@ -59,7 +59,9 @@
|
|
|
59
59
|
}
|
|
60
60
|
return data;
|
|
61
61
|
};
|
|
62
|
-
const bcWsChannel = new BroadcastChannel(
|
|
62
|
+
const bcWsChannel = new BroadcastChannel(
|
|
63
|
+
`/jupyterpack/ws/${instanceId}/${kernelClientId}`
|
|
64
|
+
);
|
|
63
65
|
|
|
64
66
|
class BroadcastChannelWebSocket implements WebSocket {
|
|
65
67
|
constructor(url: string | URL, protocols?: string | string[]) {
|
|
@@ -109,6 +111,10 @@
|
|
|
109
111
|
cb();
|
|
110
112
|
}
|
|
111
113
|
this._eventHandlers['close'] = [];
|
|
114
|
+
sendTypedMessage({
|
|
115
|
+
action: 'close',
|
|
116
|
+
wsUrl: this.url
|
|
117
|
+
});
|
|
112
118
|
bcWsChannel.removeEventListener('message', this._bcMessageHandler);
|
|
113
119
|
|
|
114
120
|
this.readyState = this.CLOSED;
|
|
@@ -168,10 +174,12 @@
|
|
|
168
174
|
} else {
|
|
169
175
|
data = rawData;
|
|
170
176
|
}
|
|
177
|
+
|
|
171
178
|
const { action, dest, wsUrl, payload } = data;
|
|
172
179
|
if (dest !== kernelClientId || wsUrl !== this.url) {
|
|
173
180
|
return;
|
|
174
181
|
}
|
|
182
|
+
|
|
175
183
|
switch (action) {
|
|
176
184
|
case 'connected': {
|
|
177
185
|
this.readyState = this.OPEN;
|