@ai4b-team/fsaos-gateway-sdk 4.3.0 → 5.0.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-11-05T00:06:42.061Z */
1
+ /* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-11-11T18:24:37.520Z */
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
@@ -223,7 +223,6 @@ __export(src_exports, {
223
223
  useSeatMember: () => useSeatMember,
224
224
  useTheme: () => useTheme,
225
225
  useTimelineHistory: () => useTimelineHistory,
226
- useTool: () => useTool,
227
226
  useTree: () => useTree,
228
227
  useType: () => useType,
229
228
  useTypeHelpers: () => useTypeHelpers,
@@ -2556,6 +2555,204 @@ function replaceMounts(refs, anchor) {
2556
2555
  });
2557
2556
  }
2558
2557
 
2558
+ // src/ui.ts
2559
+ var ui_exports = {};
2560
+ __export(ui_exports, {
2561
+ Badge: () => Badge,
2562
+ Breadcrumbs: () => Breadcrumbs,
2563
+ Button: () => Button,
2564
+ Card: () => Card,
2565
+ DataView: () => DataView,
2566
+ Detail: () => Detail,
2567
+ Empty: () => Empty,
2568
+ FilePreview: () => FilePreview,
2569
+ Form: () => Form,
2570
+ Grid: () => Grid,
2571
+ Image: () => Image,
2572
+ Link: () => Link,
2573
+ Page: () => Page,
2574
+ Router: () => Router,
2575
+ Sidebar: () => Sidebar,
2576
+ Spinner: () => Spinner,
2577
+ Stack: () => Stack,
2578
+ Table: () => Table,
2579
+ Tabs: () => Tabs,
2580
+ Video: () => Video
2581
+ });
2582
+ function getEdgeBaseUrl() {
2583
+ const config2 = typeof window !== "undefined" && window.__FSAOS_CONFIG__ || {};
2584
+ return config2.edgeBaseUrl || "";
2585
+ }
2586
+ function Page(props) {
2587
+ return React.createElement("div", {
2588
+ style: { minHeight: "100vh", display: "flex", flexDirection: "column" },
2589
+ className: props.className || ""
2590
+ }, props.children);
2591
+ }
2592
+ function Stack(props) {
2593
+ const dir = props.direction || "vertical";
2594
+ return React.createElement("div", {
2595
+ style: {
2596
+ display: "flex",
2597
+ flexDirection: dir === "horizontal" ? "row" : "column",
2598
+ gap: props.gap || "0.5rem",
2599
+ padding: props.padding || "0",
2600
+ alignItems: props.align || "stretch",
2601
+ justifyContent: props.justify || "flex-start",
2602
+ flex: props.flex || "initial"
2603
+ },
2604
+ className: props.className || ""
2605
+ }, props.children);
2606
+ }
2607
+ function Grid(props) {
2608
+ return React.createElement("div", {
2609
+ style: {
2610
+ display: "grid",
2611
+ gridTemplateColumns: "repeat(" + (props.columns || 3) + ", 1fr)",
2612
+ gap: props.gap || "1rem",
2613
+ padding: props.padding || "0"
2614
+ },
2615
+ className: props.className || ""
2616
+ }, props.children);
2617
+ }
2618
+ function Sidebar(props) {
2619
+ return React.createElement("div", {
2620
+ style: { display: "flex", flexDirection: "row", minHeight: "100vh" },
2621
+ className: props.className || ""
2622
+ }, props.children);
2623
+ }
2624
+ function Card(props) {
2625
+ return React.createElement("div", {
2626
+ style: {
2627
+ border: "1px solid var(--color-border, #e5e7eb)",
2628
+ borderRadius: "var(--border-radius, 0.5rem)",
2629
+ padding: props.padding || "1rem",
2630
+ background: "var(--color-surface, #fff)"
2631
+ },
2632
+ className: props.className || "",
2633
+ onClick: props.onClick
2634
+ }, props.children);
2635
+ }
2636
+ function Badge(props) {
2637
+ return React.createElement("span", {
2638
+ style: {
2639
+ display: "inline-flex",
2640
+ alignItems: "center",
2641
+ padding: "0.125rem 0.5rem",
2642
+ fontSize: "0.75rem",
2643
+ fontWeight: "500",
2644
+ borderRadius: "9999px",
2645
+ background: props.color || "#e5e7eb",
2646
+ color: props.textColor || "#374151"
2647
+ },
2648
+ className: props.className || ""
2649
+ }, props.children || props.label);
2650
+ }
2651
+ function Spinner(props) {
2652
+ const size = props.size || "1.5rem";
2653
+ return React.createElement("div", {
2654
+ style: {
2655
+ width: size,
2656
+ height: size,
2657
+ border: "2px solid #e5e7eb",
2658
+ borderTopColor: "var(--color-primary, #3b82f6)",
2659
+ borderRadius: "50%",
2660
+ animation: "fsaos-spin 0.6s linear infinite"
2661
+ }
2662
+ });
2663
+ }
2664
+ function Button(props) {
2665
+ return React.createElement("button", {
2666
+ style: {
2667
+ display: "inline-flex",
2668
+ alignItems: "center",
2669
+ justifyContent: "center",
2670
+ padding: "0.5rem 1rem",
2671
+ fontSize: "0.875rem",
2672
+ fontWeight: "500",
2673
+ borderRadius: "var(--border-radius, 0.375rem)",
2674
+ border: props.variant === "outline" ? "1px solid var(--color-border, #d1d5db)" : "none",
2675
+ background: props.variant === "outline" || props.variant === "ghost" ? "transparent" : "var(--color-primary, #3b82f6)",
2676
+ color: props.variant === "outline" || props.variant === "ghost" ? "var(--color-text, #1a1a1a)" : "#fff",
2677
+ cursor: props.disabled ? "not-allowed" : "pointer",
2678
+ opacity: props.disabled ? "0.5" : "1",
2679
+ gap: "0.5rem"
2680
+ },
2681
+ className: props.className || "",
2682
+ onClick: props.onClick,
2683
+ disabled: props.disabled
2684
+ }, props.children || props.label);
2685
+ }
2686
+ function Empty(props) {
2687
+ return React.createElement(
2688
+ "div",
2689
+ {
2690
+ style: {
2691
+ display: "flex",
2692
+ flexDirection: "column",
2693
+ alignItems: "center",
2694
+ justifyContent: "center",
2695
+ padding: "3rem",
2696
+ color: "var(--color-text-secondary, #6b7280)",
2697
+ textAlign: "center"
2698
+ }
2699
+ },
2700
+ props.icon ? React.createElement("div", { style: { fontSize: "2rem", marginBottom: "0.5rem" } }, props.icon) : null,
2701
+ React.createElement(
2702
+ "div",
2703
+ { style: { fontWeight: 500, marginBottom: "0.25rem" } },
2704
+ props.title || props.message || props.children || "No items"
2705
+ ),
2706
+ props.description ? React.createElement("div", { style: { fontSize: "0.875rem", opacity: 0.7 } }, props.description) : null
2707
+ );
2708
+ }
2709
+ function DataView(props) {
2710
+ return React.createElement("div", { className: props.className || "" }, props.children);
2711
+ }
2712
+ function Table(props) {
2713
+ return React.createElement("table", { className: props.className || "" }, props.children);
2714
+ }
2715
+ function Form(props) {
2716
+ return React.createElement("form", { className: props.className || "", onSubmit: props.onSubmit }, props.children);
2717
+ }
2718
+ function Detail(props) {
2719
+ return React.createElement("div", { className: props.className || "" }, props.children);
2720
+ }
2721
+ function Router(props) {
2722
+ return React.createElement("div", null, props.children);
2723
+ }
2724
+ function Link(props) {
2725
+ return React.createElement("a", {
2726
+ href: props.href || props.to,
2727
+ className: props.className || "",
2728
+ onClick: props.onClick
2729
+ }, props.children);
2730
+ }
2731
+ function Tabs(props) {
2732
+ return React.createElement("div", { className: props.className || "" }, props.children);
2733
+ }
2734
+ function Breadcrumbs(props) {
2735
+ return React.createElement("nav", { className: props.className || "" }, props.children);
2736
+ }
2737
+ function Image(props) {
2738
+ return React.createElement("img", {
2739
+ src: props.src || (props.path ? getEdgeBaseUrl() + props.path : ""),
2740
+ alt: props.alt || "",
2741
+ className: props.className || "",
2742
+ style: props.style
2743
+ });
2744
+ }
2745
+ function Video(props) {
2746
+ return React.createElement("video", {
2747
+ src: props.src || (props.path ? getEdgeBaseUrl() + props.path : ""),
2748
+ controls: true,
2749
+ className: props.className || ""
2750
+ });
2751
+ }
2752
+ function FilePreview(props) {
2753
+ return React.createElement("div", { className: props.className || "" }, props.children || "File preview");
2754
+ }
2755
+
2559
2756
  // src/mounted-reader-events.ts
2560
2757
  function inMountedReadScope(event) {
2561
2758
  if (typeof event.path !== "string") return false;
@@ -3496,7 +3693,6 @@ function useAsset(idOrPath) {
3496
3693
  return { data, loading, error };
3497
3694
  }
3498
3695
  var componentCache = {};
3499
- var componentCssCache = {};
3500
3696
  registerCleanup(() => {
3501
3697
  for (const key of Object.keys(componentCache)) {
3502
3698
  delete componentCache[key];
@@ -3521,9 +3717,11 @@ function sdkRequireShim(name) {
3521
3717
  return typeof window !== "undefined" && window.React ? { jsx: window.React.createElement, jsxs: window.React.createElement, Fragment: window.React.Fragment } : JsxRuntime__namespace;
3522
3718
  case "@fsaos/gateway":
3523
3719
  case "@fsaos/react":
3720
+ case "@ai4b-team/fsaos-gateway-sdk":
3524
3721
  return typeof window !== "undefined" && window.__FSAOS_GATEWAY__ || _sdkExports || {};
3525
3722
  case "@fsaos/ui":
3526
- return typeof window !== "undefined" && window.__FSAOS_UI__ || {};
3723
+ case "@ai4b-team/fsaos-gateway-sdk/ui":
3724
+ return typeof window !== "undefined" && window.__FSAOS_UI__ || ui_exports;
3527
3725
  case "@fsaos/theme":
3528
3726
  return {};
3529
3727
  default:
@@ -3531,29 +3729,41 @@ function sdkRequireShim(name) {
3531
3729
  return {};
3532
3730
  }
3533
3731
  }
3534
- function scopeComponentCss(cssText, scopeClass) {
3535
- return cssText.replace(
3536
- /^(\s*)(:root|body)(\s*[{,])/gm,
3537
- (_match, ws2, _sel, rest) => `${ws2}.${scopeClass}${rest}`
3538
- );
3539
- }
3540
- async function loadComponentCss(cssUrl, scopeId) {
3541
- if (componentCssCache[cssUrl]) return;
3732
+ var componentCss = {};
3733
+ async function fetchComponentCss(cssUrl) {
3542
3734
  try {
3543
3735
  const response = await fetch(cssUrl);
3544
- if (!response.ok) return;
3545
- let cssText = await response.text();
3546
- if (!cssText.trim()) return;
3547
- if (cssText.includes("No CSS bundle for this component")) return;
3548
- if (scopeId && !cssText.includes(`.fsaos-c-${scopeId}`)) ;
3549
- const style = document.createElement("style");
3550
- style.setAttribute("data-fsaos-component-css", cssUrl);
3551
- if (scopeId) ;
3552
- style.textContent = cssText;
3553
- document.head.appendChild(style);
3554
- componentCssCache[cssUrl] = style;
3736
+ if (!response.ok) return null;
3737
+ const cssText = await response.text();
3738
+ if (!cssText.trim()) return null;
3739
+ if (cssText.includes("No CSS bundle for this component")) return null;
3740
+ return cssText;
3555
3741
  } catch {
3742
+ return null;
3743
+ }
3744
+ }
3745
+ async function holdComponentCss(cssUrl) {
3746
+ let entry = componentCss[cssUrl];
3747
+ if (!entry) {
3748
+ entry = componentCss[cssUrl] = { users: 0, text: fetchComponentCss(cssUrl), style: null };
3556
3749
  }
3750
+ entry.users += 1;
3751
+ const cssText = await entry.text;
3752
+ if (componentCss[cssUrl] !== entry || entry.users === 0 || entry.style || !cssText) return;
3753
+ if (typeof document === "undefined") return;
3754
+ const style = document.createElement("style");
3755
+ style.setAttribute("data-fsaos-component-css", cssUrl);
3756
+ style.textContent = cssText;
3757
+ document.head.appendChild(style);
3758
+ entry.style = style;
3759
+ }
3760
+ function releaseComponentCss(cssUrl) {
3761
+ const entry = componentCss[cssUrl];
3762
+ if (!entry) return;
3763
+ entry.users -= 1;
3764
+ if (entry.users > 0) return;
3765
+ entry.style?.remove();
3766
+ delete componentCss[cssUrl];
3557
3767
  }
3558
3768
  function evaluateBundle(jsCode) {
3559
3769
  let registered = null;
@@ -3580,65 +3790,84 @@ function evaluateBundle(jsCode) {
3580
3790
  }
3581
3791
  }
3582
3792
  }
3583
- function useComponent(path) {
3793
+ function useComponent(path, options) {
3584
3794
  const [Component, setComponent] = React.useState(null);
3585
3795
  const [loading, setLoading] = React.useState(true);
3586
3796
  const [error, setError] = React.useState(null);
3797
+ const shown = React.useRef(null);
3798
+ const pinnedVersion = Number.isSafeInteger(options?.version) && options.version > 0 ? options.version : null;
3587
3799
  React.useEffect(() => {
3588
3800
  if (!path) return;
3589
3801
  let cancelled = false;
3590
- setLoading(true);
3591
3802
  setError(null);
3803
+ if (shown.current?.path !== path) {
3804
+ if (shown.current?.cssUrl) releaseComponentCss(shown.current.cssUrl);
3805
+ shown.current = null;
3806
+ setComponent(null);
3807
+ setLoading(true);
3808
+ }
3592
3809
  const config2 = typeof window !== "undefined" && window.__FSAOS_CONFIG__ || {};
3593
3810
  const edgeBaseUrl = config2.edgeBaseUrl || "";
3594
3811
  (async () => {
3812
+ let heldCssUrl = null;
3595
3813
  try {
3596
3814
  let version = 1;
3597
3815
  let cacheKey = path + "@v1";
3598
3816
  let bundleUrl = edgeBaseUrl + path + "/__bundle.js";
3599
- try {
3600
- const metaResponse = await fetch(edgeBaseUrl + path + "/__meta", { cache: "no-store" });
3601
- if (metaResponse.ok) {
3602
- const meta = await metaResponse.json();
3603
- version = meta.version || 1;
3604
- cacheKey = path + "@v" + version;
3605
- bundleUrl = edgeBaseUrl + path + "/__bundle.v" + version + ".js";
3817
+ if (pinnedVersion !== null) {
3818
+ version = pinnedVersion;
3819
+ cacheKey = path + "@v" + version;
3820
+ bundleUrl = edgeBaseUrl + path + "/__bundle.v" + version + ".js";
3821
+ } else {
3822
+ try {
3823
+ const metaResponse = await fetch(edgeBaseUrl + path + "/__meta", { cache: "no-store" });
3824
+ if (metaResponse.ok) {
3825
+ const meta = await metaResponse.json();
3826
+ version = meta.version || 1;
3827
+ cacheKey = path + "@v" + version;
3828
+ bundleUrl = edgeBaseUrl + path + "/__bundle.v" + version + ".js";
3829
+ }
3830
+ } catch {
3831
+ bundleUrl = edgeBaseUrl + path + "/__bundle.js?v=" + Date.now();
3606
3832
  }
3607
- } catch {
3608
- bundleUrl = edgeBaseUrl + path + "/__bundle.js?v=" + Date.now();
3609
- }
3610
- if (cancelled) return;
3611
- if (componentCache[cacheKey]) {
3612
- setComponent(() => componentCache[cacheKey]);
3613
- setLoading(false);
3614
- return;
3615
- }
3616
- const jsResponse = await fetch(bundleUrl);
3617
- if (!jsResponse.ok) {
3618
- throw new Error(
3619
- `Failed to fetch bundle: ${jsResponse.status} ${jsResponse.statusText} (${bundleUrl})`
3620
- );
3621
3833
  }
3622
- const jsCode = await jsResponse.text();
3623
3834
  if (cancelled) return;
3624
3835
  const cssUrl = bundleUrl.replace(/__bundle(\.v\d+)?\.js(\?.*)?$/, "__bundle$1.css");
3625
- loadComponentCss(cssUrl).catch(() => {
3626
- });
3627
- const resolved = evaluateBundle(jsCode);
3836
+ heldCssUrl = cssUrl;
3837
+ const cssReady = holdComponentCss(cssUrl);
3838
+ let resolved = componentCache[cacheKey];
3628
3839
  if (!resolved) {
3629
- throw new Error(
3630
- "Bundle did not export a component. Expected window.__FSAOS_COMPONENT__ (FSAOS build) or a __FSAOS_REGISTER__(Component) call."
3631
- );
3632
- }
3633
- if (typeof resolved !== "function") {
3634
- throw new Error(`Bundle export is not a React component (got ${typeof resolved})`);
3840
+ const jsResponse = await fetch(bundleUrl);
3841
+ if (!jsResponse.ok) {
3842
+ throw new Error(
3843
+ `Failed to fetch bundle: ${jsResponse.status} ${jsResponse.statusText} (${bundleUrl})`
3844
+ );
3845
+ }
3846
+ const jsCode = await jsResponse.text();
3847
+ resolved = evaluateBundle(jsCode);
3848
+ if (!resolved) {
3849
+ throw new Error(
3850
+ "Bundle did not export a component. Expected window.__FSAOS_COMPONENT__ (FSAOS build) or a __FSAOS_REGISTER__(Component) call."
3851
+ );
3852
+ }
3853
+ if (typeof resolved !== "function") {
3854
+ throw new Error(`Bundle export is not a React component (got ${typeof resolved})`);
3855
+ }
3856
+ componentCache[cacheKey] = resolved;
3635
3857
  }
3636
- componentCache[cacheKey] = resolved;
3637
- if (!cancelled) {
3638
- setComponent(() => resolved);
3639
- setLoading(false);
3858
+ await cssReady;
3859
+ if (cancelled) {
3860
+ releaseComponentCss(cssUrl);
3861
+ return;
3640
3862
  }
3863
+ const previousCssUrl = shown.current?.cssUrl ?? null;
3864
+ shown.current = { path, cssUrl };
3865
+ heldCssUrl = null;
3866
+ setComponent(() => resolved);
3867
+ setLoading(false);
3868
+ if (previousCssUrl) releaseComponentCss(previousCssUrl);
3641
3869
  } catch (err) {
3870
+ if (heldCssUrl) releaseComponentCss(heldCssUrl);
3642
3871
  if (!cancelled) {
3643
3872
  setError(err instanceof Error ? err : new Error(String(err)));
3644
3873
  setLoading(false);
@@ -3648,7 +3877,11 @@ function useComponent(path) {
3648
3877
  return () => {
3649
3878
  cancelled = true;
3650
3879
  };
3651
- }, [path]);
3880
+ }, [path, pinnedVersion]);
3881
+ React.useEffect(() => () => {
3882
+ if (shown.current?.cssUrl) releaseComponentCss(shown.current.cssUrl);
3883
+ shown.current = null;
3884
+ }, []);
3652
3885
  return { Component, loading, error };
3653
3886
  }
3654
3887
  var THEME_PROPERTIES = [
@@ -3822,9 +4055,6 @@ function usePrincipal() {
3822
4055
  error: null
3823
4056
  };
3824
4057
  }
3825
- function useTool() {
3826
- return { data: null, loading: false, error: null };
3827
- }
3828
4058
  function ComponentRenderer(props) {
3829
4059
  const { path, ...rest } = props;
3830
4060
  const result = useComponent(path);
@@ -5659,14 +5889,27 @@ function getRequiredFormFields(typeDef) {
5659
5889
  (f) => required.has(f.key) || f.default_value === void 0
5660
5890
  );
5661
5891
  }
5662
- var _idCounter = 0;
5663
5892
  function generateUploadId() {
5664
- return `upload_${Date.now()}_${++_idCounter}`;
5893
+ if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
5894
+ const bytes = new Uint8Array(16);
5895
+ if (globalThis.crypto?.getRandomValues) {
5896
+ globalThis.crypto.getRandomValues(bytes);
5897
+ bytes[6] = bytes[6] & 15 | 64;
5898
+ bytes[8] = bytes[8] & 63 | 128;
5899
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
5900
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
5901
+ }
5902
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
5903
+ const n = Math.floor(Math.random() * 16);
5904
+ return (c === "x" ? n : n & 3 | 8).toString(16);
5905
+ });
5665
5906
  }
5666
5907
  async function uploadFile(file, options, onProgress, signal2) {
5667
5908
  const fileName = options.name || (file instanceof File ? file.name : `file-${Date.now()}`);
5668
5909
  const contentType = file.type || "application/octet-stream";
5669
5910
  const itemType = options.itemType || "file";
5911
+ const collisionPolicy = options.collisionPolicy || "keep_both";
5912
+ const uploadId = collisionPolicy === "keep_both" ? generateUploadId() : void 0;
5670
5913
  const createParams = {
5671
5914
  parent_path: options.parentPath,
5672
5915
  item_type: itemType,
@@ -5675,7 +5918,9 @@ async function uploadFile(file, options, onProgress, signal2) {
5675
5918
  ...options.typeData || {},
5676
5919
  file_source: {
5677
5920
  type: "upload",
5678
- content_type: contentType
5921
+ content_type: contentType,
5922
+ collision_policy: collisionPolicy,
5923
+ ...uploadId ? { upload_id: uploadId } : {}
5679
5924
  }
5680
5925
  }
5681
5926
  };
@@ -5777,6 +6022,7 @@ function useFileUpload() {
5777
6022
  const fileName = options.name || file.name;
5778
6023
  const contentType = file.type || "application/octet-stream";
5779
6024
  const itemType = options.itemType || "file";
6025
+ const collisionPolicy = options.collisionPolicy || "keep_both";
5780
6026
  let itemId = existingState?.itemId || null;
5781
6027
  let itemPath = existingState?.itemPath || null;
5782
6028
  let storageKey = existingState?.storageKey || null;
@@ -5793,7 +6039,9 @@ function useFileUpload() {
5793
6039
  ...options.typeData || {},
5794
6040
  file_source: {
5795
6041
  type: "upload",
5796
- content_type: contentType
6042
+ content_type: contentType,
6043
+ collision_policy: collisionPolicy,
6044
+ ...collisionPolicy === "keep_both" ? { upload_id: uploadId } : {}
5797
6045
  }
5798
6046
  }
5799
6047
  });
@@ -6559,7 +6807,6 @@ exports.useSearch = useSearch;
6559
6807
  exports.useSeatMember = useSeatMember;
6560
6808
  exports.useTheme = useTheme;
6561
6809
  exports.useTimelineHistory = useTimelineHistory;
6562
- exports.useTool = useTool;
6563
6810
  exports.useTree = useTree;
6564
6811
  exports.useType = useType;
6565
6812
  exports.useTypeHelpers = useTypeHelpers;