"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.loadEchartsFramework = loadEchartsFramework;
exports.loadEchartsEventAction = loadEchartsEventAction;
exports.toString = exports.convertToPostMessageString = void 0;

var _echarts = _interopRequireDefault(require("./echarts.min"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// 读取echart框架文件内容
const TAG = 'echarts '; // @ts-ignore

function loadEchartsFramework() {
  // 读取echart的lib文件
  try {
    const data = _echarts.default + ''; // 等待操作结果返回，然后打印结果

    console.log(TAG + 'echartjs的lib文件');
    return data;
  } catch (e) {
    console.log(TAG + '读取echarts文件发生错误', e);
    return '';
  }
} // 读取echart框架事件行为监听内容


function loadEchartsEventAction() {
  let str = `
    echart.on('click', funtion (event) {

    })
  `;
  return str;
}

const convertToPostMessageString = obj => {
  return JSON.stringify(obj, (_key, val) => {
    if (typeof val === 'function') {
      console.log(val); // eslint-disable-next-line no-new-func

      console.log('function', new Function('return ' + val.toString()));
      console.log('function', val.toString());
      console.log('function', val.constructor.toString()); // eslint-disable-next-line no-new-func

      return val.toString() + '';
    }

    return val;
  });
};

exports.convertToPostMessageString = convertToPostMessageString;

const toString = obj => {
  if (obj === undefined) return JSON.stringify({});
  return JSON.stringify(obj, (_key, val) => {
    if (typeof val === 'function') {
      console.log('function ', val.toString());
      return val.toString() + '';
    }

    return val;
  });
};

exports.toString = toString;
//# sourceMappingURL=provider.js.map