@intoss/shared 0.0.1 → 0.0.3
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/dist/advertisement/index.cjs +1 -1
- package/dist/advertisement/index.d.cts +0 -1
- package/dist/advertisement/index.d.ts +0 -1
- package/dist/advertisement/index.js +1 -1
- package/dist/auth-state/index.cjs +1 -0
- package/dist/auth-state/index.d.cts +20 -0
- package/dist/auth-state/index.d.ts +20 -0
- package/dist/auth-state/index.js +1 -0
- package/dist/chunk-HANNZE3T.js +1 -0
- package/dist/chunk-HSSVYUEL.js +1 -0
- package/dist/chunk-R22ZR6YP.js +1 -0
- package/dist/config/index.cjs +1 -0
- package/dist/config/index.d.cts +12 -0
- package/dist/config/index.d.ts +12 -0
- package/dist/config/index.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/query/index.cjs +1 -1
- package/dist/query/index.d.cts +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +1 -1
- package/package.json +47 -27
- package/dist/chunk-GLHQQNHA.js +0 -1
- package/dist/chunk-VLK5XE5U.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var N=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var W=(e,t)=>{for(var o in t)N(e,o,{get:t[o],enumerable:!0})},O=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of V(t))!R.call(e,i)&&i!==o&&N(e,i,{get:()=>t[i],enumerable:!(a=L(t,i))||a.enumerable});return e};var z=e=>O(N({},"__esModule",{value:!0}),e);var j={};W(j,{AdGroupProvider:()=>b,useAdGroup:()=>w,useAdvertisement:()=>y});module.exports=z(j);var x=require("react");var E=require("@apps-in-toss/framework"),G=(0,E.getOperationalEnvironment)()==="sandbox"?"local":(0,E.getSchemeUri)().startsWith("intoss-private")?"preview":"production",F={local:"http://localhost:3000",preview:"https://preview-api.intoss.app",production:"https://api.intoss.app"}[G];var _=(0,x.createContext)({appName:"",apiEndpoint:"http://localhost:3000",runningEnvironment:"local"});var I=()=>(0,x.useContext)(_);var r=require("react"),M=(0,r.createContext)({getAdGroupId:()=>""}),b=({initial:e,children:t})=>{let{appName:o,runningEnvironment:a}=I(),[i,d]=(0,r.useState)(a!=="production"),[p,c]=(0,r.useState)(e),s=(0,r.useCallback)((u,l)=>p[l]??(u==="interstitial"?"ait-ad-test-interstitial-id":"ait-ad-test-rewarded-id"),[p]),f=(0,r.useMemo)(()=>({getAdGroupId:s}),[s]);return(0,r.useEffect)(()=>{if(i)return;let u=new AbortController,l=setTimeout(()=>u.abort(),3e3);fetch(`https://static.intoss.app/${o}/assets/adGroupList.json`,{signal:u.signal}).then(C=>C.json()).then(c).finally(()=>{clearTimeout(l),d(!0)})},[o,i]),i?React.createElement(M.Provider,{value:f},t):null},w=()=>(0,r.useContext)(M);var P=require("@apps-in-toss/framework"),n=require("react"),y=({primaryAdGroup:e,secondaryAdGroup:t,onShowAd:o,onDissmissAd:a})=>{let[i,d]=(0,n.useState)(!1),[p,c]=(0,n.useState)(!1),[s,f]=(0,n.useState)(),[u,l]=(0,n.useState)(null),C=(0,n.useCallback)(m=>new Promise(v=>{let h=P.GoogleAdMob.loadAppsInTossAdMob({options:{adGroupId:m},onEvent:A=>{switch(A.type){case"loaded":v([!0,h]);break}},onError:()=>v([!1,h])})}),[]),T=(0,n.useCallback)(async()=>{if(P.GoogleAdMob.loadAppsInTossAdMob.isSupported()!==!0){d(!0);return}if(p)return;let[m,v]=await C(e.id);if(m){d(!0),c(!0),f(e.id),l(()=>v);return}if(v(),!t){d(!0);return}let[h,A]=await C(t.id);if(h){d(!0),c(!0),f(t.id),l(()=>A);return}A(),d(!0)},[e,t,p,C]),g=(0,n.useCallback)(()=>{u?.(),c(!1),f(void 0),l(null)},[u]),k=(0,n.useCallback)(()=>{if(P.GoogleAdMob.loadAppsInTossAdMob.isSupported()!==!0){o?.(),a?.();return}if(!p||!s){o?.(),a?.();return}P.GoogleAdMob.showAppsInTossAdMob({options:{adGroupId:s},onEvent:m=>{switch(m.type){case"show":(s===e.id&&e.type==="interstitial"||s===t?.id&&t.type==="interstitial")&&o?.();break;case"failedToShow":o?.(),g();break;case"dismissed":a?.(),g();break;case"userEarnedReward":o?.();break}},onError:()=>{o?.(),g()}})},[p,s,e,t,o,a,g]);return(0,n.useEffect)(()=>{s||T()},[s,T]),(0,n.useEffect)(()=>()=>g(),[]),{initialized:i,adLoaded:p,showAd:k}};0&&(module.exports={AdGroupProvider,useAdGroup,useAdvertisement});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"../chunk-
|
|
1
|
+
import{a,b,c}from"../chunk-HANNZE3T.js";import"../chunk-R22ZR6YP.js";export{a as AdGroupProvider,b as useAdGroup,c as useAdvertisement};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var C=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var n in e)C(t,n,{get:e[n],enumerable:!0})},O=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of R(e))!W.call(t,o)&&o!==n&&C(t,o,{get:()=>e[o],enumerable:!(r=E(e,o))||r.enumerable});return t};var b=t=>O(C({},"__esModule",{value:!0}),t);var $={};A($,{AuthStateProvider:()=>g,useAuthState:()=>l,useSignInWithToss:()=>P});module.exports=b($);var y=require("@tanstack/react-query"),p=require("react"),x=(0,p.createContext)({isPreparing:!0,isLoggedIn:!1,retry:()=>Promise.resolve()}),g=({children:t})=>{let{data:e,isFetching:n,refetch:r}=(0,y.useQuery)({queryKey:["/my/user"]}),o=(0,p.useMemo)(()=>({isPreparing:n,isLoggedIn:!!e?.user?.id,retry:r}),[e,n,r]);return React.createElement(x.Provider,{value:o},t)},l=()=>(0,p.useContext)(x);var f=require("@apps-in-toss/framework");var z=require("@apps-in-toss/framework");var m=require("react");var d=require("@apps-in-toss/framework"),v=(0,d.getOperationalEnvironment)()==="sandbox"?"local":(0,d.getSchemeUri)().startsWith("intoss-private")?"preview":"production",Q={local:"http://localhost:3000",preview:"https://preview-api.intoss.app",production:"https://api.intoss.app"}[v];var J=(0,m.createContext)({appName:"",apiEndpoint:"http://localhost:3000",runningEnvironment:"local"});var s=require("react");var _=(0,s.createContext)({fetcher:fetch,setToken:()=>null});var u=()=>(0,s.useContext)(_);var c=require("react"),h=(t,e,n)=>{let{displayName:r}=n??{},o=(0,c.memo)(e),a=(0,c.memo)(i=>(0,c.createElement)(o,t(i)));return a.ViewComponent=o,r&&(a.displayName=r,a.ViewComponent.displayName=`${r}View`),a};var N=require("@tanstack/react-query");var V=require("@tanstack/react-query"),F=require("react");var S=({children:t})=>{let{fetcher:e}=u();return{queryClient:(0,F.useMemo)(()=>new V.QueryClient({defaultOptions:{queries:{queryFn:({queryKey:r})=>e(r[0])}}}),[e]),children:t}};var M=h(S,({queryClient:t,children:e})=>React.createElement(N.QueryClientProvider,{client:t},e));var T=require("@tanstack/react-query"),I=require("react");var L="@auth/token",P=({onSuccess:t})=>{let{retry:e}=l(),{fetcher:n,setToken:r}=u(),o=(0,T.useMutation)({mutationFn:async i=>n("/my/sessions",{method:"POST",body:JSON.stringify(i)}),onSuccess:async i=>{r(i.token),await f.Storage.setItem(L,i.token),await e(),t?.()}});return{signInWithToss:(0,I.useCallback)(async()=>{let{authorizationCode:i,referrer:k}=await(0,f.appLogin)();o.mutate({authorizationCode:i,referrer:k})},[o]),isLoading:o.isPending}};0&&(module.exports={AuthStateProvider,useAuthState,useSignInWithToss});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
type AuthStateContextValues = {
|
|
4
|
+
isPreparing: boolean;
|
|
5
|
+
isLoggedIn: boolean;
|
|
6
|
+
retry: () => Promise<unknown>;
|
|
7
|
+
};
|
|
8
|
+
type Props$1 = PropsWithChildren<unknown>;
|
|
9
|
+
declare const AuthStateProvider: FC<Props$1>;
|
|
10
|
+
declare const useAuthState: () => AuthStateContextValues;
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
onSuccess?: () => void;
|
|
14
|
+
};
|
|
15
|
+
declare const useSignInWithToss: ({ onSuccess }: Props) => {
|
|
16
|
+
signInWithToss: () => Promise<void>;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { type AuthStateContextValues, AuthStateProvider, useAuthState, useSignInWithToss };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
type AuthStateContextValues = {
|
|
4
|
+
isPreparing: boolean;
|
|
5
|
+
isLoggedIn: boolean;
|
|
6
|
+
retry: () => Promise<unknown>;
|
|
7
|
+
};
|
|
8
|
+
type Props$1 = PropsWithChildren<unknown>;
|
|
9
|
+
declare const AuthStateProvider: FC<Props$1>;
|
|
10
|
+
declare const useAuthState: () => AuthStateContextValues;
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
onSuccess?: () => void;
|
|
14
|
+
};
|
|
15
|
+
declare const useSignInWithToss: ({ onSuccess }: Props) => {
|
|
16
|
+
signInWithToss: () => Promise<void>;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { type AuthStateContextValues, AuthStateProvider, useAuthState, useSignInWithToss };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as u}from"../chunk-HSSVYUEL.js";import"../chunk-R22ZR6YP.js";import"../chunk-5USVVOWK.js";import{useQuery as m}from"@tanstack/react-query";import{createContext as c,useContext as S,useMemo as y}from"react";var a=c({isPreparing:!0,isLoggedIn:!1,retry:()=>Promise.resolve()}),p=({children:i})=>{let{data:o,isFetching:r,refetch:s}=m({queryKey:["/my/user"]}),e=y(()=>({isPreparing:r,isLoggedIn:!!o?.user?.id,retry:s}),[o,r,s]);return React.createElement(a.Provider,{value:e},i)},n=()=>S(a);import{appLogin as d,Storage as P}from"@apps-in-toss/framework";import{useMutation as f}from"@tanstack/react-query";import{useCallback as x}from"react";var l="@auth/token",h=({onSuccess:i})=>{let{retry:o}=n(),{fetcher:r,setToken:s}=u(),e=f({mutationFn:async t=>r("/my/sessions",{method:"POST",body:JSON.stringify(t)}),onSuccess:async t=>{s(t.token),await P.setItem(l,t.token),await o(),i?.()}});return{signInWithToss:x(async()=>{let{authorizationCode:t,referrer:g}=await d();e.mutate({authorizationCode:t,referrer:g})},[e]),isLoading:e.isPending}};export{p as AuthStateProvider,n as useAuthState,h as useSignInWithToss};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as P}from"./chunk-R22ZR6YP.js";import{createContext as T,useCallback as M,useContext as z,useEffect as W,useMemo as j,useState as w}from"react";var h=T({getAdGroupId:()=>""}),y=({initial:i,children:r})=>{let{appName:t,runningEnvironment:a}=P(),[u,s]=w(a!=="production"),[o,p]=w(i),e=M((n,d)=>o[d]??(n==="interstitial"?"ait-ad-test-interstitial-id":"ait-ad-test-rewarded-id"),[o]),l=j(()=>({getAdGroupId:e}),[e]);return W(()=>{if(u)return;let n=new AbortController,d=setTimeout(()=>n.abort(),3e3);fetch(`https://static.intoss.app/${t}/assets/adGroupList.json`,{signal:n.signal}).then(c=>c.json()).then(p).finally(()=>{clearTimeout(d),s(!0)})},[t,u]),u?React.createElement(h.Provider,{value:l},r):null},k=()=>z(h);import{GoogleAdMob as b}from"@apps-in-toss/framework";import{useCallback as v,useEffect as E,useState as x}from"react";var G=({primaryAdGroup:i,secondaryAdGroup:r,onShowAd:t,onDissmissAd:a})=>{let[u,s]=x(!1),[o,p]=x(!1),[e,l]=x(),[n,d]=x(null),c=v(m=>new Promise(A=>{let g=b.loadAppsInTossAdMob({options:{adGroupId:m},onEvent:C=>{switch(C.type){case"loaded":A([!0,g]);break}},onError:()=>A([!1,g])})}),[]),I=v(async()=>{if(b.loadAppsInTossAdMob.isSupported()!==!0){s(!0);return}if(o)return;let[m,A]=await c(i.id);if(m){s(!0),p(!0),l(i.id),d(()=>A);return}if(A(),!r){s(!0);return}let[g,C]=await c(r.id);if(g){s(!0),p(!0),l(r.id),d(()=>C);return}C(),s(!0)},[i,r,o,c]),f=v(()=>{n?.(),p(!1),l(void 0),d(null)},[n]),L=v(()=>{if(b.loadAppsInTossAdMob.isSupported()!==!0){t?.(),a?.();return}if(!o||!e){t?.(),a?.();return}b.showAppsInTossAdMob({options:{adGroupId:e},onEvent:m=>{switch(m.type){case"show":(e===i.id&&i.type==="interstitial"||e===r?.id&&r.type==="interstitial")&&t?.();break;case"failedToShow":t?.(),f();break;case"dismissed":a?.(),f();break;case"userEarnedReward":t?.();break}},onError:()=>{t?.(),f()}})},[o,e,i,r,t,a,f]);return E(()=>{e||I()},[e,I]),E(()=>()=>f(),[]),{initialized:u,adLoaded:o,showAd:L}};export{y as a,k as b,G as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as c}from"./chunk-R22ZR6YP.js";import{a as p}from"./chunk-5USVVOWK.js";import{Storage as x}from"@apps-in-toss/framework";import{createContext as F,useCallback as g,useContext as Q,useEffect as k,useState as h}from"react";var T="@auth/token",l=F({fetcher:fetch,setToken:()=>null}),f=({baseUrl:e,children:r})=>{let{appName:n,apiEndpoint:t}=c(),[i,s]=h(null),[d,P]=h(!1),y=g((C,u)=>fetch(`${e??t}/${n}${C}`,{...u,headers:{...u?.headers,...i?{Authorization:`Bearer ${i}`}:{}}}).then(v=>v.json()),[n,t,i,e]);return k(()=>{x.getItem(T).then(s).finally(()=>P(!0))},[]),React.createElement(l.Provider,{value:{fetcher:y,setToken:s}},d?r:null)},o=()=>Q(l);import{QueryClientProvider as W}from"@tanstack/react-query";import{QueryClient as q}from"@tanstack/react-query";import{useMemo as E}from"react";var m=({children:e})=>{let{fetcher:r}=o();return{queryClient:E(()=>new q({defaultOptions:{queries:{queryFn:({queryKey:t})=>r(t[0])}}}),[r]),children:e}};var a=p(m,({queryClient:e,children:r})=>React.createElement(W,{client:e},r));export{f as a,o as b,a as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as c,useContext as l,useMemo as g}from"react";import{getOperationalEnvironment as a,getSchemeUri as C}from"@apps-in-toss/framework";var o=a()==="sandbox"?"local":C().startsWith("intoss-private")?"preview":"production",n={local:"http://localhost:3000",preview:"https://preview-api.intoss.app",production:"https://api.intoss.app"}[o];var e=c({appName:"",apiEndpoint:"http://localhost:3000",runningEnvironment:"local"}),i=({appName:t,children:p})=>{let s=g(()=>({appName:t,apiEndpoint:n,runningEnvironment:o}),[t]);return React.createElement(e.Provider,{value:s},p)},r=()=>l(e);export{i as a,r as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var x=(t,o)=>{for(var n in o)p(t,n,{get:o[n],enumerable:!0})},m=(t,o,n,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of N(o))!f.call(t,i)&&i!==n&&p(t,i,{get:()=>o[i],enumerable:!(c=u(o,i))||c.enumerable});return t};var v=t=>m(p({},"__esModule",{value:!0}),t);var d={};x(d,{ConfigProvider:()=>a,useConfig:()=>C});module.exports=v(d);var e=require("react");var r=require("@apps-in-toss/framework"),s=(0,r.getOperationalEnvironment)()==="sandbox"?"local":(0,r.getSchemeUri)().startsWith("intoss-private")?"preview":"production",l={local:"http://localhost:3000",preview:"https://preview-api.intoss.app",production:"https://api.intoss.app"}[s];var g=(0,e.createContext)({appName:"",apiEndpoint:"http://localhost:3000",runningEnvironment:"local"}),a=({appName:t,children:o})=>{let n=(0,e.useMemo)(()=>({appName:t,apiEndpoint:l,runningEnvironment:s}),[t]);return React.createElement(g.Provider,{value:n},o)},C=()=>(0,e.useContext)(g);0&&(module.exports={ConfigProvider,useConfig});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
type ConfigContextValues = {
|
|
4
|
+
appName: string;
|
|
5
|
+
apiEndpoint: string;
|
|
6
|
+
runningEnvironment: "local" | "preview" | "production";
|
|
7
|
+
};
|
|
8
|
+
type Props = PropsWithChildren<ConfigContextValues>;
|
|
9
|
+
declare const ConfigProvider: FC<Props>;
|
|
10
|
+
declare const useConfig: () => ConfigContextValues;
|
|
11
|
+
|
|
12
|
+
export { ConfigProvider, useConfig };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
type ConfigContextValues = {
|
|
4
|
+
appName: string;
|
|
5
|
+
apiEndpoint: string;
|
|
6
|
+
runningEnvironment: "local" | "preview" | "production";
|
|
7
|
+
};
|
|
8
|
+
type Props = PropsWithChildren<ConfigContextValues>;
|
|
9
|
+
declare const ConfigProvider: FC<Props>;
|
|
10
|
+
declare const useConfig: () => ConfigContextValues;
|
|
11
|
+
|
|
12
|
+
export { ConfigProvider, useConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"../chunk-R22ZR6YP.js";export{a as ConfigProvider,b as useConfig};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var V=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var oe=(e,t)=>{for(var o in t)V(e,o,{get:t[o],enumerable:!0})},re=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!te.call(e,r)&&r!==o&&V(e,r,{get:()=>t[r],enumerable:!(n=Z(t,r))||n.enumerable});return e};var ne=e=>re(V({},"__esModule",{value:!0}),e);var le={};oe(le,{AdGroupProvider:()=>R,FetcherProvider:()=>K,QueryProvider:()=>D,bind:()=>y,calculateDay:()=>N,calculateDayOfWeek:()=>O,calculateHour:()=>I,calculateMinute:()=>k,calculateWeek:()=>W,useAdGroup:()=>A,useAdvertisement:()=>b,useFetcher:()=>v,useStorage:()=>U});module.exports=ne(le);var E=require("react");var T=require("@apps-in-toss/framework"),z=(0,T.getOperationalEnvironment)()==="sandbox"?"local":(0,T.getSchemeUri)().startsWith("intoss-private")?"preview":"production",ie={local:"http://localhost:3000",preview:"https://preview-api.intoss.app",production:"https://api.intoss.app"}[z];var se=(0,E.createContext)({appName:"",apiEndpoint:"http://localhost:3000",runningEnvironment:"local"});var C=()=>(0,E.useContext)(se);var a=require("react"),Q=(0,a.createContext)({getAdGroupId:()=>""}),R=({initial:e,children:t})=>{let{appName:o,runningEnvironment:n}=C(),[r,s]=(0,a.useState)(n!=="production"),[i,d]=(0,a.useState)(e),l=(0,a.useCallback)((c,f)=>i[f]??(c==="interstitial"?"ait-ad-test-interstitial-id":"ait-ad-test-rewarded-id"),[i]),m=(0,a.useMemo)(()=>({getAdGroupId:l}),[l]);return(0,a.useEffect)(()=>{if(r)return;let c=new AbortController,f=setTimeout(()=>c.abort(),3e3);fetch(`https://static.intoss.app/${o}/assets/adGroupList.json`,{signal:c.signal}).then(P=>P.json()).then(d).finally(()=>{clearTimeout(f),s(!0)})},[o,r]),r?React.createElement(Q.Provider,{value:m},t):null},A=()=>(0,a.useContext)(Q);var M=require("@apps-in-toss/framework"),p=require("react"),b=({primaryAdGroup:e,secondaryAdGroup:t,onShowAd:o,onDissmissAd:n})=>{let[r,s]=(0,p.useState)(!1),[i,d]=(0,p.useState)(!1),[l,m]=(0,p.useState)(),[c,f]=(0,p.useState)(null),P=(0,p.useCallback)(_=>new Promise(g=>{let w=M.GoogleAdMob.loadAppsInTossAdMob({options:{adGroupId:_},onEvent:F=>{switch(F.type){case"loaded":g([!0,w]);break}},onError:()=>g([!1,w])})}),[]),Y=(0,p.useCallback)(async()=>{if(M.GoogleAdMob.loadAppsInTossAdMob.isSupported()!==!0){s(!0);return}if(i)return;let[_,g]=await P(e.id);if(_){s(!0),d(!0),m(e.id),f(()=>g);return}if(g(),!t){s(!0);return}let[w,F]=await P(t.id);if(w){s(!0),d(!0),m(t.id),f(()=>F);return}F(),s(!0)},[e,t,i,P]),h=(0,p.useCallback)(()=>{c?.(),d(!1),m(void 0),f(null)},[c]),X=(0,p.useCallback)(()=>{if(M.GoogleAdMob.loadAppsInTossAdMob.isSupported()!==!0){o?.(),n?.();return}if(!i||!l){o?.(),n?.();return}M.GoogleAdMob.showAppsInTossAdMob({options:{adGroupId:l},onEvent:_=>{switch(_.type){case"show":(l===e.id&&e.type==="interstitial"||l===t?.id&&t.type==="interstitial")&&o?.();break;case"failedToShow":o?.(),h();break;case"dismissed":n?.(),h();break;case"userEarnedReward":o?.();break}},onError:()=>{o?.(),h()}})},[i,l,e,t,o,n,h]);return(0,p.useEffect)(()=>{l||Y()},[l,Y]),(0,p.useEffect)(()=>()=>h(),[]),{initialized:r,adLoaded:i,showAd:X}};var N=e=>Math.floor((e+324e5)/864e5);var O=e=>(e+3)%7;var I=e=>Math.floor((e+324e5)%864e5/36e5);var k=e=>Math.floor((e+324e5)%36e5/6e4);var W=e=>Math.floor((e+3)/7);var H=require("@apps-in-toss/framework");var u=require("react"),pe="@auth/token",$=(0,u.createContext)({fetcher:fetch,setToken:()=>null}),K=({baseUrl:e,children:t})=>{let{appName:o,apiEndpoint:n}=C(),[r,s]=(0,u.useState)(null),[i,d]=(0,u.useState)(!1),l=(0,u.useCallback)((m,c)=>fetch(`${e??n}/${o}${m}`,{...c,headers:{...c?.headers,...r?{Authorization:`Bearer ${r}`}:{}}}).then(f=>f.json()),[o,n,r,e]);return(0,u.useEffect)(()=>{H.Storage.getItem(pe).then(s).finally(()=>d(!0))},[]),React.createElement($.Provider,{value:{fetcher:l,setToken:s}},i?t:null)},v=()=>(0,u.useContext)($);var S=require("react"),y=(e,t,o)=>{let{displayName:n}=o??{},r=(0,S.memo)(t),s=(0,S.memo)(i=>(0,S.createElement)(r,e(i)));return s.ViewComponent=r,n&&(s.displayName=n,s.ViewComponent.displayName=`${n}View`),s};var B=require("@tanstack/react-query");var q=require("@tanstack/react-query"),j=require("react");var J=({children:e})=>{let{fetcher:t}=v();return{queryClient:(0,j.useMemo)(()=>new q.QueryClient({defaultOptions:{queries:{queryFn:({queryKey:n})=>t(n[0])}}}),[t]),children:e}};var D=y(J,({queryClient:e,children:t})=>React.createElement(B.QueryClientProvider,{client:e},t));var L=require("@apps-in-toss/framework"),x=require("react"),G=require("react-native"),U=e=>{let[t,o]=(0,x.useState)(),[n,r]=(0,x.useState)(!0),s=(0,x.useCallback)(i=>(o(i),G.DeviceEventEmitter.emit(e,i),L.Storage.setItem(e,JSON.stringify({value:i}))),[e]);return(0,x.useEffect)(()=>{r(!0),L.Storage.getItem(e).then(d=>{try{o(d===null?void 0:JSON.parse(d).value)}catch{o(void 0)}finally{r(!1)}});let i=G.DeviceEventEmitter.addListener(e,o);return()=>i.remove()},[e]),[t,s,n]};0&&(module.exports={AdGroupProvider,FetcherProvider,QueryProvider,bind,calculateDay,calculateDayOfWeek,calculateHour,calculateMinute,calculateWeek,useAdGroup,useAdvertisement,useFetcher,useStorage});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e}from"./chunk-HANNZE3T.js";import{a as f,b as m,c as p,d as t,e as x}from"./chunk-IMEAYFIW.js";import{a,b,c as d}from"./chunk-HSSVYUEL.js";import"./chunk-R22ZR6YP.js";import{a as g}from"./chunk-LUKG4S33.js";import{a as c}from"./chunk-5USVVOWK.js";export{o as AdGroupProvider,a as FetcherProvider,d as QueryProvider,c as bind,f as calculateDay,m as calculateDayOfWeek,p as calculateHour,t as calculateMinute,x as calculateWeek,r as useAdGroup,e as useAdvertisement,b as useFetcher,g as useStorage};
|
package/dist/query/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var C=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(o,e)=>{for(var i in e)C(o,i,{get:e[i],enumerable:!0})},Q=(o,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of T(e))!I.call(o,t)&&t!==i&&C(o,t,{get:()=>e[t],enumerable:!(r=k(e,t))||r.enumerable});return o};var W=o=>Q(C({},"__esModule",{value:!0}),o);var z={};O(z,{FetcherProvider:()=>f,QueryProvider:()=>h,useFetcher:()=>l});module.exports=W(z);var g=require("@apps-in-toss/framework");var p=require("react");var a=require("@apps-in-toss/framework"),x=(0,a.getOperationalEnvironment)()==="sandbox"?"local":(0,a.getSchemeUri)().startsWith("intoss-private")?"preview":"production",b={local:"http://localhost:3000",preview:"https://preview-api.intoss.app",production:"https://api.intoss.app"}[x];var _=(0,p.createContext)({appName:"",apiEndpoint:"http://localhost:3000",runningEnvironment:"local"});var d=()=>(0,p.useContext)(_);var n=require("react"),q="@auth/token",w=(0,n.createContext)({fetcher:fetch,setToken:()=>null}),f=({baseUrl:o,children:e})=>{let{appName:i,apiEndpoint:r}=d(),[t,s]=(0,n.useState)(null),[m,F]=(0,n.useState)(!1),M=(0,n.useCallback)((E,P)=>fetch(`${o??r}/${i}${E}`,{...P,headers:{...P?.headers,...t?{Authorization:`Bearer ${t}`}:{}}}).then(R=>R.json()),[i,r,t,o]);return(0,n.useEffect)(()=>{g.Storage.getItem(q).then(s).finally(()=>F(!0))},[]),React.createElement(w.Provider,{value:{fetcher:M,setToken:s}},m?e:null)},l=()=>(0,n.useContext)(w);var u=require("react"),c=(o,e,i)=>{let{displayName:r}=i??{},t=(0,u.memo)(e),s=(0,u.memo)(m=>(0,u.createElement)(t,o(m)));return s.ViewComponent=t,r&&(s.displayName=r,s.ViewComponent.displayName=`${r}View`),s};var N=require("@tanstack/react-query");var y=require("@tanstack/react-query"),v=require("react");var V=({children:o})=>{let{fetcher:e}=l();return{queryClient:(0,v.useMemo)(()=>new y.QueryClient({defaultOptions:{queries:{queryFn:({queryKey:r})=>e(r[0])}}}),[e]),children:o}};var h=c(V,({queryClient:o,children:e})=>React.createElement(N.QueryClientProvider,{client:o},e));0&&(module.exports={FetcherProvider,QueryProvider,useFetcher});
|
package/dist/query/index.d.cts
CHANGED
package/dist/query/index.d.ts
CHANGED
package/dist/query/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"../chunk-
|
|
1
|
+
import{a,b,c}from"../chunk-HSSVYUEL.js";import"../chunk-R22ZR6YP.js";import"../chunk-5USVVOWK.js";export{a as FetcherProvider,c as QueryProvider,b as useFetcher};
|
package/package.json
CHANGED
|
@@ -1,69 +1,89 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intoss/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"module": "dist/index.
|
|
7
|
-
"types": "dist/index.d.
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.cts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": {
|
|
11
|
-
"types": "./dist/index.d.mts",
|
|
12
|
-
"default": "./dist/index.mjs"
|
|
13
|
-
},
|
|
14
|
-
"require": {
|
|
15
11
|
"types": "./dist/index.d.ts",
|
|
16
12
|
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"./advertisement": {
|
|
20
20
|
"import": {
|
|
21
|
-
"types": "./dist/advertisement/index.d.mts",
|
|
22
|
-
"default": "./dist/advertisement/index.mjs"
|
|
23
|
-
},
|
|
24
|
-
"require": {
|
|
25
21
|
"types": "./dist/advertisement/index.d.ts",
|
|
26
22
|
"default": "./dist/advertisement/index.js"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/advertisement/index.d.cts",
|
|
26
|
+
"default": "./dist/advertisement/index.cjs"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"./
|
|
29
|
+
"./auth-state": {
|
|
30
30
|
"import": {
|
|
31
|
-
"types": "./dist/
|
|
32
|
-
"default": "./dist/
|
|
31
|
+
"types": "./dist/auth-state/index.d.ts",
|
|
32
|
+
"default": "./dist/auth-state/index.js"
|
|
33
33
|
},
|
|
34
34
|
"require": {
|
|
35
|
+
"types": "./dist/auth-state/index.d.cts",
|
|
36
|
+
"default": "./dist/auth-state/index.cjs"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"./calendar": {
|
|
40
|
+
"import": {
|
|
35
41
|
"types": "./dist/calendar/index.d.ts",
|
|
36
42
|
"default": "./dist/calendar/index.js"
|
|
43
|
+
},
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./dist/calendar/index.d.cts",
|
|
46
|
+
"default": "./dist/calendar/index.cjs"
|
|
37
47
|
}
|
|
38
48
|
},
|
|
39
|
-
"./
|
|
49
|
+
"./config": {
|
|
40
50
|
"import": {
|
|
41
|
-
"types": "./dist/
|
|
42
|
-
"default": "./dist/
|
|
51
|
+
"types": "./dist/config/index.d.ts",
|
|
52
|
+
"default": "./dist/config/index.js"
|
|
43
53
|
},
|
|
44
54
|
"require": {
|
|
55
|
+
"types": "./dist/config/index.d.cts",
|
|
56
|
+
"default": "./dist/config/index.cjs"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"./query": {
|
|
60
|
+
"import": {
|
|
45
61
|
"types": "./dist/query/index.d.ts",
|
|
46
62
|
"default": "./dist/query/index.js"
|
|
63
|
+
},
|
|
64
|
+
"require": {
|
|
65
|
+
"types": "./dist/query/index.d.cts",
|
|
66
|
+
"default": "./dist/query/index.cjs"
|
|
47
67
|
}
|
|
48
68
|
},
|
|
49
69
|
"./storage": {
|
|
50
70
|
"import": {
|
|
51
|
-
"types": "./dist/storage/index.d.mts",
|
|
52
|
-
"default": "./dist/storage/index.mjs"
|
|
53
|
-
},
|
|
54
|
-
"require": {
|
|
55
71
|
"types": "./dist/storage/index.d.ts",
|
|
56
72
|
"default": "./dist/storage/index.js"
|
|
73
|
+
},
|
|
74
|
+
"require": {
|
|
75
|
+
"types": "./dist/storage/index.d.cts",
|
|
76
|
+
"default": "./dist/storage/index.cjs"
|
|
57
77
|
}
|
|
58
78
|
},
|
|
59
79
|
"./view-model": {
|
|
60
80
|
"import": {
|
|
61
|
-
"types": "./dist/view-model/index.d.mts",
|
|
62
|
-
"default": "./dist/view-model/index.mjs"
|
|
63
|
-
},
|
|
64
|
-
"require": {
|
|
65
81
|
"types": "./dist/view-model/index.d.ts",
|
|
66
82
|
"default": "./dist/view-model/index.js"
|
|
83
|
+
},
|
|
84
|
+
"require": {
|
|
85
|
+
"types": "./dist/view-model/index.d.cts",
|
|
86
|
+
"default": "./dist/view-model/index.cjs"
|
|
67
87
|
}
|
|
68
88
|
},
|
|
69
89
|
"./package.json": "./package.json"
|
|
@@ -72,7 +92,7 @@
|
|
|
72
92
|
"dist"
|
|
73
93
|
],
|
|
74
94
|
"scripts": {
|
|
75
|
-
"build": "tsup"
|
|
95
|
+
"build": "rm -rf dist && tsup"
|
|
76
96
|
},
|
|
77
97
|
"dependencies": {
|
|
78
98
|
"@tanstack/react-query": "5.90.12"
|
package/dist/chunk-GLHQQNHA.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as s}from"./chunk-5USVVOWK.js";import{Storage as P}from"@apps-in-toss/framework";import{createContext as C,useCallback as v,useContext as x,useEffect as F,useState as u}from"react";var g="@query/token",c=C({fetcher:fetch,setToken:()=>null}),h=({baseUrl:e,children:r})=>{let[t,o]=u(null),[f,d]=u(!1),m=v((a,i)=>fetch(`${e}${a}`,{...i,headers:{...i?.headers,...t?{Authorization:`Bearer ${t}`}:{}}}).then(y=>y.json()),[t,e]);return F(()=>{P.getItem(g).then(o).finally(()=>d(!0))},[]),React.createElement(c.Provider,{value:{fetcher:m,setToken:o}},f?r:null)},n=()=>x(c);import{QueryClientProvider as T}from"@tanstack/react-query";import{QueryClient as Q}from"@tanstack/react-query";import{useMemo as k}from"react";var l=({children:e})=>{let{fetcher:r}=n();return{queryClient:k(()=>new Q({defaultOptions:{queries:{queryFn:({queryKey:o})=>r(o[0])}}}),[r]),children:e}};var p=s(l,({queryClient:e,children:r})=>React.createElement(T,{client:e},r));export{h as a,n as b,p as c};
|
package/dist/chunk-VLK5XE5U.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createContext as L,useCallback as T,useContext as M,useEffect as z,useMemo as W,useState as P}from"react";var w=L({getAdGroupId:()=>""}),h=({tenant:t,initial:e,children:r})=>{let[s,v]=P(!1),[o,d]=P(e),a=T((n,u)=>o[u]??(n==="interstitial"?"ait-ad-test-interstitial-id":"ait-ad-test-rewarded-id"),[o]),i=W(()=>({getAdGroupId:a}),[a]);return z(()=>{if(s)return;let n=new AbortController,u=setTimeout(()=>n.abort(),3e3);fetch(`https://static.intoss.app/${t}/assets/adGroupList.json`,{signal:n.signal}).then(l=>l.json()).then(d).finally(()=>{clearTimeout(u),v(!0)})},[t,s]),s?React.createElement(w.Provider,{value:i},r):null},y=()=>M(w);import{GoogleAdMob as b}from"@apps-in-toss/framework";import{useCallback as m,useEffect as k,useState as C}from"react";var G=({primaryAdGroup:t,secondaryAdGroup:e,onShowAd:r,onDissmissAd:s})=>{let[v,o]=C(!1),[d,a]=C(!1),[i,n]=C(),[u,l]=C(null),x=m(c=>new Promise(f=>{let A=b.loadAppsInTossAdMob({options:{adGroupId:c},onEvent:g=>{switch(g.type){case"loaded":f([!0,A]);break}},onError:()=>f([!1,A])})}),[]),I=m(async()=>{if(b.loadAppsInTossAdMob.isSupported()!==!0){o(!0);return}if(d)return;let[c,f]=await x(t.id);if(c){o(!0),a(!0),n(t.id),l(()=>f);return}if(f(),!e){o(!0);return}let[A,g]=await x(e.id);if(A){o(!0),a(!0),n(e.id),l(()=>g);return}g(),o(!0)},[t,e,d,x]),p=m(()=>{u?.(),a(!1),n(void 0),l(null)},[u]),E=m(()=>{if(b.loadAppsInTossAdMob.isSupported()!==!0){r?.(),s?.();return}if(!d||!i){r?.(),s?.();return}b.showAppsInTossAdMob({options:{adGroupId:i},onEvent:c=>{switch(c.type){case"show":(i===t.id&&t.type==="interstitial"||i===e?.id&&e.type==="interstitial")&&r?.();break;case"failedToShow":r?.(),p();break;case"dismissed":s?.(),p();break;case"userEarnedReward":r?.();break}},onError:()=>{r?.(),p()}})},[d,i,t,e,r,s,p]);return k(()=>{i||I()},[i,I]),k(()=>()=>p(),[]),{initialized:v,adLoaded:d,showAd:E}};export{h as a,y as b,G as c};
|