UNPKG

blade

Version:
28 lines (27 loc) 998 B
//#region private/client/utils/wrap-client.ts const CLIENT_REFERENCE = Symbol.for("react.client.reference"); const REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"); /** * Used to mark internal framework components as client components. * * @param component - The React component to mark as a client component. * @param name - The name of the React component. * * @returns Nothing. */ const wrapClientComponent = (component, name) => { const chunkId = name.toLowerCase(); const isNetlify = typeof Netlify !== "undefined"; if (typeof window === "undefined" || isNetlify) Object.defineProperties(component.$$typeof === REACT_FORWARD_REF_TYPE ? component.render : component, { $$typeof: { value: CLIENT_REFERENCE }, name: { value: name }, chunk: { value: chunkId }, id: { value: `native-${name}` } }); else { if (!window["BLADE_CHUNKS"]) window["BLADE_CHUNKS"] = {}; window.BLADE_CHUNKS[chunkId] = { [name]: component }; } }; //#endregion export { wrapClientComponent as t };