feat(tabletop): inject proxy handlers from web app
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
"@tts/mesh": "workspace:*",
|
||||
"@tts/shared": "workspace:*",
|
||||
"@tts/bgm": "workspace:*",
|
||||
"@tts/tabletop": "workspace:*",
|
||||
"bson": "^7.3.1",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { PartView, ErrorBoundary, TabletopProvider } from '@tts/tabletop';
|
||||
import Breadcrumbs from '../components/Breadcrumbs';
|
||||
import PackageMissing from '../components/PackageMissing';
|
||||
import Scene from '../components/viewers/Scene';
|
||||
import { findPackage } from './bgm';
|
||||
import { tabletopHttp } from '../tabletopHttp';
|
||||
|
||||
/** Detail view for a single part within a package. */
|
||||
export default function PartPage() {
|
||||
@@ -35,6 +38,16 @@ export default function PartPage() {
|
||||
{found.fillet ? ` · fillet ${found.fillet}mm` : ''}
|
||||
</p>
|
||||
</div>
|
||||
{/* The boundary wraps the Canvas (Scene), not PartView, so its HTML
|
||||
fallback renders outside the r3f namespace. The provider wires the
|
||||
library's proxy calls to the web app's proxy. */}
|
||||
<ErrorBoundary>
|
||||
<TabletopProvider http={tabletopHttp}>
|
||||
<Scene>
|
||||
<PartView part={found} baseUrl={found.baseUrl} />
|
||||
</Scene>
|
||||
</TabletopProvider>
|
||||
</ErrorBoundary>
|
||||
<pre className="overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900 p-3 text-xs text-zinc-400">
|
||||
{JSON.stringify(found, null, 2)}
|
||||
</pre>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { TabletopHttp } from '@tts/tabletop';
|
||||
import { traceImage as apiTraceImage } from './api';
|
||||
import { assetUrl as viewerAssetUrl } from './components/viewers/assetUrl';
|
||||
|
||||
/**
|
||||
* The tabletop library's HTTP handlers, wired to the web app's proxy. The
|
||||
* library defaults to the conventional `/asset` and `/trace` paths, but the web
|
||||
* app provides its own so the coupling is explicit and testable.
|
||||
*/
|
||||
export const tabletopHttp: TabletopHttp = {
|
||||
assetUrl: viewerAssetUrl,
|
||||
traceImage: apiTraceImage,
|
||||
};
|
||||
Reference in New Issue
Block a user