{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-bp2019/src/client/pen-editor/components/abstract-ast-node.js"],"names":["Morph","keyInfo","d3","nodeEqual","ComponentLoader","prepareElementForPath","path","slotName","oldElement","element","isNew","setPath","setAttribute","getAppropriateElement","newElementTag","shouldReuseOldElement","create","matchesFunctionShorthand","isArrowFunctionExpression","get","isSimpleMemberExpression","isMemberExpression","matchesAccessFunctionShorthand","matchesCallFunctionShorthand","matchesSubmorphGetter","isClassMethod","getAppropriateElementTagName","SCOPE_MAP","WeakMap","NEXT_SCOPE_ID","AbstractAstNode","isAstNode","addChildType","astNodeType","initialize","initHover","addEventListener","evt","onClick","onKeydown","onFocus","onCopy","onCut","onPaste","onMouseOver","onMouseOut","stopPropagation","type","notify","warn","info","char","ctrl","shift","alt","keyCode","charCode","handledByNavigation","copyNodeToClipboard","extractExpressionIntoLocalVariable","preventDefault","localName","prompt","node","value","astNode","addNodeStylingInfo","depth","find","p","getOrCreate","setNode","babelASTNode","updateProjection","createSubElementForPath","astPath","remove","replaceChild","appendChild","createSubElementForPaths","paths","currentChildren","getAllSubmorphs","currentMatches","Map","forEach","matchingChild","child","set","matchingOnly","both","nonMatching","from","values","newElements","has","removeSubElementInSlot","subElement","editor","allParents","ele","livelyPreMigrate","livelyMigrate","other","Error","livelyInspect","contentNode","inspector","livelyPrepareSave","livelyExample","livelyUpdateStrategy","livelyUpdate","updateFromTemplate","applyTemplate"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;AAEOA,W;;AAEAC,a;;AACAC,Q;;AACEC,e,YAAAA,S;;AAEFC,qB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,q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BAAM,qEAAIC,KAAJ,EAAU,oCAAV,CAAN;AAAwD;AAC/EC,sBAAcC,WAAd,EAA2BC,SAA3B,EAAsC,CAAE;AACxCC,4BAAoB,CAAE;AACtB,cAAMC,aAAN,GAAsB,CAAE;;AAExB,YAAIC,oBAAJ,GAA2B;AAAE,iBAAO,SAAP;AAAmB;AAChDC,uBAAe;AAAA;;AACb,eAAKC,kBAAL;AACA;AACD;AACDA,6BAAqB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kEAA4B,EAA5B;AARmB;AASnB,8HAAgBC,aAAhB,CAA8B,IAA9B,aAAoC,IAApC;AACD;AA/OgD;;yBAA9BnF,e","file":"abstract-ast-node.js","sourcesContent":["\"enable aexpr\";\n\nimport Morph from 'src/components/widgets/lively-morph.js';\n\nimport keyInfo from 'src/client/keyinfo.js';\nimport d3 from 'src/external/d3.v5.js';\nimport { nodeEqual } from './utils.js';\n\nimport ComponentLoader from \"src/client/morphic/component-loader.js\";\n\nasync function prepareElementForPath(path, slotName, oldElement) {\n  const [element, isNew] = await getAppropriateElement(path, oldElement);\n\n  await element.setPath(path);\n\n  element.slot= slotName;\n  element.setAttribute('slot', slotName);\n\n  return [element, isNew];\n}\n\nexport async function getAppropriateElement(path, oldElement) {\n  const newElementTag = getAppropriateElementTagName(path);\n  const shouldReuseOldElement = oldElement && oldElement.constructor.name === newElementTag;\n  const element = shouldReuseOldElement ? oldElement : await lively.create(newElementTag);\n\n  return [element, !shouldReuseOldElement];\n}\n\nfunction matchesFunctionShorthand(path) {\n  return path.isArrowFunctionExpression() &&\n    path.node.expression === true &&\n    path.get('params').length === 1 &&\n    path.get('params')[0].isIdentifier();\n}\n\nfunction isSimpleMemberExpression(path) {\n  return path.isMemberExpression() &&\n    path.get('object').isIdentifier() &&\n    !path.node.computed;\n}\n\nfunction matchesAccessFunctionShorthand(path) {\n  return matchesFunctionShorthand(path) &&\n    isSimpleMemberExpression(path.get('body')) &&\n    path.get('params')[0].node.name === path.get('body.object').node.name;\n}\n\nfunction matchesCallFunctionShorthand(path) {\n  return matchesFunctionShorthand(path) &&\n    path.get('body').isCallExpression() &&\n    path.get('body.arguments').length === 0 &&\n    isSimpleMemberExpression(path.get('body.callee')) &&\n    path.get('params')[0].node.name === path.get('body.callee.object').node.name;\n}\n\nfunction matchesSubmorphGetter(path) {\n  return path.isClassMethod() &&\n    path.node.kind === \"get\" &&\n    path.get('key').isIdentifier() &&\n    path.get('body').isBlockStatement() &&\n    path.get('body.body').length === 1 &&\n    path.get('body.body.0').isReturnStatement() &&\n    path.get('body.body.0.argument').isCallExpression() &&\n    path.get('body.body.0.argument.callee').isMemberExpression() &&\n    path.get('body.body.0.argument.callee.object').isThisExpression() &&\n    path.get('body.body.0.argument.callee.property').isIdentifier() &&\n    path.get('body.body.0.argument.callee.property').node.name === 'get' &&\n    !path.get('body.body.0.argument.callee').node.computed &&\n    path.get('body.body.0.argument.arguments').length === 1 &&\n    path.get('body.body.0.argument.arguments.0').isStringLiteral();\n}\n\nfunction getAppropriateElementTagName(path) {\n\n  if (!path) {\n    return 'generic-ast-node';\n  }\n\n  if (matchesAccessFunctionShorthand(path)) {\n    return 'compound-node-access-function-shorthand';\n  }\n  if (matchesCallFunctionShorthand(path)) {\n    return 'compound-node-call-function-shorthand';\n  }\n  \n  if (matchesSubmorphGetter(path)) {\n    return 'compound-node-submorph-getter';\n  }\n  \n  \n  if (path.node.type === 'Identifier') { return 'ast-node-identifier'; }\n  if (path.node.type === 'Program') { return 'ast-node-program'; }\n  if (path.node.type === 'ExpressionStatement') { return 'ast-node-expression-statement'; }\n  if (path.node.type === 'VariableDeclaration') { return 'ast-node-variable-declaration'; }\n  if (path.node.type === 'VariableDeclarator') { return 'ast-node-variable-declarator'; }\n  if (path.node.type === 'CallExpression') { return 'ast-node-call-expression'; }\n  if (path.node.type === 'ReturnStatement') { return 'ast-node-return-statement'; }\n  if (path.node.type === 'AssignmentExpression') { return 'ast-node-assignment-expression'; }\n  if (path.node.type === 'BinaryExpression') { return 'ast-node-binary-expression'; }\n  if (path.node.type === 'NumericLiteral') { return 'ast-node-numeric-literal'; }\n  if (path.node.type === 'MemberExpression') { return 'ast-node-member-expression'; }\n  if (path.node.type === 'ArrowFunctionExpression') { return 'ast-node-arrow-function-expression'; }\n  if (path.node.type === 'BlockStatement') { return 'ast-node-block-statement'; }\n  if (path.node.type === 'RegExpLiteral') { return 'ast-node-reg-exp-literal'; }\n  if (path.node.type === 'NullLiteral') { return 'ast-node-null-literal'; }\n  if (path.node.type === 'StringLiteral') { return 'ast-node-string-literal'; }\n  if (path.node.type === 'BooleanLiteral') { return 'ast-node-boolean-literal'; }\n  if (path.node.type === 'EmptyStatement') { return 'ast-node-empty-statement'; }\n  if (path.node.type === 'DebuggerStatement') { return 'ast-node-debugger-statement'; }\n  if (path.node.type === 'WithStatement') { return 'ast-node-with-statement'; }\n  if (path.node.type === 'LabeledStatement') { return 'ast-node-labeled-statement'; }\n  if (path.node.type === 'BreakStatement') { return 'ast-node-break-statement'; }\n  if (path.node.type === 'ContinueStatement') { return 'ast-node-continue-statement'; }\n  if (path.node.type === 'IfStatement') { return 'ast-node-if-statement'; }\n  if (path.node.type === 'SwitchStatement') { return 'ast-node-switch-statement'; }\n  if (path.node.type === 'SwitchCase') { return 'ast-node-switch-case'; }\n  if (path.node.type === 'ThrowStatement') { return 'ast-node-throw-statement'; }\n  if (path.node.type === 'TryStatement') { return 'ast-node-try-statement'; }\n  if (path.node.type === 'CatchClause') { return 'ast-node-catch-clause'; }\n  if (path.node.type === 'WhileStatement') { return 'ast-node-while-statement'; }\n  if (path.node.type === 'DoWhileStatement') { return 'ast-node-do-while-statement'; }\n  if (path.node.type === 'ForStatement') { return 'ast-node-for-statement'; }\n  if (path.node.type === 'ForInStatement') { return 'ast-node-for-in-statement'; }\n  if (path.node.type === 'ForOfStatement') { return 'ast-node-for-of-statement'; }\n  if (path.node.type === 'FunctionDeclaration') { return 'ast-node-function-declaration'; }\n  if (path.node.type === 'Decorator') { return 'ast-node-decorator'; }\n  if (path.node.type === 'Directive') { return 'ast-node-directive'; }\n  if (path.node.type === 'DirectiveLiteral') { return 'ast-node-directive-literal'; }\n  if (path.node.type === 'Super') { return 'ast-node-super'; }\n  if (path.node.type === 'Import') { return 'ast-node-import'; }\n  if (path.node.type === 'ThisExpression') { return 'ast-node-this-expression'; }\n  if (path.node.type === 'YieldExpression') { return 'ast-node-yield-expression'; }\n  if (path.node.type === 'AwaitExpression') { return 'ast-node-await-expression'; }\n  if (path.node.type === 'ArrayExpression') { return 'ast-node-array-expression'; }\n  if (path.node.type === 'ObjectExpression') { return 'ast-node-object-expression'; }\n  if (path.node.type === 'ObjectMember') { return 'ast-node-object-member'; }\n  if (path.node.type === 'ObjectProperty') { return 'ast-node-object-property'; }\n  if (path.node.type === 'ObjectMethod') { return 'ast-node-object-method'; }\n  if (path.node.type === 'FunctionExpression') { return 'ast-node-function-expression'; }\n  if (path.node.type === 'UnaryExpression') { return 'ast-node-unary-expression'; }\n  if (path.node.type === 'UnaryOperator') { return 'ast-node-unary-operator'; }\n  if (path.node.type === 'UpdateExpression') { return 'ast-node-update-expression'; }\n  if (path.node.type === 'UpdateOperator') { return 'ast-node-update-operator'; }\n  if (path.node.type === 'LogicalExpression') { return 'ast-node-logical-expression'; }\n  if (path.node.type === 'SpreadElement') { return 'ast-node-spread-element'; }\n  if (path.node.type === 'BindExpression') { return 'ast-node-bind-expression'; }\n  if (path.node.type === 'ConditionalExpression') { return 'ast-node-conditional-expression'; }\n  if (path.node.type === 'NewExpression') { return 'ast-node-new-expression'; }\n  if (path.node.type === 'SequenceExpression') { return 'ast-node-sequence-expression'; }\n  if (path.node.type === 'DoExpression') { return 'ast-node-do-expression'; }\n  if (path.node.type === 'TemplateLiteral') { return 'ast-node-template-literal'; }\n  if (path.node.type === 'TaggedTemplateExpression') { return 'ast-node-tagged-template-expression'; }\n  if (path.node.type === 'TemplateElement') { return 'ast-node-template-element'; }\n  if (path.node.type === 'ObjectPattern') { return 'ast-node-object-pattern'; }\n  if (path.node.type === 'ArrayPattern') { return 'ast-node-array-pattern'; }\n  if (path.node.type === 'RestElement') { return 'ast-node-rest-element'; }\n  if (path.node.type === 'AssignmentPattern') { return 'ast-node-assignment-pattern'; }\n  if (path.node.type === 'ClassBody') { return 'ast-node-class-body'; }\n  if (path.node.type === 'ClassMethod') { return 'ast-node-class-method'; }\n  if (path.node.type === 'ClassPrivateMethod') { return 'ast-node-class-private-method'; }\n  if (path.node.type === 'ClassProperty') { return 'ast-node-class-property'; }\n  if (path.node.type === 'ClassPrivateProperty') { return 'ast-node-class-private-property'; }\n  if (path.node.type === 'ClassDeclaration') { return 'ast-node-class-declaration'; }\n  if (path.node.type === 'ClassExpression') { return 'ast-node-class-expression'; }\n  if (path.node.type === 'MetaProperty') { return 'ast-node-meta-property'; }\n  if (path.node.type === 'ModuleDeclaration') { return 'ast-node-module-declaration'; }\n  if (path.node.type === 'ModuleSpecifier') { return 'ast-node-module-specifier'; }\n  if (path.node.type === 'ImportDeclaration') { return 'ast-node-import-declaration'; }\n  if (path.node.type === 'ImportSpecifier') { return 'ast-node-import-specifier'; }\n  if (path.node.type === 'ImportDefaultSpecifier') { return 'ast-node-import-default-specifier'; }\n  if (path.node.type === 'ImportNamespaceSpecifier') { return 'ast-node-import-namespace-specifier'; }\n  if (path.node.type === 'ExportNamedDeclaration') { return 'ast-node-export-named-declaration'; }\n  if (path.node.type === 'ExportSpecifier') { return 'ast-node-export-specifier'; }\n  if (path.node.type === 'ExportDefaultDeclaration') { return 'ast-node-export-default-declaration'; }\n  if (path.node.type === 'ExportAllDeclaration') { return 'ast-node-export-all-declaration'; }\n\n  return 'generic-ast-node';\n}\n\nconst SCOPE_MAP = new WeakMap();\nlet NEXT_SCOPE_ID = 0;\n\nexport default class AbstractAstNode extends Morph {\n\n  get isAstNode() { return true; }\n\n  static addChildType(astNodeType) {\n    self.AstNodeTypes.push(astNodeType);\n  }\n\n  async initialize() {\n    this.windowTitle = \"AbstractAstNode\";\n\n    this.tabIndex = 0;\n\n    this.initHover();\n    this.addEventListener('click', evt => this.onClick(evt));\n    this.addEventListener('keydown', evt => this.onKeydown(evt));\n    // this.addEventListener('blur', evt => { lively.notify('blur', this.path.type); });\n    this.addEventListener('focus', evt => { this.onFocus(evt); });\n    // this.addEventListener('focusin', evt => { lively.notify('focusin', this.path.type); });\n    // this.addEventListener('focusout', evt => { lively.notify('focusout', this.path.type); });\n    this.addEventListener('copy', evt => this.onCopy(evt));\n    this.addEventListener('cut', evt => this.onCut(evt));\n    this.addEventListener('paste', evt => this.onPaste(evt));\n    \n    // color [0-360], saturation [0-1], lightness [0-1]\n    // this.style.backgroundColor = `${d3.hsl(\n    //   Math.random() * 360,\n    //   Math.random() * 0.2 + 0.4,\n    //   Math.random() * 0.2 + 0.8\n    // )}`;\n    this.classList.add('ast-node');\n  }\n\n  initHover() {\n    this.addEventListener('mouseover', evt => this.onMouseOver(evt));\n    this.addEventListener('mouseout', evt => this.onMouseOut(evt));\n  }\n\n  onMouseOver(evt) {\n    evt.stopPropagation();\n    this.classList.add('node-hover');\n  }\n  onMouseOut(evt) {\n    this.classList.remove('node-hover');\n  }\n  onClick(evt) {\n    evt.stopPropagation();\n    const type = this.path && this.path.type;\n    if (type) {\n      lively.notify('clicked ' + type);\n    } else {\n      lively.warn('no type found for clicked element');\n    }\n    this.editor.navigation.onClickElement(this, evt);\n  }\n  onKeydown(evt) {\n    const info = keyInfo(evt);\n    const { char, ctrl, shift, alt, keyCode, charCode } = info;\n\n    const handledByNavigation = this.editor.navigation.handleKeydown(this, evt);\n    if (handledByNavigation) { return false; }\n    \n    if (ctrl && (info.backspace || info.del)) {\n      lively.warn('should delete')\n      return;\n    }\n\n    if (ctrl && char === 'C') {\n      this.copyNodeToClipboard(evt);\n      return;\n    }\n\n    if (ctrl && char === 'E') {\n      this.extractExpressionIntoLocalVariable(evt);\n      return;\n    }\n\n    info.notify();\n    \n    return false;\n  }\n  onFocus(evt) {\n    this.editor.buildPathInfo();\n  }\n  onCopy(evt) {\n    debugger\n    lively.notify('copy')\n  }\n  onCut(evt) {\n        lively.notify('cut')\n\n  }\n  onPaste(evt) {\n        lively.notify('paste')\n\n  }\n  \n  getAppropriateElement(path) {\n    return getAppropriateElement(path);\n  }\n  \n  extractExpressionIntoLocalVariable(evt) {\n    evt.stopPropagation();\n    evt.preventDefault();\n    \n    const localName = window.prompt('name of local variable', 'temp');\n    this.editor.commandExtractExpressionIntoLocalVariable(this, localName);\n  }\n  copyNodeToClipboard(evt) {\n      lively.warn('should COPY')\n    \n  }\n  \n  get node() { return this._node; }\n  set node(value) { return this._node = value; }\n\n  get astNode() { return this._node; }\n  set astNode(value) { return this._node = value; }\n\n  addNodeStylingInfo(path) {\n    let depth = -1;\n    path.find(p => {\n      depth++;\n      return p.parentPath && p.scope !== p.parentPath.scope;\n    });\n    this.setAttribute('ast-node-scope', SCOPE_MAP.getOrCreate(path.scope, () => NEXT_SCOPE_ID++ % 20));\n    this.setAttribute('ast-node-depth', depth);\n    this.style.setProperty(\"--my-border\", `10px solid red`);\n  }\n\n  async setPath(path) {\n    this.path = path;\n    this.node = path.node;\n\n    this.addNodeStylingInfo(path);\n    await this.setNode(path.node);\n  }\n  \n  async setNode(babelASTNode) {\n    this.node = babelASTNode;\n\n    await this.updateProjection(babelASTNode);\n    \n    return this;\n  }\n\n  async createSubElementForPath(astPath, slotName) {\n    const oldElement = this.get(`:scope > [slot=${slotName}]`);\n    \n    if (!astPath.node) {\n      oldElement && oldElement.remove();\n      return;\n    }\n    \n    const [element, isNew] = await prepareElementForPath(astPath, slotName, oldElement);\n\n    if (oldElement) {\n      if (isNew) {\n        this.replaceChild(element, oldElement);\n      }\n    } else {\n      this.appendChild(element);\n    }\n  }\n  \n  async createSubElementForPaths(paths, slotName) {\n    paths;\n    const currentChildren = this.getAllSubmorphs(`:scope > [slot=${slotName}]`);\n    const currentMatches = new Map();\n\n    paths.forEach(path => {\n      const matchingChild = currentChildren.find(child => nodeEqual(path, child));\n      if (matchingChild) {\n        currentMatches.set(path, matchingChild);\n      }\n    });\n\n    const [matchingOnly, both, nonMatching] = Array.from(currentMatches.values()).computeDiff(currentChildren);\n    nonMatching.forEach(element => element.remove());\n\n    const newElements = new Map();\n    for (let path of paths) {\n      if (path.node === null) { continue; }\n\n      const oldElement = currentMatches.get(path);\n      const [element, isNew] = await prepareElementForPath(path, slotName, oldElement);\n      newElements.set(path, [element, isNew]);\n    }\n\n    paths.forEach(path => {\n      const oldElement = currentMatches.get(path);\n\n      // #Todo #Workaround some nodes allow for null elements in multi-child fields, e.g. ArrayExpression::elements could have `null` as an element\n      if (!newElements.has(path)) { return; }\n      const [element, isNew] = newElements.get(path);\n\n      // append here\n      if (oldElement) {\n        if (isNew) {\n          oldElement.remove();\n        }\n      }\n      this.appendChild(element);\n    });\n  }\n  \n  removeSubElementInSlot(slotName) {\n    const subElement = this.get(`:scope > [slot=${slotName}]`)\n    if (subElement) {\n      subElement.remove();\n    }\n  }\n  \n  get editor() {\n    return this._editor = this._editor || lively.allParents(this, [], true).find(ele => ele.localName === 'pen-editor');\n  }\n\n  /* Lively-specific API */\n  livelyPreMigrate() {}\n  livelyMigrate(other) { throw new Error('livelyMigrate should not be called'); }\n  livelyInspect(contentNode, inspector) {}\n  livelyPrepareSave() {}\n  async livelyExample() {}\n\n  get livelyUpdateStrategy() { return 'inplace'; }\n  livelyUpdate() {\n    this.updateFromTemplate();\n    // lively.success(\"WRONG\");\n  }\n  updateFromTemplate() {\n    // #Paper #WebComponents #ObjectMigration\n    // object migration strategy:\n    // - keep identity\n    // - but replace internal state\n    // #TODO: was about external children\n    // #TODO: reuse part of old state in more fine-grained manner\n    // #GOAL: keep as much object identity as possible alive, due to potentially exposed references to internal state\n    this.shadowRoot.innerHTML = \"\";\n    ComponentLoader.applyTemplate(this, this.localName);\n  }\n}\n"]}