// type StoreLog = {
//   type: "get" | "set" | "delete",
//   path: string,
//   value?: any,
//   timestamp: number,
// };

// 给各模块创建 store
export function createStore(initialState, moduleName, onChange) {
  // 关于logs这里先注释，后面不是这么玩的，应该是通过插件直接写
  // const logs: StoreLog[] = [];

  var handler = {
    get: function get(target, prop, receiver) {
      var value = Reflect.get(target, prop, receiver);
      // logs.push({ type: "get", path: `${moduleName}.${String(prop)}`, timestamp: Date.now() });
      return value;
    },
    set: function set(target, prop, value, receiver) {
      // logs.push({
      //   type: "set",
      //   path: `${moduleName}.${String(prop)}`,
      //   value,
      //   timestamp: Date.now(),
      // });
      var result = Reflect.set(target, prop, value, receiver);
      onChange === null || onChange === void 0 || onChange("".concat(String(prop)), value);
      return result;
    },
    deleteProperty: function deleteProperty(target, prop) {
      // logs.push({
      //   type: "delete",
      //   path: `${moduleName}.${String(prop)}`,
      //   timestamp: Date.now(),
      // });
      return Reflect.deleteProperty(target, prop);
    }
  };
  var proxy = new Proxy(initialState, handler);
  return {
    proxy: proxy
  };
}