From ee508c50b937f1459ba65a3f62432ef848744818 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 12 Jun 2021 11:44:17 +0200 Subject: [PATCH] filter out legacy JS code from importmap and sort it also only add extension-less includes for .ts files (was accidentally commented out) and fix some .js imports without extension --- api/js/egw_action/egw_dragdrop_dhtmlx_tree.js | 4 ++-- api/js/etemplate/et2_widget_file.js | 1 - api/js/etemplate/et2_widget_file.ts | 1 - api/js/etemplate/etemplate2.js | 2 +- api/js/etemplate/etemplate2.ts | 2 +- api/js/jquery/jquery.noconflict.js | 1 + api/js/jsapi/egw.js | 2 +- api/src/Framework.php | 4 +--- api/src/Framework/Bundle.php | 11 ++++++++++- 9 files changed, 17 insertions(+), 11 deletions(-) diff --git a/api/js/egw_action/egw_dragdrop_dhtmlx_tree.js b/api/js/egw_action/egw_dragdrop_dhtmlx_tree.js index 32ce725600..8dde9e7b7f 100644 --- a/api/js/egw_action/egw_dragdrop_dhtmlx_tree.js +++ b/api/js/egw_action/egw_dragdrop_dhtmlx_tree.js @@ -12,8 +12,8 @@ egw_action; */ -import {EGW_AO_STATE_FOCUSED, EGW_AO_STATE_SELECTED, egwActionObjectInterface, EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT} from "./egw_action"; -import {egwBitIsSet} from "./egw_action_common"; +import {EGW_AO_STATE_FOCUSED, EGW_AO_STATE_SELECTED, egwActionObjectInterface, EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT} from "./egw_action.js"; +import {egwBitIsSet} from "./egw_action_common.js"; /** * This file contains an egw_actionObjectInterface which allows a dhtmlx tree diff --git a/api/js/etemplate/et2_widget_file.js b/api/js/etemplate/et2_widget_file.js index 04726f2e89..6d92b079cc 100644 --- a/api/js/etemplate/et2_widget_file.js +++ b/api/js/etemplate/et2_widget_file.js @@ -17,7 +17,6 @@ import { et2_register_widget } from "./et2_core_widget"; import { ClassWithAttributes } from "./et2_core_inheritance"; import { et2_no_init } from "./et2_core_common"; import { et2_vfsSize } from "./et2_widget_vfs"; -import "../Resumable/resumable.js"; /** * Class which implements file upload * diff --git a/api/js/etemplate/et2_widget_file.ts b/api/js/etemplate/et2_widget_file.ts index d0d48208c9..a515f61837 100644 --- a/api/js/etemplate/et2_widget_file.ts +++ b/api/js/etemplate/et2_widget_file.ts @@ -20,7 +20,6 @@ import {ClassWithAttributes} from "./et2_core_inheritance"; import {et2_no_init} from "./et2_core_common"; import {et2_DOMWidget} from "./et2_core_DOMWidget"; import {et2_vfsSize} from "./et2_widget_vfs"; -import "../Resumable/resumable.js"; /** * Class which implements file upload diff --git a/api/js/etemplate/etemplate2.js b/api/js/etemplate/etemplate2.js index 4fcc5645b8..90ba9aebf5 100644 --- a/api/js/etemplate/etemplate2.js +++ b/api/js/etemplate/etemplate2.js @@ -27,7 +27,7 @@ import { et2_compileLegacyJS } from "./et2_core_legacyJSFunctions"; import { et2_loadXMLFromURL } from "./et2_core_xml"; import { et2_nextmatch, et2_nextmatch_header_bar } from "./et2_extension_nextmatch"; import '../jsapi/egw_json.js'; -import { egwIsMobile } from "../egw_action/egw_action_common"; +import { egwIsMobile } from "../egw_action/egw_action_common.js"; /* Include all widget classes here, we only care about them registering, not importing anything import './et2_widget_template'; import './et2_widget_grid'; diff --git a/api/js/etemplate/etemplate2.ts b/api/js/etemplate/etemplate2.ts index 81021aa423..00d5137cc9 100644 --- a/api/js/etemplate/etemplate2.ts +++ b/api/js/etemplate/etemplate2.ts @@ -85,7 +85,7 @@ import {et2_loadXMLFromURL} from "./et2_core_xml"; import {et2_nextmatch, et2_nextmatch_header_bar} from "./et2_extension_nextmatch"; import {et2_tabbox} from "./et2_widget_tabs"; import '../jsapi/egw_json.js'; -import {egwIsMobile} from "../egw_action/egw_action_common"; +import {egwIsMobile} from "../egw_action/egw_action_common.js"; /* Include all widget classes here, we only care about them registering, not importing anything import './et2_widget_template'; diff --git a/api/js/jquery/jquery.noconflict.js b/api/js/jquery/jquery.noconflict.js index 8693f5cbf6..e488aca3d9 100644 --- a/api/js/jquery/jquery.noconflict.js +++ b/api/js/jquery/jquery.noconflict.js @@ -19,5 +19,6 @@ /vendor/egroupware/magicsuggest/magicsuggest.js; /api/js/jquery/splitter.js; /api/js/jquery/blueimp/js/blueimp-gallery.min.js; + /api/js/Resumable/resumable.js; */ jQuery.noConflict(); \ No newline at end of file diff --git a/api/js/jsapi/egw.js b/api/js/jsapi/egw.js index 361c234f5c..4172a70834 100644 --- a/api/js/jsapi/egw.js +++ b/api/js/jsapi/egw.js @@ -78,7 +78,7 @@ window.app = {classes: {}}; window.egw_appName = egw_script.getAttribute('data-app'); // split includes in legacy js and modules - const legacy_js_regexp = /\/dhtmlx|jquery/; + const legacy_js_regexp = /\/dhtmlx|jquery|magicsuggest|resumable/; // check if egw object was injected by window open if (typeof window.egw == 'undefined') diff --git a/api/src/Framework.php b/api/src/Framework.php index 5334abb7d7..26df8c7cb8 100644 --- a/api/src/Framework.php +++ b/api/src/Framework.php @@ -1124,7 +1124,7 @@ abstract class Framework extends Framework\Extra /** * Files imported via script tag in egw.js, because they are no modules */ - const legacy_js_imports = '/\/dhtmlx|jquery/'; + const legacy_js_imports = '#/dhtmlx|jquery|magicsuggest|resumable#'; /** * Add EGroupware URL prefix eg. '/egroupware' to files AND bundles @@ -1137,8 +1137,6 @@ abstract class Framework extends Framework\Extra // adding some extra mappings if (($prefix = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH)) === '/') $prefix = ''; - $imports['jquery'] = $imports[$prefix.'/vendor/bower-asset/jquery/dist/jquery.js']; - $imports['jqueryui'] = $imports[$prefix.'/vendor/bower-asset/jquery-ui/jquery-ui.js']; // fix egw_global(.d.ts) import $imports[$prefix.'/api/js/jsapi/egw_global'] = $prefix.'/api/js/jsapi/egw_global.js?'. diff --git a/api/src/Framework/Bundle.php b/api/src/Framework/Bundle.php index 02e328b44d..a300d18e92 100644 --- a/api/src/Framework/Bundle.php +++ b/api/src/Framework/Bundle.php @@ -13,6 +13,7 @@ namespace EGroupware\Api\Framework; +use EGroupware\Api; use EGroupware\Api\Cache; use EGroupware\Api\Header\UserAgent; @@ -380,12 +381,20 @@ class Bundle if (!$use_bundle) $target = $file; $map[$prefix . $file] = $prefix.$target.'?'.filemtime(EGW_SERVER_ROOT.$target); // typescript unfortunately has currently no option to add ".js" to it's es6 import statements - // therefore we add extra entries without .js extension to the map if (file_exists(EGW_SERVER_ROOT.substr($file, 0, -3) . '.ts')) + // therefore we add extra entries without .js extension to the map + if (file_exists(EGW_SERVER_ROOT.substr($file, 0, -3) . '.ts')) { $map[$prefix . substr($file, 0, -3)] = $prefix.$target.'?'.filemtime(EGW_SERVER_ROOT.$target); } } } + // filter out legacy js files not load via import + $map = array_filter($map, function($url) + { + return !preg_match(Api\Framework::legacy_js_imports, $url); + }); + ksort($map); + return $map; }, [], 30); }