From 019fdc28b345e8b6f07cb96562f5e26c112da4cf Mon Sep 17 00:00:00 2001 From: pylixonly <82711525+pylixonly@users.noreply.github.com> Date: Sat, 12 Oct 2024 23:07:44 +0800 Subject: [PATCH] feat(metro): expose common components & custom jsx runtime --- shims/jsxRuntime.ts | 4 ++++ src/lib/index.ts | 4 ++++ src/metro/common/index.ts | 2 ++ 3 files changed, 10 insertions(+) diff --git a/shims/jsxRuntime.ts b/shims/jsxRuntime.ts index 7352a67..81b54bd 100644 --- a/shims/jsxRuntime.ts +++ b/shims/jsxRuntime.ts @@ -4,6 +4,10 @@ import { findByPropsLazy } from "@metro/wrappers"; const jsxRuntime = findByPropsLazy("jsx", "jsxs", "Fragment"); function unproxyFirstArg(args: T[]) { + if (!args[0]) { + throw new Error("The first argument (Component) is falsy. Ensure that you are passing a valid component."); + } + const factory = getProxyFactory(args[0]); if (factory) args[0] = factory(); return args; diff --git a/src/lib/index.ts b/src/lib/index.ts index 3791476..7230786 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -12,6 +12,10 @@ export * as metro from "@metro"; import * as fonts from "./fonts"; import * as plugins from "./plugins"; import * as themes from "./themes"; + +/** @internal */ +export * as _jsx from "react/jsx-runtime"; + import { proxyLazy } from "./utils/lazy"; export const managers = proxyLazy(() => { diff --git a/src/metro/common/index.ts b/src/metro/common/index.ts index 0f6f27a..04618a5 100644 --- a/src/metro/common/index.ts +++ b/src/metro/common/index.ts @@ -2,6 +2,8 @@ import { findByFilePathLazy, findByProps, findByPropsLazy } from "@metro/wrapper import type { Dispatcher } from "./types/flux"; +export * as components from "./components"; + // Discord export const constants = findByPropsLazy("Fonts", "Permissions"); export const channels = findByPropsLazy("getVoiceChannelId");