@ai4b-team/fsaos-gateway-sdk 3.2.0 → 3.3.0

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/iife/ui.js CHANGED
@@ -1,3 +1,3 @@
1
- /* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-05-27T19:05:12.688Z */
1
+ /* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-05-27T19:47:41.917Z */
2
2
  "use strict";var __FSAOS_UI__=(()=>{var m=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var y=(e,i)=>()=>(i||e((i={exports:{}}).exports,i),i.exports),N=(e,i)=>{for(var a in i)r(e,a,{get:i[a],enumerable:!0})},s=(e,i,a,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of u(i))!h.call(e,t)&&t!==a&&r(e,t,{get:()=>i[t],enumerable:!(l=g(i,t))||l.enumerable});return e};var x=(e,i,a)=>(a=e!=null?m(f(e)):{},s(i||!e||!e.__esModule?r(a,"default",{value:e,enumerable:!0}):a,e)),b=e=>s(r({},"__esModule",{value:!0}),e);var d=y((V,c)=>{c.exports=React});var P={};N(P,{Badge:()=>z,Breadcrumbs:()=>A,Button:()=>D,Card:()=>w,DataView:()=>R,Detail:()=>_,Empty:()=>I,FilePreview:()=>O,Form:()=>F,Grid:()=>k,Image:()=>G,Link:()=>E,Page:()=>v,Router:()=>T,Sidebar:()=>S,Spinner:()=>B,Stack:()=>C,Table:()=>j,Tabs:()=>W,Video:()=>H});var n=x(d(),1);function o(){return(typeof window<"u"&&window.__FSAOS_CONFIG__||{}).edgeBaseUrl||""}function v(e){return(0,n.createElement)("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column"},className:e.className||""},e.children)}function C(e){let i=e.direction||"vertical";return(0,n.createElement)("div",{style:{display:"flex",flexDirection:i==="horizontal"?"row":"column",gap:e.gap||"0.5rem",padding:e.padding||"0",alignItems:e.align||"stretch",justifyContent:e.justify||"flex-start",flex:e.flex||"initial"},className:e.className||""},e.children)}function k(e){return(0,n.createElement)("div",{style:{display:"grid",gridTemplateColumns:"repeat("+(e.columns||3)+", 1fr)",gap:e.gap||"1rem",padding:e.padding||"0"},className:e.className||""},e.children)}function S(e){return(0,n.createElement)("div",{style:{display:"flex",flexDirection:"row",minHeight:"100vh"},className:e.className||""},e.children)}function w(e){return(0,n.createElement)("div",{style:{border:"1px solid var(--color-border, #e5e7eb)",borderRadius:"var(--border-radius, 0.5rem)",padding:e.padding||"1rem",background:"var(--color-surface, #fff)"},className:e.className||"",onClick:e.onClick},e.children)}function z(e){return(0,n.createElement)("span",{style:{display:"inline-flex",alignItems:"center",padding:"0.125rem 0.5rem",fontSize:"0.75rem",fontWeight:"500",borderRadius:"9999px",background:e.color||"#e5e7eb",color:e.textColor||"#374151"},className:e.className||""},e.children||e.label)}function B(e){let i=e.size||"1.5rem";return(0,n.createElement)("div",{style:{width:i,height:i,border:"2px solid #e5e7eb",borderTopColor:"var(--color-primary, #3b82f6)",borderRadius:"50%",animation:"fsaos-spin 0.6s linear infinite"}})}function D(e){return(0,n.createElement)("button",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:"500",borderRadius:"var(--border-radius, 0.375rem)",border:e.variant==="outline"?"1px solid var(--color-border, #d1d5db)":"none",background:e.variant==="outline"||e.variant==="ghost"?"transparent":"var(--color-primary, #3b82f6)",color:e.variant==="outline"||e.variant==="ghost"?"var(--color-text, #1a1a1a)":"#fff",cursor:e.disabled?"not-allowed":"pointer",opacity:e.disabled?"0.5":"1",gap:"0.5rem"},className:e.className||"",onClick:e.onClick,disabled:e.disabled},e.children||e.label)}function I(e){return(0,n.createElement)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"3rem",color:"var(--color-text-secondary, #6b7280)",textAlign:"center"}},e.icon?(0,n.createElement)("div",{style:{fontSize:"2rem",marginBottom:"0.5rem"}},e.icon):null,(0,n.createElement)("div",{style:{fontWeight:500,marginBottom:"0.25rem"}},e.title||e.message||e.children||"No items"),e.description?(0,n.createElement)("div",{style:{fontSize:"0.875rem",opacity:.7}},e.description):null)}function R(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function j(e){return(0,n.createElement)("table",{className:e.className||""},e.children)}function F(e){return(0,n.createElement)("form",{className:e.className||"",onSubmit:e.onSubmit},e.children)}function _(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function T(e){return(0,n.createElement)("div",null,e.children)}function E(e){return(0,n.createElement)("a",{href:e.href||e.to,className:e.className||"",onClick:e.onClick},e.children)}function W(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function A(e){return(0,n.createElement)("nav",{className:e.className||""},e.children)}function G(e){return(0,n.createElement)("img",{src:e.src||(e.path?o()+e.path:""),alt:e.alt||"",className:e.className||"",style:e.style})}function H(e){return(0,n.createElement)("video",{src:e.src||(e.path?o()+e.path:""),controls:!0,className:e.className||""})}function O(e){return(0,n.createElement)("div",{className:e.className||""},e.children||"File preview")}return b(P);})();
3
3
  //# sourceMappingURL=ui.js.map
package/dist/index.cjs CHANGED
@@ -2474,8 +2474,72 @@ function useInfiniteChannelMessages(options) {
2474
2474
  "vfs_change",
2475
2475
  () => {
2476
2476
  if (debounceRef.current) clearTimeout(debounceRef.current);
2477
- debounceRef.current = setTimeout(() => {
2478
- qc.invalidateQueries({ queryKey: stableKey });
2477
+ debounceRef.current = setTimeout(async () => {
2478
+ const currentData = qc.getQueryData(stableKey);
2479
+ if (!currentData?.pages?.length) {
2480
+ qc.invalidateQueries({ queryKey: stableKey });
2481
+ return;
2482
+ }
2483
+ let maxSeq = 0;
2484
+ for (const page of currentData.pages) {
2485
+ for (const msg of page.messages) {
2486
+ if (msg.seq > maxSeq) maxSeq = msg.seq;
2487
+ }
2488
+ }
2489
+ if (maxSeq === 0) {
2490
+ qc.invalidateQueries({ queryKey: stableKey });
2491
+ return;
2492
+ }
2493
+ try {
2494
+ const newPage = await fetchChannelMessagesPage(channelPath, {
2495
+ parentMessageId,
2496
+ limit,
2497
+ after_seq: maxSeq
2498
+ });
2499
+ if (newPage.messages.length === 0 && newPage.siblingCards.length === 0) {
2500
+ qc.invalidateQueries({ queryKey: stableKey });
2501
+ return;
2502
+ }
2503
+ if (newPage.messages.length > 0) {
2504
+ const minNewSeq = Math.min(...newPage.messages.map((m) => m.seq));
2505
+ if (minNewSeq > maxSeq + 1) {
2506
+ console.warn(
2507
+ `[useInfiniteChannelMessages] sequence gap detected: maxSeq=${maxSeq}, minNewSeq=${minNewSeq}. Triggering full refetch.`
2508
+ );
2509
+ qc.invalidateQueries({ queryKey: stableKey });
2510
+ return;
2511
+ }
2512
+ }
2513
+ qc.setQueryData(stableKey, (old) => {
2514
+ if (!old) return old;
2515
+ const pages = [...old.pages];
2516
+ const lastIdx = pages.length - 1;
2517
+ const lastPage = pages[lastIdx];
2518
+ const existingIds = new Set(lastPage.messages.map((m) => m.id));
2519
+ const uniqueNew = newPage.messages.filter((m) => !existingIds.has(m.id));
2520
+ const mergedMessages = [...lastPage.messages, ...uniqueNew].sort((a, b) => a.seq - b.seq);
2521
+ const mergedMsgCards = new Map(lastPage.messageCards);
2522
+ for (const [path, cards] of newPage.messageCards) {
2523
+ const existing = mergedMsgCards.get(path) || [];
2524
+ const existingCardIds = new Set(existing.map((c) => c.id));
2525
+ const newCards = cards.filter((c) => !existingCardIds.has(c.id));
2526
+ mergedMsgCards.set(path, [...existing, ...newCards]);
2527
+ }
2528
+ const existingSibIds = new Set(lastPage.siblingCards.map((c) => c.id));
2529
+ const newSiblings = newPage.siblingCards.filter((c) => !existingSibIds.has(c.id));
2530
+ const mergedSiblings = [...lastPage.siblingCards, ...newSiblings];
2531
+ pages[lastIdx] = {
2532
+ ...lastPage,
2533
+ messages: mergedMessages,
2534
+ messageCards: mergedMsgCards,
2535
+ siblingCards: mergedSiblings
2536
+ };
2537
+ return { ...old, pages };
2538
+ });
2539
+ } catch (err) {
2540
+ console.warn("[useInfiniteChannelMessages] live tail fetch failed, falling back to full invalidation:", err);
2541
+ qc.invalidateQueries({ queryKey: stableKey });
2542
+ }
2479
2543
  }, 500);
2480
2544
  },
2481
2545
  (data) => {
@@ -2486,7 +2550,7 @@ function useInfiniteChannelMessages(options) {
2486
2550
  unsub();
2487
2551
  if (debounceRef.current) clearTimeout(debounceRef.current);
2488
2552
  };
2489
- }, [realtime, channelPath, queryEnabled, stableKey, qc]);
2553
+ }, [realtime, channelPath, queryEnabled, stableKey, qc, parentMessageId, limit]);
2490
2554
  return {
2491
2555
  messages,
2492
2556
  /** Cards grouped by parent message path (child cards of messages). */