| 205 | * for other expression or invalid code. |
| 206 | */ |
| 207 | export function wrapObjectLiteral(code: string): string { |
| 208 | try { |
| 209 | const expr = parseExpressionAt(code, 0, acornOptions); |
| 210 | if (expr.end < code.length) { |
| 211 | return code; |
| 212 | } |
| 213 | |
| 214 | const cast = expr as Expression; |
| 215 | if (cast.type !== 'ObjectExpression') { |
| 216 | return code; |
| 217 | } |
| 218 | |
| 219 | return `(${code})`; |
| 220 | } catch { |
| 221 | return code; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | export function parseSourceMappingUrl(content: string): string | undefined { |
| 226 | if (!content) return; |