@swarm.ing/pieui 2.1.1 → 2.1.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/README.md +52 -0
- package/dist/agent/index.esm.js +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts +15 -0
- package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts.map +1 -1
- package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts +15 -0
- package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts.map +1 -1
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/max/index.esm.js +1 -1
- package/dist/max/index.js +1 -1
- package/dist/pieui.components.json +62 -62
- package/dist/storybook/addon/manager.esm.js +2 -0
- package/dist/storybook/addon/manager.js +2 -0
- package/dist/telegram/components/CloudStorageCard/index.d.ts.map +1 -0
- package/dist/telegram/components/CloudStorageCard/types/index.d.ts.map +1 -0
- package/dist/telegram/components/CloudStorageCard/ui/CloudStorageCard.d.ts +15 -0
- package/dist/telegram/components/CloudStorageCard/ui/CloudStorageCard.d.ts.map +1 -0
- package/dist/telegram/components/SecureStorageCard/index.d.ts.map +1 -0
- package/dist/telegram/components/SecureStorageCard/types/index.d.ts.map +1 -0
- package/dist/telegram/components/SecureStorageCard/ui/SecureStorageCard.d.ts +15 -0
- package/dist/telegram/components/SecureStorageCard/ui/SecureStorageCard.d.ts.map +1 -0
- package/dist/telegram/index.d.ts +4 -0
- package/dist/telegram/index.d.ts.map +1 -1
- package/dist/telegram/index.esm.js +1 -1
- package/dist/telegram/index.js +1 -1
- package/dist/util/ajaxCommonUtils.d.ts +60 -13
- package/dist/util/ajaxCommonUtils.d.ts.map +1 -1
- package/dist/util/centrifuge.d.ts.map +1 -1
- package/dist/util/fallback.d.ts.map +1 -1
- package/dist/util/globalSingleton.d.ts +2 -0
- package/dist/util/globalSingleton.d.ts.map +1 -0
- package/dist/util/lazyError.d.ts.map +1 -1
- package/dist/util/mitt.d.ts +3 -0
- package/dist/util/mitt.d.ts.map +1 -1
- package/dist/util/navigate.d.ts.map +1 -1
- package/dist/util/pieConfig.d.ts.map +1 -1
- package/dist/util/registry.d.ts +16 -0
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/socket.d.ts.map +1 -1
- package/dist/util/uiRenderer.d.ts.map +1 -1
- package/dist/util/waitForSidAvailable.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/components/Common/CloudStorageCard/index.d.ts.map +0 -1
- package/dist/components/Common/CloudStorageCard/types/index.d.ts.map +0 -1
- package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts +0 -4
- package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts.map +0 -1
- package/dist/components/Common/SecureStorageCard/index.d.ts.map +0 -1
- package/dist/components/Common/SecureStorageCard/types/index.d.ts.map +0 -1
- package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts +0 -4
- package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts.map +0 -1
- /package/dist/{components/Common → telegram/components}/CloudStorageCard/index.d.ts +0 -0
- /package/dist/{components/Common → telegram/components}/CloudStorageCard/types/index.d.ts +0 -0
- /package/dist/{components/Common → telegram/components}/SecureStorageCard/index.d.ts +0 -0
- /package/dist/{components/Common → telegram/components}/SecureStorageCard/types/index.d.ts +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useMemo as G}from"react";import{QueryClient as aU,QueryClientProvider as tU,useQuery as rU}from"@tanstack/react-query";import BU from"mitt";import{createContext as FU,useCallback as VL,useContext as ZL}from"react";var k=null;function m(){if(!k)k=BU();return k}var NU=FU(null);var d=NU;import{io as XU}from"socket.io-client";import{createContext as DU}from"react";var u=new Map,g=(U)=>{let L=u.get(U);if(L)return L;let z=XU(U,{autoConnect:!1,transports:["websocket"]});return u.set(U,z),z},OU=DU(null),K=OU;import{createContext as QU}from"react";import{Centrifuge as c}from"centrifuge";var l=new Map,h=(U,L)=>{if(!L)return null;let z=`${U}::${L}`,J=l.get(z);if(J)return J;async function I(){let H=await fetch(U+"api/centrifuge/gen_token");if(!H.ok){if(H.status===403)throw new c.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${H.status}`)}return(await H.json()).token}let $=new c(L,{getToken:I});return l.set(z,$),$},qU=QU(null),W=qU;import{useContext as MU,useEffect as RU}from"react";import{useEffect as GU,useState as YU}from"react";var _=new Map,M=new Map;function R(U,L){let z=`${U}::${L}`,J=U?_.get(z):void 0,[I,$]=YU(J??null);return GU(()=>{if(!U)return;if(_.has(z)){$(_.get(z));return}let H=M.get(z);if(!H)H=fetch(U+`api/support/${L}`,{method:"GET"}).then((V)=>V.json()).then((V)=>{return _.set(z,V),M.delete(z),V}).catch((V)=>{throw M.delete(z),V}),M.set(z,H);let B=!1;return H.then((V)=>{if(!B)$(V)}).catch(()=>{}),()=>{B=!0}},[U,L,z]),I}import{createContext as KU,useContext as WU}from"react";var P=KU(null),T=()=>{let U=WU(P);if(!U)throw Error("usePieConfig must be used within PieConfigProvider");return U},S=()=>{let{apiServer:U}=T();return U},E=S,o=()=>{let{centrifugeServer:U}=T();return U};var N=()=>{let{enableRenderingLog:U}=T();return U};var p=()=>{let{pageProcessor:U}=T();return U};var _U=null;function n(){_U?.()}var TU=({children:U})=>{let L=MU(K),z=E(),J=R(z,"socketIO"),I=($)=>{if(typeof window<"u")window.sid=$.sid,n(),console.log(`SocketIO initialized: ${window.sid}`)};return RU(()=>{if(!L)return;let $=()=>{console.log("SocketIO connected")},H=(B)=>{console.log(`SocketIO disconnected: ${B}`),L.connect()};if(J)L.on("pieinit",I),L.on("connect",$),L.on("disconnect",H),L.connect();return()=>{if(J)L.off("pieinit",I),L.off("connect",$),L.off("disconnect",H),L.disconnect()}},[L,J]),U},s=TU;import{useContext as EU,useEffect as AU}from"react";var jU=({children:U})=>{let L=EU(W),z=E(),J=R(z,"centrifuge");return AU(()=>{if(!L)return;let I=()=>{console.log("Centrifuge connected")},$=(H)=>{console.log("Centrifuge disconnected:",H)};if(J)L.on("connected",I),L.on("disconnected",$),L.connect();return()=>{if(J)L.disconnect()}},[L,J]),U},i=jU;import{createContext as fU}from"react";import{jsx as SU,Fragment as PU}from"react/jsx-runtime";var kU=fU(SU(PU,{})),X=kU;import{createContext as wU}from"react";var yU=wU(void 0),D=yU;var a=Symbol.for("@swarm.ing/pieui:component-registry"),t=globalThis,bU=t[a]??(t[a]=new Map);var A=(U)=>{return bU.get(U)};import{useContext as r,memo as uU}from"react";import{Component as xU,Suspense as CU}from"react";import{jsx as dU}from"react/jsx-runtime";var vU=2,mU=400;class O extends xU{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(U){if(this.props.onError?.(U),this.state.attempt<vU){let L=mU*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState((z)=>({failed:!1,attempt:z.attempt+1}))},L)}}componentDidUpdate(U){if(U.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return dU(CU,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}import{jsx as w}from"react/jsx-runtime";function gU({uiConfig:U,setUiAjaxConfiguration:L}){let z=r(X),J=r(D),I=N();if(I)console.log("[UI] Rendering component:",U.card),console.log("[UI] Component data:",U.data),console.log("[UI] Component content:",U.content),console.log("[UI] Has setUiAjaxConfiguration:",!!L);let $=A(U.card);if(!$?.component){if(I)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return z}if(I)console.log("[UI] Found component in registry:",{name:$.name,isLazy:$.isLazy,hasMetadata:!!$.metadata});let H=$.component,B=w(H,{data:U.data,content:U.content,setUiAjaxConfiguration:L});if($.isLazy){if(I)console.log("[UI] Rendering lazy component with Suspense:",$.name);return w(O,{name:$.name,fallback:$.fallback?w($.fallback,{}):z,onError:J,children:B})}if(I)console.log("[UI] Rendering component directly:",$.name);return B}var y=uU(gU);import{createAxiosDateTransformer as eU}from"axios-date-transformer";import{useEffect as cU,useState as lU}from"react";var j=({onError:U}={})=>{let[L,z]=lU(null),J=p();return cU(()=>{if(typeof window>"u")return;let I=window.Telegram?.WebApp;if(!I)return;try{I.ready?.()}catch($){U?.()}if(J==="telegram_expanded"&&(I.platform==="ios"||I.platform==="android"))I.expand();z(I)},[]),L},hU=()=>{let U=j();return[U?.initDataUnsafe,U?.initData]};import{createContext as oU}from"react";var pU=oU(void 0),e=pU;import{useContext as LU}from"react";import{createContext as nU}from"react";var sU=nU(null),UU=sU;import{jsx as f}from"react/jsx-runtime";function $U({uiConfig:U,setUiAjaxConfiguration:L}){let z=LU(X),J=LU(D),I=N();if(I)console.log("[UILoading] Rendering fallback for:",U.card),console.log("[UILoading] Component data:",U.data),console.log("[UILoading] Component content:",U.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!L);let $=A(U.card);if(!$?.component){if(I)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return z}if(I)console.log("[UILoading] Found component in registry:",{name:$.name,isLazy:$.isLazy,hasMetadata:!!$.metadata,hasFallback:!!$.fallback});if($.fallback){if(I)console.log("[UILoading] Rendering fallback for:",$.name);let V=$.fallback;return f(V,{})}if(I)console.log("[UILoading] No fallback, rendering full component:",$.name);let H=$.component,B=f(UU.Provider,{value:$U,children:f(H,{data:U.data,content:U.content,setUiAjaxConfiguration:L})});if($.isLazy)return f(O,{name:$.name,fallback:z,onError:J,children:B});return B}var zU=$U;import{jsx as iU}from"react/jsx-runtime";function IU(U,L,z){if(!L)return z;let J=U.replace(/^\//,""),I=L[J];if(!I)return z;return iU(zU,{uiConfig:I})}import{jsx as Z,Fragment as $L}from"react/jsx-runtime";var UL=({location:U,fallback:L,piecache:z,onError:J,queryOptions:I,disableGlobalForm:$})=>{let H=S(),B=o(),V=N(),HU=G(()=>eU({baseURL:H}),[H]),JU=G(()=>m(),[]),VU=G(()=>H?g(H):null,[H]),ZU=G(()=>H?h(H,B):null,[H,B]),Y=j({onError:J}),{data:Q,isLoading:b,error:F}=rU({queryKey:["uiConfig",U.pathname+U.search,Y?.initData],enabled:!!Y?.initData,queryFn:async()=>{let q=new URLSearchParams(U.search);if(q.set("__pieroot","telegram"),Y?.initData)q.set("initData",Y.initData);let C="/api/content"+U.pathname+"?"+q.toString();if(V)console.log("[PieRoot] Fetching UI configuration from:",C);let v=await HU.get(C,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(V)console.log("[PieRoot] Received UI configuration:",v.data);return v.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(q)=>Math.min(1000*2**q,30000),...I}),x=IU(U.pathname,z,L);if(!H)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(F&&V)return console.error("[PieRoot] Error fetching UI configuration:",F),console.error("[PieRoot] Error details:",{message:F.message,status:F.response?.status,data:F.response?.data}),J?.(F),x;if(b||!Q){if(V)console.log("[PieRoot] Loading state:",{isLoading:b,hasUiConfiguration:!!Q});return x}if(V)console.log("[PieRoot] UI configuration loaded successfully:",Q),console.log("[PieRoot] Rendering UI with configuration");return Z(d.Provider,{value:JU,children:Z(K.Provider,{value:VU,children:Z(W.Provider,{value:ZU,children:Z(X.Provider,{value:L??Z($L,{}),children:Z(s,{children:Z(i,{children:$?Z(y,{uiConfig:Q}):Z("form",{id:"piedata_global_form",action:H+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:Z(y,{uiConfig:Q})})})})})})})})},LL=(U)=>{let L=G(()=>new aU,[]),z=U.queryClient??L;return Z(e.Provider,{value:U.onNavigate,children:Z(P.Provider,{value:U.config,children:Z(D.Provider,{value:U.onError,children:Z(tU,{client:z,children:Z(UL,{...U})})})})})},zL=LL;export{j as useWebApp,hU as useInitData,zL as PieTelegramRoot};
|
|
2
|
+
import{useMemo as w}from"react";import{QueryClient as F$,QueryClientProvider as G$,useQuery as Q$}from"@tanstack/react-query";import RU from"mitt";import{createContext as MU,useCallback as b$,useContext as v$}from"react";var h=globalThis,F=(U,$)=>{let H=Symbol.for(U);if(!(H in h))h[H]=$();return h[H]};function i(){return F("@swarm.ing/pieui:mitt-emitter",()=>RU())}var AU=F("@swarm.ing/pieui:context:mitt",()=>MU(null));var k=AU;import{io as EU}from"socket.io-client";import{createContext as NU}from"react";var r=F("@swarm.ing/pieui:socket-cache",()=>new Map),a=(U)=>{let $=r.get(U);if($)return $;let H=EU(U,{autoConnect:!1,transports:["websocket"]});return r.set(U,H),H},PU=F("@swarm.ing/pieui:context:socket",()=>NU(null)),M=PU;import{createContext as jU}from"react";import{Centrifuge as t}from"centrifuge";var e=F("@swarm.ing/pieui:centrifuge-cache",()=>new Map),UU=(U,$)=>{if(!$)return null;let H=`${U}::${$}`,B=e.get(H);if(B)return B;async function J(){let Z=await fetch(U+"api/centrifuge/gen_token");if(!Z.ok){if(Z.status===403)throw new t.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${Z.status}`)}return(await Z.json()).token}let I=new t($,{getToken:J});return e.set(H,I),I},wU=F("@swarm.ing/pieui:context:centrifuge",()=>jU(null)),A=wU;import{useContext as vU,useEffect as CU}from"react";import{useEffect as kU,useState as xU}from"react";var x=new Map,f=new Map;function y(U,$){let H=`${U}::${$}`,B=U?x.get(H):void 0,[J,I]=xU(B??null);return kU(()=>{if(!U)return;if(x.has(H)){I(x.get(H));return}let Z=f.get(H);if(!Z)Z=fetch(U+`api/support/${$}`,{method:"GET"}).then((Y)=>Y.json()).then((Y)=>{return x.set(H,Y),f.delete(H),Y}).catch((Y)=>{throw f.delete(H),Y}),f.set(H,Z);let D=!1;return Z.then((Y)=>{if(!D)I(Y)}).catch(()=>{}),()=>{D=!0}},[U,$,H]),J}import{createContext as fU,useContext as yU}from"react";var l=F("@swarm.ing/pieui:context:pieConfig",()=>fU(null)),b=()=>{let U=yU(l);if(!U)throw Error("usePieConfig must be used within PieConfigProvider");return U},p=()=>{let{apiServer:U}=b();return U},v=p,$U=()=>{let{centrifugeServer:U}=b();return U};var R=()=>{let{enableRenderingLog:U}=b();return U},HU=R,IU=()=>{let{pageProcessor:U}=b();return U};var bU=F("@swarm.ing/pieui:sid-state",()=>({promise:null,resolve:null}));function JU(){bU.resolve?.()}var SU=({children:U})=>{let $=vU(M),H=v(),B=y(H,"socketIO"),J=(I)=>{if(typeof window<"u")window.sid=I.sid,JU(),console.log(`SocketIO initialized: ${window.sid}`)};return CU(()=>{if(!$)return;let I=()=>{console.log("SocketIO connected")},Z=(D)=>{console.log(`SocketIO disconnected: ${D}`),$.connect()};if(B)$.on("pieinit",J),$.on("connect",I),$.on("disconnect",Z),$.connect();return()=>{if(B)$.off("pieinit",J),$.off("connect",I),$.off("disconnect",Z),$.disconnect()}},[$,B]),U},ZU=SU;import{useContext as mU,useEffect as gU}from"react";var cU=({children:U})=>{let $=mU(A),H=v(),B=y(H,"centrifuge");return gU(()=>{if(!$)return;let J=()=>{console.log("Centrifuge connected")},I=(Z)=>{console.log("Centrifuge disconnected:",Z)};if(B)$.on("connected",J),$.on("disconnected",I),$.connect();return()=>{if(B)$.disconnect()}},[$,B]),U},BU=cU;import{createContext as hU}from"react";import{jsx as dU,Fragment as pU}from"react/jsx-runtime";var lU=F("@swarm.ing/pieui:context:fallback",()=>hU(dU(pU,{}))),E=lU;import{createContext as uU}from"react";var oU=F("@swarm.ing/pieui:context:lazyError",()=>uU(void 0)),N=oU;import{lazy as nU}from"react";var j=new Map;function sU(U,$){return $.catch(()=>{if(j.get(U)===$)j.delete(U)}),j.set(U,$),$}function XU(U,$){return nU(()=>{if(j.has($))return j.get($);return sU($,U().then((H)=>H))})}var YU=F("@swarm.ing/pieui:component-registry",()=>new Map),iU=(U)=>{if(!U.name)throw Error("Component registration requires a name");if(!U.component&&!U.loader)throw Error(`Component "${U.name}" requires component or loader`);let $={name:U.name,component:U.component,loader:U.loader,metadata:U.metadata,fallback:U.fallback,isLazy:!1};if(!$.component&&$.loader)$.component=XU($.loader,U.name),$.isLazy=!0;return $};function C(U){let $=iU(U);return YU.set($.name,$),$.component}var S=(U)=>{return YU.get(U)};import{useContext as zU,memo as $$}from"react";import{Component as rU,Suspense as aU}from"react";import{jsx as U$}from"react/jsx-runtime";var tU=2,eU=400;class P extends rU{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(U){if(this.props.onError?.(U),this.state.attempt<tU){let $=eU*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState((H)=>({failed:!1,attempt:H.attempt+1}))},$)}}componentDidUpdate(U){if(U.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return U$(aU,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}import{jsx as d}from"react/jsx-runtime";function H$({uiConfig:U,setUiAjaxConfiguration:$}){let H=zU(E),B=zU(N),J=R();if(J)console.log("[UI] Rendering component:",U.card),console.log("[UI] Component data:",U.data),console.log("[UI] Component content:",U.content),console.log("[UI] Has setUiAjaxConfiguration:",!!$);let I=S(U.card);if(!I?.component){if(J)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return H}if(J)console.log("[UI] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata});let Z=I.component,D=d(Z,{data:U.data,content:U.content,setUiAjaxConfiguration:$});if(I.isLazy){if(J)console.log("[UI] Rendering lazy component with Suspense:",I.name);return d(P,{name:I.name,fallback:I.fallback?d(I.fallback,{}):H,onError:B,children:D})}if(J)console.log("[UI] Rendering component directly:",I.name);return D}var u=$$(H$);import{createAxiosDateTransformer as T$}from"axios-date-transformer";import{useEffect as I$,useState as J$}from"react";var m=({onError:U}={})=>{let[$,H]=J$(null),B=IU();return I$(()=>{if(typeof window>"u")return;let J=window.Telegram?.WebApp;if(!J)return;try{J.ready?.()}catch(I){U?.()}if(B==="telegram_expanded"&&(J.platform==="ios"||J.platform==="android"))J.expand();H(J)},[]),$},Z$=()=>{let U=m();return[U?.initDataUnsafe,U?.initData]};import{createContext as B$}from"react";var X$=F("@swarm.ing/pieui:context:navigate",()=>B$(void 0)),DU=X$;import{useContext as GU}from"react";import{createContext as Y$}from"react";var z$=F("@swarm.ing/pieui:context:uiRenderer",()=>Y$(null)),FU=z$;import{jsx as g}from"react/jsx-runtime";function QU({uiConfig:U,setUiAjaxConfiguration:$}){let H=GU(E),B=GU(N),J=R();if(J)console.log("[UILoading] Rendering fallback for:",U.card),console.log("[UILoading] Component data:",U.data),console.log("[UILoading] Component content:",U.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!$);let I=S(U.card);if(!I?.component){if(J)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return H}if(J)console.log("[UILoading] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata,hasFallback:!!I.fallback});if(I.fallback){if(J)console.log("[UILoading] Rendering fallback for:",I.name);let Y=I.fallback;return g(Y,{})}if(J)console.log("[UILoading] No fallback, rendering full component:",I.name);let Z=I.component,D=g(FU.Provider,{value:QU,children:g(Z,{data:U.data,content:U.content,setUiAjaxConfiguration:$})});if(I.isLazy)return g(P,{name:I.name,fallback:H,onError:B,children:D});return D}var TU=QU;import{jsx as D$}from"react/jsx-runtime";function qU(U,$,H){if(!$)return H;let B=U.replace(/^\//,""),J=$[B];if(!J)return H;return D$(TU,{uiConfig:J})}import{jsx as q,Fragment as K$}from"react/jsx-runtime";var q$=({location:U,fallback:$,piecache:H,onError:B,queryOptions:J,disableGlobalForm:I})=>{let Z=p(),D=$U(),Y=R(),G=w(()=>T$({baseURL:Z}),[Z]),X=w(()=>i(),[]),W=w(()=>Z?a(Z):null,[Z]),V=w(()=>Z?UU(Z,D):null,[Z,D]),L=m({onError:B}),{data:K,isLoading:O,error:z}=Q$({queryKey:["uiConfig",U.pathname+U.search,L?.initData],enabled:!!L?.initData,queryFn:async()=>{let T=new URLSearchParams(U.search);if(T.set("__pieroot","telegram"),L?.initData)T.set("initData",L.initData);let _="/api/content"+U.pathname+"?"+T.toString();if(Y)console.log("[PieRoot] Fetching UI configuration from:",_);let s=await G.get(_,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(Y)console.log("[PieRoot] Received UI configuration:",s.data);return s.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(T)=>Math.min(1000*2**T,30000),...J}),Q=qU(U.pathname,H,$);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(z&&Y)return console.error("[PieRoot] Error fetching UI configuration:",z),console.error("[PieRoot] Error details:",{message:z.message,status:z.response?.status,data:z.response?.data}),B?.(z),Q;if(O||!K){if(Y)console.log("[PieRoot] Loading state:",{isLoading:O,hasUiConfiguration:!!K});return Q}if(Y)console.log("[PieRoot] UI configuration loaded successfully:",K),console.log("[PieRoot] Rendering UI with configuration");return q(k.Provider,{value:X,children:q(M.Provider,{value:W,children:q(A.Provider,{value:V,children:q(E.Provider,{value:$??q(K$,{}),children:q(ZU,{children:q(BU,{children:I?q(u,{uiConfig:K}):q("form",{id:"piedata_global_form",action:Z+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:q(u,{uiConfig:K})})})})})})})})},L$=(U)=>{let $=w(()=>new F$,[]),H=U.queryClient??$;return q(DU.Provider,{value:U.onNavigate,children:q(l.Provider,{value:U.config,children:q(N.Provider,{value:U.onError,children:q(G$,{client:H,children:q(q$,{...U})})})})})},O$=L$;import{useEffect as LU,useState as A$}from"react";import{useContext as o,useEffect as n,useRef as _$}from"react";import{jsx as R$,jsxs as M$,Fragment as V$}from"react/jsx-runtime";var W$=({card:U,data:$,children:H,useSocketioSupport:B=!1,useCentrifugeSupport:J=!1,useMittSupport:I=!1,centrifugeChannel:Z=void 0,methods:D=void 0,stored:Y=void 0})=>{let G=HU(),X=_$(D);if(X.current=D,G)console.log("[PieCard] Rendering card:",U),console.log("[PieCard] Card data:",$),console.log("[PieCard] Component name:",$?.name),console.log("[PieCard] Real-time support:",{socketio:B,centrifuge:J,mitt:I,centrifugeChannel:Z}),console.log("[PieCard] Methods:",D?Object.keys(D):"none"),console.log("[PieCard] Has children:",!!H);let W=o(M),V=o(A),L=o(k);if(n(()=>{if(!W||!B||!X.current||!$.name){if(G&&B)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!W,useSocketioSupport:B,hasMethods:!!X.current,hasDataName:!!$?.name});return}let O=Object.keys(X.current??{}).map((z)=>{let Q=`pie${z}_${$.name}`;if(G)console.log(`[PieCard] Socket.IO registering event: ${Q}`);let T=(_)=>{X.current?.[z]?.(_)};return W.on(Q,T),[Q,T]});return()=>{O.forEach(([z,Q])=>{if(G)console.log(`[PieCard] Socket.IO unregistering event: ${z}`);W.off(z,Q)})}},[W,$.name,B]),n(()=>{if(!V||!J||!Z||!$.name){if(G&&J)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!V,useCentrifugeSupport:J,hasCentrifugeChannel:!!Z,hasMethods:!!X.current,hasDataName:!!$?.name});return}let O=Object.keys(X.current??{}).map((z)=>{let Q=`pie${z}_${$.name}_${Z}`;if(G)console.log(`[PieCard] Centrifuge subscribing to channel: ${Q}`);let T=V.newSubscription(Q);return T.on("publication",(_)=>{if(G)console.log(`[PieCard] Centrifuge received data on ${Q}:`,_.data);X.current?.[z]?.(_.data)}),T.subscribe(),T});return()=>{O.forEach((z)=>{if(G)console.log("[PieCard] Centrifuge unsubscribing from channel");z.unsubscribe(),V.removeSubscription(z)})}},[V,Z,$.name,J]),n(()=>{if(!L||!I||!$.name){if(G&&I)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!L,useMittSupport:I,hasMethods:!!X.current,hasDataName:!!$?.name});return}let K=Object.keys(X.current??{}),O={};return K.forEach((z)=>{let Q=`pie${z}_${$.name}`,T=(_)=>{if(G)console.log(`[PieCard] Mitt registering event: ${Q}`);X.current?.[z]?.(_)};O[Q]=T,L.on(Q,T)}),()=>{Object.entries(O).forEach(([z,Q])=>{if(G)console.log(`[PieCard] Mitt unregistering event: ${z}`);L.off(z,Q)})}},[L,$.name,I]),G)console.log("[PieCard] Rendering complete, returning children");if(Y!==void 0)return M$(V$,{children:[R$("input",{type:"hidden",name:$.name,value:JSON.stringify(Y)}),H]});return H},c=W$;import{jsx as KU}from"react/jsx-runtime";var E$=({data:U})=>{let{name:$,key:H,value:B,useSocketioSupport:J,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:D}=U,[Y,G]=A$(B);return LU(()=>{G(B)},[B]),LU(()=>{if(typeof window>"u")return;let X=window.Telegram?.WebApp?.CloudStorage;if(!X)return;X.setItem(H,Y)},[H,Y]),KU(c,{card:"CloudStorageCard",data:U,useSocketioSupport:J,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:D,methods:{update:({value:X})=>{G(X)},remove:()=>{let X=window.Telegram?.WebApp?.CloudStorage;if(X)X.removeItem(H);G("")}},children:KU("input",{type:"hidden",id:$,name:$,value:Y})})},OU=E$;var N$=C({name:"CloudStorageCard",component:OU,metadata:{author:"PieData"}});import{useEffect as _U,useState as P$}from"react";import{jsx as WU}from"react/jsx-runtime";var j$=({data:U})=>{let{name:$,key:H,value:B,useSocketioSupport:J,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:D}=U,[Y,G]=P$(B);return _U(()=>{G(B)},[B]),_U(()=>{if(typeof window>"u")return;let X=window.Telegram?.WebApp?.SecureStorage;if(!X)return;X.setItem(H,Y)},[H,Y]),WU(c,{card:"SecureStorageCard",data:U,useSocketioSupport:J,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:D,methods:{update:({value:X})=>{G(X)},remove:()=>{let X=window.Telegram?.WebApp?.SecureStorage;if(X)X.removeItem(H);G("")}},children:WU("input",{type:"hidden",id:$,name:$,value:Y})})},VU=j$;var w$=C({name:"SecureStorageCard",component:VU,metadata:{author:"PieData"}});export{m as useWebApp,Z$ as useInitData,w$ as SecureStorageCard,O$ as PieTelegramRoot,N$ as CloudStorageCard};
|
package/dist/telegram/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var xU=Object.create;var{getPrototypeOf:CU,defineProperty:K,getOwnPropertyNames:r,getOwnPropertyDescriptor:vU}=Object,e=Object.prototype.hasOwnProperty;var mU=(U,L,$)=>{$=U!=null?xU(CU(U)):{};let H=L||!U||!U.__esModule?K($,"default",{value:U,enumerable:!0}):$;for(let I of r(U))if(!e.call(H,I))K(H,I,{get:()=>U[I],enumerable:!0});return H},t=new WeakMap,dU=(U)=>{var L=t.get(U),$;if(L)return L;if(L=K({},"__esModule",{value:!0}),U&&typeof U==="object"||typeof U==="function")r(U).map((H)=>!e.call(L,H)&&K(L,H,{get:()=>U[H],enumerable:!($=vU(U,H))||$.enumerable}));return t.set(U,L),L};var uU=(U,L)=>{for(var $ in L)K(U,$,{get:L[$],enumerable:!0,configurable:!0,set:(H)=>L[$]=()=>H})};var zL={};uU(zL,{useWebApp:()=>_,useInitData:()=>WU,PieTelegramRoot:()=>PU});module.exports=dU(zL);var Q=require("react"),q=require("@tanstack/react-query");var UU=mU(require("mitt")),T=require("react"),g=null;function LU(){if(!g)g=UU.default();return g}var gU=T.createContext(null);var $U=gU;var IU=require("socket.io-client"),HU=require("react"),zU=new Map,JU=(U)=>{let L=zU.get(U);if(L)return L;let $=IU.io(U,{autoConnect:!1,transports:["websocket"]});return zU.set(U,$),$},cU=HU.createContext(null),E=cU;var ZU=require("react"),c=require("centrifuge"),VU=new Map,BU=(U,L)=>{if(!L)return null;let $=`${U}::${L}`,H=VU.get($);if(H)return H;async function I(){let J=await fetch(U+"api/centrifuge/gen_token");if(!J.ok){if(J.status===403)throw new c.Centrifuge.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${J.status}`)}return(await J.json()).token}let z=new c.Centrifuge(L,{getToken:I});return VU.set($,z),z},lU=ZU.createContext(null),A=lU;var b=require("react");var k=require("react"),j=new Map,f=new Map;function P(U,L){let $=`${U}::${L}`,H=U?j.get($):void 0,[I,z]=k.useState(H??null);return k.useEffect(()=>{if(!U)return;if(j.has($)){z(j.get($));return}let J=f.get($);if(!J)J=fetch(U+`api/support/${L}`,{method:"GET"}).then((Z)=>Z.json()).then((Z)=>{return j.set($,Z),f.delete($),Z}).catch((Z)=>{throw f.delete($),Z}),f.set($,J);let B=!1;return J.then((Z)=>{if(!B)z(Z)}).catch(()=>{}),()=>{B=!0}},[U,L,$]),I}var S=require("react"),l=S.createContext(null),w=()=>{let U=S.useContext(l);if(!U)throw Error("usePieConfig must be used within PieConfigProvider");return U},h=()=>{let{apiServer:U}=w();return U},y=h,FU=()=>{let{centrifugeServer:U}=w();return U};var N=()=>{let{enableRenderingLog:U}=w();return U};var NU=()=>{let{pageProcessor:U}=w();return U};var hU=null;function XU(){hU?.()}var oU=({children:U})=>{let L=b.useContext(E),$=y(),H=P($,"socketIO"),I=(z)=>{if(typeof window<"u")window.sid=z.sid,XU(),console.log(`SocketIO initialized: ${window.sid}`)};return b.useEffect(()=>{if(!L)return;let z=()=>{console.log("SocketIO connected")},J=(B)=>{console.log(`SocketIO disconnected: ${B}`),L.connect()};if(H)L.on("pieinit",I),L.on("connect",z),L.on("disconnect",J),L.connect();return()=>{if(H)L.off("pieinit",I),L.off("connect",z),L.off("disconnect",J),L.disconnect()}},[L,H]),U},DU=oU;var x=require("react");var pU=({children:U})=>{let L=x.useContext(A),$=y(),H=P($,"centrifuge");return x.useEffect(()=>{if(!L)return;let I=()=>{console.log("Centrifuge connected")},z=(J)=>{console.log("Centrifuge disconnected:",J)};if(H)L.on("connected",I),L.on("disconnected",z),L.connect();return()=>{if(H)L.disconnect()}},[L,H]),U},OU=pU;var QU=require("react"),C=require("react/jsx-runtime"),nU=QU.createContext(C.jsx(C.Fragment,{})),X=nU;var qU=require("react"),sU=qU.createContext(void 0),D=sU;var GU=Symbol.for("@swarm.ing/pieui:component-registry"),YU=globalThis,iU=YU[GU]??(YU[GU]=new Map);var v=(U)=>{return iU.get(U)};var W=require("react");var m=require("react"),KU=require("react/jsx-runtime"),aU=2,tU=400;class O extends m.Component{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(U){if(this.props.onError?.(U),this.state.attempt<aU){let L=tU*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState(($)=>({failed:!1,attempt:$.attempt+1}))},L)}}componentDidUpdate(U){if(U.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return KU.jsx(m.Suspense,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}var d=require("react/jsx-runtime");function rU({uiConfig:U,setUiAjaxConfiguration:L}){let $=W.useContext(X),H=W.useContext(D),I=N();if(I)console.log("[UI] Rendering component:",U.card),console.log("[UI] Component data:",U.data),console.log("[UI] Component content:",U.content),console.log("[UI] Has setUiAjaxConfiguration:",!!L);let z=v(U.card);if(!z?.component){if(I)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return $}if(I)console.log("[UI] Found component in registry:",{name:z.name,isLazy:z.isLazy,hasMetadata:!!z.metadata});let J=z.component,B=d.jsx(J,{data:U.data,content:U.content,setUiAjaxConfiguration:L});if(z.isLazy){if(I)console.log("[UI] Rendering lazy component with Suspense:",z.name);return d.jsx(O,{name:z.name,fallback:z.fallback?d.jsx(z.fallback,{}):$,onError:H,children:B})}if(I)console.log("[UI] Rendering component directly:",z.name);return B}var o=W.memo(rU);var kU=require("axios-date-transformer");var u=require("react");var _=({onError:U}={})=>{let[L,$]=u.useState(null),H=NU();return u.useEffect(()=>{if(typeof window>"u")return;let I=window.Telegram?.WebApp;if(!I)return;try{I.ready?.()}catch(z){U?.()}if(H==="telegram_expanded"&&(I.platform==="ios"||I.platform==="android"))I.expand();$(I)},[]),L},WU=()=>{let U=_();return[U?.initDataUnsafe,U?.initData]};var _U=require("react"),eU=_U.createContext(void 0),MU=eU;var p=require("react");var RU=require("react"),UL=RU.createContext(null),TU=UL;var M=require("react/jsx-runtime");function EU({uiConfig:U,setUiAjaxConfiguration:L}){let $=p.useContext(X),H=p.useContext(D),I=N();if(I)console.log("[UILoading] Rendering fallback for:",U.card),console.log("[UILoading] Component data:",U.data),console.log("[UILoading] Component content:",U.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!L);let z=v(U.card);if(!z?.component){if(I)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return $}if(I)console.log("[UILoading] Found component in registry:",{name:z.name,isLazy:z.isLazy,hasMetadata:!!z.metadata,hasFallback:!!z.fallback});if(z.fallback){if(I)console.log("[UILoading] Rendering fallback for:",z.name);let Z=z.fallback;return M.jsx(Z,{})}if(I)console.log("[UILoading] No fallback, rendering full component:",z.name);let J=z.component,B=M.jsx(TU.Provider,{value:EU,children:M.jsx(J,{data:U.data,content:U.content,setUiAjaxConfiguration:L})});if(z.isLazy)return M.jsx(O,{name:z.name,fallback:$,onError:H,children:B});return B}var AU=EU;var fU=require("react/jsx-runtime");function jU(U,L,$){if(!L)return $;let H=U.replace(/^\//,""),I=L[H];if(!I)return $;return fU.jsx(AU,{uiConfig:I})}var V=require("react/jsx-runtime"),LL=({location:U,fallback:L,piecache:$,onError:H,queryOptions:I,disableGlobalForm:z})=>{let J=h(),B=FU(),Z=N(),SU=Q.useMemo(()=>kU.createAxiosDateTransformer({baseURL:J}),[J]),wU=Q.useMemo(()=>LU(),[]),yU=Q.useMemo(()=>J?JU(J):null,[J]),bU=Q.useMemo(()=>J?BU(J,B):null,[J,B]),R=_({onError:H}),{data:G,isLoading:n,error:F}=q.useQuery({queryKey:["uiConfig",U.pathname+U.search,R?.initData],enabled:!!R?.initData,queryFn:async()=>{let Y=new URLSearchParams(U.search);if(Y.set("__pieroot","telegram"),R?.initData)Y.set("initData",R.initData);let i="/api/content"+U.pathname+"?"+Y.toString();if(Z)console.log("[PieRoot] Fetching UI configuration from:",i);let a=await SU.get(i,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(Z)console.log("[PieRoot] Received UI configuration:",a.data);return a.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Y)=>Math.min(1000*2**Y,30000),...I}),s=jU(U.pathname,$,L);if(!J)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(F&&Z)return console.error("[PieRoot] Error fetching UI configuration:",F),console.error("[PieRoot] Error details:",{message:F.message,status:F.response?.status,data:F.response?.data}),H?.(F),s;if(n||!G){if(Z)console.log("[PieRoot] Loading state:",{isLoading:n,hasUiConfiguration:!!G});return s}if(Z)console.log("[PieRoot] UI configuration loaded successfully:",G),console.log("[PieRoot] Rendering UI with configuration");return V.jsx($U.Provider,{value:wU,children:V.jsx(E.Provider,{value:yU,children:V.jsx(A.Provider,{value:bU,children:V.jsx(X.Provider,{value:L??V.jsx(V.Fragment,{}),children:V.jsx(DU,{children:V.jsx(OU,{children:z?V.jsx(o,{uiConfig:G}):V.jsx("form",{id:"piedata_global_form",action:J+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:V.jsx(o,{uiConfig:G})})})})})})})})},$L=(U)=>{let L=Q.useMemo(()=>new q.QueryClient,[]),$=U.queryClient??L;return V.jsx(MU.Provider,{value:U.onNavigate,children:V.jsx(l.Provider,{value:U.config,children:V.jsx(D.Provider,{value:U.onError,children:V.jsx(q.QueryClientProvider,{client:$,children:V.jsx(LL,{...U})})})})})},PU=$L;
|
|
2
|
+
var aU=Object.create;var{getPrototypeOf:tU,defineProperty:f,getOwnPropertyNames:QU,getOwnPropertyDescriptor:eU}=Object,TU=Object.prototype.hasOwnProperty;var U$=(U,$,H)=>{H=U!=null?aU(tU(U)):{};let J=$||!U||!U.__esModule?f(H,"default",{value:U,enumerable:!0}):H;for(let Z of QU(U))if(!TU.call(J,Z))f(J,Z,{get:()=>U[Z],enumerable:!0});return J},GU=new WeakMap,$$=(U)=>{var $=GU.get(U),H;if($)return $;if($=f({},"__esModule",{value:!0}),U&&typeof U==="object"||typeof U==="function")QU(U).map((J)=>!TU.call($,J)&&f($,J,{get:()=>U[J],enumerable:!(H=eU(U,J))||H.enumerable}));return GU.set(U,$),$};var H$=(U,$)=>{for(var H in $)f(U,H,{get:$[H],enumerable:!0,configurable:!0,set:(J)=>$[H]=()=>J})};var M$={};H$(M$,{useWebApp:()=>v,useInitData:()=>CU,SecureStorageCard:()=>rU,PieTelegramRoot:()=>oU,CloudStorageCard:()=>sU});module.exports=$$(M$);var w=require("react"),k=require("@tanstack/react-query");var qU=U$(require("mitt")),g=require("react");var IU=globalThis,F=(U,$)=>{let H=Symbol.for(U);if(!(H in IU))IU[H]=$();return IU[H]};function LU(){return F("@swarm.ing/pieui:mitt-emitter",()=>qU.default())}var I$=F("@swarm.ing/pieui:context:mitt",()=>g.createContext(null));var c=I$;var OU=require("socket.io-client"),_U=require("react");var KU=F("@swarm.ing/pieui:socket-cache",()=>new Map),WU=(U)=>{let $=KU.get(U);if($)return $;let H=OU.io(U,{autoConnect:!1,transports:["websocket"]});return KU.set(U,H),H},J$=F("@swarm.ing/pieui:context:socket",()=>_U.createContext(null)),A=J$;var RU=require("react"),JU=require("centrifuge");var VU=F("@swarm.ing/pieui:centrifuge-cache",()=>new Map),MU=(U,$)=>{if(!$)return null;let H=`${U}::${$}`,J=VU.get(H);if(J)return J;async function Z(){let B=await fetch(U+"api/centrifuge/gen_token");if(!B.ok){if(B.status===403)throw new JU.Centrifuge.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${B.status}`)}return(await B.json()).token}let I=new JU.Centrifuge($,{getToken:Z});return VU.set(H,I),I},Z$=F("@swarm.ing/pieui:context:centrifuge",()=>RU.createContext(null)),E=Z$;var s=require("react");var p=require("react"),h=new Map,l=new Map;function d(U,$){let H=`${U}::${$}`,J=U?h.get(H):void 0,[Z,I]=p.useState(J??null);return p.useEffect(()=>{if(!U)return;if(h.has(H)){I(h.get(H));return}let B=l.get(H);if(!B)B=fetch(U+`api/support/${$}`,{method:"GET"}).then((Y)=>Y.json()).then((Y)=>{return h.set(H,Y),l.delete(H),Y}).catch((Y)=>{throw l.delete(H),Y}),l.set(H,B);let D=!1;return B.then((Y)=>{if(!D)I(Y)}).catch(()=>{}),()=>{D=!0}},[U,$,H]),Z}var u=require("react");var ZU=F("@swarm.ing/pieui:context:pieConfig",()=>u.createContext(null)),o=()=>{let U=u.useContext(ZU);if(!U)throw Error("usePieConfig must be used within PieConfigProvider");return U},BU=()=>{let{apiServer:U}=o();return U},n=BU,AU=()=>{let{centrifugeServer:U}=o();return U};var M=()=>{let{enableRenderingLog:U}=o();return U},EU=M,NU=()=>{let{pageProcessor:U}=o();return U};var B$=F("@swarm.ing/pieui:sid-state",()=>({promise:null,resolve:null}));function PU(){B$.resolve?.()}var X$=({children:U})=>{let $=s.useContext(A),H=n(),J=d(H,"socketIO"),Z=(I)=>{if(typeof window<"u")window.sid=I.sid,PU(),console.log(`SocketIO initialized: ${window.sid}`)};return s.useEffect(()=>{if(!$)return;let I=()=>{console.log("SocketIO connected")},B=(D)=>{console.log(`SocketIO disconnected: ${D}`),$.connect()};if(J)$.on("pieinit",Z),$.on("connect",I),$.on("disconnect",B),$.connect();return()=>{if(J)$.off("pieinit",Z),$.off("connect",I),$.off("disconnect",B),$.disconnect()}},[$,J]),U},jU=X$;var i=require("react");var Y$=({children:U})=>{let $=i.useContext(E),H=n(),J=d(H,"centrifuge");return i.useEffect(()=>{if(!$)return;let Z=()=>{console.log("Centrifuge connected")},I=(B)=>{console.log("Centrifuge disconnected:",B)};if(J)$.on("connected",Z),$.on("disconnected",I),$.connect();return()=>{if(J)$.disconnect()}},[$,J]),U},wU=Y$;var kU=require("react");var r=require("react/jsx-runtime"),z$=F("@swarm.ing/pieui:context:fallback",()=>kU.createContext(r.jsx(r.Fragment,{}))),N=z$;var xU=require("react");var D$=F("@swarm.ing/pieui:context:lazyError",()=>xU.createContext(void 0)),P=D$;var fU=require("react"),y=new Map;function F$(U,$){return $.catch(()=>{if(y.get(U)===$)y.delete(U)}),y.set(U,$),$}function yU(U,$){return fU.lazy(()=>{if(y.has($))return y.get($);return F$($,U().then((H)=>H))})}var bU=F("@swarm.ing/pieui:component-registry",()=>new Map),G$=(U)=>{if(!U.name)throw Error("Component registration requires a name");if(!U.component&&!U.loader)throw Error(`Component "${U.name}" requires component or loader`);let $={name:U.name,component:U.component,loader:U.loader,metadata:U.metadata,fallback:U.fallback,isLazy:!1};if(!$.component&&$.loader)$.component=yU($.loader,U.name),$.isLazy=!0;return $};function a(U){let $=G$(U);return bU.set($.name,$),$.component}var t=(U)=>{return bU.get(U)};var b=require("react");var e=require("react"),vU=require("react/jsx-runtime"),Q$=2,T$=400;class j extends e.Component{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(U){if(this.props.onError?.(U),this.state.attempt<Q$){let $=T$*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState((H)=>({failed:!1,attempt:H.attempt+1}))},$)}}componentDidUpdate(U){if(U.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return vU.jsx(e.Suspense,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}var UU=require("react/jsx-runtime");function q$({uiConfig:U,setUiAjaxConfiguration:$}){let H=b.useContext(N),J=b.useContext(P),Z=M();if(Z)console.log("[UI] Rendering component:",U.card),console.log("[UI] Component data:",U.data),console.log("[UI] Component content:",U.content),console.log("[UI] Has setUiAjaxConfiguration:",!!$);let I=t(U.card);if(!I?.component){if(Z)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return H}if(Z)console.log("[UI] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata});let B=I.component,D=UU.jsx(B,{data:U.data,content:U.content,setUiAjaxConfiguration:$});if(I.isLazy){if(Z)console.log("[UI] Rendering lazy component with Suspense:",I.name);return UU.jsx(j,{name:I.name,fallback:I.fallback?UU.jsx(I.fallback,{}):H,onError:J,children:D})}if(Z)console.log("[UI] Rendering component directly:",I.name);return D}var XU=b.memo(q$);var uU=require("axios-date-transformer");var $U=require("react");var v=({onError:U}={})=>{let[$,H]=$U.useState(null),J=NU();return $U.useEffect(()=>{if(typeof window>"u")return;let Z=window.Telegram?.WebApp;if(!Z)return;try{Z.ready?.()}catch(I){U?.()}if(J==="telegram_expanded"&&(Z.platform==="ios"||Z.platform==="android"))Z.expand();H(Z)},[]),$},CU=()=>{let U=v();return[U?.initDataUnsafe,U?.initData]};var SU=require("react");var L$=F("@swarm.ing/pieui:context:navigate",()=>SU.createContext(void 0)),mU=L$;var YU=require("react");var gU=require("react");var K$=F("@swarm.ing/pieui:context:uiRenderer",()=>gU.createContext(null)),cU=K$;var C=require("react/jsx-runtime");function hU({uiConfig:U,setUiAjaxConfiguration:$}){let H=YU.useContext(N),J=YU.useContext(P),Z=M();if(Z)console.log("[UILoading] Rendering fallback for:",U.card),console.log("[UILoading] Component data:",U.data),console.log("[UILoading] Component content:",U.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!$);let I=t(U.card);if(!I?.component){if(Z)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return H}if(Z)console.log("[UILoading] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata,hasFallback:!!I.fallback});if(I.fallback){if(Z)console.log("[UILoading] Rendering fallback for:",I.name);let Y=I.fallback;return C.jsx(Y,{})}if(Z)console.log("[UILoading] No fallback, rendering full component:",I.name);let B=I.component,D=C.jsx(cU.Provider,{value:hU,children:C.jsx(B,{data:U.data,content:U.content,setUiAjaxConfiguration:$})});if(I.isLazy)return C.jsx(j,{name:I.name,fallback:H,onError:J,children:D});return D}var lU=hU;var dU=require("react/jsx-runtime");function pU(U,$,H){if(!$)return H;let J=U.replace(/^\//,""),Z=$[J];if(!Z)return H;return dU.jsx(lU,{uiConfig:Z})}var T=require("react/jsx-runtime"),O$=({location:U,fallback:$,piecache:H,onError:J,queryOptions:Z,disableGlobalForm:I})=>{let B=BU(),D=AU(),Y=M(),G=w.useMemo(()=>uU.createAxiosDateTransformer({baseURL:B}),[B]),X=w.useMemo(()=>LU(),[]),V=w.useMemo(()=>B?WU(B):null,[B]),R=w.useMemo(()=>B?MU(B,D):null,[B,D]),L=v({onError:J}),{data:O,isLoading:_,error:z}=k.useQuery({queryKey:["uiConfig",U.pathname+U.search,L?.initData],enabled:!!L?.initData,queryFn:async()=>{let q=new URLSearchParams(U.search);if(q.set("__pieroot","telegram"),L?.initData)q.set("initData",L.initData);let W="/api/content"+U.pathname+"?"+q.toString();if(Y)console.log("[PieRoot] Fetching UI configuration from:",W);let FU=await G.get(W,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(Y)console.log("[PieRoot] Received UI configuration:",FU.data);return FU.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(q)=>Math.min(1000*2**q,30000),...Z}),Q=pU(U.pathname,H,$);if(!B)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(z&&Y)return console.error("[PieRoot] Error fetching UI configuration:",z),console.error("[PieRoot] Error details:",{message:z.message,status:z.response?.status,data:z.response?.data}),J?.(z),Q;if(_||!O){if(Y)console.log("[PieRoot] Loading state:",{isLoading:_,hasUiConfiguration:!!O});return Q}if(Y)console.log("[PieRoot] UI configuration loaded successfully:",O),console.log("[PieRoot] Rendering UI with configuration");return T.jsx(c.Provider,{value:X,children:T.jsx(A.Provider,{value:V,children:T.jsx(E.Provider,{value:R,children:T.jsx(N.Provider,{value:$??T.jsx(T.Fragment,{}),children:T.jsx(jU,{children:T.jsx(wU,{children:I?T.jsx(XU,{uiConfig:O}):T.jsx("form",{id:"piedata_global_form",action:B+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:T.jsx(XU,{uiConfig:O})})})})})})})})},_$=(U)=>{let $=w.useMemo(()=>new k.QueryClient,[]),H=U.queryClient??$;return T.jsx(mU.Provider,{value:U.onNavigate,children:T.jsx(ZU.Provider,{value:U.config,children:T.jsx(P.Provider,{value:U.onError,children:T.jsx(k.QueryClientProvider,{client:H,children:T.jsx(O$,{...U})})})})})},oU=_$;var S=require("react");var K=require("react");var x=require("react/jsx-runtime"),W$=({card:U,data:$,children:H,useSocketioSupport:J=!1,useCentrifugeSupport:Z=!1,useMittSupport:I=!1,centrifugeChannel:B=void 0,methods:D=void 0,stored:Y=void 0})=>{let G=EU(),X=K.useRef(D);if(X.current=D,G)console.log("[PieCard] Rendering card:",U),console.log("[PieCard] Card data:",$),console.log("[PieCard] Component name:",$?.name),console.log("[PieCard] Real-time support:",{socketio:J,centrifuge:Z,mitt:I,centrifugeChannel:B}),console.log("[PieCard] Methods:",D?Object.keys(D):"none"),console.log("[PieCard] Has children:",!!H);let V=K.useContext(A),R=K.useContext(E),L=K.useContext(c);if(K.useEffect(()=>{if(!V||!J||!X.current||!$.name){if(G&&J)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!V,useSocketioSupport:J,hasMethods:!!X.current,hasDataName:!!$?.name});return}let _=Object.keys(X.current??{}).map((z)=>{let Q=`pie${z}_${$.name}`;if(G)console.log(`[PieCard] Socket.IO registering event: ${Q}`);let q=(W)=>{X.current?.[z]?.(W)};return V.on(Q,q),[Q,q]});return()=>{_.forEach(([z,Q])=>{if(G)console.log(`[PieCard] Socket.IO unregistering event: ${z}`);V.off(z,Q)})}},[V,$.name,J]),K.useEffect(()=>{if(!R||!Z||!B||!$.name){if(G&&Z)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!R,useCentrifugeSupport:Z,hasCentrifugeChannel:!!B,hasMethods:!!X.current,hasDataName:!!$?.name});return}let _=Object.keys(X.current??{}).map((z)=>{let Q=`pie${z}_${$.name}_${B}`;if(G)console.log(`[PieCard] Centrifuge subscribing to channel: ${Q}`);let q=R.newSubscription(Q);return q.on("publication",(W)=>{if(G)console.log(`[PieCard] Centrifuge received data on ${Q}:`,W.data);X.current?.[z]?.(W.data)}),q.subscribe(),q});return()=>{_.forEach((z)=>{if(G)console.log("[PieCard] Centrifuge unsubscribing from channel");z.unsubscribe(),R.removeSubscription(z)})}},[R,B,$.name,Z]),K.useEffect(()=>{if(!L||!I||!$.name){if(G&&I)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!L,useMittSupport:I,hasMethods:!!X.current,hasDataName:!!$?.name});return}let O=Object.keys(X.current??{}),_={};return O.forEach((z)=>{let Q=`pie${z}_${$.name}`,q=(W)=>{if(G)console.log(`[PieCard] Mitt registering event: ${Q}`);X.current?.[z]?.(W)};_[Q]=q,L.on(Q,q)}),()=>{Object.entries(_).forEach(([z,Q])=>{if(G)console.log(`[PieCard] Mitt unregistering event: ${z}`);L.off(z,Q)})}},[L,$.name,I]),G)console.log("[PieCard] Rendering complete, returning children");if(Y!==void 0)return x.jsxs(x.Fragment,{children:[x.jsx("input",{type:"hidden",name:$.name,value:JSON.stringify(Y)}),H]});return H},HU=W$;var zU=require("react/jsx-runtime"),V$=({data:U})=>{let{name:$,key:H,value:J,useSocketioSupport:Z,useCentrifugeSupport:I,useMittSupport:B,centrifugeChannel:D}=U,[Y,G]=S.useState(J);return S.useEffect(()=>{G(J)},[J]),S.useEffect(()=>{if(typeof window>"u")return;let X=window.Telegram?.WebApp?.CloudStorage;if(!X)return;X.setItem(H,Y)},[H,Y]),zU.jsx(HU,{card:"CloudStorageCard",data:U,useSocketioSupport:Z,useCentrifugeSupport:I,useMittSupport:B,centrifugeChannel:D,methods:{update:({value:X})=>{G(X)},remove:()=>{let X=window.Telegram?.WebApp?.CloudStorage;if(X)X.removeItem(H);G("")}},children:zU.jsx("input",{type:"hidden",id:$,name:$,value:Y})})},nU=V$;var sU=a({name:"CloudStorageCard",component:nU,metadata:{author:"PieData"}});var m=require("react");var DU=require("react/jsx-runtime"),R$=({data:U})=>{let{name:$,key:H,value:J,useSocketioSupport:Z,useCentrifugeSupport:I,useMittSupport:B,centrifugeChannel:D}=U,[Y,G]=m.useState(J);return m.useEffect(()=>{G(J)},[J]),m.useEffect(()=>{if(typeof window>"u")return;let X=window.Telegram?.WebApp?.SecureStorage;if(!X)return;X.setItem(H,Y)},[H,Y]),DU.jsx(HU,{card:"SecureStorageCard",data:U,useSocketioSupport:Z,useCentrifugeSupport:I,useMittSupport:B,centrifugeChannel:D,methods:{update:({value:X})=>{G(X)},remove:()=>{let X=window.Telegram?.WebApp?.SecureStorage;if(X)X.removeItem(H);G("")}},children:DU.jsx("input",{type:"hidden",id:$,name:$,value:Y})})},iU=R$;var rU=a({name:"SecureStorageCard",component:iU,metadata:{author:"PieData"}});
|
|
@@ -27,23 +27,64 @@ export type GetAjaxSubmitOptions = {
|
|
|
27
27
|
retryPolicy?: RetryPolicy;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
30
|
+
* The origin a dep value is read from. `dom` is the default for any name
|
|
31
|
+
* without a recognized prefix.
|
|
32
|
+
*/
|
|
33
|
+
export type DepSource = 'dom' | 'sid' | 'localStorage' | 'sessionStorage' | 'cookie' | 'url' | 'telegram:cloud' | 'telegram:secure';
|
|
34
|
+
/**
|
|
35
|
+
* Splits a dep name into its source and bare key, following the magic-name
|
|
36
|
+
* convention used by Ajax cards.
|
|
37
|
+
*
|
|
38
|
+
* - `'sid'` → `{ source: 'sid', key: 'sid' }` (SocketIO session id).
|
|
39
|
+
* - `'localStorage:token'` → `{ source: 'localStorage', key: 'token' }`; the
|
|
40
|
+
* same for `sessionStorage:`, `cookie:`, `url:`, `telegram:cloud:` and
|
|
41
|
+
* `telegram:secure:` prefixes.
|
|
42
|
+
* - Anything else (including a name that contains a colon but no recognized
|
|
43
|
+
* prefix) → `{ source: 'dom', key: <name> }`.
|
|
33
44
|
*
|
|
45
|
+
* The returned `key` is what gets sent to the backend as the field name, so a
|
|
46
|
+
* prefixed dep is submitted under its bare key (`localStorage:token` → `token`).
|
|
47
|
+
*/
|
|
48
|
+
export declare const parseDepName: (depName: string) => {
|
|
49
|
+
source: DepSource;
|
|
50
|
+
key: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Reads the value(s) for a single dep name, following the same convention used
|
|
54
|
+
* by Ajax cards. Returns an array because file inputs (and cookies / repeated
|
|
55
|
+
* URL params) can contribute multiple values for the same key.
|
|
56
|
+
*
|
|
57
|
+
* The source is determined by {@link parseDepName}:
|
|
34
58
|
* - `'sid'` resolves to `window.sid`. The caller must ensure SocketIO is
|
|
35
59
|
* ready (e.g. via {@link waitForSidAvailable}) before calling this.
|
|
36
|
-
* -
|
|
37
|
-
*
|
|
38
|
-
* -
|
|
39
|
-
*
|
|
40
|
-
* -
|
|
60
|
+
* - `localStorage:` / `sessionStorage:` read `getItem(key)` (try/caught, since
|
|
61
|
+
* storage access can throw in private mode); missing/blocked → `[]`.
|
|
62
|
+
* - `cookie:` reads and `decodeURIComponent`s the matching cookie; missing →
|
|
63
|
+
* `[]`.
|
|
64
|
+
* - `url:` reads `URLSearchParams(location.search).getAll(key)` (repeated
|
|
65
|
+
* params supported); missing → `[]`.
|
|
66
|
+
* - `telegram:cloud:` / `telegram:secure:` are asynchronous and cannot be
|
|
67
|
+
* served here — they return `[]`. Use {@link readAjaxKeyAsync} instead (the
|
|
68
|
+
* Ajax submit flow already does).
|
|
69
|
+
* - DOM names are looked up via `document.getElementsByName`; only the first
|
|
70
|
+
* match is read. `<input type="file">` returns every selected `File`; other
|
|
71
|
+
* `<input>` / `<textarea>` returns the current `.value`.
|
|
72
|
+
* - Missing values return `[]` (and emit a warning when `renderingLogEnabled`).
|
|
41
73
|
*
|
|
42
74
|
* Must run in a browser environment — relies on `document` and `window`.
|
|
43
75
|
*
|
|
44
|
-
* @throws if
|
|
76
|
+
* @throws if the resolved source is `sid` and `window.sid` is not initialized.
|
|
45
77
|
*/
|
|
46
78
|
export declare const readAjaxKey: (depName: string, renderingLogEnabled?: boolean) => Array<string | File>;
|
|
79
|
+
/**
|
|
80
|
+
* Asynchronous counterpart to {@link readAjaxKey}. Behaves identically for all
|
|
81
|
+
* synchronous sources (it delegates to `readAjaxKey`) but additionally resolves
|
|
82
|
+
* the asynchronous Telegram sources (`telegram:cloud:` / `telegram:secure:`).
|
|
83
|
+
*
|
|
84
|
+
* This is what the Ajax submit flow uses so that every supported source — sync
|
|
85
|
+
* or async — can contribute values to the request.
|
|
86
|
+
*/
|
|
87
|
+
export declare const readAjaxKeyAsync: (depName: string, renderingLogEnabled?: boolean) => Promise<Array<string | File>>;
|
|
47
88
|
/**
|
|
48
89
|
* Builds an async "submit" function that issues an AJAX request to
|
|
49
90
|
* `api/ajax_content{pathname}` and streams (or JSON-decodes) the response
|
|
@@ -52,8 +93,11 @@ export declare const readAjaxKey: (depName: string, renderingLogEnabled?: boolea
|
|
|
52
93
|
* The returned function collects form data from:
|
|
53
94
|
* 1. the static `kwargs` object,
|
|
54
95
|
* 2. any `extraKwargs` passed at call time,
|
|
55
|
-
* 3.
|
|
56
|
-
*
|
|
96
|
+
* 3. the dep names in `depsNames`, each resolved by {@link readAjaxKeyAsync}
|
|
97
|
+
* from its source: DOM inputs by default, `sid` (resolved via
|
|
98
|
+
* {@link waitForSidAvailable}), or the `localStorage:`, `sessionStorage:`,
|
|
99
|
+
* `cookie:`, `url:`, `telegram:cloud:` and `telegram:secure:` prefixes —
|
|
100
|
+
* submitted under the bare key, and
|
|
57
101
|
* 4. file inputs (multiple files supported).
|
|
58
102
|
*
|
|
59
103
|
* If the server streams NDJSON, each line is parsed as a `UIEventType` and
|
|
@@ -65,8 +109,11 @@ export declare const readAjaxKey: (depName: string, renderingLogEnabled?: boolea
|
|
|
65
109
|
*
|
|
66
110
|
* @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card.
|
|
67
111
|
* @param kwargs Static key/value pairs appended to the request.
|
|
68
|
-
* @param depsNames
|
|
69
|
-
*
|
|
112
|
+
* @param depsNames Dep names whose current values should also be
|
|
113
|
+
* sent. Plain names read DOM inputs; the
|
|
114
|
+
* `localStorage:`, `sessionStorage:`, `cookie:`,
|
|
115
|
+
* `url:`, `telegram:cloud:` and `telegram:secure:`
|
|
116
|
+
* prefixes read those client sources.
|
|
70
117
|
* @param pathname Path segment appended to `api/ajax_content`.
|
|
71
118
|
* @param options See {@link GetAjaxSubmitOptions}.
|
|
72
119
|
* @returns An `async (extraKwargs?) => Promise<any>` submit function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ajaxCommonUtils.d.ts","sourceRoot":"","sources":["../../src/util/ajaxCommonUtils.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,CAAA;AACjB,OAAO,EAAE,0BAA0B,EAAe,MAAM,UAAU,CAAA;AAKlE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kJAAkJ;IAClJ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,uEAAuE;IACvE,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"ajaxCommonUtils.d.ts","sourceRoot":"","sources":["../../src/util/ajaxCommonUtils.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,CAAA;AACjB,OAAO,EAAE,0BAA0B,EAAe,MAAM,UAAU,CAAA;AAKlE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kJAAkJ;IAClJ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,uEAAuE;IACvE,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GACf,KAAK,GACL,KAAK,GACL,cAAc,GACd,gBAAgB,GAChB,QAAQ,GACR,KAAK,GACL,gBAAgB,GAChB,iBAAiB,CAAA;AAmBvB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GACrB,SAAS,MAAM,KAChB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAWlC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,WAAW,GACpB,SAAS,MAAM,EACf,sBAAqB,OAAe,KACrC,KAAK,CAAC,MAAM,GAAG,IAAI,CA6ErB,CAAA;AA6ED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GACzB,SAAS,MAAM,EACf,sBAAqB,OAAe,KACrC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAM9B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,aAAa,GACtB,yBAAyB,0BAA0B,EACnD,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,YAAW,KAAK,CAAC,MAAM,CAAM,EAC7B,WAAW,MAAM,EACjB,UAAU,oBAAoB,MAahB,cAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,iBA2KtD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GACtB,yBAAyB,0BAA0B,EACnD,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,YAAW,KAAK,CAAC,MAAM,CAAM,EAC7B,WAAW,MAAM,EACjB,UAAU;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,oBAjM9B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBA6NjD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"centrifuge.d.ts","sourceRoot":"","sources":["../../src/util/centrifuge.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"centrifuge.d.ts","sourceRoot":"","sources":["../../src/util/centrifuge.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAQvC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,GACtB,WAAW,MAAM,EACjB,mBAAmB,MAAM,KAC1B,UAAU,GAAG,IAwBf,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,mBAAmB,4CAGxB,CAAA;AACD,eAAe,mBAAmB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../src/util/fallback.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../src/util/fallback.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAGhD;;;;;GAKG;AACH,QAAA,MAAM,eAAe,oCAGpB,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalSingleton.d.ts","sourceRoot":"","sources":["../../src/util/globalSingleton.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,MAAM,MAAM,EAAE,QAAQ,MAAM,CAAC,KAAG,CAMlE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyError.d.ts","sourceRoot":"","sources":["../../src/util/lazyError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lazyError.d.ts","sourceRoot":"","sources":["../../src/util/lazyError.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,mCAEW,OAAO,KAAK,IAAI,cAChD,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
package/dist/util/mitt.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export type MittEvents = {
|
|
|
14
14
|
* Prefer {@link usePieEmit} from within React components — it honours the
|
|
15
15
|
* provider-supplied emitter from `MittContext` when one is available.
|
|
16
16
|
*
|
|
17
|
+
* The emitter is stashed on `globalThis` so every pre-bundled entry point shares
|
|
18
|
+
* the same instance and events emitted from one bundle reach listeners in another.
|
|
19
|
+
*
|
|
17
20
|
* @returns The process-wide Mitt emitter instance.
|
|
18
21
|
*/
|
|
19
22
|
export declare function getEmitter(): Emitter<MittEvents>;
|
package/dist/util/mitt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mitt.d.ts","sourceRoot":"","sources":["../../src/util/mitt.ts"],"names":[],"mappings":"AAEA,OAAa,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"mitt.d.ts","sourceRoot":"","sources":["../../src/util/mitt.ts"],"names":[],"mappings":"AAEA,OAAa,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAIpC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,CAIhD;AAED;;;;;GAKG;AACH,QAAA,MAAM,WAAW,qDAGhB,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,gBAGlB,MAAM,YAAY,GAAG,UAKzC;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/util/navigate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/util/navigate.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD;;;;;GAKG;AACH,QAAA,MAAM,eAAe,uDAGpB,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pieConfig.d.ts","sourceRoot":"","sources":["../../src/util/pieConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"pieConfig.d.ts","sourceRoot":"","sources":["../../src/util/pieConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGpC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,2CAG5B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,iBAMxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,cAGxB,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,YAAY,cAAe,CAAA;AAExC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,0BAG/B,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,mBAAmB,0BAAsB,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,2BAGpC,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAE7D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,0BAG5B,CAAA;AAED,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,0BAAmB,CAAA;AAEhD;;;;GAIG;AACH,eAAO,MAAM,QAAQ,gBAAgB,CAAA"}
|
package/dist/util/registry.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { ComponentMetadata, ComponentRegistration } from '../types';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Central in-memory registry of PieUI components keyed by their name. Every
|
|
5
|
+
* call to {@link registerPieComponent} writes into this `Map`, and the
|
|
6
|
+
* dynamic UI renderer reads from it at render time to resolve a `card` name
|
|
7
|
+
* to a concrete React component.
|
|
8
|
+
*
|
|
9
|
+
* The `Map` is stashed on `globalThis` under a shared `Symbol.for` key (via
|
|
10
|
+
* {@link globalSingleton}) so that every copy of this module resolves to the
|
|
11
|
+
* SAME instance. `registry.ts` gets inlined into each pre-bundled entry point
|
|
12
|
+
* (main, `/components`, `/telegram`, `/max`, `/agent`), and without a shared
|
|
13
|
+
* backing store each bundle would own a separate `Map`. A component registered
|
|
14
|
+
* via one entry (`import "@swarm.ing/pieui/components"`) would then be invisible
|
|
15
|
+
* to a renderer loaded from another (`PieTelegramRoot` from
|
|
16
|
+
* `@swarm.ing/pieui/telegram`), surfacing as "[UI] Component not found in
|
|
17
|
+
* registry".
|
|
18
|
+
*/
|
|
3
19
|
type RegistryMap = Map<string, ComponentRegistration<any>>;
|
|
4
20
|
export declare const registry: RegistryMap;
|
|
5
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/util/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/util/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAGrC;;;;;;;;;;;;;;;GAeG;AACH,KAAK,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAA;AAE1D,eAAO,MAAM,QAAQ,EAAE,WAGtB,CAAA;AAwCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EACvC,YAAY,EAAE,qBAAqB,CAAC,MAAM,CAAC,GAC5C,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAInC;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GACnC,YAAY,qBAAqB,CAAC,GAAG,CAAC,EAAE,SAG3C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,SAE/C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,YAExC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,KACb,iBAAiB,GAAG,SAEtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,KACb,qBAAqB,CAAC,GAAG,CAAC,GAAG,SAE/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,QAAO,MAAM,EAEnD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,QAAO,MAElC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAAM,EAGpB,CAAA;AAE3B;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,SAIlE,CAAA;AAID;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,QAAO,IAsCzC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/util/socket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/util/socket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAS7C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,KAAG,MAU7C,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,eAAe,0JAGpB,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uiRenderer.d.ts","sourceRoot":"","sources":["../../src/util/uiRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"uiRenderer.d.ts","sourceRoot":"","sources":["../../src/util/uiRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGnE;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,EAAE,YAAY,CAAA;IACtB,sBAAsB,CAAC,EAAE,0BAA0B,CAAA;CACtD,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,gEAGtB,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForSidAvailable.d.ts","sourceRoot":"","sources":["../../src/util/waitForSidAvailable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"waitForSidAvailable.d.ts","sourceRoot":"","sources":["../../src/util/waitForSidAvailable.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,wBAAgB,gBAAgB,SAE/B;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAe3D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swarm.ing/pieui",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "A React component library featuring PieCard component",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
|
-
"build": "rm -rf ./dist && rm -rf pieui-*.tgz && bun run build:clean && NODE_ENV=production bun run build:esm && NODE_ENV=production bun run build:cjs && NODE_ENV=production bun run build:components:esm && NODE_ENV=production bun run build:components:cjs && NODE_ENV=production bun run build:agent:esm && NODE_ENV=production bun run build:agent:cjs && NODE_ENV=production bun run build:telegram:esm && NODE_ENV=production bun run build:telegram:cjs && NODE_ENV=production bun run build:max:esm && NODE_ENV=production bun run build:max:cjs && NODE_ENV=production bun run build:storybook:esm && NODE_ENV=production bun run build:storybook:cjs && NODE_ENV=production bun run build:storybook:addon:esm && NODE_ENV=production bun run build:storybook:addon:cjs && NODE_ENV=production bun run build:storybook:addon:preset && bun run build:banner && NODE_ENV=production bun run build:types && NODE_ENV=production bun run build:cli && bun src/cli.ts postbuild --src-dir src --out-dir dist && bun pm pack",
|
|
64
|
+
"build": "rm -rf ./dist && rm -rf pieui-*.tgz && bun run build:clean && NODE_ENV=production bun run build:esm && NODE_ENV=production bun run build:cjs && NODE_ENV=production bun run build:components:esm && NODE_ENV=production bun run build:components:cjs && NODE_ENV=production bun run build:agent:esm && NODE_ENV=production bun run build:agent:cjs && NODE_ENV=production bun run build:telegram:esm && NODE_ENV=production bun run build:telegram:cjs && NODE_ENV=production bun run build:max:esm && NODE_ENV=production bun run build:max:cjs && NODE_ENV=production bun run build:storybook:esm && NODE_ENV=production bun run build:storybook:cjs && NODE_ENV=production bun run build:storybook:addon:esm && NODE_ENV=production bun run build:storybook:addon:cjs && NODE_ENV=production bun run build:storybook:addon:manager:esm && NODE_ENV=production bun run build:storybook:addon:manager:cjs && NODE_ENV=production bun run build:storybook:addon:preset && bun run build:banner && NODE_ENV=production bun run build:types && NODE_ENV=production bun run build:cli && bun src/cli.ts postbuild --src-dir src --out-dir dist && bun pm pack",
|
|
65
65
|
"build:banner": "node -e \"const fs=require('fs');['dist/index.esm.js','dist/index.js','dist/components/index.esm.js','dist/components/index.js','dist/agent/index.esm.js','dist/agent/index.js','dist/telegram/index.esm.js','dist/telegram/index.js','dist/max/index.esm.js','dist/max/index.js','dist/storybook/index.esm.js','dist/storybook/index.js','dist/storybook/addon/index.esm.js','dist/storybook/addon/index.js'].forEach(f=>{if(fs.existsSync(f)){fs.writeFileSync(f,'\\\"use client\\\";\\n'+fs.readFileSync(f,'utf8'))}})\"",
|
|
66
66
|
"build:clean": "rm -rf dist",
|
|
67
67
|
"build:esm": "bun build src/index.ts --outfile dist/index.esm.js --format esm --target browser --jsx=automatic --jsx-import-source=react --minify --packages=external",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Common/CloudStorageCard/index.ts"],"names":[],"mappings":";AAGA,wBAIE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Common/CloudStorageCard/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IAEb,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB,CAAC,oBAAoB,CAAC;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CloudStorageCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/Common/CloudStorageCard/ui/CloudStorageCard.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGhD,QAAA,MAAM,gBAAgB,GAAI,UAAU,qBAAqB,gCA6CxD,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Common/SecureStorageCard/index.ts"],"names":[],"mappings":";AAGA,wBAIE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Common/SecureStorageCard/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IAEb,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB,CAAC,qBAAqB,CAAC;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SecureStorageCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/Common/SecureStorageCard/ui/SecureStorageCard.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAGjD,QAAA,MAAM,iBAAiB,GAAI,UAAU,sBAAsB,gCA6C1D,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|