Files
orca/examples/plugins/hello-tsx/src/panel.tsx
Neil 4ee788a725 Build-less TS/TSX plugins, typings and authoring tools (#36918)
* feat(plugins): build-less TS/TSX plugins, typings and authoring tools

- Plugin frames transpile .ts/.tsx/.mts/.jsx on load (sucrase on a shared worker thread with a
  2 s budget, cached in main), resolve relative imports to exact files, and refuse bare
  package imports by name. Components and html panel/editor entries may be .ts/.tsx.
- orca plugin types writes typings for the components orca module, window.orca, worker
  activate(orca), host.call and events into .orca/types, from one host-typings generator.
- orca plugin create --template components; templates omit publisher and target 1.4.246.
- orca plugin release-entry, dev inspect and restart; validate:plugin checks named files.
- Guest console errors reach orca plugin logs; dev workers restart on edits; the dev watcher
  ignores .git, .orca and node_modules; Git and folder installs cannot replace catalog installs.
- examples/plugins/hello-tsx, docs, and the plugin-buildless-tsx e2e spec.

* ci: run the Windows parity probes with one tsgo checker

tsconfig.node peaks near 22 GB with tsgo's default four checkers (each holds its own types)
and about 16 GB with one; the 16 GB Windows runner paged the native probe past its 900 s
timeout once this branch's package.json change triggered the job. One checker gives the
same diagnostics (verified locally with --parity-only); the timing benchmark is unchanged.
2026-11-01 01:28:35 -08:00

63 lines
1.7 KiB
TypeScript

// No build step: Orca strips the types, compiles the JSX and resolves `./todos` when it loads.
import {
atom,
Badge,
Button,
Heading,
IconButton,
Input,
on,
Progress,
read,
Row,
set,
Stack,
Text,
ui,
update,
type PanelContext
} from 'orca'
import { TodoList } from './todo-list'
import { add, clearDone, draft, openCount, percentDone, todos } from './todos'
const themeSwitches = atom(0)
/** Runs once before the first render; what it pushes to `subscriptions` ends with the panel. */
export function setup(ctx: PanelContext): void {
ctx.subscriptions.push(on('theme', () => update(themeSwitches, (n) => n + 1)))
}
export default function Panel() {
const open = read(openCount)
return (
<Stack gap="md">
<Row justify="between">
<Heading>Tasks</Heading>
<Badge tone={open > 0 ? 'accent' : 'neutral'}>{open} open</Badge>
</Row>
{/* Feature-detect: an older Orca without Progress still renders the rest. */}
{ui.has('Progress') ? <Progress label="Done" labelHidden value={read(percentDone)} /> : null}
<Row gap="xs">
<Input
label="New task"
labelHidden
placeholder="New task"
value={read(draft)}
onChange={(value) => set(draft, value)}
onSubmit={add}
/>
<IconButton icon="add" label="Add task" onPress={add} disabled={!read(draft).trim()} />
</Row>
<TodoList items={read(todos)} />
<Row justify="end">
<Button variant="ghost" onPress={clearDone}>
Clear done
</Button>
</Row>
<Text muted size="xs">
Written in TSX with no build step. Theme switches seen: {read(themeSwitches)}.
</Text>
</Stack>
)
}