{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-livelyenergy/src/components/demo/lively-math.js"],"names":["Morph","Math","LivelyMath","initialize","workspace","shadowRoot","querySelector","boundEval","str","Promise","resolve","value","eval"],"mappings":";;;;;;AAEOA,W;;AACAC,U;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEQ,YAAMC,UAAN,SAAyBF,KAAzB,CAA+B;;AAE5CG,qBAAa;AACX,cAAIC,YAAY,KAAKC,UAAL,CAAgBC,aAAhB,CAA8B,YAA9B,CAAhB;AACAF,oBAAUG,SAAV,GAAsB,UAAUC,GAAV,EAAe;AACnC,mBAAOC,QAAQC,OAAR,CAAgB,EAACC,OAAOV,KAAKW,IAAL,CAAUJ,GAAV,CAAR,EAAhB,CAAP;AACD,WAFD;AAGJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACG;;AA3C2C;;yBAAzBN,U","file":"lively-math.js","sourcesContent":["\n\nimport Morph from 'src/components/widgets/lively-morph.js'\nimport Math from 'src/external/math.js'\n\nexport default class LivelyMath extends Morph {\n\n  initialize() {\n    var workspace = this.shadowRoot.querySelector('#workspace')\n    workspace.boundEval = function (str) {\n      return Promise.resolve({value: Math.eval(str)})\n    } \n// #TODO get autocompletion work again in CodeMirror math workspace\n// #TODO how can we make use of Math.js in other code? #DSL\n//     workspace.enableAutocompletion = function(filename) {\n//       return this.aceRequire(\"ace/ext/language_tools\").then( module => {\n//         if (!this.editor) return\n        \n//         this.editor.setOptions({\n//             enableBasicAutocompletion: true,\n//             enableSnippets: true,\n//             enableLiveAutocompletion: false\n//         });\n//         this.editor.completers[3] =  {\n//           getCompletions: function(editor, session, pos, prefix, callback) {\n//               // console.log(\"getCompletions: \" + pos + \" prefix \" + prefix)\n//               var curLine = session.getDocument().getLine(pos.row);\n//               var curTokens = curLine.slice(0, pos.column).split(/\\s+/);\n//               var curCmd = _.last(curTokens);\n//               // console.log(\"line : \" + curLine + \" curTokens: \" + curTokens + \" curCmd:\" + curCmd)\n//               if (!curCmd) return;\n//               try {\n//                 var wordList = [];\n//               wordList = lively.allProperties(lively.math);\n//               // console.log(\"complete: \" + curCmd +\"\\n\" + wordList)\n//                 callback(null, _.keys(wordList).map(function(ea) {\n//                   return {name: ea, value: ea, score: 300, meta: wordList[ea]};\n//                   }));\n//               } catch(err) {\n//                 console.log(\"Could not complete: \" + curCmd +\", because of:\" + err)\n//               }\n//             }\n//           }\n//       })\n//     }\n//     workspace.enableAutocompletion()\n     \n//     }\n  }\n    \n}"]}