@brushes/context 0.0.6 → 0.0.8

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/package.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "@brushes/context",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
- "start": "rollup -c --watch",
8
- "build": "./scripts/build.sh"
9
7
  },
10
8
  "repository": {
11
9
  "type": "git",
package/dist/index.js DELETED
@@ -1 +0,0 @@
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};
@@ -1,5 +0,0 @@
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;
@@ -1,38 +0,0 @@
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/rollup.config.js DELETED
@@ -1,15 +0,0 @@
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
- };