@brushes/context 0.0.8 → 0.0.9

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.
@@ -0,0 +1 @@
1
+ export * from "./store";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{jsx as o}from"react/jsx-runtime";import{createStore as e,useStore as r}from"zustand";import{createContext as t,useRef as n,useContext as c}from"react";import{persist as s,createJSONStorage as i}from"zustand/middleware";function u(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(t=Object.getOwnPropertySymbols(o);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(o,t[n])&&(r[t[n]]=o[t[n]])}return r}"function"==typeof SuppressedError&&SuppressedError;const a={contractSettlOpno:0,upmMap:{},rebMoney:0,goodsCamount:0,shoppingCountPrice:0,totalDiscountPrice:0,accountsSumPrice:0,discount:0,freight:0,comDisMoney:0,copyComDisMoney:0,shoppingType:"",promotionCode:"",promotionCodes:""},l=t(null);function d(r){var{children:t}=r,c=u(r,["children"]);const s=n();return s.current||(s.current=(o=>{const r={moduleStore:{_ocDiscount:[],_ocPoints:[],_couponList:[],_selectCoupon:[],_shoppingList:[],_contractGoodsList:[],_orderDomainStr:[],_ocContractSettlList:[],_orderAddressInfo:{freight:0,goodsReceiptMem:"",goodsReceiptPhone:"",goodsReceiptArrdess:"",areaCode:""},defaultValue:void 0,_skuInfo:{},params:{},breadList:[],open:!1}};return e()(e=>Object.assign(Object.assign(Object.assign({},r),o),{setModuleStore:o=>e(e=>({moduleStore:Object.assign(e.moduleStore,o)}))}))})(c)),o(l.Provider,{value:s.current,children:t})}function p(o){const e=c(l);if(!e)throw new Error("Missing ModuleContext.Provider in the tree");return r(e,o)}let m=localStorage;const f=o=>{o&&(m={getItem:e=>{try{const r=o.getStorageSync(e);return""!==r?r:null}catch(o){return console.error(`读取存储失败 [${e}]`,o),null}},setItem:(e,r)=>{try{o.setStorageSync(e,r)}catch(o){console.error(`写入存储失败 [${e}]`,o)}},removeItem:e=>{try{o.removeStorageSync(e)}catch(o){console.error(`删除存储失败 [${e}]`,o)}}})},g=t(null);function h(r){var{children:t}=r,c=u(r,["children"]);const a=n();return a.current||(a.current=(o=>{const r={rootStore:{safe:0,_userInfo:{},_historyList:[],_themeColor:{colorPrimary:"#1677ff",colorBgTextHover:"#e6r4ff"},_orderCount:{},_cart:0,_webStore:{},_menuChildren:[]}};return e()(s(e=>Object.assign(Object.assign(Object.assign({},r),o),{setModuleRootStore:o=>e(e=>({rootStore:Object.assign(e.rootStore,o)}))}),{name:"root-storage",storage:i(()=>m)}))})(c)),o(g.Provider,{value:a.current,children:t})}function S(o){const e=c(g);if(!e)throw new Error("Missing RootModuleContext.Provider in the tree");return r(e,o)}export{d as ModuleProvider,h as ModuleRootProvider,f as initPersist,a as initialValueOrder,p as useModuleContext,S as useModuleRootContext};
@@ -0,0 +1,5 @@
1
+ import { ModuleState, moduleStore } from "./commonStore";
2
+ type ModuleProviderProps = React.PropsWithChildren<Partial<moduleStore>>;
3
+ export { initialValueOrder } from "./commonStore";
4
+ export declare function ModuleProvider({ children, ...props }: ModuleProviderProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function useModuleContext<T>(selector: (state: ModuleState) => T): T;
@@ -0,0 +1,56 @@
1
+ export declare const goodListIntialValue: {
2
+ dataPic: string;
3
+ goodsName: string;
4
+ goodsCamount: number;
5
+ skuName: string;
6
+ pricesetNprice: number;
7
+ };
8
+ export declare const initialValueOrder: {
9
+ contractSettlOpno: number;
10
+ upmMap: {};
11
+ rebMoney: number;
12
+ goodsCamount: number;
13
+ shoppingCountPrice: number;
14
+ totalDiscountPrice: number;
15
+ accountsSumPrice: number;
16
+ discount: number;
17
+ freight: number;
18
+ comDisMoney: number;
19
+ copyComDisMoney: number;
20
+ shoppingType: string;
21
+ promotionCode: string;
22
+ promotionCodes: string;
23
+ };
24
+ export type addressInfo = {
25
+ freight: number;
26
+ goodsReceiptMem: string;
27
+ goodsReceiptPhone: string;
28
+ goodsReceiptArrdess: string;
29
+ areaCode: string;
30
+ };
31
+ export type moduleType = {
32
+ [v: string]: any;
33
+ _ocPoints: Array<any>;
34
+ _ocDiscount: Array<any>;
35
+ _orderAddressInfo: addressInfo;
36
+ _couponList: [];
37
+ _selectCoupon: [];
38
+ _shoppingList: Array<any>;
39
+ _contractGoodsList: Array<typeof goodListIntialValue>;
40
+ _orderDomainStr: Array<typeof initialValueOrder>;
41
+ _ocContractSettlList: Array<any>;
42
+ open?: boolean;
43
+ defaultValue?: object;
44
+ goodNum?: number;
45
+ _skuInfo?: object;
46
+ params?: object;
47
+ breadList?: [];
48
+ };
49
+ export interface moduleStore {
50
+ moduleStore: moduleType;
51
+ }
52
+ export interface ModuleState extends moduleStore {
53
+ setModuleStore: (e: Partial<moduleType>) => void;
54
+ }
55
+ export type ModuleStore = ReturnType<typeof createModuleStore>;
56
+ export declare const createModuleStore: (initProps?: Partial<moduleStore>) => import("zustand").StoreApi<ModuleState>;
@@ -0,0 +1,2 @@
1
+ export * from "./commonModule";
2
+ export * from "./rootModule";
@@ -0,0 +1,5 @@
1
+ import { ModuleRootState, moduleRootStore } from "./rootStore";
2
+ export { initPersist } from "./rootStore";
3
+ type ModuleProviderProps = React.PropsWithChildren<Partial<moduleRootStore>>;
4
+ export declare function ModuleRootProvider({ children, ...props }: ModuleProviderProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function useModuleRootContext<T>(selector: (state: ModuleRootState) => T): T;
@@ -0,0 +1,38 @@
1
+ export declare const initPersist: (Taro: any) => void;
2
+ export type moduleType = {
3
+ [v: string]: any;
4
+ safe?: number;
5
+ _historyList: Array<any>;
6
+ _themeColor: {
7
+ colorPrimary: string;
8
+ colorBgTextHover: string;
9
+ };
10
+ _orderCount: {
11
+ [v: string]: string | number;
12
+ };
13
+ _userInfo: {
14
+ [v: string]: any;
15
+ };
16
+ _cart: number;
17
+ };
18
+ export interface moduleRootStore {
19
+ rootStore: moduleType;
20
+ [v: string]: any;
21
+ }
22
+ export interface ModuleRootState extends moduleRootStore {
23
+ setModuleRootStore: (e: Partial<moduleType>) => void;
24
+ }
25
+ export type ModuleRootStore = ReturnType<typeof createRootModuleStore>;
26
+ export declare const createRootModuleStore: (initProps?: Partial<moduleRootStore>) => Omit<import("zustand").StoreApi<ModuleRootState>, "setState" | "persist"> & {
27
+ setState(partial: ModuleRootState | Partial<ModuleRootState> | ((state: ModuleRootState) => ModuleRootState | Partial<ModuleRootState>), replace?: false | undefined): unknown;
28
+ setState(state: ModuleRootState | ((state: ModuleRootState) => ModuleRootState), replace: true): unknown;
29
+ persist: {
30
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ModuleRootState, unknown, unknown>>) => void;
31
+ clearStorage: () => void;
32
+ rehydrate: () => Promise<void> | void;
33
+ hasHydrated: () => boolean;
34
+ onHydrate: (fn: (state: ModuleRootState) => void) => () => void;
35
+ onFinishHydration: (fn: (state: ModuleRootState) => void) => () => void;
36
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<ModuleRootState, unknown, unknown>>;
37
+ };
38
+ };
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@brushes/context",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
+ "start": "rollup -c --watch",
8
+ "build": "./scripts/build.sh"
7
9
  },
8
10
  "repository": {
9
11
  "type": "git",
@@ -0,0 +1,15 @@
1
+ import ts from 'rollup-plugin-typescript2';
2
+ import terser from '@rollup/plugin-terser';
3
+
4
+ export default {
5
+ input: 'src/index.ts',
6
+ output: [
7
+ {
8
+ name: '@brushes/context',
9
+ file: 'dist/index.js'
10
+ }
11
+ ],
12
+ cache: false,
13
+ external: ['react/jsx-runtime', 'zustand', 'react', 'zustand/middleware', '@brushes/utils', '@brushes/component-tool'],
14
+ plugins: [ts({}), terser()]
15
+ };