@ai4b-team/fsaos-gateway-sdk 5.7.1 → 5.8.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 +16 -0
- 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 +141 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -1
- package/dist/index.d.ts +54 -1
- package/dist/index.js +140 -1
- package/dist/index.js.map +1 -1
- package/dist/ui.d.cts +1 -1
- package/dist/ui.d.ts +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-22T15:58:44.492Z */
|
|
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
|
@@ -136,6 +136,7 @@ __export(src_exports, {
|
|
|
136
136
|
itemsFilterFromQueryFilter: () => itemsFilterFromQueryFilter,
|
|
137
137
|
listChildren: () => listChildren,
|
|
138
138
|
listInvitations: () => listInvitations,
|
|
139
|
+
loadCompiledBundle: () => loadCompiledBundle,
|
|
139
140
|
loadMounts: () => loadMounts,
|
|
140
141
|
loadPublishedBundle: () => loadPublishedBundle,
|
|
141
142
|
mount: () => mount2,
|
|
@@ -198,6 +199,7 @@ __export(src_exports, {
|
|
|
198
199
|
useChannelMessages: () => useChannelMessages,
|
|
199
200
|
useChannels: () => useChannels,
|
|
200
201
|
useChildren: () => useChildren,
|
|
202
|
+
useCompiledComponent: () => useCompiledComponent,
|
|
201
203
|
useComponent: () => useComponent,
|
|
202
204
|
useCreate: () => useCreate,
|
|
203
205
|
useCreateAgent: () => useCreateAgent,
|
|
@@ -4623,6 +4625,143 @@ function usePublishedComponent(item) {
|
|
|
4623
4625
|
version: onScreen?.version ?? null
|
|
4624
4626
|
};
|
|
4625
4627
|
}
|
|
4628
|
+
var COMPILED_BUILD_LIMIT = 512 * 1024;
|
|
4629
|
+
var compiledBundles = /* @__PURE__ */ new Map();
|
|
4630
|
+
var compiledComponents = /* @__PURE__ */ new Map();
|
|
4631
|
+
registerCleanup(() => {
|
|
4632
|
+
compiledBundles.clear();
|
|
4633
|
+
compiledComponents.clear();
|
|
4634
|
+
});
|
|
4635
|
+
var compiledKey = (fileId, sha256) => `${fileId}:${sha256.toLowerCase()}`;
|
|
4636
|
+
async function readCompiledBundle(build) {
|
|
4637
|
+
const opened = await gatewayCall("open", {
|
|
4638
|
+
id: build.fileId,
|
|
4639
|
+
mode: "render",
|
|
4640
|
+
...build.scopePath ? { _scope_path: build.scopePath } : {}
|
|
4641
|
+
});
|
|
4642
|
+
const url = plainRecord(plainRecord(opened.render).props).url;
|
|
4643
|
+
if (opened.item_id !== build.fileId || opened.item_type !== "file" || typeof url !== "string" || !url) {
|
|
4644
|
+
throw new Error("The compiled build could not be opened.");
|
|
4645
|
+
}
|
|
4646
|
+
const response = await fetch(url, { credentials: "omit", referrerPolicy: "no-referrer" });
|
|
4647
|
+
if (!response.ok) {
|
|
4648
|
+
throw new Error(`Failed to read the compiled build: ${response.status} ${response.statusText}`.trim());
|
|
4649
|
+
}
|
|
4650
|
+
const bytes = await response.arrayBuffer();
|
|
4651
|
+
if (bytes.byteLength > COMPILED_BUILD_LIMIT) throw new Error("The compiled build is too large to run.");
|
|
4652
|
+
const digest = Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes))).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
4653
|
+
if (digest !== build.sha256.toLowerCase()) {
|
|
4654
|
+
throw new Error("The compiled build does not match the bytes it was shown with.");
|
|
4655
|
+
}
|
|
4656
|
+
let parsed;
|
|
4657
|
+
try {
|
|
4658
|
+
parsed = JSON.parse(new TextDecoder().decode(bytes));
|
|
4659
|
+
} catch {
|
|
4660
|
+
throw new Error("The compiled build is not a build file.");
|
|
4661
|
+
}
|
|
4662
|
+
const { js, css, scope } = plainRecord(parsed);
|
|
4663
|
+
if (typeof js !== "string" || !js || css != null && typeof css !== "string" || scope != null && (typeof scope !== "string" || !/^[A-Za-z0-9_-]{1,64}$/.test(scope))) {
|
|
4664
|
+
throw new Error("The compiled build is not a build file.");
|
|
4665
|
+
}
|
|
4666
|
+
return {
|
|
4667
|
+
script: js,
|
|
4668
|
+
stylesheet: typeof css === "string" && css.trim() ? css : null,
|
|
4669
|
+
scopeClass: typeof scope === "string" ? `fsaos-c-${scope}` : null
|
|
4670
|
+
};
|
|
4671
|
+
}
|
|
4672
|
+
function loadCompiledBundle(build) {
|
|
4673
|
+
if (!build.fileId || !/^[0-9a-f]{64}$/i.test(build.sha256 || "")) {
|
|
4674
|
+
return Promise.reject(new Error("A compiled build is named by its file and the SHA-256 of its bytes."));
|
|
4675
|
+
}
|
|
4676
|
+
const key = compiledKey(build.fileId, build.sha256);
|
|
4677
|
+
let pending5 = compiledBundles.get(key);
|
|
4678
|
+
if (!pending5) {
|
|
4679
|
+
pending5 = readCompiledBundle(build);
|
|
4680
|
+
compiledBundles.set(key, pending5);
|
|
4681
|
+
pending5.catch(() => {
|
|
4682
|
+
if (compiledBundles.get(key) === pending5) compiledBundles.delete(key);
|
|
4683
|
+
});
|
|
4684
|
+
}
|
|
4685
|
+
return pending5;
|
|
4686
|
+
}
|
|
4687
|
+
function useCompiledComponent(build) {
|
|
4688
|
+
const [onScreen, setOnScreen] = React.useState(null);
|
|
4689
|
+
const [status, setStatus] = React.useState("loading");
|
|
4690
|
+
const [error, setError] = React.useState(null);
|
|
4691
|
+
const shown = React.useRef(null);
|
|
4692
|
+
const fileId = build?.fileId || null;
|
|
4693
|
+
const sha256 = build?.sha256 || null;
|
|
4694
|
+
const scopePath = build?.scopePath;
|
|
4695
|
+
React.useEffect(() => {
|
|
4696
|
+
if (!fileId || !sha256) {
|
|
4697
|
+
if (shown.current?.cssKey) releaseComponentCss(shown.current.cssKey);
|
|
4698
|
+
shown.current = null;
|
|
4699
|
+
setOnScreen(null);
|
|
4700
|
+
setError(null);
|
|
4701
|
+
setStatus("loading");
|
|
4702
|
+
return;
|
|
4703
|
+
}
|
|
4704
|
+
const key = compiledKey(fileId, sha256);
|
|
4705
|
+
if (shown.current?.key === key) return;
|
|
4706
|
+
let cancelled = false;
|
|
4707
|
+
setError(null);
|
|
4708
|
+
if (!shown.current) setStatus("loading");
|
|
4709
|
+
(async () => {
|
|
4710
|
+
let heldCssKey = null;
|
|
4711
|
+
try {
|
|
4712
|
+
const bundle = await loadCompiledBundle({ fileId, sha256, scopePath });
|
|
4713
|
+
if (cancelled) return;
|
|
4714
|
+
let resolved = compiledComponents.get(key);
|
|
4715
|
+
if (!resolved) {
|
|
4716
|
+
resolved = evaluateBundle(bundle.script);
|
|
4717
|
+
if (!resolved) {
|
|
4718
|
+
throw new Error(
|
|
4719
|
+
"The compiled build did not hand over a component. Expected window.__FSAOS_COMPONENT__ (what the compile emits) or a __FSAOS_REGISTER__(Component) call."
|
|
4720
|
+
);
|
|
4721
|
+
}
|
|
4722
|
+
if (typeof resolved !== "function") {
|
|
4723
|
+
throw new Error(`The compiled build handed over something that is not a React component (${typeof resolved}).`);
|
|
4724
|
+
}
|
|
4725
|
+
compiledComponents.set(key, resolved);
|
|
4726
|
+
}
|
|
4727
|
+
const cssKey = bundle.stylesheet ? `compiled:${key}` : null;
|
|
4728
|
+
if (cssKey) {
|
|
4729
|
+
heldCssKey = cssKey;
|
|
4730
|
+
await holdComponentCss(cssKey, async () => bundle.stylesheet);
|
|
4731
|
+
}
|
|
4732
|
+
if (cancelled) {
|
|
4733
|
+
if (heldCssKey) releaseComponentCss(heldCssKey);
|
|
4734
|
+
return;
|
|
4735
|
+
}
|
|
4736
|
+
const previousCssKey = shown.current?.cssKey ?? null;
|
|
4737
|
+
shown.current = { key, cssKey };
|
|
4738
|
+
heldCssKey = null;
|
|
4739
|
+
setOnScreen({ Component: resolved, key, scopeClass: bundle.scopeClass });
|
|
4740
|
+
setStatus("ready");
|
|
4741
|
+
if (previousCssKey) releaseComponentCss(previousCssKey);
|
|
4742
|
+
} catch (err) {
|
|
4743
|
+
if (heldCssKey) releaseComponentCss(heldCssKey);
|
|
4744
|
+
if (cancelled) return;
|
|
4745
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
4746
|
+
if (!shown.current) setStatus("error");
|
|
4747
|
+
}
|
|
4748
|
+
})();
|
|
4749
|
+
return () => {
|
|
4750
|
+
cancelled = true;
|
|
4751
|
+
};
|
|
4752
|
+
}, [fileId, sha256, scopePath]);
|
|
4753
|
+
React.useEffect(() => () => {
|
|
4754
|
+
if (shown.current?.cssKey) releaseComponentCss(shown.current.cssKey);
|
|
4755
|
+
shown.current = null;
|
|
4756
|
+
}, []);
|
|
4757
|
+
return {
|
|
4758
|
+
Component: onScreen?.Component ?? null,
|
|
4759
|
+
/** The class to put on the element that wraps the component (see `CompiledBundle.scopeClass`). */
|
|
4760
|
+
scopeClass: onScreen?.scopeClass ?? null,
|
|
4761
|
+
status,
|
|
4762
|
+
error
|
|
4763
|
+
};
|
|
4764
|
+
}
|
|
4626
4765
|
var THEME_PROPERTIES = [
|
|
4627
4766
|
"--color-primary",
|
|
4628
4767
|
"--color-secondary",
|
|
@@ -7676,6 +7815,7 @@ exports.isScopeReady = isScopeReady;
|
|
|
7676
7815
|
exports.itemsFilterFromQueryFilter = itemsFilterFromQueryFilter;
|
|
7677
7816
|
exports.listChildren = listChildren;
|
|
7678
7817
|
exports.listInvitations = listInvitations;
|
|
7818
|
+
exports.loadCompiledBundle = loadCompiledBundle;
|
|
7679
7819
|
exports.loadMounts = loadMounts;
|
|
7680
7820
|
exports.loadPublishedBundle = loadPublishedBundle;
|
|
7681
7821
|
exports.mount = mount2;
|
|
@@ -7738,6 +7878,7 @@ exports.useAuth = useAuth;
|
|
|
7738
7878
|
exports.useChannelMessages = useChannelMessages;
|
|
7739
7879
|
exports.useChannels = useChannels;
|
|
7740
7880
|
exports.useChildren = useChildren;
|
|
7881
|
+
exports.useCompiledComponent = useCompiledComponent;
|
|
7741
7882
|
exports.useComponent = useComponent;
|
|
7742
7883
|
exports.useCreate = useCreate;
|
|
7743
7884
|
exports.useCreateAgent = useCreateAgent;
|