'@wordpress/abilities', 'import' => 'dynamic')), $version, array('in_footer' => true)); // Minimal config injected on the page (public, no secrets). $config = array( 'endpoint' => esc_url_raw(rest_url('embodied-assistant/v1')), 'admissionUrl' => esc_url_raw(admin_url('admin-ajax.php')), 'entryUrl' => esc_url_raw(add_query_arg('ver', $version, EMBODIED_ASSISTANT_URL . 'assets/dist/' . $main)), 'mode' => isset($context['mode']) ? sanitize_key($context['mode']) : 'default', ); add_filter('script_module_data_' . self::HANDLE, static function () use ($config) { return $config; }); wp_enqueue_script_module(self::HANDLE); // The component injects its own shadow-DOM styles; the plugin only // styles the mount container (sizing) via a tiny inline block style // added by Embed, so no stylesheet round trip is needed for the bot. if (!empty($manifest['style'])) { wp_register_style(self::HANDLE, EMBODIED_ASSISTANT_URL . 'assets/dist/' . $manifest['style'], array(), $version); wp_enqueue_style(self::HANDLE); } } /** * Parse the build manifest (id → hashed file path). * * @return array {main: string, style: string} */ public static function manifest() { if (null !== self::$manifest) { return self::$manifest; } self::$manifest = array('main' => '', 'style' => ''); $path = EMBODIED_ASSISTANT_DIR . self::MANIFEST; if (!is_readable($path)) { return self::$manifest; } $decoded = json_decode((string) file_get_contents($path), true); if (!is_array($decoded)) { return self::$manifest; } if (!empty($decoded['embodied-assistant.js'])) { self::$manifest['main'] = ltrim((string) $decoded['embodied-assistant.js'], '/'); } if (!empty($decoded['index.css'])) { self::$manifest['style'] = ltrim((string) $decoded['index.css'], '/'); } return self::$manifest; } }