import { Decorator } from '../support_decorators/decorator.js'; /** * PHP parity: Livewire\Attributes\Js * * Real Livewire's #[Js] works by treating the decorated PHP method's body * as literal JavaScript source and shipping it to the client, where it's * registered as a callable on `$wire.js` — so `$wire.methodName()` runs * entirely in the browser, no request round-trip. TypeScript methods * aren't source-inspectable at the language level either, but functions * ARE stringifiable at runtime (`fn.toString()`), which is exactly what * the pre-existing `bind()` decorator already relies on for parameter * names — this decorator reuses the same trick for the method body. * * The method itself never runs server-side: this only ever reads its * source text and re-emits it as client JS via the existing `@script` * tag infrastructure (SupportScriptsAndAssets's `scripts` store/effect, * with its own once-per-component dedup already handling repeat * dehydrates). The vendored client bundle (assets/livewire.js) already * exposes `$wire.$js` as a proxy that registers/calls these * (`component.addJsAction`/`getJsAction`) - nothing to add there. * * Caveat carried over from real Livewire: the method body must be * self-contained client JS (it runs with `$wire`/`$js` in scope, nothing * server-side) - see docs/attribute-js.md. */ export default class Js extends Decorator { name: string; constructor(name: string); dehydrate(): Promise; }