@monerium/sdk-react-provider 0.0.2 → 0.0.4
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/index.js +1 -0
- package/{dist/index.mjs → index.mjs} +416 -414
- package/{dist/lib → lib}/provider.d.ts +1 -0
- package/package.json +6 -3
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -18
- package/README.md +0 -7
- package/dist/index.js +0 -1
- package/dist/package.json +0 -12
- package/jest.config.ts +0 -11
- package/project.json +0 -46
- package/src/index.ts +0 -3
- package/src/lib/context.tsx +0 -31
- package/src/lib/hook.test.tsx +0 -88
- package/src/lib/hook.tsx +0 -10
- package/src/lib/provider.test.tsx +0 -82
- package/src/lib/provider.tsx +0 -188
- package/tsconfig.json +0 -21
- package/tsconfig.lib.json +0 -23
- package/tsconfig.spec.json +0 -20
- package/vite.config.ts +0 -43
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/lib → lib}/context.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monerium/sdk-react-provider",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"import": "./
|
|
9
|
-
"require": "./
|
|
8
|
+
"import": "./index.mjs",
|
|
9
|
+
"require": "./index.js"
|
|
10
10
|
}
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@monerium/sdk": "*"
|
|
11
14
|
}
|
|
12
15
|
}
|
package/.babelrc
DELETED
package/.eslintrc.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
|
|
3
|
-
"ignorePatterns": ["!**/*"],
|
|
4
|
-
"overrides": [
|
|
5
|
-
{
|
|
6
|
-
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
-
"rules": {}
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"files": ["*.ts", "*.tsx"],
|
|
11
|
-
"rules": {}
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"files": ["*.js", "*.jsx"],
|
|
15
|
-
"rules": {}
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
package/README.md
DELETED
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var Z=(o,e,r)=>{if(!e.has(o))throw TypeError("Cannot "+r)};var _=(o,e,r)=>(Z(o,e,"read from private field"),r?r.call(o):e.get(o)),H=(o,e,r)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,r)},O=(o,e,r,t)=>(Z(o,e,"write to private field"),t?t.call(o,r):e.set(o,r),r);var I=(o,e,r)=>(Z(o,e,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("react/jsx-runtime"),B=require("react"),oe=B.createContext(null),Y=o=>{var e;return o&&((e=Object.entries(o))==null?void 0:e.length)>0?Object.entries(o).map(([r,t])=>`${encodeURIComponent(r)}=${encodeURIComponent(t)}`).join("&"):""},he=o=>{switch(o){case 1:case 5:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${o}`)}},pe=o=>{switch(o){case 1:case 100:case 137:return"mainnet";case 5:return"goerli";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${o}`)}},ee={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}},G="monerium.sdk.code_verifier",te="monerium.sdk.refresh_token";var N=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ce(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function ve(o){if(o.__esModule)return o;var e=o.default;if(typeof e=="function"){var r=function t(){if(this instanceof t){var u=[null];u.push.apply(u,arguments);var i=Function.bind.apply(e,u);return new i}return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(o).forEach(function(t){var u=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(r,t,u.get?u:{enumerable:!0,get:function(){return o[t]}})}),r}var ue={exports:{}};function ge(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var re={exports:{}};const we={},ye=Object.freeze(Object.defineProperty({__proto__:null,default:we},Symbol.toStringTag,{value:"Module"})),me=ve(ye);var se;function le(){return se||(se=1,function(o,e){(function(r,t){o.exports=t()})(N,function(){var r=r||function(t,u){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof N<"u"&&N.crypto&&(i=N.crypto),!i&&typeof ge=="function")try{i=me}catch{}var v=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},b=Object.create||function(){function n(){}return function(s){var a;return n.prototype=s,a=new n,n.prototype=null,a}}(),p={},w=p.lib={},y=w.Base=function(){return{extend:function(n){var s=b(this);return n&&s.mixIn(n),(!s.hasOwnProperty("init")||this.init===s.init)&&(s.init=function(){s.$super.init.apply(this,arguments)}),s.init.prototype=s,s.$super=this,s},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var s in n)n.hasOwnProperty(s)&&(this[s]=n[s]);n.hasOwnProperty("toString")&&(this.toString=n.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=w.WordArray=y.extend({init:function(n,s){n=this.words=n||[],s!=u?this.sigBytes=s:this.sigBytes=n.length*4},toString:function(n){return(n||f).stringify(this)},concat:function(n){var s=this.words,a=n.words,l=this.sigBytes,m=n.sigBytes;if(this.clamp(),l%4)for(var k=0;k<m;k++){var C=a[k>>>2]>>>24-k%4*8&255;s[l+k>>>2]|=C<<24-(l+k)%4*8}else for(var x=0;x<m;x+=4)s[l+x>>>2]=a[x>>>2];return this.sigBytes+=m,this},clamp:function(){var n=this.words,s=this.sigBytes;n[s>>>2]&=4294967295<<32-s%4*8,n.length=t.ceil(s/4)},clone:function(){var n=y.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var s=[],a=0;a<n;a+=4)s.push(v());return new g.init(s,n)}}),S=p.enc={},f=S.Hex={stringify:function(n){for(var s=n.words,a=n.sigBytes,l=[],m=0;m<a;m++){var k=s[m>>>2]>>>24-m%4*8&255;l.push((k>>>4).toString(16)),l.push((k&15).toString(16))}return l.join("")},parse:function(n){for(var s=n.length,a=[],l=0;l<s;l+=2)a[l>>>3]|=parseInt(n.substr(l,2),16)<<24-l%8*4;return new g.init(a,s/2)}},h=S.Latin1={stringify:function(n){for(var s=n.words,a=n.sigBytes,l=[],m=0;m<a;m++){var k=s[m>>>2]>>>24-m%4*8&255;l.push(String.fromCharCode(k))}return l.join("")},parse:function(n){for(var s=n.length,a=[],l=0;l<s;l++)a[l>>>2]|=(n.charCodeAt(l)&255)<<24-l%4*8;return new g.init(a,s)}},c=S.Utf8={stringify:function(n){try{return decodeURIComponent(escape(h.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return h.parse(unescape(encodeURIComponent(n)))}},d=w.BufferedBlockAlgorithm=y.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(n){typeof n=="string"&&(n=c.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes},_process:function(n){var s,a=this._data,l=a.words,m=a.sigBytes,k=this.blockSize,C=k*4,x=m/C;n?x=t.ceil(x):x=t.max((x|0)-this._minBufferSize,0);var D=x*k,U=t.min(D*4,m);if(D){for(var q=0;q<D;q+=k)this._doProcessBlock(l,q);s=l.splice(0,D),a.sigBytes-=U}return new g.init(s,U)},clone:function(){var n=y.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});w.Hasher=d.extend({cfg:y.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var s=this._doFinalize();return s},blockSize:16,_createHelper:function(n){return function(s,a){return new n.init(a).finalize(s)}},_createHmacHelper:function(n){return function(s,a){return new A.HMAC.init(n,a).finalize(s)}}});var A=p.algo={};return p}(Math);return r})}(re)),re.exports}(function(o,e){(function(r,t){o.exports=t(le())})(N,function(r){return function(){var t=r,u=t.lib,i=u.WordArray,v=t.enc;v.Base64url={stringify:function(p,w){w===void 0&&(w=!0);var y=p.words,g=p.sigBytes,S=w?this._safe_map:this._map;p.clamp();for(var f=[],h=0;h<g;h+=3)for(var c=y[h>>>2]>>>24-h%4*8&255,d=y[h+1>>>2]>>>24-(h+1)%4*8&255,A=y[h+2>>>2]>>>24-(h+2)%4*8&255,n=c<<16|d<<8|A,s=0;s<4&&h+s*.75<g;s++)f.push(S.charAt(n>>>6*(3-s)&63));var a=S.charAt(64);if(a)for(;f.length%4;)f.push(a);return f.join("")},parse:function(p,w){w===void 0&&(w=!0);var y=p.length,g=w?this._safe_map:this._map,S=this._reverseMap;if(!S){S=this._reverseMap=[];for(var f=0;f<g.length;f++)S[g.charCodeAt(f)]=f}var h=g.charAt(64);if(h){var c=p.indexOf(h);c!==-1&&(y=c)}return b(p,y,S)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function b(p,w,y){for(var g=[],S=0,f=0;f<w;f++)if(f%4){var h=y[p.charCodeAt(f-1)]<<f%4*2,c=y[p.charCodeAt(f)]>>>6-f%4*2,d=h|c;g[S>>>2]|=d<<24-S%4*8,S++}return i.create(g,S)}}(),r.enc.Base64url})})(ue);var _e=ue.exports;const be=ce(_e);var fe={exports:{}};(function(o,e){(function(r,t){o.exports=t(le())})(N,function(r){return function(t){var u=r,i=u.lib,v=i.WordArray,b=i.Hasher,p=u.algo,w=[],y=[];(function(){function f(A){for(var n=t.sqrt(A),s=2;s<=n;s++)if(!(A%s))return!1;return!0}function h(A){return(A-(A|0))*4294967296|0}for(var c=2,d=0;d<64;)f(c)&&(d<8&&(w[d]=h(t.pow(c,1/2))),y[d]=h(t.pow(c,1/3)),d++),c++})();var g=[],S=p.SHA256=b.extend({_doReset:function(){this._hash=new v.init(w.slice(0))},_doProcessBlock:function(f,h){for(var c=this._hash.words,d=c[0],A=c[1],n=c[2],s=c[3],a=c[4],l=c[5],m=c[6],k=c[7],C=0;C<64;C++){if(C<16)g[C]=f[h+C]|0;else{var x=g[C-15],D=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,U=g[C-2],q=(U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10;g[C]=D+g[C-7]+q+g[C-16]}var E=a&l^~a&m,z=d&A^d&n^A&n,L=(d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22),V=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),W=k+V+E+y[C]+g[C],j=L+z;k=m,m=l,l=a,a=s+W|0,s=n,n=A,A=d,d=W+j|0}c[0]=c[0]+d|0,c[1]=c[1]+A|0,c[2]=c[2]+n|0,c[3]=c[3]+s|0,c[4]=c[4]+a|0,c[5]=c[5]+l|0,c[6]=c[6]+m|0,c[7]=c[7]+k|0},_doFinalize:function(){var f=this._data,h=f.words,c=this._nDataBytes*8,d=f.sigBytes*8;return h[d>>>5]|=128<<24-d%32,h[(d+64>>>9<<4)+14]=t.floor(c/4294967296),h[(d+64>>>9<<4)+15]=c,f.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var f=b.clone.call(this);return f._hash=this._hash.clone(),f}});u.SHA256=b._createHelper(S),u.HmacSHA256=b._createHmacHelper(S)}(Math),r.SHA256})})(fe);var Se=fe.exports;const ke=ce(Se),Be=(o,e)=>{const{client_id:r,redirect_uri:t,scope:u,state:i,chainId:v,chain:b,network:p,address:w,signature:y}=o,g=w?{address:w,...y!==void 0?{signature:y}:{},...v!==void 0||b!==void 0?{chain:v?he(v):b}:{},...v!==void 0||p!==void 0?{network:v?pe(v):p}:{}}:{};return Y({client_id:r,redirect_uri:t,...u!==void 0?{scope:u}:{},...i!==void 0?{state:i}:{},code_challenge:e,code_challenge_method:"S256",response_type:"code",...g})},Ce=()=>{let o="";const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=e.length;let t=0;for(;t<128;)o+=e.charAt(Math.floor(Math.random()*r)),t+=1;return o},xe=o=>be.stringify(ke(o)),ie=(o,e)=>{const r=Ce(),t=xe(r);return sessionStorage.setItem(G,r||""),`${o}/auth?${Be(e,t)}`},Ee=()=>{const o=window.location.href,[e,r]=o.split("?");r&&window.history.replaceState(null,"",e)},ae=o=>o.code!=null,Ae=o=>o.refresh_token!=null,Pe=o=>o.client_secret!=null,Oe=async(o,e,r,t)=>{const u=await fetch(`${o}`,{method:e,headers:t,body:r});let i;const v=await u.text();try{i=JSON.parse(v)}catch{throw v}if(!u.ok)throw i;return i},ne=typeof window>"u";var T,J,F,M,$,P,R,K,Q,X;class Ie{constructor(e){H(this,P);H(this,T,void 0);H(this,J,void 0);H(this,F,void 0);H(this,M,void 0);H(this,$,void 0);H(this,K,void 0);H(this,Q,void 0);H(this,X,void 0);if(O(this,M,new Map),this.isAuthorized=!!this.bearerProfile,O(this,K,async(r,t,u)=>{const i=sessionStorage.getItem(G)||"";if(!i)throw new Error("Code verifier not found");return this.codeVerifier=i,sessionStorage.removeItem(G),await this.getBearerToken({code:u,redirect_uri:t,client_id:r,code_verifier:i})}),O(this,Q,async({clientId:r,clientSecret:t})=>await this.getBearerToken({client_id:r,client_secret:t})),O(this,X,async(r,t)=>await this.getBearerToken({refresh_token:t,client_id:r})),this.subscribeToOrderNotifications=()=>{var u,i;const r=`${_(this,T).wss}/profiles/${(u=this.bearerProfile)==null?void 0:u.profile}/orders?access_token=${(i=this.bearerProfile)==null?void 0:i.access_token}`,t=new WebSocket(r);return t.addEventListener("open",()=>{console.info(`Socket connected: ${r}`)}),t.addEventListener("error",v=>{throw console.error(v),new Error(`Socket error: ${r}`)}),t.addEventListener("message",v=>{var p;const b=JSON.parse(v.data);(p=_(this,M).get(b.meta.state))==null||p(b)}),t.addEventListener("close",()=>{console.info(`Socket connection closed: ${r}`)}),t},this.auth=async r=>await this.getBearerToken(r),this.getAuthFlowURI=r=>ie(_(this,T).api,r),this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>_(this,T),!e){O(this,T,ee.environments.sandbox);return}if(typeof e=="string")O(this,T,ee.environments[e]);else if(O(this,T,ee.environments[e.env||"sandbox"]),ne){const{clientId:r,clientSecret:t}=e;O(this,$,{clientId:r,clientSecret:t})}else{const{clientId:r,redirectUrl:t}=e;O(this,$,{clientId:r,redirectUrl:t})}}async authorize(e){var i,v;const r=(e==null?void 0:e.clientId)||((i=_(this,$))==null?void 0:i.clientId),t=(e==null?void 0:e.redirectUrl)||((v=_(this,$))==null?void 0:v.redirectUrl);if(!r)throw new Error("Missing ClientId");if(!t)throw new Error("Missing RedirectUrl");const u=ie(_(this,T).api,{client_id:r,redirect_uri:t,...e==null?void 0:e.wallet});window.location.replace(u)}async connect(e){var b,p,w;const r=(e==null?void 0:e.clientId)||((b=_(this,$))==null?void 0:b.clientId);if((e==null?void 0:e.clientSecret)||((p=_(this,$))==null?void 0:p.clientSecret)){if(!ne)throw new Error("Only use client credentials on server side");return await _(this,Q).call(this,_(this,$)),!!this.bearerProfile}const u=(e==null?void 0:e.redirectUrl)||((w=_(this,$))==null?void 0:w.redirectUrl);if(!r)throw new Error("Missing ClientId");if(ne)throw new Error("This only works on client side");const i=new URLSearchParams(window.location.search).get("code")||void 0,v=sessionStorage.getItem(te)||void 0;return i?await _(this,K).call(this,r,u,i):v&&await _(this,X).call(this,r,v),!!this.bearerProfile}async getBearerToken(e){let r;if(ae(e))r={...e,grant_type:"authorization_code"};else if(Ae(e))r={...e,grant_type:"refresh_token"};else if(Pe(e))r={...e,grant_type:"client_credentials"};else throw new Error("Authentication method could not be detected.");return await I(this,P,R).call(this,"post","auth/token",r,!0).then(t=>{var u;this.bearerProfile=t,this.isAuthorized=!!t,O(this,J,`Bearer ${t==null?void 0:t.access_token}`),window.sessionStorage.setItem(te,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(t=>{throw sessionStorage.removeItem(G),sessionStorage.removeItem(te),new Error(t==null?void 0:t.message)}),ae(e)&&Ee(),this.bearerProfile}getAuthContext(){return I(this,P,R).call(this,"get","auth/context")}getProfile(e){return I(this,P,R).call(this,"get",`profiles/${e}`)}getBalances(e){return e?I(this,P,R).call(this,"get",`profiles/${e}/balances`):I(this,P,R).call(this,"get","balances")}getOrders(e){const r=Y(e);return I(this,P,R).call(this,"get",`orders?${r}`)}getOrder(e){return I(this,P,R).call(this,"get",`orders/${e}`)}getTokens(){return I(this,P,R).call(this,"get","tokens")}linkAddress(e,r){return I(this,P,R).call(this,"post",`profiles/${e}/addresses`,JSON.stringify(r))}placeOrder(e,r){const t={...e,kind:"redeem",currency:"eur"};return r?I(this,P,R).call(this,"post",`profiles/${r}/orders`,JSON.stringify(t)):I(this,P,R).call(this,"post","orders",JSON.stringify(t))}uploadSupportingDocument(e){const r=Y(e);return I(this,P,R).call(this,"post","files/supporting-document",r,!0)}async connectOrderSocket(){var e;(e=this.bearerProfile)!=null&&e.access_token&&_(this,M).size>0&&O(this,F,this.subscribeToOrderNotifications())}async disconnect(){var e;sessionStorage.removeItem(G),_(this,M).clear(),(e=_(this,F))==null||e.close()}subscribeOrders(e,r){_(this,M).set(e,r)}unsubscribeOrders(e){var r;_(this,M).delete(e),_(this,M).size===0&&((r=_(this,F))==null||r.close(),O(this,F,void 0))}}T=new WeakMap,J=new WeakMap,F=new WeakMap,M=new WeakMap,$=new WeakMap,P=new WeakSet,R=async function(e,r,t,u){return Oe(`${_(this,T).api}/${r}`,e,u?Y(t):t,{Authorization:_(this,J)||"","Content-Type":`application/${u?"x-www-form-urlencoded":"json"}`})},K=new WeakMap,Q=new WeakMap,X=new WeakMap;const Re=({children:o,clientId:e="f99e629b-6dca-11ee-8aa6-5273f65ed05b",redirectUrl:r="http://localhost:5173"})=>{const[t,u]=B.useState(),[i,v]=B.useState(!1),[b,p]=B.useState(null),[w,y]=B.useState(null),[g,S]=B.useState(!1),[f,h]=B.useState(!1),[c,d]=B.useState(!1),[A,n]=B.useState(!1),[s,a]=B.useState(null),[l,m]=B.useState([]),[k,C]=B.useState([]);B.useEffect(()=>{const E=new Ie({clientId:e,redirectUrl:r});u(E)},[]),B.useEffect(()=>((async()=>{t&&v(await t.connect())})(),()=>{t&&t.disconnect()}),[t]),B.useEffect(()=>{(async()=>{if(t&&i)try{S(!0);const z=await t.getAuthContext(),L=await t.getProfile(z.defaultProfile),V=await t.getBalances(),W=await t.getOrders(),j=await t.getTokens();p(L),y(V),m(W),C(j)}catch(z){console.error("Error fetching data:",z),a(z)}finally{S(!1)}})()},[t,i]);const x=B.useCallback(async()=>{try{t&&await t.authorize()}catch(E){console.error("Error during authorization:",E),a(E)}},[t]),D=B.useCallback(async()=>{if(t&&i)try{n(!0);const E=await t.getBalances();y(E)}catch(E){console.error("Error getting balances:",E),a(E)}finally{n(!1)}},[t,i]),U=B.useCallback(async(E,z)=>{if(t&&i)try{h(!0);let L;parseInt(E.amount)>15e3&&z&&(L=(await t.uploadSupportingDocument(z)).id);const V={...E,documentId:L},W=await t.placeOrder(V);m(j=>[...j,W])}catch(L){console.error("Error placing order:",L),a(L)}finally{h(!1)}},[t,i]),q=B.useCallback(async E=>{if(t&&i&&b)try{return d(!0),await t.linkAddress(b.id,E)}catch(z){console.error("Error linking address:",z),a(z)}finally{d(!1)}},[t,i,b]);return de.jsx(oe.Provider,{value:{authorize:x,isAuthorized:i,profile:b,balances:w,loading:g,loadingPlaceOrder:f,loadingLinkAddress:c,loadingBalances:A,getBalances:D,linkAddress:q,placeOrder:U,orders:l,tokens:k,error:s},children:o})};function ze(){const o=B.useContext(oe);if(o===null)throw new Error("useMonerium must be used within a MoneriumProvider");return o}exports.MoneriumContext=oe;exports.MoneriumProvider=Re;exports.useMonerium=ze;
|
package/dist/package.json
DELETED
package/jest.config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
export default {
|
|
3
|
-
displayName: 'sdk-react-provider',
|
|
4
|
-
preset: '../../jest.preset.js',
|
|
5
|
-
transform: {
|
|
6
|
-
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
|
|
7
|
-
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
|
|
8
|
-
},
|
|
9
|
-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
10
|
-
coverageDirectory: '../../coverage/libs/sdk-react-provider',
|
|
11
|
-
};
|
package/project.json
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sdk-react-provider",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "libs/sdk-react-provider/src",
|
|
5
|
-
"projectType": "library",
|
|
6
|
-
"tags": [],
|
|
7
|
-
"targets": {
|
|
8
|
-
"lint": {
|
|
9
|
-
"executor": "@nx/eslint:lint",
|
|
10
|
-
"outputs": ["{options.outputFile}"],
|
|
11
|
-
"options": {
|
|
12
|
-
"lintFilePatterns": ["libs/sdk-react-provider/**/*.{ts,tsx,js,jsx}"]
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"build": {
|
|
16
|
-
"executor": "@nx/vite:build",
|
|
17
|
-
"outputs": ["{options.outputPath}"],
|
|
18
|
-
"defaultConfiguration": "production",
|
|
19
|
-
"options": {
|
|
20
|
-
"outputPath": "libs/sdk-react-provider/dist"
|
|
21
|
-
},
|
|
22
|
-
"configurations": {
|
|
23
|
-
"development": {
|
|
24
|
-
"mode": "development"
|
|
25
|
-
},
|
|
26
|
-
"production": {
|
|
27
|
-
"mode": "production"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"test": {
|
|
32
|
-
"executor": "@nx/jest:jest",
|
|
33
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
34
|
-
"options": {
|
|
35
|
-
"jestConfig": "libs/sdk-react-provider/jest.config.ts",
|
|
36
|
-
"passWithNoTests": true
|
|
37
|
-
},
|
|
38
|
-
"configurations": {
|
|
39
|
-
"ci": {
|
|
40
|
-
"ci": true,
|
|
41
|
-
"codeCoverage": true
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
package/src/index.ts
DELETED
package/src/lib/context.tsx
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Profile,
|
|
4
|
-
Balances,
|
|
5
|
-
LinkAddress,
|
|
6
|
-
Order,
|
|
7
|
-
NewOrder,
|
|
8
|
-
Token,
|
|
9
|
-
} from '@monerium/sdk';
|
|
10
|
-
|
|
11
|
-
interface MoneriumContextValue {
|
|
12
|
-
authorize: () => Promise<void>;
|
|
13
|
-
isAuthorized: boolean;
|
|
14
|
-
profile: Profile | null;
|
|
15
|
-
balances: Balances[] | null;
|
|
16
|
-
loading: boolean;
|
|
17
|
-
loadingPlaceOrder: boolean;
|
|
18
|
-
loadingLinkAddress: boolean;
|
|
19
|
-
loadingBalances: boolean;
|
|
20
|
-
getBalances: () => Promise<void>;
|
|
21
|
-
linkAddress: (addressDetails: LinkAddress) => Promise<unknown>;
|
|
22
|
-
placeOrder: (
|
|
23
|
-
orderDetails: NewOrder,
|
|
24
|
-
supportingDocument?: File
|
|
25
|
-
) => Promise<void>;
|
|
26
|
-
orders: Order[];
|
|
27
|
-
tokens: Token[];
|
|
28
|
-
error: unknown;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const MoneriumContext = createContext<MoneriumContextValue | null>(null);
|
package/src/lib/hook.test.tsx
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, waitFor, act } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { useMonerium } from './hook';
|
|
5
|
-
import { MoneriumProvider } from './provider';
|
|
6
|
-
import { MoneriumClient } from '@monerium/sdk';
|
|
7
|
-
|
|
8
|
-
jest.mock('@monerium/sdk', () => {
|
|
9
|
-
const mockMoneriumClient = {
|
|
10
|
-
authorize: jest.fn().mockResolvedValue(true),
|
|
11
|
-
connect: jest.fn().mockResolvedValue(true),
|
|
12
|
-
disconnect: jest.fn(),
|
|
13
|
-
getAuthContext: jest
|
|
14
|
-
.fn()
|
|
15
|
-
.mockResolvedValue({ defaultProfile: 'defaultProfile' }),
|
|
16
|
-
getProfile: jest.fn().mockResolvedValue({
|
|
17
|
-
name: 'John Doe',
|
|
18
|
-
}),
|
|
19
|
-
getBalances: jest.fn().mockResolvedValue([
|
|
20
|
-
/* mock balance data */
|
|
21
|
-
]),
|
|
22
|
-
getOrders: jest.fn().mockResolvedValue([
|
|
23
|
-
/* mock order data */
|
|
24
|
-
]),
|
|
25
|
-
getTokens: jest.fn().mockResolvedValue([
|
|
26
|
-
/* mock token data */
|
|
27
|
-
]),
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
MoneriumClient: jest.fn(() => mockMoneriumClient),
|
|
32
|
-
MoneriumContext: jest.fn(() => null),
|
|
33
|
-
// mock other exports as needed
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Mock Test Consumer Component
|
|
38
|
-
const TestConsumerComponent = () => {
|
|
39
|
-
const context = useMonerium();
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<div>
|
|
43
|
-
<p data-testid="context">{JSON.stringify(context)}</p>
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
describe('useMonerium', () => {
|
|
49
|
-
test('returns the context value when used within a MoneriumProvider', async () => {
|
|
50
|
-
await act(async () => {
|
|
51
|
-
render(
|
|
52
|
-
<MoneriumProvider>
|
|
53
|
-
<TestConsumerComponent />
|
|
54
|
-
</MoneriumProvider>
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
await waitFor(() =>
|
|
59
|
-
expect(screen.getByTestId('context')).toHaveTextContent(
|
|
60
|
-
JSON.stringify({
|
|
61
|
-
isAuthorized: true,
|
|
62
|
-
profile: { name: 'John Doe' },
|
|
63
|
-
balances: [],
|
|
64
|
-
loading: false,
|
|
65
|
-
loadingPlaceOrder: false,
|
|
66
|
-
loadingLinkAddress: false,
|
|
67
|
-
loadingBalances: false,
|
|
68
|
-
orders: [],
|
|
69
|
-
tokens: [],
|
|
70
|
-
error: null,
|
|
71
|
-
})
|
|
72
|
-
)
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('throws an error when used outside a MoneriumProvider', () => {
|
|
77
|
-
// Suppress console error for this test
|
|
78
|
-
const consoleError = console.error;
|
|
79
|
-
console.error = jest.fn();
|
|
80
|
-
|
|
81
|
-
expect(() => render(<TestConsumerComponent />)).toThrow(
|
|
82
|
-
'useMonerium must be used within a MoneriumProvider'
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// Restore console error
|
|
86
|
-
console.error = consoleError;
|
|
87
|
-
});
|
|
88
|
-
});
|
package/src/lib/hook.tsx
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { MoneriumContext } from './context';
|
|
3
|
-
|
|
4
|
-
export function useMonerium() {
|
|
5
|
-
const context = useContext(MoneriumContext);
|
|
6
|
-
if (context === null) {
|
|
7
|
-
throw new Error('useMonerium must be used within a MoneriumProvider');
|
|
8
|
-
}
|
|
9
|
-
return context;
|
|
10
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { MoneriumProvider } from './provider';
|
|
5
|
-
import { useMonerium } from './hook';
|
|
6
|
-
import { MoneriumClient } from '@monerium/sdk';
|
|
7
|
-
|
|
8
|
-
jest.mock('@monerium/sdk', () => {
|
|
9
|
-
const mockMoneriumClient = {
|
|
10
|
-
authorize: jest.fn().mockResolvedValue(true),
|
|
11
|
-
connect: jest.fn().mockResolvedValue(true),
|
|
12
|
-
disconnect: jest.fn(),
|
|
13
|
-
getAuthContext: jest
|
|
14
|
-
.fn()
|
|
15
|
-
.mockResolvedValue({ defaultProfile: 'defaultProfile' }),
|
|
16
|
-
getProfile: jest.fn().mockResolvedValue({
|
|
17
|
-
name: 'John Doe',
|
|
18
|
-
}),
|
|
19
|
-
getBalances: jest.fn().mockResolvedValue([
|
|
20
|
-
/* mock balance data */
|
|
21
|
-
]),
|
|
22
|
-
getOrders: jest.fn().mockResolvedValue([
|
|
23
|
-
/* mock order data */
|
|
24
|
-
]),
|
|
25
|
-
getTokens: jest.fn().mockResolvedValue([
|
|
26
|
-
/* mock token data */
|
|
27
|
-
]),
|
|
28
|
-
// mock other methods as needed
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
MoneriumClient: jest.fn(() => mockMoneriumClient),
|
|
33
|
-
// mock other exports as needed
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
// Mock Test Consumer Component
|
|
37
|
-
const TestConsumerComponent = () => {
|
|
38
|
-
const {
|
|
39
|
-
authorize,
|
|
40
|
-
isAuthorized,
|
|
41
|
-
profile,
|
|
42
|
-
// include other pieces of context you want to test
|
|
43
|
-
} = useMonerium();
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div>
|
|
47
|
-
<button onClick={authorize}>Authorize</button>
|
|
48
|
-
{isAuthorized && <p>Authorized!</p>}
|
|
49
|
-
{profile && <p data-testid="profile">{profile.name}</p>}
|
|
50
|
-
{/* You can add more elements for other context values */}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
describe('MoneriumProvider', () => {
|
|
56
|
-
test('provides context to consumer and allows function calls', async () => {
|
|
57
|
-
render(
|
|
58
|
-
<MoneriumProvider>
|
|
59
|
-
<TestConsumerComponent />
|
|
60
|
-
</MoneriumProvider>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// Test initial state
|
|
64
|
-
expect(screen.queryByText('Authorized!')).toBeNull();
|
|
65
|
-
|
|
66
|
-
// Simulate button click to authorize
|
|
67
|
-
screen.getByRole('button', { name: /authorize/i }).click();
|
|
68
|
-
|
|
69
|
-
// Test if authorize function has been called
|
|
70
|
-
await waitFor(() =>
|
|
71
|
-
expect(screen.getByText('Authorized!')).toBeInTheDocument()
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
// Test if profile data is present
|
|
75
|
-
await waitFor(() => {
|
|
76
|
-
expect(screen.getByTestId('profile')).toBeInTheDocument();
|
|
77
|
-
expect(screen.getByTestId('profile')).toHaveTextContent('John Doe');
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// Add more tests for other functions and state changes
|
|
82
|
-
});
|
package/src/lib/provider.tsx
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, FC, useEffect, useState, ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import { MoneriumContext } from './context';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
MoneriumClient,
|
|
7
|
-
LinkAddress,
|
|
8
|
-
Profile,
|
|
9
|
-
Balances,
|
|
10
|
-
Order,
|
|
11
|
-
NewOrder,
|
|
12
|
-
Token,
|
|
13
|
-
} from '@monerium/sdk';
|
|
14
|
-
|
|
15
|
-
interface MoneriumProviderProps {
|
|
16
|
-
children: ReactNode;
|
|
17
|
-
clientId?: string;
|
|
18
|
-
redirectUrl?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const MoneriumProvider: FC<MoneriumProviderProps> = ({
|
|
22
|
-
children,
|
|
23
|
-
clientId = 'f99e629b-6dca-11ee-8aa6-5273f65ed05b',
|
|
24
|
-
redirectUrl = 'http://localhost:5173',
|
|
25
|
-
}) => {
|
|
26
|
-
const [monerium, setMonerium] = useState<MoneriumClient>();
|
|
27
|
-
const [isAuthorized, setIsAuthorized] = useState<boolean>(false);
|
|
28
|
-
const [profile, setProfile] = useState<Profile | null>(null);
|
|
29
|
-
const [balances, setBalances] = useState<Balances[] | null>(null);
|
|
30
|
-
const [loading, setLoading] = useState(false);
|
|
31
|
-
const [loadingPlaceOrder, setLoadingPlaceOrder] = useState(false);
|
|
32
|
-
const [loadingLinkAddress, setLoadingLinkAddress] = useState(false);
|
|
33
|
-
const [loadingBalances, setLoadingBalances] = useState(false);
|
|
34
|
-
const [error, setError] = useState<Error | unknown | null>(null);
|
|
35
|
-
const [orders, setOrders] = useState<Order[]>([]);
|
|
36
|
-
const [tokens, setTokens] = useState<Token[]>([]);
|
|
37
|
-
|
|
38
|
-
// Initialize the SDK
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const sdk = new MoneriumClient({
|
|
41
|
-
clientId,
|
|
42
|
-
redirectUrl,
|
|
43
|
-
});
|
|
44
|
-
setMonerium(sdk);
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const connect = async () => {
|
|
49
|
-
if (monerium) {
|
|
50
|
-
setIsAuthorized(await monerium.connect());
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
connect();
|
|
55
|
-
|
|
56
|
-
return () => {
|
|
57
|
-
if (monerium) {
|
|
58
|
-
monerium.disconnect();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}, [monerium]);
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const fetchData = async () => {
|
|
65
|
-
if (monerium && isAuthorized) {
|
|
66
|
-
try {
|
|
67
|
-
setLoading(true);
|
|
68
|
-
const authCtx = await monerium.getAuthContext();
|
|
69
|
-
const profileData = await monerium.getProfile(authCtx.defaultProfile);
|
|
70
|
-
const balanceData = await monerium.getBalances();
|
|
71
|
-
const ordersData = await monerium.getOrders();
|
|
72
|
-
const tokensData = await monerium.getTokens();
|
|
73
|
-
setProfile(profileData);
|
|
74
|
-
setBalances(balanceData);
|
|
75
|
-
setOrders(ordersData);
|
|
76
|
-
setTokens(tokensData);
|
|
77
|
-
} catch (err) {
|
|
78
|
-
console.error('Error fetching data:', err);
|
|
79
|
-
setError(err);
|
|
80
|
-
} finally {
|
|
81
|
-
setLoading(false);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
fetchData();
|
|
87
|
-
}, [monerium, isAuthorized]);
|
|
88
|
-
|
|
89
|
-
const authorize = useCallback(async () => {
|
|
90
|
-
try {
|
|
91
|
-
if (monerium) {
|
|
92
|
-
await monerium.authorize();
|
|
93
|
-
}
|
|
94
|
-
} catch (err) {
|
|
95
|
-
console.error('Error during authorization:', err);
|
|
96
|
-
setError(err);
|
|
97
|
-
}
|
|
98
|
-
}, [monerium]);
|
|
99
|
-
|
|
100
|
-
const getBalances = useCallback(async () => {
|
|
101
|
-
if (monerium && isAuthorized) {
|
|
102
|
-
try {
|
|
103
|
-
setLoadingBalances(true);
|
|
104
|
-
const balances = await monerium.getBalances();
|
|
105
|
-
setBalances(balances);
|
|
106
|
-
} catch (err) {
|
|
107
|
-
console.error('Error getting balances:', err);
|
|
108
|
-
setError(err);
|
|
109
|
-
} finally {
|
|
110
|
-
setLoadingBalances(false);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, [monerium, isAuthorized]);
|
|
114
|
-
|
|
115
|
-
const placeOrder = useCallback(
|
|
116
|
-
async (orderDetails: NewOrder, supportingDocument?: File) => {
|
|
117
|
-
if (monerium && isAuthorized) {
|
|
118
|
-
try {
|
|
119
|
-
setLoadingPlaceOrder(true);
|
|
120
|
-
|
|
121
|
-
let documentId;
|
|
122
|
-
if (parseInt(orderDetails.amount) > 15000 && supportingDocument) {
|
|
123
|
-
const uploadedDocument = await monerium.uploadSupportingDocument(
|
|
124
|
-
supportingDocument
|
|
125
|
-
);
|
|
126
|
-
documentId = uploadedDocument.id;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const newOrderDetails = {
|
|
130
|
-
...orderDetails,
|
|
131
|
-
documentId: documentId,
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const newOrder = await monerium.placeOrder(newOrderDetails);
|
|
135
|
-
setOrders((prevOrders) => [...prevOrders, newOrder]);
|
|
136
|
-
} catch (err) {
|
|
137
|
-
console.error('Error placing order:', err);
|
|
138
|
-
setError(err);
|
|
139
|
-
} finally {
|
|
140
|
-
setLoadingPlaceOrder(false);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
[monerium, isAuthorized]
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
const linkAddress = useCallback(
|
|
148
|
-
async (addressDetails: LinkAddress) => {
|
|
149
|
-
if (monerium && isAuthorized && profile) {
|
|
150
|
-
try {
|
|
151
|
-
setLoadingLinkAddress(true);
|
|
152
|
-
return await monerium.linkAddress(profile.id, addressDetails);
|
|
153
|
-
|
|
154
|
-
// Update your state or do something with linkedAddress
|
|
155
|
-
} catch (err) {
|
|
156
|
-
console.error('Error linking address:', err);
|
|
157
|
-
setError(err);
|
|
158
|
-
} finally {
|
|
159
|
-
setLoadingLinkAddress(false);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
[monerium, isAuthorized, profile]
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
<MoneriumContext.Provider
|
|
168
|
-
value={{
|
|
169
|
-
authorize,
|
|
170
|
-
isAuthorized,
|
|
171
|
-
profile,
|
|
172
|
-
balances,
|
|
173
|
-
loading,
|
|
174
|
-
loadingPlaceOrder,
|
|
175
|
-
loadingLinkAddress,
|
|
176
|
-
loadingBalances,
|
|
177
|
-
getBalances,
|
|
178
|
-
linkAddress,
|
|
179
|
-
placeOrder,
|
|
180
|
-
orders,
|
|
181
|
-
tokens,
|
|
182
|
-
error,
|
|
183
|
-
}}
|
|
184
|
-
>
|
|
185
|
-
{children}
|
|
186
|
-
</MoneriumContext.Provider>
|
|
187
|
-
);
|
|
188
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"jsx": "react-jsx",
|
|
4
|
-
"allowJs": false,
|
|
5
|
-
"esModuleInterop": false,
|
|
6
|
-
"allowSyntheticDefaultImports": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"types": ["vite/client"]
|
|
9
|
-
},
|
|
10
|
-
"files": [],
|
|
11
|
-
"include": [],
|
|
12
|
-
"references": [
|
|
13
|
-
{
|
|
14
|
-
"path": "./tsconfig.lib.json"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"path": "./tsconfig.spec.json"
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"extends": "../../tsconfig.base.json"
|
|
21
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"types": [
|
|
6
|
-
"node",
|
|
7
|
-
"@nx/react/typings/cssmodule.d.ts",
|
|
8
|
-
"@nx/react/typings/image.d.ts",
|
|
9
|
-
"vite/client"
|
|
10
|
-
]
|
|
11
|
-
},
|
|
12
|
-
"exclude": [
|
|
13
|
-
"**/*.spec.ts",
|
|
14
|
-
"**/*.test.ts",
|
|
15
|
-
"**/*.spec.tsx",
|
|
16
|
-
"**/*.test.tsx",
|
|
17
|
-
"**/*.spec.js",
|
|
18
|
-
"**/*.test.js",
|
|
19
|
-
"**/*.spec.jsx",
|
|
20
|
-
"**/*.test.jsx"
|
|
21
|
-
],
|
|
22
|
-
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
23
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"types": ["jest", "node"]
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"jest.config.ts",
|
|
10
|
-
"src/**/*.test.ts",
|
|
11
|
-
"src/**/*.spec.ts",
|
|
12
|
-
"src/**/*.test.tsx",
|
|
13
|
-
"src/**/*.spec.tsx",
|
|
14
|
-
"src/**/*.test.js",
|
|
15
|
-
"src/**/*.spec.js",
|
|
16
|
-
"src/**/*.test.jsx",
|
|
17
|
-
"src/**/*.spec.jsx",
|
|
18
|
-
"src/**/*.d.ts"
|
|
19
|
-
]
|
|
20
|
-
}
|