protected async function renderAsync()

in src/x_js-scope.php [16:44]


  protected async function renderAsync(): Awaitable<x\node> {
    $calls = new ScriptDataList();
    $instances = new ScriptDataList();
    $this->setContext('x_js_scope/calls', $calls);
    $this->setContext('x_js_scope/instances', $instances);

    $children = await Vec\map_async($this->getChildren(), async $c ==> {
      invariant($c is x\node,
        '%s is not an x\node',
        is_object($c) ? get_class($c) : gettype($c),
      );
      $c->__transferContext($this->getAllContexts());
      return await $c->__flushSubtree();
    });

    $this->replaceChildren();

    return
      <x:frag>
        {$children}
        <script>
          var XHPJS = window.XHPJS ? window.XHPJS : require('xhpjs');
          new XHPJS(
            {json_encode($instances)},
            {json_encode($calls)}
          );
        </script>
      </x:frag>;
  }