Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.3 KB
Raw Blame
import { createElement, type ReactNode } from 'react'

// Preserve host tags/props/children for projection, without layout or events.
// Drop render-callback children rather than inventing unscripted presses.
export function inertNativeElement(name: string) {
  function InertNativeElement(props: { children?: ReactNode }): ReactNode {
    const { children, ...rest } = props
    return createElement(name, rest, typeof children === 'function' ? undefined : children)
  }
  InertNativeElement.displayName = name
  return InertNativeElement
}

/** One inert element per name, built once so React sees a stable component identity per render. */
export function inertNativeElements(names: readonly string[]): Record<string, unknown> {
  return Object.fromEntries(names.map((name) => [name, inertNativeElement(name)]))
}

// Icon packages export only icons; memoize each name so renders preserve component identity.
export function inertIconModule(): unknown {
  const icons = new Map<string, unknown>()
  return new Proxy(
    {},
    {
      get: (_target, key) => {
        if (typeof key !== 'string' || key === '__esModule') {
          return undefined
        }
        const found = icons.get(key)
        if (found) {
          return found
        }
        const icon = inertNativeElement(key)
        icons.set(key, icon)
        return icon
      }
    }
  )
}