openpencil/packages/op-web-sdk-react/src/context.ts
Kayshen-X 199d9bbec9 feat(sdk): add React + Vue adapters for op-web-sdk
Plan 3 of the web embedding SDK: @zseven-w/op-web-sdk-react and -vue — thin
read-only framework adapters over the TS core. Each: <DesignView> (canvas +
viewer lifecycle), provider/inject of OpViewer, and read-only
useDocument/useViewport/useActivePage. React via useSyncExternalStore
(cache-invalidate-on-event); Vue via an async shallowRef provider so children
inject the viewer after load. Self-contained (no pen-* deps; framework peer);
React 5/5 + Vue 4/4 tests; both tsc clean.
2026-06-19 21:01:27 +08:00

6 lines
251 B
TypeScript

import { createContext } from 'react';
import type { OpViewer } from '@zseven-w/op-web-sdk';
// React context holding the current OpViewer instance; null when no provider is mounted.
export const ViewerContext = createContext<OpViewer | null>(null);