Files
JiboSDK/lib/main.js
2026-03-22 03:21:45 +02:00

1 line
4.5 KiB
JavaScript

"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},o=function(){function e(e,o){for(var t in o){var i=o[t];i.configurable=!0,i.value&&(i.writable=!0)}Object.defineProperties(e,o)}return function(o,t,i){return t&&e(o.prototype,t),i&&e(o,i),o}}(),t=function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")},i=console.log;console.log=function(){},console.log=i;var r=e(require("lodash")),n=e(require("path")),JiboSim=e(require("./animation-preview/jibo-sim")),AnimationEditor=e(require("./animation-editor/animation-editor")),BehaviorEditor=e(require("./behavior-editor/behavior-editor")),a=e(require("./common/json-opener")),s=e(require("./package-generator/package-generator-modal")),l=e(require("./launcher/launcher")),$=e(require("jquery")),u=e(require("react")),Toolbar=e(require("./toolbar/toolbar")),c=e(require("./atom-react/atom-integration")),CheatSheetTab=e(require("./cheat-sheet/cheat-sheat-tab")),StyleguideEditor=e(require("./atom-react/styleguide/styleguide-editor")),d=require("atom").CompositeDisposable,p=e(require("./rules/rule-tester-panel")),f=e(require("./gating/login")),g=function(){function e(){t(this,e),this.config={AnimationEditorBackgroundColor:{type:"color","default":"#4C4C4C",description:"The background color in the Animation Editor"},AnimationEditorGridColor:{type:"color","default":"#E5E5E5",description:"The grid color in the Animation Editor"},"RunConfiguration.type":{type:"string","enum":["local","remote"],"default":"local",description:"Which mode to use when running/debugging your skill."},"RunConfiguration.host":{type:"string","default":"",description:"The host or ip of the robot you want to target."},"RunConfiguration.run-dir":{type:"string","default":"${project}",description:"The directory to run your skill from if it's not the root of your opened project."},DisableRunSkillShortcut:{type:"boolean","default":"false",description:"Disable the shortcut for running skills, if you prefer it binding to built in the [Symbol-Viewer](https://github.com/atom/symbols-view#symbols-view-package-) toggle."}}}return o(e,{toggleRulePane:{value:function(e,o){var t=this;if(this.rulePaneDisposable&&this.rulePaneDisposable.destroy(),e){var i=document.createElement("div");i.setAttribute("class","rule-panel"),u.render(u.createElement(p,{editor:o,onClose:function(){t.destroyModal()}}),i),this.rulePaneDisposable=atom.workspace.addRightPanel({item:i,priority:1})}}},activate:{value:function(){var e=this;this.disposable=new d;var o=!1,t=!1,i=function(){c.activate(),e.disposable.add(atom.workspace.addOpener(function(o){return e.openURI(o)})),e.disposable.add(atom.commands.add("atom-workspace",{"jibo-sdk:new-project":function(){s()},"jibo-sdk:open-as-json":function(){a.open()},"jibo-sdk:new-animation-file":function(){AnimationEditor.createNewFile()},"jibo-sdk:new-behavior-tree-file":function(){BehaviorEditor.createNewFile()},"jibo-sdk:play":function(){l.play()},"jibo-sdk:play-animation":function(){l.play()},"jibo-sdk:stop":function(){l.stop()},"jibo-sdk:cheat-sheet":function(){atom.workspace.open("atom://jibo-cheat-sheet")},"atom-react:styleguide":function(){atom.workspace.open("atom://atom-react-styleguide")},"jibo-sdk:run-skill":function(e){return atom.config.get("jibo-sdk.DisableRunSkillShortcut")?void e.abortKeyBinding():void l.togglePlayer()}}));var t=$("<div/>");t.addClass("toolbar"),u.render(u.createElement(Toolbar,null),t[0]),e.toolbarPanel=atom.workspace.addTopPanel({item:t});var i=function(o){if(o&&o.constructor&&"TextEditor"===o.constructor.name){var t=n.extname(o.getPath());if(".nli"===t||".rule"===t||".grm"===t)return e.editor=o,void e.toggleRulePane(!0,o)}e.toggleRulePane(!1)};atom.workspace.observeActivePaneItem(function(e){i(e)}),i(atom.workspace.getActiveTextEditor()),o=!0},r=function(){return f.isUserLoggedIn()?void i():(t=!0,void f.showDialog(function(e,o){return t=!1,e?void console.log(e):void(o&&i())}))};r(),this.disposable.add(atom.commands.add("atom-workspace",{"jibo-sdk:login":function(){return o?void alert("You are already logged in"):void(t||r())}}))}},deactivate:{value:function(){this.toolbarPanel&&this.toolbarPanel.destroy(),this.disposable.dispose(),c.deactivate()}},openURI:{value:function(e){if(a.useDefaultEditor()!==!1){if("atom://jibo-cheat-sheet"===e)return new CheatSheetTab(e,!0);if("atom://atom-react-styleguide"===e)return new StyleguideEditor(e,!0);var o={".anim":JiboSim,".keys":AnimationEditor,".bt":BehaviorEditor},t=n.extname(e).toLowerCase();return r.has(o,t)?new o[t](e):void 0}}}}),e}();module.exports=new g;