// Break down '  \\( inlineFunc )  '
// into tokens: '  ', '\', '(', ' inlineFunc ', ')', '  '
export const tokenizeInlineFunc = function(inlineFunc) {
  return INLINE_FUNC_REGEXP.exec(inlineFunc)
}

const INLINE_FUNC_REGEXP = /^(\s*)(?<escape>\\?)(\()(?<body>.*)(\))(\s*)$/su

// Remove outer parenthesis from inline function
export const getInlineFunc = function(inlineFunc) {
  const parts = tokenizeInlineFunc(inlineFunc)
  return parts.groups.body
}

// Retrieves inline config function body
export const stringifyConfigFunc = function({
  configFunc,
  configFunc: { name },
}) {
  if (name && name !== 'anonymous') {
    return `${name}()`
  }

  const funcStr = configFunc.toString()
  const body = getInlineFuncBody({ funcStr })
  return body || funcStr
}

const getInlineFuncBody = function({ funcStr }) {
  const [, body] = BODY_REGEXP.exec(funcStr) || []
  return body
}

// Extracts inline function. Only works on inline functions.
const BODY_REGEXP = /^function anonymous\(\{(?:.|\n)+return \((.*)\)/u

@@ -697,174 +697,90 @@
 nst 
-body = getInlineFuncBody(%7B funcStr %7D)%0A  return body %7C%7C funcStr%0A%7D%0A%0Aconst getInlineFuncBody = function(%7B funcStr %7D) %7B%0A  const %5B, body%5D = BODY_REGEXP.exec(funcStr) %7C%7C %5B%5D
+parts = BODY_REGEXP.exec(funcStr)%0A%0A  if (parts === null) %7B%0A    return funcStr%0A  %7D%0A
 %0A  r
@@ -785,20 +785,24 @@
  return 
-body
+parts%5B1%5D
 %0A%7D%0A%0A// E
@@ -906,17 +906,10 @@
 %5C(%5C%7B
-(?:.%7C%5Cn)+
+.*
 retu
@@ -920,10 +920,11 @@
 ((.*)%5C)/
+s
 u%0A

Improve inline function serialization