// The gui engine, named once. // // @hanzo/gui is a facade over ~55 `@hanzogui/*` packages, and several of them // (`popper`, `popover`, `core`, `floating`) publish React contexts at MODULE // scope. Two physical copies of such a package are two different context // objects, so a provider from copy A is invisible to a consumer from copy B and // the consumer silently falls back to the context's default value. // // That is not a theoretical hazard, it is the shape of the loudest bug this // package has shipped: `PopperAnchor` reads `refs` off the Popper context and // calls `refs.setReference(node)` from a ref callback with no guard, so when the // context is the empty default the browser logs // // Cannot read properties of undefined (reading 'setReference') // // once per tooltip trigger, uncaught (it runs inside `startTransition`, so no // error boundary sees it). A page with a tooltip per table row logs it hundreds // of times. The gui engine itself diagnoses the same root cause out loud when // the duplication reaches its config lookup: "Can't find Hanzo GUI // configuration … due to having mis-matched versions of Hanzo GUI dependencies, // or bundlers somehow duplicating them." // // So the engine list is a VALUE, declared once here, and both bundler wrappers // (`@luxfi/ui/vite`, `@luxfi/ui/next`) dedupe against it. A consumer that uses // the wrapper cannot end up with two copies, and does not have to hand-write a // per-app `pnpm.overrides` block pinning three dozen packages to stop it. /** Every package `@hanzo/gui` re-exports — the engine, in full. */ export const GUI_PACKAGES: ReadonlyArray = [ '@hanzo/gui', '@hanzogui/accordion', '@hanzogui/adapt', '@hanzogui/alert-dialog', '@hanzogui/animate', '@hanzogui/animate-presence', '@hanzogui/avatar', '@hanzogui/button', '@hanzogui/card', '@hanzogui/checkbox', '@hanzogui/collapsible', '@hanzogui/component-helpers', '@hanzogui/compose-refs', '@hanzogui/config', '@hanzogui/context-menu', '@hanzogui/core', '@hanzogui/create-context', '@hanzogui/create-menu', '@hanzogui/dialog', '@hanzogui/dismissable', '@hanzogui/element', '@hanzogui/elements', '@hanzogui/floating', '@hanzogui/focus-scope', '@hanzogui/font-size', '@hanzogui/form', '@hanzogui/get-token', '@hanzogui/group', '@hanzogui/helpers', '@hanzogui/image', '@hanzogui/input', '@hanzogui/label', '@hanzogui/list-item', '@hanzogui/menu', '@hanzogui/popover', '@hanzogui/popper', '@hanzogui/portal', '@hanzogui/progress', '@hanzogui/radio-group', '@hanzogui/react-native-media-driver', '@hanzogui/remove-scroll', '@hanzogui/scroll-view', '@hanzogui/select', '@hanzogui/separator', '@hanzogui/shapes', '@hanzogui/sheet', '@hanzogui/slider', '@hanzogui/spacer', '@hanzogui/spinner', '@hanzogui/stacks', '@hanzogui/switch', '@hanzogui/tabs', '@hanzogui/text', '@hanzogui/theme', '@hanzogui/toast', '@hanzogui/toggle-group', '@hanzogui/tooltip', '@hanzogui/use-controllable-state', '@hanzogui/use-debounce', '@hanzogui/use-force-update', '@hanzogui/use-presence', '@hanzogui/use-window-dimensions', '@hanzogui/visually-hidden', '@hanzogui/web', '@hanzogui/z-index-stack', '@luxfi/ui', ]; /** * The engine branches on these at module scope; without them a browser bundle * takes the native path. */ export const GUI_DEFINES: Readonly> = { 'process.env.EXPO_OS': JSON.stringify('web'), 'process.env.IS_WEB': JSON.stringify('true'), }; /** * Every package that must exist exactly ONCE in a bundle — the engine, plus the * three libraries outside it that also publish a module-scope React context. * * `react` and `react-dom` are the classic case. `@tanstack/react-query` is the * same failure with a different message: lux.market resolved two copies (one * under react@19.1.0, one under react@19.2.8), the app's `QueryClientProvider` * came from copy A and `@luxfi/ui`'s `useQuery` read copy B's context, and the * whole page died with "No QueryClient set, use QueryClientProvider to set one". * * ONE list, shared by both bundler wrappers, so vite and next cannot dedupe * different sets — which is exactly how that market bug survived: the vite * wrapper already listed these three, the Next wrapper did not. */ export const ENGINE_DEDUPE: ReadonlyArray = [ 'react', 'react-dom', '@tanstack/react-query', ...GUI_PACKAGES, ]; /** * The subset of ENGINE_DEDUPE that may be pinned by a hard bundler ALIAS. * * `dedupe` is advisory hoisting; an alias is a hard redirect, and redirecting * `react` / `react-dom` inside a Next app breaks the framework's own graph — * the RSC client manifest is keyed on Next's copy, so the MPC dashboard died * with `Could not find the module … segment-explorer-node.js#SegmentViewNode in * the React Client Manifest` followed by `__webpack_modules__[moduleId] is not * a function`. Next already guarantees one React; it does not guarantee one * react-query, and it does not guarantee one popper. */ export const ALIASABLE: ReadonlyArray = [ '@tanstack/react-query', ...GUI_PACKAGES, ];