{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-theresa/src/client/utils.js"],"names":["executeAllTestRunners","document","querySelectorAll","forEach","runner","onRunButton","promisedEvent","eventTarget","type","Error","Promise","resolve","addEventListener","fileName","replace","fileEnding","replaceFileEndingWith","newEnding","PausableLoop","constructor","func","cancelID","running","ensureRunning","loopBody","requestAnimationFrame","pause","cancelAnimationFrame","hintForLabel","label","asDragImageFor","evt","offsetX","offsetY","clone","cloneNode","body","appendChild","style","top","Math","max","clientY","left","clientX","position","pointerEvents","setTimeout","remove","dataTransfer","setDragImage","listAsDragImage","labels","hints","map","textualRepresentation","hintLength","length","maxLength","push","dragInfo","TEMP_OBJECT_STORAGE","Map","getTempKeyFor","obj","tempKey","set","getObjectFor","get","removeTempKey","delete","uuid","c","r","crypto","getRandomValues","Uint8Array","v","toString","copyTextToClipboard","text","textArea","createElement","Object","assign","width","height","padding","border","outline","boxShadow","background","value","select","supported","queryCommandSupported","err","lively","warn","enabled","queryCommandEnabled","execCommand","removeChild","functionMetaInfo","functionToCheck","undefined","isFunction","isAsync","isGenerator","description","call","match","isFunc","isAsyncFunc","cancelEvent","stopPropagation","preventDefault","thing","prototype","name","getDeepProperty","pathString","path","split","next","result","shift","nextResult","waitForDeepProperty","timeout","step","parseQuery","queryString","query","pairs","substr","i","pair","decodeURIComponent","wait","ms","CallableObject","using","contextManagerIterable","callback","error","contextManagers","Array","from","cm","__enter__","e","reverse","__exit__","onStyleChange","target","styleObserver","MutationObserver","mutations","mutation","attributeName","observe","attributes","shake","animate","transform","duration","iterations","updateEditors","url","excludedEditors","editors","findAllElements","ea","localName","editorsToUpdate","filter","getURLString","textChanged","includes","loadFile","babelToCM","babelPosition","line","ch","column","cmToBabel","cmPosition","Location","isLocation","l","_cmLine","_cmCharacter","isEqual","other","isBefore","isStrictBefore","asBabel","asCM","innerToString","loc","Range","isRange","start","end","_start","_end","contains","ll","isBehind","selectInCM","setSelection","range","isArray","first","second"],"mappings":";;;;;;;;;;;;;;;;;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b,iBAAOjI,CAAP;AACD;AACD;AACA,YAAI0E,MAAMkE,OAAN,CAAc5I,CAAd,CAAJ,EAAsB;AACpB,iBAAO,oCAAIgI,KAAJ,CAAUhI,EAAE6I,KAAZ,EAAmB7I,EAAE8I,MAArB,CAAP;AACD;AACD;AACA,YAAI9I,EAAEkI,KAAF,IAAWlI,EAAEmI,GAAjB,EAAsB;AACpB,iBAAO,oCAAIH,KAAJ,CAAUhI,EAAEkI,KAAZ,EAAmBlI,EAAEmI,GAArB,CAAP;AACD;AACD,cAAM,IAAInM,KAAJ,CAAW,eAAcgE,CAAE,kBAA3B,CAAN;AACD","file":"utils.js","sourcesContent":["/**\n * All lodash utility functions with this reference bound as first parameter\n * @example <caption>Example using lodash bound.</caption>\n * import {through, last}from \"utils\"\n * \n * document.body.querySelectorAll('lively-window')::last(); // return last selected window\n */\nexport * from './lodash-bound.js';\n\nexport function executeAllTestRunners() {\n  document.querySelectorAll('lively-testrunner').forEach(runner => runner.onRunButton());\n}\n\nexport function promisedEvent(eventTarget, type) {\n  if (!type || !eventTarget) throw new Error(\"arguments missing\");\n  return new Promise(resolve => eventTarget.addEventListener(type, resolve))\n}\n\n// #TODO: make this more robust to urlStrings that do not contain a filename, e.g.\n// \"https://goole.com\"::fileName() should not \"goole.com\"\nexport function fileName() {\n  return this.replace(/.*\\//,\"\");\n}\n\n// Example usage: \"path/to/a.json\"::fileEnding() returns \"json\"\n// #TODO: make this more robust to strings that do not contain a file ending\nexport function fileEnding() {\n  return this.replace(/.*\\./,\"\");\n}\n\n// Example usage: \"path/to/a.json\"::replaceFileEndingWith(\"xml\") returns \"path/to/a.xml\"\n// #TODO: make this more robust to strings that do not contain a file ending\nexport function replaceFileEndingWith(newEnding) {\n  return this.replace(/[^\\.]+$/, newEnding);\n}\n\nexport class PausableLoop {\n  constructor(func) {\n    this.func = func;\n    this.cancelID;\n    this.running = false;\n  }\n  \n  ensureRunning() {\n    if(!this.running) {\n      this.running = true;\n\n      const loopBody = () => {\n        this.func();\n        if(this.running) {\n          this.cancelID = requestAnimationFrame(loopBody);\n        }\n      }\n\n      this.cancelID = requestAnimationFrame(loopBody);\n    }\n  }\n\n  pause() {\n    cancelAnimationFrame(this.cancelID);\n    this.running = false;\n  }\n}\n\nexport function hintForLabel(label) {\n  return <div style=\"\n    margin: 0.5px 0px;\n    font-size: x-small;\n    background-color: lightgray;\n    border: 1px solid gray;\n    border-radius: 2px;\n    max-width: fit-content;\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n  \">\n    {label}\n  </div>\n}\n\n// #TODO: chrome does not support dataTransfer.addElement :(\n// e.g. dt.addElement(<h1>drop me</h1>);\n// Therefore, we have to perform this hack stolen from:\n// https://stackoverflow.com/questions/12766103/html5-drag-and-drop-events-and-setdragimage-browser-support\nexport function asDragImageFor(evt, offsetX=0, offsetY=0) {\n  const clone = this.cloneNode(true);\n  document.body.appendChild(clone);\n  clone.style[\"z-index\"] = \"10000000\";\n  clone.style.top = Math.max(0, evt.clientY - offsetY) + \"px\";\n  clone.style.left = Math.max(0, evt.clientX - offsetX) + \"px\";\n  clone.style.position = \"absolute\";\n  clone.style.pointerEvents = \"none\";\n\n  setTimeout(::clone.remove);\n  evt.dataTransfer.setDragImage(clone, offsetX, offsetY);\n}\n\nexport function listAsDragImage(labels, evt, offsetX, offsetY) {\n  const hints = labels\n    .map(textualRepresentation)\n    .map(hintForLabel);\n  const hintLength = hints.length;\n  const maxLength = 5;\n  if(hints.length > maxLength) {\n    hints.length = maxLength;\n    hints.push(hintForLabel(`+ ${hintLength - maxLength} more.`))\n  }\n  const dragInfo = <div style=\"width: 151px;\">\n    {...hints}\n  </div>;\n  dragInfo::asDragImageFor(evt, offsetX, offsetY);\n}\n\nconst TEMP_OBJECT_STORAGE = new Map();\nexport function getTempKeyFor(obj) {\n  const tempKey = uuid();\n  TEMP_OBJECT_STORAGE.set(tempKey, obj);\n  \n  // safety net: remove the key in 10 minutes\n  setTimeout(() => removeTempKey(tempKey), 10 * 60 * 1000);\n\n  return tempKey;\n}\nexport function getObjectFor(tempKey) {\n  return TEMP_OBJECT_STORAGE.get(tempKey);\n}\nexport function removeTempKey(tempKey) {\n  TEMP_OBJECT_STORAGE.delete(tempKey);\n}\n\nexport function uuid() {\n\treturn 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {\n\t\tvar r = crypto.getRandomValues(new Uint8Array(1))[0]%16|0, v = c == 'x' ? r : (r&0x3|0x8);\n\t\treturn v.toString(16);\n\t});\t\n}\n\n/**\n * Taken from and modified using:\n * https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript\n */\nexport function copyTextToClipboard(text) {\n  const textArea = document.createElement(\"textarea\");\n\n  //\n  // *** This styling is an extra step which is likely not required. ***\n  //\n  // Why is it here? To ensure:\n  // 1. the element is able to have focus and selection.\n  // 2. if element was to flash render it has minimal visual impact.\n  // 3. less flakyness with selection and copying which **might** occur if\n  //    the textarea element is not visible.\n  //\n  // The likelihood is the element won't even render, not even a flash,\n  // so some of these are just precautions. However in IE the element\n  // is visible whilst the popup box asking the user for permission for\n  // the web page to copy to the clipboard.\n  //\n\n  Object.assign(textArea.style, {\n    // Place in top-left corner of screen regardless of scroll position.\n    position: 'fixed',\n    top: 0,\n    left: 0,\n\n    // Ensure it has a small width and height. Setting to 1px / 1em\n    // doesn't work as this gives a negative w/h on some browsers.\n    width: '2em',\n    height: '2em',\n\n    // We don't need padding, reducing the size if it does flash render.\n    padding: 0,\n\n    // Clean up any borders.\n    border: 'none',\n    outline: 'none',\n    boxShadow: 'none',\n\n    // Avoid flash of white box if rendered for any reason.\n    background: 'transparent',\n  });\n\n  textArea.value = text;\n\n  document.body.appendChild(textArea);\n\n  textArea.select();\n\n  let supported;\n  try {\n    supported = document.queryCommandSupported('copy');\n  } catch (err) {\n    lively.warn('Copy to clipboard not supported.', err);\n    supported = false;\n  }\n  if(supported) {\n    let enabled;\n    try {\n      enabled = document.queryCommandEnabled('copy');\n    } catch (err) {\n      lively.warn('Copy to clipboard not enabled.', err);\n      enabled = false;\n    }\n    if(enabled) {\n      try {\n        if(!document.execCommand('copy')) {\n          lively.warn('Copying not successful.');\n        }\n      } catch (err) {\n        lively.warn('Unable to execute copy.');\n      }\n    }\n  }\n\n  document.body.removeChild(textArea);\n}\n\nexport function functionMetaInfo(functionToCheck) {\n  if(functionToCheck === undefined) { return {\n    isFunction: false,\n    isAsync: false,\n    isGenerator: false\n  }; }\n  \n  const description = ({}).toString.call(functionToCheck)\n  return {\n    isFunction: !!description.match(/\\[object (Async)?(Generator)?Function\\]/),\n    isAsync: !!description.match(/\\[object Async(Generator)?Function\\]/),\n    isGenerator: !!description.match(/\\[object (Async)?GeneratorFunction\\]/)\n  };\n}\n// taken from https://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascript-variable-is-function-type\nexport function isFunction(functionToCheck) {\n  if(functionToCheck === undefined) { return false; }\n  let isFunc = ({}).toString.call(functionToCheck) === '[object Function]';\n  let isAsyncFunc = ({}).toString.call(functionToCheck) === '[object AsyncFunction]';\n  return isFunc || isAsyncFunc;\n}\n\nexport function cancelEvent(evt) {\n  evt.stopPropagation();\n  evt.preventDefault();\n}\n\nexport function textualRepresentation(thing) {\n  // primitive falsy value?\n  if(!thing) { return '' + thing}\n  \n  // toString method different from Object?\n  if(thing.toString && thing.toString !== Object.prototype.toString) {\n    return thing.toString();\n  }\n  \n  // instance of a named class?\n  if(thing.constructor && thing.constructor.name) {\n    return 'a ' + thing.constructor.name;\n  }\n  \n  return 'unprintable object';\n}\n\n\nexport function getDeepProperty(obj, pathString) {\n  var path = pathString.split(\".\")\n  var next\n  var result = obj\n  while(next = path.shift()) {\n    var nextResult = result[next] \n    if (!nextResult) return // could not resolve path\n    result = nextResult\n  }\n  return result\n}\n\n/*\n * waits for the deep construction of a data structure // object\n * \n */\nexport async function waitForDeepProperty(obj, pathString, timeout=60000 /* one minuete */, step=10) {\n  var path = pathString.split(\".\")\n  var next\n  var result = obj\n  var nextResult\n  while(next = path.shift()) {\n    nextResult  = result[next]\n    while(!nextResult) {\n      await wait(step) // busy waiting...\n      nextResult  = result[next]\n    }\n    // if (!nextResult) return // could not resolve path\n    result = nextResult\n    // console.log(\"next result \" + next + \" = \" + result )\n    \n  }\n  return result\n}\n\n\n// https://stackoverflow.com/questions/2090551/parse-query-string-in-javascript\nexport function parseQuery(queryString) {\n    var query = {};\n    var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');\n    for (var i = 0; i < pairs.length; i++) {\n        var pair = pairs[i].split('=');\n        query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');\n    }\n    return query;\n}\n\nexport function wait(ms) {\n  return new Promise(resolve => setTimeout(resolve, ms));\n}\n\nexport class CallableObject {\n  // #TODO: implement this\n}\n\n/**\n * Executes the given function considering the given context objects.\n * @param {Array<ContextManager>} contexts\n * @param {function} callback\n * @return {Object} result - The callback's evaluation result.\n *\n * @class ContextManager\n * @classdesc Used to specify the setup and teardown of the function call.\n * @method {__enter__} enter callback - called before the function call. Put setup code here.\n * @method {__exit__} exit callback - called after the funciton call. Put teardown code here.\n\n * @example <caption>Poor mans COP.</caption>\n * import { using }from \"utils\";\n * \n * const silentFetch = {\n *   __enter__() {\n *     this.originalFetch = window.fetch;\n *     window.fetch = () => {};\n *   }\n *   __exit__() {\n *     window.fetch = this.originalFetch; // restore the original fetch \n *   }\n * }\n *\n * using([silentFetch], () => {\n *   lively.notify(fetch('https://lively-kernel.org/lively4/')) // logs nothing\n * });\n */\nexport function using(contextManagerIterable, callback) {\n  let result;\n  let error;\n  const contextManagers = Array.from(contextManagerIterable);\n  \n  contextManagers.forEach(cm => cm.__enter__());\n  try {\n    result = callback();\n  } catch(e) {\n    error = e;\n  } finally {\n    contextManagers.reverse().forEach(cm => cm.__exit__(error));\n  }\n  if(error !== undefined) {\n    throw error;\n  }\n  return result;\n}\n\n/**\n * Get notified, whenever the style attribute of given target changes\n */\nexport function onStyleChange(target, callback) {\n  const styleObserver = new MutationObserver(mutations => {\n    mutations.forEach(mutation => {  \n      if(mutation.type == \"attributes\" && mutation.attributeName == \"style\") {\n          callback();\n      }\n    });\n  });\n  styleObserver.observe(target, { attributes: true });\n\n  return styleObserver;\n}\n\n/**\n * shakes given element using css transformations\n */\nexport function shake(target) {\n  target.animate([\n    { transform: 'translate(1px, 1px) rotate(0deg)' },\n    { transform: 'translate(-1px, -2px) rotate(-1deg)' },\n    { transform: 'translate(-3px, 0px) rotate(1deg)' },\n    { transform: 'translate(3px, 2px) rotate(0deg)' },\n    { transform: 'translate(1px, -1px) rotate(1deg)' },\n    { transform: 'translate(-1px, 2px) rotate(-1deg)' },\n    { transform: 'translate(-3px, 1px) rotate(0deg)' },\n    { transform: 'translate(3px, 1px) rotate(-1deg)' },\n    { transform: 'translate(-1px, -1px) rotate(1deg)' },\n    { transform: 'translate(1px, 2px) rotate(0deg)' },\n    { transform: 'translate(1px, -2px) rotate(-1deg)' },\n  ], { \n    // timing options\n    duration: 100,\n    iterations: 1,\n    // easing: 'cubic-bezier(0.42, 0, 0.58, 1)'\n  });\n}\n\n\nexport function updateEditors(url, excludedEditors = []) {\n  \n  \n  \n  const editors = lively.findAllElements(ea => ea.localName == \"lively-editor\", true)\n     \n  // DEPRECATED\n  // Array.from(document.querySelectorAll(\"lively-index-search::shadow lively-editor, lively-container::shadow lively-editor, lively-editor\"));\n\n  const editorsToUpdate = editors.filter( ea => ea.getURLString() === url && !ea.textChanged && !excludedEditors.includes(ea));\n\n  editorsToUpdate.forEach( ea => {\n    // lively.showElement(ea);\n    ea.loadFile()\n  });\n}\n\n/*MD Source Code Locations and Ranges MD*/\nfunction babelToCM(babelPosition) {\n  return {\n    line: babelPosition.line - 1,\n    ch: babelPosition.column\n  };\n}\n\nfunction cmToBabel(cmPosition) {\n  return {\n    line: cmPosition.line + 1,\n    column: cmPosition.ch\n  };\n}\n\nclass Location {\n  get isLocation() { return true; }\n  \n  constructor(l) {\n    this._cmLine = l.line;\n    this._cmCharacter = l.ch;\n  }\n  \n  isEqual(l) {\n    const other = loc(l)\n    return this._cmLine === other._cmLine && this._cmCharacter === other._cmCharacter;\n  }\n  isBefore(l) {\n    const other = loc(l)\n    return this._cmLine < other._cmLine ||\n      (this._cmLine === other._cmLine && this._cmCharacter <= other._cmCharacter);\n  }\n  isStrictBefore(l) {\n    const other = loc(l)\n    return this._cmLine < other._cmLine ||\n      (this._cmLine === other._cmLine && this._cmCharacter < other._cmCharacter);\n  }\n  \n  asBabel() {\n    return cmToBabel(this.asCM());\n  }\n  asCM() {\n    return {\n      line: this._cmLine,\n      ch: this._cmCharacter\n    };\n  }\n  \n  innerToString() {\n    return `${this._cmLine}:${this._cmCharacter}`;\n  }\n  toString() {\n    return `loc(${this.innerToString()})`;\n  }\n}\n\nexport function loc(l) {\n  if (l.isLocation) {\n    return l\n  }\n  // cm style\n  if (l.ch !== undefined) {\n    return new Location(l)\n  }\n  // babel style\n  if (l.column !== undefined) {\n    return new Location(babelToCM(l))\n  }\n  throw new Error(`Location value ${l} not recognized.`);\n}\n\nclass Range {\n  get isRange() { return true; }\n\n  constructor(start, end) {\n    this._start = loc(start);\n    this._end = loc(end);\n  }\n  \n  asBabel() {\n    throw new Error('asBabel not yet implemented.');\n  }\n  asCM() {\n    // from, to\n    return [this._start.asCM(), this._end.asCM()]\n  }\n\n  contains(l) {\n    const ll = loc(l);\n    return this._start.isBefore(ll) && ll.isBefore(this._end);\n  }\n  isBehind(l) {\n    return loc(l).isBefore(this._start)\n  }\n  \n  selectInCM(cm) {\n    cm.setSelection(...this.asCM())\n  }\n  \n  toString() {\n    return `range(${this._start.innerToString()}, ${this._end.innerToString()})`\n  }\n}\n\nexport function range(r) {\n  if (r.isRange) {\n    return r;\n  }\n  // cm style\n  if (Array.isArray(r)) {\n    return new Range(r.first, r.second)\n  }\n  // babel style\n  if (r.start && r.end) {\n    return new Range(r.start, r.end)\n  }\n  throw new Error(`Range value ${r} not recognized.`);\n}\n\n"]}