@pisell/core 1.0.23 → 1.0.25

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.
package/es/app/app.d.ts CHANGED
@@ -22,6 +22,7 @@ export interface AppOptions {
22
22
  history?: HistoryOptions;
23
23
  storage?: StorageOptions;
24
24
  locales?: LocalesOptions;
25
+ getPisellos?: () => any;
25
26
  }
26
27
  declare class App {
27
28
  private static instance;
@@ -35,7 +36,7 @@ declare class App {
35
36
  locales: Locales;
36
37
  models: {
37
38
  getStore: () => import("../models").Store;
38
- StoreProvider: any;
39
+ StoreProvider: typeof import("react-redux").Provider;
39
40
  setConfig: (models: any[]) => void;
40
41
  };
41
42
  request: {
@@ -43,7 +44,7 @@ declare class App {
43
44
  post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
44
45
  put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
45
46
  remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
46
- custom: (url: string, config: import("../request").RequestSetting | undefined) => Promise<any>;
47
+ custom: (url: string, config: import("../request").RequestSetting | undefined) => any;
47
48
  setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
48
49
  getConfig: () => import("../request").RequestConfig;
49
50
  };
@@ -66,6 +67,7 @@ declare class App {
66
67
  cmd: CMD;
67
68
  aws: AWS;
68
69
  tasksManager: TasksManager;
70
+ getPisellos: any;
69
71
  dbManager: IndexDBManager | null;
70
72
  constants: {
71
73
  channel: string;
package/es/app/app.js CHANGED
@@ -67,6 +67,8 @@ var App = /*#__PURE__*/function () {
67
67
  _defineProperty(this, "aws", void 0);
68
68
  // 任务管理
69
69
  _defineProperty(this, "tasksManager", void 0);
70
+ // getPisellos
71
+ _defineProperty(this, "getPisellos", void 0);
70
72
  _defineProperty(this, "dbManager", null);
71
73
  _defineProperty(this, "constants", {
72
74
  channel: ""
@@ -87,6 +89,7 @@ var App = /*#__PURE__*/function () {
87
89
  this.tasksManager = new TasksManager(this);
88
90
  this.cmd = new CMD(this, options === null || options === void 0 ? void 0 : options.cmd);
89
91
  this.aws = new AWS(this, options === null || options === void 0 ? void 0 : options.aws);
92
+ this.getPisellos = options === null || options === void 0 ? void 0 : options.getPisellos;
90
93
  if (options !== null && options !== void 0 && options.constants) {
91
94
  this.constants = options.constants || {};
92
95
  }
package/es/aws/index.d.ts CHANGED
@@ -11,6 +11,6 @@ declare class AWS {
11
11
  private app;
12
12
  private config?;
13
13
  constructor(app: App, options?: AWSOptions);
14
- upload(params: UploadParams): Promise<any>;
14
+ upload(params: UploadParams): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
15
15
  }
16
16
  export default AWS;
@@ -1,13 +1,14 @@
1
1
  import type { History as HistoryType } from "history";
2
+ import { useHistory, useLocation, useParams } from "react-router-dom";
2
3
  import App from "../app";
3
4
  export interface HistoryOptions {
4
5
  basename?: string;
5
6
  }
6
7
  export declare class History {
7
- instance: any;
8
- useHistory: any;
9
- useLocation: any;
10
- useParams: any;
8
+ instance: HistoryType<unknown>;
9
+ useHistory: typeof useHistory;
10
+ useLocation: typeof useLocation;
11
+ useParams: typeof useParams;
11
12
  app: App;
12
13
  constructor(app: App, options?: HistoryOptions);
13
14
  push: HistoryType["push"];
@@ -14,4 +14,4 @@ export declare const MenuProvider: React.FC<{
14
14
  children: React.ReactNode;
15
15
  menus: MenuItem[];
16
16
  }>;
17
- export declare const useMenu: () => any;
17
+ export declare const useMenu: () => MenuContextType;
@@ -12,7 +12,7 @@ export declare class MenuManager {
12
12
  private menuItems;
13
13
  private menuMaps;
14
14
  private app;
15
- useMenu: () => any;
15
+ useMenu: () => import("./hooks").MenuContextType;
16
16
  MenuProvider: React.FC<{
17
17
  children: React.ReactNode;
18
18
  menus: MenuItem[];
@@ -1,4 +1,5 @@
1
1
  import hooks from '../hooks';
2
+ import { Provider as StoreProvider } from "react-redux";
2
3
  declare const models: import("./global").GlobalModal[];
3
4
  declare type ModalsType = (typeof models[number]);
4
5
  export interface Store {
@@ -38,7 +39,7 @@ declare const getDataByModel: <T extends "global", D extends keyof ModelsState[T
38
39
  declare const setDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key: any, value: any) => void;
39
40
  declare const _default: {
40
41
  getStore: () => Store;
41
- StoreProvider: any;
42
+ StoreProvider: typeof StoreProvider;
42
43
  setConfig: (models: any[]) => void;
43
44
  };
44
45
  export default _default;
@@ -32,7 +32,7 @@ export declare const getCacheData: (url: string, data: any, cache: CacheProps) =
32
32
  * @return {*}
33
33
  * @Author: zhiwei.Wang
34
34
  */
35
- export declare const setCacheData: (url: string, data: any, res: any, cache?: CacheProps) => any | null;
35
+ export declare const setCacheData: (url: string, data: any, res: any, cache: CacheProps) => any | null;
36
36
  /**
37
37
  * @title: 缓存函数包装器
38
38
  * @description:
@@ -124,26 +124,20 @@ var getCache = /*#__PURE__*/function () {
124
124
  case 0:
125
125
  _getConfig3 = getConfig(), storage = _getConfig3.storage; // 如果 当前时间 - 数据缓存时间 小于 超时时间, 则数据正常.
126
126
  if (!(cache.type === 'memory')) {
127
- _context2.next = 8;
128
- break;
129
- }
130
- if (CACHES[key]) {
131
- _context2.next = 4;
127
+ _context2.next = 6;
132
128
  break;
133
129
  }
134
- return _context2.abrupt("return", null);
135
- case 4:
136
130
  if (!getIsEffectiveTime(CACHES[key].time)) {
137
- _context2.next = 6;
131
+ _context2.next = 4;
138
132
  break;
139
133
  }
140
134
  return _context2.abrupt("return", CACHES[key].data);
141
- case 6:
142
- _context2.next = 23;
135
+ case 4:
136
+ _context2.next = 21;
143
137
  break;
144
- case 8:
138
+ case 6:
145
139
  if (!(cache.type === 'storage')) {
146
- _context2.next = 15;
140
+ _context2.next = 13;
147
141
  break;
148
142
  }
149
143
  storageDetail = storage.getStorage(key) || "";
@@ -151,35 +145,35 @@ var getCache = /*#__PURE__*/function () {
151
145
  storageDetail = JSON.parse(storageDetail);
152
146
  }
153
147
  if (!getIsEffectiveTime(storageDetail.time)) {
154
- _context2.next = 13;
148
+ _context2.next = 11;
155
149
  break;
156
150
  }
157
151
  return _context2.abrupt("return", (_storageDetail = storageDetail) === null || _storageDetail === void 0 ? void 0 : _storageDetail.data);
158
- case 13:
159
- _context2.next = 23;
152
+ case 11:
153
+ _context2.next = 21;
160
154
  break;
161
- case 15:
155
+ case 13:
162
156
  if (!(cache.type === 'indexDB')) {
163
- _context2.next = 23;
157
+ _context2.next = 21;
164
158
  break;
165
159
  }
166
160
  app = getApp();
167
161
  if (!app.dbManager) {
168
- _context2.next = 23;
162
+ _context2.next = 21;
169
163
  break;
170
164
  }
171
- _context2.next = 20;
165
+ _context2.next = 18;
172
166
  return app.dbManager.get('requests', key);
173
- case 20:
167
+ case 18:
174
168
  indexDBDetail = _context2.sent;
175
169
  if (!indexDBDetail) {
176
- _context2.next = 23;
170
+ _context2.next = 21;
177
171
  break;
178
172
  }
179
173
  return _context2.abrupt("return", indexDBDetail === null || indexDBDetail === void 0 ? void 0 : indexDBDetail.data);
180
- case 23:
174
+ case 21:
181
175
  return _context2.abrupt("return", null);
182
- case 24:
176
+ case 22:
183
177
  case "end":
184
178
  return _context2.stop();
185
179
  }
@@ -257,10 +251,7 @@ export var getCacheData = /*#__PURE__*/function () {
257
251
  * @return {*}
258
252
  * @Author: zhiwei.Wang
259
253
  */
260
- export var setCacheData = function setCacheData(url, data, res) {
261
- var cache = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
262
- type: 'memory'
263
- };
254
+ export var setCacheData = function setCacheData(url, data, res, cache) {
264
255
  // 创建缓存key
265
256
  var _key = createCacheKey(url, data, cache);
266
257
  setCache(_key, res, cache);
@@ -278,44 +269,37 @@ export var setCacheData = function setCacheData(url, data, res) {
278
269
  */
279
270
  export var cacheFn = /*#__PURE__*/function () {
280
271
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(props, fn) {
281
- var url, data, config, cache, _data, _config$cache;
272
+ var url, data, config, _data, _config$cache;
282
273
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
283
274
  while (1) switch (_context4.prev = _context4.next) {
284
275
  case 0:
285
276
  url = props.url, data = props.data, config = props.config;
286
- if (!(config !== null && config !== void 0 && config.cache || config !== null && config !== void 0 && config.useCache)) {
287
- _context4.next = 10;
277
+ if (!(config !== null && config !== void 0 && config.cache)) {
278
+ _context4.next = 8;
288
279
  break;
289
280
  }
290
- cache = config.cache;
291
- if (config.useCache) {
292
- cache = {
293
- type: 'memory'
294
- };
295
- }
296
- // 获取缓存数据
297
- _context4.next = 6;
298
- return getCacheData(url, data, cache);
299
- case 6:
281
+ _context4.next = 4;
282
+ return getCacheData(url, data, config.cache);
283
+ case 4:
300
284
  _data = _context4.sent;
301
285
  if (!_data) {
302
- _context4.next = 10;
286
+ _context4.next = 8;
303
287
  break;
304
288
  }
305
289
  // 如果开启更新缓存执行函数
306
290
  if ((_config$cache = config.cache) !== null && _config$cache !== void 0 && _config$cache.updateCache) {
307
291
  fn(_objectSpread(_objectSpread({}, props), {}, {
308
292
  config: _objectSpread(_objectSpread({}, props.config), {}, {
309
- cache: _objectSpread(_objectSpread({}, cache), {}, {
293
+ cache: _objectSpread(_objectSpread({}, props.config.cache), {}, {
310
294
  updateCache: false
311
295
  })
312
296
  })
313
297
  }));
314
298
  }
315
299
  return _context4.abrupt("return", _data);
316
- case 10:
300
+ case 8:
317
301
  return _context4.abrupt("return", fn(props));
318
- case 11:
302
+ case 9:
319
303
  case "end":
320
304
  return _context4.stop();
321
305
  }
@@ -5,19 +5,19 @@ export declare const createRequest: (props: RequestWrapperProps) => Promise<unkn
5
5
  * @param props
6
6
  * @returns
7
7
  */
8
- export declare const request: (props: RequestWrapperProps) => Promise<any>;
8
+ export declare const request: (props: RequestWrapperProps) => any;
9
9
  export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
10
10
  export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
11
11
  export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
12
12
  export declare const remove: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
13
- export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => Promise<any>;
13
+ export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => any;
14
14
  export * from "./type";
15
15
  declare const _default: {
16
16
  get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
17
17
  post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
18
18
  put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
19
19
  remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
20
- custom: (url: string, config: import("./type").RequestSetting | undefined) => Promise<any>;
20
+ custom: (url: string, config: import("./type").RequestSetting | undefined) => any;
21
21
  setConfig: (newConfig: Partial<RequestConfig>) => void;
22
22
  getConfig: () => RequestConfig;
23
23
  };
@@ -13,6 +13,7 @@ import { cacheFn } from "./cache";
13
13
  import { interceptorsRequest, interceptorsResponse, interceptorsRequestError, interceptorsResponseError, requestCallback } from "./utils";
14
14
  import axios from "axios";
15
15
  import { getConfig, setConfig } from "./config";
16
+ import { getApp } from "../app";
16
17
  // 实例
17
18
  var axiosInstance = axios.create(axiosConfig);
18
19
 
@@ -59,13 +60,25 @@ export var createRequest = function createRequest(props) {
59
60
  */
60
61
  export var request = function request(props) {
61
62
  var config = props.config,
62
- url = props.url;
63
+ url = props.url,
64
+ method = props.method;
63
65
  // 请求防抖
64
66
  if (config !== null && config !== void 0 && config.abort) {
65
67
  var signal = createSignal(config.abort, url);
66
68
  config.signal = signal;
67
69
  }
68
70
 
71
+ // 使用os服务层
72
+ if (config !== null && config !== void 0 && config.osServer) {
73
+ var _app$getPisellos, _pisellos$server, _pisellos$server$hasR;
74
+ var app = getApp();
75
+ var pisellos = (_app$getPisellos = app.getPisellos) === null || _app$getPisellos === void 0 ? void 0 : _app$getPisellos.call(app);
76
+ if (pisellos !== null && pisellos !== void 0 && pisellos.server && pisellos !== null && pisellos !== void 0 && (_pisellos$server = pisellos.server) !== null && _pisellos$server !== void 0 && (_pisellos$server$hasR = _pisellos$server.hasRoute) !== null && _pisellos$server$hasR !== void 0 && _pisellos$server$hasR.call(_pisellos$server, method, url)) {
77
+ var _pisellos$server2, _pisellos$server2$han;
78
+ return pisellos === null || pisellos === void 0 || (_pisellos$server2 = pisellos.server) === null || _pisellos$server2 === void 0 || (_pisellos$server2$han = _pisellos$server2.handleRoute) === null || _pisellos$server2$han === void 0 ? void 0 : _pisellos$server2$han.call(_pisellos$server2, method, url, props);
79
+ }
80
+ }
81
+
69
82
  // 缓存函数
70
83
  return cacheFn(props, createRequest);
71
84
  };
@@ -31,6 +31,7 @@ export interface RequestSetting {
31
31
  cache?: CacheProps;
32
32
  signal?: any;
33
33
  token?: string;
34
+ osServer?: boolean;
34
35
  [key: string]: any;
35
36
  }
36
37
  export interface RequestWrapperProps {
@@ -128,7 +128,7 @@ export var requestCallback = function requestCallback(resData) {
128
128
  if (codeFn) {
129
129
  if ((res === null || res === void 0 ? void 0 : res.code) === 200) {
130
130
  // 需要缓存的进行缓存数据
131
- if (config !== null && config !== void 0 && config.useCache || config !== null && config !== void 0 && config.cache) {
131
+ if (config !== null && config !== void 0 && config.cache) {
132
132
  var _config$cacheUpdateCh;
133
133
  setCacheData(props.url, props.data, res, config === null || config === void 0 ? void 0 : config.cache);
134
134
  config === null || config === void 0 || (_config$cacheUpdateCh = config.cacheUpdateChange) === null || _config$cacheUpdateCh === void 0 || _config$cacheUpdateCh.call(config, res);
@@ -20,9 +20,9 @@ export declare class RouterManager {
20
20
  get(name: string): RouteType;
21
21
  has(name: string): boolean;
22
22
  remove(name: string): void;
23
- renderComponent(item: RouteType, children?: React.ReactNode): any;
23
+ renderComponent(item: RouteType, children?: React.ReactNode): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
24
24
  getPageByRoute(route: string): ApplicationInterface | undefined;
25
25
  getRouterComponent({ fallback }: {
26
26
  fallback?: React.ReactNode;
27
- }): any[];
27
+ }): JSX.Element[];
28
28
  }
@@ -7,7 +7,7 @@ export declare class TasksManager {
7
7
  private app;
8
8
  private db;
9
9
  useTasks: () => {
10
- tasks: any;
10
+ tasks: TasksModule;
11
11
  };
12
12
  watchTaskCallback: (taskModule: TasksModule) => void;
13
13
  private timerIds;
@@ -1,4 +1,5 @@
1
+ import { TasksModule } from './type';
1
2
  declare const useTasks: () => {
2
- tasks: any;
3
+ tasks: TasksModule;
3
4
  };
4
5
  export default useTasks;
package/lib/app/app.d.ts CHANGED
@@ -22,6 +22,7 @@ export interface AppOptions {
22
22
  history?: HistoryOptions;
23
23
  storage?: StorageOptions;
24
24
  locales?: LocalesOptions;
25
+ getPisellos?: () => any;
25
26
  }
26
27
  declare class App {
27
28
  private static instance;
@@ -35,7 +36,7 @@ declare class App {
35
36
  locales: Locales;
36
37
  models: {
37
38
  getStore: () => import("../models").Store;
38
- StoreProvider: any;
39
+ StoreProvider: typeof import("react-redux").Provider;
39
40
  setConfig: (models: any[]) => void;
40
41
  };
41
42
  request: {
@@ -43,7 +44,7 @@ declare class App {
43
44
  post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
44
45
  put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
45
46
  remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
46
- custom: (url: string, config: import("../request").RequestSetting | undefined) => Promise<any>;
47
+ custom: (url: string, config: import("../request").RequestSetting | undefined) => any;
47
48
  setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
48
49
  getConfig: () => import("../request").RequestConfig;
49
50
  };
@@ -66,6 +67,7 @@ declare class App {
66
67
  cmd: CMD;
67
68
  aws: AWS;
68
69
  tasksManager: TasksManager;
70
+ getPisellos: any;
69
71
  dbManager: IndexDBManager | null;
70
72
  constants: {
71
73
  channel: string;
package/lib/app/app.js CHANGED
@@ -92,6 +92,8 @@ var App = class _App {
92
92
  aws;
93
93
  // 任务管理
94
94
  tasksManager;
95
+ // getPisellos
96
+ getPisellos;
95
97
  dbManager = null;
96
98
  constants = {
97
99
  channel: ""
@@ -113,6 +115,7 @@ var App = class _App {
113
115
  this.tasksManager = new import_tasks.TasksManager(this);
114
116
  this.cmd = new import_cmd.default(this, options == null ? void 0 : options.cmd);
115
117
  this.aws = new import_aws.default(this, options == null ? void 0 : options.aws);
118
+ this.getPisellos = options == null ? void 0 : options.getPisellos;
116
119
  if (options == null ? void 0 : options.constants) {
117
120
  this.constants = options.constants || {};
118
121
  }
@@ -11,6 +11,6 @@ declare class AWS {
11
11
  private app;
12
12
  private config?;
13
13
  constructor(app: App, options?: AWSOptions);
14
- upload(params: UploadParams): Promise<any>;
14
+ upload(params: UploadParams): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
15
15
  }
16
16
  export default AWS;
@@ -1,13 +1,14 @@
1
1
  import type { History as HistoryType } from "history";
2
+ import { useHistory, useLocation, useParams } from "react-router-dom";
2
3
  import App from "../app";
3
4
  export interface HistoryOptions {
4
5
  basename?: string;
5
6
  }
6
7
  export declare class History {
7
- instance: any;
8
- useHistory: any;
9
- useLocation: any;
10
- useParams: any;
8
+ instance: HistoryType<unknown>;
9
+ useHistory: typeof useHistory;
10
+ useLocation: typeof useLocation;
11
+ useParams: typeof useParams;
11
12
  app: App;
12
13
  constructor(app: App, options?: HistoryOptions);
13
14
  push: HistoryType["push"];
@@ -14,4 +14,4 @@ export declare const MenuProvider: React.FC<{
14
14
  children: React.ReactNode;
15
15
  menus: MenuItem[];
16
16
  }>;
17
- export declare const useMenu: () => any;
17
+ export declare const useMenu: () => MenuContextType;
@@ -12,7 +12,7 @@ export declare class MenuManager {
12
12
  private menuItems;
13
13
  private menuMaps;
14
14
  private app;
15
- useMenu: () => any;
15
+ useMenu: () => import("./hooks").MenuContextType;
16
16
  MenuProvider: React.FC<{
17
17
  children: React.ReactNode;
18
18
  menus: MenuItem[];
@@ -1,4 +1,5 @@
1
1
  import hooks from '../hooks';
2
+ import { Provider as StoreProvider } from "react-redux";
2
3
  declare const models: import("./global").GlobalModal[];
3
4
  declare type ModalsType = (typeof models[number]);
4
5
  export interface Store {
@@ -38,7 +39,7 @@ declare const getDataByModel: <T extends "global", D extends keyof ModelsState[T
38
39
  declare const setDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key: any, value: any) => void;
39
40
  declare const _default: {
40
41
  getStore: () => Store;
41
- StoreProvider: any;
42
+ StoreProvider: typeof StoreProvider;
42
43
  setConfig: (models: any[]) => void;
43
44
  };
44
45
  export default _default;
@@ -32,7 +32,7 @@ export declare const getCacheData: (url: string, data: any, cache: CacheProps) =
32
32
  * @return {*}
33
33
  * @Author: zhiwei.Wang
34
34
  */
35
- export declare const setCacheData: (url: string, data: any, res: any, cache?: CacheProps) => any | null;
35
+ export declare const setCacheData: (url: string, data: any, res: any, cache: CacheProps) => any | null;
36
36
  /**
37
37
  * @title: 缓存函数包装器
38
38
  * @description:
@@ -77,9 +77,6 @@ var getIsEffectiveTime = (time) => {
77
77
  var getCache = async (key, cache) => {
78
78
  const { storage } = (0, import_config.getConfig)();
79
79
  if (cache.type === "memory") {
80
- if (!CACHES[key]) {
81
- return null;
82
- }
83
80
  if (getIsEffectiveTime(CACHES[key].time)) {
84
81
  return CACHES[key].data;
85
82
  }
@@ -125,23 +122,15 @@ var getCacheData = async (url, data, cache) => {
125
122
  const res = await getCache(_key, cache);
126
123
  return res;
127
124
  };
128
- var setCacheData = (url, data, res, cache = {
129
- type: "memory"
130
- }) => {
125
+ var setCacheData = (url, data, res, cache) => {
131
126
  let _key = createCacheKey(url, data, cache);
132
127
  setCache(_key, res, cache);
133
128
  };
134
129
  var cacheFn = async (props, fn) => {
135
130
  var _a;
136
131
  const { url, data, config } = props;
137
- if ((config == null ? void 0 : config.cache) || (config == null ? void 0 : config.useCache)) {
138
- let cache = config.cache;
139
- if (config.useCache) {
140
- cache = {
141
- type: "memory"
142
- };
143
- }
144
- let _data = await getCacheData(url, data, cache);
132
+ if (config == null ? void 0 : config.cache) {
133
+ let _data = await getCacheData(url, data, config.cache);
145
134
  if (_data) {
146
135
  if ((_a = config.cache) == null ? void 0 : _a.updateCache) {
147
136
  fn({
@@ -149,7 +138,7 @@ var cacheFn = async (props, fn) => {
149
138
  config: {
150
139
  ...props.config,
151
140
  cache: {
152
- ...cache,
141
+ ...props.config.cache,
153
142
  updateCache: false
154
143
  }
155
144
  }
@@ -5,19 +5,19 @@ export declare const createRequest: (props: RequestWrapperProps) => Promise<unkn
5
5
  * @param props
6
6
  * @returns
7
7
  */
8
- export declare const request: (props: RequestWrapperProps) => Promise<any>;
8
+ export declare const request: (props: RequestWrapperProps) => any;
9
9
  export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
10
10
  export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
11
11
  export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
12
12
  export declare const remove: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
13
- export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => Promise<any>;
13
+ export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => any;
14
14
  export * from "./type";
15
15
  declare const _default: {
16
16
  get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
17
17
  post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
18
18
  put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
19
19
  remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
20
- custom: (url: string, config: import("./type").RequestSetting | undefined) => Promise<any>;
20
+ custom: (url: string, config: import("./type").RequestSetting | undefined) => any;
21
21
  setConfig: (newConfig: Partial<RequestConfig>) => void;
22
22
  getConfig: () => RequestConfig;
23
23
  };
@@ -46,6 +46,7 @@ var import_cache = require("./cache");
46
46
  var import_utils = require("./utils");
47
47
  var import_axios = __toESM(require("axios"));
48
48
  var import_config = require("./config");
49
+ var import_app = require("../app");
49
50
  __reExport(request_exports, require("./type"), module.exports);
50
51
  var axiosInstance = import_axios.default.create(import_constants.axiosConfig);
51
52
  axiosInstance.interceptors.request.use(import_utils.interceptorsRequest, import_utils.interceptorsRequestError);
@@ -74,11 +75,19 @@ var createRequest = (props) => {
74
75
  });
75
76
  };
76
77
  var request = (props) => {
77
- const { config, url } = props;
78
+ var _a, _b, _c, _d, _e;
79
+ const { config, url, method } = props;
78
80
  if (config == null ? void 0 : config.abort) {
79
81
  let signal = (0, import_cancelToken.createSignal)(config.abort, url);
80
82
  config.signal = signal;
81
83
  }
84
+ if (config == null ? void 0 : config.osServer) {
85
+ const app = (0, import_app.getApp)();
86
+ const pisellos = (_a = app.getPisellos) == null ? void 0 : _a.call(app);
87
+ if ((pisellos == null ? void 0 : pisellos.server) && ((_c = (_b = pisellos == null ? void 0 : pisellos.server) == null ? void 0 : _b.hasRoute) == null ? void 0 : _c.call(_b, method, url))) {
88
+ return (_e = (_d = pisellos == null ? void 0 : pisellos.server) == null ? void 0 : _d.handleRoute) == null ? void 0 : _e.call(_d, method, url, props);
89
+ }
90
+ }
82
91
  return (0, import_cache.cacheFn)(props, createRequest);
83
92
  };
84
93
  var get = async (url, data, config) => {
@@ -31,6 +31,7 @@ export interface RequestSetting {
31
31
  cache?: CacheProps;
32
32
  signal?: any;
33
33
  token?: string;
34
+ osServer?: boolean;
34
35
  [key: string]: any;
35
36
  }
36
37
  export interface RequestWrapperProps {
@@ -86,7 +86,7 @@ var requestCallback = (resData) => {
86
86
  const codeFn = requestCallbacks == null ? void 0 : requestCallbacks[res == null ? void 0 : res.code];
87
87
  if (codeFn) {
88
88
  if ((res == null ? void 0 : res.code) === 200) {
89
- if ((config == null ? void 0 : config.useCache) || (config == null ? void 0 : config.cache)) {
89
+ if (config == null ? void 0 : config.cache) {
90
90
  (0, import_cache.setCacheData)(props.url, props.data, res, config == null ? void 0 : config.cache);
91
91
  (_a = config == null ? void 0 : config.cacheUpdateChange) == null ? void 0 : _a.call(config, res);
92
92
  }
@@ -20,9 +20,9 @@ export declare class RouterManager {
20
20
  get(name: string): RouteType;
21
21
  has(name: string): boolean;
22
22
  remove(name: string): void;
23
- renderComponent(item: RouteType, children?: React.ReactNode): any;
23
+ renderComponent(item: RouteType, children?: React.ReactNode): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
24
24
  getPageByRoute(route: string): ApplicationInterface | undefined;
25
25
  getRouterComponent({ fallback }: {
26
26
  fallback?: React.ReactNode;
27
- }): any[];
27
+ }): JSX.Element[];
28
28
  }
@@ -7,7 +7,7 @@ export declare class TasksManager {
7
7
  private app;
8
8
  private db;
9
9
  useTasks: () => {
10
- tasks: any;
10
+ tasks: TasksModule;
11
11
  };
12
12
  watchTaskCallback: (taskModule: TasksModule) => void;
13
13
  private timerIds;
@@ -1,4 +1,5 @@
1
+ import { TasksModule } from './type';
1
2
  declare const useTasks: () => {
2
- tasks: any;
3
+ tasks: TasksModule;
3
4
  };
4
5
  export default useTasks;
package/package.json CHANGED
@@ -1,12 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/core",
3
- "version": "1.0.23",
4
- "scripts": {
5
- "build": "father build",
6
- "dev": "father dev",
7
- "build:types": "tsc --project tsconfig.types.json",
8
- "publish:types": "npm run build:types && cd types && cp ../types-package.json package.json && npm publish"
9
- },
3
+ "version": "1.0.25",
10
4
  "sideEffects": false,
11
5
  "main": "./lib/index.js",
12
6
  "module": "./es/index.js",
@@ -44,5 +38,11 @@
44
38
  ],
45
39
  "publishConfig": {
46
40
  "access": "public"
41
+ },
42
+ "scripts": {
43
+ "build": "father build",
44
+ "dev": "father dev",
45
+ "build:types": "tsc --project tsconfig.types.json",
46
+ "publish:types": "npm run build:types && cd types && cp ../types-package.json package.json && npm publish"
47
47
  }
48
48
  }