@hexclave/shared 1.0.1 → 1.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","names":[],"sources":["../../../src/utils/react.tsx"],"mappings":";;;iBAOgB,gBAAA,WACJ,KAAA,CAAM,aAAA,cAA2B,KAAA,CAAM,GAAA,CAAI,iBAAA,6BAAA,CAErD,WAAA,UAAqB,MAAA,EAAQ,KAAA,CAAM,wBAAA,CAAyB,gBAAA,CAAiB,CAAA,GAAI,KAAA,CAAM,qBAAA,CAAsB,CAAA,IAAK,UAAA,IAAW,KAAA,CAAA,EAAA,CAAA,KAAA,CAAA,qBAAA,CAAA,CAAA,IAAA,UAAA;;;KAK1H,gBAAA,WAA2B,KAAA,CAAM,aAAA,cAA2B,KAAA,CAAM,GAAA,CAAI,iBAAA,IAAqB,WAAA,CAAY,wBAAA,CAAyB,KAAA,CAAM,qBAAA,CAAsB,CAAA;AAAA,KAC5J,wBAAA,MAA8B,CAAA,SAAU,KAAA,CAAM,SAAA,YAAqB,CAAA;AAAA,iBAGxD,GAAA,GAAA,CAAO,OAAA,EAAS,OAAA,CAAQ,CAAA,IAAK,CAAA;AAAA,iBA4B7B,kBAAA,WAAA,CAA8B,MAAA,EAAQ,KAAA,CAAM,wBAAA,CAAyB,CAAA,EAAG,CAAA,IAAK,KAAA,CAAM,EAAA,CAAG,CAAA;EAAM,GAAA,GAAM,KAAA,CAAM,GAAA,CAAI,CAAA;AAAA;AAAA,iBAY5G,WAAA,CAAY,IAAA,EAAM,KAAA,CAAM,SAAA;;;;;;iBAkExB,OAAA,CAAA;AAAA,iBAKA,MAAA,MAAA,CAAa,GAAA,EAAK,WAAA,CAAY,CAAA,GAAI,MAAA,GAAS,KAAA,EAAO,CAAA,KAAM,CAAA,GAAI,WAAA,CAAY,CAAA;AAAA,KAa5E,WAAA;EAAA,SACD,OAAA,EAAS,CAAA;AAAA;AAAA,K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50
50
  if (!node) return "";
51
51
  if (Array.isArray(node)) return node.map(getNodeText).join("");
52
- if (typeof node === "object" && "props" in node) return getNodeText(node.props.children);
52
+ if (React.isValidElement(node)) return getNodeText(node.props.children);
53
53
  throw new Error(`Unknown node type: ${typeof node}`);
54
54
  }
55
55
  (void 0)?.test("getNodeText", ({ expect }) => {
@@ -72,9 +72,9 @@ function getNodeText(node) {
72
72
  42,
73
73
  null
74
74
  ])).toBe("hello42");
75
- expect(getNodeText({ props: { children: "child text" } })).toBe("child text");
76
- expect(getNodeText({ props: { children: { props: { children: "nested text" } } } })).toBe("nested text");
77
- expect(getNodeText([{ props: { children: "first" } }, { props: { children: "second" } }])).toBe("firstsecond");
75
+ expect(getNodeText(React.createElement("span", null, "child text"))).toBe("child text");
76
+ expect(getNodeText(React.createElement("div", null, React.createElement("span", null, "nested text")))).toBe("nested text");
77
+ expect(getNodeText([React.createElement("span", null, "first"), React.createElement("span", null, "second")])).toBe("firstsecond");
78
78
  });
79
79
  /**
80
80
  * Suspends the currently rendered component indefinitely. Will not unsuspend unless the component rerenders.
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","names":[],"sources":["../../../src/utils/react.tsx"],"sourcesContent":["import React, { SetStateAction } from \"react\";\nimport { isBrowserLike } from \"./env\";\nimport { neverResolve, runAsynchronously } from \"./promises\";\nimport { AsyncResult } from \"./results\";\nimport { ensureMonkeyPatch, NO_SUSPENSE_BOUNDARY_ERROR_SENTINEL } from \"./monkey-patch\";\nimport { deindent } from \"./strings\";\n\nexport function componentWrapper<\n C extends React.ComponentType<any> | keyof React.JSX.IntrinsicElements,\n ExtraProps extends {} = {}\n>(displayName: string, render: React.ForwardRefRenderFunction<RefFromComponent<C>, React.ComponentPropsWithRef<C> & ExtraProps>) {\n const Component = forwardRefIfNeeded(render);\n Component.displayName = displayName;\n return Component;\n}\ntype RefFromComponent<C extends React.ComponentType<any> | keyof React.JSX.IntrinsicElements> = NonNullable<RefFromComponentDistCond<React.ComponentPropsWithRef<C>[\"ref\"]>>;\ntype RefFromComponentDistCond<A> = A extends React.RefObject<infer T> ? T : never; // distributive conditional type; see https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n\nconst react18PromiseCache = new WeakMap<Promise<unknown>, AsyncResult<unknown, unknown>>();\nexport function use<T>(promise: Promise<T>): T {\n if (\"use\" in React) {\n return React.use(promise);\n } else {\n if (react18PromiseCache.has(promise)) {\n const result = react18PromiseCache.get(promise)!;\n if (result.status === \"pending\") {\n throw promise;\n } else if (result.status === \"ok\") {\n return result.data as T;\n } else {\n throw result.error;\n }\n } else {\n react18PromiseCache.set(promise, { \"status\": \"pending\", progress: undefined });\n runAsynchronously(async () => {\n try {\n const res = await promise;\n react18PromiseCache.set(promise, { \"status\": \"ok\", data: res });\n } catch (e) {\n react18PromiseCache.set(promise, { \"status\": \"error\", error: e });\n }\n });\n throw promise;\n }\n }\n}\n\nexport function forwardRefIfNeeded<T, P = {}>(render: React.ForwardRefRenderFunction<T, P>): React.FC<P & { ref?: React.Ref<T> }> {\n // TODO: when we drop support for react 18, remove this\n\n const version = React.version;\n const major = parseInt(version.split(\".\")[0]);\n if (major < 19) {\n return React.forwardRef<T, P>(render as any) as any;\n } else {\n return ((props: P) => render(props, (props as any).ref)) as any;\n }\n}\n\nexport function getNodeText(node: React.ReactNode): string {\n if ([\"number\", \"string\"].includes(typeof node)) {\n return `${node}`;\n }\n if (!node) {\n return \"\";\n }\n if (Array.isArray(node)) {\n return node.map(getNodeText).join(\"\");\n }\n if (typeof node === \"object\" && \"props\" in node) {\n return getNodeText(node.props.children);\n }\n throw new Error(`Unknown node type: ${typeof node}`);\n}\nimport.meta.vitest?.test(\"getNodeText\", ({ expect }) => {\n // Test with string\n expect(getNodeText(\"hello\")).toBe(\"hello\");\n\n // Test with number\n expect(getNodeText(42)).toBe(\"42\");\n\n // Test with null/undefined\n expect(getNodeText(null)).toBe(\"\");\n expect(getNodeText(undefined)).toBe(\"\");\n\n // Test with array\n expect(getNodeText([\"hello\", \" \", \"world\"])).toBe(\"hello world\");\n expect(getNodeText([1, 2, 3])).toBe(\"123\");\n\n // Test with mixed array\n expect(getNodeText([\"hello\", 42, null])).toBe(\"hello42\");\n\n // Test with React element (mocked)\n const mockElement = {\n props: {\n children: \"child text\"\n }\n } as React.ReactElement;\n expect(getNodeText(mockElement)).toBe(\"child text\");\n\n // Test with nested React elements\n const nestedElement = {\n props: {\n children: {\n props: {\n children: \"nested text\"\n }\n } as React.ReactElement\n }\n } as React.ReactElement;\n expect(getNodeText(nestedElement)).toBe(\"nested text\");\n\n // Test with array of React elements\n const arrayOfElements = [\n { props: { children: \"first\" } } as React.ReactElement,\n { props: { children: \"second\" } } as React.ReactElement\n ];\n expect(getNodeText(arrayOfElements)).toBe(\"firstsecond\");\n});\n\n/**\n * Suspends the currently rendered component indefinitely. Will not unsuspend unless the component rerenders.\n *\n * You can use this to translate older query- or AsyncResult-based code to new the Suspense system, for example: `if (query.isLoading) suspend();`\n */\nexport function suspend(): never {\n use(neverResolve());\n throw new Error(\"Somehow a Promise that never resolves was resolved?\");\n}\n\nexport function mapRef<T, R>(ref: ReadonlyRef<T>, mapper: (value: T) => R): ReadonlyRef<R> {\n let last: [T, R] | null = null;\n return {\n get current() {\n const input = ref.current;\n if (last === null || input !== last[0]) {\n last = [input, mapper(input)];\n }\n return last[1];\n },\n };\n}\n\nexport type ReadonlyRef<T> = {\n readonly current: T,\n};\n\nexport type RefState<T> = ReadonlyRef<T> & {\n set: (updater: SetStateAction<T>) => void,\n};\n\n/**\n * Like useState, but its value is immediately available on refState.current after being set.\n *\n * Like useRef, but setting the value will cause a rerender.\n *\n * Note that useRefState returns a new object every time a rerender happens due to a value change, which is intentional\n * as it allows you to specify it in a dependency array like this:\n *\n * ```tsx\n * useEffect(() => {\n * // do something with refState.current\n * }, [refState]); // instead of refState.current\n * ```\n *\n * If you don't want this, you can wrap the result in a useMemo call.\n */\nexport function useRefState<T>(initialValue: T | (() => T)): RefState<T> {\n // Support lazy initialization like React.useState does: if initialValue is a function,\n // call it once to get the actual initial value (React.useRef does NOT do this automatically).\n const lazyInitRef = React.useRef<{ v: T } | null>(null);\n if (lazyInitRef.current === null) {\n lazyInitRef.current = {\n v: typeof initialValue === \"function\" ? (initialValue as () => T)() : initialValue,\n };\n }\n const resolvedInitialValue = lazyInitRef.current.v;\n const [, setState] = React.useState<T>(() => resolvedInitialValue);\n const ref = React.useRef(resolvedInitialValue);\n const setValue = React.useCallback((updater: SetStateAction<T>) => {\n const value: T = typeof updater === \"function\" ? (updater as any)(ref.current) : updater;\n ref.current = value;\n setState(value);\n }, []);\n const res = React.useMemo(() => ({\n get current() {\n return ref.current;\n },\n set: setValue,\n }), [setValue]);\n return res;\n}\n\nexport function mapRefState<T, R>(refState: RefState<T>, mapper: (value: T) => R, reverseMapper: (oldT: T, newR: R) => T): RefState<R> {\n let last: [T, R] | null = null;\n return {\n get current() {\n const input = refState.current;\n if (last === null || input !== last[0]) {\n last = [input, mapper(input)];\n }\n return last[1];\n },\n set(updater: SetStateAction<R>) {\n const value: R = typeof updater === \"function\" ? (updater as any)(this.current) : updater;\n refState.set(reverseMapper(refState.current, value));\n },\n };\n}\n\nexport function useQueryState(key: string, defaultValue?: string) {\n const getValue = () => new URLSearchParams(window.location.search).get(key) ?? defaultValue ?? null;\n\n const [value, setValue] = React.useState(getValue);\n\n React.useEffect(() => {\n const onPopState = () => setValue(getValue());\n window.addEventListener(\"popstate\", onPopState);\n return () => window.removeEventListener(\"popstate\", onPopState);\n }, []);\n\n const update = (next: string | null) => {\n const params = new URLSearchParams(window.location.search);\n if (next !== null) {\n params.set(key, next);\n } else {\n params.delete(key);\n }\n const newUrl = params.toString()\n ? `${window.location.pathname}?${params.toString()}`\n : window.location.pathname;\n window.history.pushState(null, \"\", newUrl);\n setValue(next);\n };\n\n return [value, update] as const;\n}\n\nexport function shouldRethrowRenderingError(error: unknown): boolean {\n return !!error && typeof error === \"object\" && \"digest\" in error && error.digest === \"BAILOUT_TO_CLIENT_SIDE_RENDERING\";\n}\n\nexport class NoSuspenseBoundaryError extends Error {\n digest: string;\n reason: string;\n __noSuspenseBoundarySentinel = NO_SUSPENSE_BOUNDARY_ERROR_SENTINEL;\n\n constructor(options: { caller?: string }) {\n ensureMonkeyPatch();\n\n super(deindent`\n Suspense boundary not found! Read the error message below carefully (or paste it into your AI agent).\n\n ${options.caller ?? \"This code path\"} attempted to display a loading indicator, but didn't find a Suspense boundary above it. Please read the error message below carefully.\n \n There are several potential causes:\n \n 1. [Next.js] You are missing a loading.tsx file in your app directory. Fix it by adding a loading.tsx file in your app directory.\n\n 2. [React] You are missing a <Suspense> boundary in your component. Fix it by wrapping your component (or the entire app) in a <Suspense> component.\n\n 3. [Next.js] The component is rendered in the root (outermost) layout.tsx or template.tsx file. Next.js does not wrap those files in a Suspense boundary, even if there is a loading.tsx file in the same folder. To fix it, wrap your layout inside a route group like this:\n\n - app\n - - layout.tsx // contains <html> and <body>, alongside providers and other components that don't need ${options.caller ?? \"this code path\"}\n - - loading.tsx // required for suspense\n - - (main)\n - - - layout.tsx // contains the main layout of your app, like a sidebar or a header, and can use ${options.caller ?? \"this code path\"}\n - - - route.tsx // your actual main page\n - - - the rest of your app\n\n For more information on this approach, see Next's documentation on route groups: https://nextjs.org/docs/app/building-your-application/routing/route-groups\n \n 4. You caught this error with try-catch or a custom error boundary. Fix this by rethrowing the error or not catching it in the first place.\n\n 5. Your version of Hexclave is too old. Upgrade to the latest version to see if that fixes the issue.\n\n See: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\n\n More information on SSR and Suspense boundaries: https://react.dev/reference/react/Suspense#providing-a-fallback-for-server-errors-and-client-only-content\n `);\n\n this.name = \"NoSuspenseBoundaryError\";\n this.reason = options.caller ?? \"suspendIfSsr()\";\n\n // set the digest so nextjs doesn't log the error\n // https://github.com/vercel/next.js/blob/d01d6d9c35a8c2725b3d74c1402ab76d4779a6cf/packages/next/src/shared/lib/lazy-dynamic/bailout-to-csr.ts#L14\n this.digest = \"BAILOUT_TO_CLIENT_SIDE_RENDERING\";\n }\n}\nimport.meta.vitest?.test(\"NoSuspenseBoundaryError\", ({ expect }) => {\n // Test with default options\n const defaultError = new NoSuspenseBoundaryError({});\n expect(defaultError.name).toBe(\"NoSuspenseBoundaryError\");\n expect(defaultError.reason).toBe(\"suspendIfSsr()\");\n expect(defaultError.digest).toBe(\"BAILOUT_TO_CLIENT_SIDE_RENDERING\");\n expect(defaultError.message).toContain(\"This code path attempted to display a loading indicator\");\n\n // Test with custom caller\n const customError = new NoSuspenseBoundaryError({ caller: \"CustomComponent\" });\n expect(customError.name).toBe(\"NoSuspenseBoundaryError\");\n expect(customError.reason).toBe(\"CustomComponent\");\n expect(customError.digest).toBe(\"BAILOUT_TO_CLIENT_SIDE_RENDERING\");\n expect(customError.message).toContain(\"CustomComponent attempted to display a loading indicator\");\n\n // Verify error message contains all the necessary information\n expect(customError.message).toContain(\"loading.tsx\");\n expect(customError.message).toContain(\"route groups\");\n expect(customError.message).toContain(\"https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\");\n});\n\n\n/**\n * Use this in a component or a hook to disable SSR. Should be wrapped in a Suspense boundary, or it will throw an error.\n */\nexport function suspendIfSsr(caller?: string) {\n if (!isBrowserLike()) {\n throw new NoSuspenseBoundaryError({ caller });\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,iBAGd,aAAqB,QAA0G;CAC/H,MAAM,YAAY,mBAAmB,OAAO;AAC5C,WAAU,cAAc;AACxB,QAAO;;MAKH,sCAAsB,IAAI,SAA0D;AAC1F,SAAgB,IAAO,SAAwB;AAC7C,KAAI,SAAS,MACX,QAAO,MAAM,IAAI,QAAQ;UAErB,oBAAoB,IAAI,QAAQ,EAAE;EACpC,MAAM,SAAS,oBAAoB,IAAI,QAAQ;AAC/C,MAAI,OAAO,WAAW,UACpB,OAAM;WACG,OAAO,WAAW,KAC3B,QAAO,OAAO;MAEd,OAAM,OAAO;QAEV;AACL,sBAAoB,IAAI,SAA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UAAU,iBAAgB;;;6GAGvC,QAAQ,UAAU,iBAAgB;;;;;;;;;;;;;MAazI;sCAnC2B;AAqC7B,OAAK,OAAO;AACZ,OAAK,SAAS,QAAQ,UAAU;AAIhC,OAAK,SAAS;;;CAGlB,SAAW,KAAC,4BAAc,EAAA,aAA6B;CAErD,MAAM,eAAe,IAAI,wBAAwB,EAAE,CAAC;AACpD,QAAO,aAAa,KAAK,CAAC,KAAK,0BAA0B;AACzD,QAAO,aAAa,OAAO,CAAC,KAAK,iBAAiB;AAClD,QAAO,aAAa,OAAO,CAAC,KAAK,mCAAmC;AACpE,QAAO,aAAa,QAAQ,CAAC,UAAU,0DAA0D;CAGjG,MAAM,cAAc,IAAI,wBAAwB,EAAE,QAAQ,mBAAmB,CAAC;AAC9E,QAAO,YAAY,KAAK,CAAC,KAAK,0BAA0B;AACxD,QAAO,YAAY,OAAO,CAAC,KAAK,kBAAkB;AAClD,QAAO,YAAY,OAAO,CAAC,KAAK,mCAAmC;AACnE,QAAO,YAAY,QAAQ,CAAC,UAAU,2DAA2D;AAGjG,QAAO,YAAY,QAAQ,CAAC,UAAU,cAAc;AACpD,QAAO,YAAY,QAAQ,CAAC,UAAU,eAAe;AACrD,QAAO,YAAY,QAAQ,CAAC,UAAU,qEAAqE;EAC3G;;;;AAMF,SAAgB,aAAa,QAAiB;AAC5C,KAAI,CAAC,eAAe,CAClB,OAAM,IAAI,wBAAwB,EAAE,QAAQ,CAAC"}
1
+ {"version":3,"file":"react.js","names":[],"sources":["../../../src/utils/react.tsx"],"sourcesContent":["import React, { SetStateAction } from \"react\";\nimport { isBrowserLike } from \"./env\";\nimport { neverResolve, runAsynchronously } from \"./promises\";\nimport { AsyncResult } from \"./results\";\nimport { ensureMonkeyPatch, NO_SUSPENSE_BOUNDARY_ERROR_SENTINEL } from \"./monkey-patch\";\nimport { deindent } from \"./strings\";\n\nexport function componentWrapper<\n C extends React.ComponentType<any> | keyof React.JSX.IntrinsicElements,\n ExtraProps extends {} = {}\n>(displayName: string, render: React.ForwardRefRenderFunction<RefFromComponent<C>, React.ComponentPropsWithRef<C> & ExtraProps>) {\n const Component = forwardRefIfNeeded(render);\n Component.displayName = displayName;\n return Component;\n}\ntype RefFromComponent<C extends React.ComponentType<any> | keyof React.JSX.IntrinsicElements> = NonNullable<RefFromComponentDistCond<React.ComponentPropsWithRef<C>[\"ref\"]>>;\ntype RefFromComponentDistCond<A> = A extends React.RefObject<infer T> ? T : never; // distributive conditional type; see https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n\nconst react18PromiseCache = new WeakMap<Promise<unknown>, AsyncResult<unknown, unknown>>();\nexport function use<T>(promise: Promise<T>): T {\n if (\"use\" in React) {\n return React.use(promise);\n } else {\n if (react18PromiseCache.has(promise)) {\n const result = react18PromiseCache.get(promise)!;\n if (result.status === \"pending\") {\n throw promise;\n } else if (result.status === \"ok\") {\n return result.data as T;\n } else {\n throw result.error;\n }\n } else {\n react18PromiseCache.set(promise, { \"status\": \"pending\", progress: undefined });\n runAsynchronously(async () => {\n try {\n const res = await promise;\n react18PromiseCache.set(promise, { \"status\": \"ok\", data: res });\n } catch (e) {\n react18PromiseCache.set(promise, { \"status\": \"error\", error: e });\n }\n });\n throw promise;\n }\n }\n}\n\nexport function forwardRefIfNeeded<T, P = {}>(render: React.ForwardRefRenderFunction<T, P>): React.FC<P & { ref?: React.Ref<T> }> {\n // TODO: when we drop support for react 18, remove this\n\n const version = React.version;\n const major = parseInt(version.split(\".\")[0]);\n if (major < 19) {\n return React.forwardRef<T, P>(render as any) as any;\n } else {\n return ((props: P) => render(props, (props as any).ref)) as any;\n }\n}\n\nexport function getNodeText(node: React.ReactNode): string {\n if ([\"number\", \"string\"].includes(typeof node)) {\n return `${node}`;\n }\n if (!node) {\n return \"\";\n }\n if (Array.isArray(node)) {\n return node.map(getNodeText).join(\"\");\n }\n if (React.isValidElement<{ children?: React.ReactNode }>(node)) {\n return getNodeText(node.props.children);\n }\n throw new Error(`Unknown node type: ${typeof node}`);\n}\nimport.meta.vitest?.test(\"getNodeText\", ({ expect }) => {\n // Test with string\n expect(getNodeText(\"hello\")).toBe(\"hello\");\n\n // Test with number\n expect(getNodeText(42)).toBe(\"42\");\n\n // Test with null/undefined\n expect(getNodeText(null)).toBe(\"\");\n expect(getNodeText(undefined)).toBe(\"\");\n\n // Test with array\n expect(getNodeText([\"hello\", \" \", \"world\"])).toBe(\"hello world\");\n expect(getNodeText([1, 2, 3])).toBe(\"123\");\n\n // Test with mixed array\n expect(getNodeText([\"hello\", 42, null])).toBe(\"hello42\");\n\n // Test with React element\n const mockElement = React.createElement(\"span\", null, \"child text\");\n expect(getNodeText(mockElement)).toBe(\"child text\");\n\n // Test with nested React elements\n const nestedElement = React.createElement(\"div\", null, React.createElement(\"span\", null, \"nested text\"));\n expect(getNodeText(nestedElement)).toBe(\"nested text\");\n\n // Test with array of React elements\n const arrayOfElements = [\n React.createElement(\"span\", null, \"first\"),\n React.createElement(\"span\", null, \"second\"),\n ];\n expect(getNodeText(arrayOfElements)).toBe(\"firstsecond\");\n});\n\n/**\n * Suspends the currently rendered component indefinitely. Will not unsuspend unless the component rerenders.\n *\n * You can use this to translate older query- or AsyncResult-based code to new the Suspense system, for example: `if (query.isLoading) suspend();`\n */\nexport function suspend(): never {\n use(neverResolve());\n throw new Error(\"Somehow a Promise that never resolves was resolved?\");\n}\n\nexport function mapRef<T, R>(ref: ReadonlyRef<T>, mapper: (value: T) => R): ReadonlyRef<R> {\n let last: [T, R] | null = null;\n return {\n get current() {\n const input = ref.current;\n if (last === null || input !== last[0]) {\n last = [input, mapper(input)];\n }\n return last[1];\n },\n };\n}\n\nexport type ReadonlyRef<T> = {\n readonly current: T,\n};\n\nexport type RefState<T> = ReadonlyRef<T> & {\n set: (updater: SetStateAction<T>) => void,\n};\n\n/**\n * Like useState, but its value is immediately available on refState.current after being set.\n *\n * Like useRef, but setting the value will cause a rerender.\n *\n * Note that useRefState returns a new object every time a rerender happens due to a value change, which is intentional\n * as it allows you to specify it in a dependency array like this:\n *\n * ```tsx\n * useEffect(() => {\n * // do something with refState.current\n * }, [refState]); // instead of refState.current\n * ```\n *\n * If you don't want this, you can wrap the result in a useMemo call.\n */\nexport function useRefState<T>(initialValue: T | (() => T)): RefState<T> {\n // Support lazy initialization like React.useState does: if initialValue is a function,\n // call it once to get the actual initial value (React.useRef does NOT do this automatically).\n const lazyInitRef = React.useRef<{ v: T } | null>(null);\n if (lazyInitRef.current === null) {\n lazyInitRef.current = {\n v: typeof initialValue === \"function\" ? (initialValue as () => T)() : initialValue,\n };\n }\n const resolvedInitialValue = lazyInitRef.current.v;\n const [, setState] = React.useState<T>(() => resolvedInitialValue);\n const ref = React.useRef(resolvedInitialValue);\n const setValue = React.useCallback((updater: SetStateAction<T>) => {\n const value: T = typeof updater === \"function\" ? (updater as any)(ref.current) : updater;\n ref.current = value;\n setState(value);\n }, []);\n const res = React.useMemo(() => ({\n get current() {\n return ref.current;\n },\n set: setValue,\n }), [setValue]);\n return res;\n}\n\nexport function mapRefState<T, R>(refState: RefState<T>, mapper: (value: T) => R, reverseMapper: (oldT: T, newR: R) => T): RefState<R> {\n let last: [T, R] | null = null;\n return {\n get current() {\n const input = refState.current;\n if (last === null || input !== last[0]) {\n last = [input, mapper(input)];\n }\n return last[1];\n },\n set(updater: SetStateAction<R>) {\n const value: R = typeof updater === \"function\" ? (updater as any)(this.current) : updater;\n refState.set(reverseMapper(refState.current, value));\n },\n };\n}\n\nexport function useQueryState(key: string, defaultValue?: string) {\n const getValue = () => new URLSearchParams(window.location.search).get(key) ?? defaultValue ?? null;\n\n const [value, setValue] = React.useState(getValue);\n\n React.useEffect(() => {\n const onPopState = () => setValue(getValue());\n window.addEventListener(\"popstate\", onPopState);\n return () => window.removeEventListener(\"popstate\", onPopState);\n }, []);\n\n const update = (next: string | null) => {\n const params = new URLSearchParams(window.location.search);\n if (next !== null) {\n params.set(key, next);\n } else {\n params.delete(key);\n }\n const newUrl = params.toString()\n ? `${window.location.pathname}?${params.toString()}`\n : window.location.pathname;\n window.history.pushState(null, \"\", newUrl);\n setValue(next);\n };\n\n return [value, update] as const;\n}\n\nexport function shouldRethrowRenderingError(error: unknown): boolean {\n return !!error && typeof error === \"object\" && \"digest\" in error && error.digest === \"BAILOUT_TO_CLIENT_SIDE_RENDERING\";\n}\n\nexport class NoSuspenseBoundaryError extends Error {\n digest: string;\n reason: string;\n __noSuspenseBoundarySentinel = NO_SUSPENSE_BOUNDARY_ERROR_SENTINEL;\n\n constructor(options: { caller?: string }) {\n ensureMonkeyPatch();\n\n super(deindent`\n Suspense boundary not found! Read the error message below carefully (or paste it into your AI agent).\n\n ${options.caller ?? \"This code path\"} attempted to display a loading indicator, but didn't find a Suspense boundary above it. Please read the error message below carefully.\n \n There are several potential causes:\n \n 1. [Next.js] You are missing a loading.tsx file in your app directory. Fix it by adding a loading.tsx file in your app directory.\n\n 2. [React] You are missing a <Suspense> boundary in your component. Fix it by wrapping your component (or the entire app) in a <Suspense> component.\n\n 3. [Next.js] The component is rendered in the root (outermost) layout.tsx or template.tsx file. Next.js does not wrap those files in a Suspense boundary, even if there is a loading.tsx file in the same folder. To fix it, wrap your layout inside a route group like this:\n\n - app\n - - layout.tsx // contains <html> and <body>, alongside providers and other components that don't need ${options.caller ?? \"this code path\"}\n - - loading.tsx // required for suspense\n - - (main)\n - - - layout.tsx // contains the main layout of your app, like a sidebar or a header, and can use ${options.caller ?? \"this code path\"}\n - - - route.tsx // your actual main page\n - - - the rest of your app\n\n For more information on this approach, see Next's documentation on route groups: https://nextjs.org/docs/app/building-your-application/routing/route-groups\n \n 4. You caught this error with try-catch or a custom error boundary. Fix this by rethrowing the error or not catching it in the first place.\n\n 5. Your version of Hexclave is too old. Upgrade to the latest version to see if that fixes the issue.\n\n See: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\n\n More information on SSR and Suspense boundaries: https://react.dev/reference/react/Suspense#providing-a-fallback-for-server-errors-and-client-only-content\n `);\n\n this.name = \"NoSuspenseBoundaryError\";\n this.reason = options.caller ?? \"suspendIfSsr()\";\n\n // set the digest so nextjs doesn't log the error\n // https://github.com/vercel/next.js/blob/d01d6d9c35a8c2725b3d74c1402ab76d4779a6cf/packages/next/src/shared/lib/lazy-dynamic/bailout-to-csr.ts#L14\n this.digest = \"BAILOUT_TO_CLIENT_SIDE_RENDERING\";\n }\n}\nimport.meta.vitest?.test(\"NoSuspenseBoundaryError\", ({ expect }) => {\n // Test with default options\n const defaultError = new NoSuspenseBoundaryError({});\n expect(defaultError.name).toBe(\"NoSuspenseBoundaryError\");\n expect(defaultError.reason).toBe(\"suspendIfSsr()\");\n expect(defaultError.digest).toBe(\"BAILOUT_TO_CLIENT_SIDE_RENDERING\");\n expect(defaultError.message).toContain(\"This code path attempted to display a loading indicator\");\n\n // Test with custom caller\n const customError = new NoSuspenseBoundaryError({ caller: \"CustomComponent\" });\n expect(customError.name).toBe(\"NoSuspenseBoundaryError\");\n expect(customError.reason).toBe(\"CustomComponent\");\n expect(customError.digest).toBe(\"BAILOUT_TO_CLIENT_SIDE_RENDERING\");\n expect(customError.message).toContain(\"CustomComponent attempted to display a loading indicator\");\n\n // Verify error message contains all the necessary information\n expect(customError.message).toContain(\"loading.tsx\");\n expect(customError.message).toContain(\"route groups\");\n expect(customError.message).toContain(\"https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\");\n});\n\n\n/**\n * Use this in a component or a hook to disable SSR. Should be wrapped in a Suspense boundary, or it will throw an error.\n */\nexport function suspendIfSsr(caller?: string) {\n if (!isBrowserLike()) {\n throw new NoSuspenseBoundaryError({ caller });\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,iBAGd,aAAqB,QAA0G;CAC/H,MAAM,YAAY,mBAAmB,OAAO;AAC5C,WAAU,cAAc;AACxB,QAAO;;MAKH,sCAAsB,IAAI,SAA0D;AAC1F,SAAgB,IAAO,SAAwB;AAC7C,KAAI,SAAS,MACX,QAAO,MAAM,IAAI,QAAQ;UAErB,oBAAoB,IAAI,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,WAAW;;AAGvF,IAAa,0BAAb,cAA6C,MAAM;CAKjD,YAAY,SAA8B;AACxC,qBAAmB;AAEnB,QAAM,QAAQ;;;QAGV,QAAQ,UAAU,iBAAiB;;;;;;;;;;;kHAWuE,QAAQ,UAAU,iBAAgB;;;6GAGvC,QAAQ,UAAU,iBAAgB;;;;;;;;;;;;;MAazI;sCAnC2B;AAqC7B,OAAK,OAAO;AACZ,OAAK,SAAS,QAAQ,UAAU;AAIhC,OAAK,SAAS;;;CAGlB,SAAW,KAAC,4BAAc,EAAA,aAA6B;CAErD,MAAM,eAAe,IAAI,wBAAwB,EAAE,CAAC;AACpD,QAAO,aAAa,KAAK,CAAC,KAAK,0BAA0B;AACzD,QAAO,aAAa,OAAO,CAAC,KAAK,iBAAiB;AAClD,QAAO,aAAa,OAAO,CAAC,KAAK,mCAAmC;AACpE,QAAO,aAAa,QAAQ,CAAC,UAAU,0DAA0D;CAGjG,MAAM,cAAc,IAAI,wBAAwB,EAAE,QAAQ,mBAAmB,CAAC;AAC9E,QAAO,YAAY,KAAK,CAAC,KAAK,0BAA0B;AACxD,QAAO,YAAY,OAAO,CAAC,KAAK,kBAAkB;AAClD,QAAO,YAAY,OAAO,CAAC,KAAK,mCAAmC;AACnE,QAAO,YAAY,QAAQ,CAAC,UAAU,2DAA2D;AAGjG,QAAO,YAAY,QAAQ,CAAC,UAAU,cAAc;AACpD,QAAO,YAAY,QAAQ,CAAC,UAAU,eAAe;AACrD,QAAO,YAAY,QAAQ,CAAC,UAAU,qEAAqE;EAC3G;;;;AAMF,SAAgB,aAAa,QAAiB;AAC5C,KAAI,CAAC,eAAe,CAClB,OAAM,IAAI,wBAAwB,EAAE,QAAQ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  //#region src/hooks/use-hover.d.ts
2
- declare function useHover<T extends HTMLElement>(ref: React.RefObject<T>, options?: {
2
+ declare function useHover<T extends HTMLElement | null>(ref: React.RefObject<T>, options?: {
3
3
  onMouseEnter?: () => void;
4
4
  onMouseLeave?: () => void;
5
5
  }): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"use-hover.d.ts","names":[],"sources":["../../src/hooks/use-hover.tsx"],"mappings":";iBAGgB,QAAA,WAAmB,WAAA,CAAA,CACjC,GAAA,EAAK,KAAA,CAAM,SAAA,CAAU,CAAA,GACrB,OAAA;EACE,YAAA;EACA,YAAA;AAAA"}
1
+ {"version":3,"file":"use-hover.d.ts","names":[],"sources":["../../src/hooks/use-hover.tsx"],"mappings":";iBAGgB,QAAA,WAAmB,WAAA,QAAA,CACjC,GAAA,EAAK,KAAA,CAAM,SAAA,CAAU,CAAA,GACrB,OAAA;EACE,YAAA;EACA,YAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-hover.js","names":[],"sources":["../../src/hooks/use-hover.tsx"],"sourcesContent":["import { useLayoutEffect } from \"react\";\nimport { useRefState } from \"../utils/react\";\n\nexport function useHover<T extends HTMLElement>(\n ref: React.RefObject<T>,\n options: {\n onMouseEnter?: () => void,\n onMouseLeave?: () => void,\n } = {},\n): boolean {\n // Internal counter: mouseenter++ / mouseleave-- (isHovering = counter > 0)\n const counter = useRefState(0);\n\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n let incr = 0;\n let prevInside = false;\n\n const contains = (r: DOMRect, x: number, y: number) =>\n x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;\n\n const enter = () => {\n incr++;\n counter.set(c => c + 1);\n if (counter.current === 1) {\n options.onMouseEnter?.();\n }\n };\n\n const leave = () => {\n incr--;\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n counter.set(c => c - 1);\n if (counter.current === 0) {\n options.onMouseLeave?.();\n }\n });\n });\n };\n\n const topMatchesTarget = (x: number, y: number) => {\n const top = document.elementFromPoint(x, y);\n return !!(top && (top === el || el.contains(top)));\n };\n\n const processPoint = (x: number, y: number) => {\n const rect = el.getBoundingClientRect();\n\n // True “hoverability”: inside rect AND not occluded by others\n const inside = contains(rect, x, y) && topMatchesTarget(x, y);\n if (inside && !prevInside) {\n enter();\n } else if (!inside && prevInside) {\n leave();\n }\n prevInside = inside;\n };\n\n const onMove = (e: PointerEvent) => {\n if (e.pointerType !== \"mouse\") return; // keep it hover-only\n // Use coalesced points when available\n const batch = e.getCoalescedEvents();\n if (batch.length) {\n for (let eventIndex = 0; eventIndex < batch.length - 1; eventIndex++) {\n const e1 = batch[eventIndex];\n const e2 = batch[eventIndex + 1];\n const steps = 10;\n for (let i = 0; i <= steps; i++) {\n processPoint(e1.clientX + (e2.clientX - e1.clientX) * i / steps, e1.clientY + (e2.clientY - e1.clientY) * i / steps);\n }\n }\n } else {\n processPoint(e.clientX, e.clientY);\n }\n };\n\n window.addEventListener(\"pointermove\", onMove, { passive: true });\n\n return () => {\n window.removeEventListener(\"pointermove\", onMove);\n counter.set(c => c - incr);\n };\n }, []);\n\n return counter.current > 0;\n}\n"],"mappings":";;;;;;AAGA,SAAgB,SACd,KACA,UAGI,EAAE,EACG;CAET,MAAM,6CAAsB,EAAE;AAE9B,kCAAsB;EACpB,MAAM,KAAK,IAAI;AACf,MAAI,CAAC,GAAI;EACT,IAAI,OAAO;EACX,IAAI,aAAa;EAEjB,MAAM,YAAY,GAAY,GAAW,MACvC,KAAK,EAAE,QAAQ,KAAK,EAAE,SAAS,KAAK,EAAE,OAAO,KAAK,EAAE;EAEtD,MAAM,cAAc;AAClB;AACA,WAAQ,KAAI,MAAK,IAAI,EAAE;AACvB,OAAI,QAAQ,YAAY,EACtB,SAAQ,gBAAgB;;EAI5B,MAAM,cAAc;AAClB;AACA,+BAA4B;AAC1B,gCAA4B;AAC1B,aAAQ,KAAI,MAAK,IAAI,EAAE;AACvB,SAAI,QAAQ,YAAY,EACtB,SAAQ,gBAAgB;MAE1B;KACF;;EAGJ,MAAM,oBAAoB,GAAW,MAAc;GACjD,MAAM,MAAM,SAAS,iBAAiB,GAAG,EAAE;AAC3C,UAAO,CAAC,EAAE,QAAQ,QAAQ,MAAM,GAAG,SAAS,IAAI;;EAGlD,MAAM,gBAAgB,GAAW,MAAc;GAI7C,MAAM,SAAS,SAHF,GAAG,uBAAuB,EAGT,GAAG,EAAE,IAAI,iBAAiB,GAAG,EAAE;AAC7D,OAAI,UAAU,CAAC,WACb,QAAO;YACE,CAAC,UAAU,WACpB,QAAO;AAET,gBAAa;;EAGf,MAAM,UAAU,MAAoB;AAClC,OAAI,EAAE,gBAAgB,QAAS;GAE/B,MAAM,QAAQ,EAAE,oBAAoB;AACpC,OAAI,MAAM,OACR,MAAK,IAAI,aAAa,GAAG,aAAa,MAAM,SAAS,GAAG,cAAc;IACpE,MAAM,KAAK,MAAM;IACjB,MAAM,KAAK,MAAM,aAAa;IAC9B,MAAM,QAAQ;AACd,SAAK,IAAI,IAAI,GAAG,KAAK,OAAO,IAC1B,cAAa,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,IAAI,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,IAAI,MAAM;;OAIxH,cAAa,EAAE,SAAS,EAAE,QAAQ;;AAItC,SAAO,iBAAiB,eAAe,QAAQ,EAAE,SAAS,MAAM,CAAC;AAEjE,eAAa;AACX,UAAO,oBAAoB,eAAe,OAAO;AACjD,WAAQ,KAAI,MAAK,IAAI,KAAK;;IAE3B,EAAE,CAAC;AAEN,QAAO,QAAQ,UAAU"}
1
+ {"version":3,"file":"use-hover.js","names":[],"sources":["../../src/hooks/use-hover.tsx"],"sourcesContent":["import { useLayoutEffect } from \"react\";\nimport { useRefState } from \"../utils/react\";\n\nexport function useHover<T extends HTMLElement | null>(\n ref: React.RefObject<T>,\n options: {\n onMouseEnter?: () => void,\n onMouseLeave?: () => void,\n } = {},\n): boolean {\n // Internal counter: mouseenter++ / mouseleave-- (isHovering = counter > 0)\n const counter = useRefState(0);\n\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n let incr = 0;\n let prevInside = false;\n\n const contains = (r: DOMRect, x: number, y: number) =>\n x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;\n\n const enter = () => {\n incr++;\n counter.set(c => c + 1);\n if (counter.current === 1) {\n options.onMouseEnter?.();\n }\n };\n\n const leave = () => {\n incr--;\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n counter.set(c => c - 1);\n if (counter.current === 0) {\n options.onMouseLeave?.();\n }\n });\n });\n };\n\n const topMatchesTarget = (x: number, y: number) => {\n const top = document.elementFromPoint(x, y);\n return !!(top && (top === el || el.contains(top)));\n };\n\n const processPoint = (x: number, y: number) => {\n const rect = el.getBoundingClientRect();\n\n // True “hoverability”: inside rect AND not occluded by others\n const inside = contains(rect, x, y) && topMatchesTarget(x, y);\n if (inside && !prevInside) {\n enter();\n } else if (!inside && prevInside) {\n leave();\n }\n prevInside = inside;\n };\n\n const onMove = (e: PointerEvent) => {\n if (e.pointerType !== \"mouse\") return; // keep it hover-only\n // Use coalesced points when available\n const batch = e.getCoalescedEvents();\n if (batch.length) {\n for (let eventIndex = 0; eventIndex < batch.length - 1; eventIndex++) {\n const e1 = batch[eventIndex];\n const e2 = batch[eventIndex + 1];\n const steps = 10;\n for (let i = 0; i <= steps; i++) {\n processPoint(e1.clientX + (e2.clientX - e1.clientX) * i / steps, e1.clientY + (e2.clientY - e1.clientY) * i / steps);\n }\n }\n } else {\n processPoint(e.clientX, e.clientY);\n }\n };\n\n window.addEventListener(\"pointermove\", onMove, { passive: true });\n\n return () => {\n window.removeEventListener(\"pointermove\", onMove);\n counter.set(c => c - incr);\n };\n }, []);\n\n return counter.current > 0;\n}\n"],"mappings":";;;;;;AAGA,SAAgB,SACd,KACA,UAGI,EAAE,EACG;CAET,MAAM,6CAAsB,EAAE;AAE9B,kCAAsB;EACpB,MAAM,KAAK,IAAI;AACf,MAAI,CAAC,GAAI;EACT,IAAI,OAAO;EACX,IAAI,aAAa;EAEjB,MAAM,YAAY,GAAY,GAAW,MACvC,KAAK,EAAE,QAAQ,KAAK,EAAE,SAAS,KAAK,EAAE,OAAO,KAAK,EAAE;EAEtD,MAAM,cAA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versationSummarySchema: yup$1.ObjectSchema<{
49
49
  userPrimaryEmail: string | null;
50
50
  userProfileImageUrl: string | null;
51
51
  subject: string;
52
- status: "open" | "pending" | "closed";
52
+ status: "pending" | "open" | "closed";
53
53
  priority: "low" | "normal" | "high" | "urgent";
54
54
  source: "email" | "manual" | "chat" | "api";
55
55
  lastMessageType: "message" | "internal-note" | "status-change";
@@ -129,7 +129,7 @@ declare const conversationMessageSchema: yup$1.ObjectSchema<{
129
129
  userId: string | null;
130
130
  teamId: string | null;
131
131
  subject: string;
132
- status: "open" | "pending" | "closed";
132
+ status: "pending" | "open" | "closed";
133
133
  priority: "low" | "normal" | "high" | "urgent";
134
134
  source: "email" | "manual" | "chat" | "api";
135
135
  messageType: "message" | "internal-note" | "status-change";
@@ -173,7 +173,7 @@ declare const conversationListResponseSchema: yup$1.ObjectSchema<{
173
173
  lastOutboundAt?: string | null | undefined;
174
174
  closedAt?: string | null | undefined;
175
175
  recordMetadata?: {} | null | undefined;
176
- status: "open" | "pending" | "closed";
176
+ status: "pending" | "open" | "closed";
177
177
  priority: "low" | "normal" | "high" | "urgent";
178
178
  subject: string;
179
179
  conversationId: string;
@@ -211,7 +211,7 @@ declare const conversationDetailResponseSchema: yup$1.ObjectSchema<{
211
211
  lastOutboundAt?: string | null | undefined;
212
212
  closedAt?: string | null | undefined;
213
213
  recordMetadata?: {} | null | undefined;
214
- status: "open" | "pending" | "closed";
214
+ status: "pending" | "open" | "closed";
215
215
  priority: "low" | "normal" | "high" | "urgent";
216
216
  subject: string;
217
217
  conversationId: string;
@@ -236,7 +236,7 @@ declare const conversationDetailResponseSchema: yup$1.ObjectSchema<{
236
236
  };
237
237
  };
238
238
  messages: {
239
- status: "open" | "pending" | "closed";
239
+ status: "pending" | "open" | "closed";
240
240
  id: string;
241
241
  priority: "low" | "normal" | "high" | "urgent";
242
242
  subject: string;