feat(core): 将goog.get接口调整为goog.readJsonSync以指示其同步操作特性
This commit is contained in:
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -24,16 +24,16 @@ class EditorAce extends EditorBase {
|
||||
static {
|
||||
this.CTRL_BTNS = ['resetFontSize', 'increaseFontSize', 'decreaseFontSize'];
|
||||
this.CTRL_BTN_TEMPLATE = '<div m-id="{{d.mId}}" class="code-editor-btn setFontSize"></div>';
|
||||
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`))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = $('<div class="page-item"></div>');
|
||||
|
||||
@@ -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 }));
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = $('<div class="page-item"></div>');
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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'];
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 = '';
|
||||
|
||||
|
||||
@@ -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']
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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__']
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
|
||||
@@ -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 = {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user