@pisell/core 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,17 +10,14 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
10
10
  import { createSignal } from "./cancelToken";
11
11
  import { axiosConfig } from "./constants";
12
12
  import { cacheFn } from "./cache";
13
- import { interceptorsResponse, interceptorsRequestError, interceptorsResponseError, requestCallback } from "./utils";
13
+ import { interceptorsRequest, interceptorsResponse, interceptorsRequestError, interceptorsResponseError, requestCallback } from "./utils";
14
14
  import axios from "axios";
15
15
  import { getConfig, setConfig } from "./config";
16
16
  // 实例
17
17
  var axiosInstance = axios.create(axiosConfig);
18
- console.log('config1111');
18
+
19
19
  // 请求拦截器
20
- axiosInstance.interceptors.request.use(function (config) {
21
- console.log('config11', config);
22
- return config;
23
- }, interceptorsRequestError);
20
+ axiosInstance.interceptors.request.use(interceptorsRequest, interceptorsRequestError);
24
21
 
25
22
  // 响应拦截器
26
23
  axiosInstance.interceptors.response.use(interceptorsResponse, interceptorsResponseError);
@@ -9,9 +9,9 @@ export declare class Storage {
9
9
  private app?;
10
10
  private options;
11
11
  constructor(app?: App, options?: StorageOptions);
12
- createKey(key: string): string;
13
- setStorage(key: string, value: string): void;
14
- getStorage(key: string): string | null;
15
- removeStorage(key: string): void;
16
- clear(): void;
12
+ createKey: (key: string) => string;
13
+ setStorage: (key: string, value: string) => void;
14
+ getStorage: (key: string) => string | null;
15
+ removeStorage: (key: string) => void;
16
+ clear: () => void;
17
17
  }
@@ -1,56 +1,43 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
2
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
3
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- export var Storage = /*#__PURE__*/function () {
9
- function Storage(app, options) {
10
- _classCallCheck(this, Storage);
11
- _defineProperty(this, "storageKey", 'CapacitorStorage.native_');
12
- _defineProperty(this, "app", void 0);
13
- _defineProperty(this, "options", {});
14
- this.app = app;
15
- if (options) {
16
- this.options = options;
17
- }
18
- if (options !== null && options !== void 0 && options.storageKey) {
19
- this.storageKey = options.storageKey;
8
+ export var Storage = /*#__PURE__*/_createClass(function Storage(app, options) {
9
+ var _this = this;
10
+ _classCallCheck(this, Storage);
11
+ _defineProperty(this, "storageKey", 'CapacitorStorage.native_');
12
+ _defineProperty(this, "app", void 0);
13
+ _defineProperty(this, "options", {});
14
+ _defineProperty(this, "createKey", function (key) {
15
+ if (key.indexOf(_this.storageKey) !== -1) {
16
+ return key;
20
17
  }
18
+ return _this.storageKey + key;
19
+ });
20
+ _defineProperty(this, "setStorage", function (key, value) {
21
+ var _this$options, _this$options$setStor;
22
+ localStorage.setItem(_this.createKey(key), value);
23
+ (_this$options = _this.options) === null || _this$options === void 0 || (_this$options$setStor = _this$options.setStorageAfter) === null || _this$options$setStor === void 0 || _this$options$setStor.call(_this$options, key, value);
24
+ });
25
+ _defineProperty(this, "getStorage", function (key) {
26
+ return localStorage.getItem(_this.createKey(key));
27
+ });
28
+ _defineProperty(this, "removeStorage", function (key) {
29
+ var _this$options2, _this$options2$remove;
30
+ localStorage.removeItem(_this.createKey(key));
31
+ (_this$options2 = _this.options) === null || _this$options2 === void 0 || (_this$options2$remove = _this$options2.removeStorageAfter) === null || _this$options2$remove === void 0 || _this$options2$remove.call(_this$options2, key);
32
+ });
33
+ _defineProperty(this, "clear", function () {
34
+ localStorage.clear();
35
+ });
36
+ this.app = app;
37
+ if (options) {
38
+ this.options = options;
21
39
  }
22
- _createClass(Storage, [{
23
- key: "createKey",
24
- value: function createKey(key) {
25
- if (key.indexOf(this.storageKey) !== -1) {
26
- return key;
27
- }
28
- return this.storageKey + key;
29
- }
30
- }, {
31
- key: "setStorage",
32
- value: function setStorage(key, value) {
33
- var _this$options, _this$options$setStor;
34
- localStorage.setItem(this.createKey(key), value);
35
- (_this$options = this.options) === null || _this$options === void 0 || (_this$options$setStor = _this$options.setStorageAfter) === null || _this$options$setStor === void 0 || _this$options$setStor.call(_this$options, key, value);
36
- }
37
- }, {
38
- key: "getStorage",
39
- value: function getStorage(key) {
40
- return localStorage.getItem(this.createKey(key));
41
- }
42
- }, {
43
- key: "removeStorage",
44
- value: function removeStorage(key) {
45
- var _this$options2, _this$options2$remove;
46
- localStorage.removeItem(this.createKey(key));
47
- (_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2$remove = _this$options2.removeStorageAfter) === null || _this$options2$remove === void 0 || _this$options2$remove.call(_this$options2, key);
48
- }
49
- }, {
50
- key: "clear",
51
- value: function clear() {
52
- localStorage.clear();
53
- }
54
- }]);
55
- return Storage;
56
- }();
40
+ if (options !== null && options !== void 0 && options.storageKey) {
41
+ this.storageKey = options.storageKey;
42
+ }
43
+ });
@@ -48,11 +48,7 @@ var import_axios = __toESM(require("axios"));
48
48
  var import_config = require("./config");
49
49
  __reExport(request_exports, require("./type"), module.exports);
50
50
  var axiosInstance = import_axios.default.create(import_constants.axiosConfig);
51
- console.log("config1111");
52
- axiosInstance.interceptors.request.use((config) => {
53
- console.log("config11", config);
54
- return config;
55
- }, import_utils.interceptorsRequestError);
51
+ axiosInstance.interceptors.request.use(import_utils.interceptorsRequest, import_utils.interceptorsRequestError);
56
52
  axiosInstance.interceptors.response.use(import_utils.interceptorsResponse, import_utils.interceptorsResponseError);
57
53
  var createRequest = (props) => {
58
54
  const { data, config, method } = props;
@@ -9,9 +9,9 @@ export declare class Storage {
9
9
  private app?;
10
10
  private options;
11
11
  constructor(app?: App, options?: StorageOptions);
12
- createKey(key: string): string;
13
- setStorage(key: string, value: string): void;
14
- getStorage(key: string): string | null;
15
- removeStorage(key: string): void;
16
- clear(): void;
12
+ createKey: (key: string) => string;
13
+ setStorage: (key: string, value: string) => void;
14
+ getStorage: (key: string) => string | null;
15
+ removeStorage: (key: string) => void;
16
+ clear: () => void;
17
17
  }
@@ -26,6 +26,28 @@ var Storage = class {
26
26
  constructor(app, options) {
27
27
  this.storageKey = "CapacitorStorage.native_";
28
28
  this.options = {};
29
+ this.createKey = (key) => {
30
+ if (key.indexOf(this.storageKey) !== -1) {
31
+ return key;
32
+ }
33
+ return this.storageKey + key;
34
+ };
35
+ this.setStorage = (key, value) => {
36
+ var _a, _b;
37
+ localStorage.setItem(this.createKey(key), value);
38
+ (_b = (_a = this.options) == null ? void 0 : _a.setStorageAfter) == null ? void 0 : _b.call(_a, key, value);
39
+ };
40
+ this.getStorage = (key) => {
41
+ return localStorage.getItem(this.createKey(key));
42
+ };
43
+ this.removeStorage = (key) => {
44
+ var _a, _b;
45
+ localStorage.removeItem(this.createKey(key));
46
+ (_b = (_a = this.options) == null ? void 0 : _a.removeStorageAfter) == null ? void 0 : _b.call(_a, key);
47
+ };
48
+ this.clear = () => {
49
+ localStorage.clear();
50
+ };
29
51
  this.app = app;
30
52
  if (options) {
31
53
  this.options = options;
@@ -34,28 +56,6 @@ var Storage = class {
34
56
  this.storageKey = options.storageKey;
35
57
  }
36
58
  }
37
- createKey(key) {
38
- if (key.indexOf(this.storageKey) !== -1) {
39
- return key;
40
- }
41
- return this.storageKey + key;
42
- }
43
- setStorage(key, value) {
44
- var _a, _b;
45
- localStorage.setItem(this.createKey(key), value);
46
- (_b = (_a = this.options) == null ? void 0 : _a.setStorageAfter) == null ? void 0 : _b.call(_a, key, value);
47
- }
48
- getStorage(key) {
49
- return localStorage.getItem(this.createKey(key));
50
- }
51
- removeStorage(key) {
52
- var _a, _b;
53
- localStorage.removeItem(this.createKey(key));
54
- (_b = (_a = this.options) == null ? void 0 : _a.removeStorageAfter) == null ? void 0 : _b.call(_a, key);
55
- }
56
- clear() {
57
- localStorage.clear();
58
- }
59
59
  };
60
60
  // Annotate the CommonJS export names for ESM import in node:
61
61
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/core",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",