From af2910adb07ec12a62ba243735318d3dc955678d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Sun, 27 Apr 2025 15:40:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E5=B0=86goog.get=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B0=83=E6=95=B4=E4=B8=BAgoog.readJsonSync=E4=BB=A5?= =?UTF-8?q?=E6=8C=87=E7=A4=BA=E5=85=B6=E5=90=8C=E6=AD=A5=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E7=89=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/common/app.js | 2 +- common/modules/mixly-modules/common/config.js | 6 ++-- .../mixly-modules/common/context-menu.js | 2 +- .../mixly-modules/common/editor-ace.js | 6 ++-- .../mixly-modules/common/editor-blockly.js | 4 +-- .../modules/mixly-modules/common/editor-md.js | 4 +-- .../mixly-modules/common/editor-mix.js | 4 +-- .../mixly-modules/common/editor-monaco.js | 2 +- .../mixly-modules/common/editor-unknown.js | 2 +- .../mixly-modules/common/editor-welcome.js | 2 +- .../mixly-modules/common/editors-manager.js | 4 +-- .../modules/mixly-modules/common/file-tree.js | 6 ++-- .../modules/mixly-modules/common/footerbar.js | 2 +- .../common/footerlayer-board-config.js | 2 +- .../common/footerlayer-example.js | 2 +- .../common/footerlayer-message.js | 6 ++-- .../mixly-modules/common/footerlayer.js | 2 +- common/modules/mixly-modules/common/loader.js | 2 +- common/modules/mixly-modules/common/nav.js | 12 ++++---- .../mixly-modules/common/sidebar-libs.js | 2 +- .../common/sidebar-local-storage.js | 2 +- .../mixly-modules/common/sidebars-manager.js | 8 ++--- .../mixly-modules/common/statusbar-ampy.js | 6 ++-- .../mixly-modules/common/statusbar-fs.js | 4 +-- .../common/statusbar-libs-code.js | 2 +- .../common/statusbar-libs-mix.js | 2 +- .../common/statusbar-serial-chart.js | 2 +- .../common/statusbar-serial-output.js | 2 +- .../mixly-modules/common/statusbar-serial.js | 2 +- .../common/statusbars-manager.js | 4 +-- .../mixly-modules/common/toolbox-searcher.js | 2 +- .../modules/mixly-modules/common/workspace.js | 2 +- common/modules/mixly-modules/common/xml.js | 4 +-- .../mixly-modules/electron/arduino-shell.js | 2 +- .../mixly-modules/electron/burn-upload.js | 2 +- .../mixly-modules/electron/wiki-generator.js | 4 +-- common/modules/mixly-modules/web/ampy.js | 29 +++++++++++-------- .../modules/mixly-modules/web/burn-upload.js | 10 +++---- .../mixly-modules/web/footerlayer-example.js | 2 +- common/modules/mixly-modules/web/serial.js | 2 +- .../web-modules/microbit/fs-wrapper.js | 4 +-- .../modules/web-modules/monaco-i18n-loader.js | 2 +- mixly-sw/mixly-modules/common/config.js | 4 +-- mixly-sw/mixly-modules/common/xml.js | 2 +- 44 files changed, 92 insertions(+), 87 deletions(-) diff --git a/common/modules/mixly-modules/common/app.js b/common/modules/mixly-modules/common/app.js index 6a99560c..c0748a00 100644 --- a/common/modules/mixly-modules/common/app.js +++ b/common/modules/mixly-modules/common/app.js @@ -87,7 +87,7 @@ class App extends Component { static { HTMLTemplate.add( 'html/app.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/app.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/app.html'))) ); } diff --git a/common/modules/mixly-modules/common/config.js b/common/modules/mixly-modules/common/config.js index 77d2b810..c6152826 100644 --- a/common/modules/mixly-modules/common/config.js +++ b/common/modules/mixly-modules/common/config.js @@ -51,18 +51,18 @@ const SOFTWARE_DEFAULT_CONFIG = { Config.init = () => { const urlConfig = Url.getConfig(); Config.BOARD = { - ...goog.getJSON(path.join(Env.boardDirPath, 'config.json'), BOARD_DEFAULT_CONFIG), + ...goog.readJsonSync(path.join(Env.boardDirPath, 'config.json'), BOARD_DEFAULT_CONFIG), ...urlConfig }; if (typeof Config.BOARD.board === 'string' && path.extname(Config.BOARD.board) === '.json') { - Config.BOARD.board = goog.getJSON(path.join(Env.boardDirPath, Config.BOARD.board)); + Config.BOARD.board = goog.readJsonSync(path.join(Env.boardDirPath, Config.BOARD.board)); } let pathPrefix = '../'; - Config.SOFTWARE = goog.getJSON(path.join(Env.srcDirPath, 'sw-config.json'), SOFTWARE_DEFAULT_CONFIG); + Config.SOFTWARE = goog.readJsonSync(path.join(Env.srcDirPath, 'sw-config.json'), SOFTWARE_DEFAULT_CONFIG); Config.pathPrefix = pathPrefix; Env.hasSocketServer = Config.SOFTWARE?.webSocket?.enabled ? true : false; diff --git a/common/modules/mixly-modules/common/context-menu.js b/common/modules/mixly-modules/common/context-menu.js index 3ad1f454..c19b949e 100644 --- a/common/modules/mixly-modules/common/context-menu.js +++ b/common/modules/mixly-modules/common/context-menu.js @@ -20,7 +20,7 @@ class ContextMenu { static { HTMLTemplate.add( 'html/context-menu-item.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/context-menu-item.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/context-menu-item.html'))) ); this.getItem = (name, hotKey) => HTMLTemplate.get('html/context-menu-item.html').render({ name, hotKey }); diff --git a/common/modules/mixly-modules/common/editor-ace.js b/common/modules/mixly-modules/common/editor-ace.js index 04d16903..4c052417 100644 --- a/common/modules/mixly-modules/common/editor-ace.js +++ b/common/modules/mixly-modules/common/editor-ace.js @@ -24,16 +24,16 @@ class EditorAce extends EditorBase { static { this.CTRL_BTNS = ['resetFontSize', 'increaseFontSize', 'decreaseFontSize']; this.CTRL_BTN_TEMPLATE = '
'; - this.MODE_MAP = goog.getJSON(path.join(Env.templatePath, 'json/ace-mode-map.json')); + this.MODE_MAP = goog.readJsonSync(path.join(Env.templatePath, 'json/ace-mode-map.json')); HTMLTemplate.add( 'html/editor/editor-code.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-code.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-code.html'))) ); if (['zh-hans', 'zh-hant'].includes(Msg.nowLang)) { ace.config.setMessages( - goog.getJSON(path.join(Env.templatePath, `json/ace.i18n.${Msg.nowLang}.json`)) + goog.readJsonSync(path.join(Env.templatePath, `json/ace.i18n.${Msg.nowLang}.json`)) ); } } diff --git a/common/modules/mixly-modules/common/editor-blockly.js b/common/modules/mixly-modules/common/editor-blockly.js index eccd0c8b..fbbe3ad2 100644 --- a/common/modules/mixly-modules/common/editor-blockly.js +++ b/common/modules/mixly-modules/common/editor-blockly.js @@ -46,12 +46,12 @@ class EditorBlockly extends EditorBase { static { HTMLTemplate.add( 'html/editor/editor-blockly.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-blockly.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-blockly.html'))) ); HTMLTemplate.add( 'xml/default-categories.xml', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'xml/default-categories.xml'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'xml/default-categories.xml'))) ); this.$blockly = $(''); diff --git a/common/modules/mixly-modules/common/editor-md.js b/common/modules/mixly-modules/common/editor-md.js index 5a98b866..5c7b246e 100644 --- a/common/modules/mixly-modules/common/editor-md.js +++ b/common/modules/mixly-modules/common/editor-md.js @@ -28,12 +28,12 @@ class EditorMd extends EditorBase { static { HTMLTemplate.add( 'html/editor/editor-md.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-md.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-md.html'))) ); HTMLTemplate.add( 'html/editor/editor-md-btns.html', - goog.get(path.join(Env.templatePath, 'html/editor/editor-md-btns.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-md-btns.html')) ); marked.use(markedKatex({ throwOnError: false })); diff --git a/common/modules/mixly-modules/common/editor-mix.js b/common/modules/mixly-modules/common/editor-mix.js index bf4b1d04..d2c1b4db 100644 --- a/common/modules/mixly-modules/common/editor-mix.js +++ b/common/modules/mixly-modules/common/editor-mix.js @@ -49,12 +49,12 @@ class EditorMix extends EditorBase { static { HTMLTemplate.add( 'html/editor/editor-mix.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-mix.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-mix.html'))) ); HTMLTemplate.add( 'html/editor/editor-mix-btns.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-mix-btns.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-mix-btns.html'))) ); } diff --git a/common/modules/mixly-modules/common/editor-monaco.js b/common/modules/mixly-modules/common/editor-monaco.js index 71f25a72..bac9c033 100644 --- a/common/modules/mixly-modules/common/editor-monaco.js +++ b/common/modules/mixly-modules/common/editor-monaco.js @@ -25,7 +25,7 @@ class EditorMonaco extends EditorBase { static { HTMLTemplate.add( 'html/editor/editor-code.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-code.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-code.html'))) ); this.$monaco = $(''); diff --git a/common/modules/mixly-modules/common/editor-unknown.js b/common/modules/mixly-modules/common/editor-unknown.js index 7ab324c3..5f6c755c 100644 --- a/common/modules/mixly-modules/common/editor-unknown.js +++ b/common/modules/mixly-modules/common/editor-unknown.js @@ -18,7 +18,7 @@ class EditorUnknown extends EditorBase { static { HTMLTemplate.add( 'html/editor/editor-unknown.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-unknown.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-unknown.html'))) ); } diff --git a/common/modules/mixly-modules/common/editor-welcome.js b/common/modules/mixly-modules/common/editor-welcome.js index ca42f39f..fcc061e1 100644 --- a/common/modules/mixly-modules/common/editor-welcome.js +++ b/common/modules/mixly-modules/common/editor-welcome.js @@ -17,7 +17,7 @@ class EditorWelcome extends EditorBase { static { HTMLTemplate.add( 'html/editor/editor-welcome.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-welcome.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-welcome.html'))) ); } diff --git a/common/modules/mixly-modules/common/editors-manager.js b/common/modules/mixly-modules/common/editors-manager.js index fdffa14a..b0dc0d21 100644 --- a/common/modules/mixly-modules/common/editors-manager.js +++ b/common/modules/mixly-modules/common/editors-manager.js @@ -42,12 +42,12 @@ class EditorsManager extends PagesManager { static { HTMLTemplate.add( 'html/editor/editor-manager.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-manager.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-manager.html'))) ); HTMLTemplate.add( 'html/editor/editor-tab.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/editor/editor-tab.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/editor/editor-tab.html'))) ); this.typesRegistry = new Registry(); diff --git a/common/modules/mixly-modules/common/file-tree.js b/common/modules/mixly-modules/common/file-tree.js index 46f4b565..9f57694f 100644 --- a/common/modules/mixly-modules/common/file-tree.js +++ b/common/modules/mixly-modules/common/file-tree.js @@ -34,12 +34,12 @@ const { USER } = Config; class FileTree extends Component { static { - this.FILE_ICON_MAP = goog.getJSON(path.join(Env.templatePath, 'json/file-icons.json')); - this.FOLDER_ICON_MAP = goog.getJSON(path.join(Env.templatePath, 'json/folder-icons.json')); + this.FILE_ICON_MAP = goog.readJsonSync(path.join(Env.templatePath, 'json/file-icons.json')); + this.FOLDER_ICON_MAP = goog.readJsonSync(path.join(Env.templatePath, 'json/folder-icons.json')); HTMLTemplate.add( 'html/file-tree.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/file-tree.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/file-tree.html'))) ); } diff --git a/common/modules/mixly-modules/common/footerbar.js b/common/modules/mixly-modules/common/footerbar.js index 2b4e4d8d..68e29f22 100644 --- a/common/modules/mixly-modules/common/footerbar.js +++ b/common/modules/mixly-modules/common/footerbar.js @@ -39,7 +39,7 @@ class FooterBar extends Component { static { HTMLTemplate.add( 'html/footerbar.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/footerbar.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/footerbar.html'))) ); } diff --git a/common/modules/mixly-modules/common/footerlayer-board-config.js b/common/modules/mixly-modules/common/footerlayer-board-config.js index ccea6e7f..a6ec2d94 100644 --- a/common/modules/mixly-modules/common/footerlayer-board-config.js +++ b/common/modules/mixly-modules/common/footerlayer-board-config.js @@ -25,7 +25,7 @@ class FooterLayerBoardConfig extends FooterLayer { static { // 弹层模板 this.menuHTMLTemplate = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/footerlayer/footerlayer-board-config.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/footerlayer/footerlayer-board-config.html')) ); } diff --git a/common/modules/mixly-modules/common/footerlayer-example.js b/common/modules/mixly-modules/common/footerlayer-example.js index c25e6eb9..aaf29b90 100644 --- a/common/modules/mixly-modules/common/footerlayer-example.js +++ b/common/modules/mixly-modules/common/footerlayer-example.js @@ -25,7 +25,7 @@ class FooterLayerExample extends FooterLayer { static { // 弹层模板 this.menuHTMLTemplate = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/footerlayer/footerlayer-example.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/footerlayer/footerlayer-example.html')) ); } diff --git a/common/modules/mixly-modules/common/footerlayer-message.js b/common/modules/mixly-modules/common/footerlayer-message.js index 89f4b7bd..316e6385 100644 --- a/common/modules/mixly-modules/common/footerlayer-message.js +++ b/common/modules/mixly-modules/common/footerlayer-message.js @@ -21,15 +21,15 @@ class FooterLayerMessage extends FooterLayer { // 弹层模板 static { this.menuHTMLTemplate = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/footerlayer/footerlayer-message.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/footerlayer/footerlayer-message.html')) ); this.menuItemHTMLTemplate = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/footerlayer/footerlayer-message-item.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/footerlayer/footerlayer-message-item.html')) ); this.menuItemWithIconHTMLTemplate = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/footerlayer/footerlayer-message-item-with-icon.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/footerlayer/footerlayer-message-item-with-icon.html')) ); this.STYLES = ['primary', 'secondary', 'success', 'danger', 'warning']; diff --git a/common/modules/mixly-modules/common/footerlayer.js b/common/modules/mixly-modules/common/footerlayer.js index 81dfc983..e6ddf26b 100644 --- a/common/modules/mixly-modules/common/footerlayer.js +++ b/common/modules/mixly-modules/common/footerlayer.js @@ -12,7 +12,7 @@ const { Env, XML, Msg } = Mixly; class FooterLayer { static { // 弹层模板和一些默认配置项 - this.TEMPLATE = goog.get(path.join(Env.templatePath, 'html/footerlayer/footerlayer.html')); + this.TEMPLATE = goog.readFileSync(path.join(Env.templatePath, 'html/footerlayer/footerlayer.html')); this.DEFAULT_CONFIG_TIPPY = { allowHTML: true, trigger: 'manual', diff --git a/common/modules/mixly-modules/common/loader.js b/common/modules/mixly-modules/common/loader.js index 2d10697e..39e1d267 100644 --- a/common/modules/mixly-modules/common/loader.js +++ b/common/modules/mixly-modules/common/loader.js @@ -48,7 +48,7 @@ window.addEventListener('load', () => { } const app = new App($('body')[0]); Mixly.app = app; - const $xml = $(goog.get(Env.boardIndexPath)); + const $xml = $(goog.readFileSync(Env.boardIndexPath)); let scrpitPaths = []; let cssPaths = []; let $categories = null; diff --git a/common/modules/mixly-modules/common/nav.js b/common/modules/mixly-modules/common/nav.js index c68318dc..a5313075 100644 --- a/common/modules/mixly-modules/common/nav.js +++ b/common/modules/mixly-modules/common/nav.js @@ -28,7 +28,7 @@ class Nav extends Component { */ HTMLTemplate.add( 'html/nav/nav.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/nav/nav.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/nav/nav.html'))) ); /** @@ -37,7 +37,7 @@ class Nav extends Component { */ HTMLTemplate.add( 'html/nav/nav-btn.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/nav/nav-btn.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/nav/nav-btn.html'))) ); /** @@ -46,7 +46,7 @@ class Nav extends Component { */ HTMLTemplate.add( 'html/nav/nav-item-container.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/nav/nav-item-container.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/nav/nav-item-container.html'))) ); /** @@ -55,7 +55,7 @@ class Nav extends Component { */ HTMLTemplate.add( 'html/nav/nav-item.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/nav/nav-item.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/nav/nav-item.html'))) ); /** @@ -64,7 +64,7 @@ class Nav extends Component { */ HTMLTemplate.add( 'html/nav/board-selector-div.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/nav/board-selector-div.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/nav/board-selector-div.html'))) ); /** @@ -73,7 +73,7 @@ class Nav extends Component { */ HTMLTemplate.add( 'html/nav/port-selector-div.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/nav/port-selector-div.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/nav/port-selector-div.html'))) ); Nav.Scope = { diff --git a/common/modules/mixly-modules/common/sidebar-libs.js b/common/modules/mixly-modules/common/sidebar-libs.js index 2bf89190..35f3e799 100644 --- a/common/modules/mixly-modules/common/sidebar-libs.js +++ b/common/modules/mixly-modules/common/sidebar-libs.js @@ -23,7 +23,7 @@ class SideBarLibs extends PageBase { static { HTMLTemplate.add( 'html/sidebar/sidebar-libs.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/sidebar/sidebar-libs.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/sidebar/sidebar-libs.html'))) ); } diff --git a/common/modules/mixly-modules/common/sidebar-local-storage.js b/common/modules/mixly-modules/common/sidebar-local-storage.js index d275f66b..c5abf0c9 100644 --- a/common/modules/mixly-modules/common/sidebar-local-storage.js +++ b/common/modules/mixly-modules/common/sidebar-local-storage.js @@ -38,7 +38,7 @@ class SideBarLocalStorage extends PageBase { static { HTMLTemplate.add( 'html/sidebar/sidebar-local-storage-open-folder.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/sidebar/sidebar-local-storage-open-folder.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/sidebar/sidebar-local-storage-open-folder.html'))) ); } diff --git a/common/modules/mixly-modules/common/sidebars-manager.js b/common/modules/mixly-modules/common/sidebars-manager.js index 828d31f2..3253cdf9 100644 --- a/common/modules/mixly-modules/common/sidebars-manager.js +++ b/common/modules/mixly-modules/common/sidebars-manager.js @@ -31,22 +31,22 @@ class SideBarsManager extends PagesManager { static { HTMLTemplate.add( 'html/sidebar/left-sidebars-manager.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/sidebar/left-sidebars-manager.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/sidebar/left-sidebars-manager.html'))) ); HTMLTemplate.add( 'html/sidebar/left-sidebars-tab.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/sidebar/left-sidebars-tab.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/sidebar/left-sidebars-tab.html'))) ); HTMLTemplate.add( 'html/sidebar/right-sidebars-manager.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/sidebar/right-sidebars-manager.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/sidebar/right-sidebars-manager.html'))) ); HTMLTemplate.add( 'html/sidebar/right-sidebars-tab.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/sidebar/right-sidebars-tab.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/sidebar/right-sidebars-tab.html'))) ); this.typesRegistry = new Registry(); diff --git a/common/modules/mixly-modules/common/statusbar-ampy.js b/common/modules/mixly-modules/common/statusbar-ampy.js index 8215c5cd..ba307f5d 100644 --- a/common/modules/mixly-modules/common/statusbar-ampy.js +++ b/common/modules/mixly-modules/common/statusbar-ampy.js @@ -32,17 +32,17 @@ class StatusBarAmpy extends PageBase { static { HTMLTemplate.add( 'html/statusbar/statusbar-ampy.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-ampy.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-ampy.html'))) ); HTMLTemplate.add( 'html/statusbar/statusbar-ampy-open-fs.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-ampy-open-fs.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-ampy-open-fs.html'))) ); HTMLTemplate.add( 'html/statusbar/statusbar-ampy-editor-empty.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-ampy-editor-empty.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-ampy-editor-empty.html'))) ); } diff --git a/common/modules/mixly-modules/common/statusbar-fs.js b/common/modules/mixly-modules/common/statusbar-fs.js index 549678e0..558ddeae 100644 --- a/common/modules/mixly-modules/common/statusbar-fs.js +++ b/common/modules/mixly-modules/common/statusbar-fs.js @@ -41,7 +41,7 @@ class Panel extends Component { static { HTMLTemplate.add( 'html/statusbar/statusbar-fs-panel.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-fs-panel.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-fs-panel.html'))) ); } @@ -195,7 +195,7 @@ class StatusBarFS extends PageBase { static { HTMLTemplate.add( 'html/statusbar/statusbar-fs.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-fs.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-fs.html'))) ); } diff --git a/common/modules/mixly-modules/common/statusbar-libs-code.js b/common/modules/mixly-modules/common/statusbar-libs-code.js index dc20369b..71ba1fc5 100644 --- a/common/modules/mixly-modules/common/statusbar-libs-code.js +++ b/common/modules/mixly-modules/common/statusbar-libs-code.js @@ -17,7 +17,7 @@ class StatusBarLibsCode extends PageBase { static { HTMLTemplate.add( 'html/statusbar/statusbar-libs-mix.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-libs-mix.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-libs-mix.html'))) ); } diff --git a/common/modules/mixly-modules/common/statusbar-libs-mix.js b/common/modules/mixly-modules/common/statusbar-libs-mix.js index 2ab41436..3fb6f726 100644 --- a/common/modules/mixly-modules/common/statusbar-libs-mix.js +++ b/common/modules/mixly-modules/common/statusbar-libs-mix.js @@ -18,7 +18,7 @@ class StatusBarLibsMix extends PageBase { static { HTMLTemplate.add( 'html/statusbar/statusbar-libs-mix.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-libs-mix.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-libs-mix.html'))) ); } diff --git a/common/modules/mixly-modules/common/statusbar-serial-chart.js b/common/modules/mixly-modules/common/statusbar-serial-chart.js index cf324e65..f2751370 100644 --- a/common/modules/mixly-modules/common/statusbar-serial-chart.js +++ b/common/modules/mixly-modules/common/statusbar-serial-chart.js @@ -28,7 +28,7 @@ class StatusBarSerialChart extends PageBase { static { HTMLTemplate.add( 'html/statusbar/statusbar-serial-chart.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-serial-chart.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-serial-chart.html'))) ); } diff --git a/common/modules/mixly-modules/common/statusbar-serial-output.js b/common/modules/mixly-modules/common/statusbar-serial-output.js index c14a4d05..ab95ea4e 100644 --- a/common/modules/mixly-modules/common/statusbar-serial-output.js +++ b/common/modules/mixly-modules/common/statusbar-serial-output.js @@ -21,7 +21,7 @@ class StatusBarSerialOutput extends PageBase { static { HTMLTemplate.add( 'html/statusbar/statusbar-serial-output.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-serial-output.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-serial-output.html'))) ); } diff --git a/common/modules/mixly-modules/common/statusbar-serial.js b/common/modules/mixly-modules/common/statusbar-serial.js index 6e43a53d..93dbfd0f 100644 --- a/common/modules/mixly-modules/common/statusbar-serial.js +++ b/common/modules/mixly-modules/common/statusbar-serial.js @@ -58,7 +58,7 @@ class StatusBarSerial extends PageBase { static { HTMLTemplate.add( 'html/statusbar/statusbar-serial.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbar-serial.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbar-serial.html'))) ); SideBarsManager.typesRegistry.register(['serial_output'], StatusBarSerialOutput); SideBarsManager.typesRegistry.register(['serial_chart'], StatusBarSerialChart); diff --git a/common/modules/mixly-modules/common/statusbars-manager.js b/common/modules/mixly-modules/common/statusbars-manager.js index 3e9fd8c4..31c58cd7 100644 --- a/common/modules/mixly-modules/common/statusbars-manager.js +++ b/common/modules/mixly-modules/common/statusbars-manager.js @@ -53,11 +53,11 @@ class StatusBarsManager extends PagesManager { static { HTMLTemplate.add( 'html/statusbar/statusbars-manager.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbars-manager.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbars-manager.html'))) ); HTMLTemplate.add( 'html/statusbar/statusbars-tab.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/statusbar/statusbars-tab.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/statusbar/statusbars-tab.html'))) ); this.typesRegistry = new Registry(); this.managersRegistry = new Registry(); diff --git a/common/modules/mixly-modules/common/toolbox-searcher.js b/common/modules/mixly-modules/common/toolbox-searcher.js index 5b4d860e..3d521794 100644 --- a/common/modules/mixly-modules/common/toolbox-searcher.js +++ b/common/modules/mixly-modules/common/toolbox-searcher.js @@ -20,7 +20,7 @@ const { class ToolboxSearcher { static { this.searchHtmlTemplate = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/search-div.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/search-div.html')) ); } diff --git a/common/modules/mixly-modules/common/workspace.js b/common/modules/mixly-modules/common/workspace.js index afa80e41..02cad131 100644 --- a/common/modules/mixly-modules/common/workspace.js +++ b/common/modules/mixly-modules/common/workspace.js @@ -35,7 +35,7 @@ class Workspace extends Component { static { HTMLTemplate.add( 'html/workspace.html', - new HTMLTemplate(goog.get(path.join(Env.templatePath, 'html/workspace.html'))) + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/workspace.html'))) ); this.workspaces = []; diff --git a/common/modules/mixly-modules/common/xml.js b/common/modules/mixly-modules/common/xml.js index d0842551..c43063ed 100644 --- a/common/modules/mixly-modules/common/xml.js +++ b/common/modules/mixly-modules/common/xml.js @@ -123,7 +123,7 @@ XML.convert = function (str, trimEscaped) { for (let i of XML.TEMPLATE_CONFIG) { const { type, config, appendToBody } = i; if (XML.TEMPLATE_ENV[type]) { - const xmlStr = goog.get(path.join(Env.templatePath, i.path)); + const xmlStr = goog.readFileSync(path.join(Env.templatePath, i.path)); if (xmlStr) { XML.TEMPLATE_STR[type] = xmlStr; XML.TEMPLATE_STR_RENDER[type] = XML.render(xmlStr, config); @@ -139,7 +139,7 @@ if (layui._typeof(BOARD.board) === 'object') { const boardConfig = BOARD.board[i]; if (layui._typeof(boardConfig) === 'object' && layui._typeof(boardConfig.xmlPath) === 'string') { - const categoriesStr = goog.get(path.join(Env.boardDirPath, boardConfig.xmlPath)); + const categoriesStr = goog.readFileSync(path.join(Env.boardDirPath, boardConfig.xmlPath)); if (categoriesStr) XML.CATEGORIES_STR[i] = categoriesStr; } diff --git a/common/modules/mixly-modules/electron/arduino-shell.js b/common/modules/mixly-modules/electron/arduino-shell.js index 1d8f9e08..2f204f53 100644 --- a/common/modules/mixly-modules/electron/arduino-shell.js +++ b/common/modules/mixly-modules/electron/arduino-shell.js @@ -45,7 +45,7 @@ const { Shell } = Electron; -ArduShell.DEFAULT_CONFIG = goog.getJSON(path.join(Env.templatePath, 'json/arduino-cli-config.json')); +ArduShell.DEFAULT_CONFIG = goog.readJsonSync(path.join(Env.templatePath, 'json/arduino-cli-config.json')); ArduShell.binFilePath = ''; diff --git a/common/modules/mixly-modules/electron/burn-upload.js b/common/modules/mixly-modules/electron/burn-upload.js index 4dc04a76..259d171d 100644 --- a/common/modules/mixly-modules/electron/burn-upload.js +++ b/common/modules/mixly-modules/electron/burn-upload.js @@ -49,7 +49,7 @@ BU.burning = false; BU.shell = null; BU.FILMWARE_LAYER = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/filmware-layer.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/filmware-layer.html')) ).render({ cancel: Msg.Lang['nav.btn.cancel'], burn: Msg.Lang['nav.btn.burn'] diff --git a/common/modules/mixly-modules/electron/wiki-generator.js b/common/modules/mixly-modules/electron/wiki-generator.js index a25db11c..93a50ef8 100644 --- a/common/modules/mixly-modules/electron/wiki-generator.js +++ b/common/modules/mixly-modules/electron/wiki-generator.js @@ -18,8 +18,8 @@ const fs = Mixly.require('fs'); class WikiGenerator { static { - this.WIKI_PAGE_FILE = goog.get(path.join(Env.templatePath, 'markdown/wiki-page-file.md')); - this.WIKI_PAGE_DIR = goog.get(path.join(Env.templatePath, 'markdown/wiki-page-dir.md')); + this.WIKI_PAGE_FILE = goog.readFileSync(path.join(Env.templatePath, 'markdown/wiki-page-file.md')); + this.WIKI_PAGE_DIR = goog.readFileSync(path.join(Env.templatePath, 'markdown/wiki-page-dir.md')); } #$xml_ = null; diff --git a/common/modules/mixly-modules/web/ampy.js b/common/modules/mixly-modules/web/ampy.js index 3e2692cc..26f37ca1 100644 --- a/common/modules/mixly-modules/web/ampy.js +++ b/common/modules/mixly-modules/web/ampy.js @@ -18,16 +18,16 @@ const { class AmpyExt extends Ampy { static { - this.LS = goog.get(path.join(Env.templatePath, 'python/ls.py')); - this.LS_RECURSIVE = goog.get(path.join(Env.templatePath, 'python/ls-recursive.py')); - this.LS_LONG_FORMAT = goog.get(path.join(Env.templatePath, 'python/ls-long-format.py')); - this.MKDIR = goog.get(path.join(Env.templatePath, 'python/mkdir.py')); - this.MKFILE = goog.get(path.join(Env.templatePath, 'python/mkfile.py')); - this.RENAME = goog.get(path.join(Env.templatePath, 'python/rename.py')); - this.RM = goog.get(path.join(Env.templatePath, 'python/rm.py')); - this.RMDIR = goog.get(path.join(Env.templatePath, 'python/rmdir.py')); - this.GET = goog.get(path.join(Env.templatePath, 'python/get.py')); - this.CWD = goog.get(path.join(Env.templatePath, 'python/cwd.py')); + this.LS = goog.readFileSync(path.join(Env.templatePath, 'python/ls.py')); + this.LS_RECURSIVE = goog.readFileSync(path.join(Env.templatePath, 'python/ls-recursive.py')); + this.LS_LONG_FORMAT = goog.readFileSync(path.join(Env.templatePath, 'python/ls-long-format.py')); + this.MKDIR = goog.readFileSync(path.join(Env.templatePath, 'python/mkdir.py')); + this.MKFILE = goog.readFileSync(path.join(Env.templatePath, 'python/mkfile.py')); + this.RENAME = goog.readFileSync(path.join(Env.templatePath, 'python/rename.py')); + this.RM = goog.readFileSync(path.join(Env.templatePath, 'python/rm.py')); + this.RMDIR = goog.readFileSync(path.join(Env.templatePath, 'python/rmdir.py')); + this.GET = goog.readFileSync(path.join(Env.templatePath, 'python/get.py')); + this.CWD = goog.readFileSync(path.join(Env.templatePath, 'python/cwd.py')); } #device_ = null; @@ -223,12 +223,17 @@ class AmpyExt extends Ampy { return this.#device_.decode(this.unhexlify(data)); } - async put(filename, code, timeout = 5000) { + async put(filename, data, timeout = 5000) { if (!this.isActive()) { throw new Error(Msg.Lang['ampy.portIsNotOpen']); } await this.exec(`file = open('${filename}', 'wb')`, timeout); - const buffer = this.#device_.encode(code); + let buffer = null; + if (typeof data === 'string') { + buffer = this.#device_.encode(data); + } else { + buffer = data; + } const len = Math.ceil(buffer.length / 64); for (let i = 0; i < len; i++) { const writeBuffer = buffer.slice(i * 64, Math.min((i + 1) * 64, buffer.length)); diff --git a/common/modules/mixly-modules/web/burn-upload.js b/common/modules/mixly-modules/web/burn-upload.js index c2abbbd2..a06b83ad 100644 --- a/common/modules/mixly-modules/web/burn-upload.js +++ b/common/modules/mixly-modules/web/burn-upload.js @@ -54,7 +54,7 @@ BU.uploading = false; BU.burning = false; BU.FILMWARE_LAYER = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/filmware-layer.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/filmware-layer.html')) ).render({ cancel: Msg.Lang['nav.btn.cancel'], burn: Msg.Lang['nav.btn.burn'] @@ -166,7 +166,7 @@ BU.burnByUSB = async () => { const { web } = SELECTED_BOARD; const { burn } = web; - const hexStr = goog.get(path.join(Env.boardDirPath, burn.filePath)); + const hexStr = goog.readFileSync(path.join(Env.boardDirPath, burn.filePath)); const hex2Blob = new Blob([ hexStr ], { type: 'text/plain' }); const buffer = await hex2Blob.arrayBuffer(); if (!buffer) { @@ -499,7 +499,7 @@ BU.getImportModules = (code) => { const libPath = SELECTED_BOARD.upload.libPath; for (let i = libPath.length - 1; i >= 0; i--) { const dirname = MString.tpl(libPath[i], { indexPath: Env.boardDirPath }); - const map = goog.getJSON(path.join(dirname, 'map.json')); + const map = goog.readJsonSync(path.join(dirname, 'map.json')); if (!(map && map instanceof Object)) { continue; } @@ -603,7 +603,7 @@ BU.uploadByUSB = async (portName) => { const importsMap = BU.getImportModules(code); for (let key in importsMap) { const filename = importsMap[key]['__name__']; - const data = goog.get(importsMap[key]['__path__']); + const data = goog.readFileSync(importsMap[key]['__path__']); FSWrapper.writeFile(filename, data); } const layerNum = layer.open({ @@ -690,7 +690,7 @@ BU.uploadWithAmpy = (portName) => { let libraries = {}; for (let key in importsMap) { const filename = importsMap[key]['__name__']; - const data = goog.get(importsMap[key]['__path__']); + const data = goog.readFileSync(importsMap[key]['__path__']); libraries[filename] = { data, size: importsMap[key]['__size__'] diff --git a/common/modules/mixly-modules/web/footerlayer-example.js b/common/modules/mixly-modules/web/footerlayer-example.js index df73b161..a869bbe9 100644 --- a/common/modules/mixly-modules/web/footerlayer-example.js +++ b/common/modules/mixly-modules/web/footerlayer-example.js @@ -77,7 +77,7 @@ class FooterLayerExampleExt extends FooterLayerExample { } dataToWorkspace(inPath) { - const data = goog.get(path.join(Env.boardDirPath, 'examples', inPath)); + const data = goog.readFileSync(path.join(Env.boardDirPath, 'examples', inPath)); this.updateCode(path.extname(inPath), data); } } diff --git a/common/modules/mixly-modules/web/serial.js b/common/modules/mixly-modules/web/serial.js index 4e3f0ac6..62017376 100644 --- a/common/modules/mixly-modules/web/serial.js +++ b/common/modules/mixly-modules/web/serial.js @@ -43,7 +43,7 @@ class WebSerial extends Serial { this.devicesRegistry = new Registry(); this.type = Serial.type; this.DEVICES_SELECT_LAYER = new HTMLTemplate( - goog.get(path.join(Env.templatePath, 'html/devices-select-layer.html')) + goog.readFileSync(path.join(Env.templatePath, 'html/devices-select-layer.html')) ); this.getConfig = function () { diff --git a/common/modules/web-modules/microbit/fs-wrapper.js b/common/modules/web-modules/microbit/fs-wrapper.js index 6c890322..b5fce108 100644 --- a/common/modules/web-modules/microbit/fs-wrapper.js +++ b/common/modules/web-modules/microbit/fs-wrapper.js @@ -49,8 +49,8 @@ class microbitFsWrapper { * initial main.py */ setupFilesystem(folderPath) { - const uPyV1 = goog.get(path.join(folderPath, 'microbit-micropython-v1.hex')); - const uPyV2 = goog.get(path.join(folderPath, 'microbit-micropython-v2.hex')); + const uPyV1 = goog.readFileSync(path.join(folderPath, 'microbit-micropython-v1.hex')); + const uPyV2 = goog.readFileSync(path.join(folderPath, 'microbit-micropython-v2.hex')); if (!uPyV1 || !uPyV2) { console.error('There was an issue loading the MicroPython Hex files.'); } diff --git a/common/modules/web-modules/monaco-i18n-loader.js b/common/modules/web-modules/monaco-i18n-loader.js index f6eeebe8..6cdf1e36 100644 --- a/common/modules/web-modules/monaco-i18n-loader.js +++ b/common/modules/web-modules/monaco-i18n-loader.js @@ -8,7 +8,7 @@ const { Msg, Env } = Mixly; if (['zh-hans', 'zh-hant'].includes(Msg.nowLang)) { const i18nFilePath = path.join(Env.templatePath, `json/monaco.i18n.${Msg.nowLang}.json`); - window.monacoI18N = goog.getJSON(i18nFilePath); + window.monacoI18N = goog.readJsonSync(i18nFilePath); } else { window.monacoI18N = {}; } diff --git a/mixly-sw/mixly-modules/common/config.js b/mixly-sw/mixly-modules/common/config.js index 0e572784..c09c0857 100644 --- a/mixly-sw/mixly-modules/common/config.js +++ b/mixly-sw/mixly-modules/common/config.js @@ -24,9 +24,9 @@ Config.USER = { * @return {void} **/ Config.init = () => { - Config.SOFTWARE = goog.getJSON('./sw-config.json', {}); + Config.SOFTWARE = goog.readJsonSync('./sw-config.json', {}); console.log('Config.SOFTWARE:', Config.SOFTWARE); - Config.BOARDS_INFO = goog.getJSON('./boards.json', {}); + Config.BOARDS_INFO = goog.readJsonSync('./boards.json', {}); console.log('Config.BOARDS_INFO:', Config.BOARDS_INFO); const boardPageConfig = Url.getConfig(); Config.BOARD_PAGE = boardPageConfig ?? {}; diff --git a/mixly-sw/mixly-modules/common/xml.js b/mixly-sw/mixly-modules/common/xml.js index c53bd259..0afe7f1c 100644 --- a/mixly-sw/mixly-modules/common/xml.js +++ b/mixly-sw/mixly-modules/common/xml.js @@ -211,7 +211,7 @@ for (let i of XML.TEMPLATE_CONFIG) { generateDom } = i; if (XML.TEMPLATE_ENV[type]) { - const xmlStr = goog.get(XML.TEMPLATE_DIR_PATH + path); + const xmlStr = goog.readFileSync(XML.TEMPLATE_DIR_PATH + path); if (xmlStr) { XML.TEMPLATE_STR[type] = xmlStr; if (generateDom) {