easy-soft-dva 3.6.117 → 3.6.119
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/index.js +1 -1
- package/es/utils/dvaAssist.d.ts +46 -4
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as
|
|
1
|
+
import{_ as t,c as i,a as n}from"./index2.js";import{_ as o}from"./regeneratorRuntime.js";import{logDevelop as a,isObject as e,promptTextBuilder as r,checkObjectIsNullOrEmpty as p,isArray as l,getModelCollection as c,tryDoDvaPrepareWork as s,logException as m,logDebug as d,buildPromptModuleInfo as u,mergeTextMessage as f}from"easy-soft-utility";import{createLoading as v}from"./dva-loading/index.js";import{jsx as h}from"react/jsx-runtime";import{Provider as w}from"react-redux";export{Provider,connect}from"react-redux";import"invariant";import"redux";import"redux-saga";import"is-plain-object";import"flatten";import"@reduxjs/toolkit";import"warning";var g="easy-soft-dva";function x(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return u(g,f(t,i),y)}var y="dvaAssist",O={application:null,initialOption:{initialState:{},models:[]},initialOptionSetComplete:!1,applicationInitializeComplete:!1};function j(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(O.initialOptionSetComplete)a(x("setApplicationInitialOption"),"reset is not allowed, it can be set only once");else{if(!e(i))throw new Error(x("setApplicationInitialOption",r.buildMustObject({})));var n=i||{};p(n)?a("application initial option","empty"):a(n,"application initial option"),n.models=l(n.models)?[].concat(t(n.models),t(c())):c(),O.initialOption=n,O.initialOptionSetComplete=!0}}function C(){if(!O.initialOptionSetComplete)throw new Error(x("initializeApplication","please exec setApplicationInitialOption to set application initial option"));if(null==O.application||!O.applicationInitializeComplete){s(),O.application=i(O.initialOption),O.application.use(v({}));var t,e=o({models:[]},O.initialOption).models,r=n(void 0===e?[]:e);try{for(r.s();!(t=r.n()).done;){var p=t.value;O.application.model(p)}}catch(t){r.e(t)}finally{r.f()}O.application.start(),a(x("initializeApplication","dva app start complete")),O.application.getStore=function(){return O.application._store},O.application.use({onError:function(t){m(t)}}),O.application.dispatch=O.application._store.dispatch,O.applicationInitializeComplete=!0}}function b(){if(!O.applicationInitializeComplete)throw new Error(x("getStore","please exec initializeApplication to start application before get store"))}function z(){return b(),O.application}function A(){return b(),O.application._store}function E(){return b(),O.application.dispatch}function I(t){var i=t.model,n=t.effect,o=t.payload,a=void 0===o?{}:o,e=t.alias,r=void 0===e?"data":e;if(p(i))throw new Error(x("dispatch","parameter model must be string and not allow empty"));if(p(n))throw new Error(x("dispatch","parameter effect must be string and not allow empty"));var l=E(),c="".concat(i,"/").concat(n);return d("model access: ".concat(c)),l({type:c,payload:a,alias:r})}function S(){return z()._models}function _(t){var i=S(),n=i.filter((function(i){return i.namespace===t}));if(n.length>0)return n[0];throw new Error("".concat(t," not in dva models, current models is ").concat(i.map((function(t){return t.namespace})).join(",")))}function k(t){return _(t).state}function M(t){return o({data:{}},k(t)).data||{}}var P=function(t){return h(w,{store:A(),children:t.children})};export{P as ApplicationProvider,O as applicationAssist,I as dispatch,S as getAllModel,E as getDispatch,z as getDvaApplication,_ as getModel,M as getModelRemoteData,k as getModelState,A as getStore,C as initializeApplication,j as setApplicationInitialOption};
|
package/es/utils/dvaAssist.d.ts
CHANGED
|
@@ -3,14 +3,52 @@
|
|
|
3
3
|
* @param {Object|Array} configs application initial config list
|
|
4
4
|
*/
|
|
5
5
|
export function setApplicationInitialOption(o?: {}): void;
|
|
6
|
+
/**
|
|
7
|
+
* Initialize application
|
|
8
|
+
*/
|
|
6
9
|
export function initializeApplication(): void;
|
|
7
10
|
export function getDvaApplication(): null;
|
|
11
|
+
/**
|
|
12
|
+
* Get store
|
|
13
|
+
*/
|
|
8
14
|
export function getStore(): any;
|
|
15
|
+
/**
|
|
16
|
+
* Get dispatch
|
|
17
|
+
*/
|
|
9
18
|
export function getDispatch(): any;
|
|
19
|
+
/**
|
|
20
|
+
* Dispatch model effect with payload and alias
|
|
21
|
+
* @param {Object} option dispatch option
|
|
22
|
+
* @param {String} option.model model name
|
|
23
|
+
* @param {String} option.effect model effect name
|
|
24
|
+
* @param {Object} option.payload payload params
|
|
25
|
+
* @param {String} option.alias data mount to state with alias key
|
|
26
|
+
*/
|
|
27
|
+
export function dispatch({ model, effect, payload, alias }: {
|
|
28
|
+
model: string;
|
|
29
|
+
effect: string;
|
|
30
|
+
payload: Object;
|
|
31
|
+
alias: string;
|
|
32
|
+
}): any;
|
|
33
|
+
/**
|
|
34
|
+
* Get all models
|
|
35
|
+
*/
|
|
10
36
|
export function getAllModel(): any;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Get the special model
|
|
39
|
+
* @param {String} name model name
|
|
40
|
+
*/
|
|
41
|
+
export function getModel(name: string): any;
|
|
42
|
+
/**
|
|
43
|
+
* Get the special model state
|
|
44
|
+
* @param {String} name model name
|
|
45
|
+
*/
|
|
46
|
+
export function getModelState(name: string): any;
|
|
47
|
+
/**
|
|
48
|
+
* Get the special model state date, eg "model.state.data" value
|
|
49
|
+
* @param {String} name model name
|
|
50
|
+
*/
|
|
51
|
+
export function getModelRemoteData(name: string): any;
|
|
14
52
|
export namespace applicationAssist {
|
|
15
53
|
const application: null;
|
|
16
54
|
namespace initialOption {
|
|
@@ -20,5 +58,9 @@ export namespace applicationAssist {
|
|
|
20
58
|
const initialOptionSetComplete: boolean;
|
|
21
59
|
const applicationInitializeComplete: boolean;
|
|
22
60
|
}
|
|
23
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Encapsulation dva Provider with store
|
|
63
|
+
* @param {Object} properties properties
|
|
64
|
+
*/
|
|
65
|
+
export function ApplicationProvider(properties: Object): JSX.Element;
|
|
24
66
|
export { connect, Provider } from "../dva-core";
|