@ai4b-team/fsaos-gateway-sdk 5.1.0 → 5.2.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/README.md +22 -2
- package/dist/iife/gateway.js +4 -4
- package/dist/iife/gateway.js.map +3 -3
- package/dist/iife/ui.js +1 -1
- package/dist/index.cjs +53 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +53 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/iife/ui.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-11-
|
|
1
|
+
/* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-11-12T19:59:44.646Z */
|
|
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
|
@@ -276,6 +276,7 @@ var EnforcementDeniedError = class _EnforcementDeniedError extends Error {
|
|
|
276
276
|
};
|
|
277
277
|
var CONFIG = typeof window !== "undefined" && window.__FSAOS_CONFIG__ || {};
|
|
278
278
|
var PUBLIC_SOURCES = Array.isArray(CONFIG.sources) ? CONFIG.sources : [];
|
|
279
|
+
var HOST_SESSION = CONFIG.hostSession === true;
|
|
279
280
|
var SUPABASE_URL = CONFIG.supabaseUrl || "https://vahbmsslxuustnlvsrkg.supabase.co";
|
|
280
281
|
var SUPABASE_ANON_KEY = CONFIG.supabaseAnonKey || "sb_publishable_ZjosozAjfpZ4InMNElTr6Q_hHB-f5nc";
|
|
281
282
|
var GATEWAY_URL = CONFIG.gatewayUrl || "https://fsaos-mcp-gw-rust.fly.dev";
|
|
@@ -321,6 +322,7 @@ function clearCachedToken() {
|
|
|
321
322
|
}
|
|
322
323
|
async function getAccessToken() {
|
|
323
324
|
const cfg = typeof window !== "undefined" && window.__FSAOS_CONFIG__ || {};
|
|
325
|
+
if (cfg.hostSession === true) return null;
|
|
324
326
|
if (cfg.embedToken) {
|
|
325
327
|
if (typeof cfg.embedToken === "function") {
|
|
326
328
|
try {
|
|
@@ -1240,6 +1242,10 @@ function hasActiveSubscriptions() {
|
|
|
1240
1242
|
return activeScopes.size > 0 || activePaths.size > 0;
|
|
1241
1243
|
}
|
|
1242
1244
|
async function ensureConnection() {
|
|
1245
|
+
if (HOST_SESSION) {
|
|
1246
|
+
log("ensureConnection: the host holds the session, no realtime connection");
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1243
1249
|
if (!hasActiveSubscriptions()) {
|
|
1244
1250
|
log("ensureConnection: no active subscriptions, skipping");
|
|
1245
1251
|
return;
|
|
@@ -1570,6 +1576,7 @@ function getPathSubscriptionState(path) {
|
|
|
1570
1576
|
}
|
|
1571
1577
|
function waitForPathReady(path, timeoutMs = 5e3) {
|
|
1572
1578
|
if (!activePaths.has(path)) return Promise.resolve(false);
|
|
1579
|
+
if (HOST_SESSION) return Promise.resolve(false);
|
|
1573
1580
|
if (pathStates.get(path) === "ready" && ws && ws.readyState === WebSocket.OPEN) {
|
|
1574
1581
|
return Promise.resolve(true);
|
|
1575
1582
|
}
|
|
@@ -2300,6 +2307,7 @@ var unsubEvents = null;
|
|
|
2300
2307
|
var unsubCcmEvents = null;
|
|
2301
2308
|
var debounceTimers = /* @__PURE__ */ new Map();
|
|
2302
2309
|
var DEBOUNCE_MS = 250;
|
|
2310
|
+
var pendingChanges = /* @__PURE__ */ new Map();
|
|
2303
2311
|
function initVfsRealtimeWs(accountId) {
|
|
2304
2312
|
if (unsubEvents) {
|
|
2305
2313
|
mountRealtimeScope(accountId);
|
|
@@ -2342,6 +2350,7 @@ function disposeVfsRealtimeWs() {
|
|
|
2342
2350
|
}
|
|
2343
2351
|
debounceTimers.forEach((timer) => clearTimeout(timer));
|
|
2344
2352
|
debounceTimers.clear();
|
|
2353
|
+
pendingChanges.clear();
|
|
2345
2354
|
}
|
|
2346
2355
|
registerCleanup(disposeVfsRealtimeWs);
|
|
2347
2356
|
function handleVfsChange(data) {
|
|
@@ -2351,11 +2360,19 @@ function handleVfsChange(data) {
|
|
|
2351
2360
|
const segments = path.split("/");
|
|
2352
2361
|
segments.pop();
|
|
2353
2362
|
const parentPath = segments.join("/") || "/root";
|
|
2363
|
+
let changes = pendingChanges.get(parentPath);
|
|
2364
|
+
if (!changes) {
|
|
2365
|
+
changes = /* @__PURE__ */ new Map();
|
|
2366
|
+
pendingChanges.set(parentPath, changes);
|
|
2367
|
+
}
|
|
2368
|
+
changes.set(path, { action, itemId: typeof data.item_id === "string" ? data.item_id : void 0 });
|
|
2354
2369
|
const existing = debounceTimers.get(parentPath);
|
|
2355
2370
|
if (existing) clearTimeout(existing);
|
|
2356
2371
|
const timer = setTimeout(() => {
|
|
2357
2372
|
debounceTimers.delete(parentPath);
|
|
2358
|
-
|
|
2373
|
+
const flushed = pendingChanges.get(parentPath);
|
|
2374
|
+
pendingChanges.delete(parentPath);
|
|
2375
|
+
if (flushed) applyInvalidation(parentPath, flushed);
|
|
2359
2376
|
}, DEBOUNCE_MS);
|
|
2360
2377
|
debounceTimers.set(parentPath, timer);
|
|
2361
2378
|
}
|
|
@@ -2379,41 +2396,30 @@ function handleCcmChange(data) {
|
|
|
2379
2396
|
}, DEBOUNCE_MS);
|
|
2380
2397
|
debounceTimers.set(debounceKey, timer);
|
|
2381
2398
|
}
|
|
2382
|
-
function applyInvalidation(
|
|
2383
|
-
const
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
item_type: data.item_type,
|
|
2395
|
-
parent_id: data.parent_id,
|
|
2396
|
-
scope_item_id: data.scope_item_id
|
|
2397
|
-
};
|
|
2398
|
-
const normalized = normalizeItem(record);
|
|
2399
|
-
if (normalized && normalized.id) {
|
|
2400
|
-
getQueryClient().setQueryData(vfsKeys.item(path), normalized);
|
|
2401
|
-
}
|
|
2402
|
-
} catch (_e) {
|
|
2399
|
+
function applyInvalidation(parentPath, changes) {
|
|
2400
|
+
const client2 = getQueryClient();
|
|
2401
|
+
for (const [path, change] of changes) {
|
|
2402
|
+
if ((change.action || "").toUpperCase() === "DELETE") {
|
|
2403
|
+
client2.removeQueries({ queryKey: vfsKeys.item(path) });
|
|
2404
|
+
client2.removeQueries({ queryKey: vfsKeys.children(path) });
|
|
2405
|
+
client2.removeQueries({ queryKey: vfsKeys.tree(path) });
|
|
2406
|
+
} else {
|
|
2407
|
+
void refreshQuery(client2, vfsKeys.item(path), { exact: true });
|
|
2408
|
+
}
|
|
2409
|
+
if (change.itemId) {
|
|
2410
|
+
client2.invalidateQueries({ queryKey: vfsKeys.itemById(change.itemId) });
|
|
2403
2411
|
}
|
|
2404
2412
|
}
|
|
2405
|
-
|
|
2406
|
-
|
|
2413
|
+
client2.invalidateQueries({ queryKey: vfsKeys.children(parentPath) });
|
|
2414
|
+
const changed = [...changes.keys()];
|
|
2415
|
+
client2.invalidateQueries({
|
|
2407
2416
|
predicate: (query) => {
|
|
2408
2417
|
const key = query.queryKey;
|
|
2409
2418
|
if (key[0] !== "vfs" || key[1] !== "tree") return false;
|
|
2410
2419
|
const treePath = key[2];
|
|
2411
|
-
return path.startsWith(treePath + "/") || path === treePath;
|
|
2420
|
+
return changed.some((path) => path.startsWith(treePath + "/") || path === treePath);
|
|
2412
2421
|
}
|
|
2413
2422
|
});
|
|
2414
|
-
if (data.item_id) {
|
|
2415
|
-
getQueryClient().invalidateQueries({ queryKey: vfsKeys.itemById(data.item_id) });
|
|
2416
|
-
}
|
|
2417
2423
|
}
|
|
2418
2424
|
|
|
2419
2425
|
// src/mounts.ts
|
|
@@ -3886,8 +3892,16 @@ function useComponent(path, options) {
|
|
|
3886
3892
|
}, []);
|
|
3887
3893
|
return { Component, loading, error };
|
|
3888
3894
|
}
|
|
3889
|
-
var IN_APP_SCRIPT =
|
|
3890
|
-
var IN_APP_STYLESHEET =
|
|
3895
|
+
var IN_APP_SCRIPT = /^embed\/bundle-[A-Za-z0-9_-]+\.js$/;
|
|
3896
|
+
var IN_APP_STYLESHEET = /^embed\/bundle-[A-Za-z0-9_-]+\.css$/;
|
|
3897
|
+
function inAppFile(artifacts, pattern, what) {
|
|
3898
|
+
const paths = Object.keys(artifacts).filter((path2) => pattern.test(path2));
|
|
3899
|
+
if (paths.length > 1) throw new Error(`The published release has more than one in-app ${what}.`);
|
|
3900
|
+
const path = paths[0];
|
|
3901
|
+
if (!path) return null;
|
|
3902
|
+
const sha256 = plainRecord(artifacts[path]).sha256;
|
|
3903
|
+
return typeof sha256 === "string" && sha256 ? { path, sha256 } : null;
|
|
3904
|
+
}
|
|
3891
3905
|
var publishedBundles = /* @__PURE__ */ new Map();
|
|
3892
3906
|
var publishedComponents = /* @__PURE__ */ new Map();
|
|
3893
3907
|
registerCleanup(() => {
|
|
@@ -3926,10 +3940,10 @@ async function readPublishedBundle(componentId, releaseItemId, version) {
|
|
|
3926
3940
|
throw new Error("This component's live version does not match its release record.");
|
|
3927
3941
|
}
|
|
3928
3942
|
const artifacts = plainRecord(record.artifacts);
|
|
3929
|
-
const
|
|
3930
|
-
if (
|
|
3931
|
-
const
|
|
3932
|
-
const wanted =
|
|
3943
|
+
const sealedScript = inAppFile(artifacts, IN_APP_SCRIPT, "script");
|
|
3944
|
+
if (!sealedScript) return { status: "no_in_app_version", releaseItemId, version };
|
|
3945
|
+
const sealedStylesheet = inAppFile(artifacts, IN_APP_STYLESHEET, "stylesheet");
|
|
3946
|
+
const wanted = sealedStylesheet ? [sealedScript.path, sealedStylesheet.path] : [sealedScript.path];
|
|
3933
3947
|
const buildItemId = record.build_item_id;
|
|
3934
3948
|
if (typeof buildItemId !== "string" || !buildItemId) throw new Error("The published release names no build.");
|
|
3935
3949
|
const { items } = await fetchItems(
|
|
@@ -3937,14 +3951,14 @@ async function readPublishedBundle(componentId, releaseItemId, version) {
|
|
|
3937
3951
|
{ throwOnError: true }
|
|
3938
3952
|
);
|
|
3939
3953
|
const fileAt = (path) => items.find((item) => plainRecord(item.type_data).package_path === path);
|
|
3940
|
-
const scriptFile = fileAt(
|
|
3941
|
-
const stylesheetFile =
|
|
3942
|
-
if (!scriptFile ||
|
|
3954
|
+
const scriptFile = fileAt(sealedScript.path);
|
|
3955
|
+
const stylesheetFile = sealedStylesheet ? fileAt(sealedStylesheet.path) : void 0;
|
|
3956
|
+
if (!scriptFile || sealedStylesheet && !stylesheetFile) {
|
|
3943
3957
|
throw new Error("The published release's in-app files could not be found in its build.");
|
|
3944
3958
|
}
|
|
3945
3959
|
const [script, stylesheet] = await Promise.all([
|
|
3946
|
-
readSealedFile(scriptFile,
|
|
3947
|
-
stylesheetFile ? readSealedFile(stylesheetFile,
|
|
3960
|
+
readSealedFile(scriptFile, sealedScript.sha256, "script"),
|
|
3961
|
+
stylesheetFile && sealedStylesheet ? readSealedFile(stylesheetFile, sealedStylesheet.sha256, "stylesheet") : Promise.resolve(null)
|
|
3948
3962
|
]);
|
|
3949
3963
|
return { status: "ready", releaseItemId, version, script, stylesheet: stylesheet?.trim() ? stylesheet : null };
|
|
3950
3964
|
}
|