@asymmetric-effort/specifyjs 1.1.7 → 1.2.2

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.
@@ -28,7 +28,7 @@ import {
28
28
  useEffect,
29
29
  useMemo,
30
30
  useState
31
- } from "./chunk-4V37N6QN.js";
31
+ } from "./chunk-AQX42M4L.js";
32
32
 
33
33
  // src/context/create-context.ts
34
34
  function createContext(defaultValue) {
@@ -1,5 +1,105 @@
1
1
  /* (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE */
2
2
 
3
+ // src/hooks/use-media-query.ts
4
+ function useMediaQuery(query) {
5
+ const subscribe2 = useCallback(
6
+ (onStoreChange) => {
7
+ if (typeof window === "undefined") return () => {
8
+ };
9
+ const mql = window.matchMedia(query);
10
+ mql.addEventListener("change", onStoreChange);
11
+ return () => mql.removeEventListener("change", onStoreChange);
12
+ },
13
+ [query]
14
+ );
15
+ const getSnapshot2 = useCallback(() => {
16
+ if (typeof window === "undefined") return false;
17
+ return window.matchMedia(query).matches;
18
+ }, [query]);
19
+ const getServerSnapshot2 = useCallback(() => false, []);
20
+ return useSyncExternalStore(subscribe2, getSnapshot2, getServerSnapshot2);
21
+ }
22
+
23
+ // src/hooks/use-window-size.ts
24
+ var currentSize = typeof window !== "undefined" ? { width: window.innerWidth, height: window.innerHeight } : { width: 0, height: 0 };
25
+ var listeners = /* @__PURE__ */ new Set();
26
+ var listenerAttached = false;
27
+ function handleResize() {
28
+ const w = window.innerWidth;
29
+ const h = window.innerHeight;
30
+ if (w === currentSize.width && h === currentSize.height) return;
31
+ currentSize = { width: w, height: h };
32
+ for (const cb of listeners) cb();
33
+ }
34
+ function subscribe(callback) {
35
+ listeners.add(callback);
36
+ if (!listenerAttached && typeof window !== "undefined") {
37
+ window.addEventListener("resize", handleResize);
38
+ listenerAttached = true;
39
+ }
40
+ return () => {
41
+ listeners.delete(callback);
42
+ if (listeners.size === 0 && listenerAttached) {
43
+ window.removeEventListener("resize", handleResize);
44
+ listenerAttached = false;
45
+ }
46
+ };
47
+ }
48
+ function getSnapshot() {
49
+ return currentSize;
50
+ }
51
+ function getServerSnapshot() {
52
+ return { width: 0, height: 0 };
53
+ }
54
+ function useWindowSize() {
55
+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
56
+ }
57
+
58
+ // src/hooks/breakpoints.ts
59
+ var DEFAULT_BREAKPOINTS = {
60
+ xs: 0,
61
+ sm: 640,
62
+ md: 768,
63
+ lg: 1024,
64
+ xl: 1280,
65
+ "2xl": 1536
66
+ };
67
+ var breakpoints = { ...DEFAULT_BREAKPOINTS };
68
+ function getBreakpoints() {
69
+ return { ...breakpoints };
70
+ }
71
+ function configureBreakpoints(custom) {
72
+ breakpoints = { ...DEFAULT_BREAKPOINTS, ...custom };
73
+ }
74
+ function breakpointQuery(name) {
75
+ return `(min-width: ${breakpoints[name]}px)`;
76
+ }
77
+
78
+ // src/hooks/use-breakpoint.ts
79
+ var BREAKPOINT_ORDER = ["2xl", "xl", "lg", "md", "sm", "xs"];
80
+ function useBreakpoint() {
81
+ const match2xl = useMediaQuery(breakpointQuery("2xl"));
82
+ const matchXl = useMediaQuery(breakpointQuery("xl"));
83
+ const matchLg = useMediaQuery(breakpointQuery("lg"));
84
+ const matchMd = useMediaQuery(breakpointQuery("md"));
85
+ const matchSm = useMediaQuery(breakpointQuery("sm"));
86
+ if (match2xl) return "2xl";
87
+ if (matchXl) return "xl";
88
+ if (matchLg) return "lg";
89
+ if (matchMd) return "md";
90
+ if (matchSm) return "sm";
91
+ return "xs";
92
+ }
93
+ function useBreakpointValue(values) {
94
+ const current = useBreakpoint();
95
+ const idx = BREAKPOINT_ORDER.indexOf(current);
96
+ for (let i = idx; i < BREAKPOINT_ORDER.length; i++) {
97
+ const val = values[BREAKPOINT_ORDER[i]];
98
+ if (val !== void 0) return val;
99
+ }
100
+ return void 0;
101
+ }
102
+
3
103
  // src/hooks/index.ts
4
104
  var currentDispatcher = null;
5
105
  function __setDispatcher(dispatcher) {
@@ -52,8 +152,8 @@ function useDeferredValue(value) {
52
152
  function useTransition() {
53
153
  return resolveDispatcher().useTransition();
54
154
  }
55
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
56
- return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
155
+ function useSyncExternalStore(subscribe2, getSnapshot2, getServerSnapshot2) {
156
+ return resolveDispatcher().useSyncExternalStore(subscribe2, getSnapshot2, getServerSnapshot2);
57
157
  }
58
158
  function useInsertionEffect(create, deps) {
59
159
  return resolveDispatcher().useInsertionEffect(create, deps);
@@ -182,6 +282,13 @@ function setHttpEquivMeta(httpEquiv, content) {
182
282
 
183
283
  export {
184
284
  useHead,
285
+ useMediaQuery,
286
+ useWindowSize,
287
+ getBreakpoints,
288
+ configureBreakpoints,
289
+ breakpointQuery,
290
+ useBreakpoint,
291
+ useBreakpointValue,
185
292
  __setDispatcher,
186
293
  useState,
187
294
  useEffect,
@@ -7,7 +7,7 @@ import {
7
7
  useEffect,
8
8
  useRef,
9
9
  useState
10
- } from "../chunks/chunk-4V37N6QN.js";
10
+ } from "../chunks/chunk-AQX42M4L.js";
11
11
  import "../chunks/chunk-FDNBPWUH.js";
12
12
 
13
13
  // src/client/rest.ts
@@ -1,7 +1,7 @@
1
1
  /* (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE */
2
2
  import {
3
3
  createContext
4
- } from "./chunks/chunk-PGUFCUSX.js";
4
+ } from "./chunks/chunk-5NXJ7PRB.js";
5
5
  import "./chunks/chunk-7OC7LXZ7.js";
6
6
  import "./chunks/chunk-SRUWIDIG.js";
7
7
  import {
@@ -18,7 +18,7 @@ import {
18
18
  useReducer,
19
19
  useRef,
20
20
  useState
21
- } from "./chunks/chunk-4V37N6QN.js";
21
+ } from "./chunks/chunk-AQX42M4L.js";
22
22
  import {
23
23
  __publicField
24
24
  } from "./chunks/chunk-FDNBPWUH.js";
@@ -15974,6 +15974,34 @@ var FILE_CONTENTS = {
15974
15974
  };
15975
15975
  var SAMPLE_CODE = FILE_CONTENTS["App.ts"];
15976
15976
  function IDE(props) {
15977
+ const isMobile = typeof window !== "undefined" && window.innerWidth < 768;
15978
+ if (isMobile) {
15979
+ return createElement(
15980
+ "div",
15981
+ {
15982
+ style: {
15983
+ display: "flex",
15984
+ flexDirection: "column",
15985
+ alignItems: "center",
15986
+ justifyContent: "center",
15987
+ height: "100%",
15988
+ minHeight: "300px",
15989
+ padding: "32px",
15990
+ textAlign: "center",
15991
+ backgroundColor: "#1e1e1e",
15992
+ color: "#cccccc",
15993
+ fontFamily: '"Segoe UI", Roboto, Arial, sans-serif'
15994
+ }
15995
+ },
15996
+ createElement("div", { style: { fontSize: "48px", marginBottom: "16px" } }, "\u{1F4BB}"),
15997
+ createElement("h3", { style: { fontSize: "18px", fontWeight: "600", marginBottom: "8px" } }, "Desktop Experience"),
15998
+ createElement(
15999
+ "p",
16000
+ { style: { fontSize: "14px", opacity: "0.8", maxWidth: "300px" } },
16001
+ "The IDE layout requires a desktop-sized screen. Please view on a device with a wider display."
16002
+ )
16003
+ );
16004
+ }
15977
16005
  const [activeFile, setActiveFile] = useState("App.ts");
15978
16006
  const [expandedFolders, setExpandedFolders] = useState({
15979
16007
  src: true,
@@ -16734,6 +16762,34 @@ function buildMarketDepth() {
16734
16762
  );
16735
16763
  }
16736
16764
  function TradingDashboard(props) {
16765
+ const isMobile = typeof window !== "undefined" && window.innerWidth < 768;
16766
+ if (isMobile) {
16767
+ return createElement(
16768
+ "div",
16769
+ {
16770
+ style: {
16771
+ display: "flex",
16772
+ flexDirection: "column",
16773
+ alignItems: "center",
16774
+ justifyContent: "center",
16775
+ height: "100%",
16776
+ minHeight: "300px",
16777
+ padding: "32px",
16778
+ textAlign: "center",
16779
+ backgroundColor: "#0d0d1a",
16780
+ color: "#ccccdd",
16781
+ fontFamily: '"Inter", "Segoe UI", Roboto, sans-serif'
16782
+ }
16783
+ },
16784
+ createElement("div", { style: { fontSize: "48px", marginBottom: "16px" } }, "\u{1F4C8}"),
16785
+ createElement("h3", { style: { fontSize: "18px", fontWeight: "600", marginBottom: "8px" } }, "Desktop Experience"),
16786
+ createElement(
16787
+ "p",
16788
+ { style: { fontSize: "14px", opacity: "0.8", maxWidth: "300px" } },
16789
+ "The Trading Dashboard requires a desktop-sized screen. Please view on a device with a wider display."
16790
+ )
16791
+ );
16792
+ }
16737
16793
  const [priceOffset, setPriceOffset] = useState(0);
16738
16794
  const [clockTime, setClockTime] = useState("--:--:--");
16739
16795
  const [liveVisible, setLiveVisible] = useState(true);
@@ -20707,6 +20763,34 @@ function getMockContent(title, windowId, onTitleChange) {
20707
20763
  }
20708
20764
  function UnityDesktopInner(props) {
20709
20765
  const { apps, user, onAppOpen, onLogout, theme = "dark", children } = props;
20766
+ const isMobile = typeof window !== "undefined" && window.innerWidth < 768;
20767
+ if (isMobile) {
20768
+ return createElement(
20769
+ "div",
20770
+ {
20771
+ style: {
20772
+ display: "flex",
20773
+ flexDirection: "column",
20774
+ alignItems: "center",
20775
+ justifyContent: "center",
20776
+ height: "100%",
20777
+ minHeight: "300px",
20778
+ padding: "32px",
20779
+ textAlign: "center",
20780
+ backgroundColor: "#2c001e",
20781
+ color: "#ffffff",
20782
+ fontFamily: "Ubuntu, sans-serif"
20783
+ }
20784
+ },
20785
+ createElement("div", { style: { fontSize: "48px", marginBottom: "16px" } }, "\u{1F5A5}\uFE0F"),
20786
+ createElement("h3", { style: { fontSize: "18px", fontWeight: "600", marginBottom: "8px" } }, "Desktop Experience"),
20787
+ createElement(
20788
+ "p",
20789
+ { style: { fontSize: "14px", opacity: "0.8", maxWidth: "300px" } },
20790
+ "The Unity Desktop layout is designed for desktop screens. Please view on a device with a wider display."
20791
+ )
20792
+ );
20793
+ }
20710
20794
  const wm = useWindowManager();
20711
20795
  const wmActiveMenuBar = wm.activeMenuBar;
20712
20796
  const wmDockSignals = wm.dockSignals;
@@ -28,7 +28,7 @@ import {
28
28
  } from "../chunks/chunk-UJTLBTMV.js";
29
29
  import {
30
30
  __setDispatcher
31
- } from "../chunks/chunk-4V37N6QN.js";
31
+ } from "../chunks/chunk-AQX42M4L.js";
32
32
  import "../chunks/chunk-FDNBPWUH.js";
33
33
 
34
34
  // src/core/fiber.ts
package/dist/esm/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  useNavigate,
25
25
  useParams,
26
26
  useRouter
27
- } from "./chunks/chunk-PGUFCUSX.js";
27
+ } from "./chunks/chunk-5NXJ7PRB.js";
28
28
  import {
29
29
  getComponentTypeTable,
30
30
  resolveComponentId,
@@ -45,6 +45,11 @@ import {
45
45
  secureFetch
46
46
  } from "./chunks/chunk-RH3DFT32.js";
47
47
  import {
48
+ breakpointQuery,
49
+ configureBreakpoints,
50
+ getBreakpoints,
51
+ useBreakpoint,
52
+ useBreakpointValue,
48
53
  useCallback,
49
54
  useContext,
50
55
  useDebugValue,
@@ -55,13 +60,15 @@ import {
55
60
  useImperativeHandle,
56
61
  useInsertionEffect,
57
62
  useLayoutEffect,
63
+ useMediaQuery,
58
64
  useMemo,
59
65
  useReducer,
60
66
  useRef,
61
67
  useState,
62
68
  useSyncExternalStore,
63
- useTransition
64
- } from "./chunks/chunk-4V37N6QN.js";
69
+ useTransition,
70
+ useWindowSize
71
+ } from "./chunks/chunk-AQX42M4L.js";
65
72
  import "./chunks/chunk-FDNBPWUH.js";
66
73
  export {
67
74
  Children,
@@ -79,12 +86,15 @@ export {
79
86
  Suspense,
80
87
  act,
81
88
  assertSecureUrl,
89
+ breakpointQuery,
82
90
  cloneElement,
91
+ configureBreakpoints,
83
92
  createContext,
84
93
  createElement,
85
94
  createFactory,
86
95
  createRef,
87
96
  forwardRef,
97
+ getBreakpoints,
88
98
  getComponentTypeTable,
89
99
  createElement as h,
90
100
  isValidElement,
@@ -95,6 +105,8 @@ export {
95
105
  secureFetch,
96
106
  setComponentIdsEnabled,
97
107
  startTransition,
108
+ useBreakpoint,
109
+ useBreakpointValue,
98
110
  useCallback,
99
111
  useContext,
100
112
  useDebugValue,
@@ -106,6 +118,7 @@ export {
106
118
  useImperativeHandle,
107
119
  useInsertionEffect,
108
120
  useLayoutEffect,
121
+ useMediaQuery,
109
122
  useMemo,
110
123
  useNavigate,
111
124
  useParams,
@@ -114,5 +127,6 @@ export {
114
127
  useRouter,
115
128
  useState,
116
129
  useSyncExternalStore,
117
- useTransition
130
+ useTransition,
131
+ useWindowSize
118
132
  };
@@ -9,7 +9,7 @@ import "../chunks/chunk-RH3DFT32.js";
9
9
  import {
10
10
  useEffect,
11
11
  useRef
12
- } from "../chunks/chunk-4V37N6QN.js";
12
+ } from "../chunks/chunk-AQX42M4L.js";
13
13
  import "../chunks/chunk-FDNBPWUH.js";
14
14
 
15
15
  // src/telemetry/tracing.ts
@@ -1,2 +1,2 @@
1
1
  /* (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE */
2
- "use strict";var O=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},re=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!te.call(e,r)&&r!==n&&O(e,r,{get:()=>t[r],enumerable:!(o=Y(t,r))||o.enumerable});return e};var oe=e=>re(O({},"__esModule",{value:!0}),e);var ge={};ne(ge,{RestError:()=>v,createGraphQLClient:()=>B,createGrpcWebClient:()=>j,createRestClient:()=>F,defineMessage:()=>N,gql:()=>_,useMutation:()=>X,useProto:()=>J,useQuery:()=>K,useRest:()=>W});module.exports=oe(ge);var H=null;function P(){if(H===null)throw new Error("Invalid hook call. Hooks can only be called inside the body of a function component.");return H}function w(e){return P().useState(e)}function S(e,t){return P().useEffect(e,t)}function k(e,t){return P().useCallback(e,t)}function x(e){return P().useRef(e)}var se=/^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function ie(e){let t=se.exec(e);return t?Number(t[1])<=255&&Number(t[2])<=255&&Number(t[3])<=255:!1}function L(e){if(e.startsWith("//"))throw new Error(`[SpecifyJS] Protocol-relative URL rejected: "${e}". Use an explicit https:// prefix.`);if(e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return;if(e.startsWith("data:")){if(e.length>1024*1024)throw new Error("[SpecifyJS] secureFetch: data: URI exceeds 1MB limit");return}let t;try{t=new URL(e,typeof window<"u"?window.location.href:void 0)}catch{throw new Error(`[SpecifyJS] secureFetch: unable to validate URL "${e}". Provide a valid absolute HTTPS URL or a relative path.`)}if(t.protocol==="https:")return;let n=t.hostname.toLowerCase();if(!(n==="localhost"||n==="127.0.0.1"||n==="[::1]"||n==="0.0.0.0"||ie(n)))throw n.endsWith(".localhost")?new Error(`[SpecifyJS] SSRF protection: "${e}" uses a .localhost subdomain which resolves to the loopback interface. Use exact "localhost" instead.`):new Error(`[SpecifyJS] Insecure URL rejected: "${e}". SpecifyJS enforces HTTPS-only for all network requests. Use https:// or a relative URL. Localhost URLs are allowed for development.`)}var v=class extends Error{constructor(t,n,o,r,u){super(t),this.name="RestError",this.status=n,this.statusText=o,this.data=r,this.config=u}};function ae(e){let t={};return e.forEach((n,o)=>{t[o]=n}),t}function ue(e,t){let n=e.endsWith("/")?e.slice(0,-1):e,o=t.startsWith("/")?t:"/"+t;return n+o}function F(e){let{baseURL:t,headers:n={},timeout:o,interceptors:r={}}=e,u=r.request??[],c=r.response??[],f=r.error??[];async function h(l,a,s,p){let i={url:ue(t,a),method:l,headers:{...n,...p?.headers??{}},body:s,signal:p?.signal,timeout:p?.timeout??o};s!=null&&!i.headers["Content-Type"]&&(i.headers["Content-Type"]="application/json");for(let R of u)i=await R(i);let g,d;if(i.timeout&&i.timeout>0&&(d=new AbortController,g=setTimeout(()=>{d.abort()},i.timeout),i.signal)){let R=i.signal;R.aborted?d.abort():R.addEventListener("abort",()=>{d.abort()})}let T=d?d.signal:i.signal,y={method:i.method,headers:i.headers,signal:T};s!=null&&(y.body=JSON.stringify(s));let m;try{L(i.url),m=await fetch(i.url,y)}catch(R){g!==void 0&&clearTimeout(g);let z=R instanceof DOMException&&R.name==="AbortError"?`Request timeout after ${i.timeout}ms`:R instanceof Error?R.message:"Network error",A=new v(z,0,"",null,i);for(let Z of f)A=await Z(A);throw A}g!==void 0&&clearTimeout(g);let E=m.headers.get("content-type")??"",b;if(E.includes("application/json"))b=await m.json();else{let R=await m.text();try{b=JSON.parse(R)}catch{b=R}}let C=ae(m.headers);if(!m.ok){let R=new v(`Request failed with status ${m.status}`,m.status,m.statusText,b,i);for(let M of f)R=await M(R);throw R}let G={data:b,status:m.status,headers:C,ok:m.ok};for(let R of c)G=R(G);return G}return{get(l,a){return h("GET",l,void 0,a)},post(l,a,s){return h("POST",l,a,s)},put(l,a,s){return h("PUT",l,a,s)},patch(l,a,s){return h("PATCH",l,a,s)},delete(l,a){return h("DELETE",l,void 0,a)}}}function W(e,t,n){let o=n?.method??"GET",r=n?.body,u=n?.deps??[],c=n?.enabled??!0,[f,h]=w(null),[l,a]=w(c),[s,p]=w(null),i=x(null),g=x(!0),d=k(()=>{if(!c){a(!1);return}i.current&&i.current.abort();let y=new AbortController;i.current=y,a(!0),p(null);let m={signal:y.signal},E,b=o.toUpperCase();b==="POST"?E=e.post(t,r,m):b==="PUT"?E=e.put(t,r,m):b==="PATCH"?E=e.patch(t,r,m):b==="DELETE"?E=e.delete(t,m):E=e.get(t,m),E.then(C=>{g.current&&!y.signal.aborted&&(h(C.data),a(!1))}).catch(C=>{g.current&&!y.signal.aborted&&(p(C instanceof v?C:new v(C instanceof Error?C.message:"Unknown error",0,"",null,{url:t,method:b,headers:{}})),a(!1))})},[e,t,o,r,c,...u]);S(()=>(g.current=!0,d(),()=>{g.current=!1,i.current&&i.current.abort()}),[d]);let T=k(()=>{d()},[d]);return{data:f,loading:l,error:s,refetch:T}}function q(e){let t=[],n=e>>>0;for(;n>127;)t.push(n&127|128),n>>>=7;return t.push(n&127),t}function U(e,t){let n=0,o=0,r=t;for(;r<e.length;){let u=e[r];if(n|=(u&127)<<o,r++,(u&128)===0)return[n>>>0,r];if(o+=7,o>=35)throw new Error("Varint too long")}throw new Error("Unexpected end of data while decoding varint")}var I=0,Q=1,D=2;function ce(e){switch(e){case"int32":case"uint32":case"bool":case"enum":return I;case"float64":return Q;case"string":case"bytes":return D}}function $(e,t){return q(e<<3|t)}function V(e,t){switch(e){case"int32":return q(t|0);case"uint32":return q(t>>>0);case"bool":return q(t?1:0);case"enum":return q(t>>>0);case"float64":{let n=new ArrayBuffer(8);return new DataView(n).setFloat64(0,t,!0),Array.from(new Uint8Array(n))}case"string":{let n=new TextEncoder().encode(t);return[...q(n.length),...n]}case"bytes":{let n=t;return[...q(n.length),...n]}}}function le(e,t,n,o){switch(t){case I:{let[r,u]=U(n,o);switch(e){case"bool":return[r!==0,u];case"int32":return[r|0,u];case"uint32":case"enum":return[r>>>0,u];default:return[r,u]}}case Q:{if(o+8>n.length)throw new Error("Unexpected end of data while decoding 64-bit value");let r=new ArrayBuffer(8),u=new Uint8Array(r);for(let f=0;f<8;f++)u[f]=n[o+f]??0;return[new DataView(r).getFloat64(0,!0),o+8]}case D:{let[r,u]=U(n,o);if(u+r>n.length)throw new Error("Unexpected end of data while decoding length-delimited value");let c=n.slice(u,u+r);return e==="string"?[new TextDecoder().decode(c),u+r]:[c,u+r]}default:throw new Error(`Unknown wire type: ${t}`)}}function N(e,t){let n=new Map;for(let[u,c]of Object.entries(t))n.set(c.tag,{fieldName:u,descriptor:c});function o(u){let c=[],f=u;for(let[h,l]of Object.entries(t)){let a=f[h];if(a==null)continue;let s=ce(l.type);if(l.repeated){let p=a;for(let i of p)c.push(...$(l.tag,s)),c.push(...V(l.type,i))}else c.push(...$(l.tag,s)),c.push(...V(l.type,a))}return new Uint8Array(c)}function r(u){let c={};for(let[h,l]of Object.entries(t))l.repeated&&(c[h]=[]);let f=0;for(;f<u.length;){let[h,l]=U(u,f),a=h>>>3,s=h&7;f=l;let p=n.get(a);if(!p){f=pe(s,u,f);continue}let[i,g]=le(p.descriptor.type,s,u,f);f=g,p.descriptor.repeated?c[p.fieldName].push(i):c[p.fieldName]=i}return c}return{name:e,fields:t,encode:o,decode:r}}function pe(e,t,n){switch(e){case I:{let[,o]=U(t,n);return o}case Q:return n+8;case D:{let[o,r]=U(t,n);return r+o}default:throw new Error(`Cannot skip unknown wire type: ${e}`)}}function fe(e,t=0){let n=new Uint8Array(5+e.length);return n[0]=t,new DataView(n.buffer,n.byteOffset,n.byteLength).setUint32(1,e.length,!1),n.set(e,5),n}function de(e){if(e.length<5)throw new Error("gRPC-Web frame too short");let t=e[0]??0,o=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(1,!1);if(e.length<5+o)throw new Error("gRPC-Web frame data incomplete");let r=e.slice(5,5+o);return[t,r,5+o]}function j(e){let{baseURL:t,headers:n}=e;async function o(r,u,c,f,h){let l=c.encode(h),a=fe(l),s=`${t.replace(/\/+$/,"")}/${r}/${u}`,p={"Content-Type":"application/grpc-web+proto",Accept:"application/grpc-web+proto","X-Grpc-Web":"1",...n};L(s);let i=await fetch(s,{method:"POST",headers:p,body:a.buffer});if(!i.ok)throw new Error(`gRPC-Web request failed: ${i.status} ${i.statusText}`);let g=new Uint8Array(await i.arrayBuffer()),d=0;for(;d<g.length;){let[T,y,m]=de(g.subarray(d));if(d+=m,(T&128)===0)return f.decode(y)}throw new Error("No data frame found in gRPC-Web response")}return{unary:o}}function J(e,t,n,o,r,u,c){let[f,h]=w(null),[l,a]=w(!1),[s,p]=w(null),i=x(!0),g=x(u);g.current=u;let d=c?.enabled!==!1,T=k(()=>{d&&(a(!0),p(null),e.unary(t,n,o,r,g.current).then(y=>{i.current&&(h(y),a(!1))}).catch(y=>{i.current&&(p(y instanceof Error?y:new Error(String(y))),a(!1))}))},[e,t,n,o,r,d]);return S(()=>(i.current=!0,T(),()=>{i.current=!1}),[T]),{data:f,loading:l,error:s,refetch:T}}function _(e,...t){let n="";for(let o=0;o<e.length;o++)if(n+=e[o],o<t.length){let r=String(t[o]);if(/[{}():]/.test(r))throw new Error(`[SpecifyJS] gql: Interpolated value "${r}" contains GraphQL metacharacters ({, }, (, ), :). Use the variables parameter instead of string interpolation to prevent injection.`);n+=r}return n.replace(/\s+/g," ").trim()}function B(e){let{url:t,headers:n,credentials:o,cache:r=!1}=e,u=100,c=new Map;function f(a,s){return JSON.stringify({query:a,variables:s})}async function h(a,s){let p={"Content-Type":"application/json",...n},i=JSON.stringify({query:a,variables:s});L(t);let g=await fetch(t,{method:"POST",headers:p,credentials:o,body:i});if(!g.ok)throw new Error(`GraphQL request failed with status ${g.status}`);let d=await g.json();return{data:d.data??null,errors:d.errors??null,...d.extensions!==void 0?{extensions:d.extensions}:{}}}return{async query(a,s){if(r){let p=f(a,s),i=c.get(p);if(i)return i;let g=await h(a,s);if(c.size>=u){let d=c.keys().next().value;d!==void 0&&c.delete(d)}return c.set(p,g),g}return h(a,s)},async mutate(a,s){return h(a,s)},clearCache(){c.clear()},invalidate(a){for(let s of c.keys())try{JSON.parse(s).query===a&&c.delete(s)}catch{}}}}function K(e,t,n){let o=n?.variables,r=n?.deps,u=n?.enabled??!0,[c,f]=w(null),[h,l]=w(u),[a,s]=w(null),p=x(0),i=k(()=>{if(!u)return;let d=++p.current;l(!0),s(null),e.query(t,o).then(T=>{p.current===d&&(f(T.data),s(T.errors),l(!1))}).catch(T=>{p.current===d&&(s([{message:T instanceof Error?T.message:String(T)}]),l(!1))})},[e,t,o,u]),g=r?[i,...r]:[i];return S(()=>{i()},g),{data:c,loading:h,error:a,refetch:i}}function X(e,t){let[n,o]=w(null),[r,u]=w(!1),[c,f]=w(null),h=async a=>{u(!0),f(null);try{let s=await e.mutate(t,a);return o(s.data),f(s.errors),u(!1),s}catch(s){let p=[{message:s instanceof Error?s.message:String(s)}];return f(p),u(!1),{data:null,errors:p,extensions:void 0}}};return[k(((...a)=>h(a[0])),[e,t]),{data:n,loading:r,error:c}]}
2
+ "use strict";var G=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},re=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!te.call(e,r)&&r!==n&&G(e,r,{get:()=>t[r],enumerable:!(o=Y(t,r))||o.enumerable});return e};var oe=e=>re(G({},"__esModule",{value:!0}),e);var Re={};ne(Re,{RestError:()=>C,createGraphQLClient:()=>z,createGrpcWebClient:()=>N,createRestClient:()=>H,defineMessage:()=>$,gql:()=>j,useMutation:()=>K,useProto:()=>_,useQuery:()=>J,useRest:()=>B});module.exports=oe(Re);var ve=typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var ie={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Se={...ie};var W=null;function P(){if(W===null)throw new Error("Invalid hook call. Hooks can only be called inside the body of a function component.");return W}function T(e){return P().useState(e)}function S(e,t){return P().useEffect(e,t)}function k(e,t){return P().useCallback(e,t)}function x(e){return P().useRef(e)}var ce=/^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function le(e){let t=ce.exec(e);return t?Number(t[1])<=255&&Number(t[2])<=255&&Number(t[3])<=255:!1}function q(e){if(e.startsWith("//"))throw new Error(`[SpecifyJS] Protocol-relative URL rejected: "${e}". Use an explicit https:// prefix.`);if(e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return;if(e.startsWith("data:")){if(e.length>1024*1024)throw new Error("[SpecifyJS] secureFetch: data: URI exceeds 1MB limit");return}let t;try{t=new URL(e,typeof window<"u"?window.location.href:void 0)}catch{throw new Error(`[SpecifyJS] secureFetch: unable to validate URL "${e}". Provide a valid absolute HTTPS URL or a relative path.`)}if(t.protocol==="https:")return;let n=t.hostname.toLowerCase();if(!(n==="localhost"||n==="127.0.0.1"||n==="[::1]"||n==="0.0.0.0"||le(n)))throw n.endsWith(".localhost")?new Error(`[SpecifyJS] SSRF protection: "${e}" uses a .localhost subdomain which resolves to the loopback interface. Use exact "localhost" instead.`):new Error(`[SpecifyJS] Insecure URL rejected: "${e}". SpecifyJS enforces HTTPS-only for all network requests. Use https:// or a relative URL. Localhost URLs are allowed for development.`)}var C=class extends Error{constructor(t,n,o,r,u){super(t),this.name="RestError",this.status=n,this.statusText=o,this.data=r,this.config=u}};function pe(e){let t={};return e.forEach((n,o)=>{t[o]=n}),t}function de(e,t){let n=e.endsWith("/")?e.slice(0,-1):e,o=t.startsWith("/")?t:"/"+t;return n+o}function H(e){let{baseURL:t,headers:n={},timeout:o,interceptors:r={}}=e,u=r.request??[],c=r.response??[],d=r.error??[];async function h(l,a,s,p){let i={url:de(t,a),method:l,headers:{...n,...p?.headers??{}},body:s,signal:p?.signal,timeout:p?.timeout??o};s!=null&&!i.headers["Content-Type"]&&(i.headers["Content-Type"]="application/json");for(let w of u)i=await w(i);let g,f;if(i.timeout&&i.timeout>0&&(f=new AbortController,g=setTimeout(()=>{f.abort()},i.timeout),i.signal)){let w=i.signal;w.aborted?f.abort():w.addEventListener("abort",()=>{f.abort()})}let R=f?f.signal:i.signal,y={method:i.method,headers:i.headers,signal:R};s!=null&&(y.body=JSON.stringify(s));let m;try{q(i.url),m=await fetch(i.url,y)}catch(w){g!==void 0&&clearTimeout(g);let X=w instanceof DOMException&&w.name==="AbortError"?`Request timeout after ${i.timeout}ms`:w instanceof Error?w.message:"Network error",O=new C(X,0,"",null,i);for(let Z of d)O=await Z(O);throw O}g!==void 0&&clearTimeout(g);let E=m.headers.get("content-type")??"",b;if(E.includes("application/json"))b=await m.json();else{let w=await m.text();try{b=JSON.parse(w)}catch{b=w}}let v=pe(m.headers);if(!m.ok){let w=new C(`Request failed with status ${m.status}`,m.status,m.statusText,b,i);for(let D of d)w=await D(w);throw w}let A={data:b,status:m.status,headers:v,ok:m.ok};for(let w of c)A=w(A);return A}return{get(l,a){return h("GET",l,void 0,a)},post(l,a,s){return h("POST",l,a,s)},put(l,a,s){return h("PUT",l,a,s)},patch(l,a,s){return h("PATCH",l,a,s)},delete(l,a){return h("DELETE",l,void 0,a)}}}function B(e,t,n){let o=n?.method??"GET",r=n?.body,u=n?.deps??[],c=n?.enabled??!0,[d,h]=T(null),[l,a]=T(c),[s,p]=T(null),i=x(null),g=x(!0),f=k(()=>{if(!c){a(!1);return}i.current&&i.current.abort();let y=new AbortController;i.current=y,a(!0),p(null);let m={signal:y.signal},E,b=o.toUpperCase();b==="POST"?E=e.post(t,r,m):b==="PUT"?E=e.put(t,r,m):b==="PATCH"?E=e.patch(t,r,m):b==="DELETE"?E=e.delete(t,m):E=e.get(t,m),E.then(v=>{g.current&&!y.signal.aborted&&(h(v.data),a(!1))}).catch(v=>{g.current&&!y.signal.aborted&&(p(v instanceof C?v:new C(v instanceof Error?v.message:"Unknown error",0,"",null,{url:t,method:b,headers:{}})),a(!1))})},[e,t,o,r,c,...u]);S(()=>(g.current=!0,f(),()=>{g.current=!1,i.current&&i.current.abort()}),[f]);let R=k(()=>{f()},[f]);return{data:d,loading:l,error:s,refetch:R}}function L(e){let t=[],n=e>>>0;for(;n>127;)t.push(n&127|128),n>>>=7;return t.push(n&127),t}function U(e,t){let n=0,o=0,r=t;for(;r<e.length;){let u=e[r];if(n|=(u&127)<<o,r++,(u&128)===0)return[n>>>0,r];if(o+=7,o>=35)throw new Error("Varint too long")}throw new Error("Unexpected end of data while decoding varint")}var Q=0,I=1,M=2;function fe(e){switch(e){case"int32":case"uint32":case"bool":case"enum":return Q;case"float64":return I;case"string":case"bytes":return M}}function F(e,t){return L(e<<3|t)}function V(e,t){switch(e){case"int32":return L(t|0);case"uint32":return L(t>>>0);case"bool":return L(t?1:0);case"enum":return L(t>>>0);case"float64":{let n=new ArrayBuffer(8);return new DataView(n).setFloat64(0,t,!0),Array.from(new Uint8Array(n))}case"string":{let n=new TextEncoder().encode(t);return[...L(n.length),...n]}case"bytes":{let n=t;return[...L(n.length),...n]}}}function ge(e,t,n,o){switch(t){case Q:{let[r,u]=U(n,o);switch(e){case"bool":return[r!==0,u];case"int32":return[r|0,u];case"uint32":case"enum":return[r>>>0,u];default:return[r,u]}}case I:{if(o+8>n.length)throw new Error("Unexpected end of data while decoding 64-bit value");let r=new ArrayBuffer(8),u=new Uint8Array(r);for(let d=0;d<8;d++)u[d]=n[o+d]??0;return[new DataView(r).getFloat64(0,!0),o+8]}case M:{let[r,u]=U(n,o);if(u+r>n.length)throw new Error("Unexpected end of data while decoding length-delimited value");let c=n.slice(u,u+r);return e==="string"?[new TextDecoder().decode(c),u+r]:[c,u+r]}default:throw new Error(`Unknown wire type: ${t}`)}}function $(e,t){let n=new Map;for(let[u,c]of Object.entries(t))n.set(c.tag,{fieldName:u,descriptor:c});function o(u){let c=[],d=u;for(let[h,l]of Object.entries(t)){let a=d[h];if(a==null)continue;let s=fe(l.type);if(l.repeated){let p=a;for(let i of p)c.push(...F(l.tag,s)),c.push(...V(l.type,i))}else c.push(...F(l.tag,s)),c.push(...V(l.type,a))}return new Uint8Array(c)}function r(u){let c={};for(let[h,l]of Object.entries(t))l.repeated&&(c[h]=[]);let d=0;for(;d<u.length;){let[h,l]=U(u,d),a=h>>>3,s=h&7;d=l;let p=n.get(a);if(!p){d=he(s,u,d);continue}let[i,g]=ge(p.descriptor.type,s,u,d);d=g,p.descriptor.repeated?c[p.fieldName].push(i):c[p.fieldName]=i}return c}return{name:e,fields:t,encode:o,decode:r}}function he(e,t,n){switch(e){case Q:{let[,o]=U(t,n);return o}case I:return n+8;case M:{let[o,r]=U(t,n);return r+o}default:throw new Error(`Cannot skip unknown wire type: ${e}`)}}function me(e,t=0){let n=new Uint8Array(5+e.length);return n[0]=t,new DataView(n.buffer,n.byteOffset,n.byteLength).setUint32(1,e.length,!1),n.set(e,5),n}function we(e){if(e.length<5)throw new Error("gRPC-Web frame too short");let t=e[0]??0,o=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(1,!1);if(e.length<5+o)throw new Error("gRPC-Web frame data incomplete");let r=e.slice(5,5+o);return[t,r,5+o]}function N(e){let{baseURL:t,headers:n}=e;async function o(r,u,c,d,h){let l=c.encode(h),a=me(l),s=`${t.replace(/\/+$/,"")}/${r}/${u}`,p={"Content-Type":"application/grpc-web+proto",Accept:"application/grpc-web+proto","X-Grpc-Web":"1",...n};q(s);let i=await fetch(s,{method:"POST",headers:p,body:a.buffer});if(!i.ok)throw new Error(`gRPC-Web request failed: ${i.status} ${i.statusText}`);let g=new Uint8Array(await i.arrayBuffer()),f=0;for(;f<g.length;){let[R,y,m]=we(g.subarray(f));if(f+=m,(R&128)===0)return d.decode(y)}throw new Error("No data frame found in gRPC-Web response")}return{unary:o}}function _(e,t,n,o,r,u,c){let[d,h]=T(null),[l,a]=T(!1),[s,p]=T(null),i=x(!0),g=x(u);g.current=u;let f=c?.enabled!==!1,R=k(()=>{f&&(a(!0),p(null),e.unary(t,n,o,r,g.current).then(y=>{i.current&&(h(y),a(!1))}).catch(y=>{i.current&&(p(y instanceof Error?y:new Error(String(y))),a(!1))}))},[e,t,n,o,r,f]);return S(()=>(i.current=!0,R(),()=>{i.current=!1}),[R]),{data:d,loading:l,error:s,refetch:R}}function j(e,...t){let n="";for(let o=0;o<e.length;o++)if(n+=e[o],o<t.length){let r=String(t[o]);if(/[{}():]/.test(r))throw new Error(`[SpecifyJS] gql: Interpolated value "${r}" contains GraphQL metacharacters ({, }, (, ), :). Use the variables parameter instead of string interpolation to prevent injection.`);n+=r}return n.replace(/\s+/g," ").trim()}function z(e){let{url:t,headers:n,credentials:o,cache:r=!1}=e,u=100,c=new Map;function d(a,s){return JSON.stringify({query:a,variables:s})}async function h(a,s){let p={"Content-Type":"application/json",...n},i=JSON.stringify({query:a,variables:s});q(t);let g=await fetch(t,{method:"POST",headers:p,credentials:o,body:i});if(!g.ok)throw new Error(`GraphQL request failed with status ${g.status}`);let f=await g.json();return{data:f.data??null,errors:f.errors??null,...f.extensions!==void 0?{extensions:f.extensions}:{}}}return{async query(a,s){if(r){let p=d(a,s),i=c.get(p);if(i)return i;let g=await h(a,s);if(c.size>=u){let f=c.keys().next().value;f!==void 0&&c.delete(f)}return c.set(p,g),g}return h(a,s)},async mutate(a,s){return h(a,s)},clearCache(){c.clear()},invalidate(a){for(let s of c.keys())try{JSON.parse(s).query===a&&c.delete(s)}catch{}}}}function J(e,t,n){let o=n?.variables,r=n?.deps,u=n?.enabled??!0,[c,d]=T(null),[h,l]=T(u),[a,s]=T(null),p=x(0),i=k(()=>{if(!u)return;let f=++p.current;l(!0),s(null),e.query(t,o).then(R=>{p.current===f&&(d(R.data),s(R.errors),l(!1))}).catch(R=>{p.current===f&&(s([{message:R instanceof Error?R.message:String(R)}]),l(!1))})},[e,t,o,u]),g=r?[i,...r]:[i];return S(()=>{i()},g),{data:c,loading:h,error:a,refetch:i}}function K(e,t){let[n,o]=T(null),[r,u]=T(!1),[c,d]=T(null),h=async a=>{u(!0),d(null);try{let s=await e.mutate(t,a);return o(s.data),d(s.errors),u(!1),s}catch(s){let p=[{message:s instanceof Error?s.message:String(s)}];return d(p),u(!1),{data:null,errors:p,extensions:void 0}}};return[k(((...a)=>h(a[0])),[e,t]),{data:n,loading:r,error:c}]}
@@ -7,7 +7,7 @@ import {
7
7
  useEffect,
8
8
  useRef,
9
9
  useState
10
- } from "./esm/chunks/chunk-4V37N6QN.js";
10
+ } from "./esm/chunks/chunk-AQX42M4L.js";
11
11
  import "./esm/chunks/chunk-FDNBPWUH.js";
12
12
 
13
13
  // src/client/rest.ts