@jupyterlite/xeus 0.2.0-a2 → 0.2.0-b0
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/lib/coincident.worker.d.ts +14 -0
- package/lib/coincident.worker.js +3 -0
- package/lib/coincident.worker.js.map +1 -0
- package/lib/comlink.worker.d.ts +7 -0
- package/lib/comlink.worker.js +3 -0
- package/lib/comlink.worker.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/tokens.d.ts +68 -0
- package/lib/tokens.js +3 -0
- package/lib/web_worker_kernel.d.ts +26 -6
- package/lib/web_worker_kernel.js +96 -38
- package/lib/worker.d.ts +21 -6
- package/lib/worker.js +140 -3
- package/package.json +3 -2
- package/lib/worker.js.map +0 -1
package/lib/index.js
CHANGED
package/lib/tokens.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Definitions for the Xeus kernel.
|
|
3
|
+
*/
|
|
4
|
+
import { TDriveMethod, TDriveRequest, TDriveResponse } from '@jupyterlite/contents';
|
|
5
|
+
import { IWorkerKernel } from '@jupyterlite/kernel';
|
|
6
|
+
/**
|
|
7
|
+
* An interface for Xeus workers.
|
|
8
|
+
*/
|
|
9
|
+
export interface IXeusWorkerKernel extends IWorkerKernel {
|
|
10
|
+
/**
|
|
11
|
+
* Handle any lazy initialization activities.
|
|
12
|
+
*/
|
|
13
|
+
initialize(options: IXeusWorkerKernel.IOptions): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Process drive request
|
|
16
|
+
* @param data
|
|
17
|
+
*/
|
|
18
|
+
processDriveRequest<T extends TDriveMethod>(data: TDriveRequest<T>): TDriveResponse<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Process a message sent from the main thread to the worker.
|
|
21
|
+
* @param msg
|
|
22
|
+
*/
|
|
23
|
+
processMessage(msg: any): void;
|
|
24
|
+
/**
|
|
25
|
+
* Process worker message
|
|
26
|
+
* @param msg
|
|
27
|
+
*/
|
|
28
|
+
processWorkerMessage(msg: any): void;
|
|
29
|
+
/**
|
|
30
|
+
* Register a callback for handling messages from the worker.
|
|
31
|
+
*/
|
|
32
|
+
registerCallback(callback: (msg: any) => void): void;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the kernel is ready.
|
|
35
|
+
* @returns a promise that resolves when the kernel is ready.
|
|
36
|
+
*/
|
|
37
|
+
ready(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Mount a drive
|
|
40
|
+
* @param driveName The name of the drive
|
|
41
|
+
* @param mountpoint The mountpoint of the drive
|
|
42
|
+
* @param baseUrl The base URL of the server
|
|
43
|
+
*/
|
|
44
|
+
mount(driveName: string, mountpoint: string, baseUrl: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Change the current working directory
|
|
47
|
+
* @param path The path to change to
|
|
48
|
+
*/
|
|
49
|
+
cd(path: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a path is a directory
|
|
52
|
+
* @param path The path to check
|
|
53
|
+
*/
|
|
54
|
+
isDir(path: string): Promise<boolean>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* An namespace for Xeus workers.
|
|
58
|
+
*/
|
|
59
|
+
export declare namespace IXeusWorkerKernel {
|
|
60
|
+
/**
|
|
61
|
+
* Initialization options for a worker.
|
|
62
|
+
*/
|
|
63
|
+
interface IOptions extends IWorkerKernel.IOptions {
|
|
64
|
+
baseUrl: string;
|
|
65
|
+
kernelSpec: any;
|
|
66
|
+
mountDrive: boolean;
|
|
67
|
+
}
|
|
68
|
+
}
|
package/lib/tokens.js
ADDED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { Remote } from 'comlink';
|
|
1
2
|
import { ISignal } from '@lumino/signaling';
|
|
2
3
|
import { Contents, KernelMessage } from '@jupyterlab/services';
|
|
3
4
|
import { IKernel } from '@jupyterlite/kernel';
|
|
5
|
+
import { IXeusWorkerKernel } from './tokens';
|
|
4
6
|
export declare class WebWorkerKernel implements IKernel {
|
|
5
7
|
/**
|
|
6
8
|
* Instantiate a new WebWorkerKernel
|
|
@@ -8,6 +10,18 @@ export declare class WebWorkerKernel implements IKernel {
|
|
|
8
10
|
* @param options The instantiation options for a new WebWorkerKernel
|
|
9
11
|
*/
|
|
10
12
|
constructor(options: WebWorkerKernel.IOptions);
|
|
13
|
+
/**
|
|
14
|
+
* Load the worker.
|
|
15
|
+
*/
|
|
16
|
+
protected initWorker(options: WebWorkerKernel.IOptions): Worker;
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the remote kernel.
|
|
19
|
+
* Use coincident if crossOriginIsolated, comlink otherwise
|
|
20
|
+
* See the two following issues for more context:
|
|
21
|
+
* - https://github.com/jupyterlite/jupyterlite/issues/1424
|
|
22
|
+
* - https://github.com/jupyterlite/xeus/issues/102
|
|
23
|
+
*/
|
|
24
|
+
protected initRemote(options: WebWorkerKernel.IOptions): IXeusWorkerKernel | Remote<IXeusWorkerKernel>;
|
|
11
25
|
handleMessage(msg: KernelMessage.IMessage): Promise<void>;
|
|
12
26
|
private _sendMessageToWorker;
|
|
13
27
|
/**
|
|
@@ -23,11 +37,17 @@ export declare class WebWorkerKernel implements IKernel {
|
|
|
23
37
|
*/
|
|
24
38
|
get location(): string;
|
|
25
39
|
/**
|
|
26
|
-
* Process a message coming from the
|
|
40
|
+
* Process a message coming from the coincident web worker.
|
|
41
|
+
*
|
|
42
|
+
* @param msg The worker message to process.
|
|
43
|
+
*/
|
|
44
|
+
private _processCoincidentWorkerMessage;
|
|
45
|
+
/**
|
|
46
|
+
* Process a message coming from the comlink web worker.
|
|
27
47
|
*
|
|
28
48
|
* @param msg The worker message to process.
|
|
29
49
|
*/
|
|
30
|
-
private
|
|
50
|
+
private _processComlinkWorkerMessage;
|
|
31
51
|
/**
|
|
32
52
|
* A promise that is fulfilled when the kernel is ready.
|
|
33
53
|
*/
|
|
@@ -52,15 +72,14 @@ export declare class WebWorkerKernel implements IKernel {
|
|
|
52
72
|
* Get the name of the kernel
|
|
53
73
|
*/
|
|
54
74
|
get name(): string;
|
|
55
|
-
private setupFilesystemAPIs;
|
|
56
75
|
private initFileSystem;
|
|
57
|
-
private
|
|
76
|
+
private _kernelSpec;
|
|
58
77
|
private _id;
|
|
59
78
|
private _name;
|
|
60
79
|
private _location;
|
|
61
80
|
private _contentsManager;
|
|
62
81
|
private _contentsProcessor;
|
|
63
|
-
private
|
|
82
|
+
private _remoteKernel;
|
|
64
83
|
private _isDisposed;
|
|
65
84
|
private _disposed;
|
|
66
85
|
private _worker;
|
|
@@ -68,6 +87,7 @@ export declare class WebWorkerKernel implements IKernel {
|
|
|
68
87
|
private _executeDelegate;
|
|
69
88
|
private _parentHeader;
|
|
70
89
|
private _parent;
|
|
90
|
+
private _ready;
|
|
71
91
|
}
|
|
72
92
|
/**
|
|
73
93
|
* A namespace for WebWorkerKernel statics.
|
|
@@ -79,6 +99,6 @@ export declare namespace WebWorkerKernel {
|
|
|
79
99
|
interface IOptions extends IKernel.IOptions {
|
|
80
100
|
contentsManager: Contents.IManager;
|
|
81
101
|
mountDrive: boolean;
|
|
82
|
-
|
|
102
|
+
kernelSpec: any;
|
|
83
103
|
}
|
|
84
104
|
}
|
package/lib/web_worker_kernel.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) JupyterLite Contributors
|
|
3
3
|
// Distributed under the terms of the Modified BSD License.
|
|
4
4
|
import coincident from 'coincident';
|
|
5
|
+
import { wrap } from 'comlink';
|
|
5
6
|
import { Signal } from '@lumino/signaling';
|
|
6
7
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
7
8
|
import { PageConfig } from '@jupyterlab/coreutils';
|
|
@@ -19,33 +20,85 @@ export class WebWorkerKernel {
|
|
|
19
20
|
this._executeDelegate = new PromiseDelegate();
|
|
20
21
|
this._parentHeader = undefined;
|
|
21
22
|
this._parent = undefined;
|
|
22
|
-
|
|
23
|
+
this._ready = new PromiseDelegate();
|
|
24
|
+
const { id, name, sendMessage, location, kernelSpec, contentsManager } = options;
|
|
23
25
|
this._id = id;
|
|
24
26
|
this._name = name;
|
|
25
27
|
this._location = location;
|
|
26
|
-
this.
|
|
28
|
+
this._kernelSpec = kernelSpec;
|
|
27
29
|
this._contentsManager = contentsManager;
|
|
28
30
|
this._sendMessage = sendMessage;
|
|
29
|
-
this._worker =
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
this._worker.onmessage = this._processWorkerMessage.bind(this);
|
|
33
|
-
this._remote = coincident(this._worker);
|
|
34
|
-
this.setupFilesystemAPIs();
|
|
35
|
-
this._remote.initialize(this._kernelspec, PageConfig.getBaseUrl());
|
|
31
|
+
this._worker = this.initWorker(options);
|
|
32
|
+
this._remoteKernel = this.initRemote(options);
|
|
36
33
|
this.initFileSystem(options);
|
|
37
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Load the worker.
|
|
37
|
+
*/
|
|
38
|
+
initWorker(options) {
|
|
39
|
+
if (crossOriginIsolated) {
|
|
40
|
+
return new Worker(new URL('./coincident.worker.js', import.meta.url), {
|
|
41
|
+
type: 'module'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return new Worker(new URL('./comlink.worker.js', import.meta.url), {
|
|
46
|
+
type: 'module'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Initialize the remote kernel.
|
|
52
|
+
* Use coincident if crossOriginIsolated, comlink otherwise
|
|
53
|
+
* See the two following issues for more context:
|
|
54
|
+
* - https://github.com/jupyterlite/jupyterlite/issues/1424
|
|
55
|
+
* - https://github.com/jupyterlite/xeus/issues/102
|
|
56
|
+
*/
|
|
57
|
+
initRemote(options) {
|
|
58
|
+
let remote;
|
|
59
|
+
if (crossOriginIsolated) {
|
|
60
|
+
// We directly forward messages to xeus, which will dispatch them properly
|
|
61
|
+
// See discussion in https://github.com/jupyterlite/xeus/pull/108#discussion_r1750143661
|
|
62
|
+
this._worker.onmessage = this._processCoincidentWorkerMessage.bind(this);
|
|
63
|
+
remote = coincident(this._worker);
|
|
64
|
+
// The coincident worker uses its own filesystem API:
|
|
65
|
+
remote.processDriveRequest = async (data) => {
|
|
66
|
+
if (!DriveContentsProcessor) {
|
|
67
|
+
throw new Error('File system calls over Atomics.wait is only supported with jupyterlite>=0.4.0a3');
|
|
68
|
+
}
|
|
69
|
+
if (this._contentsProcessor === undefined) {
|
|
70
|
+
this._contentsProcessor = new DriveContentsProcessor({
|
|
71
|
+
contentsManager: this._contentsManager
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return await this._contentsProcessor.processDriveRequest(data);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this._worker.onmessage = e => {
|
|
79
|
+
this._processComlinkWorkerMessage(e.data);
|
|
80
|
+
};
|
|
81
|
+
remote = wrap(this._worker);
|
|
82
|
+
}
|
|
83
|
+
remote
|
|
84
|
+
.initialize({
|
|
85
|
+
kernelSpec: this._kernelSpec,
|
|
86
|
+
baseUrl: PageConfig.getBaseUrl(),
|
|
87
|
+
mountDrive: options.mountDrive
|
|
88
|
+
})
|
|
89
|
+
.then(this._ready.resolve.bind(this._ready));
|
|
90
|
+
return remote;
|
|
91
|
+
}
|
|
38
92
|
async handleMessage(msg) {
|
|
39
93
|
this._parent = msg;
|
|
40
94
|
this._parentHeader = msg.header;
|
|
41
95
|
await this._sendMessageToWorker(msg);
|
|
42
96
|
}
|
|
43
97
|
async _sendMessageToWorker(msg) {
|
|
44
|
-
// TODO Remove this??
|
|
45
98
|
if (msg.header.msg_type !== 'input_reply') {
|
|
46
99
|
this._executeDelegate = new PromiseDelegate();
|
|
47
100
|
}
|
|
48
|
-
await this.
|
|
101
|
+
await this._remoteKernel.processMessage({ msg, parent: this.parent });
|
|
49
102
|
if (msg.header.msg_type !== 'input_reply') {
|
|
50
103
|
return await this._executeDelegate.promise;
|
|
51
104
|
}
|
|
@@ -69,17 +122,17 @@ export class WebWorkerKernel {
|
|
|
69
122
|
return this._location;
|
|
70
123
|
}
|
|
71
124
|
/**
|
|
72
|
-
* Process a message coming from the
|
|
125
|
+
* Process a message coming from the coincident web worker.
|
|
73
126
|
*
|
|
74
127
|
* @param msg The worker message to process.
|
|
75
128
|
*/
|
|
76
|
-
|
|
77
|
-
var _a, _b, _c, _d;
|
|
78
|
-
if (!msg.data.header) {
|
|
129
|
+
_processCoincidentWorkerMessage(msg) {
|
|
130
|
+
var _a, _b, _c, _d, _e;
|
|
131
|
+
if (!((_a = msg.data) === null || _a === void 0 ? void 0 : _a.header)) {
|
|
79
132
|
return;
|
|
80
133
|
}
|
|
81
|
-
msg.data.header.session = (
|
|
82
|
-
msg.data.session = (
|
|
134
|
+
msg.data.header.session = (_c = (_b = this._parentHeader) === null || _b === void 0 ? void 0 : _b.session) !== null && _c !== void 0 ? _c : '';
|
|
135
|
+
msg.data.session = (_e = (_d = this._parentHeader) === null || _d === void 0 ? void 0 : _d.session) !== null && _e !== void 0 ? _e : '';
|
|
83
136
|
this._sendMessage(msg.data);
|
|
84
137
|
// resolve promise
|
|
85
138
|
if (msg.data.header.msg_type === 'status' &&
|
|
@@ -87,11 +140,30 @@ export class WebWorkerKernel {
|
|
|
87
140
|
this._executeDelegate.resolve();
|
|
88
141
|
}
|
|
89
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Process a message coming from the comlink web worker.
|
|
145
|
+
*
|
|
146
|
+
* @param msg The worker message to process.
|
|
147
|
+
*/
|
|
148
|
+
_processComlinkWorkerMessage(msg) {
|
|
149
|
+
var _a, _b, _c, _d;
|
|
150
|
+
if (!msg.header) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
msg.header.session = (_b = (_a = this._parentHeader) === null || _a === void 0 ? void 0 : _a.session) !== null && _b !== void 0 ? _b : '';
|
|
154
|
+
msg.session = (_d = (_c = this._parentHeader) === null || _c === void 0 ? void 0 : _c.session) !== null && _d !== void 0 ? _d : '';
|
|
155
|
+
this._sendMessage(msg);
|
|
156
|
+
// resolve promise
|
|
157
|
+
if (msg.header.msg_type === 'status' &&
|
|
158
|
+
msg.content.execution_state === 'idle') {
|
|
159
|
+
this._executeDelegate.resolve();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
90
162
|
/**
|
|
91
163
|
* A promise that is fulfilled when the kernel is ready.
|
|
92
164
|
*/
|
|
93
165
|
get ready() {
|
|
94
|
-
return
|
|
166
|
+
return this._ready.promise;
|
|
95
167
|
}
|
|
96
168
|
/**
|
|
97
169
|
* Return whether the kernel is disposed.
|
|
@@ -114,7 +186,7 @@ export class WebWorkerKernel {
|
|
|
114
186
|
}
|
|
115
187
|
this._worker.terminate();
|
|
116
188
|
this._worker = null;
|
|
117
|
-
this.
|
|
189
|
+
this._remoteKernel = null;
|
|
118
190
|
this._isDisposed = true;
|
|
119
191
|
this._disposed.emit(void 0);
|
|
120
192
|
}
|
|
@@ -130,20 +202,6 @@ export class WebWorkerKernel {
|
|
|
130
202
|
get name() {
|
|
131
203
|
return this._name;
|
|
132
204
|
}
|
|
133
|
-
setupFilesystemAPIs() {
|
|
134
|
-
this._remote.processDriveRequest = async (data) => {
|
|
135
|
-
if (!DriveContentsProcessor) {
|
|
136
|
-
console.error('File system calls over Atomics.wait is only supported with jupyterlite>=0.4.0a3');
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (this._contentsProcessor === undefined) {
|
|
140
|
-
this._contentsProcessor = new DriveContentsProcessor({
|
|
141
|
-
contentsManager: this._contentsManager
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return await this._contentsProcessor.processDriveRequest(data);
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
205
|
async initFileSystem(options) {
|
|
148
206
|
let driveName;
|
|
149
207
|
let localPath;
|
|
@@ -156,13 +214,13 @@ export class WebWorkerKernel {
|
|
|
156
214
|
driveName = '';
|
|
157
215
|
localPath = options.location;
|
|
158
216
|
}
|
|
159
|
-
await this.
|
|
160
|
-
await this.
|
|
161
|
-
if (await this.
|
|
162
|
-
await this.
|
|
217
|
+
await this._remoteKernel.ready();
|
|
218
|
+
await this._remoteKernel.mount(driveName, '/drive', PageConfig.getBaseUrl());
|
|
219
|
+
if (await this._remoteKernel.isDir('/files')) {
|
|
220
|
+
await this._remoteKernel.cd('/files');
|
|
163
221
|
}
|
|
164
222
|
else {
|
|
165
|
-
await this.
|
|
223
|
+
await this._remoteKernel.cd(localPath);
|
|
166
224
|
}
|
|
167
225
|
}
|
|
168
226
|
}
|
package/lib/worker.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { DriveFS } from '@jupyterlite/contents';
|
|
2
|
+
import { IXeusWorkerKernel } from './tokens';
|
|
3
|
+
export declare class XeusRemoteKernel {
|
|
4
|
+
constructor(options?: XeusRemoteKernel.IOptions);
|
|
5
|
+
ready(): Promise<void>;
|
|
6
|
+
cd(path: string): Promise<void>;
|
|
7
|
+
isDir(path: string): Promise<boolean>;
|
|
8
|
+
processMessage(event: any): Promise<void>;
|
|
9
|
+
initialize(options: IXeusWorkerKernel.IOptions): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Register the callback function to send messages from the worker back to the main thread.
|
|
12
|
+
* @param callback the callback to register
|
|
13
|
+
*/
|
|
14
|
+
registerCallback(callback: (msg: any) => void): void;
|
|
15
|
+
protected _driveName: string;
|
|
16
|
+
protected _driveFS: DriveFS | null;
|
|
17
|
+
protected _sendWorkerMessage: (msg: any) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare namespace XeusRemoteKernel {
|
|
20
|
+
interface IOptions {
|
|
21
|
+
}
|
|
7
22
|
}
|
package/lib/worker.js
CHANGED
|
@@ -1,3 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
define((()=>(()=>{var __webpack_modules__={13:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActivityMonitor=void 0;const r=n(838);t.ActivityMonitor=class{constructor(e){this._timer=-1,this._timeout=-1,this._isDisposed=!1,this._activityStopped=new r.Signal(this),e.signal.connect(this._onSignalFired,this),this._timeout=e.timeout||1e3}get activityStopped(){return this._activityStopped}get timeout(){return this._timeout}set timeout(e){this._timeout=e}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,r.Signal.clearData(this))}_onSignalFired(e,t){clearTimeout(this._timer),this._sender=e,this._args=t,this._timer=setTimeout((()=>{this._activityStopped.emit({sender:this._sender,args:this._args})}),this._timeout)}}},376:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(13),t),o(n(106),t),o(n(477),t),o(n(484),t),o(n(279),t),o(n(169),t),o(n(58),t),o(n(121),t),o(n(659),t),o(n(881),t)},106:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},477:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LruCache=void 0,t.LruCache=class{constructor(e={}){this._map=new Map,this._maxSize=(null==e?void 0:e.maxSize)||128}get size(){return this._map.size}clear(){this._map.clear()}get(e){const t=this._map.get(e)||null;return null!=t&&(this._map.delete(e),this._map.set(e,t)),t}set(e,t){this._map.size>=this._maxSize&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}}},484:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.MarkdownCodeBlocks=void 0,function(e){e.CODE_BLOCK_MARKER="```";const t=[".markdown",".mdown",".mkdn",".md",".mkd",".mdwn",".mdtxt",".mdtext",".text",".txt",".Rmd"];class n{constructor(e){this.startLine=e,this.code="",this.endLine=-1}}e.MarkdownCodeBlock=n,e.isMarkdown=function(e){return t.indexOf(e)>-1},e.findMarkdownCodeBlocks=function(t){if(!t||""===t)return[];const r=t.split("\n"),o=[];let i=null;for(let t=0;t<r.length;t++){const s=r[t],a=0===s.indexOf(e.CODE_BLOCK_MARKER),l=null!=i;if(a||l)if(l)i&&(a?(i.endLine=t-1,o.push(i),i=null):i.code+=s+"\n");else{i=new n(t);const r=s.indexOf(e.CODE_BLOCK_MARKER),a=s.lastIndexOf(e.CODE_BLOCK_MARKER);r!==a&&(i.code=s.substring(r+e.CODE_BLOCK_MARKER.length,a),i.endLine=t,o.push(i),i=null)}}return o}}(n||(t.MarkdownCodeBlocks=n={}))},279:function(__unused_webpack_module,exports,__webpack_require__){"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageConfig=void 0;const coreutils_1=__webpack_require__(899),minimist_1=__importDefault(__webpack_require__(31)),url_1=__webpack_require__(881);var PageConfig;(function(PageConfig){function getOption(name){if(configData)return configData[name]||getBodyData(name);configData=Object.create(null);let found=!1;if("undefined"!=typeof document&&document){const e=document.getElementById("jupyter-config-data");e&&(configData=JSON.parse(e.textContent||""),found=!0)}if(!found&&"undefined"!=typeof process&&process.argv)try{const cli=(0,minimist_1.default)(process.argv.slice(2)),path=__webpack_require__(975);let fullPath="";"jupyter-config-data"in cli?fullPath=path.resolve(cli["jupyter-config-data"]):"JUPYTER_CONFIG_DATA"in process.env&&(fullPath=path.resolve(process.env.JUPYTER_CONFIG_DATA)),fullPath&&(configData=eval("require")(fullPath))}catch(e){console.error(e)}if(coreutils_1.JSONExt.isObject(configData))for(const e in configData)"string"!=typeof configData[e]&&(configData[e]=JSON.stringify(configData[e]));else configData=Object.create(null);return configData[name]||getBodyData(name)}function setOption(e,t){const n=getOption(e);return configData[e]=t,n}function getBaseUrl(){return url_1.URLExt.normalize(getOption("baseUrl")||"/")}function getTreeUrl(){return url_1.URLExt.join(getBaseUrl(),getOption("treeUrl"))}function getShareUrl(){return url_1.URLExt.normalize(getOption("shareUrl")||getBaseUrl())}function getTreeShareUrl(){return url_1.URLExt.normalize(url_1.URLExt.join(getShareUrl(),getOption("treeUrl")))}function getUrl(e){var t,n,r,o;let i=e.toShare?getShareUrl():getBaseUrl();const s=null!==(t=e.mode)&&void 0!==t?t:getOption("mode"),a=null!==(n=e.workspace)&&void 0!==n?n:getOption("workspace"),l="single-document"===s?"doc":"lab";i=url_1.URLExt.join(i,l),a!==PageConfig.defaultWorkspace&&(i=url_1.URLExt.join(i,"workspaces",encodeURIComponent(null!==(r=getOption("workspace"))&&void 0!==r?r:PageConfig.defaultWorkspace)));const c=null!==(o=e.treePath)&&void 0!==o?o:getOption("treePath");return c&&(i=url_1.URLExt.join(i,"tree",url_1.URLExt.encodeParts(c))),i}function getWsUrl(e){let t=getOption("wsUrl");if(!t){if(0!==(e=e?url_1.URLExt.normalize(e):getBaseUrl()).indexOf("http"))return"";t="ws"+e.slice(4)}return url_1.URLExt.normalize(t)}function getNBConvertURL({path:e,format:t,download:n}){const r=url_1.URLExt.encodeParts(e),o=url_1.URLExt.join(getBaseUrl(),"nbconvert",t,r);return n?o+"?download=true":o}function getToken(){return getOption("token")||getBodyData("jupyterApiToken")}function getNotebookVersion(){const e=getOption("notebookVersion");return""===e?[0,0,0]:JSON.parse(e)}PageConfig.getOption=getOption,PageConfig.setOption=setOption,PageConfig.getBaseUrl=getBaseUrl,PageConfig.getTreeUrl=getTreeUrl,PageConfig.getShareUrl=getShareUrl,PageConfig.getTreeShareUrl=getTreeShareUrl,PageConfig.getUrl=getUrl,PageConfig.defaultWorkspace="default",PageConfig.getWsUrl=getWsUrl,PageConfig.getNBConvertURL=getNBConvertURL,PageConfig.getToken=getToken,PageConfig.getNotebookVersion=getNotebookVersion;let configData=null,Extension;function getBodyData(e){if("undefined"==typeof document||!document.body)return"";const t=document.body.dataset[e];return void 0===t?"":decodeURIComponent(t)}!function(e){function t(e){try{const t=getOption(e);if(t)return JSON.parse(t)}catch(t){console.warn(`Unable to parse ${e}.`,t)}return[]}e.deferred=t("deferredExtensions"),e.disabled=t("disabledExtensions"),e.isDeferred=function(t){const n=t.indexOf(":");let r="";return-1!==n&&(r=t.slice(0,n)),e.deferred.some((e=>e===t||r&&e===r))},e.isDisabled=function(t){const n=t.indexOf(":");let r="";return-1!==n&&(r=t.slice(0,n)),e.disabled.some((e=>e===t||r&&e===r))}}(Extension=PageConfig.Extension||(PageConfig.Extension={}))})(PageConfig||(exports.PageConfig=PageConfig={}))},169:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PathExt=void 0;const r=n(975);var o;!function(e){function t(e){return 0===e.indexOf("/")&&(e=e.slice(1)),e}e.join=function(...e){const n=r.posix.join(...e);return"."===n?"":t(n)},e.joinWithLeadingSlash=function(...e){const t=r.posix.join(...e);return"."===t?"":t},e.basename=function(e,t){return r.posix.basename(e,t)},e.dirname=function(e){const n=t(r.posix.dirname(e));return"."===n?"":n},e.extname=function(e){return r.posix.extname(e)},e.normalize=function(e){return""===e?"":t(r.posix.normalize(e))},e.resolve=function(...e){return t(r.posix.resolve(...e))},e.relative=function(e,n){return t(r.posix.relative(e,n))},e.normalizeExtension=function(e){return e.length>0&&0!==e.indexOf(".")&&(e=`.${e}`),e},e.removeSlash=t}(o||(t.PathExt=o={}))},58:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signalToPromise=void 0;const r=n(899);t.signalToPromise=function(e,t){const n=new r.PromiseDelegate;function o(){e.disconnect(i)}function i(e,t){o(),n.resolve([e,t])}return e.connect(i),(null!=t?t:0)>0&&setTimeout((()=>{o(),n.reject(`Signal not emitted within ${t} ms.`)}),t),n.promise}},121:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Text=void 0,function(e){e.jsIndexToCharIndex=function(e,t){return e},e.charIndexToJsIndex=function(e,t){return e},e.camelCase=function(e,t=!1){return e.replace(/^(\w)|[\s-_:]+(\w)/g,(function(e,n,r){return r?r.toUpperCase():t?n.toUpperCase():n.toLowerCase()}))},e.titleCase=function(e){return(e||"").toLowerCase().split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" ")}}(n||(t.Text=n={}))},659:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Time=void 0;const n=[{name:"years",milliseconds:31536e6},{name:"months",milliseconds:2592e6},{name:"days",milliseconds:864e5},{name:"hours",milliseconds:36e5},{name:"minutes",milliseconds:6e4},{name:"seconds",milliseconds:1e3}];var r;!function(e){e.formatHuman=function(e,t="long"){const r=document.documentElement.lang||"en",o=new Intl.RelativeTimeFormat(r,{numeric:"auto",style:t}),i=new Date(e).getTime()-Date.now();for(let e of n){const t=Math.ceil(i/e.milliseconds);if(0!==t)return o.format(t,e.name)}return o.format(0,"seconds")},e.format=function(e){const t=document.documentElement.lang||"en";return new Intl.DateTimeFormat(t,{dateStyle:"short",timeStyle:"short"}).format(new Date(e))}}(r||(t.Time=r={}))},881:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.URLExt=void 0;const o=n(975),i=r(n(160));var s;!function(e){function t(e){if("undefined"!=typeof document&&document){const t=document.createElement("a");return t.href=e,t}return(0,i.default)(e)}function n(...e){let t=(0,i.default)(e[0],{});const n=""===t.protocol&&t.slashes;n&&(t=(0,i.default)(e[0],"https:"+e[0]));const r=`${n?"":t.protocol}${t.slashes?"//":""}${t.auth}${t.auth?"@":""}${t.host}`,s=o.posix.join(`${r&&"/"!==t.pathname[0]?"/":""}${t.pathname}`,...e.slice(1));return`${r}${"."===s?"":s}`}e.parse=t,e.getHostName=function(e){return(0,i.default)(e).hostname},e.normalize=function(e){return e&&t(e).toString()},e.join=n,e.encodeParts=function(e){return n(...e.split("/").map(encodeURIComponent))},e.objectToQueryString=function(e){const t=Object.keys(e).filter((e=>e.length>0));return t.length?"?"+t.map((t=>{const n=encodeURIComponent(String(e[t]));return t+(n?"="+n:"")})).join("&"):""},e.queryStringToObject=function(e){return e.replace(/^\?/,"").split("&").reduce(((e,t)=>{const[n,r]=t.split("=");return n.length>0&&(e[n]=decodeURIComponent(r||"")),e}),{})},e.isLocal=function(e,n=!1){const{protocol:r}=t(e);return(!r||0!==e.toLowerCase().indexOf(r))&&(n?0!==e.indexOf("//"):0!==e.indexOf("/"))}}(s||(t.URLExt=s={}))},899:function(e,t){!function(e){"use strict";e.JSONExt=void 0,function(e){function t(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e}function n(e){return Array.isArray(e)}function r(e,o){if(e===o)return!0;if(t(e)||t(o))return!1;let i=n(e),s=n(o);return i===s&&(i&&s?function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0,o=e.length;n<o;++n)if(!r(e[n],t[n]))return!1;return!0}(e,o):function(e,t){if(e===t)return!0;for(let n in e)if(void 0!==e[n]&&!(n in t))return!1;for(let n in t)if(void 0!==t[n]&&!(n in e))return!1;for(let n in e){let o=e[n],i=t[n];if(void 0!==o||void 0!==i){if(void 0===o||void 0===i)return!1;if(!r(o,i))return!1}}return!0}(e,o))}function o(e){return t(e)?e:n(e)?function(e){let t=new Array(e.length);for(let n=0,r=e.length;n<r;++n)t[n]=o(e[n]);return t}(e):function(e){let t={};for(let n in e){let r=e[n];void 0!==r&&(t[n]=o(r))}return t}(e)}e.emptyObject=Object.freeze({}),e.emptyArray=Object.freeze([]),e.isPrimitive=t,e.isArray=n,e.isObject=function(e){return!t(e)&&!n(e)},e.deepEqual=r,e.deepCopy=o}(e.JSONExt||(e.JSONExt={}));function t(e){let t=0;for(let n=0,r=e.length;n<r;++n)n%4==0&&(t=4294967295*Math.random()>>>0),e[n]=255&t,t>>>=8}e.Random=void 0,(e.Random||(e.Random={})).getRandomValues=(()=>{const e="undefined"!=typeof window&&(window.crypto||window.msCrypto)||null;return e&&"function"==typeof e.getRandomValues?function(t){return e.getRandomValues(t)}:t})(),e.UUID=void 0,(e.UUID||(e.UUID={})).uuid4=function(e){const t=new Uint8Array(16),n=new Array(256);for(let e=0;e<16;++e)n[e]="0"+e.toString(16);for(let e=16;e<256;++e)n[e]=e.toString(16);return function(){return e(t),t[6]=64|15&t[6],t[8]=128|63&t[8],n[t[0]]+n[t[1]]+n[t[2]]+n[t[3]]+"-"+n[t[4]]+n[t[5]]+"-"+n[t[6]]+n[t[7]]+"-"+n[t[8]]+n[t[9]]+"-"+n[t[10]]+n[t[11]]+n[t[12]]+n[t[13]]+n[t[14]]+n[t[15]]}}(e.Random.getRandomValues),e.MimeData=class{constructor(){this._types=[],this._values=[]}types(){return this._types.slice()}hasData(e){return-1!==this._types.indexOf(e)}getData(e){let t=this._types.indexOf(e);return-1!==t?this._values[t]:void 0}setData(e,t){this.clearData(e),this._types.push(e),this._values.push(t)}clearData(e){let t=this._types.indexOf(e);-1!==t&&(this._types.splice(t,1),this._values.splice(t,1))}clear(){this._types.length=0,this._values.length=0}},e.PromiseDelegate=class{constructor(){this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}resolve(e){(0,this._resolve)(e)}reject(e){(0,this._reject)(e)}},e.Token=class{constructor(e,t){this.name=e,this.description=null!=t?t:"",this._tokenStructuralPropertyT=null}}}(t)},838:(e,t,n)=>{"use strict";var r,o,i;n.r(t),n.d(t,{Signal:()=>l,Stream:()=>c}),function(e){function t(e,t,n=0,r=-1){let o,i=e.length;if(0===i)return-1;n=n<0?Math.max(0,n+i):Math.min(n,i-1),o=(r=r<0?Math.max(0,r+i):Math.min(r,i-1))<n?r+1+(i-n):r-n+1;for(let r=0;r<o;++r){let o=(n+r)%i;if(e[o]===t)return o}return-1}function n(e,t,n=-1,r=0){let o,i=e.length;if(0===i)return-1;o=(n=n<0?Math.max(0,n+i):Math.min(n,i-1))<(r=r<0?Math.max(0,r+i):Math.min(r,i-1))?n+1+(i-r):n-r+1;for(let r=0;r<o;++r){let o=(n-r+i)%i;if(e[o]===t)return o}return-1}function r(e,t,n=0,r=-1){let o,i=e.length;if(0===i)return-1;n=n<0?Math.max(0,n+i):Math.min(n,i-1),o=(r=r<0?Math.max(0,r+i):Math.min(r,i-1))<n?r+1+(i-n):r-n+1;for(let r=0;r<o;++r){let o=(n+r)%i;if(t(e[o],o))return o}return-1}function o(e,t,n=-1,r=0){let o,i=e.length;if(0===i)return-1;o=(n=n<0?Math.max(0,n+i):Math.min(n,i-1))<(r=r<0?Math.max(0,r+i):Math.min(r,i-1))?n+1+(i-r):n-r+1;for(let r=0;r<o;++r){let o=(n-r+i)%i;if(t(e[o],o))return o}return-1}function i(e,t=0,n=-1){let r=e.length;if(!(r<=1))for(t=t<0?Math.max(0,t+r):Math.min(t,r-1),n=n<0?Math.max(0,n+r):Math.min(n,r-1);t<n;){let r=e[t],o=e[n];e[t++]=o,e[n--]=r}}function s(e,t){let n=e.length;if(t<0&&(t+=n),t<0||t>=n)return;let r=e[t];for(let r=t+1;r<n;++r)e[r-1]=e[r];return e.length=n-1,r}e.firstIndexOf=t,e.lastIndexOf=n,e.findFirstIndex=r,e.findLastIndex=o,e.findFirstValue=function(e,t,n=0,o=-1){let i=r(e,t,n,o);return-1!==i?e[i]:void 0},e.findLastValue=function(e,t,n=-1,r=0){let i=o(e,t,n,r);return-1!==i?e[i]:void 0},e.lowerBound=function(e,t,n,r=0,o=-1){let i=e.length;if(0===i)return 0;let s=r=r<0?Math.max(0,r+i):Math.min(r,i-1),a=(o=o<0?Math.max(0,o+i):Math.min(o,i-1))-r+1;for(;a>0;){let r=a>>1,o=s+r;n(e[o],t)<0?(s=o+1,a-=r+1):a=r}return s},e.upperBound=function(e,t,n,r=0,o=-1){let i=e.length;if(0===i)return 0;let s=r=r<0?Math.max(0,r+i):Math.min(r,i-1),a=(o=o<0?Math.max(0,o+i):Math.min(o,i-1))-r+1;for(;a>0;){let r=a>>1,o=s+r;n(e[o],t)>0?a=r:(s=o+1,a-=r+1)}return s},e.shallowEqual=function(e,t,n){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0,o=e.length;r<o;++r)if(n?!n(e[r],t[r]):e[r]!==t[r])return!1;return!0},e.slice=function(e,t={}){let{start:n,stop:r,step:o}=t;if(void 0===o&&(o=1),0===o)throw new Error("Slice `step` cannot be zero.");let i,s=e.length;void 0===n?n=o<0?s-1:0:n<0?n=Math.max(n+s,o<0?-1:0):n>=s&&(n=o<0?s-1:s),void 0===r?r=o<0?-1:s:r<0?r=Math.max(r+s,o<0?-1:0):r>=s&&(r=o<0?s-1:s),i=o<0&&r>=n||o>0&&n>=r?0:o<0?Math.floor((r-n+1)/o+1):Math.floor((r-n-1)/o+1);let a=[];for(let t=0;t<i;++t)a[t]=e[n+t*o];return a},e.move=function(e,t,n){let r=e.length;if(r<=1)return;if((t=t<0?Math.max(0,t+r):Math.min(t,r-1))===(n=n<0?Math.max(0,n+r):Math.min(n,r-1)))return;let o=e[t],i=t<n?1:-1;for(let r=t;r!==n;r+=i)e[r]=e[r+i];e[n]=o},e.reverse=i,e.rotate=function(e,t,n=0,r=-1){let o=e.length;if(o<=1)return;if((n=n<0?Math.max(0,n+o):Math.min(n,o-1))>=(r=r<0?Math.max(0,r+o):Math.min(r,o-1)))return;let s=r-n+1;if(t>0?t%=s:t<0&&(t=(t%s+s)%s),0===t)return;let a=n+t;i(e,n,a-1),i(e,a,r),i(e,n,r)},e.fill=function(e,t,n=0,r=-1){let o,i=e.length;if(0!==i){n=n<0?Math.max(0,n+i):Math.min(n,i-1),o=(r=r<0?Math.max(0,r+i):Math.min(r,i-1))<n?r+1+(i-n):r-n+1;for(let r=0;r<o;++r)e[(n+r)%i]=t}},e.insert=function(e,t,n){let r=e.length;t=t<0?Math.max(0,t+r):Math.min(t,r);for(let n=r;n>t;--n)e[n]=e[n-1];e[t]=n},e.removeAt=s,e.removeFirstOf=function(e,n,r=0,o=-1){let i=t(e,n,r,o);return-1!==i&&s(e,i),i},e.removeLastOf=function(e,t,r=-1,o=0){let i=n(e,t,r,o);return-1!==i&&s(e,i),i},e.removeAllOf=function(e,t,n=0,r=-1){let o=e.length;if(0===o)return 0;n=n<0?Math.max(0,n+o):Math.min(n,o-1),r=r<0?Math.max(0,r+o):Math.min(r,o-1);let i=0;for(let s=0;s<o;++s)n<=r&&s>=n&&s<=r&&e[s]===t||r<n&&(s<=r||s>=n)&&e[s]===t?i++:i>0&&(e[s-i]=e[s]);return i>0&&(e.length=o-i),i},e.removeFirstWhere=function(e,t,n=0,o=-1){let i,a=r(e,t,n,o);return-1!==a&&(i=s(e,a)),{index:a,value:i}},e.removeLastWhere=function(e,t,n=-1,r=0){let i,a=o(e,t,n,r);return-1!==a&&(i=s(e,a)),{index:a,value:i}},e.removeAllWhere=function(e,t,n=0,r=-1){let o=e.length;if(0===o)return 0;n=n<0?Math.max(0,n+o):Math.min(n,o-1),r=r<0?Math.max(0,r+o):Math.min(r,o-1);let i=0;for(let s=0;s<o;++s)n<=r&&s>=n&&s<=r&&t(e[s],s)||r<n&&(s<=r||s>=n)&&t(e[s],s)?i++:i>0&&(e[s-i]=e[s]);return i>0&&(e.length=o-i),i}}(r||(r={})),function(e){e.rangeLength=function(e,t,n){return 0===n?1/0:e>t&&n>0||e<t&&n<0?0:Math.ceil((t-e)/n)}}(o||(o={})),function(e){function t(e,t,n=0){let r=new Array(t.length);for(let o=0,i=n,s=t.length;o<s;++o,++i){if(i=e.indexOf(t[o],i),-1===i)return null;r[o]=i}return r}e.findIndices=t,e.matchSumOfSquares=function(e,n,r=0){let o=t(e,n,r);if(!o)return null;let i=0;for(let e=0,t=o.length;e<t;++e){let t=o[e]-r;i+=t*t}return{score:i,indices:o}},e.matchSumOfDeltas=function(e,n,r=0){let o=t(e,n,r);if(!o)return null;let i=0,s=r-1;for(let e=0,t=o.length;e<t;++e){let t=o[e];i+=t-s-1,s=t}return{score:i,indices:o}},e.highlight=function(e,t,n){let r=[],o=0,i=0,s=t.length;for(;o<s;){let a=t[o],l=t[o];for(;++o<s&&t[o]===l+1;)l++;i<a&&r.push(e.slice(i,a)),a<l+1&&r.push(n(e.slice(a,l+1))),i=l+1}return i<e.length&&r.push(e.slice(i)),r},e.cmp=function(e,t){return e<t?-1:e>t?1:0}}(i||(i={}));var s,a=n(899);class l{constructor(e){this.sender=e}connect(e,t){return s.connect(this,e,t)}disconnect(e,t){return s.disconnect(this,e,t)}emit(e){s.emit(this,e)}}!function(e){e.disconnectBetween=function(e,t){s.disconnectBetween(e,t)},e.disconnectSender=function(e){s.disconnectSender(e)},e.disconnectReceiver=function(e){s.disconnectReceiver(e)},e.disconnectAll=function(e){s.disconnectAll(e)},e.clearData=function(e){s.disconnectAll(e)},e.getExceptionHandler=function(){return s.exceptionHandler},e.setExceptionHandler=function(e){let t=s.exceptionHandler;return s.exceptionHandler=e,t}}(l||(l={}));class c extends l{constructor(){super(...arguments),this._pending=new a.PromiseDelegate}async*[Symbol.asyncIterator](){let e=this._pending;for(;;)try{const{args:t,next:n}=await e.promise;e=n,yield t}catch(e){return}}emit(e){const t=this._pending,n=this._pending=new a.PromiseDelegate;t.resolve({args:e,next:n}),super.emit(e)}stop(){this._pending.promise.catch((()=>{})),this._pending.reject("stop"),this._pending=new a.PromiseDelegate}}!function(e){function t(e){let t=o.get(e);if(t&&0!==t.length){for(const e of t){if(!e.signal)continue;let t=e.thisArg||e.slot;e.signal=null,u(i.get(t))}u(t)}}function n(e){let t=i.get(e);if(t&&0!==t.length){for(const e of t){if(!e.signal)continue;let t=e.signal.sender;e.signal=null,u(o.get(t))}u(t)}}e.exceptionHandler=e=>{console.error(e)},e.connect=function(e,t,n){n=n||void 0;let r=o.get(e.sender);if(r||(r=[],o.set(e.sender,r)),l(r,e,t,n))return!1;let s=n||t,a=i.get(s);a||(a=[],i.set(s,a));let c={signal:e,slot:t,thisArg:n};return r.push(c),a.push(c),!0},e.disconnect=function(e,t,n){n=n||void 0;let r=o.get(e.sender);if(!r||0===r.length)return!1;let s=l(r,e,t,n);if(!s)return!1;let a=n||t,c=i.get(a);return s.signal=null,u(r),u(c),!0},e.disconnectBetween=function(e,t){let n=o.get(e);if(!n||0===n.length)return;let r=i.get(t);if(r&&0!==r.length){for(const t of r)t.signal&&t.signal.sender===e&&(t.signal=null);u(n),u(r)}},e.disconnectSender=t,e.disconnectReceiver=n,e.disconnectAll=function(e){t(e),n(e)},e.emit=function(e,t){let n=o.get(e.sender);if(n&&0!==n.length)for(let r=0,o=n.length;r<o;++r){let o=n[r];o.signal===e&&c(o,t)}};const o=new WeakMap,i=new WeakMap,s=new Set,a="function"==typeof requestAnimationFrame?requestAnimationFrame:setImmediate;function l(e,t,n,r){return function(e,o){for(const o of e)if((i=o).signal===t&&i.slot===n&&i.thisArg===r)return o;var i}(e)}function c(t,n){let{signal:r,slot:o,thisArg:i}=t;try{o.call(i,r.sender,n)}catch(t){e.exceptionHandler(t)}}function u(e){0===s.size&&a(f),s.add(e)}function f(){s.forEach(h),s.clear()}function h(e){r.removeAllWhere(e,d)}function d(e){return null===e.signal}}(s||(s={}))},31:e=>{"use strict";function t(e){return"number"==typeof e||!!/^0x[0-9a-f]+$/i.test(e)||/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function n(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"===t}e.exports=function(e,r){r||(r={});var o={bools:{},strings:{},unknownFn:null};"function"==typeof r.unknown&&(o.unknownFn=r.unknown),"boolean"==typeof r.boolean&&r.boolean?o.allBools=!0:[].concat(r.boolean).filter(Boolean).forEach((function(e){o.bools[e]=!0}));var i={};function s(e){return i[e].some((function(e){return o.bools[e]}))}Object.keys(r.alias||{}).forEach((function(e){i[e]=[].concat(r.alias[e]),i[e].forEach((function(t){i[t]=[e].concat(i[e].filter((function(e){return t!==e})))}))})),[].concat(r.string).filter(Boolean).forEach((function(e){o.strings[e]=!0,i[e]&&[].concat(i[e]).forEach((function(e){o.strings[e]=!0}))}));var a=r.default||{},l={_:[]};function c(e,t,r){for(var i=e,s=0;s<t.length-1;s++){var a=t[s];if(n(i,a))return;void 0===i[a]&&(i[a]={}),i[a]!==Object.prototype&&i[a]!==Number.prototype&&i[a]!==String.prototype||(i[a]={}),i[a]===Array.prototype&&(i[a]=[]),i=i[a]}var l=t[t.length-1];n(i,l)||(i!==Object.prototype&&i!==Number.prototype&&i!==String.prototype||(i={}),i===Array.prototype&&(i=[]),void 0===i[l]||o.bools[l]||"boolean"==typeof i[l]?i[l]=r:Array.isArray(i[l])?i[l].push(r):i[l]=[i[l],r])}function u(e,n,r){if(!r||!o.unknownFn||function(e,t){return o.allBools&&/^--[^=]+$/.test(t)||o.strings[e]||o.bools[e]||i[e]}(e,r)||!1!==o.unknownFn(r)){var s=!o.strings[e]&&t(n)?Number(n):n;c(l,e.split("."),s),(i[e]||[]).forEach((function(e){c(l,e.split("."),s)}))}}Object.keys(o.bools).forEach((function(e){u(e,void 0!==a[e]&&a[e])}));var f=[];-1!==e.indexOf("--")&&(f=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var h=0;h<e.length;h++){var d,p,m=e[h];if(/^--.+=/.test(m)){var g=m.match(/^--([^=]+)=([\s\S]*)$/);d=g[1];var _=g[2];o.bools[d]&&(_="false"!==_),u(d,_,m)}else if(/^--no-.+/.test(m))u(d=m.match(/^--no-(.+)/)[1],!1,m);else if(/^--.+/.test(m))d=m.match(/^--(.+)/)[1],void 0===(p=e[h+1])||/^(-|--)[^-]/.test(p)||o.bools[d]||o.allBools||i[d]&&s(d)?/^(true|false)$/.test(p)?(u(d,"true"===p,m),h+=1):u(d,!o.strings[d]||"",m):(u(d,p,m),h+=1);else if(/^-[^-]+/.test(m)){for(var v=m.slice(1,-1).split(""),w=!1,y=0;y<v.length;y++)if("-"!==(p=m.slice(y+2))){if(/[A-Za-z]/.test(v[y])&&"="===p[0]){u(v[y],p.slice(1),m),w=!0;break}if(/[A-Za-z]/.test(v[y])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(p)){u(v[y],p,m),w=!0;break}if(v[y+1]&&v[y+1].match(/\W/)){u(v[y],m.slice(y+2),m),w=!0;break}u(v[y],!o.strings[v[y]]||"",m)}else u(v[y],p,m);d=m.slice(-1)[0],w||"-"===d||(!e[h+1]||/^(-|--)[^-]/.test(e[h+1])||o.bools[d]||i[d]&&s(d)?e[h+1]&&/^(true|false)$/.test(e[h+1])?(u(d,"true"===e[h+1],m),h+=1):u(d,!o.strings[d]||"",m):(u(d,e[h+1],m),h+=1))}else if(o.unknownFn&&!1===o.unknownFn(m)||l._.push(o.strings._||!t(m)?m:Number(m)),r.stopEarly){l._.push.apply(l._,e.slice(h+1));break}}return Object.keys(a).forEach((function(e){var t,n,r;t=l,n=e.split("."),r=t,n.slice(0,-1).forEach((function(e){r=r[e]||{}})),n[n.length-1]in r||(c(l,e.split("."),a[e]),(i[e]||[]).forEach((function(t){c(l,t.split("."),a[e])})))})),r["--"]?l["--"]=f.slice():f.forEach((function(e){l._.push(e)})),l}},975:e=>{"use strict";function t(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var n,r="",o=0,i=-1,s=0,a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(47===n)break;n=47}if(47===n){if(i===a-1||1===s);else if(i!==a-1&&2===s){if(r.length<2||2!==o||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var l=r.lastIndexOf("/");if(l!==r.length-1){-1===l?(r="",o=0):o=(r=r.slice(0,l)).length-1-r.lastIndexOf("/"),i=a,s=0;continue}}else if(2===r.length||1===r.length){r="",o=0,i=a,s=0;continue}t&&(r.length>0?r+="/..":r="..",o=2)}else r.length>0?r+="/"+e.slice(i+1,a):r=e.slice(i+1,a),o=a-i-1;i=a,s=0}else 46===n&&-1!==s?++s:s=-1}return r}var r={resolve:function(){for(var e,r="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var s;i>=0?s=arguments[i]:(void 0===e&&(e=process.cwd()),s=e),t(s),0!==s.length&&(r=s+"/"+r,o=47===s.charCodeAt(0))}return r=n(r,!o),o?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),o=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!r)).length||r||(e="."),e.length>0&&o&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,n=0;n<arguments.length;++n){var o=arguments[n];t(o),o.length>0&&(void 0===e?e=o:e+="/"+o)}return void 0===e?".":r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n)return"";if((e=r.resolve(e))===(n=r.resolve(n)))return"";for(var o=1;o<e.length&&47===e.charCodeAt(o);++o);for(var i=e.length,s=i-o,a=1;a<n.length&&47===n.charCodeAt(a);++a);for(var l=n.length-a,c=s<l?s:l,u=-1,f=0;f<=c;++f){if(f===c){if(l>c){if(47===n.charCodeAt(a+f))return n.slice(a+f+1);if(0===f)return n.slice(a+f)}else s>c&&(47===e.charCodeAt(o+f)?u=f:0===f&&(u=0));break}var h=e.charCodeAt(o+f);if(h!==n.charCodeAt(a+f))break;47===h&&(u=f)}var d="";for(f=o+u+1;f<=i;++f)f!==i&&47!==e.charCodeAt(f)||(0===d.length?d+="..":d+="/..");return d.length>0?d+n.slice(a+u):(a+=u,47===n.charCodeAt(a)&&++a,n.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var n=e.charCodeAt(0),r=47===n,o=-1,i=!0,s=e.length-1;s>=1;--s)if(47===(n=e.charCodeAt(s))){if(!i){o=s;break}}else i=!1;return-1===o?r?"/":".":r&&1===o?"//":e.slice(0,o)},basename:function(e,n){if(void 0!==n&&"string"!=typeof n)throw new TypeError('"ext" argument must be a string');t(e);var r,o=0,i=-1,s=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var a=n.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!s){o=r+1;break}}else-1===l&&(s=!1,l=r+1),a>=0&&(c===n.charCodeAt(a)?-1==--a&&(i=r):(a=-1,i=l))}return o===i?i=l:-1===i&&(i=e.length),e.slice(o,i)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!s){o=r+1;break}}else-1===i&&(s=!1,i=r+1);return-1===i?"":e.slice(o,i)},extname:function(e){t(e);for(var n=-1,r=0,o=-1,i=!0,s=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===o&&(i=!1,o=a+1),46===l?-1===n?n=a:1!==s&&(s=1):-1!==n&&(s=-1);else if(!i){r=a+1;break}}return-1===n||-1===o||0===s||1===s&&n===o-1&&n===r+1?"":e.slice(n,o)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+"/"+r:r}(0,e)},parse:function(e){t(e);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return n;var r,o=e.charCodeAt(0),i=47===o;i?(n.root="/",r=1):r=0;for(var s=-1,a=0,l=-1,c=!0,u=e.length-1,f=0;u>=r;--u)if(47!==(o=e.charCodeAt(u)))-1===l&&(c=!1,l=u+1),46===o?-1===s?s=u:1!==f&&(f=1):-1!==s&&(f=-1);else if(!c){a=u+1;break}return-1===s||-1===l||0===f||1===f&&s===l-1&&s===a+1?-1!==l&&(n.base=n.name=0===a&&i?e.slice(1,l):e.slice(a,l)):(0===a&&i?(n.name=e.slice(1,s),n.base=e.slice(1,l)):(n.name=e.slice(a,s),n.base=e.slice(a,l)),n.ext=e.slice(s,l)),a>0?n.dir=e.slice(0,a-1):i&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r},992:(e,t)=>{"use strict";var n=Object.prototype.hasOwnProperty;function r(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o(e){try{return encodeURIComponent(e)}catch(e){return null}}t.stringify=function(e,t){t=t||"";var r,i,s=[];for(i in"string"!=typeof t&&(t="?"),e)if(n.call(e,i)){if((r=e[i])||null!=r&&!isNaN(r)||(r=""),i=o(i),r=o(r),null===i||null===r)continue;s.push(i+"="+r)}return s.length?t+s.join("&"):""},t.parse=function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,o={};t=n.exec(e);){var i=r(t[1]),s=r(t[2]);null===i||null===s||i in o||(o[i]=s)}return o}},63:e=>{"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},160:(e,t,n)=>{"use strict";var r=n(63),o=n(992),i=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,s=/[\n\r\t]/g,a=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,l=/:\d+$/,c=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,u=/^[a-zA-Z]:/;function f(e){return(e||"").toString().replace(i,"")}var h=[["#","hash"],["?","query"],function(e,t){return m(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],d={hash:1,query:1};function p(e){var t,r=("undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{}).location||{},o={},i=typeof(e=e||r);if("blob:"===e.protocol)o=new _(unescape(e.pathname),{});else if("string"===i)for(t in o=new _(e,{}),d)delete o[t];else if("object"===i){for(t in e)t in d||(o[t]=e[t]);void 0===o.slashes&&(o.slashes=a.test(e.href))}return o}function m(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function g(e,t){e=(e=f(e)).replace(s,""),t=t||{};var n,r=c.exec(e),o=r[1]?r[1].toLowerCase():"",i=!!r[2],a=!!r[3],l=0;return i?a?(n=r[2]+r[3]+r[4],l=r[2].length+r[3].length):(n=r[2]+r[4],l=r[2].length):a?(n=r[3]+r[4],l=r[3].length):n=r[4],"file:"===o?l>=2&&(n=n.slice(2)):m(o)?n=r[4]:o?i&&(n=n.slice(2)):l>=2&&m(t.protocol)&&(n=r[4]),{protocol:o,slashes:i||m(o),slashesCount:l,rest:n}}function _(e,t,n){if(e=(e=f(e)).replace(s,""),!(this instanceof _))return new _(e,t,n);var i,a,l,c,d,v,w=h.slice(),y=typeof t,b=this,x=0;for("object"!==y&&"string"!==y&&(n=t,t=null),n&&"function"!=typeof n&&(n=o.parse),i=!(a=g(e||"",t=p(t))).protocol&&!a.slashes,b.slashes=a.slashes||i&&t.slashes,b.protocol=a.protocol||t.protocol||"",e=a.rest,("file:"===a.protocol&&(2!==a.slashesCount||u.test(e))||!a.slashes&&(a.protocol||a.slashesCount<2||!m(b.protocol)))&&(w[3]=[/(.*)/,"pathname"]);x<w.length;x++)"function"!=typeof(c=w[x])?(l=c[0],v=c[1],l!=l?b[v]=e:"string"==typeof l?~(d="@"===l?e.lastIndexOf(l):e.indexOf(l))&&("number"==typeof c[2]?(b[v]=e.slice(0,d),e=e.slice(d+c[2])):(b[v]=e.slice(d),e=e.slice(0,d))):(d=l.exec(e))&&(b[v]=d[1],e=e.slice(0,d.index)),b[v]=b[v]||i&&c[3]&&t[v]||"",c[4]&&(b[v]=b[v].toLowerCase())):e=c(e,b);n&&(b.query=n(b.query)),i&&t.slashes&&"/"!==b.pathname.charAt(0)&&(""!==b.pathname||""!==t.pathname)&&(b.pathname=function(e,t){if(""===e)return t;for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=n.length,o=n[r-1],i=!1,s=0;r--;)"."===n[r]?n.splice(r,1):".."===n[r]?(n.splice(r,1),s++):s&&(0===r&&(i=!0),n.splice(r,1),s--);return i&&n.unshift(""),"."!==o&&".."!==o||n.push(""),n.join("/")}(b.pathname,t.pathname)),"/"!==b.pathname.charAt(0)&&m(b.protocol)&&(b.pathname="/"+b.pathname),r(b.port,b.protocol)||(b.host=b.hostname,b.port=""),b.username=b.password="",b.auth&&(~(d=b.auth.indexOf(":"))?(b.username=b.auth.slice(0,d),b.username=encodeURIComponent(decodeURIComponent(b.username)),b.password=b.auth.slice(d+1),b.password=encodeURIComponent(decodeURIComponent(b.password))):b.username=encodeURIComponent(decodeURIComponent(b.auth)),b.auth=b.password?b.username+":"+b.password:b.username),b.origin="file:"!==b.protocol&&m(b.protocol)&&b.host?b.protocol+"//"+b.host:"null",b.href=b.toString()}_.prototype={set:function(e,t,n){var i=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||o.parse)(t)),i[e]=t;break;case"port":i[e]=t,r(t,i.protocol)?t&&(i.host=i.hostname+":"+t):(i.host=i.hostname,i[e]="");break;case"hostname":i[e]=t,i.port&&(t+=":"+i.port),i.host=t;break;case"host":i[e]=t,l.test(t)?(t=t.split(":"),i.port=t.pop(),i.hostname=t.join(":")):(i.hostname=t,i.port="");break;case"protocol":i.protocol=t.toLowerCase(),i.slashes=!n;break;case"pathname":case"hash":if(t){var s="pathname"===e?"/":"#";i[e]=t.charAt(0)!==s?s+t:t}else i[e]=t;break;case"username":case"password":i[e]=encodeURIComponent(t);break;case"auth":var a=t.indexOf(":");~a?(i.username=t.slice(0,a),i.username=encodeURIComponent(decodeURIComponent(i.username)),i.password=t.slice(a+1),i.password=encodeURIComponent(decodeURIComponent(i.password))):i.username=encodeURIComponent(decodeURIComponent(t))}for(var c=0;c<h.length;c++){var u=h[c];u[4]&&(i[u[1]]=i[u[1]].toLowerCase())}return i.auth=i.password?i.username+":"+i.password:i.username,i.origin="file:"!==i.protocol&&m(i.protocol)&&i.host?i.protocol+"//"+i.host:"null",i.href=i.toString(),i},toString:function(e){e&&"function"==typeof e||(e=o.stringify);var t,n=this,r=n.host,i=n.protocol;i&&":"!==i.charAt(i.length-1)&&(i+=":");var s=i+(n.protocol&&n.slashes||m(n.protocol)?"//":"");return n.username?(s+=n.username,n.password&&(s+=":"+n.password),s+="@"):n.password?(s+=":"+n.password,s+="@"):"file:"!==n.protocol&&m(n.protocol)&&!r&&"/"!==n.pathname&&(s+="@"),(":"===r[r.length-1]||l.test(n.hostname)&&!n.port)&&(r+=":"),s+=r+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(s+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(s+=n.hash),s}},_.extractProtocol=g,_.location=p,_.trimLeft=f,_.qs=o,e.exports=_}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{SharedBufferContentsAPI:()=>T});const e="function",t="64e10b34-2bf7-4616-9668-f99de5aa046e",n="get",r="has",o="set",{isArray:i}=Array;let{SharedArrayBuffer:s,window:a}=globalThis,{notify:l,wait:c,waitAsync:u}=Atomics,f=null;u||(u=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))");n.onmessage=t,n.postMessage(e)}))}));try{new s(4)}catch(e){s=ArrayBuffer;const n=new WeakMap;if(a){const e=new Map,{prototype:{postMessage:r}}=Worker,o=n=>{const r=n.data?.[t];if(!i(r)){n.stopImmediatePropagation();const{id:t,sb:o}=r;e.get(t)(o)}};f=function(e,...s){const a=e?.[t];if(i(a)){const[e,t]=a;n.set(t,e),this.addEventListener("message",o)}return r.call(this,e,...s)},u=t=>({value:new Promise((r=>{e.set(n.get(t),r)})).then((r=>{e.delete(n.get(t)),n.delete(t);for(let e=0;e<r.length;e++)t[e]=r[e];return"ok"}))})}else{const e=(e,n)=>({[t]:{id:e,sb:n}});l=t=>{postMessage(e(n.get(t),t))},addEventListener("message",(e=>{const r=e.data?.[t];if(i(r)){const[e,t]=r;n.set(t,e)}}))}}const{Int32Array:h,Map:d,Uint16Array:p}=globalThis,{BYTES_PER_ELEMENT:m}=h,{BYTES_PER_ELEMENT:g}=p,_=new WeakSet,v=new WeakMap,w={value:{then:e=>e()}};let y=0;const b=(a,{parse:b=JSON.parse,stringify:x=JSON.stringify,transform:O,interrupt:E}=JSON)=>{if(!v.has(a)){const P=f||a.postMessage,C=(e,...n)=>P.call(a,{[t]:n},{transfer:e}),M=typeof E===e?E:E?.handler,k=E?.delay||42,S=new TextDecoder("utf-16"),A=(e,t)=>e?u(t,0):(M?((e,t,n)=>{for(;"timed-out"===c(e,0,0,t);)n()})(t,k,M):c(t,0),w);let R=!1;v.set(a,new Proxy(new d,{[r]:(e,t)=>"string"==typeof t&&!t.startsWith("_"),[n]:(e,t)=>"then"===t?null:(...e)=>{const n=y++;let r=new h(new s(2*m)),o=[];_.has(e.at(-1)||o)&&_.delete(o=e.pop()),C(o,n,r,t,O?e.map(O):e);const i=a!==globalThis;let l=0;return R&&i&&(l=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${t}(...args) is awaited`)),A(i,r).value.then((()=>{clearTimeout(l);const e=r[1];if(!e)return;const t=g*e;return r=new h(new s(t+t%m)),C([],n,r),A(i,r).value.then((()=>b(S.decode(new p(r.buffer).slice(0,e)))))}))},[o](n,r,o){const s=typeof o;if(s!==e)throw new Error(`Unable to assign ${r} as ${s}`);if(!n.size){const e=new d;a.addEventListener("message",(async r=>{const o=r.data?.[t];if(i(o)){r.stopImmediatePropagation();const[t,i,...s]=o;let a;if(s.length){const[r,o]=s;if(n.has(r)){R=!0;try{const s=await n.get(r)(...o);if(void 0!==s){const n=x(O?O(s):s);e.set(t,n),i[1]=n.length}}catch(e){a=e}finally{R=!1}}else a=new Error(`Unsupported action: ${r}`);i[0]=1}else{const n=e.get(t);e.delete(t);for(let e=new p(i.buffer),t=0;t<n.length;t++)e[t]=n.charCodeAt(t)}if(l(i,0),a)throw a}}))}return!!n.set(r,o)}}))}return v.get(a)};b.transfer=(...e)=>(_.add(e),e);const x=b,O=new TextEncoder,E=new TextDecoder("utf-8"),P={0:!1,1:!0,2:!0,64:!0,65:!0,66:!0,129:!0,193:!0,514:!0,577:!0,578:!0,705:!0,706:!0,1024:!0,1025:!0,1026:!0,1089:!0,1090:!0,1153:!0,1154:!0,1217:!0,1218:!0,4096:!0,4098:!0};class C{constructor(e){this.fs=e}open(e){const t=this.fs.realPath(e.node);this.fs.FS.isFile(e.node.mode)&&(e.file=this.fs.API.get(t))}close(e){if(!this.fs.FS.isFile(e.node.mode)||!e.file)return;const t=this.fs.realPath(e.node),n=e.flags;let r="string"==typeof n?parseInt(n,10):n;r&=8191;let o=!0;r in P&&(o=P[r]),o&&this.fs.API.put(t,e.file),e.file=void 0}read(e,t,n,r,o){if(r<=0||void 0===e.file||o>=(e.file.data.length||0))return 0;const i=Math.min(e.file.data.length-o,r);return t.set(e.file.data.subarray(o,o+i),n),i}write(e,t,n,r,o){var i;if(r<=0||void 0===e.file)return 0;if(e.node.timestamp=Date.now(),o+r>((null===(i=e.file)||void 0===i?void 0:i.data.length)||0)){const t=e.file.data?e.file.data:new Uint8Array;e.file.data=new Uint8Array(o+r),e.file.data.set(t)}return e.file.data.set(t.subarray(n,n+r),o),r}llseek(e,t,n){let r=t;if(1===n)r+=e.position;else if(2===n&&this.fs.FS.isFile(e.node.mode)){if(void 0===e.file)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM);r+=e.file.data.length}if(r<0)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL);return r}}class M{constructor(e){this.fs=e}node(e){return function(e){return"node"in e}(e)?e.node:e}getattr(e){const t=this.node(e);return{...this.fs.API.getattr(this.fs.realPath(t)),mode:t.mode,ino:t.id}}setattr(e,t){const n=this.node(e);for(const[e,r]of Object.entries(t))switch(e){case"mode":n.mode=r;break;case"timestamp":n.timestamp=r;break;default:console.warn("setattr",e,"of",r,"on",n,"not yet implemented")}}lookup(e,t){const n=this.node(e),r=this.fs.PATH.join2(this.fs.realPath(n),t),o=this.fs.API.lookup(r);if(!o.ok)throw this.fs.FS.genericErrors[this.fs.ERRNO_CODES.ENOENT];return this.fs.createNode(n,t,o.mode,0)}mknod(e,t,n,r){const o=this.node(e),i=this.fs.PATH.join2(this.fs.realPath(o),t);return this.fs.API.mknod(i,n),this.fs.createNode(o,t,n,r)}rename(e,t,n){const r=this.node(e),o=this.node(t);this.fs.API.rename(r.parent?this.fs.PATH.join2(this.fs.realPath(r.parent),r.name):r.name,this.fs.PATH.join2(this.fs.realPath(o),n)),r.name=n,r.parent=o}unlink(e,t){this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(e)),t))}rmdir(e,t){this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(e)),t))}readdir(e){return this.fs.API.readdir(this.fs.realPath(this.node(e)))}symlink(e,t,n){throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)}readlink(e){throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)}}class k{constructor(e,t,n,r){this._driveName=e,this._mountpoint=t,this.FS=n,this.ERRNO_CODES=r}lookup(e){return this.request({method:"lookup",path:this.normalizePath(e)})}getmode(e){return this.request({method:"getmode",path:this.normalizePath(e)})}mknod(e,t){return this.request({method:"mknod",path:this.normalizePath(e),data:{mode:t}})}rename(e,t){return this.request({method:"rename",path:this.normalizePath(e),data:{newPath:this.normalizePath(t)}})}readdir(e){const t=this.request({method:"readdir",path:this.normalizePath(e)});return t.push("."),t.push(".."),t}rmdir(e){return this.request({method:"rmdir",path:this.normalizePath(e)})}get(e){const t=this.request({method:"get",path:this.normalizePath(e)});if(!t)throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT);const n=t.content,r=t.format;switch(r){case"json":case"text":return{data:O.encode(n),format:r};case"base64":{const e=atob(n),t=e.length,o=new Uint8Array(t);for(let n=0;n<t;n++)o[n]=e.charCodeAt(n);return{data:o,format:r}}default:throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT)}}put(e,t){switch(t.format){case"json":case"text":return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:E.decode(t.data)}});case"base64":{let n="";for(let e=0;e<t.data.byteLength;e++)n+=String.fromCharCode(t.data[e]);return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:btoa(n)}})}}}getattr(e){const t=this.request({method:"getattr",path:this.normalizePath(e)});return t.atime&&(t.atime=new Date(t.atime)),t.mtime&&(t.mtime=new Date(t.mtime)),t.ctime&&(t.ctime=new Date(t.ctime)),t.size=t.size||0,t}normalizePath(e){return e.startsWith(this._mountpoint)&&(e=e.slice(this._mountpoint.length)),this._driveName&&(e=`${this._driveName}:${e}`),e}}class S extends k{constructor(e,t,n,r,o){super(t,n,r,o),this._baseUrl=e}request(e){const t=new XMLHttpRequest;t.open("POST",encodeURI(this.endpoint),!1);try{t.send(JSON.stringify(e))}catch(e){console.error(e)}if(t.status>=400)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return JSON.parse(t.responseText)}get endpoint(){return`${this._baseUrl}api/drive`}}class A{constructor(e){this.FS=e.FS,this.PATH=e.PATH,this.ERRNO_CODES=e.ERRNO_CODES,this.API=this.createAPI(e),this.driveName=e.driveName,this.node_ops=new M(this),this.stream_ops=new C(this)}createAPI(e){return new S(e.baseUrl,e.driveName,e.mountpoint,e.FS,e.ERRNO_CODES)}mount(e){return this.createNode(null,e.mountpoint,16895,0)}createNode(e,t,n,r){const o=this.FS;if(!o.isDir(n)&&!o.isFile(n))throw new o.ErrnoError(this.ERRNO_CODES.EINVAL);const i=o.createNode(e,t,n,r);return i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i}getMode(e){return this.API.getmode(e)}realPath(e){const t=[];let n=e;for(t.push(n.name);n.parent!==n;)n=n.parent,t.push(n.name);return t.reverse(),this.PATH.join.apply(null,t)}}var R=__webpack_require__(376);globalThis.Module={};const U=x(self);class T extends k{request(e){return U.processDriveRequest(e)}}class D extends A{createAPI(e){return crossOriginIsolated?new T(e.driveName,e.mountpoint,e.FS,e.ERRNO_CODES):new S(e.baseUrl,e.driveName,e.mountpoint,e.FS,e.ERRNO_CODES)}}let j,N,I,L,F;async function q(){const e=new Promise((e=>{globalThis.Module.monitorRunDependencies=t=>{0===t&&e()}}));return globalThis.Module.addRunDependency("dummy"),globalThis.Module.removeRunDependency("dummy"),e}globalThis.toplevel_promise=null,globalThis.toplevel_promise_py_proxy=null,self.get_stdin=async function(){return new Promise((e=>{j=e}))},globalThis.ready=new Promise((e=>{I=e})),U.mount=(e,t,n)=>{const{FS:r,PATH:o,ERRNO_CODES:i}=globalThis.Module;r&&(N=new D({FS:r,PATH:o,ERRNO_CODES:i,baseUrl:n,driveName:e,mountpoint:t}),r.mkdir(t),r.mount(N,{},t),r.chdir(t))},U.ready=async()=>await globalThis.ready,U.cd=e=>{e&&globalThis.Module.FS&&globalThis.Module.FS.chdir(e)},U.isDir=e=>{try{const t=globalThis.Module.FS.lookupPath(e);return globalThis.Module.FS.isDir(t.node.mode)}catch(e){return!1}},U.processMessage=async e=>{const t=e.msg.header.msg_type;await globalThis.ready,null!==globalThis.toplevel_promise&&null!==globalThis.toplevel_promise_py_proxy&&(await globalThis.toplevel_promise,globalThis.toplevel_promise_py_proxy.delete(),globalThis.toplevel_promise_py_proxy=null,globalThis.toplevel_promise=null),"input_reply"===t?j(e.msg):F.notify_listener(e.msg)},U.initialize=async(e,t)=>{const n=R.URLExt.join(t,e.argv[0]),r=n.replace(".js",".wasm");importScripts(n),globalThis.Module=await createXeusModule({locateFile:e=>e.endsWith(".wasm")?r:e});try{if(await q(),void 0!==globalThis.Module.async_init){const n=R.URLExt.join(t,`xeus/kernels/${e.dir}`),r=R.URLExt.join(t,"xeus/kernel_packages"),o=!0;await globalThis.Module.async_init(n,r,o)}await q(),L=new globalThis.Module.xkernel,F=L.get_server(),F||console.error("Failed to start kernel!"),L.start()}catch(e){if("number"==typeof e){const t=globalThis.Module.get_exception_message(e);throw console.error(t),new Error(t)}throw console.error(e),e}I(1)}})(),__webpack_exports__})()));
|
|
3
|
-
|
|
1
|
+
// Copyright (c) Thorsten Beier
|
|
2
|
+
// Copyright (c) JupyterLite Contributors
|
|
3
|
+
// Distributed under the terms of the Modified BSD License.
|
|
4
|
+
import { URLExt } from '@jupyterlab/coreutils';
|
|
5
|
+
globalThis.Module = {};
|
|
6
|
+
// when a toplevel cell uses an await, the cell is implicitly
|
|
7
|
+
// wrapped in a async function. Since the webloop - eventloop
|
|
8
|
+
// implementation does not support `eventloop.run_until_complete(f)`
|
|
9
|
+
// we need to convert the toplevel future in a javascript Promise
|
|
10
|
+
// this `toplevel` promise is then awaited before we
|
|
11
|
+
// execute the next cell. After the promise is awaited we need
|
|
12
|
+
// to do some cleanup and delete the python proxy
|
|
13
|
+
// (ie a js-wrapped python object) to avoid memory leaks
|
|
14
|
+
globalThis.toplevel_promise = null;
|
|
15
|
+
globalThis.toplevel_promise_py_proxy = null;
|
|
16
|
+
let resolveInputReply;
|
|
17
|
+
let kernelReady;
|
|
18
|
+
let rawXKernel;
|
|
19
|
+
let rawXServer;
|
|
20
|
+
async function get_stdin() {
|
|
21
|
+
const replyPromise = new Promise(resolve => {
|
|
22
|
+
resolveInputReply = resolve;
|
|
23
|
+
});
|
|
24
|
+
return replyPromise;
|
|
25
|
+
}
|
|
26
|
+
self.get_stdin = get_stdin;
|
|
27
|
+
async function waitRunDependency() {
|
|
28
|
+
const promise = new Promise(resolve => {
|
|
29
|
+
globalThis.Module.monitorRunDependencies = (n) => {
|
|
30
|
+
if (n === 0) {
|
|
31
|
+
resolve();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
// If there are no pending dependencies left, monitorRunDependencies will
|
|
36
|
+
// never be called. Since we can't check the number of dependencies,
|
|
37
|
+
// manually trigger a call.
|
|
38
|
+
globalThis.Module.addRunDependency('dummy');
|
|
39
|
+
globalThis.Module.removeRunDependency('dummy');
|
|
40
|
+
return promise;
|
|
41
|
+
}
|
|
42
|
+
globalThis.ready = new Promise(resolve => {
|
|
43
|
+
kernelReady = resolve;
|
|
44
|
+
});
|
|
45
|
+
export class XeusRemoteKernel {
|
|
46
|
+
constructor(options = {}) {
|
|
47
|
+
this._driveName = '';
|
|
48
|
+
this._driveFS = null;
|
|
49
|
+
this._sendWorkerMessage = () => { };
|
|
50
|
+
}
|
|
51
|
+
async ready() {
|
|
52
|
+
return await globalThis.ready;
|
|
53
|
+
}
|
|
54
|
+
async cd(path) {
|
|
55
|
+
if (!path || !globalThis.Module.FS) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
globalThis.Module.FS.chdir(path);
|
|
59
|
+
}
|
|
60
|
+
async isDir(path) {
|
|
61
|
+
try {
|
|
62
|
+
const lookup = globalThis.Module.FS.lookupPath(path);
|
|
63
|
+
return globalThis.Module.FS.isDir(lookup.node.mode);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async processMessage(event) {
|
|
70
|
+
const msg_type = event.msg.header.msg_type;
|
|
71
|
+
await globalThis.ready;
|
|
72
|
+
if (globalThis.toplevel_promise !== null &&
|
|
73
|
+
globalThis.toplevel_promise_py_proxy !== null) {
|
|
74
|
+
await globalThis.toplevel_promise;
|
|
75
|
+
globalThis.toplevel_promise_py_proxy.delete();
|
|
76
|
+
globalThis.toplevel_promise_py_proxy = null;
|
|
77
|
+
globalThis.toplevel_promise = null;
|
|
78
|
+
}
|
|
79
|
+
if (msg_type === 'input_reply') {
|
|
80
|
+
resolveInputReply(event.msg);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
rawXServer.notify_listener(event.msg);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async initialize(options) {
|
|
87
|
+
const { baseUrl, kernelSpec } = options;
|
|
88
|
+
// location of the kernel binary on the server
|
|
89
|
+
const binary_js = URLExt.join(baseUrl, kernelSpec.argv[0]);
|
|
90
|
+
const binary_wasm = binary_js.replace('.js', '.wasm');
|
|
91
|
+
importScripts(binary_js);
|
|
92
|
+
globalThis.Module = await createXeusModule({
|
|
93
|
+
locateFile: (file) => {
|
|
94
|
+
if (file.endsWith('.wasm')) {
|
|
95
|
+
return binary_wasm;
|
|
96
|
+
}
|
|
97
|
+
return file;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
try {
|
|
101
|
+
await waitRunDependency();
|
|
102
|
+
// each kernel can have a `async_init` function
|
|
103
|
+
// which can do kernel specific **async** initialization
|
|
104
|
+
// This function is usually implemented in the pre/post.js
|
|
105
|
+
// in the emscripten build of that kernel
|
|
106
|
+
if (globalThis.Module['async_init'] !== undefined) {
|
|
107
|
+
const kernel_root_url = URLExt.join(baseUrl, `xeus/kernels/${kernelSpec.dir}`);
|
|
108
|
+
const pkg_root_url = URLExt.join(baseUrl, 'xeus/kernel_packages');
|
|
109
|
+
const verbose = true;
|
|
110
|
+
await globalThis.Module['async_init'](kernel_root_url, pkg_root_url, verbose);
|
|
111
|
+
}
|
|
112
|
+
await waitRunDependency();
|
|
113
|
+
rawXKernel = new globalThis.Module.xkernel();
|
|
114
|
+
rawXServer = rawXKernel.get_server();
|
|
115
|
+
if (!rawXServer) {
|
|
116
|
+
console.error('Failed to start kernel!');
|
|
117
|
+
}
|
|
118
|
+
rawXKernel.start();
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
if (typeof e === 'number') {
|
|
122
|
+
const msg = globalThis.Module.get_exception_message(e);
|
|
123
|
+
console.error(msg);
|
|
124
|
+
throw new Error(msg);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
console.error(e);
|
|
128
|
+
throw e;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
kernelReady(1);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Register the callback function to send messages from the worker back to the main thread.
|
|
135
|
+
* @param callback the callback to register
|
|
136
|
+
*/
|
|
137
|
+
registerCallback(callback) {
|
|
138
|
+
this._sendWorkerMessage = callback;
|
|
139
|
+
}
|
|
140
|
+
}
|