From a35422b0dda65bbb283d6265110ba64d181310d5 Mon Sep 17 00:00:00 2001 From: GhilesHideur <47829666+GhilesHideur@users.noreply.github.com> Date: Mon, 6 May 2024 17:12:52 +0200 Subject: [PATCH] feat: added loading of taipy-gui libraries from bundle folder #27 --- back_end/common/template_utils.py | 9 +- back_end/render/render.py | 2 +- back_end/taipy/resource_handler.py | 20 +- front-end/gulpFiles/JsFiles.json | 8 +- front-end/gulpFiles/main.js | 131 ++++--------- front-end/gulpFiles/main_build_quick.js | 155 ++++++---------- front-end/index-taipy-view.html | 175 ------------------ front-end/index_tmp.html | 1 + .../connectors/taipy/677.taipy-gui-base.js | 1 - .../taipy/preview.taipy-gui-base.js | 1 - .../connectors/taipy/shared.taipy-gui-base.js | 1 - .../source/connectors/taipy/taipy-gui-base.js | 1 - front-end/xprjson-view_tmp.html | 1 + 13 files changed, 115 insertions(+), 391 deletions(-) delete mode 100644 front-end/index-taipy-view.html delete mode 100644 front-end/source/connectors/taipy/677.taipy-gui-base.js delete mode 100644 front-end/source/connectors/taipy/preview.taipy-gui-base.js delete mode 100644 front-end/source/connectors/taipy/shared.taipy-gui-base.js delete mode 100644 front-end/source/connectors/taipy/taipy-gui-base.js diff --git a/back_end/common/template_utils.py b/back_end/common/template_utils.py index 1b9b6a33..20ec72f7 100644 --- a/back_end/common/template_utils.py +++ b/back_end/common/template_utils.py @@ -39,7 +39,7 @@ def get_version(cls, root_dir: str) -> str: return "" # debug mode @classmethod - def render_template(cls, root_dir: str, xprjson_path: str, file_name: str) -> str: + def render_template(cls, root_dir: str, xprjson_path: str) -> str: """ Generates the dashboard HTML content by dynamically injecting configuration data from a JSON file into the dashboard's template HTML. @@ -48,9 +48,6 @@ def render_template(cls, root_dir: str, xprjson_path: str, file_name: str) -> st - xprjson_path (str): The filesystem path to the configuration JSON file. This file contains the configuration data to be injected into the dashboard template. - - file_name (str): The base name of the template HTML file. - The method dynamically appends the version number obtained from - `get_version` method to this base name to locate the final template file. - root_dir (Path): The root directory path where the index HTML file is located. This path is also set as the base directory for the application. @@ -63,12 +60,12 @@ def render_template(cls, root_dir: str, xprjson_path: str, file_name: str) -> st with open(xprjson_path, "r") as config_file: config_data = json.load(config_file) - index_view_path: Path = root_dir / f"{file_name}{VERSION}.html" + index_view_path: Path = Path(root_dir) / f"index-view{VERSION}.html" with open(index_view_path, "r") as template_file: template_data: str = template_file.read() - template_data_with_config: str = template_data.replace( + template_data_with_config = template_data.replace( "jsonContent = {};", f"jsonContent = {json.dumps(config_data)};" ) diff --git a/back_end/render/render.py b/back_end/render/render.py index e4713ae4..f6435d67 100644 --- a/back_end/render/render.py +++ b/back_end/render/render.py @@ -56,7 +56,7 @@ def add_cors_headers(response: Response) -> Response: def static_files(path: str) -> Any: if path == "" or path.endswith("/"): return TemplateUtils.render_template( - RenderApp.BASE_DIR, RenderApp.XPRJSON_PATH, "index-view" + RenderApp.BASE_DIR, RenderApp.XPRJSON_PATH ) return send_from_directory(str(RenderApp.BASE_DIR), path) diff --git a/back_end/taipy/resource_handler.py b/back_end/taipy/resource_handler.py index 7f6cb2d4..1959400b 100644 --- a/back_end/taipy/resource_handler.py +++ b/back_end/taipy/resource_handler.py @@ -10,9 +10,10 @@ # specific language governing permissions and limitations under the License. -from pathlib import Path import typing as t -from flask import send_from_directory +import os +from pathlib import Path +from flask import send_file, send_from_directory from taipy.gui.custom import ResourceHandler from ..common import TemplateUtils @@ -43,13 +44,22 @@ def get_resources(self, path: str, base_bundle_path: str) -> t.Any: return send_from_directory(root_dir, "index.html") xprjson_path: Path = (Path.cwd() / self.xprjson_file_name).resolve() if xprjson_path.is_file(): - return TemplateUtils.render_template( - root_dir, xprjson_path, "index-taipy-view" - ) + return TemplateUtils.render_template(root_dir, xprjson_path) # Serve the requested file if it exists file_path: Path = root_dir / path if file_path.is_file(): return send_from_directory(root_dir, path) + if any( + substring in path + for substring in [ + "shared.taipy-gui-base.js", + "taipy-gui-base.js", + "preview.taipy-gui-base.js", + ] + ): + file_path = Path(base_bundle_path) / os.path.basename(path) + return send_file(file_path, mimetype="application/javascript") + return ("File not found", 404) diff --git a/front-end/gulpFiles/JsFiles.json b/front-end/gulpFiles/JsFiles.json index 3a325f98..68190597 100644 --- a/front-end/gulpFiles/JsFiles.json +++ b/front-end/gulpFiles/JsFiles.json @@ -53,9 +53,7 @@ "thirdparty/marked.min.js", "thirdparty/jquery.bt.js", "thirdparty/moment.min.js", - "thirdparty/daterangepicker.js", - "source/connectors/taipy/shared.taipy-gui-base.js", - "source/connectors/taipy/preview.taipy-gui-base.js" + "thirdparty/daterangepicker.js" ], "body": [ "source/kernel/utils/geoConversion.js", @@ -294,9 +292,7 @@ "source/kernel/general/backend/FileMngr.js", "thirdparty/json_parseMore.js", "thirdparty/marked.min.js", - "thirdparty/daterangepicker.js", - "source/connectors/taipy/shared.taipy-gui-base.js", - "source/connectors/taipy/taipy-gui-base.js" + "thirdparty/daterangepicker.js" ], "body": [ "source/kernel/datanodes/execution-engine/DatanodeDependency.js", diff --git a/front-end/gulpFiles/main.js b/front-end/gulpFiles/main.js index 7ef1368c..42bf4754 100644 --- a/front-end/gulpFiles/main.js +++ b/front-end/gulpFiles/main.js @@ -42,16 +42,15 @@ let browsersync = require('browser-sync').create(), xdashRuntimeHeaderJsList, xdashRuntimeBodyJsList, xdashRuntimeCssJsList, - taipyRuntimeHeaderJsList, xdashEditorCss = filesName.xdash_editor.css, xdashEditorHeader = filesName.xdash_editor.header, xdashEditorBody = filesName.xdash_editor.body, xdashRuntimeCss = filesName.xdash_runtime.css, xdashRuntimeHeader = filesName.xdash_runtime.header, xdashRuntimeBody = filesName.xdash_runtime.body, - taipyRuntimeHeader = filesName.taipy_runtime.header, - taipyGuiFile = 'source/connectors/taipy/taipy-gui-base.js', - previewTaipyGuiFile = 'source/connectors/taipy/preview.taipy-gui-base.js', + taipyGuiFilePath = './taipy-gui-base.js', + taipyGuiSharedFilePath = './shared.taipy-gui-base.js', + taipyGuiPreviewFilePath = './preview.taipy-gui-base.js', buildFilePath, buildDirPath, VERSION, @@ -134,8 +133,6 @@ task('init', (cb) => { filesName.xdash_runtime.css = xdashRuntimeCss + VERSION; filesName.xdash_runtime.header = xdashRuntimeHeader + VERSION; filesName.xdash_runtime.body = xdashRuntimeBody + VERSION; - - filesName.taipy_runtime.header = taipyRuntimeHeader + VERSION; } // Insert the configuration at the top @@ -218,8 +215,6 @@ task( xdashRuntimeHeaderJsList = [filesName.xdash_runtime.header + '.min.js']; xdashRuntimeBodyJsList = [filesName.xdash_runtime.body + '.min.js']; xdashRuntimeCssJsList = [filesName.xdash_runtime.css + '.min.css']; - - taipyRuntimeHeaderJsList = [filesName.taipy_runtime.header + '.min.js']; } else { generatedPageHeaderJsList = allFiles.xDashRuntime.header; generatedPageBodyJsList = allFiles.xDashRuntime.body; @@ -232,10 +227,6 @@ task( xdashRuntimeHeaderJsList = allFiles.xDashRuntime.header; xdashRuntimeBodyJsList = allFiles.xDashRuntime.body; xdashRuntimeCssJsList = allFiles.xDashRuntime.css; - - taipyRuntimeHeaderJsList = [...allFiles.xDashRuntime.header, taipyGuiFile].filter( - (file) => file !== previewTaipyGuiFile - ); } jsFile += @@ -261,8 +252,8 @@ task( }) ); -let fixPath = function (List, basePath) { - let path = basePath ? basePath : '../'; +const fixPath = function (List, basePath) { + const path = basePath || '../'; for (let t = 0; t < List.length; t++) { List[t] = path + List[t]; } @@ -310,24 +301,7 @@ task( task( 'usemin:xdash_runtime:header', series('createConfigurationFile', () => { - const xDashRuntimeHeaderFiles = GlobalConfig.allFiles.xDashRuntime.header; - const taipyRuntimeHeaderFiles = [...xDashRuntimeHeaderFiles, fixPath(taipyGuiFile)].filter( - (file) => file !== previewTaipyGuiFile - ); - - const xDashFileStream = src(fixPath(GlobalConfig.allFiles.xDashRuntime.header)) - .on('error', () => { - /* Ignore compiler errors */ - }) - .pipe( - terser().on('error', function (e) { - console.log(e); - this.emit('end'); - }) - ) - .pipe(concat(filesName.xdash_runtime.header + '.min.js')); - - const taipyFileStream = src(fixPath(taipyRuntimeHeaderFiles)) + return src(fixPath(GlobalConfig.allFiles.xDashRuntime.header)) .on('error', () => { /* Ignore compiler errors */ }) @@ -337,10 +311,7 @@ task( this.emit('end'); }) ) - .pipe(concat(filesName.taipy_runtime.header + '.min.js')); - - // Merge the two processes to ensure both complete before signaling task completion - return merge(xDashFileStream, taipyFileStream) + .pipe(concat(filesName.xdash_runtime.header + '.min.js')) .pipe(replace(`${filesName.workers.pyodide}dev.js`, getXdashWorkerPyodideFile())) .pipe(replace('source/assets/', 'assets/')) .pipe(dest(buildDirPath)); @@ -404,26 +375,26 @@ task( const dependenciesFiles = ['../thirdparty/pyodide.js', '../thirdparty/json_parseMore.js']; const workerFile = '../source/kernel/base/pyodide-worker.js'; - let pipe = src([configFile, ...dependenciesFiles, workerFile]) + const stream = src([configFile, ...dependenciesFiles, workerFile]) .pipe(debug()) .pipe(sourcemaps.init()) .pipe(concat(getXdashWorkerPyodideFile())); if (isProd) { - pipe = pipe.pipe( + stream.pipe( terser().on('error', function (e) { console.log(e); return this.end(); }) ); } - pipe = pipe.pipe(sourcemaps.write('.')).pipe(dest(destination)); + stream.pipe(sourcemaps.write('.')).pipe(dest(destination)); if (!isProd) { - pipe = pipe.pipe(connect.reload()); + stream.pipe(connect.reload()); } - return pipe; + return stream; }) ); @@ -436,12 +407,15 @@ task( const baseFileJs = destination; const baseFileCss = `${baseFileJs}assets/`; + const injectOptions = { ignorePath: destination, empty: true, addRootSlash: false }; + const header = src(fixPath(xdashEditorHeaderJsList, baseFileJs), { read: false }); const css = src(fixPath(xdashEditorCssJsList, baseFileCss), { read: false, addRootSlash: true }); - - const injectOptions = { ignorePath: destination, empty: true, addRootSlash: false }; + const scripts = ` + `; return src('../index_tmp.html') + .pipe(replace('', scripts)) .pipe(inject(header, { ...injectOptions, name: 'third' })) .pipe(inject(css, { ...injectOptions })) .pipe(debug()) @@ -475,15 +449,18 @@ task( const header = src(fixPath(xdashEditorHeaderJsList, baseFileJs), { read: false }); const css = src(fixPath(xdashEditorCssJsList, baseFileCss), { read: false, addRootSlash: true }); + const scripts = ` + `; - let stream = src('../index_tmp.html') + const stream = src('../index_tmp.html') + .pipe(replace('', scripts)) .pipe(inject(header, { ...injectOptions, name: 'third' })) .pipe(inject(css, injectOptions)) .pipe(debug()) .pipe(rename('index.html')); if (isProd) { - stream = stream + stream .pipe(replace('source/assets', 'assets')) .pipe(replace('source/starter-browser-compatibility.js', 'starter-browser-compatibility.js')) .pipe( @@ -493,7 +470,7 @@ task( ) .pipe(dest(destination)); } else { - stream = stream.pipe(dest(destination)).pipe(connect.reload()); + stream.pipe(dest(destination)).pipe(connect.reload()); } return stream; @@ -524,34 +501,27 @@ task( }); const xDashHeader = injectFiles(xdashRuntimeHeaderJsList, baseFileJs); - const taipyHeader = injectFiles(taipyRuntimeHeaderJsList, baseFileJs); const body = injectFiles(xdashRuntimeBodyJsList, baseFileJs); const css = injectFiles(xdashRuntimeCssJsList, baseFileCss, { addRootSlash: true }); - + const scripts = ` + `; const xDashFileName = isProd ? `index-view-${VERSION}.html` : 'index-view.html'; - const taipyFileName = isProd ? `index-taipy-view-${VERSION}.html` : 'index-taipy-view.html'; - const xDashFileStream = src('../xprjson-view_tmp.html') + const stream = src('../xprjson-view_tmp.html') + .pipe(replace('', scripts)) .pipe(inject(xDashHeader, { ...injectOptions, name: 'header' })) .pipe(inject(body, { ...injectOptions, name: 'body' })) .pipe(inject(css, injectOptions)) .pipe(debug()) - .pipe(rename(xDashFileName)); - - const taipyFileStream = src('../xprjson-view_tmp.html') - .pipe(inject(taipyHeader, { ...injectOptions, name: 'header' })) - .pipe(inject(body, { ...injectOptions, name: 'body' })) - .pipe(inject(css, injectOptions)) - .pipe(debug()) - .pipe(rename(taipyFileName)); + .pipe(rename(xDashFileName)) + .pipe(dest(destination)); // Apply live reload for development environment - let fileStream = merge(xDashFileStream, taipyFileStream).pipe(dest(destination)); if (!isProd) { - fileStream = fileStream.pipe(connect.reload()); + stream.pipe(connect.reload()); } - return fileStream; + return stream; }) ); @@ -579,28 +549,19 @@ task( }); const xDashHeader = injectFiles(xdashRuntimeHeaderJsList, baseFileJs); - const taipyHeader = injectFiles(taipyRuntimeHeaderJsList, baseFileJs); const body = injectFiles(xdashRuntimeBodyJsList, baseFileJs); const css = injectFiles(xdashRuntimeCssJsList, baseFileCss, { addRootSlash: true }); - + const scripts = ` + `; const xDashFileName = isProd ? `index-view-${VERSION}.html` : 'index-view.html'; - const taipyFileName = isProd ? `index-taipy-view-${VERSION}.html` : 'index-taipy-view.html'; - const xDashFileStream = src('../xprjson-view_tmp.html') + return src('../xprjson-view_tmp.html') + .pipe(replace('', scripts)) .pipe(inject(xDashHeader, { ...injectOptions, name: 'header' })) .pipe(inject(body, { ...injectOptions, name: 'body' })) .pipe(inject(css, injectOptions)) .pipe(debug()) - .pipe(rename(xDashFileName)); - - const taipyFileStream = src('../xprjson-view_tmp.html') - .pipe(inject(taipyHeader, { ...injectOptions, name: 'header' })) - .pipe(inject(body, { ...injectOptions, name: 'body' })) - .pipe(inject(css, injectOptions)) - .pipe(debug()) - .pipe(rename(taipyFileName)); - - return merge(xDashFileStream, taipyFileStream) + .pipe(rename(xDashFileName)) .pipe(replace('source/starter-browser-compatibility.js', 'starter-browser-compatibility.js')) .pipe(dest(destination)); }) @@ -707,7 +668,7 @@ task('inject:after', () => { .pipe(connect.reload()); }); -task('injectmk:after', done => { +task('injectmk:after', (done) => { //if (mkDocsFileName==='mkdocs_taipy.yml') { return done(); } return src(DocDirectory + '/mkdocs-open-xprjson.js') .pipe( @@ -755,10 +716,6 @@ task('copy-starter', function () { return src(['../source/starter-browser-compatibility.js']).pipe(dest(buildDirPath)); }); -task('copy-taipy-worker', function () { - return src(['../source/connectors/taipy/677.taipy-gui-base.js']).pipe(dest(buildDirPath)); -}); - task( 'build', series( @@ -769,7 +726,6 @@ task( 'mkdocs', 'template', 'copy-starter', - 'copy-taipy-worker', //'createConfigurationFile', //'usemin:xdash_editor:header', //'usemin:xdash_editor:body', @@ -787,17 +743,7 @@ task( task( 'build:runtime', - series( - 'clear:cache', - 'clear:build', - 'sass', - 'init', - 'template', - 'copy-starter', - 'copy-taipy-worker', - 'inject:files:view', - 'images' - ) + series('clear:cache', 'clear:build', 'sass', 'init', 'template', 'copy-starter', 'inject:files:view', 'images') ); task( @@ -809,7 +755,6 @@ task( 'init', 'template', 'copy-starter', - 'copy-taipy-worker', 'inject:files:prod', 'inject:files:pyodide_worker', 'inject:files:view', diff --git a/front-end/gulpFiles/main_build_quick.js b/front-end/gulpFiles/main_build_quick.js index 935844d1..e26c0c5a 100644 --- a/front-end/gulpFiles/main_build_quick.js +++ b/front-end/gulpFiles/main_build_quick.js @@ -42,15 +42,15 @@ let browsersync = require('browser-sync').create(), xdashRuntimeHeaderJsList, xdashRuntimeBodyJsList, xdashRuntimeCssJsList, - taipyRuntimeHeaderJsList, xdashEditorCss = filesName.xdash_editor.css, xdashEditorHeader = filesName.xdash_editor.header, xdashEditorBody = filesName.xdash_editor.body, xdashRuntimeCss = filesName.xdash_runtime.css, xdashRuntimeHeader = filesName.xdash_runtime.header, xdashRuntimeBody = filesName.xdash_runtime.body, - taipyRuntimeHeader = filesName.taipy_runtime.header, - taipyGuiFile = 'source/connectors/taipy/taipy-gui-base.js', + taipyGuiFilePath = './taipy-gui-base.js', + taipyGuiSharedFilePath = './shared.taipy-gui-base.js', + taipyGuiPreviewFilePath = './preview.taipy-gui-base.js', buildFilePath, buildDirPath, VERSION, @@ -123,7 +123,7 @@ task('init', (cb) => { prefixName = GlobalConfig.config.xDashConfig.xDashBasicVersion ? '/chalkit_' : '/xdash_'; buildFilePath = prefixName + VERSION; buildDirPath = '../' + configuration.paths.buildDirectory + buildFilePath; - mkDocsFileName = GlobalConfig.config.xDashConfig.xDashLiteVersion ? 'mkdocs.yml' : 'mkdocs_taipy.yml'; + mkDocsFileName = GlobalConfig.config.xDashConfig.xDashLiteVersion ? 'mkdocs_taipy.yml' : 'mkdocs.yml'; if (addVersion) { filesName.xdash_editor.css = xdashEditorCss + VERSION; @@ -133,8 +133,6 @@ task('init', (cb) => { filesName.xdash_runtime.css = xdashRuntimeCss + VERSION; filesName.xdash_runtime.header = xdashRuntimeHeader + VERSION; filesName.xdash_runtime.body = xdashRuntimeBody + VERSION; - - filesName.taipy_runtime.header = taipyRuntimeHeader + VERSION; } // Insert the configuration at the top @@ -217,8 +215,6 @@ task( xdashRuntimeHeaderJsList = [filesName.xdash_runtime.header + '.min.js']; xdashRuntimeBodyJsList = [filesName.xdash_runtime.body + '.min.js']; xdashRuntimeCssJsList = [filesName.xdash_runtime.css + '.min.css']; - - taipyRuntimeHeaderJsList = [filesName.taipy_runtime.header + '.min.js']; } else { generatedPageHeaderJsList = allFiles.xDashRuntime.header; generatedPageBodyJsList = allFiles.xDashRuntime.body; @@ -231,8 +227,6 @@ task( xdashRuntimeHeaderJsList = allFiles.xDashRuntime.header; xdashRuntimeBodyJsList = allFiles.xDashRuntime.body; xdashRuntimeCssJsList = allFiles.xDashRuntime.css; - - taipyRuntimeHeaderJsList = [...allFiles.xDashRuntime.header, taipyGuiFile]; } jsFile += @@ -258,8 +252,8 @@ task( }) ); -let fixPath = function (List, basePath) { - let path = basePath ? basePath : '../'; +const fixPath = function (List, basePath) { + const path = basePath || '../'; for (let t = 0; t < List.length; t++) { List[t] = path + List[t]; } @@ -311,38 +305,22 @@ task( task( 'usemin:xdash_runtime:header', series('createConfigurationFile', () => { - const xDashRuntimeHeaderFiles = GlobalConfig.allFiles.xDashRuntime.header; - const taipyRuntimeHeaderFiles = [...xDashRuntimeHeaderFiles, fixPath(taipyGuiFile)]; - - const xDashFileStream = src(fixPath(GlobalConfig.allFiles.xDashRuntime.header)) - .on('error', () => { - /* Ignore compiler errors */ - }) - // .pipe( - // terser().on('error', function (e) { - // console.log(e); - // this.emit('end'); - // }) - // ) - .pipe(concat(filesName.xdash_runtime.header + '.min.js')); - - const taipyFileStream = src(fixPath(taipyRuntimeHeaderFiles)) - .on('error', () => { - /* Ignore compiler errors */ - }) - // .pipe( - // terser().on('error', function (e) { - // console.log(e); - // this.emit('end'); - // }) - // ) - .pipe(concat(filesName.taipy_runtime.header + '.min.js')); - - // Merge the two processes to ensure both complete before signaling task completion - return merge(xDashFileStream, taipyFileStream) - .pipe(replace(`${filesName.workers.pyodide}dev.js`, getXdashWorkerPyodideFile())) - .pipe(replace('source/assets/', 'assets/')) - .pipe(dest(buildDirPath)); + return ( + src(fixPath(GlobalConfig.allFiles.xDashRuntime.header)) + .on('error', () => { + /* Ignore compiler errors */ + }) + // .pipe( + // terser().on('error', function (e) { + // console.log(e); + // this.emit('end'); + // }) + // ) + .pipe(concat(filesName.xdash_runtime.header + '.min.js')) + .pipe(replace(`${filesName.workers.pyodide}dev.js`, getXdashWorkerPyodideFile())) + .pipe(replace('source/assets/', 'assets/')) + .pipe(dest(buildDirPath)) + ); }) ); @@ -405,26 +383,26 @@ task( const dependenciesFiles = ['../thirdparty/pyodide.js', '../thirdparty/json_parseMore.js']; const workerFile = '../source/kernel/base/pyodide-worker.js'; - let pipe = src([configFile, ...dependenciesFiles, workerFile]) + const stream = src([configFile, ...dependenciesFiles, workerFile]) .pipe(debug()) .pipe(sourcemaps.init()) .pipe(concat(getXdashWorkerPyodideFile())); if (isProd) { - // pipe = pipe.pipe( + // stream.pipe( // terser().on('error', function (e) { // console.log(e); // return this.end(); // }) // ); } - pipe = pipe.pipe(sourcemaps.write('.')).pipe(dest(destination)); + stream.pipe(sourcemaps.write('.')).pipe(dest(destination)); if (!isProd) { - pipe = pipe.pipe(connect.reload()); + stream.pipe(connect.reload()); } - return pipe; + return stream; }) ); @@ -437,12 +415,15 @@ task( const baseFileJs = destination; const baseFileCss = `${baseFileJs}assets/`; + const injectOptions = { ignorePath: destination, empty: true, addRootSlash: false }; + const header = src(fixPath(xdashEditorHeaderJsList, baseFileJs), { read: false }); const css = src(fixPath(xdashEditorCssJsList, baseFileCss), { read: false, addRootSlash: true }); - - const injectOptions = { ignorePath: destination, empty: true, addRootSlash: false }; + const scripts = ` + `; return src('../index_tmp.html') + .pipe(replace('', scripts)) .pipe(inject(header, { ...injectOptions, name: 'third' })) .pipe(inject(css, { ...injectOptions })) .pipe(debug()) @@ -476,15 +457,18 @@ task( const header = src(fixPath(xdashEditorHeaderJsList, baseFileJs), { read: false }); const css = src(fixPath(xdashEditorCssJsList, baseFileCss), { read: false, addRootSlash: true }); + const scripts = ` + `; - let stream = src('../index_tmp.html') + const stream = src('../index_tmp.html') + .pipe(replace('', scripts)) .pipe(inject(header, { ...injectOptions, name: 'third' })) .pipe(inject(css, injectOptions)) .pipe(debug()) .pipe(rename('index.html')); if (isProd) { - stream = stream + stream .pipe(replace('source/assets', 'assets')) .pipe(replace('source/starter-browser-compatibility.js', 'starter-browser-compatibility.js')) .pipe( @@ -494,7 +478,7 @@ task( ) .pipe(dest(destination)); } else { - stream = stream.pipe(dest(destination)).pipe(connect.reload()); + stream.pipe(dest(destination)).pipe(connect.reload()); } return stream; @@ -525,34 +509,27 @@ task( }); const xDashHeader = injectFiles(xdashRuntimeHeaderJsList, baseFileJs); - const taipyHeader = injectFiles(taipyRuntimeHeaderJsList, baseFileJs); const body = injectFiles(xdashRuntimeBodyJsList, baseFileJs); const css = injectFiles(xdashRuntimeCssJsList, baseFileCss, { addRootSlash: true }); - + const scripts = ` + `; const xDashFileName = isProd ? `index-view-${VERSION}.html` : 'index-view.html'; - const taipyFileName = isProd ? `index-taipy-view-${VERSION}.html` : 'index-taipy-view.html'; - const xDashFileStream = src('../xprjson-view_tmp.html') + const stream = src('../xprjson-view_tmp.html') + .pipe(replace('', scripts)) .pipe(inject(xDashHeader, { ...injectOptions, name: 'header' })) .pipe(inject(body, { ...injectOptions, name: 'body' })) .pipe(inject(css, injectOptions)) .pipe(debug()) - .pipe(rename(xDashFileName)); - - const taipyFileStream = src('../xprjson-view_tmp.html') - .pipe(inject(taipyHeader, { ...injectOptions, name: 'header' })) - .pipe(inject(body, { ...injectOptions, name: 'body' })) - .pipe(inject(css, injectOptions)) - .pipe(debug()) - .pipe(rename(taipyFileName)); + .pipe(rename(xDashFileName)) + .pipe(dest(destination)); // Apply live reload for development environment - let fileStream = merge(xDashFileStream, taipyFileStream).pipe(dest(destination)); if (!isProd) { - fileStream = fileStream.pipe(connect.reload()); + stream.pipe(connect.reload()); } - return fileStream; + return stream; }) ); @@ -580,28 +557,19 @@ task( }); const xDashHeader = injectFiles(xdashRuntimeHeaderJsList, baseFileJs); - const taipyHeader = injectFiles(taipyRuntimeHeaderJsList, baseFileJs); const body = injectFiles(xdashRuntimeBodyJsList, baseFileJs); const css = injectFiles(xdashRuntimeCssJsList, baseFileCss, { addRootSlash: true }); - + const scripts = ` + `; const xDashFileName = isProd ? `index-view-${VERSION}.html` : 'index-view.html'; - const taipyFileName = isProd ? `index-taipy-view-${VERSION}.html` : 'index-taipy-view.html'; - const xDashFileStream = src('../xprjson-view_tmp.html') + return src('../xprjson-view_tmp.html') + .pipe(replace('', scripts)) .pipe(inject(xDashHeader, { ...injectOptions, name: 'header' })) .pipe(inject(body, { ...injectOptions, name: 'body' })) .pipe(inject(css, injectOptions)) .pipe(debug()) - .pipe(rename(xDashFileName)); - - const taipyFileStream = src('../xprjson-view_tmp.html') - .pipe(inject(taipyHeader, { ...injectOptions, name: 'header' })) - .pipe(inject(body, { ...injectOptions, name: 'body' })) - .pipe(inject(css, injectOptions)) - .pipe(debug()) - .pipe(rename(taipyFileName)); - - return merge(xDashFileStream, taipyFileStream) + .pipe(rename(xDashFileName)) .pipe(replace('source/starter-browser-compatibility.js', 'starter-browser-compatibility.js')) .pipe(dest(destination)); }) @@ -712,7 +680,8 @@ task('inject:after', () => { .pipe(connect.reload()); }); -task('injectmk:after', () => { +task('injectmk:after', (done) => { + //if (mkDocsFileName==='mkdocs_taipy.yml') { return done(); } return src(DocDirectory + '/mkdocs-open-xprjson.js') .pipe( injectString.after( @@ -759,10 +728,6 @@ task('copy-starter', function () { return src(['../source/starter-browser-compatibility.js']).pipe(dest(buildDirPath)); }); -task('copy-taipy-worker', function () { - return src(['../source/connectors/taipy/677.taipy-gui-base.js']).pipe(dest(buildDirPath)); -}); - task( 'build', series( @@ -773,7 +738,6 @@ task( 'mkdocs', 'template', 'copy-starter', - 'copy-taipy-worker', //'createConfigurationFile', //'usemin:xdash_editor:header', //'usemin:xdash_editor:body', @@ -791,17 +755,7 @@ task( task( 'build:runtime', - series( - 'clear:cache', - 'clear:build', - 'sass', - 'init', - 'template', - 'copy-starter', - 'copy-taipy-worker', - 'inject:files:view', - 'images' - ) + series('clear:cache', 'clear:build', 'sass', 'init', 'template', 'copy-starter', 'inject:files:view', 'images') ); task( @@ -813,7 +767,6 @@ task( 'init', 'template', 'copy-starter', - 'copy-taipy-worker', 'inject:files:prod', 'inject:files:pyodide_worker', 'inject:files:view', diff --git a/front-end/index-taipy-view.html b/front-end/index-taipy-view.html deleted file mode 100644 index 0cb278ea..00000000 --- a/front-end/index-taipy-view.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - Chalk'it viewer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - diff --git a/front-end/index_tmp.html b/front-end/index_tmp.html index a3dee908..041959d1 100644 --- a/front-end/index_tmp.html +++ b/front-end/index_tmp.html @@ -12,6 +12,7 @@ + diff --git a/front-end/source/connectors/taipy/677.taipy-gui-base.js b/front-end/source/connectors/taipy/677.taipy-gui-base.js deleted file mode 100644 index 87f4db0b..00000000 --- a/front-end/source/connectors/taipy/677.taipy-gui-base.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TaipyGuiBase=t():e.TaipyGuiBase=t()}(this,(()=>(()=>{"use strict";const e=(e,t,o,s,a,n,p,l,r)=>{const d=new XMLHttpRequest;d.open("POST",`${t}?client_id=${l}`,!1),d.onerror=e=>self.postMessage({message:"Error: "+e,error:!0}),d.onload=e=>r(e.lengthComputable?e.loaded:0);const i=new FormData;i.append("blob",e,n),i.append("part",s.toString()),i.append("total",a.toString()),i.append("var_name",o),i.append("multiple",p?"True":"False"),d.send(i)},t=1048576,o=(e,t)=>o=>self.postMessage({progress:100*(t+o)/e,done:!1});return self.onmessage=s=>{((s,a,n,p)=>{if(s){let l=0;for(let e=0;e0,p,m),m(f.size),c=u,u=c+t,r.push(i.name)}}self.postMessage({progress:100,message:r.join(", ")+" Uploaded Successfully",done:!0})}})(s.data.files,s.data.uploadUrl,s.data.varName,s.data.id)},{}})())); \ No newline at end of file diff --git a/front-end/source/connectors/taipy/preview.taipy-gui-base.js b/front-end/source/connectors/taipy/preview.taipy-gui-base.js deleted file mode 100644 index 7469e0fe..00000000 --- a/front-end/source/connectors/taipy/preview.taipy-gui-base.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TaipyGuiBase=e():t.TaipyGuiBase=e()}(this,(()=>(()=>{"use strict";var t,e={786:(t,e,i)=>{i.r(e),i.d(e,{TaipyApp:()=>h,createApp:()=>u,default:()=>p});var n=i(829);const a="TaipyClientId",o=(t,e,i,a,o,r="",s=!0,c)=>{const d=(0,n.A)(),l={type:e,name:i,payload:a,propagate:s,client_id:o,ack_id:d,module_context:r};return null==t||t.emit("message",l,c),d},r=new Worker(new URL(i.p+i.u(677),i.b));var s=i(80);class c{constructor(t){this._data={},this._init_data={},this.init(t)}init(t){const e={};for(const i in this._init_data)if(i in t)for(const n in this._init_data[i])n in t[i]||(i in e||(e[i]={}),e[i][n]=this._init_data[i][n]);else e[i]=this._init_data[i];0!==Object.keys(e).length&&console.error("Unmatched data tree! Removed changes: ",e),this._init_data=t,this._data={};for(const t in this._init_data)for(const e in this._init_data[t]){const i=this._init_data[t][e];this._data[i.encoded_name]=i.value}}getEncodedName(t,e){if(e in this._init_data&&t in this._init_data[e])return this._init_data[e][t].encoded_name}getName(t){for(const e in this._init_data)for(const i in this._init_data[e])if(this._init_data[e][i].encoded_name===t)return[i,e]}get(t){if(!(t in this._data))throw new Error(`${t} is not available in Taipy Gui`);return this._data[t]}getInfo(t){for(const e in this._init_data)for(const i in this._init_data[e]){const n=this._init_data[e][i];if(n.encoded_name===t)return Object.assign(Object.assign({},n),{value:this._data[t]})}}getDataTree(){return this._init_data}getAllData(){return this._data}update(t,e){if(!(t in this._data))throw new Error(`${t} is not available in Taipy Gui`);this._data[t]=e}}const d=["ID","AID","GMC"],l=(t,e)=>{d.includes(t.type)&&""!==e.clientId&&""!==e.appId&&""!==e.context&&o(e.socket,"GDT","get_data_tree",{},e.clientId,e.context)};class h{constructor(t=void 0,e=void 0,i=void 0,n=void 0){n=n||(0,s.io)("/",{autoConnect:!1}),this.onInit=t,this.onChange=e,this.variableData=void 0,this.functionData=void 0,this.clientId="",this.context="",this.appId="",this.path=i,this.socket=n,((t,e)=>{t.on("connect",(()=>{""!==e.clientId&&""!==e.appId||e.init()})),t.io.on("reconnect",(()=>{console.log("WebSocket reconnected"),o(t,"AID","reconnect",e.appId,e.clientId,e.context)})),t.on("connect_error",(e=>{console.log("Error connecting WebSocket: ",e),setTimeout((()=>{t&&t.connect()}),500)})),t.on("disconnect",((e,i)=>{console.log("WebSocket disconnected due to: ",e,i),"io server disconnect"===e&&t&&t.connect()})),t.on("message",(t=>{((t,e)=>{var i;if(t.type){if("MU"===t.type&&Array.isArray(t.payload))for(const n of t.payload){const t=n.name,{value:a}=n.payload;null===(i=e.variableData)||void 0===i||i.update(t,a),e.onChange&&e.onChange(e,t,a)}else if("ID"===t.type){const{id:i}=t;(t=>{localStorage&&localStorage.setItem(a,t)})(i),e.clientId=i,e.updateContext(e.path)}else if("GMC"===t.type){const i=t.payload.data;window.localStorage.setItem("ModuleContext",i),e.context=i}else if("GDT"===t.type){const i=t.payload,n=i.variable,a=i.function;e.variableData&&e.functionData?(e.variableData.init(n),e.functionData.init(a)):(e.variableData=new c(n),e.functionData=new c(a),e.onInit&&e.onInit(e))}else if("AID"===t.type){const i=t.payload;if("reconnect"===i.name)return e.init();e.appId=i.id}else if("AL"===t.type&&e.onNotify){const i=t;e.onNotify(e,i.atype,i.message)}l(t,e)}})(t,e)})),t.connected||t.connect()})(n,this)}get onInit(){return this._onInit}set onInit(t){if(void 0!==t&&1!==(null==t?void 0:t.length))throw new Error("onInit() requires one parameter");this._onInit=t}get onChange(){return this._onChange}set onChange(t){if(void 0!==t&&3!==(null==t?void 0:t.length))throw new Error("onChange() requires three parameters");this._onChange=t}get onNotify(){return this._onNotify}set onNotify(t){if(void 0!==t&&3!==(null==t?void 0:t.length))throw new Error("onNotify() requires three parameters");this._onNotify=t}init(){this.clientId="",this.context="",this.appId="";const t=((t,e,i)=>{const n=localStorage&&localStorage.getItem(t);return n||""})(a);o(this.socket,"ID",a,t,t,void 0,!1),o(this.socket,"AID","connect","",t,void 0,!1),""!==t&&(this.clientId=t,this.updateContext(this.path))}getEncodedName(t,e){var i;return null===(i=this.variableData)||void 0===i?void 0:i.getEncodedName(t,e)}getName(t){var e;return null===(e=this.variableData)||void 0===e?void 0:e.getName(t)}get(t){var e;return null===(e=this.variableData)||void 0===e?void 0:e.get(t)}getInfo(t){var e;return null===(e=this.variableData)||void 0===e?void 0:e.getInfo(t)}getDataTree(){var t;return null===(t=this.variableData)||void 0===t?void 0:t.getDataTree()}getAllData(){var t;return null===(t=this.variableData)||void 0===t?void 0:t.getAllData()}getFunctionList(){var t;const e=null===(t=this.functionData)||void 0===t?void 0:t.getDataTree()[this.context];return Object.keys(e||{})}update(t,e){o(this.socket,"U",t,{value:e},this.clientId,this.context)}getContext(){return this.context}updateContext(t=""){t&&""!==t||(t=window.location.pathname.slice(1)),o(this.socket,"GMC","get_module_context",{path:t},this.clientId)}trigger(t,e,i={}){i.action=t,o(this.socket,"A",e,i,this.clientId,this.context)}upload(t,e,i){return((t,e,i,n,a="/taipy-uploads")=>new Promise(((o,s)=>{r.onmessage=t=>{t.data.error?s(t.data.message):t.data.done?o(t.data.message):i(t.data.progress)},r.onerror=t=>s(t),r.postMessage({files:e,uploadUrl:a,varName:t,id:n})})))(t,e,i,this.clientId)}getPageMetadata(){return JSON.parse(localStorage.getItem("tp_cp_meta")||"{}")}}const u=(t,e,i,n)=>new h(t,e,i,n),p=h}},i={};function n(t){var a=i[t];if(void 0!==a)return a.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.m=e,t=[],n.O=(e,i,a,o)=>{if(!i){var r=1/0;for(l=0;l=o)&&Object.keys(n.O).every((t=>n.O[t](i[c])))?i.splice(c--,1):(s=!1,o0&&t[l-1][2]>o;l--)t[l]=t[l-1];t[l]=[i,a,o]},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".taipy-gui-base.js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var a=i.length-1;a>-1&&(!t||!/^http(s?):/.test(t));)t=i[a--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),(()=>{n.b=document.baseURI||self.location.href;var t={685:0};n.O.j=e=>0===t[e];var e=(e,i)=>{var a,o,[r,s,c]=i,d=0;if(r.some((e=>0!==t[e]))){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(c)var l=c(n)}for(e&&e(i);dn(786)));return n.O(a)})())); \ No newline at end of file diff --git a/front-end/source/connectors/taipy/shared.taipy-gui-base.js b/front-end/source/connectors/taipy/shared.taipy-gui-base.js deleted file mode 100644 index c2873667..00000000 --- a/front-end/source/connectors/taipy/shared.taipy-gui-base.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(this.webpackChunkTaipyGuiBase=this.webpackChunkTaipyGuiBase||[]).push([[804],{829:(t,e,s)=>{s.d(e,{A:()=>h});const n={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let i;const r=new Uint8Array(16);function o(){if(!i&&(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!i))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(r)}const a=[];for(let t=0;t<256;++t)a.push((t+256).toString(16).slice(1));const h=function(t,e,s){if(n.randomUUID&&!e&&!t)return n.randomUUID();const i=(t=t||{}).random||(t.rng||o)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){s=s||0;for(let t=0;t<16;++t)e[s+t]=i[t];return e}return function(t,e=0){return a[t[e+0]]+a[t[e+1]]+a[t[e+2]]+a[t[e+3]]+"-"+a[t[e+4]]+a[t[e+5]]+"-"+a[t[e+6]]+a[t[e+7]]+"-"+a[t[e+8]]+a[t[e+9]]+"-"+a[t[e+10]]+a[t[e+11]]+a[t[e+12]]+a[t[e+13]]+a[t[e+14]]+a[t[e+15]]}(i)}},80:(t,e,s)=>{s.d(e,{io:()=>At});var n={};s.r(n),s.d(n,{Decoder:()=>gt,Encoder:()=>ft,PacketType:()=>dt,protocol:()=>lt});const i=Object.create(null);i.open="0",i.close="1",i.ping="2",i.pong="3",i.message="4",i.upgrade="5",i.noop="6";const r=Object.create(null);Object.keys(i).forEach((t=>{r[i[t]]=t}));const o={type:"error",data:"parser error"},a="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),h="function"==typeof ArrayBuffer,c=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,u=({type:t,data:e},s,n)=>a&&e instanceof Blob?s?n(e):p(e,n):h&&(e instanceof ArrayBuffer||c(e))?s?n(e):p(new Blob([e]),n):n(i[t]+(e||"")),p=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b"+(t||""))},s.readAsDataURL(t)};function l(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let d;const f="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)f["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const y="function"==typeof ArrayBuffer,g=(t,e)=>{if("string"!=typeof t)return{type:"message",data:b(t,e)};const s=t.charAt(0);return"b"===s?{type:"message",data:m(t.substring(1),e)}:r[s]?t.length>1?{type:r[s],data:t.substring(1)}:{type:r[s]}:o},m=(t,e)=>{if(y){const s=(t=>{let e,s,n,i,r,o=.75*t.length,a=t.length,h=0;"="===t[t.length-1]&&(o--,"="===t[t.length-2]&&o--);const c=new ArrayBuffer(o),u=new Uint8Array(c);for(e=0;e>4,u[h++]=(15&n)<<4|i>>2,u[h++]=(3&i)<<6|63&r;return c})(t);return b(s,e)}return{base64:!0,data:t}},b=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,w=String.fromCharCode(30);let v;function k(t){return t.reduce(((t,e)=>t+e.length),0)}function _(t,e){if(t[0].length===e)return t.shift();const s=new Uint8Array(e);let n=0;for(let i=0;i(t.hasOwnProperty(s)&&(e[s]=t[s]),e)),{})}const O=A.setTimeout,R=A.clearTimeout;function C(t,e){e.useNativeTimers?(t.setTimeoutFn=O.bind(A),t.clearTimeoutFn=R.bind(A)):(t.setTimeoutFn=A.setTimeout.bind(A),t.clearTimeoutFn=A.clearTimeout.bind(A))}class B extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="TransportError"}}class S extends E{constructor(t){super(),this.writable=!1,C(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,s){return super.emitReserved("error",new B(t,e,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=g(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let s in t)t.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(t[s]));return e}(t);return e.length?"?"+e:""}}const N="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),x=64,L={};let q,U=0,P=0;function j(t){let e="";do{e=N[t%x]+e,t=Math.floor(t/x)}while(t>0);return e}function D(){const t=j(+new Date);return t!==q?(U=0,q=t):t+"."+j(U++)}for(;P{var t;3===s.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(s)),4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof s.status?s.status:0)}),0))},s.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"undefined"!=typeof document&&(this.index=K.requestsCount++,K.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=M,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete K.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}function Y(){for(let t in K.requests)K.requests.hasOwnProperty(t)&&K.requests[t].abort()}K.requestsCount=0,K.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Y):"function"==typeof addEventListener&&addEventListener("onpagehide"in A?"pagehide":"unload",Y,!1));const W="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),z=A.WebSocket||A.MozWebSocket,J="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),$={websocket:class extends S{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,s=J?{}:T(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=J?new z(t,e,s):e?new z(t,e):new z(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e{try{this.ws.send(t)}catch(t){}n&&W((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=D()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!z}},webtransport:class extends S{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{const e=function(t,e){v||(v=new TextDecoder);const s=[];let n=0,i=-1,r=!1;return new TransformStream({transform(a,h){for(s.push(a);;){if(0===n){if(k(s)<1)break;const t=_(s,1);r=!(128&~t[0]),i=127&t[0],n=i<126?3:126===i?1:2}else if(1===n){if(k(s)<2)break;const t=_(s,2);i=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),n=3}else if(2===n){if(k(s)<8)break;const t=_(s,8),e=new DataView(t.buffer,t.byteOffset,t.length),r=e.getUint32(0);if(r>Math.pow(2,21)-1){h.enqueue(o);break}i=r*Math.pow(2,32)+e.getUint32(4),n=3}else{if(k(s)t){h.enqueue(o);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(e).getReader(),n=new TransformStream({transform(t,e){!function(t,e){a&&t.data instanceof Blob?t.data.arrayBuffer().then(l).then(e):h&&(t.data instanceof ArrayBuffer||c(t.data))?e(l(t.data)):u(t,!1,(t=>{d||(d=new TextEncoder),e(d.encode(t))}))}(t,(s=>{const n=s.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const t=new DataView(i.buffer);t.setUint8(0,126),t.setUint16(1,n)}else{i=new Uint8Array(9);const t=new DataView(i.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(n))}t.data&&"string"!=typeof t.data&&(i[0]|=128),e.enqueue(i),e.enqueue(s)}))}});n.readable.pipeTo(t.writable),this.writer=n.writable.getWriter();const i=()=>{s.read().then((({done:t,value:e})=>{t||(this.onPacket(e),i())})).catch((t=>{}))};i();const r={type:"open"};this.query.sid&&(r.data=`{"sid":"${this.query.sid}"}`),this.writer.write(r).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e{n&&W((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends S{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){const e="https:"===location.protocol;let s=location.port;s||(s=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||s!==t.port}const e=t&&t.forceBase64;this.supportsBinary=H&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const s=t.split(w),n=[];for(let t=0;t{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const s=t.length,n=new Array(s);let i=0;t.forEach(((t,r)=>{u(t,!1,(t=>{n[r]=t,++i===s&&e(n.join(w))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=D()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new K(this.uri(),t)}doWrite(t,e){const s=this.request({method:"POST",data:t});s.on("success",e),s.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}},Q=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,X=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function G(t){if(t.length>2e3)throw"URI too long";const e=t,s=t.indexOf("["),n=t.indexOf("]");-1!=s&&-1!=n&&(t=t.substring(0,s)+t.substring(s,n).replace(/:/g,";")+t.substring(n,t.length));let i=Q.exec(t||""),r={},o=14;for(;o--;)r[X[o]]=i[o]||"";return-1!=s&&-1!=n&&(r.source=e,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=function(t,e){const s=e.replace(/\/{2,9}/g,"/").split("/");return"/"!=e.slice(0,1)&&0!==e.length||s.splice(0,1),"/"==e.slice(-1)&&s.splice(s.length-1,1),s}(0,r.path),r.queryKey=function(t,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,n){e&&(s[e]=n)})),s}(0,r.query),r}class Z extends E{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=G(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=G(e.host).host),C(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let e={},s=t.split("&");for(let t=0,n=s.length;t{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const s=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new $[t](s)}open(){let t;if(this.opts.rememberUpgrade&&Z.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),s=!1;Z.priorWebsocketSuccess=!1;const n=()=>{s||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(t=>{if(!s)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;Z.priorWebsocketSuccess="websocket"===e.name,this.transport.pause((()=>{s||"closed"!==this.readyState&&(c(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=e.name,this.emitReserved("upgradeError",t)}})))};function i(){s||(s=!0,c(),e.close(),e=null)}const r=t=>{const s=new Error("probe error: "+t);s.transport=e.name,i(),this.emitReserved("upgradeError",s)};function o(){r("transport closed")}function a(){r("socket closed")}function h(t){e&&t.name!==e.name&&i()}const c=()=>{e.removeListener("open",n),e.removeListener("error",r),e.removeListener("close",o),this.off("close",a),this.off("upgrading",h)};e.once("open",n),e.once("error",r),e.once("close",o),this.once("close",a),this.once("upgrading",h),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{s||e.open()}),200):e.open()}onOpen(){if(this.readyState="open",Z.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s=57344?s+=3:(n++,s+=4);return s}(e):Math.ceil(1.33*(e.byteLength||e.size))),s>0&&t>this.maxPayload)return this.writeBuffer.slice(0,s);t+=2}var e;return this.writeBuffer}write(t,e,s){return this.sendPacket("message",t,e,s),this}send(t,e,s){return this.sendPacket("message",t,e,s),this}sendPacket(t,e,s,n){if("function"==typeof e&&(n=e,e=void 0),"function"==typeof s&&(n=s,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},s=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?s():t()})):this.upgrading?s():t()),this}onError(t){Z.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const n=t.length;for(;s"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,st=Object.prototype.toString,nt="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===st.call(Blob),it="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===st.call(File);function rt(t){return tt&&(t instanceof ArrayBuffer||et(t))||nt&&t instanceof Blob||it&&t instanceof File}function ot(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,s=t.length;e=0&&t.num{delete this.acks[t];for(let e=0;e{this.io.clearTimeoutFn(i),e.apply(this,[null,...t])}}emitWithAck(t,...e){const s=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((n,i)=>{e.push(((t,e)=>s?t?i(t):n(e):n(t))),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...n)=>{if(s===this._queue[0])return null!==t?s.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...n)),s.pending=!1,this._drainQueue()})),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:dt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case dt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case dt.EVENT:case dt.BINARY_EVENT:this.onevent(t);break;case dt.ACK:case dt.BINARY_ACK:this.onack(t);break;case dt.DISCONNECT:this.ondisconnect();break;case dt.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let s=!1;return function(...n){s||(s=!0,e.packet({type:dt.ACK,id:t,data:n}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:dt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s0&&t.jitter<=1?t.jitter:0,this.attempts=0}kt.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*t);t=1&Math.floor(10*e)?t+s:t-s}return 0|Math.min(t,this.max)},kt.prototype.reset=function(){this.attempts=0},kt.prototype.setMin=function(t){this.ms=t},kt.prototype.setMax=function(t){this.max=t},kt.prototype.setJitter=function(t){this.jitter=t};class _t extends E{constructor(t,e){var s;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,C(this,e),this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(s=e.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new kt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const i=e.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Z(this.uri,this.opts);const e=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const n=bt(e,"open",(function(){s.onopen(),t&&t()})),i=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},r=bt(e,"error",i);if(!1!==this._timeout){const t=this._timeout,s=this.setTimeoutFn((()=>{n(),i(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}return this.subs.push(n),this.subs.push(r),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(bt(t,"ping",this.onping.bind(this)),bt(t,"data",this.ondata.bind(this)),bt(t,"error",this.onerror.bind(this)),bt(t,"close",this.onclose.bind(this)),bt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){W((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let s=this.nsps[t];return s?this._autoConnect&&!s.active&&s.connect():(s=new vt(this,t,e),this.nsps[t]=s),s}_destroy(t){const e=Object.keys(this.nsps);for(const t of e)if(this.nsps[t].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let s=0;st())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Et={};function At(t,e){"object"==typeof t&&(e=t,t=void 0);const s=function(t,e="",s){let n=t;s=s||"undefined"!=typeof location&&location,null==t&&(t=s.protocol+"//"+s.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?s.protocol+t:s.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==s?s.protocol+"//"+t:"https://"+t),n=G(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.protocol+"://"+i+(s&&s.port===n.port?"":":"+n.port),n}(t,(e=e||{}).path||"/socket.io"),n=s.source,i=s.id,r=s.path,o=Et[i]&&r in Et[i].nsps;let a;return e.forceNew||e["force new connection"]||!1===e.multiplex||o?a=new _t(n,e):(Et[i]||(Et[i]=new _t(n,e)),a=Et[i]),s.query&&!e.query&&(e.query=s.queryKey),a.socket(s.path,e)}Object.assign(At,{Manager:_t,Socket:vt,io:At,connect:At})}}]); \ No newline at end of file diff --git a/front-end/source/connectors/taipy/taipy-gui-base.js b/front-end/source/connectors/taipy/taipy-gui-base.js deleted file mode 100644 index 2e16825f..00000000 --- a/front-end/source/connectors/taipy/taipy-gui-base.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TaipyGuiBase=e():t.TaipyGuiBase=e()}(this,(()=>(()=>{"use strict";var t,e={464:(t,e,i)=>{i.r(e),i.d(e,{TaipyApp:()=>h,createApp:()=>u,default:()=>p});var n=i(829);const a="TaipyClientId",o=(t,e,i,a,o,r="",s=!0,c)=>{const d=(0,n.A)(),l={type:e,name:i,payload:a,propagate:s,client_id:o,ack_id:d,module_context:r};return null==t||t.emit("message",l,c),d},r=new Worker(new URL(i.p+i.u(677),i.b));var s=i(80);class c{constructor(t){this._data={},this._init_data={},this.init(t)}init(t){const e={};for(const i in this._init_data)if(i in t)for(const n in this._init_data[i])n in t[i]||(i in e||(e[i]={}),e[i][n]=this._init_data[i][n]);else e[i]=this._init_data[i];0!==Object.keys(e).length&&console.error("Unmatched data tree! Removed changes: ",e),this._init_data=t,this._data={};for(const t in this._init_data)for(const e in this._init_data[t]){const i=this._init_data[t][e];this._data[i.encoded_name]=i.value}}getEncodedName(t,e){if(e in this._init_data&&t in this._init_data[e])return this._init_data[e][t].encoded_name}getName(t){for(const e in this._init_data)for(const i in this._init_data[e])if(this._init_data[e][i].encoded_name===t)return[i,e]}get(t){if(!(t in this._data))throw new Error(`${t} is not available in Taipy Gui`);return this._data[t]}getInfo(t){for(const e in this._init_data)for(const i in this._init_data[e]){const n=this._init_data[e][i];if(n.encoded_name===t)return Object.assign(Object.assign({},n),{value:this._data[t]})}}getDataTree(){return this._init_data}getAllData(){return this._data}update(t,e){if(!(t in this._data))throw new Error(`${t} is not available in Taipy Gui`);this._data[t]=e}}const d=["ID","AID","GMC"],l=(t,e)=>{d.includes(t.type)&&""!==e.clientId&&""!==e.appId&&""!==e.context&&o(e.socket,"GDT","get_data_tree",{},e.clientId,e.context)};class h{constructor(t=void 0,e=void 0,i=void 0,n=void 0){n=n||(0,s.io)("/",{autoConnect:!1}),this.onInit=t,this.onChange=e,this.variableData=void 0,this.functionData=void 0,this.clientId="",this.context="",this.appId="",this.path=i,this.socket=n,((t,e)=>{t.on("connect",(()=>{""!==e.clientId&&""!==e.appId||e.init()})),t.io.on("reconnect",(()=>{console.log("WebSocket reconnected"),o(t,"AID","reconnect",e.appId,e.clientId,e.context)})),t.on("connect_error",(e=>{console.log("Error connecting WebSocket: ",e),setTimeout((()=>{t&&t.connect()}),500)})),t.on("disconnect",((e,i)=>{console.log("WebSocket disconnected due to: ",e,i),"io server disconnect"===e&&t&&t.connect()})),t.on("message",(t=>{((t,e)=>{var i;if(t.type){if("MU"===t.type&&Array.isArray(t.payload))for(const n of t.payload){const t=n.name,{value:a}=n.payload;null===(i=e.variableData)||void 0===i||i.update(t,a),e.onChange&&e.onChange(e,t,a)}else if("ID"===t.type){const{id:i}=t;(t=>{localStorage&&localStorage.setItem(a,t)})(i),e.clientId=i,e.updateContext(e.path)}else if("GMC"===t.type){const i=t.payload.data;window.localStorage.setItem("ModuleContext",i),e.context=i}else if("GDT"===t.type){const i=t.payload,n=i.variable,a=i.function;e.variableData&&e.functionData?(e.variableData.init(n),e.functionData.init(a)):(e.variableData=new c(n),e.functionData=new c(a),e.onInit&&e.onInit(e))}else if("AID"===t.type){const i=t.payload;if("reconnect"===i.name)return e.init();e.appId=i.id}else if("AL"===t.type&&e.onNotify){const i=t;e.onNotify(e,i.atype,i.message)}l(t,e)}})(t,e)})),t.connected||t.connect()})(n,this)}get onInit(){return this._onInit}set onInit(t){if(void 0!==t&&1!==(null==t?void 0:t.length))throw new Error("onInit() requires one parameter");this._onInit=t}get onChange(){return this._onChange}set onChange(t){if(void 0!==t&&3!==(null==t?void 0:t.length))throw new Error("onChange() requires three parameters");this._onChange=t}get onNotify(){return this._onNotify}set onNotify(t){if(void 0!==t&&3!==(null==t?void 0:t.length))throw new Error("onNotify() requires three parameters");this._onNotify=t}init(){this.clientId="",this.context="",this.appId="";const t=((t,e,i)=>{const n=localStorage&&localStorage.getItem(t);return n||""})(a);o(this.socket,"ID",a,t,t,void 0,!1),o(this.socket,"AID","connect","",t,void 0,!1),""!==t&&(this.clientId=t,this.updateContext(this.path))}getEncodedName(t,e){var i;return null===(i=this.variableData)||void 0===i?void 0:i.getEncodedName(t,e)}getName(t){var e;return null===(e=this.variableData)||void 0===e?void 0:e.getName(t)}get(t){var e;return null===(e=this.variableData)||void 0===e?void 0:e.get(t)}getInfo(t){var e;return null===(e=this.variableData)||void 0===e?void 0:e.getInfo(t)}getDataTree(){var t;return null===(t=this.variableData)||void 0===t?void 0:t.getDataTree()}getAllData(){var t;return null===(t=this.variableData)||void 0===t?void 0:t.getAllData()}getFunctionList(){var t;const e=null===(t=this.functionData)||void 0===t?void 0:t.getDataTree()[this.context];return Object.keys(e||{})}update(t,e){o(this.socket,"U",t,{value:e},this.clientId,this.context)}getContext(){return this.context}updateContext(t=""){t&&""!==t||(t=window.location.pathname.slice(1)),o(this.socket,"GMC","get_module_context",{path:t},this.clientId)}trigger(t,e,i={}){i.action=t,o(this.socket,"A",e,i,this.clientId,this.context)}upload(t,e,i){return((t,e,i,n,a="/taipy-uploads")=>new Promise(((o,s)=>{r.onmessage=t=>{t.data.error?s(t.data.message):t.data.done?o(t.data.message):i(t.data.progress)},r.onerror=t=>s(t),r.postMessage({files:e,uploadUrl:a,varName:t,id:n})})))(t,e,i,this.clientId)}getPageMetadata(){return JSON.parse(localStorage.getItem("tp_cp_meta")||"{}")}}const u=(t,e,i,n)=>new h(t,e,i,n),p=h;window.addEventListener("beforeunload",(()=>{document.cookie="tprh=;path=/;Max-Age=-99999999;",localStorage.removeItem("tp_cp_meta")}))}},i={};function n(t){var a=i[t];if(void 0!==a)return a.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.m=e,t=[],n.O=(e,i,a,o)=>{if(!i){var r=1/0;for(l=0;l=o)&&Object.keys(n.O).every((t=>n.O[t](i[c])))?i.splice(c--,1):(s=!1,o0&&t[l-1][2]>o;l--)t[l]=t[l-1];t[l]=[i,a,o]},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".taipy-gui-base.js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var a=i.length-1;a>-1&&(!t||!/^http(s?):/.test(t));)t=i[a--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),(()=>{n.b=document.baseURI||self.location.href;var t={818:0};n.O.j=e=>0===t[e];var e=(e,i)=>{var a,o,[r,s,c]=i,d=0;if(r.some((e=>0!==t[e]))){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(c)var l=c(n)}for(e&&e(i);dn(464)));return n.O(a)})())); \ No newline at end of file diff --git a/front-end/xprjson-view_tmp.html b/front-end/xprjson-view_tmp.html index b9a4632b..fc3a3fd4 100644 --- a/front-end/xprjson-view_tmp.html +++ b/front-end/xprjson-view_tmp.html @@ -11,6 +11,7 @@ +