@10up/wp-vite-plugins 1.0.0-alpha.2 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/php-templates.ts","../src/wp-admin-pages.ts","../src/wp-blocks.ts","../src/wp-block-styles.ts","../src/wp-copy-assets.ts","../src/package-metadata.ts","../src/wp-externals.ts","../src/wp-script-dedupe.ts","../src/wp-script-iife.ts","../src/wp-clean-css-chunks.ts","../src/wp-css-asset-info.ts","../src/wp.ts"],"names":["resolve","readFileSync","join","existsSync","fg","relative","extname","require","resolvePath","dirname","realpathSync","options","external","reachableChunks","handles","crypto","parse","init","MagicString"],"mappings":";;;;;;;;;;;AAyCO,IAAM,oBAAA,GAA2C;AAAA,EACvD,8KAAA;AAAA,EACA,CAAC,mBAAmB,SAAS;AAC9B,CAAA;AAGO,IAAM,cAAA,GAA6B,CAAC,WAAA,EAAa,UAAU,CAAA;AAwE3D,SAAS,UAAU,KAAA,EAAuB;AAChD,EAAA,OAAO,CAAA,CAAA,EAAI,MAAM,OAAA,CAAQ,KAAA,EAAO,MAAM,CAAA,CAAE,OAAA,CAAQ,IAAA,EAAM,KAAK,CAAC,CAAA,CAAA,CAAA;AAC7D;AAGO,SAAS,eAAe,MAAA,EAA0B;AACxD,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,SAAA;AAChC,EAAA,OAAO,UAAU,MAAA,CAAO,GAAA,CAAI,SAAS,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,EAAA,CAAA;AAClD;AAGO,SAAS,aAAa,KAAA,EAAuB;AACnD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA;AAC/B;AAGO,SAAS,qBAAqB,KAAA,EAAwB;AAC5D,EAAA,OAAO,0BAAA,CAA2B,IAAA,CAAK,YAAA,CAAa,K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esContent":["/**\n * PHP source generation for `@wordpress/boot` admin pages.\n *\n * A port of `@wordpress/build` 0.17.0's generated PHP layer (its\n * `templates/*.php.template` files plus the `generate*Php` functions in\n * `lib/build.mjs`) to TypeScript template functions. The package ships a\n * single tsup bundle, so the templates are string builders here rather than\n * files on disk — but they stay laid out like the originals so a future\n * upstream diff is still readable.\n *\n * Runtime behavior kept verbatim from wp-build: function/hook/filter naming,\n * the boot dependency-graph assembly, the REST preload middleware, the\n * `DOMContentLoaded`-deferred wp-admin bootstrap (core ticket 65103), the\n * full-page HTML shell with its `wp_script_modules()` printing and\n * `admin_init` render intercept, and the `file_exists()` guards that degrade\n * gracefully when a `.asset.php` sidecar is missing.\n *\n * Adapted for this repo's output layout:\n *\n * - modules live at `modules/<page>/…` (wp-build: `pages/<page>/`,\n * `routes/<name>/`), so route rows carry an explicit `dir`.\n * - one non-minified artifact per module (no `.min.js` / `SCRIPT_DEBUG`\n * switching).\n * - the prerequisites carrier reads the page's *own* `.asset.php` sidecars\n * (wp-build reads its bundled boot module's), unioned with core's boot\n * asset when that file exists.\n * - `false` (not `''`) as the carrier's `wp_register_script()` src.\n * - menu registration is generated when a page declares `menu` in\n * `page.json`; wp-build leaves menus to the author.\n * - the prefix is underscored consistently for every generated identifier\n * (wp-build emits invalid PHP for a dashed `wpPlugin.name` in\n * `routes.php`).\n */\n\n/** Which of the two page flavors a generated file implements. */\nexport type PageMode = 'full-page' | 'wp-admin';\n\n/** `'/wp/v2/settings'` or `['/wp/v2/settings', 'OPTIONS']`. */\nexport type RestPreloadEntry = string | [string, string];\n\n/** wp-build's hardcoded preload paths — our per-page default. */\nexport const DEFAULT_REST_PRELOAD: RestPreloadEntry[] = [\n\t'/?_fields=description,gmt_offset,home,image_sizes,image_size_threshold,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front',\n\t['/wp/v2/settings', 'OPTIONS'],\n];\n\n/** Both modes, in the order wp-build generates them. */\nexport const ALL_PAGE_MODES: PageMode[] = ['full-page', 'wp-admin'];\n\nexport interface PageMenu {\n\t/**\n\t * Parent menu file. Absent or `'options-general.php'` →\n\t * `add_options_page()`; `false` / `'toplevel'` → `add_menu_page()`;\n\t * any other slug → `add_submenu_page()`.\n\t */\n\tparent?: string | false;\n\t/** Capability required to see the page. Default `'manage_options'`. */\n\tcapability?: string;\n\t/** Top-level menu position (`add_menu_page()` only). */\n\tposition?: number;\n\t/** Top-level menu icon (`add_menu_page()` only). */\n\ticon?: string;\n}\n\nexport interface GeneratedRoute {\n\t/** Registry name. `'index'` for the page-root route. */\n\tname: string;\n\t/** Route path handed to `@wordpress/boot`. `'/'` for the page root. */\n\tpath: string;\n\t/** dist-relative module directory (`modules/<page>[/routes/<name>]`). */\n\tdir: string;\n\t/** Whether the route built a `content` module. */\n\thasContent: boolean;\n\t/** Whether the route built a `route` module. */\n\thasRoute: boolean;\n}\n\nexport interface GeneratedPage {\n\t/** Page directory name — the page slug. */\n\tslug: string;\n\t/** Human title, used for the menu labels. */\n\ttitle: string;\n\t/** Which files to generate for this page. */\n\tmodes: PageMode[];\n\t/** Script Module ids added to the boot graph as static dependencies. */\n\tinitModules: string[];\n\t/** REST paths preloaded into `wp.apiFetch`. */\n\trestPreload: RestPreloadEntry[];\n\t/** Generate an admin menu entry when present. */\n\tmenu?: PageMenu;\n\t/** Routes belonging to this page, page-root route first. */\n\troutes: GeneratedRoute[];\n}\n\nexport interface PhpContext {\n\t/** Identifier prefix for functions, globals and the `@package` tag. */\n\tprefix: string;\n\t/** Script Module id prefix (`<handlePrefix>/routes/<page>/<name>/…`). */\n\thandlePrefix: string;\n\t/** Raw PHP expression evaluating to the dist directory URL. */\n\tbaseUrl: string;\n\t/** Version written into `constants.php`. */\n\tversion: string;\n\t/** Text domain for the generated `__()` calls. */\n\ttextdomain: string;\n}\n\nexport interface GeneratedPhpFile {\n\t/** dist-relative output path. */\n\tfileName: string;\n\t/** PHP source. */\n\tsource: string;\n}\n\n/* -------------------------------------------------------------------------\n * Escaping / identifier helpers\n * ---------------------------------------------------------------------- */\n\n/** PHP single-quoted string literal. */\nexport function phpString(value: string): string {\n\treturn `'${value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n}\n\n/** `array( 'a', 'b' )` — `array()` when empty. */\nexport function phpStringArray(values: string[]): string {\n\tif (values.length === 0) return 'array()';\n\treturn `array( ${values.map(phpString).join(', ')} )`;\n}\n\n/** Dashes to underscores, for identifiers built out of slugs. */\nexport function toUnderscore(value: string): string {\n\treturn value.replace(/-/g, '_');\n}\n\n/** Valid as a PHP identifier fragment once dashes are underscored. */\nexport function isValidPhpIdentifier(value: string): boolean {\n\treturn /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(toUnderscore(value));\n}\n\n/** Page / route directory names allowed into slugs and module ids. */\nexport function isValidSlug(value: string): boolean {\n\treturn /^[a-z0-9-]+$/.test(value);\n}\n\n/** Naming for one (page, mode) pair — wp-build's `_wp_admin` infix. */\nfunction pageNames(page: GeneratedPage, mode: PageMode) {\n\tconst slugUnderscore = toUnderscore(page.slug);\n\tconst isWpAdmin = mode === 'wp-admin';\n\treturn {\n\t\t/** Script handle / module id / hook base: `settings-wp-admin`. */\n\t\thandle: isWpAdmin ? `${page.slug}-wp-admin` : page.slug,\n\t\t/** Function-name infix: `settings_wp_admin`. */\n\t\tfn: isWpAdmin ? `${slugUnderscore}_wp_admin` : slugUnderscore,\n\t\t/** Mount element id. */\n\t\tmountId: isWpAdmin ? `${page.slug}-wp-admin-app` : `${page.slug}-app`,\n\t};\n}\n\n/** The `.asset.php` sidecars whose classic handles the carrier must depend on. */\nfunction assetFileList(page: GeneratedPage): string[] {\n\tconst files: string[] = [];\n\tfor (const route of page.routes) {\n\t\tif (route.hasContent) files.push(`${route.dir}/content.asset.php`);\n\t\tif (route.hasRoute) files.push(`${route.dir}/route.asset.php`);\n\t}\n\treturn files;\n}\n\nfunction preloadPathsPhp(entries: RestPreloadEntry[], indent: string): string {\n\tif (entries.length === 0) return `${indent}// No REST paths configured.`;\n\treturn entries\n\t\t.map((entry) => {\n\t\t\tconst value = Array.isArray(entry)\n\t\t\t\t? `array( ${phpString(entry[0])}, ${phpString(entry[1])} )`\n\t\t\t\t: phpString(entry);\n\t\t\treturn `${indent}${value},`;\n\t\t})\n\t\t.join('\\n');\n}\n\nfunction initModulesPhp(initModules: string[], indent: string): string {\n\tif (initModules.length === 0) return `${indent}// No init modules configured.`;\n\treturn initModules\n\t\t.map(\n\t\t\t(moduleId) =>\n\t\t\t\t`${indent}$boot_dependencies[] = array( 'import' => 'static', 'id' => ${phpString(\n\t\t\t\t\tmoduleId,\n\t\t\t\t)} );`,\n\t\t)\n\t\t.join('\\n');\n}\n\n/* -------------------------------------------------------------------------\n * Shared page blocks\n * ---------------------------------------------------------------------- */\n\n/**\n * Globals, route/menu-item registrars, getters and the REST preloader —\n * wp-build duplicates this across `page.php.template` and\n * `page-wp-admin.php.template`; the only differences are the `_wp_admin`\n * infix and the full-page registrar's extra `$parent_type` argument.\n */\nfunction renderPageStateBlock(ctx: PhpContext, page: GeneratedPage, mode: PageMode): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst { handle, fn } = pageNames(page, mode);\n\tconst routesGlobal = `$${prefix}_${fn}_routes`;\n\tconst menuItemsGlobal = `$${prefix}_${fn}_menu_items`;\n\tconst parentTypeParam = mode === 'full-page' ? \", $parent_type = ''\" : '';\n\tconst parentTypeDoc =\n\t\tmode === 'full-page'\n\t\t\t? \" * @param string $parent_type Optional. Parent type: 'drilldown' or 'dropdown'.\\n\"\n\t\t\t: '';\n\tconst parentTypeBody =\n\t\tmode === 'full-page'\n\t\t\t? `\n\tif ( ! empty( $parent_type ) && in_array( $parent_type, array( 'drilldown', 'dropdown' ), true ) ) {\n\t\t$menu_item['parent_type'] = $parent_type;\n\t}\n`\n\t\t\t: '';\n\n\t// Pad the shorter assignment so the `=` line up, like wp-build's output.\n\tconst routesPad = ' '.repeat(Math.max(0, menuItemsGlobal.length - routesGlobal.length));\n\n\treturn `// Global storage for ${handle} routes and menu items.\nglobal ${routesGlobal}, ${menuItemsGlobal};\n${routesGlobal}${routesPad} = array();\n${menuItemsGlobal} = array();\n\n/**\n * Register a route for the ${handle} page.\n *\n * @param string $path Route path (e.g., '/types/$type/edit/$id').\n * @param string|null $content_module Script module ID for content (stage/inspector).\n * @param string|null $route_module Script module ID for route lifecycle hooks.\n */\nfunction ${prefix}_register_${fn}_route( $path, $content_module = null, $route_module = null ) {\n\tglobal ${routesGlobal};\n\n\t$route = array( 'path' => $path );\n\tif ( ! empty( $content_module ) ) {\n\t\t$route['content_module'] = $content_module;\n\t}\n\tif ( ! empty( $route_module ) ) {\n\t\t$route['route_module'] = $route_module;\n\t}\n\n\t${routesGlobal}[] = $route;\n}\n\n/**\n * Register a menu item for the ${handle} page.\n *\n * @param string $id Menu item ID.\n * @param string $label Display label.\n * @param string $to Route path to navigate to.\n * @param string $parent_id Optional. Parent menu item ID.\n${parentTypeDoc} */\nfunction ${prefix}_register_${fn}_menu_item( $id, $label, $to, $parent_id = ''${parentTypeParam} ) {\n\tglobal ${menuItemsGlobal};\n\n\t$menu_item = array(\n\t\t'id' => $id,\n\t\t'label' => $label,\n\t\t'to' => $to,\n\t);\n\n\tif ( ! empty( $parent_id ) ) {\n\t\t$menu_item['parent'] = $parent_id;\n\t}\n${parentTypeBody}\n\t${menuItemsGlobal}[] = $menu_item;\n}\n\n/**\n * Get all registered routes for the ${handle} page.\n *\n * @return array Array of route objects.\n */\nfunction ${prefix}_get_${fn}_routes() {\n\tglobal ${routesGlobal};\n\treturn ${routesGlobal} ?? array();\n}\n\n/**\n * Get all registered menu items for the ${handle} page.\n *\n * @return array Array of menu item objects.\n */\nfunction ${prefix}_get_${fn}_menu_items() {\n\tglobal ${menuItemsGlobal};\n\treturn ${menuItemsGlobal} ?? array();\n}\n\n/**\n * Preload REST API data for the ${handle} page.\n * Automatically called during page rendering.\n */\nfunction ${prefix}_${fn}_preload_data() {\n\t$preload_paths = array(\n${preloadPathsPhp(page.restPreload, '\\t\\t')}\n\t);\n\n\t// Use rest_preload_api_request to gather the preloaded data.\n\t$preload_data = array_reduce(\n\t\t$preload_paths,\n\t\t'rest_preload_api_request',\n\t\tarray()\n\t);\n\n\t// Register the preloading middleware with wp-api-fetch.\n\twp_add_inline_script(\n\t\t'wp-api-fetch',\n\t\tsprintf(\n\t\t\t'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );',\n\t\t\twp_json_encode( $preload_data )\n\t\t),\n\t\t'after'\n\t);\n}\n`;\n}\n\n/**\n * The prerequisites carrier: an empty-src classic script whose dependencies\n * are every classic handle the page's modules read off `window.*` (unioned\n * across the page's own sidecars and core's boot asset), plus the matching\n * style handles. Also where the inline bootstrap lands.\n */\nfunction renderCarrierBlock(ctx: PhpContext, page: GeneratedPage, mode: PageMode): string {\n\tconst { handle } = pageNames(page, mode);\n\tconst assetFiles = assetFileList(page)\n\t\t.map((file) => `\\t\\t__DIR__ . '/../../${file}',`)\n\t\t.join('\\n');\n\n\treturn `\t// Every classic script handle the page's modules read off window.* lives\n\t// in their .asset.php sidecars; the carrier depends on the union of them.\n\t$asset_files = array(\n${assetFiles}\n\t);\n\n\t$script_dependencies = array();\n\t$version = false;\n\t$has_assets = false;\n\n\tforeach ( $asset_files as $asset_file ) {\n\t\tif ( ! file_exists( $asset_file ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t$has_assets = true;\n\t\t$asset = require $asset_file;\n\t\tif ( ! empty( $asset['dependencies'] ) ) {\n\t\t\t$script_dependencies = array_merge( $script_dependencies, $asset['dependencies'] );\n\t\t}\n\t\tif ( false === $version && ! empty( $asset['version'] ) ) {\n\t\t\t$version = $asset['version'];\n\t\t}\n\t}\n\n\t// Core's boot module carries classic dependencies of its own.\n\t$boot_asset_file = ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php';\n\tif ( file_exists( $boot_asset_file ) ) {\n\t\t$boot_asset = require $boot_asset_file;\n\t\tif ( ! empty( $boot_asset['dependencies'] ) ) {\n\t\t\t$script_dependencies = array_merge( $script_dependencies, $boot_asset['dependencies'] );\n\t\t}\n\t}\n\n\t$script_dependencies = array_values( array_unique( $script_dependencies ) );\n\n\tif ( $has_assets ) {\n\t\t// This script serves two purposes:\n\t\t// 1. It ensures all the globals that are made available to the modules are loaded.\n\t\t// 2. It initializes the boot module as an inline script.\n\t\t// The src is \\`false\\`, not \\`''\\`: an empty-src carrier script.\n\t\twp_register_script( '${handle}-prerequisites', false, $script_dependencies, $version, true );\n`;\n}\n\n/** Boot dependency graph + loader module registration, shared by both modes. */\nfunction renderBootGraphBlock(ctx: PhpContext, page: GeneratedPage, mode: PageMode): string {\n\tconst { handle } = pageNames(page, mode);\n\n\treturn `\t\t// Register prerequisites style by filtering script dependencies to find registered styles.\n\t\t$style_dependencies = array_filter(\n\t\t\t$script_dependencies,\n\t\t\tfunction ( $handle ) {\n\t\t\t\treturn wp_style_is( $handle, 'registered' );\n\t\t\t}\n\t\t);\n\t\twp_register_style( '${handle}-prerequisites', false, $style_dependencies, $version );\n\n\t\t// Build dependencies for the ${handle} module.\n\t\t$boot_dependencies = array(\n\t\t\tarray(\n\t\t\t\t'import' => 'static',\n\t\t\t\t'id' => '@wordpress/boot',\n\t\t\t),\n\t\t);\n\n\t\t// Add init modules as static dependencies.\n${initModulesPhp(page.initModules, '\\t\\t')}\n\n\t\t// Add all registered routes as dependencies.\n\t\tforeach ( $routes as $route ) {\n\t\t\tif ( isset( $route['route_module'] ) ) {\n\t\t\t\t$boot_dependencies[] = array(\n\t\t\t\t\t'import' => 'static',\n\t\t\t\t\t'id' => $route['route_module'],\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( isset( $route['content_module'] ) ) {\n\t\t\t\t$boot_dependencies[] = array(\n\t\t\t\t\t'import' => 'dynamic',\n\t\t\t\t\t'id' => $route['content_module'],\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Filters the boot script-module dependencies for the\n\t\t * ${handle} page.\n\t\t *\n\t\t * Surfaces extending this page can append entries to the boot\n\t\t * dependency list. Each entry is an array with 'import' (string\n\t\t * 'static' or 'dynamic') and 'id' (script-module handle) keys.\n\t\t *\n\t\t * @param array $boot_dependencies Boot dependencies for the page.\n\t\t */\n\t\t$boot_dependencies = apply_filters(\n\t\t\t'${handle}_boot_dependencies',\n\t\t\t$boot_dependencies\n\t\t);\n\n\t\t// Dummy script module to ensure dependencies are loaded.\n\t\twp_register_script_module(\n\t\t\t'${handle}',\n\t\t\t$build_constants['build_url'] . 'modules/${page.slug}/loader.js',\n\t\t\t$boot_dependencies\n\t\t);\n\n\t\t// Enqueue the boot scripts and styles.\n\t\twp_enqueue_script( '${handle}-prerequisites' );\n\t\twp_enqueue_script_module( '${handle}' );\n\t\twp_enqueue_style( '${handle}-prerequisites' );\n\t}\n`;\n}\n\n/**\n * `{prefix}_register_{slug}_menu()` on `admin_menu`. One step beyond\n * wp-build, which leaves menu registration to the author.\n */\nfunction renderMenuBlock(ctx: PhpContext, page: GeneratedPage, mode: PageMode): string {\n\tif (!page.menu) return '';\n\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst slugUnderscore = toUnderscore(page.slug);\n\tconst { handle, fn } = pageNames(page, mode);\n\tconst menu = page.menu;\n\tconst capability = phpString(menu.capability ?? 'manage_options');\n\tconst title = `__( ${phpString(page.title)}, ${phpString(ctx.textdomain)} )`;\n\tconst renderCallback = phpString(`${prefix}_${fn}_render_page`);\n\tconst menuSlug = phpString(handle);\n\n\tlet call: string;\n\tif (menu.parent === false || menu.parent === 'toplevel') {\n\t\tconst icon = phpString(menu.icon ?? 'dashicons-admin-generic');\n\t\tconst position = typeof menu.position === 'number' ? String(menu.position) : 'null';\n\t\tcall = `\tadd_menu_page(\n\t\t${title},\n\t\t${title},\n\t\t${capability},\n\t\t${menuSlug},\n\t\t${renderCallback},\n\t\t${icon},\n\t\t${position}\n\t);`;\n\t} else if (menu.parent === undefined || menu.parent === 'options-general.php') {\n\t\tcall = `\tadd_options_page(\n\t\t${title},\n\t\t${title},\n\t\t${capability},\n\t\t${menuSlug},\n\t\t${renderCallback}\n\t);`;\n\t} else {\n\t\tcall = `\tadd_submenu_page(\n\t\t${phpString(menu.parent)},\n\t\t${title},\n\t\t${title},\n\t\t${capability},\n\t\t${menuSlug},\n\t\t${renderCallback}\n\t);`;\n\t}\n\n\treturn `\n/**\n * Register the admin menu entry for the ${handle} page.\n */\nfunction ${prefix}_register_${slugUnderscore}_menu() {\n${call}\n}\nadd_action( 'admin_menu', '${prefix}_register_${slugUnderscore}_menu' );\n`;\n}\n\n/* -------------------------------------------------------------------------\n * page.php — full-page takeover mode\n * ---------------------------------------------------------------------- */\n\nexport function renderPagePhp(ctx: PhpContext, page: GeneratedPage): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst mode: PageMode = 'full-page';\n\tconst { handle, fn, mountId } = pageNames(page, mode);\n\n\treturn `<?php\n/**\n * Page: ${handle}\n * Auto-generated by build process. Do not edit this file manually.\n *\n * Full-page takeover mode: renders its own HTML document and boots the app\n * with \\`init()\\`, so the wp-admin chrome is replaced entirely.\n *\n * @package ${ctx.prefix}\n */\n\n${renderPageStateBlock(ctx, page, mode)}\n/**\n * Render the ${handle} page.\n * Call this function from add_menu_page or add_submenu_page.\n */\nfunction ${prefix}_${fn}_render_page() {\n\t// Load build constants.\n\t$build_constants = require __DIR__ . '/../../constants.php';\n\n\t// Set current screen.\n\tset_current_screen();\n\n\t// Remove unwanted deprecated handler.\n\tremove_action( 'admin_head', 'wp_admin_bar_header' );\n\n\t// Remove unwanted scripts and styles that were enqueued during \\`admin_init\\`.\n\tforeach ( wp_scripts()->queue as $script ) {\n\t\twp_dequeue_script( $script );\n\t}\n\tforeach ( wp_styles()->queue as $style ) {\n\t\twp_dequeue_style( $style );\n\t}\n\n\t/**\n\t * Fires when the ${handle} page is initialized so extensions can register routes and menu items.\n\t */\n\tdo_action( '${handle}_init' );\n\n\t// Enqueue command palette assets for boot-based pages.\n\tif ( function_exists( 'wp_enqueue_command_palette_assets' ) ) {\n\t\twp_enqueue_command_palette_assets();\n\t}\n\n\t// Preload REST API data.\n\t${prefix}_${fn}_preload_data();\n\n\t// Get all registered routes and menu items.\n\t$menu_items = ${prefix}_get_${fn}_menu_items();\n\t$routes = ${prefix}_get_${fn}_routes();\n\n${renderCarrierBlock(ctx, page, mode)}\n\t\t// Add inline script to initialize the app.\n\t\t$init_modules = ${phpStringArray(page.initModules)};\n\t\twp_add_inline_script(\n\t\t\t'${handle}-prerequisites',\n\t\t\tsprintf(\n\t\t\t\t'import(\"@wordpress/boot\").then(mod => mod.init({mountId: \"%s\", menuItems: %s, routes: %s, initModules: %s, dashboardLink: \"%s\"}));',\n\t\t\t\t'${mountId}',\n\t\t\t\twp_json_encode( $menu_items, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\twp_json_encode( $routes, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\twp_json_encode( $init_modules, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\tesc_url( admin_url( '/' ) )\n\t\t\t)\n\t\t);\n\n${renderBootGraphBlock(ctx, page, mode)}\n\t// Output the HTML.\n\t?>\n\t<!DOCTYPE html>\n\t<html <?php language_attributes(); ?>>\n\t<head>\n\t\t<meta charset=\"<?php bloginfo( 'charset' ); ?>\">\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<title><?php echo esc_html( get_admin_page_title() ); ?></title>\n\t\t<style>\n\t\t\thtml {\n\t\t\t\tbackground: #f1f1f1;\n\t\t\t\tcolor: #444;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t\tfont-size: 13px;\n\t\t\t\tline-height: 1.4em;\n\t\t\t}\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t#wpadminbar { display: none; }\n\t\t</style>\n\t<?php\n\tglobal $hook_suffix;\n\t// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited\n\t$hook_suffix = '${handle}';\n\n\t// BEGIN see wp-admin/admin-header.php\n\tprint_admin_styles();\n\tprint_head_scripts();\n\n\t/** This action is documented in wp-admin/admin-header.php */\n\tdo_action( \"admin_head-{$hook_suffix}\" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores\n\n\t/** This action is documented in wp-admin/admin-header.php */\n\tdo_action( 'admin_head' );\n\t// END see wp-admin/admin-header.php\n\t?>\n\t</head>\n\t<body class=\"${handle}\">\n\t\t<div id=\"${mountId}\" style=\"height: 100vh; box-sizing: border-box;\"></div>\n\t<?php\n\t// BEGIN see wp-admin/admin-footer.php\n\n\t/** This action is documented in wp-admin/admin-footer.php */\n\tdo_action( 'admin_footer', '' );\n\n\t// Print import map first so it's available for inline scripts.\n\twp_script_modules()->print_import_map();\n\tprint_footer_scripts();\n\twp_script_modules()->print_enqueued_script_modules();\n\twp_script_modules()->print_script_module_preloads();\n\twp_script_modules()->print_script_module_data();\n\n\t/** This action is documented in wp-admin/admin-footer.php */\n\tdo_action( \"admin_footer-{$hook_suffix}\" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores\n\t// END see wp-admin/admin-footer.php\n\t?>\n\t</body>\n\t</html>\n\t<?php\n\texit;\n}\n\n/**\n * Intercept admin_init to render the page early.\n * This bypasses the default WordPress admin template.\n */\nfunction ${prefix}_${fn}_intercept_render() {\n\t// phpcs:ignore WordPress.Security.NonceVerification.Recommended\n\tif ( isset( $_GET['page'] ) && '${handle}' === $_GET['page'] ) {\n\t\t${prefix}_${fn}_render_page();\n\t\texit;\n\t}\n}\n\n// Hook the interceptor to admin_init.\nadd_action( 'admin_init', '${prefix}_${fn}_intercept_render' );\n${renderMenuBlock(ctx, page, mode)}`;\n}\n\n/* -------------------------------------------------------------------------\n * page-wp-admin.php — wp-admin integrated mode\n * ---------------------------------------------------------------------- */\n\nexport function renderPageWpAdminPhp(ctx: PhpContext, page: GeneratedPage): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst mode: PageMode = 'wp-admin';\n\tconst { handle, fn, mountId } = pageNames(page, mode);\n\n\treturn `<?php\n/**\n * Page: ${page.slug} (wp-admin integrated)\n * Auto-generated by build process. Do not edit this file manually.\n *\n * This version integrates with the standard WordPress admin interface,\n * keeping the wp-admin sidebar and scripts/styles intact.\n *\n * @package ${ctx.prefix}\n */\n\n${renderPageStateBlock(ctx, page, mode)}\n/**\n * Enqueue scripts and styles for the ${handle} page.\n * Hooked to admin_enqueue_scripts.\n *\n * @param string $hook_suffix The current admin page.\n */\nfunction ${prefix}_${fn}_enqueue_scripts( $hook_suffix ) {\n\t// Check all possible ways this page can be accessed:\n\t// 1. Menu page via admin.php?page=${handle}\n\t// 2. Direct file whose screen ID is '${page.slug}'\n\t$current_screen = get_current_screen();\n\t$is_our_page = (\n\t\t( isset( $_GET['page'] ) && '${handle}' === $_GET['page'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended\n\t\t( $current_screen && '${page.slug}' === $current_screen->id )\n\t);\n\n\tif ( ! $is_our_page ) {\n\t\treturn;\n\t}\n\n\t// Load build constants.\n\t$build_constants = require __DIR__ . '/../../constants.php';\n\n\t/**\n\t * Fires when the ${handle} page is initialized so extensions can register routes and menu items.\n\t */\n\tdo_action( '${handle}_init' );\n\n\t// Preload REST API data.\n\t${prefix}_${fn}_preload_data();\n\n\t// Get all registered routes.\n\t$routes = ${prefix}_get_${fn}_routes();\n\n${renderCarrierBlock(ctx, page, mode)}\n\t\t$init_modules = ${phpStringArray(page.initModules)};\n\n\t\t/*\n\t\t * Add inline script to initialize the app using initSinglePage (no menuItems).\n\t\t * The dynamic import is deferred until DOMContentLoaded so that all classic\n\t\t * script dependencies of @wordpress/boot (wp-private-apis, wp-components,\n\t\t * wp-theme, etc.) have finished parsing and executing before the boot module\n\t\t * evaluates. Otherwise, a modulepreloaded @wordpress/boot can win the race\n\t\t * against the classic-script-printing pass on fast CDN-fronted hosts in\n\t\t * Chrome, evaluating before wp.theme.privateApis is defined and throwing\n\t\t * \"Cannot unlock an undefined object\". See <https://core.trac.wordpress.org/ticket/65103>.\n\t\t */\n\t\t$init_js_function = <<<'JS'\n\t\t( mountId, routes, initModules ) => {\n\t\t\tconst run = async () => {\n\t\t\t\tconst mod = await import( \"@wordpress/boot\" );\n\t\t\t\tmod.initSinglePage( { mountId, routes, initModules } );\n\t\t\t};\n\t\t\tif ( document.readyState === \"loading\" ) {\n\t\t\t\tdocument.addEventListener( \"DOMContentLoaded\", run );\n\t\t\t} else {\n\t\t\t\trun();\n\t\t\t}\n\t\t}\n\t\tJS;\n\t\twp_add_inline_script(\n\t\t\t'${handle}-prerequisites',\n\t\t\tsprintf(\n\t\t\t\t'( %s )( %s, %s, %s );',\n\t\t\t\t$init_js_function,\n\t\t\t\twp_json_encode( '${mountId}', JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\twp_json_encode( $routes, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\twp_json_encode( $init_modules, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES )\n\t\t\t)\n\t\t);\n\n${renderBootGraphBlock(ctx, page, mode)}}\n\n/**\n * Render the ${handle} page.\n * Call this function from add_menu_page or add_submenu_page.\n * This renders within the normal WordPress admin interface.\n */\nfunction ${prefix}_${fn}_render_page() {\n\t?>\n\t<style>\n\t\t/* Critical styles to prevent layout shifts - inlined for immediate application */\n\n\t\t#wpwrap {\n\t\t\toverflow-y: auto;\n\t\t}\n\t\tbody {\n\t\t\tbackground: #fff;\n\t\t}\n\n\t\t/* Reset wp-admin padding */\n\t\t#wpcontent {\n\t\t\tpadding-inline-start: 0;\n\t\t}\n\t\t#wpbody-content {\n\t\t\tpadding-bottom: 0;\n\t\t}\n\n\t\t/* Hide legacy admin elements */\n\t\t#wpbody-content > div:not(.boot-layout-container):not(#screen-meta) {\n\t\t\tdisplay: none;\n\t\t}\n\t\t#wpfooter {\n\t\t\tdisplay: none;\n\t\t}\n\n\t\t/* Accessibility regions */\n\t\t.a11y-speak-region {\n\t\t\tinset-inline-start: -1px;\n\t\t\ttop: -1px;\n\t\t}\n\n\t\t/* Admin menu indicators */\n\t\tul#adminmenu a.wp-has-current-submenu::after,\n\t\tul#adminmenu > li.current > a.current::after {\n\t\t\tborder-inline-end-color: #fff;\n\t\t}\n\n\t\t/* Media frame fix */\n\t\t.media-frame select.attachment-filters:last-of-type {\n\t\t\twidth: auto;\n\t\t\tmax-width: 100%;\n\t\t}\n\n\t\t/* Responsive overflow fix for #wpwrap */\n\t\t@media (min-width: 782px) {\n\t\t\t#wpwrap {\n\t\t\t\toverflow-y: initial;\n\t\t\t}\n\t\t}\n\t</style>\n\t<div id=\"${mountId}\" class=\"boot-layout-container\"></div>\n\t<?php\n}\n\n// Hook the enqueue function to admin_enqueue_scripts.\nadd_action( 'admin_enqueue_scripts', '${prefix}_${fn}_enqueue_scripts' );\n${renderMenuBlock(ctx, page, mode)}`;\n}\n\n/* -------------------------------------------------------------------------\n * pages.php / build.php / constants.php\n * ---------------------------------------------------------------------- */\n\nexport function renderPagesPhp(ctx: PhpContext, pages: GeneratedPage[]): string {\n\tconst files: string[] = [];\n\tfor (const page of pages) {\n\t\tif (page.modes.includes('full-page')) {\n\t\t\tfiles.push(`\\t__DIR__ . '/pages/${page.slug}/page.php',`);\n\t\t}\n\t\tif (page.modes.includes('wp-admin')) {\n\t\t\tfiles.push(`\\t__DIR__ . '/pages/${page.slug}/page-wp-admin.php',`);\n\t\t}\n\t}\n\n\treturn `<?php\n/**\n * Pages loader - Auto-generated by build process.\n * Do not edit this file manually.\n *\n * @package ${ctx.prefix}\n */\n\n$${toUnderscore(ctx.prefix)}_page_files = array(\n${files.join('\\n')}\n);\n\nforeach ( $${toUnderscore(ctx.prefix)}_page_files as $page_file ) {\n\tif ( file_exists( $page_file ) ) {\n\t\trequire_once $page_file;\n\t}\n}\n`;\n}\n\nexport function renderBuildPhp(ctx: PhpContext): string {\n\treturn `<?php\n/**\n * Main entry point for auto-generated asset registration.\n * Auto-generated by build process. Do not edit this file manually.\n *\n * Require this file from your plugin or theme:\n *\n * require_once __DIR__ . '/dist/build.php';\n *\n * @package ${ctx.prefix}\n */\n\n// Load routes registration.\n$routes_file = __DIR__ . '/routes.php';\nif ( file_exists( $routes_file ) ) {\n\trequire_once $routes_file;\n}\n\n// Load pages registration.\n$pages_file = __DIR__ . '/pages.php';\nif ( file_exists( $pages_file ) ) {\n\trequire_once $pages_file;\n}\n`;\n}\n\nexport function renderConstantsPhp(ctx: PhpContext): string {\n\treturn `<?php\n/**\n * Plugin constants - Auto-generated by build process.\n * Do not edit this file manually.\n *\n * Returns an array of constants for use in other generated files.\n *\n * @package ${ctx.prefix}\n */\n\nreturn array(\n\t'version' => ${phpString(ctx.version)},\n\t'build_url' => ${ctx.baseUrl},\n);\n`;\n}\n\n/* -------------------------------------------------------------------------\n * routes.php / routes/registry.php\n * ---------------------------------------------------------------------- */\n\nexport function renderRouteRegistryPhp(ctx: PhpContext, pages: GeneratedPage[]): string {\n\tconst rows: string[] = [];\n\tfor (const page of pages) {\n\t\tfor (const route of page.routes) {\n\t\t\trows.push(`\tarray(\n\t\t'name' => ${phpString(route.name)},\n\t\t'path' => ${phpString(route.path)},\n\t\t'page' => ${phpString(page.slug)},\n\t\t'dir' => ${phpString(route.dir)},\n\t\t'has_route' => ${route.hasRoute ? 'true' : 'false'},\n\t\t'has_content' => ${route.hasContent ? 'true' : 'false'},\n\t),`);\n\t\t}\n\t}\n\n\treturn `<?php\n/**\n * Route registry - Auto-generated by build process.\n * Do not edit this file manually.\n *\n * @package ${ctx.prefix}\n */\n\nreturn array(\n${rows.join('\\n')}\n);\n`;\n}\n\n/** wp-build's `routes-page-functions.php.template`, one block per page. */\nfunction renderRoutesPageFunctions(ctx: PhpContext, page: GeneratedPage): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst slugUnderscore = toUnderscore(page.slug);\n\tconst blocks: string[] = [];\n\n\tfor (const mode of ALL_PAGE_MODES) {\n\t\tif (!page.modes.includes(mode)) continue;\n\t\tconst { handle, fn } = pageNames(page, mode);\n\t\tconst label = mode === 'wp-admin' ? 'wp-admin mode' : 'full-page mode';\n\t\tblocks.push(`/**\n * Register routes for the ${page.slug} page (${label}).\n */\nfunction ${prefix}_register_${fn}_page_routes() {\n\tglobal $${prefix}_${slugUnderscore}_routes_data;\n\t${prefix}_register_page_routes( $${prefix}_${slugUnderscore}_routes_data, '${prefix}_register_${fn}_route' );\n}\nadd_action( '${handle}_init', '${prefix}_register_${fn}_page_routes' );`);\n\t}\n\n\treturn `// Page-specific route registration functions for ${page.slug}.\n${blocks.join('\\n\\n')}`;\n}\n\nexport function renderRoutesPhp(ctx: PhpContext, pages: GeneratedPage[]): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst pageFunctions = pages.map((page) => renderRoutesPageFunctions(ctx, page)).join('\\n\\n');\n\n\treturn `<?php\n/**\n * Routes registration - Auto-generated by build process.\n * Registers all routes on their respective page init hooks.\n * Do not edit this file manually.\n *\n * @package ${ctx.prefix}\n */\n\n// Load routes registry.\n$routes_file = __DIR__ . '/routes/registry.php';\nif ( ! file_exists( $routes_file ) ) {\n\treturn;\n}\n\n$routes = require $routes_file;\n\n// Group routes by page and store in globals for page-specific functions.\n$routes_by_page = array();\nforeach ( $routes as $route ) {\n\t$page_slug = $route['page'];\n\tif ( ! isset( $routes_by_page[ $page_slug ] ) ) {\n\t\t$routes_by_page[ $page_slug ] = array();\n\t}\n\t$routes_by_page[ $page_slug ][] = $route;\n}\n\n// Store routes data in globals for each page.\nforeach ( $routes_by_page as $page_slug => $page_routes ) {\n\t$page_slug_underscore = str_replace( '-', '_', $page_slug );\n\t$GLOBALS[ '${prefix}_' . $page_slug_underscore . '_routes_data' ] = $page_routes;\n}\n\n/**\n * Generic helper function to register routes for a page.\n *\n * @param array $page_routes Array of route data for the page.\n * @param string $register_function_name Name of the function to call for registering each route.\n */\nfunction ${prefix}_register_page_routes( $page_routes, $register_function_name ) {\n\t// Load build constants.\n\t$build_constants = require __DIR__ . '/constants.php';\n\n\tforeach ( $page_routes as $route ) {\n\t\t$content_handle = null;\n\t\t$route_handle = null;\n\t\t$module_prefix = ${phpString(ctx.handlePrefix)} . '/routes/' . $route['page'] . '/' . $route['name'];\n\n\t\t// Register the content module when the build produced one.\n\t\tif ( $route['has_content'] ) {\n\t\t\t$content_asset_path = __DIR__ . '/' . $route['dir'] . '/content.asset.php';\n\t\t\tif ( file_exists( $content_asset_path ) ) {\n\t\t\t\t$content_asset = require $content_asset_path;\n\t\t\t\t$content_handle = $module_prefix . '/content';\n\t\t\t\t// Deregister first to override any previously registered version\n\t\t\t\t// (e.g., Core's default modules when running as a plugin).\n\t\t\t\twp_deregister_script_module( $content_handle );\n\t\t\t\twp_register_script_module(\n\t\t\t\t\t$content_handle,\n\t\t\t\t\t$build_constants['build_url'] . $route['dir'] . '/content.js',\n\t\t\t\t\t$content_asset['module_dependencies'] ?? array(),\n\t\t\t\t\t$content_asset['version'] ?? false\n\t\t\t\t);\n\n\t\t\t\t// The page stylesheet, when the entry imported any CSS.\n\t\t\t\t$content_style_path = __DIR__ . '/' . $route['dir'] . '/content.css';\n\t\t\t\tif ( file_exists( $content_style_path ) ) {\n\t\t\t\t\t$style_handle = str_replace( '/', '-', $content_handle );\n\t\t\t\t\twp_register_style(\n\t\t\t\t\t\t$style_handle,\n\t\t\t\t\t\t$build_constants['build_url'] . $route['dir'] . '/content.css',\n\t\t\t\t\t\tarray(),\n\t\t\t\t\t\t$content_asset['version'] ?? false\n\t\t\t\t\t);\n\t\t\t\t\twp_enqueue_style( $style_handle );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Register the route module when the build produced one.\n\t\tif ( $route['has_route'] ) {\n\t\t\t$route_asset_path = __DIR__ . '/' . $route['dir'] . '/route.asset.php';\n\t\t\tif ( file_exists( $route_asset_path ) ) {\n\t\t\t\t$route_asset = require $route_asset_path;\n\t\t\t\t$route_handle = $module_prefix . '/route';\n\t\t\t\t// Deregister first to override any previously registered version\n\t\t\t\t// (e.g., Core's default modules when running as a plugin).\n\t\t\t\twp_deregister_script_module( $route_handle );\n\t\t\t\twp_register_script_module(\n\t\t\t\t\t$route_handle,\n\t\t\t\t\t$build_constants['build_url'] . $route['dir'] . '/route.js',\n\t\t\t\t\t$route_asset['module_dependencies'] ?? array(),\n\t\t\t\t\t$route_asset['version'] ?? false\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Register route with page.\n\t\tif ( function_exists( $register_function_name ) ) {\n\t\t\tcall_user_func( $register_function_name, $route['path'], $content_handle, $route_handle );\n\t\t}\n\t}\n}\n\n${pageFunctions}\n`;\n}\n\n/* -------------------------------------------------------------------------\n * Entry point\n * ---------------------------------------------------------------------- */\n\n/**\n * Every generated PHP file for the given pages, as dist-relative\n * `{ fileName, source }` pairs ready for Rollup's `emitFile`.\n */\nexport function generatePhpFiles(ctx: PhpContext, pages: GeneratedPage[]): GeneratedPhpFile[] {\n\tconst files: GeneratedPhpFile[] = [\n\t\t{ fileName: 'build.php', source: renderBuildPhp(ctx) },\n\t\t{ fileName: 'constants.php', source: renderConstantsPhp(ctx) },\n\t];\n\n\tif (pages.length === 0) return files;\n\n\tfiles.push({ fileName: 'pages.php', source: renderPagesPhp(ctx, pages) });\n\n\tfor (const page of pages) {\n\t\tif (page.modes.includes('full-page')) {\n\t\t\tfiles.push({\n\t\t\t\tfileName: `pages/${page.slug}/page.php`,\n\t\t\t\tsource: renderPagePhp(ctx, page),\n\t\t\t});\n\t\t}\n\t\tif (page.modes.includes('wp-admin')) {\n\t\t\tfiles.push({\n\t\t\t\tfileName: `pages/${page.slug}/page-wp-admin.php`,\n\t\t\t\tsource: renderPageWpAdminPhp(ctx, page),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst hasRoutes = pages.some((page) => page.routes.length > 0);\n\tif (hasRoutes) {\n\t\tfiles.push({ fileName: 'routes.php', source: renderRoutesPhp(ctx, pages) });\n\t\tfiles.push({\n\t\t\tfileName: 'routes/registry.php',\n\t\t\tsource: renderRouteRegistryPhp(ctx, pages),\n\t\t});\n\t}\n\n\treturn files;\n}\n","/**\n * vite-plugin-wp-admin-pages\n *\n * Builds `@wordpress/boot`-powered admin pages (WP 6.9+ Script Module admin\n * screens) as part of the regular **module pass**, replacing the hand-rolled\n * `esbuild.boot.mjs` pipelines projects run next to their main build.\n *\n * Every immediate subdirectory of `adminPagesDir` containing a `content`\n * entry file is a page. Each page contributes one or two Rollup inputs plus\n * a generated `loader.js` anchor:\n *\n * dist/modules/<page>/\n * ├── content.js # ESM entry (required)\n * ├── content.asset.php # via wpExternals\n * ├── content.css # CSS imported by content.js, normalized here\n * ├── route.js # ESM entry (optional)\n * ├── route.asset.php # via wpExternals\n * ├── loader.js # empty anchor module PHP registers the graph on\n * └── routes/<name>/ # additional routes (content / route entries)\n *\n * The externalization strategy those pages need (`@wordpress/boot` stays a\n * bare ESM specifier, `@wordpress/dataviews` gets bundled, `wp-components`\n * & friends become `window.wp.*` reads with their classic handles collected\n * into `.asset.php`) falls out of [`wpExternals`](./wp-externals.ts) — this\n * plugin only owns discovery, the loader anchor, the CSS file naming, and\n * (opt-in via `php`) the generated PHP registration layer described in\n * [`php-templates.ts`](./php-templates.ts).\n *\n * JSX note: Vite does not parse JSX out of `.js` files. Pages whose entries\n * contain JSX must use `.jsx` / `.tsx`.\n */\nimport { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport type { Plugin, Rollup, UserConfig } from 'vite';\nimport {\n\tALL_PAGE_MODES,\n\tDEFAULT_REST_PRELOAD,\n\tgeneratePhpFiles,\n\tisValidPhpIdentifier,\n\tisValidSlug,\n\ttype GeneratedPage,\n\ttype GeneratedPhpFile,\n\ttype GeneratedRoute,\n\ttype PageMenu,\n\ttype PageMode,\n\ttype PhpContext,\n\ttype RestPreloadEntry,\n} from './php-templates';\n\n/** Source extensions probed for a page entry, in wpBlocks' resolution order. */\nconst ENTRY_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'] as const;\n\n/** Anchor module PHP registers with the page's static/dynamic import graph. */\nconst LOADER_SOURCE = '// Empty module loader for page dependencies.\\n';\n\n/**\n * Enables generation of the `@wordpress/build`-style PHP layer next to the\n * built modules — `build.php`, `constants.php`, `pages.php`,\n * `pages/<slug>/page{,-wp-admin}.php`, `routes.php` and\n * `routes/registry.php`. A consuming plugin then needs no hand-written PHP\n * beyond `require_once __DIR__ . '/dist/build.php';`.\n */\nexport interface WpAdminPagesPhpOptions {\n\t/**\n\t * Identifier prefix for every generated function, global and hook.\n\t * Default: `wpPlugin.name` from the consumer's package.json, else its\n\t * (de-scoped) package name. Dashes are underscored for PHP identifiers;\n\t * the result must be a valid PHP identifier fragment.\n\t */\n\tprefix?: string;\n\t/**\n\t * Script Module id prefix — route modules are registered as\n\t * `<handlePrefix>/routes/<page>/<route>/{content,route}`.\n\t * Default: `wpPlugin.handlePrefix`, else `prefix`.\n\t */\n\thandlePrefix?: string;\n\t/**\n\t * Raw PHP expression for the URL of the build directory, interpolated\n\t * into `constants.php` verbatim. Default `plugin_dir_url( __FILE__ )`\n\t * (`build.php` and friends live in the build directory itself).\n\t */\n\tbaseUrl?: string;\n\t/** Text domain for the generated `__()` calls. Default `'default'`. */\n\ttextdomain?: string;\n}\n\nexport interface WpAdminPagesOptions {\n\t/**\n\t * Directory whose immediate subdirectories are pages. A subdirectory is\n\t * a page when it contains a `content.{tsx,ts,jsx,js}` entry; a sibling\n\t * `route.{tsx,ts,jsx,js}` is picked up when present, as are additional\n\t * routes under `<page>/routes/<name>/`.\n\t */\n\tadminPagesDir: string;\n\t/**\n\t * Admin pages are Script Modules, so they only build in the module pass.\n\t * In `'script'` mode (the default, matching the other plugins) this\n\t * plugin contributes nothing.\n\t */\n\tbuildType?: 'script' | 'module';\n\t/**\n\t * Generate the PHP registration layer. Presence enables it; every key\n\t * is optional.\n\t */\n\tphp?: WpAdminPagesPhpOptions;\n\t/**\n\t * Root whose `package.json` supplies the generated `version` and the\n\t * `wpPlugin.name` / `wpPlugin.handlePrefix` defaults. Defaults to Vite's\n\t * `root`, else `process.cwd()`.\n\t */\n\tprojectRoot?: string;\n}\n\n/** Per-page `page.json`, all keys optional. */\ninterface PageConfig {\n\ttitle?: string;\n\tmenu?: PageMenu;\n\tinit?: string[];\n\tmodes?: PageMode[];\n\trestPreload?: RestPreloadEntry[];\n}\n\n/** An additional route under `<page>/routes/<name>/`. */\ninterface AdminPageRoute {\n\t/** Route directory name. */\n\tname: string;\n\t/** Route path — `route.json` `path`, else `/<name>`. */\n\tpath: string;\n\t/** Absolute path of the resolved `content` entry, when present. */\n\tcontent?: string;\n\t/** Absolute path of the resolved `route` entry, when present. */\n\troute?: string;\n}\n\ninterface AdminPage {\n\t/** Page directory name — the `modules/<dirName>/…` output namespace. */\n\tdirName: string;\n\t/** Absolute path of the resolved `content` entry. */\n\tcontent: string;\n\t/** Absolute path of the resolved `route` entry, when the page has one. */\n\troute?: string;\n\t/** Additional routes discovered under `<page>/routes/`. */\n\tsubRoutes: AdminPageRoute[];\n\t/** Parsed `page.json` (`{}` when the page has none). */\n\tpageConfig: PageConfig;\n}\n\nexport function wpAdminPages(options: WpAdminPagesOptions): Plugin {\n\tconst buildType = options.buildType ?? 'script';\n\tlet pages: AdminPage[] = [];\n\tlet phpFiles: GeneratedPhpFile[] = [];\n\n\treturn {\n\t\tname: 'wp-admin-pages',\n\t\tenforce: 'pre',\n\n\t\tconfig(userConfig?: UserConfig) {\n\t\t\t// Pages are module-pass only — the script pass contributes nothing.\n\t\t\tif (buildType !== 'module') return;\n\n\t\t\tconst adminPagesDirAbs = resolve(process.cwd(), options.adminPagesDir);\n\t\t\tpages = discoverPages(adminPagesDirAbs);\n\t\t\t// No pages (yet) — stay out of the config entirely.\n\t\t\tif (pages.length === 0) return;\n\n\t\t\t// PHP generation is opt-in; validation runs here so a bad prefix\n\t\t\t// or page slug fails the config, not the write.\n\t\t\tif (options.php) {\n\t\t\t\tconst projectRoot = resolve(\n\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\toptions.projectRoot ?? userConfig?.root ?? '.',\n\t\t\t\t);\n\t\t\t\tconst phpContext = resolvePhpContext(options.php, projectRoot);\n\t\t\t\tphpFiles = generatePhpFiles(phpContext, pages.map(toGeneratedPage));\n\t\t\t}\n\n\t\t\tconst input: Record<string, string> = {};\n\t\t\tfor (const page of pages) {\n\t\t\t\tinput[`modules/${page.dirName}/content`] = page.content;\n\t\t\t\tif (page.route) input[`modules/${page.dirName}/route`] = page.route;\n\t\t\t\tfor (const subRoute of page.subRoutes) {\n\t\t\t\t\tconst base = `modules/${page.dirName}/routes/${subRoute.name}`;\n\t\t\t\t\tif (subRoute.content) input[`${base}/content`] = subRoute.content;\n\t\t\t\t\tif (subRoute.route) input[`${base}/route`] = subRoute.route;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tbuild: {\n\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\t// Vite defaults app builds to `preserveEntrySignatures:\n\t\t\t\t\t\t// false`, which tree-shakes an entry's exports away. A\n\t\t\t\t\t\t// boot page IS its exports (`export const stage`,\n\t\t\t\t\t\t// `export const route` — imported by\n\t\t\t\t\t\t// `@wordpress/boot` at runtime), so they have to\n\t\t\t\t\t\t// survive.\n\t\t\t\t\t\tpreserveEntrySignatures: 'exports-only',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\n\t\tgenerateBundle(_outputOptions, bundle) {\n\t\t\tif (buildType !== 'module' || pages.length === 0) return;\n\n\t\t\t// The loader is an empty anchor: PHP registers it as the page's\n\t\t\t// Script Module and hangs the static/dynamic import graph\n\t\t\t// (`@wordpress/boot`, `<slug>-route`, `<slug>-content`) off it.\n\t\t\tfor (const page of pages) {\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: `modules/${page.dirName}/loader.js`,\n\t\t\t\t\tsource: LOADER_SOURCE,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// The generated PHP registration layer (opt-in via `php`).\n\t\t\tfor (const file of phpFiles) {\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: file.fileName,\n\t\t\t\t\tsource: file.source,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!bundle) return;\n\n\t\t\tconst entryNames = new Set<string>();\n\t\t\tfor (const page of pages) {\n\t\t\t\tentryNames.add(`modules/${page.dirName}/content`);\n\t\t\t\tif (page.route) entryNames.add(`modules/${page.dirName}/route`);\n\t\t\t\tfor (const subRoute of page.subRoutes) {\n\t\t\t\t\tconst base = `modules/${page.dirName}/routes/${subRoute.name}`;\n\t\t\t\t\tif (subRoute.content) entryNames.add(`${base}/content`);\n\t\t\t\t\tif (subRoute.route) entryNames.add(`${base}/route`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Which chunks reference which extracted stylesheet, captured\n\t\t\t// before anything is rewritten.\n\t\t\tconst referencingChunks = new Map<string, Set<string>>();\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk') continue;\n\t\t\t\tfor (const cssFileName of output.viteMetadata?.importedCss ?? []) {\n\t\t\t\t\tlet chunks = referencingChunks.get(cssFileName);\n\t\t\t\t\tif (!chunks) referencingChunks.set(cssFileName, (chunks = new Set()));\n\t\t\t\t\tchunks.add(fileName);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst pageEntries: Array<[string, Rollup.OutputChunk]> = [];\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk' || !output.isEntry) continue;\n\t\t\t\tif (!entryNames.has(output.name)) continue;\n\t\t\t\tpageEntries.push([fileName, output]);\n\t\t\t}\n\n\t\t\t// Every chunk reachable from an entry that is *not* a page — the\n\t\t\t// safety net for deleting the stylesheets we fold into the\n\t\t\t// per-page CSS files.\n\t\t\tconst pageEntryFileNames = new Set(pageEntries.map(([fileName]) => fileName));\n\t\t\tconst reachableFromOtherEntries = new Set<string>();\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk' || !output.isEntry) continue;\n\t\t\t\tif (pageEntryFileNames.has(fileName)) continue;\n\t\t\t\tfor (const chunkFileName of reachableChunks(bundle, fileName)) {\n\t\t\t\t\treachableFromOtherEntries.add(chunkFileName);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst foldedIntoPages = new Set<string>();\n\n\t\t\tfor (const [fileName, chunk] of pageEntries) {\n\t\t\t\t// Vite names an extracted stylesheet after the chunk that\n\t\t\t\t// carries it (`content.css` at the dist root for an entry,\n\t\t\t\t// `<shared-chunk>.css` when two pages share the import), so\n\t\t\t\t// the contract path `modules/<page>/content.css` has to be\n\t\t\t\t// re-established here.\n\t\t\t\tconst cssFileNames = collectImportedCss(bundle, fileName);\n\t\t\t\tif (cssFileNames.length === 0) continue;\n\n\t\t\t\tconst targetFileName = fileName.replace(/\\.m?js$/, '.css');\n\t\t\t\tconst sources: string[] = [];\n\t\t\t\tfor (const cssFileName of cssFileNames) {\n\t\t\t\t\tconst asset = bundle[cssFileName];\n\t\t\t\t\tif (!asset || asset.type !== 'asset') continue;\n\t\t\t\t\tsources.push(assetSourceToString(asset.source));\n\t\t\t\t\tif (cssFileName !== targetFileName) foldedIntoPages.add(cssFileName);\n\t\t\t\t}\n\t\t\t\tif (sources.length === 0) continue;\n\n\t\t\t\t// Already exactly the contract path (single, correctly named\n\t\t\t\t// stylesheet) — nothing to re-emit.\n\t\t\t\tif (!(cssFileNames.length === 1 && cssFileNames[0] === targetFileName)) {\n\t\t\t\t\tthis.emitFile({\n\t\t\t\t\t\ttype: 'asset',\n\t\t\t\t\t\tfileName: targetFileName,\n\t\t\t\t\t\tsource: sources.join('\\n'),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Point the entry at its own stylesheet so wpExternals folds\n\t\t\t\t// the CSS into the `.asset.php` version hash.\n\t\t\t\tconst importedCss = chunk.viteMetadata?.importedCss;\n\t\t\t\tif (importedCss) {\n\t\t\t\t\tfor (const cssFileName of [...importedCss]) importedCss.delete(cssFileName);\n\t\t\t\t\timportedCss.add(targetFileName);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Drop the originals, but only when no other entry (a block's view\n\t\t\t// module, a theme entry) still needs them.\n\t\t\tfor (const cssFileName of foldedIntoPages) {\n\t\t\t\tconst referencing = referencingChunks.get(cssFileName) ?? new Set<string>();\n\t\t\t\tlet pagesOnly = true;\n\t\t\t\tfor (const chunkFileName of referencing) {\n\t\t\t\t\tif (reachableFromOtherEntries.has(chunkFileName)) pagesOnly = false;\n\t\t\t\t}\n\t\t\t\tif (!pagesOnly) continue;\n\n\t\t\t\tdelete bundle[cssFileName];\n\t\t\t\tfor (const output of Object.values(bundle)) {\n\t\t\t\t\tif (output.type !== 'chunk') continue;\n\t\t\t\t\toutput.viteMetadata?.importedCss.delete(cssFileName);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Immediate subdirectories of `adminPagesDirAbs` that carry a `content`\n * entry. A missing directory is a silent no-op (same as wpBlocks globbing a\n * directory that isn't there yet).\n */\nfunction discoverPages(adminPagesDirAbs: string): AdminPage[] {\n\tlet dirEntries;\n\ttry {\n\t\tdirEntries = readdirSync(adminPagesDirAbs, { withFileTypes: true });\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst pages: AdminPage[] = [];\n\tfor (const dirEntry of [...dirEntries].sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tif (!dirEntry.isDirectory()) continue;\n\t\tconst pageDir = join(adminPagesDirAbs, dirEntry.name);\n\n\t\t// No `content` entry → not a page (shared helpers, `components/`, …).\n\t\tconst content = resolveEntryFile(pageDir, 'content');\n\t\tif (!content) continue;\n\n\t\tconst route = resolveEntryFile(pageDir, 'route');\n\t\tpages.push({\n\t\t\tdirName: dirEntry.name,\n\t\t\tcontent,\n\t\t\t...(route ? { route } : {}),\n\t\t\tsubRoutes: discoverSubRoutes(pageDir),\n\t\t\tpageConfig: readPageConfig(pageDir),\n\t\t});\n\t}\n\treturn pages;\n}\n\n/**\n * Additional routes: every immediate subdirectory of `<pageDir>/routes/` that\n * carries a `content` or `route` entry. `route.json`'s `path` overrides the\n * default `/<name>`.\n */\nfunction discoverSubRoutes(pageDir: string): AdminPageRoute[] {\n\tconst routesDir = join(pageDir, 'routes');\n\tlet dirEntries;\n\ttry {\n\t\tdirEntries = readdirSync(routesDir, { withFileTypes: true });\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst subRoutes: AdminPageRoute[] = [];\n\tfor (const dirEntry of [...dirEntries].sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tif (!dirEntry.isDirectory()) continue;\n\t\tconst routeDir = join(routesDir, dirEntry.name);\n\t\tconst content = resolveEntryFile(routeDir, 'content');\n\t\tconst route = resolveEntryFile(routeDir, 'route');\n\t\t// Neither entry → not a route (shared code under `routes/`).\n\t\tif (!content && !route) continue;\n\n\t\tsubRoutes.push({\n\t\t\tname: dirEntry.name,\n\t\t\tpath: readRoutePath(routeDir, dirEntry.name),\n\t\t\t...(content ? { content } : {}),\n\t\t\t...(route ? { route } : {}),\n\t\t});\n\t}\n\treturn subRoutes;\n}\n\n/** Read and validate the optional `page.json` next to a page's entries. */\nfunction readPageConfig(pageDir: string): PageConfig {\n\tconst configPath = join(pageDir, 'page.json');\n\tif (!existsSync(configPath)) return {};\n\n\tconst raw = readJsonFile(configPath);\n\tconst config: PageConfig = {};\n\n\tif (raw.title !== undefined) {\n\t\tif (typeof raw.title !== 'string') {\n\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"title\" must be a string.`);\n\t\t}\n\t\tconfig.title = raw.title;\n\t}\n\n\tif (raw.menu !== undefined) {\n\t\tif (typeof raw.menu !== 'object' || raw.menu === null || Array.isArray(raw.menu)) {\n\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"menu\" must be an object.`);\n\t\t}\n\t\tconst menu = raw.menu as Record<string, unknown>;\n\t\tconst parsed: PageMenu = {};\n\t\tif (menu.parent !== undefined) {\n\t\t\tif (typeof menu.parent !== 'string' && menu.parent !== false) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`wpAdminPages: ${configPath} — \"menu.parent\" must be a string or false.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tparsed.parent = menu.parent;\n\t\t}\n\t\tif (menu.capability !== undefined) {\n\t\t\tif (typeof menu.capability !== 'string') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`wpAdminPages: ${configPath} — \"menu.capability\" must be a string.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tparsed.capability = menu.capability;\n\t\t}\n\t\tif (menu.position !== undefined) {\n\t\t\tif (typeof menu.position !== 'number' || !Number.isFinite(menu.position)) {\n\t\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"menu.position\" must be a number.`);\n\t\t\t}\n\t\t\tparsed.position = menu.position;\n\t\t}\n\t\tif (menu.icon !== undefined) {\n\t\t\tif (typeof menu.icon !== 'string') {\n\t\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"menu.icon\" must be a string.`);\n\t\t\t}\n\t\t\tparsed.icon = menu.icon;\n\t\t}\n\t\tconfig.menu = parsed;\n\t}\n\n\tif (raw.init !== undefined) {\n\t\tif (!Array.isArray(raw.init) || raw.init.some((id) => typeof id !== 'string')) {\n\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"init\" must be an array of strings.`);\n\t\t}\n\t\tfor (const moduleId of raw.init as string[]) {\n\t\t\tif (!/^[A-Za-z0-9@._/-]+$/.test(moduleId)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`wpAdminPages: ${configPath} — \"init\" entry \"${moduleId}\" is not a valid script module id.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconfig.init = raw.init as string[];\n\t}\n\n\tif (raw.modes !== undefined) {\n\t\tif (\n\t\t\t!Array.isArray(raw.modes) ||\n\t\t\traw.modes.length === 0 ||\n\t\t\traw.modes.some((mode) => !ALL_PAGE_MODES.includes(mode as PageMode))\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`wpAdminPages: ${configPath} — \"modes\" must be a non-empty array of ${ALL_PAGE_MODES.map(\n\t\t\t\t\t(mode) => `\"${mode}\"`,\n\t\t\t\t).join(' / ')}.`,\n\t\t\t);\n\t\t}\n\t\tconfig.modes = raw.modes as PageMode[];\n\t}\n\n\tif (raw.restPreload !== undefined) {\n\t\tif (!Array.isArray(raw.restPreload)) {\n\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"restPreload\" must be an array.`);\n\t\t}\n\t\tconst entries: RestPreloadEntry[] = [];\n\t\tfor (const entry of raw.restPreload) {\n\t\t\tif (typeof entry === 'string') {\n\t\t\t\tentries.push(entry);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tArray.isArray(entry) &&\n\t\t\t\tentry.length === 2 &&\n\t\t\t\tentry.every((part) => typeof part === 'string')\n\t\t\t) {\n\t\t\t\tentries.push([entry[0] as string, entry[1] as string]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\t`wpAdminPages: ${configPath} — \"restPreload\" entries must be a path string or a [path, method] pair.`,\n\t\t\t);\n\t\t}\n\t\tconfig.restPreload = entries;\n\t}\n\n\treturn config;\n}\n\n/** `route.json`'s `path`, defaulting to `/<name>`. */\nfunction readRoutePath(routeDir: string, name: string): string {\n\tconst configPath = join(routeDir, 'route.json');\n\tif (!existsSync(configPath)) return `/${name}`;\n\n\tconst raw = readJsonFile(configPath);\n\tif (raw.path === undefined) return `/${name}`;\n\tif (typeof raw.path !== 'string' || !raw.path.startsWith('/')) {\n\t\tthrow new Error(`wpAdminPages: ${configPath} — \"path\" must be a string starting with \"/\".`);\n\t}\n\treturn raw.path;\n}\n\nfunction readJsonFile(filePath: string): Record<string, unknown> {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(readFileSync(filePath, 'utf8'));\n\t} catch (error) {\n\t\tthrow new Error(`wpAdminPages: could not parse ${filePath} — ${(error as Error).message}`, {\n\t\t\tcause: error,\n\t\t});\n\t}\n\tif (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n\t\tthrow new Error(`wpAdminPages: ${filePath} must contain a JSON object.`);\n\t}\n\treturn parsed as Record<string, unknown>;\n}\n\n/** Internal registry name of the page-root `content` / `route` pair (path `/`). */\nconst PAGE_ROOT_ROUTE_NAME = 'index';\n\n/** Discovery result → the shape the PHP templates consume. */\nfunction toGeneratedPage(page: AdminPage): GeneratedPage {\n\tif (!isValidSlug(page.dirName)) {\n\t\tthrow new Error(\n\t\t\t`wpAdminPages: page directory \"${page.dirName}\" is not a valid page slug — use lowercase letters, digits and dashes.`,\n\t\t);\n\t}\n\n\tconst routes: GeneratedRoute[] = [\n\t\t{\n\t\t\tname: PAGE_ROOT_ROUTE_NAME,\n\t\t\tpath: '/',\n\t\t\tdir: `modules/${page.dirName}`,\n\t\t\thasContent: true,\n\t\t\thasRoute: !!page.route,\n\t\t},\n\t];\n\n\tfor (const subRoute of page.subRoutes) {\n\t\tif (!isValidSlug(subRoute.name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`wpAdminPages: route directory \"${page.dirName}/routes/${subRoute.name}\" is not a valid route name — use lowercase letters, digits and dashes.`,\n\t\t\t);\n\t\t}\n\t\troutes.push({\n\t\t\tname: subRoute.name,\n\t\t\tpath: subRoute.path,\n\t\t\tdir: `modules/${page.dirName}/routes/${subRoute.name}`,\n\t\t\thasContent: !!subRoute.content,\n\t\t\thasRoute: !!subRoute.route,\n\t\t});\n\t}\n\n\tconst config = page.pageConfig;\n\treturn {\n\t\tslug: page.dirName,\n\t\ttitle: config.title ?? titleCase(page.dirName),\n\t\tmodes: config.modes ?? ALL_PAGE_MODES,\n\t\tinitModules: config.init ?? [],\n\t\trestPreload: config.restPreload ?? DEFAULT_REST_PRELOAD,\n\t\t...(config.menu ? { menu: config.menu } : {}),\n\t\troutes,\n\t};\n}\n\n/** `site-health` → `Site Health`. Fallback when `page.json` has no title. */\nfunction titleCase(slug: string): string {\n\treturn slug\n\t\t.split('-')\n\t\t.filter(Boolean)\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t.join(' ');\n}\n\n/**\n * Resolve prefix / handle prefix / base URL / version, defaulting from the\n * consumer's package.json the way `@wordpress/build` does (`wpPlugin.name`).\n */\nfunction resolvePhpContext(php: WpAdminPagesPhpOptions, projectRoot: string): PhpContext {\n\tconst packageJsonPath = join(projectRoot, 'package.json');\n\tlet packageJson: {\n\t\tname?: string;\n\t\tversion?: string;\n\t\twpPlugin?: { name?: string; handlePrefix?: string };\n\t} = {};\n\tif (existsSync(packageJsonPath)) {\n\t\tpackageJson = readJsonFile(packageJsonPath) as typeof packageJson;\n\t}\n\n\tconst packageName = (packageJson.name ?? '').replace(/^@[^/]+\\//, '');\n\tconst prefix = php.prefix ?? packageJson.wpPlugin?.name ?? packageName;\n\tif (!prefix) {\n\t\tthrow new Error(\n\t\t\t'wpAdminPages: PHP generation needs an identifier prefix — set `adminPages.php.prefix`, or `wpPlugin.name` / `name` in package.json.',\n\t\t);\n\t}\n\tif (!isValidPhpIdentifier(prefix)) {\n\t\tthrow new Error(\n\t\t\t`wpAdminPages: \"${prefix}\" is not a usable PHP identifier prefix. Use letters, digits, underscores and dashes (dashes become underscores), and don't start with a digit. Set \\`adminPages.php.prefix\\` or \\`wpPlugin.name\\` in package.json.`,\n\t\t);\n\t}\n\n\tconst handlePrefix = php.handlePrefix ?? packageJson.wpPlugin?.handlePrefix ?? prefix;\n\tif (!/^[A-Za-z0-9@._/-]+$/.test(handlePrefix)) {\n\t\tthrow new Error(\n\t\t\t`wpAdminPages: \"${handlePrefix}\" is not a usable script module id prefix. Use letters, digits and \\`@ . _ / -\\`.`,\n\t\t);\n\t}\n\n\tconst textdomain = php.textdomain ?? 'default';\n\tif (!/^[A-Za-z0-9._-]+$/.test(textdomain)) {\n\t\tthrow new Error(\n\t\t\t`wpAdminPages: \"${textdomain}\" is not a usable text domain. Use letters, digits, dots, underscores and dashes.`,\n\t\t);\n\t}\n\n\treturn {\n\t\tprefix,\n\t\thandlePrefix,\n\t\tbaseUrl: php.baseUrl ?? 'plugin_dir_url( __FILE__ )',\n\t\tversion: packageJson.version ?? '0.0.0',\n\t\ttextdomain,\n\t};\n}\n\n/** Probe `<pageDir>/<basename>.{tsx,ts,jsx,js}` in wpBlocks' order. */\nfunction resolveEntryFile(pageDir: string, basename: string): string | null {\n\tfor (const extension of ENTRY_EXTENSIONS) {\n\t\tconst candidate = join(pageDir, `${basename}${extension}`);\n\t\tif (existsSync(candidate)) return candidate;\n\t}\n\treturn null;\n}\n\n/** Chunk file names reachable from `entryFileName` (static + dynamic imports). */\nfunction reachableChunks(bundle: Rollup.OutputBundle, entryFileName: string): Set<string> {\n\tconst visited = new Set<string>();\n\tconst queue = [entryFileName];\n\twhile (queue.length > 0) {\n\t\tconst fileName = queue.shift()!;\n\t\tif (visited.has(fileName)) continue;\n\t\tconst output = bundle[fileName];\n\t\t// Missing names are externals, not chunks in this bundle.\n\t\tif (!output || output.type !== 'chunk') continue;\n\t\tvisited.add(fileName);\n\t\tfor (const imported of [...(output.imports ?? []), ...(output.dynamicImports ?? [])]) {\n\t\t\tif (!visited.has(imported)) queue.push(imported);\n\t\t}\n\t}\n\treturn visited;\n}\n\n/**\n * Stylesheets reachable from an entry chunk, dependencies first (post-order)\n * so the concatenated CSS keeps a sane cascade.\n */\nfunction collectImportedCss(bundle: Rollup.OutputBundle, entryFileName: string): string[] {\n\tconst visited = new Set<string>();\n\tconst seen = new Set<string>();\n\tconst ordered: string[] = [];\n\n\tconst visit = (fileName: string): void => {\n\t\tif (visited.has(fileName)) return;\n\t\tvisited.add(fileName);\n\t\tconst output = bundle[fileName];\n\t\tif (!output || output.type !== 'chunk') return;\n\t\tfor (const imported of [...(output.imports ?? []), ...(output.dynamicImports ?? [])]) {\n\t\t\tvisit(imported);\n\t\t}\n\t\tfor (const cssFileName of output.viteMetadata?.importedCss ?? []) {\n\t\t\tif (seen.has(cssFileName)) continue;\n\t\t\tseen.add(cssFileName);\n\t\t\tordered.push(cssFileName);\n\t\t}\n\t};\n\n\tvisit(entryFileName);\n\treturn ordered;\n}\n\nfunction assetSourceToString(source: string | Uint8Array): string {\n\treturn typeof source === 'string' ? source : Buffer.from(source).toString('utf8');\n}\n","/**\n * vite-plugin-wp-blocks\n *\n * Scans `blocksDir` for `block.json` files and turns the `file:`-prefixed\n * asset references into Rollup input entries. Also copies each `block.json`\n * and any sibling PHP files into the dist tree so registration paths line up.\n *\n * Recognized block.json fields:\n * editorScript, script, viewScript, scriptModule, viewScriptModule,\n * style, editorStyle, viewStyle\n */\nimport { readFileSync, existsSync } from 'node:fs';\nimport { createHash } from 'node:crypto';\nimport { dirname, extname, join, relative, resolve } from 'node:path';\nimport fg from 'fast-glob';\nimport type { Plugin } from 'vite';\n\nconst SCRIPT_FIELDS = ['editorScript', 'script', 'viewScript'] as const;\nconst MODULE_FIELDS = ['scriptModule', 'viewScriptModule'] as const;\nconst STYLE_FIELDS = ['style', 'editorStyle', 'viewStyle'] as const;\n\ntype BlockJson = Partial<\n\tRecord<\n\t\t(typeof SCRIPT_FIELDS | typeof MODULE_FIELDS | typeof STYLE_FIELDS)[number],\n\t\tstring | string[]\n\t>\n>;\n\nexport interface WpBlocksOptions {\n\tblocksDir: string;\n\tbuildType?: 'script' | 'module';\n\t/**\n\t * Emit `blocks-manifest.php` (returns one PHP array of all block.json\n\t * contents). Lets PHP use `wp_register_block_types_from_metadata_collection`\n\t * (WP 6.7+) instead of N filesystem reads + JSON parses on every request.\n\t * Default: `true`.\n\t */\n\temitManifest?: boolean;\n\t/**\n\t * Block directory names (relative to `blocksDir`) to skip entirely —\n\t * neither discovered as entries nor included in the manifest.\n\t */\n\tskip?: string[];\n}\n\n/**\n * Virtual entry used to keep an entry-less module pass alive. A dual-pass\n * consumer runs `vite build --mode modules` unconditionally, but most\n * projects start with zero Script Module blocks — and Rollup/Rolldown\n * error on an empty input. The stub gives the pass one no-op entry, and\n * `generateBundle` deletes its chunk so nothing extra lands in dist/.\n */\nconst EMPTY_MODULE_PASS_ENTRY = '\\0wp-blocks-empty-module-pass';\n\nexport function wpBlocks(options: WpBlocksOptions): Plugin {\n\tconst buildType = options.buildType ?? 'script';\n\tconst emitManifest = options.emitManifest ?? true;\n\tconst skip = new Set(options.skip ?? []);\n\tlet blocksDirAbs: string;\n\n\treturn {\n\t\tname: 'wp-blocks',\n\t\tenforce: 'pre',\n\n\t\tconfig() {\n\t\t\tblocksDirAbs = resolve(process.cwd(), options.blocksDir);\n\t\t\treturn {\n\t\t\t\tbuild: {\n\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\tinput: discoverEntries(blocksDirAbs, buildType, skip),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\n\t\toptions(inputOptions) {\n\t\t\t// Module pass with no entries at all (no Script Module blocks and\n\t\t\t// no user-supplied input) → substitute the no-op stub entry so the\n\t\t\t// build succeeds as a no-op instead of erroring.\n\t\t\tif (buildType !== 'module') return null;\n\t\t\tconst input = inputOptions.input;\n\t\t\tconst isEmpty =\n\t\t\t\tinput == null ||\n\t\t\t\t(Array.isArray(input) && input.length === 0) ||\n\t\t\t\t(typeof input === 'object' &&\n\t\t\t\t\t!Array.isArray(input) &&\n\t\t\t\t\tObject.keys(input).length === 0);\n\t\t\tif (!isEmpty) return null;\n\t\t\treturn {\n\t\t\t\t...inputOptions,\n\t\t\t\tinput: { 'wp-blocks-empty-module-pass': EMPTY_MODULE_PASS_ENTRY },\n\t\t\t};\n\t\t},\n\n\t\tresolveId(source) {\n\t\t\treturn source === EMPTY_MODULE_PASS_ENTRY ? source : null;\n\t\t},\n\n\t\tload(id) {\n\t\t\treturn id === EMPTY_MODULE_PASS_ENTRY ? 'export {};' : null;\n\t\t},\n\n\t\tasync buildStart() {\n\t\t\t// Watch every block.json so adding a new block triggers a reload in dev.\n\t\t\tconst blockJsons = await fg(`${blocksDirAbs.replace(/\\\\/g, '/')}/**/block.json`, {\n\t\t\t\tabsolute: true,\n\t\t\t});\n\t\t\tfor (const file of blockJsons) {\n\t\t\t\tthis.addWatchFile(file);\n\t\t\t}\n\t\t},\n\n\t\tasync generateBundle(_outputOptions, bundle) {\n\t\t\t// Drop the stub chunk from an entry-less module pass (runs in the\n\t\t\t// pre phase, before wpExternals' post-phase generateBundle would\n\t\t\t// emit an .asset.php for it).\n\t\t\tfor (const [fileName, item] of Object.entries(bundle ?? {})) {\n\t\t\t\tif (item.type === 'chunk' && item.facadeModuleId === EMPTY_MODULE_PASS_ENTRY) {\n\t\t\t\t\tdelete bundle[fileName];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Only the script pass copies block.json + PHP and emits the manifest.\n\t\t\t// In a dual (script + module) build both passes write to the same dist\n\t\t\t// dir, and these outputs are identical either way — gating to the\n\t\t\t// script pass keeps the second pass purely additive.\n\t\t\tif (buildType !== 'script') return;\n\n\t\t\tconst files = await fg(\n\t\t\t\t[\n\t\t\t\t\t`${blocksDirAbs.replace(/\\\\/g, '/')}/**/block.json`,\n\t\t\t\t\t`${blocksDirAbs.replace(/\\\\/g, '/')}/**/*.php`,\n\t\t\t\t],\n\t\t\t\t{ absolute: true },\n\t\t\t);\n\t\t\tfor (const file of files) {\n\t\t\t\tconst relativePath = relative(blocksDirAbs, file).replace(/\\\\/g, '/');\n\t\t\t\t// block.json gets `file:` refs rewritten so they point at the\n\t\t\t\t// built output (.tsx → .js, .scss → .css), and a `version`\n\t\t\t\t// gets stamped from the style content hash when missing.\n\t\t\t\tconst isBlockJson = relativePath.endsWith('block.json');\n\t\t\t\tconst source = isBlockJson\n\t\t\t\t\t? transformBlockJson(readFileSync(file, 'utf8'), file)\n\t\t\t\t\t: readFileSync(file);\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: `blocks/${relativePath}`,\n\t\t\t\t\tsource,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (emitManifest) {\n\t\t\t\tconst manifest = buildBlocksManifest(blocksDirAbs, skip);\n\t\t\t\tif (manifest) {\n\t\t\t\t\tthis.emitFile({\n\t\t\t\t\t\ttype: 'asset',\n\t\t\t\t\t\tfileName: 'blocks-manifest.php',\n\t\t\t\t\t\tsource: manifest,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Rewrite `file:` references in block.json so they point at the built\n * output, and stamp a `version` from the source style content hash when\n * the block doesn't declare one.\n *\n * editorScript / script / viewScript / scriptModule / viewScriptModule → .js\n * style / editorStyle / viewStyle → .css\n * version (missing) ← SHA-256 of each `file:` style/viewStyle's source\n *\n * Why hash the *source* styles (not the built ones)? The goal is a stable\n * cache-bust key that changes only when authors edit content. Built CSS\n * bytes are sensitive to incidental postcss/minifier output drift; source\n * bytes aren't.\n */\nfunction transformBlockJson(raw: string, blockJsonPath: string): string {\n\tlet parsed: Record<string, unknown>;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn raw;\n\t}\n\n\tconst scriptFields = [\n\t\t'editorScript',\n\t\t'script',\n\t\t'viewScript',\n\t\t'scriptModule',\n\t\t'viewScriptModule',\n\t];\n\tconst styleFields = ['style', 'editorStyle', 'viewStyle'];\n\n\tconst rewriteRef = (ref: unknown, builtExtension: '.js' | '.css'): unknown => {\n\t\tif (typeof ref !== 'string' || !ref.startsWith('file:')) return ref;\n\t\treturn ref.replace(/\\.(tsx?|jsx?|s?css|sass)$/, builtExtension);\n\t};\n\n\t// Version stamping has to happen BEFORE rewriting refs so we hash the\n\t// source file (e.g. style.scss), not the renamed one (style.css).\n\tconst explicitVersion = typeof parsed.version === 'string' && parsed.version.length > 0;\n\tif (!explicitVersion) {\n\t\tconst blockDir = dirname(blockJsonPath);\n\t\tconst versionHash = hashStyleContent(parsed, ['style', 'viewStyle'], blockDir);\n\t\tif (versionHash) {\n\t\t\tparsed.version = versionHash;\n\t\t}\n\t}\n\n\tfor (const field of scriptFields) {\n\t\tconst fieldValue = parsed[field];\n\t\tif (Array.isArray(fieldValue)) {\n\t\t\tparsed[field] = fieldValue.map((ref) => rewriteRef(ref, '.js'));\n\t\t} else {\n\t\t\tparsed[field] = rewriteRef(fieldValue, '.js');\n\t\t}\n\t}\n\tfor (const field of styleFields) {\n\t\tconst fieldValue = parsed[field];\n\t\tif (Array.isArray(fieldValue)) {\n\t\t\tparsed[field] = fieldValue.map((ref) => rewriteRef(ref, '.css'));\n\t\t} else {\n\t\t\tparsed[field] = rewriteRef(fieldValue, '.css');\n\t\t}\n\t}\n\n\treturn JSON.stringify(parsed, null, '\\t') + '\\n';\n}\n\n/**\n * SHA-256 the concatenated source contents of every `file:` ref in the\n * given style fields. Returns `''` if no style file refs were found —\n * which signals to leave `version` unset.\n */\nfunction hashStyleContent(\n\tmetadata: Record<string, unknown>,\n\tfields: string[],\n\tblockDir: string,\n): string {\n\tconst hash = createHash('sha256');\n\tlet hashedAnyFile = false;\n\n\tfor (const field of fields) {\n\t\tconst fieldValue = metadata[field];\n\t\tconst refs = Array.isArray(fieldValue) ? fieldValue : [fieldValue];\n\t\tfor (const ref of refs) {\n\t\t\tif (typeof ref !== 'string' || !ref.startsWith('file:')) continue;\n\t\t\tconst relativePath = ref.replace(/^file:/, '');\n\t\t\tconst absolutePath = join(blockDir, relativePath);\n\t\t\ttry {\n\t\t\t\thash.update(readFileSync(absolutePath));\n\t\t\t\thashedAnyFile = true;\n\t\t\t} catch {\n\t\t\t\t// Style file missing — skip; the block.json author can fix.\n\t\t\t}\n\t\t}\n\t}\n\n\treturn hashedAnyFile ? hash.digest('hex') : '';\n}\n\n/**\n * Build the WP 6.7+ blocks manifest — one PHP file returning\n * `array( '<dir>' => <block.json contents>, ... )`. Consumed by\n * `wp_register_block_types_from_metadata_collection( $dir, $manifest )`.\n *\n * The manifest's metadata also needs `file:` refs rewritten — same reason\n * as the per-block.json transform above.\n */\nfunction buildBlocksManifest(blocksDirAbs: string, skip: Set<string>): string | null {\n\tconst blockJsons = fg.sync(`${blocksDirAbs.replace(/\\\\/g, '/')}/**/block.json`, {\n\t\tabsolute: true,\n\t});\n\n\tconst entries: Array<[string, unknown]> = [];\n\tfor (const file of blockJsons) {\n\t\ttry {\n\t\t\tconst metadata = JSON.parse(transformBlockJson(readFileSync(file, 'utf8'), file));\n\t\t\t// Key = directory containing block.json, relative to blocksDir.\n\t\t\tconst blockDirName = relative(blocksDirAbs, file)\n\t\t\t\t.replace(/[\\\\/]block\\.json$/, '')\n\t\t\t\t.replace(/\\\\/g, '/');\n\t\t\tif (skip.has(blockDirName)) continue;\n\t\t\tentries.push([blockDirName, metadata]);\n\t\t} catch {\n\t\t\t// Skip malformed block.json.\n\t\t}\n\t}\n\n\tif (entries.length === 0) return null;\n\n\tconst body = entries\n\t\t.map(([blockDirName, metadata]) => `\\t'${blockDirName}' => ${phpExport(metadata, 1)},`)\n\t\t.join('\\n');\n\n\treturn `<?php\\n// This file is generated. Do not modify it manually.\\nreturn array(\\n${body}\\n);\\n`;\n}\n\n/** Minimal JSON → PHP array literal exporter. Handles strings/numbers/bools/arrays/objects. */\nfunction phpExport(value: unknown, indent: number): string {\n\tconst pad = '\\t'.repeat(indent);\n\tconst padInner = '\\t'.repeat(indent + 1);\n\n\tif (value === null) return 'null';\n\tif (typeof value === 'boolean') return value ? 'true' : 'false';\n\tif (typeof value === 'number') return String(value);\n\tif (typeof value === 'string') return `'${value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n\tif (Array.isArray(value)) {\n\t\tif (value.length === 0) return 'array()';\n\t\tconst items = value.map((item) => `${padInner}${phpExport(item, indent + 1)}`).join(',\\n');\n\t\treturn `array(\\n${items},\\n${pad})`;\n\t}\n\tif (typeof value === 'object') {\n\t\tconst keys = Object.keys(value as Record<string, unknown>);\n\t\tif (keys.length === 0) return 'array()';\n\t\tconst items = keys\n\t\t\t.map((key) => {\n\t\t\t\tconst entryValue = (value as Record<string, unknown>)[key];\n\t\t\t\tconst phpKey = `'${key.replace(/'/g, \"\\\\'\")}'`;\n\t\t\t\treturn `${padInner}${phpKey} => ${phpExport(entryValue, indent + 1)}`;\n\t\t\t})\n\t\t\t.join(',\\n');\n\t\treturn `array(\\n${items},\\n${pad})`;\n\t}\n\treturn 'null';\n}\n\nfunction discoverEntries(\n\tblocksDirAbs: string,\n\tbuildType: 'script' | 'module',\n\tskip: Set<string>,\n): Record<string, string> {\n\tconst entries: Record<string, string> = {};\n\n\tconst blockJsons = fg.sync(`${blocksDirAbs.replace(/\\\\/g, '/')}/**/block.json`, {\n\t\tabsolute: true,\n\t});\n\n\tfor (const blockJsonPath of blockJsons) {\n\t\tconst blockDirName = relative(blocksDirAbs, blockJsonPath)\n\t\t\t.replace(/[\\\\/]block\\.json$/, '')\n\t\t\t.replace(/\\\\/g, '/');\n\t\tif (skip.has(blockDirName)) continue;\n\n\t\tlet metadata: BlockJson;\n\t\ttry {\n\t\t\tmetadata = JSON.parse(readFileSync(blockJsonPath, 'utf8')) as BlockJson;\n\t\t} catch {\n\t\t\t// Empty/malformed block.json is normal during scaffolding — skip silently.\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst fields =\n\t\t\tbuildType === 'module'\n\t\t\t\t? (MODULE_FIELDS as readonly string[])\n\t\t\t\t: ([...SCRIPT_FIELDS, ...STYLE_FIELDS] as readonly string[]);\n\n\t\tconst refs: string[] = [];\n\t\tfor (const field of fields) {\n\t\t\tconst fieldValue = (metadata as Record<string, unknown>)[field];\n\t\t\tif (typeof fieldValue === 'string') refs.push(fieldValue);\n\t\t\telse if (Array.isArray(fieldValue))\n\t\t\t\trefs.push(...fieldValue.filter((item): item is string => typeof item === 'string'));\n\t\t}\n\n\t\tfor (const ref of refs) {\n\t\t\tif (!ref.startsWith('file:')) continue; // handles aren't files, skip\n\t\t\tconst declaredPath = ref.replace(/^file:/, '');\n\t\t\t// Strip extension so we can resolve to whatever source extension exists.\n\t\t\tconst pathWithoutExtension = declaredPath.replace(\n\t\t\t\t/\\.(js|ts|tsx|jsx|css|scss|sass)$/,\n\t\t\t\t'',\n\t\t\t);\n\t\t\tconst candidatePaths = [\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.tsx`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.ts`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.jsx`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.js`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.scss`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.sass`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.css`),\n\t\t\t];\n\t\t\tconst sourcePath = candidatePaths.find((candidate) => existsSync(candidate));\n\t\t\tif (!sourcePath) {\n\t\t\t\tconsole.warn(`[wp-blocks] no source file found for ${ref} in ${blockJsonPath}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst entryName = `blocks/${relative(blocksDirAbs, sourcePath)\n\t\t\t\t.replace(extname(sourcePath), '')\n\t\t\t\t.replace(/\\\\/g, '/')}`;\n\n\t\t\tentries[entryName] = sourcePath;\n\t\t}\n\t}\n\n\treturn entries;\n}\n","/**\n * vite-plugin-wp-block-styles\n *\n * Every stylesheet under `blocksStylesDir` becomes its own entry, so each\n * gets a dedicated CSS file in dist that PHP can selectively enqueue\n * per block.\n *\n * Source: `assets/css/blocks/<block-name>/<file>.scss`\n * Output: `dist/autoenqueue/<block-name>/<file>.css`\n *\n * Guarantee: one output stylesheet per source stylesheet, always. Rollup\n * (and Rolldown) content-address emitted assets, so two byte-identical\n * outputs — copy-pasted per-block styles, or placeholder files that are\n * comment-only and minify to nothing — collapse into a single emitted\n * file even though `assetFileNames` gives them distinct names. The\n * second name then silently never lands in dist, and PHP still enqueues\n * it, producing a 404. To prevent that, every discovered source gets a\n * unique marker rule appended at `transform` time so no two outputs can\n * ever be byte-identical; `generateBundle` strips the marker back out of\n * the emitted CSS, then double-checks every expected output actually\n * made it into the bundle.\n */\nimport { extname, resolve, relative } from 'node:path';\nimport { realpathSync } from 'node:fs';\nimport fg from 'fast-glob';\nimport type { Plugin } from 'vite';\n\nexport interface WpBlockStylesOptions {\n\tblocksStylesDir: string;\n}\n\n/**\n * Resolves symlinks so the source path a `transform` id carries always\n * matches the path discovered in `config()`. Vite resolves module ids\n * through `fs.realpath`, but `fast-glob`'s output isn't realpath'd — on\n * macOS `os.tmpdir()` itself is a `/var` -> `/private/var` symlink, so\n * without this every id lookup below would silently miss inside a tmp\n * fixture and the marker would never get appended.\n */\nfunction normalizePath(filePath: string): string {\n\ttry {\n\t\treturn realpathSync.native(filePath);\n\t} catch {\n\t\treturn filePath;\n\t}\n}\n\n/** Custom property carrying the dedup-busting marker. Namespaced to avoid colliding with real declarations. */\nconst MARKER_PROPERTY = '--wp-vite-entry';\n\n/**\n * Matches the marker declaration only — not the surrounding `:root` rule,\n * which may already exist in the source and carry real declarations that\n * must survive. Tolerant of minifier whitespace/quote-style changes.\n */\nconst MARKER_DECLARATION_RE = new RegExp(\n\t`${MARKER_PROPERTY}\\\\s*:\\\\s*(?:\"[^\"]*\"|'[^']*')\\\\s*;?`,\n\t'g',\n);\n\n/** A `:root` rule left empty once the marker declaration is stripped out of it. */\nconst EMPTY_ROOT_RULE_RE = /:root\\s*\\{\\s*\\}/g;\n\n/**\n * The marker rule appended to a source stylesheet. `.sass` is indentation\n * syntax — no braces or semicolons allowed — everything else (`.css`,\n * `.scss`) accepts plain CSS syntax, which a custom property on `:root`\n * survives sass compilation and cssnano/lightningcss minification intact\n * because minifiers can't safely rewrite an arbitrary string value.\n */\nfunction markerRule(entryName: string, isIndentedSass: boolean): string {\n\tif (isIndentedSass) {\n\t\treturn `\\n:root\\n\\t${MARKER_PROPERTY}: \"${entryName}\"\\n`;\n\t}\n\treturn `\\n:root{${MARKER_PROPERTY}:\"${entryName}\"}\\n`;\n}\n\n/** Strips the marker declaration, and any `:root{}` left empty by doing so, from emitted CSS. */\nfunction stripMarker(source: string): string {\n\treturn source.replace(MARKER_DECLARATION_RE, '').replace(EMPTY_ROOT_RULE_RE, '');\n}\n\nexport function wpBlockStyles(options: WpBlockStylesOptions): Plugin {\n\tlet stylesDirAbs: string;\n\t// Absolute source path -> `autoenqueue/<name>` entry name, populated in\n\t// `config()` so `transform`/`generateBundle` can map source -> output\n\t// without re-globbing.\n\tconst entryNameByFile = new Map<string, string>();\n\n\treturn {\n\t\tname: 'wp-block-styles',\n\t\tenforce: 'pre',\n\n\t\tconfig() {\n\t\t\tstylesDirAbs = resolve(process.cwd(), options.blocksStylesDir);\n\n\t\t\tconst stylesheets = fg.sync(\n\t\t\t\t`${stylesDirAbs.replace(/\\\\/g, '/')}/**/*.{css,scss,sass}`,\n\t\t\t\t{ absolute: true },\n\t\t\t);\n\n\t\t\tentryNameByFile.clear();\n\t\t\tconst entries: Record<string, string> = {};\n\t\t\tfor (const filePath of stylesheets) {\n\t\t\t\tconst blockName = relative(stylesDirAbs, filePath)\n\t\t\t\t\t.replace(extname(filePath), '')\n\t\t\t\t\t.replace(/\\\\/g, '/');\n\t\t\t\tconst entryName = `autoenqueue/${blockName}`;\n\t\t\t\tentries[entryName] = filePath;\n\t\t\t\tentryNameByFile.set(normalizePath(filePath), entryName);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tbuild: {\n\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\tinput: entries,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\n\t\ttransform(code, id) {\n\t\t\t// Strip query/hash suffixes some pipelines append to module ids\n\t\t\t// before matching against the discovered source paths.\n\t\t\tconst [rawPath] = id.split('?');\n\t\t\tconst filePath = normalizePath(rawPath);\n\t\t\tconst entryName = entryNameByFile.get(filePath);\n\t\t\tif (!entryName) return null;\n\n\t\t\treturn code + markerRule(entryName, extname(rawPath) === '.sass');\n\t\t},\n\n\t\tgenerateBundle(_options, bundle) {\n\t\t\t// Expected output fileName -> source path, for both stripping and\n\t\t\t// the missing-output safety net below.\n\t\t\tconst expected = new Map<string, string>();\n\t\t\tfor (const [filePath, entryName] of entryNameByFile) {\n\t\t\t\texpected.set(`${entryName}.css`, filePath);\n\t\t\t}\n\n\t\t\tfor (const output of Object.values(bundle)) {\n\t\t\t\tif (output.type !== 'asset' || !expected.has(output.fileName)) continue;\n\t\t\t\tif (typeof output.source === 'string') {\n\t\t\t\t\toutput.source = stripMarker(output.source);\n\t\t\t\t} else {\n\t\t\t\t\toutput.source = Buffer.from(\n\t\t\t\t\t\tstripMarker(Buffer.from(output.source).toString('utf-8')),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst missing: string[] = [];\n\t\t\tfor (const [fileName, filePath] of expected) {\n\t\t\t\tif (!(fileName in bundle)) missing.push(`${fileName} (from ${filePath})`);\n\t\t\t}\n\t\t\tif (missing.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'wpBlockStyles: expected stylesheet(s) missing from the build output — ' +\n\t\t\t\t\t\t'each source under blocksStylesDir must produce its own dist file:\\n' +\n\t\t\t\t\t\tmissing.map((entry) => ` - ${entry}`).join('\\n'),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * vite-plugin-wp-copy-assets\n *\n * Copies `assets/**` to `dist/` so theme/plugin PHP can reference paths\n * like `dist/images/logo.svg` even though those files never pass through\n * the bundler.\n *\n * Default pattern:\n * `**\\/*.{jpg,jpeg,png,gif,webp,avif,ico,svg,eot,ttf,woff,woff2,otf}`\n *\n * Path semantics: a file at `<copyAssetsDir>/images/logo.svg` lands at\n * `dist/images/logo.svg` (the `copyAssetsDir` is the \"context\", and the\n * relative subpath is preserved).\n */\nimport { readFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport fg from 'fast-glob';\nimport type { Plugin } from 'vite';\n\nconst DEFAULT_PATTERN = '**/*.{jpg,jpeg,png,gif,webp,avif,ico,svg,eot,ttf,woff,woff2,otf}';\n\nexport interface WpCopyAssetsOptions {\n\t/** Source directory (default: `./assets`). */\n\tcopyAssetsDir: string;\n\t/** Override the glob pattern (relative to `copyAssetsDir`). */\n\tpattern?: string;\n\t/** Only run during the script pass — module pass would emit duplicates. */\n\tbuildType?: 'script' | 'module';\n}\n\nexport function wpCopyAssets(options: WpCopyAssetsOptions): Plugin {\n\tconst pattern = options.pattern ?? DEFAULT_PATTERN;\n\tconst buildType = options.buildType ?? 'script';\n\tlet copyDirAbs: string;\n\n\treturn {\n\t\tname: `wp-copy-assets(${buildType})`,\n\t\tenforce: 'pre',\n\n\t\tconfig() {\n\t\t\tcopyDirAbs = resolve(process.cwd(), options.copyAssetsDir);\n\t\t},\n\n\t\tasync generateBundle() {\n\t\t\t// Module pass would write the same files a second time; skip.\n\t\t\tif (buildType !== 'script') return;\n\n\t\t\tconst matches = await fg(pattern, {\n\t\t\t\tcwd: copyDirAbs,\n\t\t\t\tabsolute: true,\n\t\t\t\tonlyFiles: true,\n\t\t\t});\n\n\t\t\tfor (const file of matches) {\n\t\t\t\tconst relativePath = relative(copyDirAbs, file).replace(/\\\\/g, '/');\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: relativePath,\n\t\t\t\t\tsource: readFileSync(file),\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * Package-metadata reader for the metadata-driven externals path.\n *\n * Mirrors `@wordpress/wp-build`'s `package-utils.mjs`. Resolves a package's\n * `package.json` via Node's module-resolution and surfaces the two fields\n * that determine whether a package is externalizable:\n *\n * wpScript: true\n * Package is registered as a classic <script> in WP core.\n * Externalize against `window.wp.<camelCased name>` with the\n * script handle `wp-<name>`.\n *\n * wpScriptModuleExports: string | Record<string, string>\n * Package is registered as a Script Module. The value lists the\n * entry points; root import maps to `'.'` or a string value,\n * subpath imports (`@wordpress/blocks/sub/path`) map to keys\n * like `'./sub/path'`. Externalize by leaving the bare specifier\n * intact for WP's import map to resolve at runtime.\n *\n * Neither field\n * Package is *not* externalizable — bundle it into the consumer's\n * output. Drops the maintenance burden of a hand-maintained\n * BUNDLED_PACKAGES list (`@wordpress/icons`, `@wordpress/dataviews`,\n * etc.) by deriving the answer from each package's own metadata.\n *\n * Also hosts `resolvePackageEsmEntry`, the entry-point lookup the force-bundle\n * escape hatch needs for packages whose metadata *lies* about externalizability\n * (see `bundle` in `wp-externals.ts`).\n */\nimport { createRequire } from 'node:module';\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join, resolve as resolvePath } from 'node:path';\n\nexport interface WpPackageJson {\n\tname: string;\n\tversion: string;\n\twpScript?: true;\n\twpScriptModuleExports?: string | Record<string, string>;\n\tsideEffects?: boolean | string[];\n\tmain?: string;\n\tmodule?: string;\n\texports?: unknown;\n}\n\n// Cache keyed by package name @ project root. Two different projects in\n// the same Node process might have different versions installed.\nconst cache = new Map<string, WpPackageJson | null>();\n\n/**\n * Resolve a package's `package.json` from the project root, cache, return.\n * Returns `null` when the package isn't installed.\n */\nexport function readPackageMetadata(\n\tpackageName: string,\n\tprojectRoot: string,\n): WpPackageJson | null {\n\tconst cacheKey = `${packageName}@${projectRoot}`;\n\tif (cache.has(cacheKey)) {\n\t\treturn cache.get(cacheKey) ?? null;\n\t}\n\n\ttry {\n\t\tconst require = createRequire(join(projectRoot, 'package.json'));\n\t\tconst packageJsonPath = require.resolve(`${packageName}/package.json`);\n\t\tconst metadata = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as WpPackageJson;\n\t\tcache.set(cacheKey, metadata);\n\t\treturn metadata;\n\t} catch {\n\t\tcache.set(cacheKey, null);\n\t\treturn null;\n\t}\n}\n\n/**\n * Given an import like `@wordpress/blocks` or `@wordpress/blocks/sub`,\n * return the root package name and the subpath portion. Subpath is\n * `null` for root imports.\n *\n * `@wordpress/blocks` → { name: '@wordpress/blocks', subpath: null }\n * `@wordpress/blocks/sub` → { name: '@wordpress/blocks', subpath: 'sub' }\n * `@wordpress/blocks/sub/path` → { name: '@wordpress/blocks', subpath: 'sub/path' }\n * `lodash` → { name: 'lodash', subpath: null }\n * `lodash/get` → { name: 'lodash', subpath: 'get' }\n */\nexport function splitImport(specifier: string): { name: string; subpath: string | null } {\n\tconst parts = specifier.split('/');\n\tif (specifier.startsWith('@')) {\n\t\t// Scoped: `@scope/pkg[/subpath...]`\n\t\tif (parts.length < 2) return { name: specifier, subpath: null };\n\t\tconst name = `${parts[0]}/${parts[1]}`;\n\t\tconst subpath = parts.length > 2 ? parts.slice(2).join('/') : null;\n\t\treturn { name, subpath };\n\t}\n\treturn {\n\t\tname: parts[0] ?? specifier,\n\t\tsubpath: parts.length > 1 ? parts.slice(1).join('/') : null,\n\t};\n}\n\n/**\n * Does the given package + subpath qualify as a Script Module import?\n * Mirrors wp-build's `isScriptModuleImport`:\n * - Root import (`subpath: null`): `wpScriptModuleExports` is a string\n * OR an object with a `'.'` key.\n * - Subpath import: an object with a `'./<subpath>'` key.\n */\nexport function isScriptModule(metadata: WpPackageJson, subpath: string | null): boolean {\n\tconst exports = metadata.wpScriptModuleExports;\n\tif (!exports) return false;\n\tif (subpath === null) {\n\t\tif (typeof exports === 'string') return true;\n\t\treturn typeof exports === 'object' && '.' in exports;\n\t}\n\treturn typeof exports === 'object' && `./${subpath}` in exports;\n}\n\n/**\n * Convert `block-editor` → `blockEditor`. Matches the camelCasing\n * `wp.<name>` uses for `@wordpress/<name>` packages.\n */\nexport function camelize(kebabCaseName: string): string {\n\treturn kebabCaseName.replace(/-(.)/g, (_match, letter: string) => letter.toUpperCase());\n}\n\n/**\n * Pick the ESM-ish entry out of an `exports` value. Handles the three shapes\n * that appear in the wild: a bare string, a subpath map (`{ '.': … }`), and a\n * conditions map (`{ import: …, require: … }`), plus fallback arrays.\n *\n * Conditions are tried in the order that lands on ESM when the package ships\n * both builds; `require`/`node` are deliberately never consulted.\n */\nfunction pickExportsEntry(value: unknown): string | null {\n\tif (typeof value === 'string') return value;\n\tif (Array.isArray(value)) {\n\t\tfor (const candidate of value) {\n\t\t\tconst picked = pickExportsEntry(candidate);\n\t\t\tif (picked) return picked;\n\t\t}\n\t\treturn null;\n\t}\n\tif (!value || typeof value !== 'object') return null;\n\tconst record = value as Record<string, unknown>;\n\t// Subpath map — only the root entry is relevant here.\n\tif ('.' in record) return pickExportsEntry(record['.']);\n\tfor (const condition of ['module', 'import', 'browser', 'default']) {\n\t\tif (!(condition in record)) continue;\n\t\tconst picked = pickExportsEntry(record[condition]);\n\t\tif (picked) return picked;\n\t}\n\treturn null;\n}\n\n/**\n * Resolve a package's ESM entry point to an absolute file path.\n *\n * Used by the force-bundle path in `wpExternals`, which rewrites a bare\n * specifier to a marker id and then has to answer with a real file. Plain\n * `require.resolve('<pkg>')` would apply the `require` condition and land on\n * the CJS build (`@wordpress/icons` ships `main: build/index.js` alongside\n * `module: build-module/index.js`), costing tree-shaking. So resolve the\n * `package.json` — always reachable, even behind an `exports` map — and read\n * the entry fields ourselves.\n *\n * `fromPaths` are tried in order; each must be a *file* path createRequire can\n * anchor on. Force-bundled packages are often only reachable from inside\n * another dependency, so the importer belongs in that list ahead of the\n * project root.\n */\nexport function resolvePackageEsmEntry(packageName: string, fromPaths: string[]): string | null {\n\tfor (const from of fromPaths) {\n\t\tconst packageJsonPath = findPackageJson(packageName, from);\n\t\tif (!packageJsonPath) continue;\n\t\tlet metadata: WpPackageJson;\n\t\ttry {\n\t\t\tmetadata = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as WpPackageJson;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tconst entry =\n\t\t\tpickExportsEntry(metadata.exports) ??\n\t\t\t(typeof metadata.module === 'string' ? metadata.module : null) ??\n\t\t\t(typeof metadata.main === 'string' ? metadata.main : null) ??\n\t\t\t'./index.js';\n\t\tconst entryPath = resolvePath(dirname(packageJsonPath), entry);\n\t\tif (!existsSync(entryPath)) continue;\n\t\t// Vite resolves through symlinks by default (`preserveSymlinks: false`),\n\t\t// so hand back the real path or the same file ends up in the graph twice\n\t\t// under two ids.\n\t\ttry {\n\t\t\treturn realpathSync(entryPath);\n\t\t} catch {\n\t\t\treturn entryPath;\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Locate a package's `package.json`, anchored on a file path.\n *\n * `require.resolve('<pkg>/package.json')` is the direct route but throws\n * `ERR_PACKAGE_PATH_NOT_EXPORTED` for the growing number of packages whose\n * `exports` map doesn't list `./package.json`, so fall back to walking\n * `node_modules` up from the anchor — which also finds nested copies installed\n * for a single dependency.\n */\nfunction findPackageJson(packageName: string, from: string): string | null {\n\ttry {\n\t\treturn createRequire(from).resolve(`${packageName}/package.json`);\n\t} catch {\n\t\t// Fall through to the manual walk.\n\t}\n\tlet dir = dirname(from);\n\tfor (;;) {\n\t\tconst candidate = join(dir, 'node_modules', packageName, 'package.json');\n\t\tif (existsSync(candidate)) return candidate;\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return null;\n\t\tdir = parent;\n\t}\n}\n","/**\n * vite-plugin-wp-externals\n *\n * Two responsibilities, modeled on `@wordpress/wp-build`'s\n * `wordpress-externals-plugin.mjs`:\n *\n * 1. Decide whether each import should be externalized, and if so, in what\n * form. The decision reads each `@wordpress/*` package's *own*\n * `package.json` for `wpScript` / `wpScriptModuleExports` fields rather\n * than hardcoding a whitelist. Packages with neither field get bundled\n * automatically. This requires consumers to install the `@wordpress/*`\n * packages they import (rather than relying on globals provided by WP),\n * which is the tradeoff for self-documenting external-ness and\n * out-of-the-box TypeScript types.\n *\n * 2. Emit a `<entry>.asset.php` sidecar for every entry chunk with a\n * content-hash `version` covering the chunk code *and* its extracted\n * CSS. Module-mode assets also get `'type' => 'module'` so WP registers\n * them via `wp_register_script_module`. Dependencies come in two shapes,\n * because the two consumers disagree:\n *\n * - Default (block Script Modules): WordPress core reads\n * `dependencies` as the *module* dependency list — static specifiers\n * as plain strings, dynamic as\n * `array( 'id' => '...', 'import' => 'dynamic' )` — plus the\n * additive `script_dependencies` key for the classic handles the\n * module reads off `window.*`.\n * - Entries matching `wpBuildAssetMatchers` (admin pages): the\n * `@wordpress/build` shape — `dependencies` = classic handles,\n * `module_dependencies` = `array( 'id' => ..., 'import' => ... )`\n * entries, omitted when empty.\n *\n * Non-`@wordpress/*` imports use the legacy hardcoded path: `react`,\n * `react-dom`, `jquery`, `lodash` map to fixed globals; other namespaces\n * (`@woo/...`, `@acme/...`) get config-driven externalization via\n * `externalNamespaces`.\n *\n * 3. Force-bundle the packages whose metadata contradicts what WordPress core\n * registers (`DEFAULT_BUNDLED_PACKAGES`, plus the `bundle` option). This is\n * a specifier-text rewrite rather than a resolver decision, because the\n * transform above matches raw source text — see `bundlePlugin`.\n */\nimport crypto from 'node:crypto';\nimport { join } from 'node:path';\nimport { init, parse, type ImportSpecifier } from 'es-module-lexer';\nimport MagicString from 'magic-string';\nimport type { Plugin, Rollup } from 'vite';\nimport {\n\tcamelize,\n\tisScriptModule,\n\treadPackageMetadata,\n\tresolvePackageEsmEntry,\n\tsplitImport,\n} from './package-metadata';\n\nexport interface ExternalNamespace {\n\t/** Window global path, e.g. `wp` for `@wordpress/*`, `woo` for `@woo/*`. */\n\tglobal: string;\n\t/** Script-handle prefix used in `.asset.php`. `wp` → `wp-block-editor`. */\n\thandlePrefix: string;\n}\n\nexport interface WpExternalsOptions {\n\t/**\n\t * Project root used to resolve `@wordpress/*` (and other) package.jsons.\n\t * Defaults to `process.cwd()`. Pass the absolute project root for\n\t * deterministic resolution in monorepos / weird CWDs.\n\t */\n\tprojectRoot?: string;\n\t/**\n\t * Additional namespaces to externalize. The metadata-driven path covers\n\t * `@wordpress/*` automatically; this lets you add `woo`, `acme`, etc.\n\t * as classic-script externals (no metadata read — global/handle config\n\t * only).\n\t */\n\texternalNamespaces?: Record<string, ExternalNamespace>;\n\t/**\n\t * Non-scoped vendor externals (`react`, `jquery`, etc.). These don't\n\t * carry WP metadata so we keep the hardcoded mapping. Pass `{}` to\n\t * disable.\n\t */\n\tadditionalExternals?: Record<string, { global: string; handle: string | null }>;\n\t/**\n\t * 'script' (default) rewrites `import { x } from '@wordpress/y'` into\n\t * `const { x } = window.wp.y;` so the resulting bundle works as a\n\t * classic <script>. `.asset.php` lists `wp-y`-style handles for\n\t * `wp_register_script`.\n\t *\n\t * 'module' leaves ESM imports of Script-Module-eligible packages intact\n\t * (resolved at runtime by WP's import map) for use with\n\t * `wp_register_script_module` — required for the Interactivity API and\n\t * Script Modules generally. `.asset.php` lists those specifiers under\n\t * `module_dependencies` and includes `'type' => 'module'`. Script-only\n\t * packages (`wpScript`, vendor globals) have no module form, so they're\n\t * still rewritten to their `window.*` global with the classic handle\n\t * recorded in `dependencies`.\n\t */\n\tbuildType?: 'script' | 'module';\n\t/**\n\t * Substring matchers for file paths that should *always* be treated as\n\t * `module`-mode regardless of the plugin-level `buildType`. Lets a\n\t * single Vite dev server (which can only run one global mode at a time)\n\t * still serve Script Module entries with their ESM imports intact.\n\t *\n\t * Example: `['/view.ts', '/view-module.ts', '/view-module.js']`\n\t */\n\tmoduleEntryMatchers?: string[];\n\t/**\n\t * Substring matchers for entry *source* paths (the entry chunk's\n\t * `facadeModuleId`) whose `.asset.php` should use the\n\t * `@wordpress/build` shape:\n\t *\n\t * 'dependencies' => classic script handles\n\t * 'module_dependencies' => array( 'id' => …, 'import' => 'static'|'dynamic' )\n\t *\n\t * Entries that don't match keep the shape WordPress core reads when it\n\t * registers a Script Module from `block.json`\n\t * (`register_block_script_module_id()` passes `dependencies` straight\n\t * into `wp_register_script_module()`), so module specifiers stay in\n\t * `dependencies` there.\n\t *\n\t * `wp()` wires this automatically for `adminPagesDir`. Set it yourself\n\t * when composing plugins by hand.\n\t *\n\t * Example: `['/assets/js/admin-pages/']`\n\t */\n\twpBuildAssetMatchers?: string[];\n\t/**\n\t * Plugin-local Script Module namespaces — exact names or `prefix-*` globs.\n\t * Imports matching `@<ns>/<anything>` are externalized as Script Modules:\n\t * the ESM import is preserved (no global rewrite) and the specifier is\n\t * recorded in the `.asset.php` dependency list.\n\t *\n\t * Example: `['ignite-wp-navigation', 'ignite-*']`\n\t */\n\tscriptModuleNamespaces?: string[];\n\t/**\n\t * Bare package names to **force-bundle**: their externalization is\n\t * suppressed and their imports are rewritten to resolve against the\n\t * installed package's ESM entry instead.\n\t *\n\t * The escape hatch for packages whose WP metadata does not match what\n\t * WordPress core actually registers. Merges with (never replaces)\n\t * `DEFAULT_BUNDLED_PACKAGES`.\n\t *\n\t * Bare names only — `@wordpress/dataviews/wp` and other subpath entries\n\t * throw at config time, because force-bundling is a whole-package verdict.\n\t *\n\t * Example: `['@wordpress/icons', 'some-lying-package']`\n\t */\n\tbundle?: string[];\n}\n\n/**\n * Packages that claim externalizability they don't have. Same rationale as\n * core's `dependency-extraction-webpack-plugin` keeping a hardcoded\n * `BUNDLED_PACKAGES` list: the metadata is wrong with respect to what core\n * registers, and there is nowhere else to record that.\n *\n * `@wordpress/icons@10.x` ships `wpScript: true`, but WordPress core registers\n * no `wp-icons` script — it's absent from `script-loader-packages.php`. Trusting\n * the metadata produces two failures at once: `window.wp.icons` is undefined,\n * *and* the unregistered `wp-icons` dependency makes WordPress refuse to\n * enqueue the script at all. (`@wordpress/icons@11.x` dropped `wpScript`, so\n * without this list the behavior depends on which copy the resolver hoists.)\n */\nexport const DEFAULT_BUNDLED_PACKAGES = ['@wordpress/icons'];\n\n/**\n * Specifier prefix the force-bundle pre-transform swaps a bare package name\n * for. Two jobs: wpExternals' own transform never sees the bare specifier (so\n * it cannot rewrite it to a `window.*` read), and the resolver gets to point at\n * the package's *ESM* entry rather than whatever condition the native resolver\n * would pick.\n *\n * Deliberately not `\\0`-prefixed: Rolldown's native resolver has to hand the\n * id to our `resolveId` hook, and `\\0` ids take different code paths in parts\n * of the Vite/Rolldown pipeline.\n */\nconst BUNDLED_MARKER_PREFIX = 'wp-vite-bundled:';\n\n/** File extensions whose contents must lex as JavaScript. */\nconst JS_SOURCE_EXTENSION = /\\.[mc]?[jt]sx?$/;\n\nfunction escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Bare package name — `lodash`, `@wordpress/icons`; no subpath, no path. */\nfunction isBarePackageName(name: string): boolean {\n\tif (name.startsWith('@')) {\n\t\tconst parts = name.split('/');\n\t\treturn parts.length === 2 && parts[0]!.length > 1 && !!parts[1];\n\t}\n\treturn name.length > 0 && !name.includes('/') && !name.startsWith('.');\n}\n\n/**\n * Vendor externals — non-`@wordpress/*` packages that need fixed\n * global/handle mappings because they're not WP-published packages and\n * don't carry `wpScript` metadata. Maps `react`, `react-dom`,\n * `react/jsx-runtime`, `react/jsx-dev-runtime`, `jquery`, `lodash`.\n *\n * Matches wp-build's `vendorExternals` map verbatim.\n */\nconst DEFAULT_VENDOR: Record<string, { global: string; handle: string | null }> = {\n\treact: { global: 'React', handle: 'react' },\n\t'react-dom': { global: 'ReactDOM', handle: 'react-dom' },\n\t'react-dom/client': { global: 'ReactDOM', handle: 'react-dom' },\n\t'react/jsx-runtime': { global: 'ReactJSXRuntime', handle: 'react-jsx-runtime' },\n\t'react/jsx-dev-runtime': { global: 'ReactJSXRuntime', handle: 'react-jsx-runtime' },\n\tmoment: { global: 'moment', handle: 'moment' },\n\tjquery: { global: 'jQuery', handle: 'jquery' },\n\tlodash: { global: 'lodash', handle: 'lodash' },\n\t'lodash-es': { global: 'lodash', handle: 'lodash' },\n};\n\n/**\n * Virtual module id prefix for the CJS-consumer shim.\n *\n * Rolldown parses CommonJS natively and, for a `require()` of a module we\n * mark `external: true`, keeps the call as a runtime `require(...)`. In a\n * browser that throws:\n *\n * Calling `require` for \"react\" in an environment that doesn't expose the\n * `require` function.\n *\n * Real dependency trees hit this constantly — `use-sync-external-store`'s\n * CJS shims (pulled in transitively by `@wordpress/dataviews` →\n * `@ariakit/react`), `react-is`, `prop-types`, etc. all `require('react')`.\n *\n * So when Rolldown tells us a specifier came from a `require()` site\n * (`options.kind === 'require-call'`), we resolve it to this virtual module\n * instead of externalizing it. `load()` answers with a one-line CommonJS\n * module that assigns the window global — the same trick the hand-rolled\n * esbuild boot pipelines use with their `wp-global:` namespace:\n *\n * module.exports = window.React;\n *\n * Rolldown wraps that in its `__commonJSMin` helper, so `require('react')`\n * becomes a plain function call returning `window.React`. No runtime\n * `require` survives.\n *\n * Note the deliberate `\\0` prefix: it keeps Vite's other plugins (and its\n * import analysis) away from the id.\n */\nconst CJS_GLOBAL_SHIM_PREFIX = '\\0wp-external-global:';\n\ninterface ResolvedExternal {\n\t/** Window global path for script-mode rewrite. `null` if module-only. */\n\tglobal: string | null;\n\t/** Script handle (`wp-element`, `react-jsx-runtime`). `null` if module-only. */\n\thandle: string | null;\n\t/** Raw import specifier preserved for module-mode `.asset.php`. */\n\tspecifier: string;\n\t/** Whether this package can be used as a Script Module. */\n\tmoduleEligible: boolean;\n\t/** Whether this package can be used as a classic script. */\n\tscriptEligible: boolean;\n}\n\n/**\n * Parse a single ES import statement and produce equivalent code that reads\n * from a global instead. Handles the four shapes that appear in real code:\n *\n * import foo from '@x/y'; → const foo = (g && g.default) || g;\n * import * as foo from '@x/y'; → const foo = g;\n * import { a, b as c } from '@x/y'; → const { a, b: c } = g;\n * import '@x/y'; → (drops the statement; rare)\n */\n// JS identifiers can contain `$` (bundlers routinely mint `Fragment$1`-style\n// deduped names), but the regex shorthand `\\w` does NOT include `$` — using\n// it here silently failed to match those bindings, leaving the ESM `as`\n// keyword in place inside a `const { ... } = window.X` destructure (invalid\n// syntax; `:` renames in destructuring, not `as`). Real-world packages hit\n// this — e.g. `@ariakit/react-components`' published\n// `import { Fragment as Fragment$1, jsx, jsxs } from \"react/jsx-runtime\"`.\nconst JS_IDENTIFIER = '[A-Za-z_$][\\\\w$]*';\n\nfunction rewriteImport(importStatement: string, globalAccess: string): string | null {\n\tconst match = importStatement.match(/^\\s*import\\s+(.*?)\\s+from\\s+['\"][^'\"]+['\"]\\s*;?\\s*$/s);\n\tif (!match || !match[1]) return '';\n\tconst bindings = match[1].trim();\n\n\tconst namespaceImport = bindings.match(new RegExp(`^\\\\*\\\\s+as\\\\s+(${JS_IDENTIFIER})$`));\n\tif (namespaceImport) return `const ${namespaceImport[1]} = ${globalAccess};`;\n\n\tconst defaultWithNamed = bindings.match(\n\t\tnew RegExp(`^(${JS_IDENTIFIER})\\\\s*,\\\\s*\\\\{(.+)\\\\}$`, 's'),\n\t);\n\tif (defaultWithNamed) {\n\t\treturn [\n\t\t\t`const ${defaultWithNamed[1]} = (${globalAccess} && ${globalAccess}.default) || ${globalAccess};`,\n\t\t\t`const { ${namedImportsToDestructuring(defaultWithNamed[2]!.trim())} } = ${globalAccess};`,\n\t\t].join(' ');\n\t}\n\n\tif (bindings.startsWith('{')) {\n\t\tconst namedImports = bindings.replace(/^\\{|\\}$/g, '').trim();\n\t\treturn `const { ${namedImportsToDestructuring(namedImports)} } = ${globalAccess};`;\n\t}\n\n\tif (new RegExp(`^${JS_IDENTIFIER}$`).test(bindings)) {\n\t\treturn `const ${bindings} = (${globalAccess} && ${globalAccess}.default) || ${globalAccess};`;\n\t}\n\n\treturn null;\n}\n\n/** Convert named-import bindings (`a, b as c`) into destructuring syntax (`a, b: c`). */\nfunction namedImportsToDestructuring(namedImports: string): string {\n\tconst aliasPattern = new RegExp(`^(${JS_IDENTIFIER})\\\\s+as\\\\s+(${JS_IDENTIFIER})$`);\n\treturn namedImports\n\t\t.split(',')\n\t\t.map((binding) => binding.trim())\n\t\t.filter(Boolean)\n\t\t.map((binding) => {\n\t\t\tconst aliased = binding.match(aliasPattern);\n\t\t\treturn aliased ? `${aliased[1]}: ${aliased[2]}` : binding;\n\t\t})\n\t\t.join(', ');\n}\n\nexport function wpExternals(options: WpExternalsOptions = {}): Plugin[] {\n\tconst projectRoot = options.projectRoot ?? process.cwd();\n\tconst externalNamespaces = options.externalNamespaces ?? {};\n\tconst vendorExternals = options.additionalExternals ?? DEFAULT_VENDOR;\n\tconst buildType = options.buildType ?? 'script';\n\tconst moduleEntryMatchers = options.moduleEntryMatchers ?? [];\n\tconst wpBuildAssetMatchers = options.wpBuildAssetMatchers ?? [];\n\tconst scriptModuleNamespaces = options.scriptModuleNamespaces ?? [];\n\n\tfor (const name of options.bundle ?? []) {\n\t\tif (isBarePackageName(name)) continue;\n\t\tconst { name: rootName, subpath } = splitImport(name);\n\t\tthrow new Error(\n\t\t\t`wpExternals: \\`bundle\\` accepts bare package names only, got '${name}'.` +\n\t\t\t\t(subpath\n\t\t\t\t\t? ` Force-bundling is a whole-package verdict — list '${rootName}' instead of the '${subpath}' subpath.`\n\t\t\t\t\t: ''),\n\t\t);\n\t}\n\tconst bundledPackages = new Set([...DEFAULT_BUNDLED_PACKAGES, ...(options.bundle ?? [])]);\n\n\t/** Match `@<namespace>/anything` against an exact or `prefix-*` glob namespace. */\n\tfunction matchesScriptModuleNamespace(packageName: string): boolean {\n\t\tif (!packageName.startsWith('@')) return false;\n\t\tconst slashIndex = packageName.indexOf('/');\n\t\tif (slashIndex < 0) return false;\n\t\tconst namespace = packageName.slice(1, slashIndex);\n\t\tfor (const pattern of scriptModuleNamespaces) {\n\t\t\tif (pattern.endsWith('*')) {\n\t\t\t\tif (namespace.startsWith(pattern.slice(0, -1))) return true;\n\t\t\t} else if (namespace === pattern) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tfunction buildModeForFile(moduleId: string): 'script' | 'module' {\n\t\tconst filePath = moduleId.split('?')[0] ?? moduleId;\n\t\tfor (const pattern of moduleEntryMatchers) {\n\t\t\tif (filePath.includes(pattern)) return 'module';\n\t\t}\n\t\treturn buildType;\n\t}\n\n\t/**\n\t * Does this entry's source path opt into the `@wordpress/build` asset\n\t * shape? Path separators are normalized so matchers can always be\n\t * written with forward slashes.\n\t */\n\tfunction usesWpBuildAssetShape(facadeModuleId: string | null | undefined): boolean {\n\t\tif (!facadeModuleId) return false;\n\t\tconst filePath = (facadeModuleId.split('?')[0] ?? facadeModuleId).replace(/\\\\/g, '/');\n\t\tfor (const pattern of wpBuildAssetMatchers) {\n\t\t\tif (filePath.includes(pattern.replace(/\\\\/g, '/'))) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Look up how a given import specifier should be externalized.\n\t * Returns `null` if it shouldn't be (i.e. should be bundled normally).\n\t *\n\t * Resolution order:\n\t * 0. Force-bundled packages — never external, whatever their metadata\n\t * says.\n\t * 1. Vendor map (`react`, `jquery`, etc.) — hardcoded.\n\t * 2. `@wordpress/*` — read the package's `package.json` for\n\t * `wpScript` / `wpScriptModuleExports`.\n\t * 3. Other configured namespaces (`@woo/*`, etc.) — config only,\n\t * no metadata read (treated like classic scripts).\n\t * 4. Script Module namespaces — preserve ESM import, record in\n\t * .asset.php for the runtime import-map.\n\t */\n\tfunction resolveExternal(specifier: string): ResolvedExternal | null {\n\t\t// 0. Force-bundled — short-circuits *before* any metadata read, so a\n\t\t// package with a wrong `wpScript` can never reach the rewrite. The\n\t\t// pre-transform below normally keeps the bare specifier from ever\n\t\t// getting here; this covers whatever syntax it didn't match.\n\t\tif (bundledPackages.has(splitImport(specifier).name)) return null;\n\n\t\t// 1. Vendor (react, jquery, …) — exact match including subpath.\n\t\tif (vendorExternals[specifier]) {\n\t\t\tconst vendor = vendorExternals[specifier];\n\t\t\treturn {\n\t\t\t\tglobal: vendor.global,\n\t\t\t\thandle: vendor.handle,\n\t\t\t\tspecifier,\n\t\t\t\tmoduleEligible: false,\n\t\t\t\tscriptEligible: true,\n\t\t\t};\n\t\t}\n\n\t\tconst { name, subpath } = splitImport(specifier);\n\n\t\t// 2. @wordpress/* — metadata-driven via package.json.\n\t\tif (name.startsWith('@wordpress/')) {\n\t\t\tconst meta = readPackageMetadata(name, projectRoot);\n\t\t\tif (!meta) {\n\t\t\t\t// Not installed locally. Two real failure modes:\n\t\t\t\t// a) consumer forgot to `npm install @wordpress/element`\n\t\t\t\t// b) package exists but is bundled-only (@wordpress/icons etc.)\n\t\t\t\t// Without metadata we can't tell — the safer default is\n\t\t\t\t// \"not externalizable; let Vite resolve/bundle or fail loudly\n\t\t\t\t// with a missing-module error\".\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst shortName = name.slice('@wordpress/'.length);\n\t\t\tconst moduleEligible = isScriptModule(meta, subpath);\n\t\t\tconst scriptEligible = !!meta.wpScript;\n\n\t\t\tif (!moduleEligible && !scriptEligible) {\n\t\t\t\t// Bundled package (@wordpress/icons, @wordpress/dataviews, …).\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tglobal: scriptEligible ? `wp.${camelize(shortName)}` : null,\n\t\t\t\thandle: scriptEligible ? `wp-${shortName}` : null,\n\t\t\t\tspecifier,\n\t\t\t\tmoduleEligible,\n\t\t\t\tscriptEligible,\n\t\t\t};\n\t\t}\n\n\t\t// 3. Other configured classic-script namespaces (`@woo/*`, etc.) —\n\t\t// no metadata, treated like classic scripts only.\n\t\tfor (const [namespace, config] of Object.entries(externalNamespaces)) {\n\t\t\tif (name.startsWith(`@${namespace}/`)) {\n\t\t\t\tconst shortName = name.slice(`@${namespace}/`.length);\n\t\t\t\treturn {\n\t\t\t\t\tglobal: `${config.global}.${camelize(shortName)}`,\n\t\t\t\t\thandle: `${config.handlePrefix}-${shortName}`,\n\t\t\t\t\tspecifier,\n\t\t\t\t\tmoduleEligible: false,\n\t\t\t\t\tscriptEligible: true,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// 4. Script Module namespaces — these IDs are registered server-side\n\t\t// via `wp_register_script_module()`. Preserve the ESM import\n\t\t// untouched; record specifier in .asset.php for the runtime\n\t\t// import-map. Module-only, never available as a classic script.\n\t\tif (matchesScriptModuleNamespace(name)) {\n\t\t\treturn {\n\t\t\t\tglobal: null,\n\t\t\t\thandle: null,\n\t\t\t\tspecifier,\n\t\t\t\tmoduleEligible: true,\n\t\t\t\tscriptEligible: false,\n\t\t\t};\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t// In module mode, only specific @wordpress packages support dynamic\n\t// imports per wp-build. Static is the safer default.\n\tfunction moduleImportKind(specifier: string, isDynamic: boolean): 'static' | 'dynamic' {\n\t\t// `@wordpress/interactivity` MUST be static (DEWP comment:\n\t\t// \"Interactivity does not support dynamic imports at this time\").\n\t\tif (specifier === '@wordpress/interactivity') return 'static';\n\t\treturn isDynamic ? 'dynamic' : 'static';\n\t}\n\n\t// Per-module dep tracking. Keyed by Rollup module id.\n\tconst staticDepsByModule = new Map<string, Set<string>>();\n\tconst dynamicDepsByModule = new Map<string, Set<string>>();\n\tconst handleDepsByModule = new Map<string, Set<string>>();\n\n\t/**\n\t * Merge into a per-module dep set. Two hooks write to `handleDepsByModule`\n\t * (the transform's ESM rewrite and the resolver's CJS shim), so a plain\n\t * `.set()` would let one clobber the other.\n\t */\n\tfunction recordDeps(\n\t\tmap: Map<string, Set<string>>,\n\t\tmoduleId: string,\n\t\tvalues: Iterable<string>,\n\t): void {\n\t\tlet set = map.get(moduleId);\n\t\tif (!set) {\n\t\t\tset = new Set<string>();\n\t\t\tmap.set(moduleId, set);\n\t\t}\n\t\tfor (const value of values) set.add(value);\n\t}\n\n\tconst resolverPlugin: Plugin = {\n\t\tname: `wp-externals-resolver(${buildType})`,\n\t\tenforce: 'pre',\n\n\t\tresolveId(source, _importer, options) {\n\t\t\t// Rolldown tags `require()` sites with `kind: 'require-call'`\n\t\t\t// (Rollup passes no `kind` at all, so this branch is inert there\n\t\t\t// and @rollup/plugin-commonjs' `?commonjs-external` path below\n\t\t\t// keeps handling that bundler).\n\t\t\tconst isRequireCall =\n\t\t\t\t(options as { kind?: string } | undefined)?.kind === 'require-call';\n\n\t\t\tconst external = resolveExternal(source);\n\t\t\tif (external) {\n\t\t\t\tif (isRequireCall) {\n\t\t\t\t\tif (external.global) {\n\t\t\t\t\t\t// Serve a CJS global shim instead of externalizing, so\n\t\t\t\t\t\t// no runtime `require` survives into the browser.\n\t\t\t\t\t\treturn CJS_GLOBAL_SHIM_PREFIX + source;\n\t\t\t\t\t}\n\t\t\t\t\t// Module-only external (Script Module namespaces, or a\n\t\t\t\t\t// `@wordpress/*` package with `wpScriptModuleExports` but\n\t\t\t\t\t// no `wpScript`). There's no global to read and a CJS\n\t\t\t\t\t// consumer can't await an ESM import, so we can only warn.\n\t\t\t\t\tif (typeof this?.warn === 'function') {\n\t\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t\t`${source} is required from CommonJS but is module-only (no wpScript in its package.json, so there is no window global to read). ` +\n\t\t\t\t\t\t\t\t`The bundled \\`require('${source}')\\` will throw at runtime — import it from ESM instead.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { id: source, external: true };\n\t\t\t}\n\t\t\t// CJS-wrapped externals (`\\0<specifier>?commonjs-external`) —\n\t\t\t// @rollup/plugin-commonjs' convention, used by Rollup-based Vite.\n\t\t\tconst commonjsMatch = source.match(/^\\0([^?]+)\\?commonjs-external$/);\n\t\t\tif (commonjsMatch && commonjsMatch[1] && resolveExternal(commonjsMatch[1])) {\n\t\t\t\treturn source;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(CJS_GLOBAL_SHIM_PREFIX)) {\n\t\t\t\tconst specifier = id.slice(CJS_GLOBAL_SHIM_PREFIX.length);\n\t\t\t\tconst external = resolveExternal(specifier);\n\t\t\t\tif (!external || !external.global) return null;\n\t\t\t\t// The shim carries the classic handle: `.asset.php` still has\n\t\t\t\t// to list `react` so WP enqueues the script that defines\n\t\t\t\t// `window.React`. Virtual ids show up in `chunk.modules`, so\n\t\t\t\t// generateBundle's walk finds this.\n\t\t\t\tif (external.handle) recordDeps(handleDepsByModule, id, [external.handle]);\n\t\t\t\t// CommonJS on purpose: Rolldown detects the format from\n\t\t\t\t// `module.exports` and turns the `require()` into a call to\n\t\t\t\t// this module's wrapper.\n\t\t\t\treturn `module.exports = (typeof window !== \"undefined\" ? window.${external.global} : {});\\n`;\n\t\t\t}\n\t\t\tconst commonjsMatch = id.match(/^\\0([^?]+)\\?commonjs-external$/);\n\t\t\tif (!commonjsMatch || !commonjsMatch[1]) return null;\n\t\t\tconst external = resolveExternal(commonjsMatch[1]);\n\t\t\tif (!external) return null;\n\t\t\tif (buildModeForFile(id) === 'module' && external.moduleEligible) {\n\t\t\t\treturn `export default {};`;\n\t\t\t}\n\t\t\tif (!external.global) {\n\t\t\t\treturn `export default {};`;\n\t\t\t}\n\t\t\tif (external.handle) recordDeps(handleDepsByModule, id, [external.handle]);\n\t\t\treturn `const __wpExternal = (typeof window !== \"undefined\" ? window.${external.global} : {}); export default __wpExternal;`;\n\t\t},\n\t};\n\n\tconst transformPlugin: Plugin = {\n\t\tname: `wp-externals(${buildType})`,\n\t\tenforce: 'post',\n\n\t\tasync transform(code, id) {\n\t\t\t// Fast-path bail.\n\t\t\tif (\n\t\t\t\t!code.includes('@wordpress/') &&\n\t\t\t\t!Object.keys(vendorExternals).some((packageName) => code.includes(packageName)) &&\n\t\t\t\t!Object.keys(externalNamespaces).some((namespace) =>\n\t\t\t\t\tcode.includes(`@${namespace}/`),\n\t\t\t\t) &&\n\t\t\t\t!scriptModuleNamespaces.some((pattern) =>\n\t\t\t\t\tcode.includes(`@${pattern.endsWith('*') ? pattern.slice(0, -1) : pattern}`),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tawait init;\n\t\t\tlet imports: readonly ImportSpecifier[];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code, id);\n\t\t\t} catch (error) {\n\t\t\t\t// A swallowed parse failure here is the worst possible outcome:\n\t\t\t\t// the module got past the fast-path, so it *does* reference\n\t\t\t\t// something externalizable, and bailing quietly ships the bare\n\t\t\t\t// `@wordpress/*` imports un-rewritten with an incomplete\n\t\t\t\t// `.asset.php` — a runtime failure in the editor with zero\n\t\t\t\t// build signal. Fail the build instead.\n\t\t\t\t//\n\t\t\t\t// Only for modules whose extension promises JavaScript: this\n\t\t\t\t// hook also sees CSS and other non-JS module content (it runs\n\t\t\t\t// before Vite's own post-build plugins), and those must stay\n\t\t\t\t// silent bails.\n\t\t\t\tconst filePath = id.split('?')[0] ?? id;\n\t\t\t\tif (!JS_SOURCE_EXTENSION.test(filePath)) return null;\n\t\t\t\treturn this.error(\n\t\t\t\t\t`wp-externals could not parse the imports of ${filePath}: ${\n\t\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t\t}\\n` +\n\t\t\t\t\t\t`Its @wordpress/* imports would ship un-rewritten (broken window.wp.* reads and an incomplete .asset.php), so this is a hard error.\\n` +\n\t\t\t\t\t\t`Most likely cause: JSX in a file that isn't .jsx/.tsx. JSX must live in .jsx/.tsx files — do not use \\`rollupOptions.moduleTypes\\` to map .js to jsx; rename the files instead. ` +\n\t\t\t\t\t\t`The JSX transform runs *after* plugin transform hooks, so \\`moduleTypes\\` makes the build pass while this plugin still sees raw JSX and produces broken output.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (imports.length === 0) return null;\n\n\t\t\tconst magicString = new MagicString(code);\n\t\t\tlet codeChanged = false;\n\t\t\tconst fileMode = buildModeForFile(id);\n\n\t\t\tconst staticDeps = new Set<string>();\n\t\t\tconst dynamicDeps = new Set<string>();\n\t\t\tconst handleDeps = new Set<string>();\n\n\t\t\t/**\n\t\t\t * Rewrite one import statement into a `window.*` read and record\n\t\t\t * its classic script handle. Returns whether code changed.\n\t\t\t */\n\t\t\tconst rewriteToGlobal = (\n\t\t\t\texternal: ResolvedExternal,\n\t\t\t\timportRecord: ImportSpecifier,\n\t\t\t): boolean => {\n\t\t\t\tconst importStatement = code.slice(importRecord.ss, importRecord.se);\n\t\t\t\tconst rewritten = rewriteImport(importStatement, `(window.${external.global})`);\n\t\t\t\tif (rewritten === null) return false;\n\t\t\t\tmagicString.overwrite(importRecord.ss, importRecord.se, rewritten);\n\t\t\t\tif (external.handle) handleDeps.add(external.handle);\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\tfor (const importRecord of imports) {\n\t\t\t\tconst importedSpecifier = importRecord.n;\n\t\t\t\tif (importedSpecifier === undefined) continue;\n\t\t\t\tconst external = resolveExternal(importedSpecifier);\n\t\t\t\tif (!external) continue;\n\n\t\t\t\tconst isDynamic = importRecord.d > -1;\n\n\t\t\t\tif (fileMode === 'script') {\n\t\t\t\t\tif (isDynamic || !external.scriptEligible) {\n\t\t\t\t\t\t// Dynamic imports → leave alone. Module-only packages\n\t\t\t\t\t\t// (no wpScript) → leave alone too; Rollup will keep\n\t\t\t\t\t\t// the bare ESM import which is fine in a module\n\t\t\t\t\t\t// context but problematic in a classic script. We\n\t\t\t\t\t\t// warn rather than fail to surface the issue.\n\t\t\t\t\t\tif (!external.scriptEligible && !isDynamic) {\n\t\t\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t\t\t`${importedSpecifier} is module-only (no wpScript in its package.json) but imported into a script-mode entry. ` +\n\t\t\t\t\t\t\t\t\t`Move this import to a viewScriptModule entry, or this script will fail at runtime.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (rewriteToGlobal(external, importRecord)) codeChanged = true;\n\t\t\t\t} else if (!external.moduleEligible) {\n\t\t\t\t\t// Module mode, script-only package (`wpScript: true` or a\n\t\t\t\t\t// vendor global like `react`). A Script Module can still\n\t\t\t\t\t// use it: WP enqueues the classic script — collected into\n\t\t\t\t\t// the sidecar's `dependencies` for PHP to depend on — and\n\t\t\t\t\t// the module reads its `window.*` global. This is the\n\t\t\t\t\t// three-tier strategy wp-build (and the hand-rolled\n\t\t\t\t\t// esbuild boot pipelines) apply, and it's what makes\n\t\t\t\t\t// `@wordpress/boot` admin pages buildable: they pull in\n\t\t\t\t\t// `wp-components`, `wp-data`, `react`, … which have no\n\t\t\t\t\t// Script Module form.\n\t\t\t\t\tif (isDynamic) {\n\t\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t\t`${importedSpecifier} is not Script-Module-eligible (no wpScriptModuleExports in its package.json) and can't be dynamically imported from a module-mode entry. ` +\n\t\t\t\t\t\t\t\t`Import it statically (it gets read off its window global) or move it to a script-mode entry.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (rewriteToGlobal(external, importRecord)) codeChanged = true;\n\t\t\t\t} else {\n\t\t\t\t\t// Module mode, Script Module package — leave the bare ESM\n\t\t\t\t\t// specifier for WP's runtime import map.\n\t\t\t\t\tconst importKind = moduleImportKind(importedSpecifier, isDynamic);\n\t\t\t\t\tif (importKind === 'static') {\n\t\t\t\t\t\tstaticDeps.add(external.specifier);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdynamicDeps.add(external.specifier);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (staticDeps.size > 0) recordDeps(staticDepsByModule, id, staticDeps);\n\t\t\tif (dynamicDeps.size > 0) recordDeps(dynamicDepsByModule, id, dynamicDeps);\n\t\t\tif (handleDeps.size > 0) recordDeps(handleDepsByModule, id, handleDeps);\n\n\t\t\tif (!codeChanged) return null;\n\n\t\t\treturn {\n\t\t\t\tcode: magicString.toString(),\n\t\t\t\tmap: magicString.generateMap({ hires: true }),\n\t\t\t};\n\t\t},\n\n\t\tgenerateBundle(_outputOptions, bundle) {\n\t\t\tconst chunksByFileName = new Map<string, Rollup.OutputChunk>();\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type === 'chunk') chunksByFileName.set(fileName, output);\n\t\t\t}\n\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk' || !output.isEntry) continue;\n\t\t\t\tif (!fileName.endsWith('.js') && !fileName.endsWith('.mjs')) continue;\n\n\t\t\t\t// Walk the local chunk graph: code an entry shares with\n\t\t\t\t// another entry (two admin pages both pulling in\n\t\t\t\t// `@wordpress/dataviews`, a shared components module) lands in\n\t\t\t\t// its own chunk, and the dependencies that travelled with it\n\t\t\t\t// still belong in *each* entry's sidecar.\n\t\t\t\tconst reachableChunks: Rollup.OutputChunk[] = [];\n\t\t\t\tconst visited = new Set<string>([fileName]);\n\t\t\t\tconst queue = [fileName];\n\t\t\t\twhile (queue.length > 0) {\n\t\t\t\t\tconst currentFileName = queue.shift()!;\n\t\t\t\t\tconst chunk = chunksByFileName.get(currentFileName);\n\t\t\t\t\tif (!chunk) continue;\n\t\t\t\t\treachableChunks.push(chunk);\n\t\t\t\t\tfor (const imported of [\n\t\t\t\t\t\t...(chunk.imports ?? []),\n\t\t\t\t\t\t...(chunk.dynamicImports ?? []),\n\t\t\t\t\t]) {\n\t\t\t\t\t\t// Names absent from the bundle are externals.\n\t\t\t\t\t\tif (!chunksByFileName.has(imported) || visited.has(imported)) continue;\n\t\t\t\t\t\tvisited.add(imported);\n\t\t\t\t\t\tqueue.push(imported);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst entryHandles = new Set<string>();\n\t\t\t\tconst entryStaticDeps = new Set<string>();\n\t\t\t\tconst entryDynamicDeps = new Set<string>();\n\n\t\t\t\tfor (const chunk of reachableChunks) {\n\t\t\t\t\tfor (const moduleId of Object.keys(chunk.modules ?? {})) {\n\t\t\t\t\t\tconst handles = handleDepsByModule.get(moduleId);\n\t\t\t\t\t\tif (handles) for (const handle of handles) entryHandles.add(handle);\n\t\t\t\t\t\tconst staticDeps = staticDepsByModule.get(moduleId);\n\t\t\t\t\t\tif (staticDeps) for (const dep of staticDeps) entryStaticDeps.add(dep);\n\t\t\t\t\t\tconst dynamicDeps = dynamicDepsByModule.get(moduleId);\n\t\t\t\t\t\tif (dynamicDeps) for (const dep of dynamicDeps) entryDynamicDeps.add(dep);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// The `module`/`script` verdict stays a property of the entry\n\t\t\t\t// itself — a shared chunk must never flip a classic entry.\n\t\t\t\tlet entryMode: 'script' | 'module' = buildType;\n\t\t\t\tfor (const moduleId of Object.keys(output.modules ?? {})) {\n\t\t\t\t\tif (buildModeForFile(moduleId) === 'module') entryMode = 'module';\n\t\t\t\t}\n\n\t\t\t\t// Version hashes the chunk code *plus* every stylesheet Vite\n\t\t\t\t// extracted for it (and for the chunks it reaches), so a\n\t\t\t\t// CSS-only edit busts WP's cache. `viteMetadata` is absent\n\t\t\t\t// under plain Rollup — then it's a code-only hash.\n\t\t\t\tconst hash = crypto.createHash('md5').update(output.code);\n\t\t\t\tconst cssFileNames = new Set<string>();\n\t\t\t\tfor (const chunk of reachableChunks) {\n\t\t\t\t\tfor (const cssFileName of chunk.viteMetadata?.importedCss ?? []) {\n\t\t\t\t\t\tcssFileNames.add(cssFileName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const cssFileName of [...cssFileNames].sort()) {\n\t\t\t\t\tconst cssAsset = bundle[cssFileName];\n\t\t\t\t\tif (!cssAsset || cssAsset.type !== 'asset') continue;\n\t\t\t\t\thash.update(cssAsset.source);\n\t\t\t\t}\n\t\t\t\tconst version = hash.digest('hex').slice(0, 20);\n\n\t\t\t\tconst handles = [...entryHandles].sort();\n\t\t\t\tconst phpList = (items: string[]) =>\n\t\t\t\t\titems.length > 0 ? ` ${items.join(', ')} ` : '';\n\n\t\t\t\t// One id per dependency. Static wins over dynamic: a dep\n\t\t\t\t// imported both ways has to be there up front either way.\n\t\t\t\tconst moduleImportKinds = new Map<string, 'static' | 'dynamic'>();\n\t\t\t\tfor (const dep of entryDynamicDeps) moduleImportKinds.set(dep, 'dynamic');\n\t\t\t\tfor (const dep of entryStaticDeps) moduleImportKinds.set(dep, 'static');\n\t\t\t\tconst sortedModuleDeps = [...moduleImportKinds.entries()].sort(([a], [b]) =>\n\t\t\t\t\ta < b ? -1 : a > b ? 1 : 0,\n\t\t\t\t);\n\n\t\t\t\tconst fields: string[] = [];\n\n\t\t\t\tif (usesWpBuildAssetShape(output.facadeModuleId)) {\n\t\t\t\t\t// `@wordpress/build` shape. `dependencies` carries classic\n\t\t\t\t\t// script handles in both modes — a Script Module reading\n\t\t\t\t\t// `window.wp.components` still needs PHP to enqueue\n\t\t\t\t\t// `wp-components` — and Script Module specifiers get their\n\t\t\t\t\t// own key. Consumed by project PHP (boot admin pages), not\n\t\t\t\t\t// by core's block-metadata registration.\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\t`'dependencies' => array(${phpList(handles.map((handle) => `'${handle}'`))})`,\n\t\t\t\t\t);\n\t\t\t\t\tconst moduleDependencies = sortedModuleDeps.map(\n\t\t\t\t\t\t([dep, kind]) => `array( 'id' => '${dep}', 'import' => '${kind}' )`,\n\t\t\t\t\t);\n\t\t\t\t\tif (moduleDependencies.length > 0) {\n\t\t\t\t\t\tfields.push(\n\t\t\t\t\t\t\t`'module_dependencies' => array(${phpList(moduleDependencies)})`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (entryMode === 'module') {\n\t\t\t\t\t// Core-compatible shape: WordPress reads `dependencies`\n\t\t\t\t\t// as the Script Module dependency list\n\t\t\t\t\t// (`register_block_script_module_id()` hands it straight to\n\t\t\t\t\t// `wp_register_script_module()`), so module specifiers stay\n\t\t\t\t\t// there — static as plain strings, dynamic in WP's\n\t\t\t\t\t// `array( 'id' => …, 'import' => 'dynamic' )` form.\n\t\t\t\t\tconst moduleDependencies = sortedModuleDeps.map(([dep, kind]) =>\n\t\t\t\t\t\tkind === 'static'\n\t\t\t\t\t\t\t? `'${dep}'`\n\t\t\t\t\t\t\t: `array( 'id' => '${dep}', 'import' => 'dynamic' )`,\n\t\t\t\t\t);\n\t\t\t\t\tfields.push(`'dependencies' => array(${phpList(moduleDependencies)})`);\n\t\t\t\t\t// Additive: the classic handles this module reads off\n\t\t\t\t\t// `window.*`. Core ignores unknown keys; project PHP can\n\t\t\t\t\t// enqueue them. Omitted when empty.\n\t\t\t\t\tif (handles.length > 0) {\n\t\t\t\t\t\tfields.push(\n\t\t\t\t\t\t\t`'script_dependencies' => array(${phpList(\n\t\t\t\t\t\t\t\thandles.map((handle) => `'${handle}'`),\n\t\t\t\t\t\t\t)})`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Classic script entry — handles only.\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\t`'dependencies' => array(${phpList(handles.map((handle) => `'${handle}'`))})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tfields.push(`'version' => '${version}'`);\n\t\t\t\tif (entryMode === 'module') fields.push(`'type' => 'module'`);\n\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: fileName.replace(/\\.m?js$/, '.asset.php'),\n\t\t\t\t\tsource: `<?php return array( ${fields.join(', ')} );\\n`,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t};\n\n\t/**\n\t * Force-bundle plugin. `resolve.alias` cannot do this job: the transform\n\t * above matches the *raw specifier text* in the source, so the rewrite to\n\t * `window.wp.*` happens regardless of how the id resolves. Only changing\n\t * the specifier text itself works — hence a `pre` transform (ordered ahead\n\t * of the `post` transform above by `enforce` alone) plus a `pre` resolveId\n\t * that answers the marker id.\n\t *\n\t * `pre` on resolveId is load-bearing under Vite 8 / Rolldown: normal-bucket\n\t * resolveId hooks are never called, because Rolldown's native resolver\n\t * answers first.\n\t */\n\tconst bundlePlugin: Plugin = {\n\t\tname: `wp-externals-bundle(${buildType})`,\n\t\tenforce: 'pre',\n\n\t\ttransform(code, id) {\n\t\t\tif (bundledPackages.size === 0) return null;\n\t\t\t// Virtual modules are ours (or another plugin's) and carry no bare\n\t\t\t// specifiers worth rewriting.\n\t\t\tif (id.startsWith('\\0')) return null;\n\t\t\tconst filePath = (id.split('?')[0] ?? id).replace(/\\\\/g, '/');\n\t\t\t// Deliberately NOT filtered on `/node_modules/`: force-bundled\n\t\t\t// packages are frequently reached only from inside another\n\t\t\t// dependency (`@wordpress/route` is imported solely by\n\t\t\t// `@wordpress/admin-ui/breadcrumbs`), and skipping node_modules\n\t\t\t// would leave exactly those imports externalized.\n\t\t\tconst magicString = new MagicString(code);\n\t\t\tlet codeChanged = false;\n\n\t\t\tfor (const packageName of bundledPackages) {\n\t\t\t\tif (!code.includes(packageName)) continue;\n\t\t\t\t// A package's own files must keep their bare self-references,\n\t\t\t\t// or the marker would resolve the entry back to itself.\n\t\t\t\tif (filePath.includes(`/node_modules/${packageName}/`)) continue;\n\n\t\t\t\t// Anchored to syntactic import position on purpose. A naive\n\t\t\t\t// `replaceAll` on the quoted name corrupts string *data* — an\n\t\t\t\t// unminified `[ '@wordpress/icons', … ]` allow-list inside a\n\t\t\t\t// dependency is real, and rewriting it changes behavior.\n\t\t\t\tconst pattern = new RegExp(\n\t\t\t\t\t`(?:\\\\bfrom|\\\\bimport|\\\\brequire)\\\\s*\\\\(?\\\\s*(['\"])${escapeRegExp(\n\t\t\t\t\t\tpackageName,\n\t\t\t\t\t)}\\\\1`,\n\t\t\t\t\t'g',\n\t\t\t\t);\n\t\t\t\tfor (const match of code.matchAll(pattern)) {\n\t\t\t\t\t// Overwrite just the specifier text between the quotes.\n\t\t\t\t\tconst end = match.index + match[0].length - 1;\n\t\t\t\t\tmagicString.overwrite(\n\t\t\t\t\t\tend - packageName.length,\n\t\t\t\t\t\tend,\n\t\t\t\t\t\tBUNDLED_MARKER_PREFIX + packageName,\n\t\t\t\t\t);\n\t\t\t\t\tcodeChanged = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!codeChanged) return null;\n\t\t\treturn {\n\t\t\t\tcode: magicString.toString(),\n\t\t\t\tmap: magicString.generateMap({ hires: true }),\n\t\t\t};\n\t\t},\n\n\t\tresolveId(source, importer) {\n\t\t\tif (!source.startsWith(BUNDLED_MARKER_PREFIX)) return null;\n\t\t\tconst packageName = source.slice(BUNDLED_MARKER_PREFIX.length);\n\t\t\t// Importer first: a force-bundled package reached from inside a\n\t\t\t// dependency may only exist in that dependency's nested\n\t\t\t// node_modules.\n\t\t\tconst fromPaths = [\n\t\t\t\t...(importer && !importer.startsWith('\\0') ? [importer.split('?')[0]!] : []),\n\t\t\t\tjoin(projectRoot, 'package.json'),\n\t\t\t];\n\t\t\tconst entry = resolvePackageEsmEntry(packageName, fromPaths);\n\t\t\tif (!entry) {\n\t\t\t\treturn this.error(\n\t\t\t\t\t`wp-externals is configured to bundle '${packageName}' (see the \\`bundle\\` option), but the package is not installed` +\n\t\t\t\t\t\t`${importer ? ` — resolved from ${importer} and ` : ' under '}${projectRoot}.\\n` +\n\t\t\t\t\t\t`Force-bundling requires the package in node_modules, since its code has to be compiled into your output. Run \\`npm install ${packageName}\\`.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Rewriting a specifier that CJS code `require()`s makes Rolldown\n\t\t\t// emit a lazy-init wrapper around the module. That's acceptable —\n\t\t\t// unlike the externalized case, no runtime `require` survives.\n\t\t\treturn entry;\n\t\t},\n\t};\n\n\t// Appended, not prepended: `enforce` already guarantees the pre/post\n\t// ordering this needs, and `wp()` spreads the whole array anyway.\n\treturn [resolverPlugin, transformPlugin, bundlePlugin];\n}\n","/**\n * vite-plugin-wp-script-dedupe\n *\n * Restores webpack-style per-entry duplication for script-mode builds.\n *\n * WordPress registers `editorScript`, `viewScript`, admin-page scripts and\n * friends with `wp_register_script()` — a classic `<script>` tag. A classic\n * script may not contain an `import` statement, so every script-mode entry\n * has to be *self-contained*. Rolldown's default is the opposite: any module\n * two entries both import is hoisted into a shared chunk and each entry keeps\n * a live `import { … } from '../chunks/…js'`. Wrapped in an IIFE by\n * `wpScriptIife` that file is a hard `SyntaxError` in the browser\n * (\"Cannot use import statement outside a module\").\n *\n * Neither Rolldown knob fixes it: `output.codeSplitting: false` is rejected\n * outright for multi-input builds, and `output.advancedChunks` only regroups\n * chunks — it cannot duplicate one module into several. webpack (and thus\n * 10up-toolkit) duplicated statically shared modules into every entry chunk,\n * which is exactly what classic scripts need. This plugin does the same, with\n * two mechanisms:\n *\n * 1. **Module-graph partitioning.** A `resolveId` hook tags every resolved id\n * with `?wp-entry=<marker>` inherited from its importer. An untagged\n * importer *is* an entry, so it mints the marker — no entry list needed.\n * Rolldown then sees N distinct ids for one file and inlines a private copy\n * per entry. Externals, `\\0` virtual ids, ids that already carry a query and\n * non-JS files pass through untouched. The hook must answer before every\n * other resolver (`enforce: 'pre'` *and* hook-level `order: 'pre'`, see\n * below), since whoever answers first fixes the id.\n *\n * 2. **Synthetic-chunk inlining.** Rolldown's interop runtime\n * (`\\0rolldown/runtime.js`) and wpExternals' CJS global shims\n * (`\\0wp-external-global:*`) are injected below the resolver, so no\n * taggable hook ever sees them and any two entries needing them still\n * share a chunk. At `generateBundle` those chunks are textually inlined\n * into each consumer as `const { … } = (() => { … return { … } })()` and\n * dropped, iterating to a fixpoint (the CJS `react` shim is itself a chunk\n * that imports the runtime). Only import-free chunks made up entirely of\n * allowlisted synthetic ids are inlined; anything else that survives\n * produces a warning naming the modules, and `wpScriptIife` then fails the\n * build.\n *\n * `wpExternals` builds each `.asset.php` dependency list by walking\n * `chunk.modules` across the chunks an entry reaches, and the shim modules are\n * what carry the `react` / `wp-components` handles. Inlined chunks' `modules`\n * maps are therefore merged into the host chunk — but under Vite 8 that merge\n * is belt-and-braces only (Rolldown hands every plugin a freshly built bundle\n * object and drops `modules` mutations on write-back). What actually keeps the\n * union correct is the `order: 'post'` on this plugin's `generateBundle`: the\n * sidecars are emitted while the shim chunk is still there.\n *\n * Build-only: dev never bundles, and marked ids would break HMR.\n */\nimport crypto from 'node:crypto';\nimport { init, parse } from 'es-module-lexer';\nimport MagicString from 'magic-string';\nimport type { Plugin, Rollup } from 'vite';\n\n/** Query parameter carrying the owning entry's marker. */\nconst MARKER_PARAM = 'wp-entry';\nconst MARKER_RE = new RegExp(`[?&]${MARKER_PARAM}=([^&]*)`);\n\n/**\n * Only real JS/TS source files get partitioned. CSS, assets and everything\n * Vite addresses through its own query conventions (`?raw`, `?url`,\n * `?worker`) keep their ids verbatim — appending a marker there would break\n * the plugin that owns the convention.\n *\n * JSON is deliberately excluded even though it compiles to a JS module: Vite's\n * JSON plugin matches on a bare `.json` id, so `block.json?wp-entry=…` reaches\n * the JS parser as raw JSON (\"Expected a semicolon…\"). A shared JSON module is\n * a byte or two of duplication we forgo, not a correctness problem.\n */\nconst PARTITIONABLE_EXTENSION = /\\.[cm]?[jt]sx?$/;\n\n/**\n * Synthetic module ids safe to inline textually. Both are bundler-injected,\n * import-free helper modules; nothing else may be duplicated blindly.\n */\nconst INLINABLE_SYNTHETIC_ID = [/^\\0?rolldown[:/]runtime(\\.[cm]?js)?$/, /^\\0wp-external-global:/];\n\nfunction markerOf(id: string): string | undefined {\n\treturn id.match(MARKER_RE)?.[1];\n}\n\nfunction withMarker(id: string, marker: string): string {\n\treturn `${id}${id.includes('?') ? '&' : '?'}${MARKER_PARAM}=${marker}`;\n}\n\n/** Drop the marker again so filesystem loads and other plugins see clean ids. */\nfunction stripEntryMarker(id: string): string {\n\treturn id\n\t\t.replace(new RegExp(`([?&])${MARKER_PARAM}=[^&]*&?`), (_match, lead: string) =>\n\t\t\tlead === '?' ? '?' : '&',\n\t\t)\n\t\t.replace(/[?&]$/, '');\n}\n\n/** Stable per-entry marker — same input, same dist, build after build. */\nfunction mintMarker(entryId: string): string {\n\treturn crypto.createHash('sha1').update(entryId).digest('hex').slice(0, 8);\n}\n\nfunction isPartitionable(id: string): boolean {\n\t// `\\0` ids are virtual (Rolldown's runtime, wpExternals' CJS shims, Vite's\n\t// internal proxies); a query means another plugin owns the id's meaning.\n\tif (id.includes('\\0') || id.includes('?')) return false;\n\treturn PARTITIONABLE_EXTENSION.test(id);\n}\n\nfunction isInlinableSyntheticChunk(chunk: Rollup.OutputChunk): boolean {\n\tconst moduleIds = Object.keys(chunk.modules ?? {});\n\tif (moduleIds.length === 0) return false;\n\treturn moduleIds.every((id) => INLINABLE_SYNTHETIC_ID.some((pattern) => pattern.test(id)));\n}\n\n/** Object-literal / destructuring key — quoted so `default` and friends are safe. */\nfunction objectKey(name: string): string {\n\treturn JSON.stringify(name);\n}\n\ninterface ImportClause {\n\t/** `{ a as b }` bindings, exported name → local name. */\n\tnamed: { imported: string; local: string }[];\n\t/** `import * as ns from …` */\n\tnamespace?: string;\n\t/** `import def from …` */\n\tdefault?: string;\n}\n\n/**\n * Parse the binding clause of a static import statement. Returns `null` for\n * shapes we refuse to rewrite (rather than emitting something broken).\n */\nfunction parseImportClause(statement: string): ImportClause | null {\n\tconst match = statement.match(/^\\s*import\\s*(?:([\\s\\S]*?)\\s*from\\s*)?['\"][^'\"]*['\"]\\s*;?\\s*$/);\n\tif (!match) return null;\n\tconst bindings = match[1]?.trim();\n\t// `import \"./chunk.js\";` — side effects only.\n\tif (!bindings) return { named: [] };\n\n\tconst clause: ImportClause = { named: [] };\n\tlet rest = bindings;\n\n\tconst leadingDefault = rest.match(/^([A-Za-z_$][\\w$]*)\\s*(?:,\\s*([\\s\\S]*))?$/);\n\tif (leadingDefault) {\n\t\tclause.default = leadingDefault[1]!;\n\t\trest = leadingDefault[2]?.trim() ?? '';\n\t}\n\n\tif (rest.startsWith('*')) {\n\t\tconst namespace = rest.match(/^\\*\\s*as\\s+([A-Za-z_$][\\w$]*)$/);\n\t\tif (!namespace) return null;\n\t\tclause.namespace = namespace[1]!;\n\t\treturn clause;\n\t}\n\n\tif (rest.startsWith('{')) {\n\t\tif (!rest.endsWith('}')) return null;\n\t\tfor (const binding of rest.slice(1, -1).split(',')) {\n\t\t\tconst trimmed = binding.trim();\n\t\t\tif (!trimmed) continue;\n\t\t\tconst aliased = trimmed.match(/^([A-Za-z_$][\\w$]*)\\s+as\\s+([A-Za-z_$][\\w$]*)$/);\n\t\t\tif (aliased) {\n\t\t\t\tclause.named.push({ imported: aliased[1]!, local: aliased[2]! });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!/^[A-Za-z_$][\\w$]*$/.test(trimmed)) return null;\n\t\t\tclause.named.push({ imported: trimmed, local: trimmed });\n\t\t}\n\t\treturn clause;\n\t}\n\n\treturn rest === '' ? clause : null;\n}\n\n/**\n * Locate the `export { … }` clause by offset, using the lexer's exported-name\n * spans as the anchor.\n *\n * Nothing here may be line-anchored. A minified chunk is a single line, so a\n * `/^export\\s*\\{…\\}$/m` strip silently matches nothing and the whole inlining\n * pass turns into a no-op — visible only in production builds. `ExportSpecifier`\n * carries no statement span (unlike `ImportSpecifier`'s `ss`/`se`), so the\n * clause is derived: back from the first exported name to `{` and the `export`\n * keyword before it, forward from the last name to `}` and an optional `;`.\n * The result is validated as a lone clause, so anything else (two clauses,\n * `export default`, a re-export) returns `null` and leaves the chunk alone.\n */\nfunction exportClauseRange(\n\tcode: string,\n\texports: readonly { s: number; e: number; ls: number; le: number }[],\n): { start: number; end: number } | null {\n\tlet firstName = Number.POSITIVE_INFINITY;\n\tlet lastName = -1;\n\tfor (const record of exports) {\n\t\tfirstName = Math.min(firstName, record.s, record.ls >= 0 ? record.ls : record.s);\n\t\tlastName = Math.max(lastName, record.e, record.le >= 0 ? record.le : record.e);\n\t}\n\tif (lastName < 0) return null;\n\n\tconst brace = code.lastIndexOf('{', firstName);\n\tif (brace < 0) return null;\n\tconst beforeBrace = code.slice(0, brace).trimEnd();\n\tif (!beforeBrace.endsWith('export')) return null;\n\tconst start = beforeBrace.length - 'export'.length;\n\t// `export` has to be its own token — not the tail of `__wpExport`.\n\tif (start > 0 && /[\\w$]/.test(code[start - 1]!)) return null;\n\n\tconst close = code.indexOf('}', lastName);\n\tif (close < 0) return null;\n\tlet end = close + 1;\n\twhile (end < code.length && /\\s/.test(code[end]!)) end += 1;\n\tif (code[end] === ';') end += 1;\n\n\t// One clause and nothing else: a nested `{`/`}` in the slice means the\n\t// derived range swallowed real code between two export statements.\n\tif (!/^export\\s*\\{[^{}]*\\}\\s*;?$/.test(code.slice(start, end))) return null;\n\treturn { start, end };\n}\n\n/**\n * Turn an import-free chunk into a self-executing expression that returns its\n * export map. Returns `null` when the chunk isn't the plain\n * `<body> + export { … }` shape we can safely rewrite.\n */\nfunction toInlineExpression(code: string): string | null {\n\tconst [imports, exports] = parse(code);\n\t// Any import record — static, dynamic, or `import.meta` — means this chunk\n\t// can't become a function body.\n\tif (imports.length > 0) return null;\n\n\tlet body = code;\n\tif (exports.length > 0) {\n\t\tconst range = exportClauseRange(code, exports);\n\t\tif (!range) return null;\n\t\tbody = code.slice(0, range.start) + code.slice(range.end);\n\t}\n\n\t// The lexer is the check, not a regex: a body that still declares module\n\t// syntax after the splice is not safe to wrap.\n\ttry {\n\t\tconst [bodyImports, bodyExports] = parse(body);\n\t\tif (bodyImports.length > 0 || bodyExports.length > 0) return null;\n\t} catch {\n\t\treturn null;\n\t}\n\n\tconst returned = exports\n\t\t.map((record) => `${objectKey(record.n)}: ${record.ln ?? record.n}`)\n\t\t.join(', ');\n\t// The lone `;` on its own line covers both minified bodies (no trailing\n\t// semicolon, ASI) and unminified ones ending in a `//#endregion` comment.\n\treturn `(() => {\\n${body.trim()}\\n;\\nreturn { ${returned} };\\n})()`;\n}\n\n/** Resolve a chunk-relative import specifier back to its bundle file name. */\nfunction resolveChunkSpecifier(hostFileName: string, specifier: string): string {\n\tconst segments = hostFileName.split('/').slice(0, -1);\n\tfor (const segment of specifier.split('/')) {\n\t\tif (segment === '.' || segment === '') continue;\n\t\tif (segment === '..') segments.pop();\n\t\telse segments.push(segment);\n\t}\n\treturn segments.join('/');\n}\n\n/**\n * Shift a chunk's sourcemap by the lines an inline insertion added. The\n * `mappings` field is `;`-separated per generated line, so inserting empty\n * entries after the rewritten line keeps everything below it aligned.\n */\nfunction shiftMappings(\n\tmap: { mappings?: string } | null,\n\tatLine: number,\n\taddedLines: number,\n): void {\n\tif (!map || typeof map.mappings !== 'string' || addedLines <= 0) return;\n\tconst lines = map.mappings.split(';');\n\tif (atLine > lines.length) return;\n\tlines.splice(atLine + 1, 0, ...new Array<string>(addedLines).fill(''));\n\tmap.mappings = lines.join(';');\n}\n\nexport function wpScriptDedupe(): Plugin {\n\t// Keyed on the MARKED importer: keying on the cleaned id lets two entry\n\t// subtrees asking the same (file, specifier) question collide under\n\t// Rolldown's parallel resolution, and the loser comes back unpartitioned\n\t// (non-deterministic output).\n\tconst inFlight = new Set<string>();\n\n\treturn {\n\t\tname: 'wp-script-dedupe',\n\t\t// Mandatory: normal-bucket `resolveId` hooks are never called during a\n\t\t// Vite 8 build — Rolldown's native resolver answers between the `pre`\n\t\t// and normal buckets.\n\t\tenforce: 'pre',\n\t\tapply: 'build',\n\n\t\tresolveId: {\n\t\t\t// `enforce: 'pre'` alone only puts this plugin in the pre bucket —\n\t\t\t// *within* it, array position decides, and any pre-bucket resolver\n\t\t\t// registered earlier answers first and hands back an untagged id.\n\t\t\t// wpExternals' force-bundle resolver is exactly that: it answers\n\t\t\t// `wp-vite-bundled:@wordpress/icons` itself, so the barrel came back\n\t\t\t// unpartitioned and its whole subtree inherited one marker minted\n\t\t\t// from the barrel — identical for every entry, i.e. a shared chunk\n\t\t\t// (issue #23). Hook-level `order: 'pre'` puts this resolver ahead of\n\t\t\t// every other resolveId hook no matter how the plugins are composed;\n\t\t\t// it delegates through `this.resolve`, so those resolvers still\n\t\t\t// decide *what* an id resolves to. This plugin only tags the answer.\n\t\t\torder: 'pre',\n\t\t\tasync handler(source, importer, options) {\n\t\t\t\t// No importer → this is an entry. Entries keep their clean id, and\n\t\t\t\t// being untagged is what makes them mint a marker for their subtree.\n\t\t\t\tif (!importer) return null;\n\t\t\t\tif (source.includes('\\0')) return null;\n\n\t\t\t\tconst key = `${importer}\\n${source}`;\n\t\t\t\tif (inFlight.has(key)) return null;\n\t\t\t\tconst marker = markerOf(importer) ?? mintMarker(importer);\n\n\t\t\t\tinFlight.add(key);\n\t\t\t\tlet resolved: Rollup.ResolvedId | null;\n\t\t\t\ttry {\n\t\t\t\t\tresolved = await this.resolve(\n\t\t\t\t\t\tstripEntryMarker(source),\n\t\t\t\t\t\tstripEntryMarker(importer),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// `kind` rides along so plugins keying on `require-call`\n\t\t\t\t\t\t\t// (wpExternals' CJS shim) still see the truth.\n\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t\tskipSelf: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} finally {\n\t\t\t\t\tinFlight.delete(key);\n\t\t\t\t}\n\n\t\t\t\tif (!resolved || resolved.external) return resolved;\n\t\t\t\tif (!isPartitionable(resolved.id)) return resolved;\n\t\t\t\treturn { ...resolved, id: withMarker(resolved.id, marker) };\n\t\t\t},\n\t\t},\n\n\t\tgenerateBundle: {\n\t\t\t// Load-bearing, not cosmetic: wpExternals emits its `.asset.php`\n\t\t\t// sidecars from `generateBundle`, unioning the dependencies of every\n\t\t\t// chunk an entry reaches — including the synthetic shim chunks this\n\t\t\t// hook inlines and deletes. Rolldown hands each plugin a freshly built\n\t\t\t// `bundle` object and drops `modules` mutations on write-back\n\t\t\t// (`collectChangedBundle` sends `modules: {}`), so the merge below\n\t\t\t// cannot be what keeps that union correct under Vite 8 — running after\n\t\t\t// the sidecars are emitted is.\n\t\t\torder: 'post',\n\t\t\tasync handler(_outputOptions, bundle) {\n\t\t\t\tawait init;\n\n\t\t\t\t// Fixpoint: inlining the runtime into the CJS-shim chunk is what\n\t\t\t\t// makes that shim chunk import-free and inlinable in turn.\n\t\t\t\tlet inlinedSomething = true;\n\t\t\t\twhile (inlinedSomething) {\n\t\t\t\t\tinlinedSomething = false;\n\t\t\t\t\tfor (const [fileName, chunk] of Object.entries(bundle)) {\n\t\t\t\t\t\tif (chunk.type !== 'chunk') continue;\n\t\t\t\t\t\tif (chunk.isEntry || chunk.isDynamicEntry) continue;\n\t\t\t\t\t\tif (!isInlinableSyntheticChunk(chunk)) continue;\n\t\t\t\t\t\tconst expression = toInlineExpression(chunk.code);\n\t\t\t\t\t\tif (!expression) continue;\n\n\t\t\t\t\t\tlet consumers = 0;\n\t\t\t\t\t\tlet failures = 0;\n\t\t\t\t\t\tfor (const [hostFileName, host] of Object.entries(bundle)) {\n\t\t\t\t\t\t\tif (host.type !== 'chunk' || hostFileName === fileName) continue;\n\t\t\t\t\t\t\tif (!(host.imports ?? []).includes(fileName)) continue;\n\t\t\t\t\t\t\tconsumers += 1;\n\t\t\t\t\t\t\tif (!inlineChunkInto(host, hostFileName, fileName, expression)) {\n\t\t\t\t\t\t\t\tfailures += 1;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tabsorbChunkMetadata(host, chunk, fileName);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (consumers > 0 && failures === 0) {\n\t\t\t\t\t\t\tdelete bundle[fileName];\n\t\t\t\t\t\t\tinlinedSomething = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Anything left that another chunk still imports is a shared chunk\n\t\t\t\t// we could not duplicate — name the modules so the failure is\n\t\t\t\t// actionable instead of a browser SyntaxError.\n\t\t\t\tfor (const [fileName, chunk] of Object.entries(bundle)) {\n\t\t\t\t\tif (chunk.type !== 'chunk' || chunk.isEntry || chunk.isDynamicEntry) continue;\n\t\t\t\t\tconst consumers = Object.entries(bundle)\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t([, host]) =>\n\t\t\t\t\t\t\t\thost.type === 'chunk' && (host.imports ?? []).includes(fileName),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map(([hostFileName]) => hostFileName);\n\t\t\t\t\tif (consumers.length === 0) continue;\n\t\t\t\t\tconst moduleIds = Object.keys(chunk.modules ?? {});\n\t\t\t\t\t// A non-JS module (typically a shared `.json`) is the one\n\t\t\t\t\t// cause with a remedy the consumer can apply themselves.\n\t\t\t\t\tconst unpartitionable = moduleIds.filter(\n\t\t\t\t\t\t(id) =>\n\t\t\t\t\t\t\t!id.includes('\\0') && !PARTITIONABLE_EXTENSION.test(id.split('?')[0]!),\n\t\t\t\t\t);\n\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t`wp-script-dedupe: shared chunk ${fileName} could not be duplicated into its consumers (${consumers.join(', ')}). ` +\n\t\t\t\t\t\t\t`It holds: ${moduleIds.join(', ')}. ` +\n\t\t\t\t\t\t\t(unpartitionable.length > 0\n\t\t\t\t\t\t\t\t? `Only JS/TS modules can be partitioned per entry, so a shared non-JS module (${unpartitionable.join(', ')}) stays in a chunk a classic script cannot import. ` +\n\t\t\t\t\t\t\t\t\t`Re-export it from a per-entry .ts module, give each entry its own copy, or build these entries in module mode.`\n\t\t\t\t\t\t\t\t: `A classic script cannot import, so those entries will not load — report the module list above upstream.`),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Fold an inlined chunk's bookkeeping into its host: module maps (so a\n * Rollup-driven pipeline's `chunk.modules` walk still sees the shim modules\n * that carry the `react` / `wp-components` handles), the import edge, and\n * Vite's CSS/asset metadata.\n */\nfunction absorbChunkMetadata(\n\thost: Rollup.OutputChunk,\n\tinlined: Rollup.OutputChunk,\n\tinlinedFileName: string,\n): void {\n\thost.modules = { ...host.modules, ...inlined.modules };\n\thost.moduleIds = [...new Set([...(host.moduleIds ?? []), ...(inlined.moduleIds ?? [])])];\n\thost.imports = (host.imports ?? []).filter((imported) => imported !== inlinedFileName);\n\tconst importedBindings = (host as unknown as { importedBindings?: Record<string, string[]> })\n\t\t.importedBindings;\n\tif (importedBindings) delete importedBindings[inlinedFileName];\n\tmergeViteMetadata(host, inlined);\n}\n\n/** Merge an inlined chunk's Vite metadata so CSS/asset bookkeeping survives. */\nfunction mergeViteMetadata(host: Rollup.OutputChunk, inlined: Rollup.OutputChunk): void {\n\tconst hostMetadata = host.viteMetadata;\n\tconst inlinedMetadata = inlined.viteMetadata;\n\tif (!hostMetadata || !inlinedMetadata) return;\n\tfor (const cssFileName of inlinedMetadata.importedCss ?? []) {\n\t\thostMetadata.importedCss?.add(cssFileName);\n\t}\n\tfor (const assetFileName of inlinedMetadata.importedAssets ?? []) {\n\t\thostMetadata.importedAssets?.add(assetFileName);\n\t}\n}\n\n/**\n * Replace every static import of `targetFileName` in `host` with the inline\n * expression. Returns false when a statement's shape isn't rewritable, in\n * which case the caller keeps the chunk (and the warning path fires).\n */\nfunction inlineChunkInto(\n\thost: Rollup.OutputChunk,\n\thostFileName: string,\n\ttargetFileName: string,\n\texpression: string,\n): boolean {\n\tconst [imports] = parse(host.code);\n\tconst replacements: { start: number; end: number; code: string }[] = [];\n\tlet counter = 0;\n\n\tfor (const record of imports) {\n\t\t// Static imports only — a dynamic `import()` of a synthetic chunk\n\t\t// cannot be inlined (and never happens for these ids).\n\t\tif (record.d !== -1) continue;\n\t\tif (!record.n) continue;\n\t\tif (resolveChunkSpecifier(hostFileName, record.n) !== targetFileName) continue;\n\n\t\tconst clause = parseImportClause(host.code.slice(record.ss, record.se));\n\t\tif (!clause) return false;\n\n\t\tconst named = clause.named\n\t\t\t.map(({ imported, local }) => `${objectKey(imported)}: ${local}`)\n\t\t\t.join(', ');\n\t\tlet code: string;\n\t\tif (clause.default || (clause.namespace && clause.named.length > 0)) {\n\t\t\tconst temp = `__wpInlined${counter++}`;\n\t\t\tconst parts = [`const ${temp} = ${expression};`];\n\t\t\tif (clause.default) parts.push(`const ${clause.default} = ${temp}[\"default\"];`);\n\t\t\tif (clause.namespace) parts.push(`const ${clause.namespace} = ${temp};`);\n\t\t\tif (named) parts.push(`const { ${named} } = ${temp};`);\n\t\t\tcode = parts.join('\\n');\n\t\t} else if (clause.namespace) {\n\t\t\tcode = `const ${clause.namespace} = ${expression};`;\n\t\t} else if (named) {\n\t\t\tcode = `const { ${named} } = ${expression};`;\n\t\t} else {\n\t\t\tcode = `${expression};`;\n\t\t}\n\t\treplacements.push({ start: record.ss, end: record.se, code });\n\t}\n\n\tif (replacements.length === 0) return false;\n\n\tconst magicString = new MagicString(host.code);\n\t// Last-to-first so each sourcemap shift is computed against line numbers\n\t// that haven't moved yet.\n\tfor (const replacement of replacements.reverse()) {\n\t\tmagicString.overwrite(replacement.start, replacement.end, replacement.code);\n\t\tconst line = host.code.slice(0, replacement.start).split('\\n').length - 1;\n\t\tconst addedLines =\n\t\t\treplacement.code.split('\\n').length -\n\t\t\thost.code.slice(replacement.start, replacement.end).split('\\n').length;\n\t\tshiftMappings(host.map as { mappings?: string } | null, line, addedLines);\n\t}\n\thost.code = magicString.toString();\n\treturn true;\n}\n","/**\n * vite-plugin-wp-script-iife\n *\n * Wraps each script-mode entry chunk in an IIFE post-write — esbuild/oxc's\n * minifier would otherwise inline a plain intro/outro IIFE for var-heavy\n * bodies, defeating the global-scope isolation needed when WP enqueues\n * these as classic <script> tags.\n *\n * It is also the gate that guarantees the output *is* a valid classic script:\n * every chunk is parsed before it's wrapped, and one that doesn't compile fails\n * the build instead of shipping a file the browser cannot load. The two causes\n * worth diagnosing by name are a live `import`/`export` statement (a shared\n * chunk Rolldown refused to duplicate) and an `import.meta` reference (Vite's\n * dynamic-import preload helper). The `import.meta` members that helper touches\n * are rewritten to classic-script-safe expressions through an injected\n * `define`, so the failure only fires for cases the define can't reach.\n *\n * Only run this in script mode. Module-mode entries (`wp_register_script_module`)\n * must stay as bare ESM for WP's import map to resolve them at runtime.\n */\nimport type { Plugin, UserConfig } from 'vite';\n\n/**\n * `import.meta` is a hard SyntaxError in a classic script, and Vite injects\n * its module-preload helper (which reads `import.meta.url`) whenever the\n * bundled graph contains a dynamic `import()` — `build.modulePreload: false`\n * does not stop that, it only controls link-preload emission. Replacing the\n * members at build time is the only thing that keeps such an entry loadable.\n */\nconst CLASSIC_SCRIPT_DEFINE: Record<string, string> = {\n\t'import.meta.url': 'document.currentScript && document.currentScript.src',\n\t'import.meta.resolve': 'undefined',\n};\n\n/**\n * Match a top-level `import`/`export` *statement* that survived stripping.\n * Deliberately narrow: `import(` / `import.meta` are expressions, and an\n * object property named `export:` starts a line often enough in unminified\n * chunk bodies that `/^export\\b/` alone would cry wolf.\n */\nconst LIVE_MODULE_STATEMENT =\n\t/^[ \\t]*(?:import\\s*(?:[{*\"']|[A-Za-z_$][\\w$]*\\s*(?:,|from\\b))|export\\s*(?:[{*]|(?:default|const|let|var|function|class|async)\\b))[^\\n]*/m;\n\nexport function wpScriptIife(): Plugin {\n\treturn {\n\t\tname: 'wp-script-iife',\n\t\t// Build-only. Vite filters plugins by `apply` before it runs `config`,\n\t\t// which is what keeps the `import.meta` define below out of `vite serve`\n\t\t// — the dev server ships real ESM to the browser, where `import.meta.url`\n\t\t// is both legal and load-bearing.\n\t\tapply: 'build',\n\n\t\tconfig(userConfig: UserConfig) {\n\t\t\t// User-supplied values win: someone may have a better answer for\n\t\t\t// their runtime than `document.currentScript`.\n\t\t\tconst define: Record<string, string> = {};\n\t\t\tfor (const [key, value] of Object.entries(CLASSIC_SCRIPT_DEFINE)) {\n\t\t\t\tif (userConfig.define && key in userConfig.define) continue;\n\t\t\t\tdefine[key] = value;\n\t\t\t}\n\t\t\treturn Object.keys(define).length > 0 ? { define } : null;\n\t\t},\n\n\t\tasync writeBundle(options, bundle) {\n\t\t\tconst { readFile, writeFile } = await import('node:fs/promises');\n\t\t\tconst { join } = await import('node:path');\n\t\t\tconst outDir = options.dir ?? '.';\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk') continue;\n\t\t\t\tif (!fileName.endsWith('.js') && !fileName.endsWith('.mjs')) continue;\n\t\t\t\tif (!output.isEntry && !output.isDynamicEntry) continue;\n\t\t\t\tconst filePath = join(outDir, fileName);\n\t\t\t\tlet chunkSource = await readFile(filePath, 'utf8');\n\t\t\t\tconst sideEffectImport = /^\\s*import\\s+[\"'][^\"']+[\"'];?\\s*\\n?/;\n\t\t\t\twhile (sideEffectImport.test(chunkSource)) {\n\t\t\t\t\tchunkSource = chunkSource.replace(sideEffectImport, '');\n\t\t\t\t}\n\t\t\t\tassertClassicScript(fileName, chunkSource, output.isEntry !== true);\n\t\t\t\tawait writeFile(filePath, `(()=>{\\n${chunkSource}\\n})();\\n`);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Fail the build rather than write a file the browser refuses to parse.\n * `this.error()` isn't available in `writeBundle`, so this throws.\n *\n * The parser is the ground truth, not the regexes: `new Function(code)` compiles\n * the body under the same rules a classic `<script>` applies to the things we\n * care about (a top-level `import`/`export` statement and `import.meta` are all\n * SyntaxErrors inside a function body), so a chunk that merely *mentions*\n * `import.meta` in a string — feature detection, an error message — can never\n * fail the build. The regexes only run afterwards, to turn the parse error into\n * a diagnosis worth reading. Anything the regexes don't explain still fails,\n * with the parser's own message: that's how we catch classic-script syntax\n * errors we didn't anticipate.\n *\n * Two constructs differ between a function body and a script top level:\n * top-level `await` (legal in a module, SyntaxError here) and `return` (legal\n * here, SyntaxError in a script). Neither appears in valid Rolldown script-mode\n * output — and this code is about to be wrapped in an IIFE anyway, which gives\n * it exactly a function body's rules.\n */\nfunction assertClassicScript(fileName: string, code: string, isDynamicOnly = false): void {\n\tlet parseError: unknown;\n\ttry {\n\t\tnew Function(code);\n\t\treturn;\n\t} catch (error) {\n\t\tif (!(error instanceof SyntaxError)) throw error;\n\t\tparseError = error;\n\t}\n\n\tconst liveStatement = code.match(LIVE_MODULE_STATEMENT);\n\tif (liveStatement) {\n\t\tconst specifiers = [...code.matchAll(/^[ \\t]*(?:import|export)\\b[^\\n]*?[\"']([^\"']+)[\"']/gm)]\n\t\t\t.map((match) => match[1]!)\n\t\t\t.filter((specifier, index, all) => all.indexOf(specifier) === index);\n\t\tthrow new Error(\n\t\t\t`wp-script-iife: ${fileName} still contains a top-level module statement, which is a SyntaxError once WordPress enqueues it as a classic script:\\n` +\n\t\t\t\t` ${liveStatement[0].trim()}\\n` +\n\t\t\t\t(specifiers.length > 0 ? ` Imported chunk(s): ${specifiers.join(', ')}\\n` : '') +\n\t\t\t\t(isDynamicOnly\n\t\t\t\t\t? ` This file is a dynamic-import chunk, so it needs its \\`export\\`s and cannot be an IIFE. A script-mode entry can't lazily load one either (WP has no module context to resolve it in) — drop the dynamic \\`import()\\`, or build this entry in module mode.`\n\t\t\t\t\t: ` This is almost always a shared chunk: a module two or more script-mode entries import gets hoisted into its own chunk instead of being duplicated into each entry. ` +\n\t\t\t\t\t\t`Add the wpScriptDedupe() plugin (auto-included by wp() in script mode — check you haven't set \\`scriptDedupe: false\\`), or build this entry in module mode.`),\n\t\t);\n\t}\n\n\tif (/\\bimport\\.meta\\b/.test(code)) {\n\t\tthrow new Error(\n\t\t\t`wp-script-iife: ${fileName} references \\`import.meta\\`, which is a SyntaxError once WordPress enqueues it as a classic script.\\n` +\n\t\t\t\t` Vite injects its module-preload helper (which reads \\`import.meta.url\\`) whenever the bundled graph contains a dynamic \\`import()\\` — \\`build.modulePreload: false\\` does not remove it. ` +\n\t\t\t\t`This plugin's \\`config()\\` hook defines \\`import.meta.url\\`/\\`import.meta.resolve\\` away; a surviving reference means either that define was overridden, or the code touches another \\`import.meta\\` member. ` +\n\t\t\t\t`Extend \\`define\\` in your Vite config, or move this entry to module mode.`,\n\t\t);\n\t}\n\n\tthrow new Error(\n\t\t`wp-script-iife: ${fileName} does not parse as a classic script, so WordPress could not load it:\\n` +\n\t\t\t` ${(parseError as SyntaxError).message}\\n` +\n\t\t\t` Nothing in this plugin's usual suspects (a shared chunk's \\`import\\`, an \\`import.meta\\` reference) explains it — inspect the written file, and report it upstream if the source is valid.`,\n\t);\n}\n","/**\n * vite-plugin-wp-clean-css-chunks\n *\n * Deletes the empty `.js` shim Vite leaves next to a CSS-only entry.\n *\n * Vite's Rollup-driven model treats every entry as a JS module that may\n * pull in CSS via side-effect imports. For an entry whose source IS a CSS\n * file (e.g. each per-block stylesheet produced by wpBlockStyles), Vite\n * still emits a tiny empty `.js` chunk that just imports the `.css`.\n * Useless for WP enqueueing.\n */\nimport type { Plugin } from 'vite';\n\nexport function wpCleanCssChunks(): Plugin {\n\treturn {\n\t\tname: 'wp-clean-css-chunks',\n\t\tgenerateBundle(_options, bundle) {\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk') continue;\n\t\t\t\tconst facadeModuleId = output.facadeModuleId ?? '';\n\t\t\t\tif (/\\.(s?css|sass)$/.test(facadeModuleId)) {\n\t\t\t\t\tdelete bundle[fileName];\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * vite-plugin-wp-css-asset-info\n *\n * Emits a `<name>.asset.php` sidecar for CSS-only entries — a stylesheet\n * declared directly in `build.rollupOptions.input` with no JS twin.\n *\n * 10up-toolkit (webpack) emitted a sidecar for every entry, JS or CSS, and\n * `TenupFramework\\Assets\\GetAssetInfo::get_asset_info()` reads it for the\n * cache-busting `version` PHP passes to `wp_enqueue_style()`. Rolldown emits\n * no JS chunk for a stylesheet entry (there's no code to bundle), so\n * `wpExternals`' chunk walk — which builds sidecars from `chunk.modules` —\n * never sees anything to write one for. Without this plugin, every CSS-only\n * enqueue migrated from toolkit silently falls back to a hardcoded version:\n * the build succeeds, nothing warns, and cache-busting just stops working.\n */\nimport crypto from 'node:crypto';\nimport type { Plugin, Rollup } from 'vite';\n\n/** Extensions treated as \"this entry's source IS a stylesheet\". */\nconst STYLESHEET_EXTENSION = /\\.(css|scss|sass)$/i;\n\nexport function wpCssAssetInfo(): Plugin {\n\t// entryName -> absolute source path, populated in configResolved so\n\t// generateBundle doesn't need to re-derive entry identity from the bundle.\n\tconst cssEntries = new Map<string, string>();\n\n\treturn {\n\t\tname: 'wp-css-asset-info',\n\n\t\tconfigResolved(config) {\n\t\t\tcssEntries.clear();\n\t\t\tconst input = config.build?.rollupOptions?.input;\n\t\t\t// Object input is the shape every entry in this project (and\n\t\t\t// wpBlockStyles' autoenqueue entries) uses — a name -> source map.\n\t\t\t// String/array inputs don't carry an explicit entry name to key a\n\t\t\t// sidecar off of, so they're left alone rather than guessed at.\n\t\t\tif (!input || typeof input !== 'object' || Array.isArray(input)) return;\n\n\t\t\tfor (const [entryName, source] of Object.entries(input as Record<string, unknown>)) {\n\t\t\t\tif (typeof source === 'string' && STYLESHEET_EXTENSION.test(source)) {\n\t\t\t\t\tcssEntries.set(entryName, source);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tgenerateBundle: {\n\t\t\t// MUST be post: wpBlockStyles strips its dedup markers from CSS\n\t\t\t// assets in its own normal-order generateBundle, and the version has\n\t\t\t// to hash the FINAL shipped bytes, not the pre-strip content.\n\t\t\torder: 'post',\n\t\t\thandler(_outputOptions, bundle) {\n\t\t\t\tfor (const [entryName, sourcePath] of cssEntries) {\n\t\t\t\t\tconst expectedFileName = `${entryName}.css`;\n\t\t\t\t\tconst cssAsset = findCssAsset(bundle, expectedFileName, sourcePath);\n\t\t\t\t\tif (!cssAsset) continue;\n\n\t\t\t\t\tconst assetPhpFileName = cssAsset.fileName.replace(/\\.css$/i, '.asset.php');\n\t\t\t\t\tif (bundle[assetPhpFileName]) continue; // already emitted (by us, or another plugin)\n\n\t\t\t\t\tconst version = crypto.createHash('md5').update(cssAsset.source).digest('hex');\n\n\t\t\t\t\tthis.emitFile({\n\t\t\t\t\t\ttype: 'asset',\n\t\t\t\t\t\tfileName: assetPhpFileName,\n\t\t\t\t\t\tsource: `<?php return array( 'dependencies' => array(), 'version' => '${version}' );\\n`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Find the CSS asset an entry produced. `assetFileNames: '[name][extname]'`\n * (the common WP setup) makes the bundle key match `<entryName>.css`\n * directly; a different pattern (default Vite hashed names, a nested output\n * dir) loses that, so `names` — which Vite/Rolldown populates from the entry\n * name regardless of the actual emitted path — is the robust fallback.\n * `originalFileNames` (the source path, root-relative) is checked too for\n * setups where neither of the above lines up.\n */\nfunction findCssAsset(\n\tbundle: Rollup.OutputBundle,\n\texpectedFileName: string,\n\tsourcePath: string,\n): Rollup.OutputAsset | undefined {\n\tconst direct = bundle[expectedFileName];\n\tif (direct && direct.type === 'asset') return direct;\n\n\tfor (const output of Object.values(bundle)) {\n\t\tif (output.type !== 'asset') continue;\n\t\tif (output.names?.includes(expectedFileName)) return output;\n\t\tif (output.originalFileNames?.some((name) => sourcePath.endsWith(name))) return output;\n\t}\n\treturn undefined;\n}\n","/**\n * `wp()` — thin composer for the four WP Vite plugins plus the two helpers.\n *\n * Top-level shortcuts cover the 90% case (just point at the dirs you have).\n * Per-plugin nested keys are the escape hatch for advanced options.\n *\n * - `blocksDir`, `blocksStylesDir`, `copyAssetsDir`, `adminPagesDir`: when\n * set, the corresponding plugin is included.\n * - `blocks`, `blockStyles`, `copyAssets`, `adminPages`, `externals`: pass\n * a full options object for that plugin. Nested keys win on conflict.\n * Pass `false` to disable the plugin entirely (overrides top-level).\n * - `externals` is always included by default (it has no required\n * options); pass `false` to disable. When `adminPagesDir` is set, its\n * resolved path is appended to the externals plugin's\n * `wpBuildAssetMatchers` so admin-page sidecars get the\n * `@wordpress/build` shape while block Script Modules keep the shape\n * WordPress core reads.\n * - `wpScriptIife` and `wpScriptDedupe` auto-included when\n * `buildType === 'script'` (a classic script has to be self-contained —\n * see docs/wp-script-dedupe.md).\n * - `wpCleanCssChunks` always included (it's a no-op without CSS-only\n * entries); pass `cleanCssChunks: false` to disable.\n * - `wpCssAssetInfo` always included (it's a no-op without CSS-only\n * entries); pass `cssAssetInfo: false` to disable.\n * - In module mode, a tiny inline `wp-module-entry-signatures` plugin sets\n * `build.rollupOptions.preserveEntrySignatures: 'exports-only'` unless\n * the user already set it themselves — see the comment on\n * `wpModuleEntrySignatures` below for why.\n *\n * For dual-pass (script + module) builds the consumer maps Vite mode to\n * `buildType` themselves:\n *\n * export default defineConfig(({ mode }) => ({\n * plugins: [\n * wp({\n * buildType: mode === 'modules' ? 'module' : 'script',\n * blocksDir: './includes/blocks',\n * }),\n * ],\n * }));\n */\nimport { resolve } from 'node:path';\nimport type { Plugin, UserConfig } from 'vite';\nimport { wpAdminPages, type WpAdminPagesOptions } from './wp-admin-pages';\nimport { wpBlocks, type WpBlocksOptions } from './wp-blocks';\nimport { wpBlockStyles, type WpBlockStylesOptions } from './wp-block-styles';\nimport { wpCopyAssets, type WpCopyAssetsOptions } from './wp-copy-assets';\nimport { wpExternals, type WpExternalsOptions } from './wp-externals';\nimport { wpScriptDedupe } from './wp-script-dedupe';\nimport { wpScriptIife } from './wp-script-iife';\nimport { wpCleanCssChunks } from './wp-clean-css-chunks';\nimport { wpCssAssetInfo } from './wp-css-asset-info';\n\n/**\n * A module-mode entry's export list IS its public contract: PHP registers it\n * with `wp_register_script_module()` and other code reaches it only through\n * WordPress's runtime import map, never through the build-time bundle graph.\n * Vite's app-build default, `preserveEntrySignatures: false`, tree-shakes an\n * entry's exports away whenever nothing in the graph imports them — which,\n * for these entries, is always. Worst case (`export * from 'focus-trap'`)\n * the built file comes out 0 bytes; short of that, an export gets stripped\n * while the module still emits, leaving importers with an empty namespace.\n * Either way the build succeeds silently.\n *\n * `preserveEntrySignatures: 'exports-only'` is the verified fix. This mirrors\n * `wpScriptIife`'s `define` injection: only fill in the setting if the user\n * config doesn't already have an opinion, so an explicit user value always\n * wins (Vite merges a plugin's `config()` result with the *plugin* winning\n * scalar conflicts, so the user check has to happen here, not via merge\n * order).\n */\nfunction wpModuleEntrySignatures(): Plugin {\n\treturn {\n\t\tname: 'wp-module-entry-signatures',\n\n\t\tconfig(userConfig: UserConfig) {\n\t\t\tif (userConfig.build?.rollupOptions?.preserveEntrySignatures !== undefined) return null;\n\t\t\treturn { build: { rollupOptions: { preserveEntrySignatures: 'exports-only' } } };\n\t\t},\n\t};\n}\n\nexport interface WpOptions {\n\t/** Build mode for sub-plugins. Default: `'script'`. */\n\tbuildType?: 'script' | 'module';\n\n\t// Top-level convenience: pass a dir to enable the plugin.\n\tblocksDir?: string;\n\tblocksStylesDir?: string;\n\tcopyAssetsDir?: string;\n\tadminPagesDir?: string;\n\n\t/**\n\t * Per-plugin escape hatches. Pass `false` to disable; pass an object\n\t * to merge extra options into the sub-plugin. Nested wins on conflict.\n\t */\n\tblocks?: Partial<WpBlocksOptions> | false;\n\tblockStyles?: Partial<WpBlockStylesOptions> | false;\n\tcopyAssets?: Partial<WpCopyAssetsOptions> | false;\n\tadminPages?: Partial<WpAdminPagesOptions> | false;\n\texternals?: WpExternalsOptions | false;\n\n\t/** Disable the auto-included script-IIFE helper. Default: enabled in script mode. */\n\tiife?: false;\n\t/**\n\t * Disable the auto-included per-entry module duplication. Default: enabled\n\t * in script mode. Without it, a module two script entries share becomes a\n\t * shared chunk each entry `import`s — invalid as a classic script.\n\t */\n\tscriptDedupe?: false;\n\t/** Disable the auto-included CSS-only-chunk cleanup. Default: always enabled. */\n\tcleanCssChunks?: false;\n\t/** Disable the auto-included CSS-only-entry `.asset.php` sidecars. Default: always enabled. */\n\tcssAssetInfo?: false;\n}\n\nexport function wp(options: WpOptions = {}): Plugin[] {\n\tconst buildType = options.buildType ?? 'script';\n\tconst plugins: Plugin[] = [];\n\n\t// wpBlocks\n\tif (options.blocks !== false) {\n\t\tconst blocksOptions = typeof options.blocks === 'object' ? options.blocks : undefined;\n\t\tconst blocksDir = blocksOptions?.blocksDir ?? options.blocksDir;\n\t\tif (blocksDir) {\n\t\t\tplugins.push(\n\t\t\t\twpBlocks({\n\t\t\t\t\tblocksDir,\n\t\t\t\t\tbuildType,\n\t\t\t\t\t...blocksOptions,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t// wpBlockStyles\n\tif (options.blockStyles !== false) {\n\t\tconst blockStylesOptions =\n\t\t\ttypeof options.blockStyles === 'object' ? options.blockStyles : undefined;\n\t\tconst blocksStylesDir = blockStylesOptions?.blocksStylesDir ?? options.blocksStylesDir;\n\t\tif (blocksStylesDir) {\n\t\t\tplugins.push(\n\t\t\t\twpBlockStyles({\n\t\t\t\t\tblocksStylesDir,\n\t\t\t\t\t...blockStylesOptions,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t// wpCopyAssets\n\tif (options.copyAssets !== false) {\n\t\tconst copyAssetsOptions =\n\t\t\ttypeof options.copyAssets === 'object' ? options.copyAssets : undefined;\n\t\tconst copyAssetsDir = copyAssetsOptions?.copyAssetsDir ?? options.copyAssetsDir;\n\t\tif (copyAssetsDir) {\n\t\t\tplugins.push(\n\t\t\t\twpCopyAssets({\n\t\t\t\t\tcopyAssetsDir,\n\t\t\t\t\tbuildType,\n\t\t\t\t\t...copyAssetsOptions,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t// wpAdminPages\n\tlet activeAdminPagesDir: string | undefined;\n\tif (options.adminPages !== false) {\n\t\tconst adminPagesOptions =\n\t\t\ttypeof options.adminPages === 'object' ? options.adminPages : undefined;\n\t\tconst adminPagesDir = adminPagesOptions?.adminPagesDir ?? options.adminPagesDir;\n\t\tif (adminPagesDir) {\n\t\t\tactiveAdminPagesDir = adminPagesDir;\n\t\t\tplugins.push(\n\t\t\t\twpAdminPages({\n\t\t\t\t\tadminPagesDir,\n\t\t\t\t\tbuildType,\n\t\t\t\t\t...adminPagesOptions,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t// wpExternals — always included unless explicitly disabled.\n\tif (options.externals !== false) {\n\t\tconst externalsOptions =\n\t\t\ttypeof options.externals === 'object' ? options.externals : undefined;\n\t\t// Admin pages are consumed by project PHP, not by core's block\n\t\t// registration, so their sidecars get the `@wordpress/build` shape.\n\t\t// Wiring the matcher here is what makes that zero-config.\n\t\tconst wpBuildAssetMatchers = [...(externalsOptions?.wpBuildAssetMatchers ?? [])];\n\t\tif (activeAdminPagesDir) {\n\t\t\tconst matcher = resolve(process.cwd(), activeAdminPagesDir).replace(/\\\\/g, '/');\n\t\t\tif (!wpBuildAssetMatchers.includes(matcher)) wpBuildAssetMatchers.push(matcher);\n\t\t}\n\t\tplugins.push(\n\t\t\t...wpExternals({\n\t\t\t\tbuildType,\n\t\t\t\t...externalsOptions,\n\t\t\t\t...(wpBuildAssetMatchers.length > 0 ? { wpBuildAssetMatchers } : {}),\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Helpers — auto-included; opt-out via `false`.\n\t// Position in this array is NOT what orders wpScriptDedupe's resolver.\n\t// It has to see every id before any other resolver answers — including\n\t// wpExternals' force-bundle resolver, pushed above — and it guarantees that\n\t// with a hook-level `order: 'pre'` instead, which no array shuffling here\n\t// (or by a consumer composing plugins by hand) can undo.\n\tif (buildType === 'script' && options.scriptDedupe !== false) {\n\t\tplugins.push(wpScriptDedupe());\n\t}\n\tif (buildType === 'script' && options.iife !== false) {\n\t\tplugins.push(wpScriptIife());\n\t}\n\t// Always on: any CSS-only entry (per-block styles, theme stylesheets\n\t// passed as first-class entries) leaves an empty JS shim behind, and the\n\t// cleanup is a no-op when none exist.\n\tif (options.cleanCssChunks !== false) {\n\t\tplugins.push(wpCleanCssChunks());\n\t}\n\t// Always on for the same reason: a CSS-only entry gets no sidecar from\n\t// wpExternals (there's no JS chunk for its chunk walk to find), and this\n\t// is a no-op when every entry has a JS twin.\n\tif (options.cssAssetInfo !== false) {\n\t\tplugins.push(wpCssAssetInfo());\n\t}\n\t// Module-mode-only: script-mode entries are already self-contained by\n\t// construction (wpScriptDedupe partitions the graph, wpScriptIife fails\n\t// the build otherwise), so no export ever needs preserving there.\n\tif (buildType === 'module') {\n\t\tplugins.push(wpModuleEntrySignatures());\n\t}\n\n\treturn plugins;\n}\n"]}
1
+ {"version":3,"sources":["../src/php-templates.ts","../src/wp-admin-pages.ts","../src/wp-blocks.ts","../src/wp-block-styles.ts","../src/wp-copy-assets.ts","../src/package-metadata.ts","../src/wp-externals.ts","../src/wp-script-dedupe.ts","../src/wp-script-iife.ts","../src/wp-clean-css-chunks.ts","../src/wp-css-asset-info.ts","../src/wp-dev-server.ts","../src/wp.ts"],"names":["resolve","readFileSync","join","existsSync","fg","relative","extname","require","resolvePath","dirname","realpathSync","options","external","re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AAAA,QACJ,mBAAA;AAAA,QACA,GAAI,oBAAA,CAAqB,MAAA,GAAS,IAAI,EAAE,oBAAA,KAAyB,EAAC;AAAA,QAClE,GAAG;AAAA,OACH;AAAA,KACF;AAIA,IAAA,OAAA,CAAQ,IAAA;AAAA,MACP,cAAA;AAAA,QACC,kBAAkB,SAAA,GAAY,EAAE,WAAW,gBAAA,CAAiB,SAAA,KAAc;AAAC;AAC5E,KACD;AAAA,EACD;AAQA,EAAA,IAAI,SAAA,KAAc,QAAA,IAAY,OAAA,CAAQ,YAAA,KAAiB,KAAA,EAAO;AAC7D,IAAA,OAAA,CAAQ,IAAA,CAAK,gBAAgB,CAAA;AAAA,EAC9B;AACA,EAAA,IAAI,SAAA,KAAc,QAAA,IAAY,OAAA,CAAQ,IAAA,KAAS,KAAA,EAAO;AACrD,IAAA,OAAA,CAAQ,KAAK,YAAA,CAAa,EAAE,OAAA,EAAS,WAAA,EAAa,CAAC,CAAA;AAAA,EACpD;AAIA,EAAA,IAAI,OAAA,CAAQ,mBAAmB,KAAA,EAAO;AACrC,IAAA,OAAA,CAAQ,IAAA,CAAK,kBAAkB,CAAA;AAAA,EAChC;AAIA,EAAA,IAAI,OAAA,CAAQ,iBAAiB,KAAA,EAAO;AACnC,IAAA,OAAA,CAAQ,IAAA,CAAK,gBAAgB,CAAA;AAAA,EAC9B;AAIA,EAAA,IAAI,cAAc,QAAA,EAAU;AAC3B,IAAA,OAAA,CAAQ,IAAA,CAAK,yBAAyB,CAAA;AAAA,EACvC;AAEA,EAAA,OAAO,OAAA;AACR","file":"index.js","sourcesContent":["/**\n * PHP source generation for `@wordpress/boot` admin pages.\n *\n * A port of `@wordpress/build` 0.17.0's generated PHP layer (its\n * `templates/*.php.template` files plus the `generate*Php` functions in\n * `lib/build.mjs`) to TypeScript template functions. The package ships a\n * single tsup bundle, so the templates are string builders here rather than\n * files on disk — but they stay laid out like the originals so a future\n * upstream diff is still readable.\n *\n * Runtime behavior kept verbatim from wp-build: function/hook/filter naming,\n * the boot dependency-graph assembly, the REST preload middleware, the\n * `DOMContentLoaded`-deferred wp-admin bootstrap (core ticket 65103), the\n * full-page HTML shell with its `wp_script_modules()` printing and\n * `admin_init` render intercept, and the `file_exists()` guards that degrade\n * gracefully when a `.asset.php` sidecar is missing.\n *\n * Adapted for this repo's output layout:\n *\n * - modules live at `modules/<page>/…` (wp-build: `pages/<page>/`,\n * `routes/<name>/`), so route rows carry an explicit `dir`.\n * - one non-minified artifact per module (no `.min.js` / `SCRIPT_DEBUG`\n * switching).\n * - the prerequisites carrier reads the page's *own* `.asset.php` sidecars\n * (wp-build reads its bundled boot module's), unioned with core's boot\n * asset when that file exists.\n * - `false` (not `''`) as the carrier's `wp_register_script()` src.\n * - menu registration is generated when a page declares `menu` in\n * `page.json`; wp-build leaves menus to the author.\n * - the prefix is underscored consistently for every generated identifier\n * (wp-build emits invalid PHP for a dashed `wpPlugin.name` in\n * `routes.php`).\n */\n\n/** Which of the two page flavors a generated file implements. */\nexport type PageMode = 'full-page' | 'wp-admin';\n\n/** `'/wp/v2/settings'` or `['/wp/v2/settings', 'OPTIONS']`. */\nexport type RestPreloadEntry = string | [string, string];\n\n/** wp-build's hardcoded preload paths — our per-page default. */\nexport const DEFAULT_REST_PRELOAD: RestPreloadEntry[] = [\n\t'/?_fields=description,gmt_offset,home,image_sizes,image_size_threshold,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front',\n\t['/wp/v2/settings', 'OPTIONS'],\n];\n\n/** Both modes, in the order wp-build generates them. */\nexport const ALL_PAGE_MODES: PageMode[] = ['full-page', 'wp-admin'];\n\nexport interface PageMenu {\n\t/**\n\t * Parent menu file. Absent or `'options-general.php'` →\n\t * `add_options_page()`; `false` / `'toplevel'` → `add_menu_page()`;\n\t * any other slug → `add_submenu_page()`.\n\t */\n\tparent?: string | false;\n\t/** Capability required to see the page. Default `'manage_options'`. */\n\tcapability?: string;\n\t/** Top-level menu position (`add_menu_page()` only). */\n\tposition?: number;\n\t/** Top-level menu icon (`add_menu_page()` only). */\n\ticon?: string;\n}\n\nexport interface GeneratedRoute {\n\t/** Registry name. `'index'` for the page-root route. */\n\tname: string;\n\t/** Route path handed to `@wordpress/boot`. `'/'` for the page root. */\n\tpath: string;\n\t/** dist-relative module directory (`modules/<page>[/routes/<name>]`). */\n\tdir: string;\n\t/** Whether the route built a `content` module. */\n\thasContent: boolean;\n\t/** Whether the route built a `route` module. */\n\thasRoute: boolean;\n}\n\nexport interface GeneratedPage {\n\t/** Page directory name — the page slug. */\n\tslug: string;\n\t/** Human title, used for the menu labels. */\n\ttitle: string;\n\t/** Which files to generate for this page. */\n\tmodes: PageMode[];\n\t/** Script Module ids added to the boot graph as static dependencies. */\n\tinitModules: string[];\n\t/** REST paths preloaded into `wp.apiFetch`. */\n\trestPreload: RestPreloadEntry[];\n\t/** Generate an admin menu entry when present. */\n\tmenu?: PageMenu;\n\t/** Routes belonging to this page, page-root route first. */\n\troutes: GeneratedRoute[];\n}\n\nexport interface PhpContext {\n\t/** Identifier prefix for functions, globals and the `@package` tag. */\n\tprefix: string;\n\t/** Script Module id prefix (`<handlePrefix>/routes/<page>/<name>/…`). */\n\thandlePrefix: string;\n\t/** Raw PHP expression evaluating to the dist directory URL. */\n\tbaseUrl: string;\n\t/** Version written into `constants.php`. */\n\tversion: string;\n\t/** Text domain for the generated `__()` calls. */\n\ttextdomain: string;\n}\n\nexport interface GeneratedPhpFile {\n\t/** dist-relative output path. */\n\tfileName: string;\n\t/** PHP source. */\n\tsource: string;\n}\n\n/* -------------------------------------------------------------------------\n * Escaping / identifier helpers\n * ---------------------------------------------------------------------- */\n\n/** PHP single-quoted string literal. */\nexport function phpString(value: string): string {\n\treturn `'${value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n}\n\n/** `array( 'a', 'b' )` — `array()` when empty. */\nexport function phpStringArray(values: string[]): string {\n\tif (values.length === 0) return 'array()';\n\treturn `array( ${values.map(phpString).join(', ')} )`;\n}\n\n/** Dashes to underscores, for identifiers built out of slugs. */\nexport function toUnderscore(value: string): string {\n\treturn value.replace(/-/g, '_');\n}\n\n/** Valid as a PHP identifier fragment once dashes are underscored. */\nexport function isValidPhpIdentifier(value: string): boolean {\n\treturn /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(toUnderscore(value));\n}\n\n/** Page / route directory names allowed into slugs and module ids. */\nexport function isValidSlug(value: string): boolean {\n\treturn /^[a-z0-9-]+$/.test(value);\n}\n\n/** Naming for one (page, mode) pair — wp-build's `_wp_admin` infix. */\nfunction pageNames(page: GeneratedPage, mode: PageMode) {\n\tconst slugUnderscore = toUnderscore(page.slug);\n\tconst isWpAdmin = mode === 'wp-admin';\n\treturn {\n\t\t/** Script handle / module id / hook base: `settings-wp-admin`. */\n\t\thandle: isWpAdmin ? `${page.slug}-wp-admin` : page.slug,\n\t\t/** Function-name infix: `settings_wp_admin`. */\n\t\tfn: isWpAdmin ? `${slugUnderscore}_wp_admin` : slugUnderscore,\n\t\t/** Mount element id. */\n\t\tmountId: isWpAdmin ? `${page.slug}-wp-admin-app` : `${page.slug}-app`,\n\t};\n}\n\n/** The `.asset.php` sidecars whose classic handles the carrier must depend on. */\nfunction assetFileList(page: GeneratedPage): string[] {\n\tconst files: string[] = [];\n\tfor (const route of page.routes) {\n\t\tif (route.hasContent) files.push(`${route.dir}/content.asset.php`);\n\t\tif (route.hasRoute) files.push(`${route.dir}/route.asset.php`);\n\t}\n\treturn files;\n}\n\nfunction preloadPathsPhp(entries: RestPreloadEntry[], indent: string): string {\n\tif (entries.length === 0) return `${indent}// No REST paths configured.`;\n\treturn entries\n\t\t.map((entry) => {\n\t\t\tconst value = Array.isArray(entry)\n\t\t\t\t? `array( ${phpString(entry[0])}, ${phpString(entry[1])} )`\n\t\t\t\t: phpString(entry);\n\t\t\treturn `${indent}${value},`;\n\t\t})\n\t\t.join('\\n');\n}\n\nfunction initModulesPhp(initModules: string[], indent: string): string {\n\tif (initModules.length === 0) return `${indent}// No init modules configured.`;\n\treturn initModules\n\t\t.map(\n\t\t\t(moduleId) =>\n\t\t\t\t`${indent}$boot_dependencies[] = array( 'import' => 'static', 'id' => ${phpString(\n\t\t\t\t\tmoduleId,\n\t\t\t\t)} );`,\n\t\t)\n\t\t.join('\\n');\n}\n\n/* -------------------------------------------------------------------------\n * Shared page blocks\n * ---------------------------------------------------------------------- */\n\n/**\n * Globals, route/menu-item registrars, getters and the REST preloader —\n * wp-build duplicates this across `page.php.template` and\n * `page-wp-admin.php.template`; the only differences are the `_wp_admin`\n * infix and the full-page registrar's extra `$parent_type` argument.\n */\nfunction renderPageStateBlock(ctx: PhpContext, page: GeneratedPage, mode: PageMode): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst { handle, fn } = pageNames(page, mode);\n\tconst routesGlobal = `$${prefix}_${fn}_routes`;\n\tconst menuItemsGlobal = `$${prefix}_${fn}_menu_items`;\n\tconst parentTypeParam = mode === 'full-page' ? \", $parent_type = ''\" : '';\n\tconst parentTypeDoc =\n\t\tmode === 'full-page'\n\t\t\t? \" * @param string $parent_type Optional. Parent type: 'drilldown' or 'dropdown'.\\n\"\n\t\t\t: '';\n\tconst parentTypeBody =\n\t\tmode === 'full-page'\n\t\t\t? `\n\tif ( ! empty( $parent_type ) && in_array( $parent_type, array( 'drilldown', 'dropdown' ), true ) ) {\n\t\t$menu_item['parent_type'] = $parent_type;\n\t}\n`\n\t\t\t: '';\n\n\t// Pad the shorter assignment so the `=` line up, like wp-build's output.\n\tconst routesPad = ' '.repeat(Math.max(0, menuItemsGlobal.length - routesGlobal.length));\n\n\treturn `// Global storage for ${handle} routes and menu items.\nglobal ${routesGlobal}, ${menuItemsGlobal};\n${routesGlobal}${routesPad} = array();\n${menuItemsGlobal} = array();\n\n/**\n * Register a route for the ${handle} page.\n *\n * @param string $path Route path (e.g., '/types/$type/edit/$id').\n * @param string|null $content_module Script module ID for content (stage/inspector).\n * @param string|null $route_module Script module ID for route lifecycle hooks.\n */\nfunction ${prefix}_register_${fn}_route( $path, $content_module = null, $route_module = null ) {\n\tglobal ${routesGlobal};\n\n\t$route = array( 'path' => $path );\n\tif ( ! empty( $content_module ) ) {\n\t\t$route['content_module'] = $content_module;\n\t}\n\tif ( ! empty( $route_module ) ) {\n\t\t$route['route_module'] = $route_module;\n\t}\n\n\t${routesGlobal}[] = $route;\n}\n\n/**\n * Register a menu item for the ${handle} page.\n *\n * @param string $id Menu item ID.\n * @param string $label Display label.\n * @param string $to Route path to navigate to.\n * @param string $parent_id Optional. Parent menu item ID.\n${parentTypeDoc} */\nfunction ${prefix}_register_${fn}_menu_item( $id, $label, $to, $parent_id = ''${parentTypeParam} ) {\n\tglobal ${menuItemsGlobal};\n\n\t$menu_item = array(\n\t\t'id' => $id,\n\t\t'label' => $label,\n\t\t'to' => $to,\n\t);\n\n\tif ( ! empty( $parent_id ) ) {\n\t\t$menu_item['parent'] = $parent_id;\n\t}\n${parentTypeBody}\n\t${menuItemsGlobal}[] = $menu_item;\n}\n\n/**\n * Get all registered routes for the ${handle} page.\n *\n * @return array Array of route objects.\n */\nfunction ${prefix}_get_${fn}_routes() {\n\tglobal ${routesGlobal};\n\treturn ${routesGlobal} ?? array();\n}\n\n/**\n * Get all registered menu items for the ${handle} page.\n *\n * @return array Array of menu item objects.\n */\nfunction ${prefix}_get_${fn}_menu_items() {\n\tglobal ${menuItemsGlobal};\n\treturn ${menuItemsGlobal} ?? array();\n}\n\n/**\n * Preload REST API data for the ${handle} page.\n * Automatically called during page rendering.\n */\nfunction ${prefix}_${fn}_preload_data() {\n\t$preload_paths = array(\n${preloadPathsPhp(page.restPreload, '\\t\\t')}\n\t);\n\n\t// Use rest_preload_api_request to gather the preloaded data.\n\t$preload_data = array_reduce(\n\t\t$preload_paths,\n\t\t'rest_preload_api_request',\n\t\tarray()\n\t);\n\n\t// Register the preloading middleware with wp-api-fetch.\n\twp_add_inline_script(\n\t\t'wp-api-fetch',\n\t\tsprintf(\n\t\t\t'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );',\n\t\t\twp_json_encode( $preload_data )\n\t\t),\n\t\t'after'\n\t);\n}\n`;\n}\n\n/**\n * The prerequisites carrier: an empty-src classic script whose dependencies\n * are every classic handle the page's modules read off `window.*` (unioned\n * across the page's own sidecars and core's boot asset), plus the matching\n * style handles. Also where the inline bootstrap lands.\n */\nfunction renderCarrierBlock(ctx: PhpContext, page: GeneratedPage, mode: PageMode): string {\n\tconst { handle } = pageNames(page, mode);\n\tconst assetFiles = assetFileList(page)\n\t\t.map((file) => `\\t\\t__DIR__ . '/../../${file}',`)\n\t\t.join('\\n');\n\n\treturn `\t// Every classic script handle the page's modules read off window.* lives\n\t// in their .asset.php sidecars; the carrier depends on the union of them.\n\t$asset_files = array(\n${assetFiles}\n\t);\n\n\t$script_dependencies = array();\n\t$version = false;\n\t$has_assets = false;\n\n\tforeach ( $asset_files as $asset_file ) {\n\t\tif ( ! file_exists( $asset_file ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t$has_assets = true;\n\t\t$asset = require $asset_file;\n\t\tif ( ! empty( $asset['dependencies'] ) ) {\n\t\t\t$script_dependencies = array_merge( $script_dependencies, $asset['dependencies'] );\n\t\t}\n\t\tif ( false === $version && ! empty( $asset['version'] ) ) {\n\t\t\t$version = $asset['version'];\n\t\t}\n\t}\n\n\t// Core's boot module carries classic dependencies of its own.\n\t$boot_asset_file = ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php';\n\tif ( file_exists( $boot_asset_file ) ) {\n\t\t$boot_asset = require $boot_asset_file;\n\t\tif ( ! empty( $boot_asset['dependencies'] ) ) {\n\t\t\t$script_dependencies = array_merge( $script_dependencies, $boot_asset['dependencies'] );\n\t\t}\n\t}\n\n\t$script_dependencies = array_values( array_unique( $script_dependencies ) );\n\n\tif ( $has_assets ) {\n\t\t// This script serves two purposes:\n\t\t// 1. It ensures all the globals that are made available to the modules are loaded.\n\t\t// 2. It initializes the boot module as an inline script.\n\t\t// The src is \\`false\\`, not \\`''\\`: an empty-src carrier script.\n\t\twp_register_script( '${handle}-prerequisites', false, $script_dependencies, $version, true );\n`;\n}\n\n/** Boot dependency graph + loader module registration, shared by both modes. */\nfunction renderBootGraphBlock(ctx: PhpContext, page: GeneratedPage, mode: PageMode): string {\n\tconst { handle } = pageNames(page, mode);\n\n\treturn `\t\t// Register prerequisites style by filtering script dependencies to find registered styles.\n\t\t$style_dependencies = array_filter(\n\t\t\t$script_dependencies,\n\t\t\tfunction ( $handle ) {\n\t\t\t\treturn wp_style_is( $handle, 'registered' );\n\t\t\t}\n\t\t);\n\t\twp_register_style( '${handle}-prerequisites', false, $style_dependencies, $version );\n\n\t\t// Build dependencies for the ${handle} module.\n\t\t$boot_dependencies = array(\n\t\t\tarray(\n\t\t\t\t'import' => 'static',\n\t\t\t\t'id' => '@wordpress/boot',\n\t\t\t),\n\t\t);\n\n\t\t// Add init modules as static dependencies.\n${initModulesPhp(page.initModules, '\\t\\t')}\n\n\t\t// Add all registered routes as dependencies.\n\t\tforeach ( $routes as $route ) {\n\t\t\tif ( isset( $route['route_module'] ) ) {\n\t\t\t\t$boot_dependencies[] = array(\n\t\t\t\t\t'import' => 'static',\n\t\t\t\t\t'id' => $route['route_module'],\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( isset( $route['content_module'] ) ) {\n\t\t\t\t$boot_dependencies[] = array(\n\t\t\t\t\t'import' => 'dynamic',\n\t\t\t\t\t'id' => $route['content_module'],\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Filters the boot script-module dependencies for the\n\t\t * ${handle} page.\n\t\t *\n\t\t * Surfaces extending this page can append entries to the boot\n\t\t * dependency list. Each entry is an array with 'import' (string\n\t\t * 'static' or 'dynamic') and 'id' (script-module handle) keys.\n\t\t *\n\t\t * @param array $boot_dependencies Boot dependencies for the page.\n\t\t */\n\t\t$boot_dependencies = apply_filters(\n\t\t\t'${handle}_boot_dependencies',\n\t\t\t$boot_dependencies\n\t\t);\n\n\t\t// Dummy script module to ensure dependencies are loaded.\n\t\twp_register_script_module(\n\t\t\t'${handle}',\n\t\t\t$build_constants['build_url'] . 'modules/${page.slug}/loader.js',\n\t\t\t$boot_dependencies\n\t\t);\n\n\t\t// Enqueue the boot scripts and styles.\n\t\twp_enqueue_script( '${handle}-prerequisites' );\n\t\twp_enqueue_script_module( '${handle}' );\n\t\twp_enqueue_style( '${handle}-prerequisites' );\n\t}\n`;\n}\n\n/**\n * `{prefix}_register_{slug}_menu()` on `admin_menu`. One step beyond\n * wp-build, which leaves menu registration to the author.\n */\nfunction renderMenuBlock(ctx: PhpContext, page: GeneratedPage, mode: PageMode): string {\n\tif (!page.menu) return '';\n\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst slugUnderscore = toUnderscore(page.slug);\n\tconst { handle, fn } = pageNames(page, mode);\n\tconst menu = page.menu;\n\tconst capability = phpString(menu.capability ?? 'manage_options');\n\tconst title = `__( ${phpString(page.title)}, ${phpString(ctx.textdomain)} )`;\n\tconst renderCallback = phpString(`${prefix}_${fn}_render_page`);\n\tconst menuSlug = phpString(handle);\n\n\tlet call: string;\n\tif (menu.parent === false || menu.parent === 'toplevel') {\n\t\tconst icon = phpString(menu.icon ?? 'dashicons-admin-generic');\n\t\tconst position = typeof menu.position === 'number' ? String(menu.position) : 'null';\n\t\tcall = `\tadd_menu_page(\n\t\t${title},\n\t\t${title},\n\t\t${capability},\n\t\t${menuSlug},\n\t\t${renderCallback},\n\t\t${icon},\n\t\t${position}\n\t);`;\n\t} else if (menu.parent === undefined || menu.parent === 'options-general.php') {\n\t\tcall = `\tadd_options_page(\n\t\t${title},\n\t\t${title},\n\t\t${capability},\n\t\t${menuSlug},\n\t\t${renderCallback}\n\t);`;\n\t} else {\n\t\tcall = `\tadd_submenu_page(\n\t\t${phpString(menu.parent)},\n\t\t${title},\n\t\t${title},\n\t\t${capability},\n\t\t${menuSlug},\n\t\t${renderCallback}\n\t);`;\n\t}\n\n\treturn `\n/**\n * Register the admin menu entry for the ${handle} page.\n */\nfunction ${prefix}_register_${slugUnderscore}_menu() {\n${call}\n}\nadd_action( 'admin_menu', '${prefix}_register_${slugUnderscore}_menu' );\n`;\n}\n\n/* -------------------------------------------------------------------------\n * page.php — full-page takeover mode\n * ---------------------------------------------------------------------- */\n\nexport function renderPagePhp(ctx: PhpContext, page: GeneratedPage): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst mode: PageMode = 'full-page';\n\tconst { handle, fn, mountId } = pageNames(page, mode);\n\n\treturn `<?php\n/**\n * Page: ${handle}\n * Auto-generated by build process. Do not edit this file manually.\n *\n * Full-page takeover mode: renders its own HTML document and boots the app\n * with \\`init()\\`, so the wp-admin chrome is replaced entirely.\n *\n * @package ${ctx.prefix}\n */\n\n${renderPageStateBlock(ctx, page, mode)}\n/**\n * Render the ${handle} page.\n * Call this function from add_menu_page or add_submenu_page.\n */\nfunction ${prefix}_${fn}_render_page() {\n\t// Load build constants.\n\t$build_constants = require __DIR__ . '/../../constants.php';\n\n\t// Set current screen.\n\tset_current_screen();\n\n\t// Remove unwanted deprecated handler.\n\tremove_action( 'admin_head', 'wp_admin_bar_header' );\n\n\t// Remove unwanted scripts and styles that were enqueued during \\`admin_init\\`.\n\tforeach ( wp_scripts()->queue as $script ) {\n\t\twp_dequeue_script( $script );\n\t}\n\tforeach ( wp_styles()->queue as $style ) {\n\t\twp_dequeue_style( $style );\n\t}\n\n\t/**\n\t * Fires when the ${handle} page is initialized so extensions can register routes and menu items.\n\t */\n\tdo_action( '${handle}_init' );\n\n\t// Enqueue command palette assets for boot-based pages.\n\tif ( function_exists( 'wp_enqueue_command_palette_assets' ) ) {\n\t\twp_enqueue_command_palette_assets();\n\t}\n\n\t// Preload REST API data.\n\t${prefix}_${fn}_preload_data();\n\n\t// Get all registered routes and menu items.\n\t$menu_items = ${prefix}_get_${fn}_menu_items();\n\t$routes = ${prefix}_get_${fn}_routes();\n\n${renderCarrierBlock(ctx, page, mode)}\n\t\t// Add inline script to initialize the app.\n\t\t$init_modules = ${phpStringArray(page.initModules)};\n\t\twp_add_inline_script(\n\t\t\t'${handle}-prerequisites',\n\t\t\tsprintf(\n\t\t\t\t'import(\"@wordpress/boot\").then(mod => mod.init({mountId: \"%s\", menuItems: %s, routes: %s, initModules: %s, dashboardLink: \"%s\"}));',\n\t\t\t\t'${mountId}',\n\t\t\t\twp_json_encode( $menu_items, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\twp_json_encode( $routes, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\twp_json_encode( $init_modules, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\tesc_url( admin_url( '/' ) )\n\t\t\t)\n\t\t);\n\n${renderBootGraphBlock(ctx, page, mode)}\n\t// Output the HTML.\n\t?>\n\t<!DOCTYPE html>\n\t<html <?php language_attributes(); ?>>\n\t<head>\n\t\t<meta charset=\"<?php bloginfo( 'charset' ); ?>\">\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<title><?php echo esc_html( get_admin_page_title() ); ?></title>\n\t\t<style>\n\t\t\thtml {\n\t\t\t\tbackground: #f1f1f1;\n\t\t\t\tcolor: #444;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t\tfont-size: 13px;\n\t\t\t\tline-height: 1.4em;\n\t\t\t}\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t#wpadminbar { display: none; }\n\t\t</style>\n\t<?php\n\tglobal $hook_suffix;\n\t// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited\n\t$hook_suffix = '${handle}';\n\n\t// BEGIN see wp-admin/admin-header.php\n\tprint_admin_styles();\n\tprint_head_scripts();\n\n\t/** This action is documented in wp-admin/admin-header.php */\n\tdo_action( \"admin_head-{$hook_suffix}\" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores\n\n\t/** This action is documented in wp-admin/admin-header.php */\n\tdo_action( 'admin_head' );\n\t// END see wp-admin/admin-header.php\n\t?>\n\t</head>\n\t<body class=\"${handle}\">\n\t\t<div id=\"${mountId}\" style=\"height: 100vh; box-sizing: border-box;\"></div>\n\t<?php\n\t// BEGIN see wp-admin/admin-footer.php\n\n\t/** This action is documented in wp-admin/admin-footer.php */\n\tdo_action( 'admin_footer', '' );\n\n\t// Print import map first so it's available for inline scripts.\n\twp_script_modules()->print_import_map();\n\tprint_footer_scripts();\n\twp_script_modules()->print_enqueued_script_modules();\n\twp_script_modules()->print_script_module_preloads();\n\twp_script_modules()->print_script_module_data();\n\n\t/** This action is documented in wp-admin/admin-footer.php */\n\tdo_action( \"admin_footer-{$hook_suffix}\" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores\n\t// END see wp-admin/admin-footer.php\n\t?>\n\t</body>\n\t</html>\n\t<?php\n\texit;\n}\n\n/**\n * Intercept admin_init to render the page early.\n * This bypasses the default WordPress admin template.\n */\nfunction ${prefix}_${fn}_intercept_render() {\n\t// phpcs:ignore WordPress.Security.NonceVerification.Recommended\n\tif ( isset( $_GET['page'] ) && '${handle}' === $_GET['page'] ) {\n\t\t${prefix}_${fn}_render_page();\n\t\texit;\n\t}\n}\n\n// Hook the interceptor to admin_init.\nadd_action( 'admin_init', '${prefix}_${fn}_intercept_render' );\n${renderMenuBlock(ctx, page, mode)}`;\n}\n\n/* -------------------------------------------------------------------------\n * page-wp-admin.php — wp-admin integrated mode\n * ---------------------------------------------------------------------- */\n\nexport function renderPageWpAdminPhp(ctx: PhpContext, page: GeneratedPage): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst mode: PageMode = 'wp-admin';\n\tconst { handle, fn, mountId } = pageNames(page, mode);\n\n\treturn `<?php\n/**\n * Page: ${page.slug} (wp-admin integrated)\n * Auto-generated by build process. Do not edit this file manually.\n *\n * This version integrates with the standard WordPress admin interface,\n * keeping the wp-admin sidebar and scripts/styles intact.\n *\n * @package ${ctx.prefix}\n */\n\n${renderPageStateBlock(ctx, page, mode)}\n/**\n * Enqueue scripts and styles for the ${handle} page.\n * Hooked to admin_enqueue_scripts.\n *\n * @param string $hook_suffix The current admin page.\n */\nfunction ${prefix}_${fn}_enqueue_scripts( $hook_suffix ) {\n\t// Check all possible ways this page can be accessed:\n\t// 1. Menu page via admin.php?page=${handle}\n\t// 2. Direct file whose screen ID is '${page.slug}'\n\t$current_screen = get_current_screen();\n\t$is_our_page = (\n\t\t( isset( $_GET['page'] ) && '${handle}' === $_GET['page'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended\n\t\t( $current_screen && '${page.slug}' === $current_screen->id )\n\t);\n\n\tif ( ! $is_our_page ) {\n\t\treturn;\n\t}\n\n\t// Load build constants.\n\t$build_constants = require __DIR__ . '/../../constants.php';\n\n\t/**\n\t * Fires when the ${handle} page is initialized so extensions can register routes and menu items.\n\t */\n\tdo_action( '${handle}_init' );\n\n\t// Preload REST API data.\n\t${prefix}_${fn}_preload_data();\n\n\t// Get all registered routes.\n\t$routes = ${prefix}_get_${fn}_routes();\n\n${renderCarrierBlock(ctx, page, mode)}\n\t\t$init_modules = ${phpStringArray(page.initModules)};\n\n\t\t/*\n\t\t * Add inline script to initialize the app using initSinglePage (no menuItems).\n\t\t * The dynamic import is deferred until DOMContentLoaded so that all classic\n\t\t * script dependencies of @wordpress/boot (wp-private-apis, wp-components,\n\t\t * wp-theme, etc.) have finished parsing and executing before the boot module\n\t\t * evaluates. Otherwise, a modulepreloaded @wordpress/boot can win the race\n\t\t * against the classic-script-printing pass on fast CDN-fronted hosts in\n\t\t * Chrome, evaluating before wp.theme.privateApis is defined and throwing\n\t\t * \"Cannot unlock an undefined object\". See <https://core.trac.wordpress.org/ticket/65103>.\n\t\t */\n\t\t$init_js_function = <<<'JS'\n\t\t( mountId, routes, initModules ) => {\n\t\t\tconst run = async () => {\n\t\t\t\tconst mod = await import( \"@wordpress/boot\" );\n\t\t\t\tmod.initSinglePage( { mountId, routes, initModules } );\n\t\t\t};\n\t\t\tif ( document.readyState === \"loading\" ) {\n\t\t\t\tdocument.addEventListener( \"DOMContentLoaded\", run );\n\t\t\t} else {\n\t\t\t\trun();\n\t\t\t}\n\t\t}\n\t\tJS;\n\t\twp_add_inline_script(\n\t\t\t'${handle}-prerequisites',\n\t\t\tsprintf(\n\t\t\t\t'( %s )( %s, %s, %s );',\n\t\t\t\t$init_js_function,\n\t\t\t\twp_json_encode( '${mountId}', JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\twp_json_encode( $routes, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),\n\t\t\t\twp_json_encode( $init_modules, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES )\n\t\t\t)\n\t\t);\n\n${renderBootGraphBlock(ctx, page, mode)}}\n\n/**\n * Render the ${handle} page.\n * Call this function from add_menu_page or add_submenu_page.\n * This renders within the normal WordPress admin interface.\n */\nfunction ${prefix}_${fn}_render_page() {\n\t?>\n\t<style>\n\t\t/* Critical styles to prevent layout shifts - inlined for immediate application */\n\n\t\t#wpwrap {\n\t\t\toverflow-y: auto;\n\t\t}\n\t\tbody {\n\t\t\tbackground: #fff;\n\t\t}\n\n\t\t/* Reset wp-admin padding */\n\t\t#wpcontent {\n\t\t\tpadding-inline-start: 0;\n\t\t}\n\t\t#wpbody-content {\n\t\t\tpadding-bottom: 0;\n\t\t}\n\n\t\t/* Hide legacy admin elements */\n\t\t#wpbody-content > div:not(.boot-layout-container):not(#screen-meta) {\n\t\t\tdisplay: none;\n\t\t}\n\t\t#wpfooter {\n\t\t\tdisplay: none;\n\t\t}\n\n\t\t/* Accessibility regions */\n\t\t.a11y-speak-region {\n\t\t\tinset-inline-start: -1px;\n\t\t\ttop: -1px;\n\t\t}\n\n\t\t/* Admin menu indicators */\n\t\tul#adminmenu a.wp-has-current-submenu::after,\n\t\tul#adminmenu > li.current > a.current::after {\n\t\t\tborder-inline-end-color: #fff;\n\t\t}\n\n\t\t/* Media frame fix */\n\t\t.media-frame select.attachment-filters:last-of-type {\n\t\t\twidth: auto;\n\t\t\tmax-width: 100%;\n\t\t}\n\n\t\t/* Responsive overflow fix for #wpwrap */\n\t\t@media (min-width: 782px) {\n\t\t\t#wpwrap {\n\t\t\t\toverflow-y: initial;\n\t\t\t}\n\t\t}\n\t</style>\n\t<div id=\"${mountId}\" class=\"boot-layout-container\"></div>\n\t<?php\n}\n\n// Hook the enqueue function to admin_enqueue_scripts.\nadd_action( 'admin_enqueue_scripts', '${prefix}_${fn}_enqueue_scripts' );\n${renderMenuBlock(ctx, page, mode)}`;\n}\n\n/* -------------------------------------------------------------------------\n * pages.php / build.php / constants.php\n * ---------------------------------------------------------------------- */\n\nexport function renderPagesPhp(ctx: PhpContext, pages: GeneratedPage[]): string {\n\tconst files: string[] = [];\n\tfor (const page of pages) {\n\t\tif (page.modes.includes('full-page')) {\n\t\t\tfiles.push(`\\t__DIR__ . '/pages/${page.slug}/page.php',`);\n\t\t}\n\t\tif (page.modes.includes('wp-admin')) {\n\t\t\tfiles.push(`\\t__DIR__ . '/pages/${page.slug}/page-wp-admin.php',`);\n\t\t}\n\t}\n\n\treturn `<?php\n/**\n * Pages loader - Auto-generated by build process.\n * Do not edit this file manually.\n *\n * @package ${ctx.prefix}\n */\n\n$${toUnderscore(ctx.prefix)}_page_files = array(\n${files.join('\\n')}\n);\n\nforeach ( $${toUnderscore(ctx.prefix)}_page_files as $page_file ) {\n\tif ( file_exists( $page_file ) ) {\n\t\trequire_once $page_file;\n\t}\n}\n`;\n}\n\nexport function renderBuildPhp(ctx: PhpContext): string {\n\treturn `<?php\n/**\n * Main entry point for auto-generated asset registration.\n * Auto-generated by build process. Do not edit this file manually.\n *\n * Require this file from your plugin or theme:\n *\n * require_once __DIR__ . '/dist/build.php';\n *\n * @package ${ctx.prefix}\n */\n\n// Load routes registration.\n$routes_file = __DIR__ . '/routes.php';\nif ( file_exists( $routes_file ) ) {\n\trequire_once $routes_file;\n}\n\n// Load pages registration.\n$pages_file = __DIR__ . '/pages.php';\nif ( file_exists( $pages_file ) ) {\n\trequire_once $pages_file;\n}\n`;\n}\n\nexport function renderConstantsPhp(ctx: PhpContext): string {\n\treturn `<?php\n/**\n * Plugin constants - Auto-generated by build process.\n * Do not edit this file manually.\n *\n * Returns an array of constants for use in other generated files.\n *\n * @package ${ctx.prefix}\n */\n\nreturn array(\n\t'version' => ${phpString(ctx.version)},\n\t'build_url' => ${ctx.baseUrl},\n);\n`;\n}\n\n/* -------------------------------------------------------------------------\n * routes.php / routes/registry.php\n * ---------------------------------------------------------------------- */\n\nexport function renderRouteRegistryPhp(ctx: PhpContext, pages: GeneratedPage[]): string {\n\tconst rows: string[] = [];\n\tfor (const page of pages) {\n\t\tfor (const route of page.routes) {\n\t\t\trows.push(`\tarray(\n\t\t'name' => ${phpString(route.name)},\n\t\t'path' => ${phpString(route.path)},\n\t\t'page' => ${phpString(page.slug)},\n\t\t'dir' => ${phpString(route.dir)},\n\t\t'has_route' => ${route.hasRoute ? 'true' : 'false'},\n\t\t'has_content' => ${route.hasContent ? 'true' : 'false'},\n\t),`);\n\t\t}\n\t}\n\n\treturn `<?php\n/**\n * Route registry - Auto-generated by build process.\n * Do not edit this file manually.\n *\n * @package ${ctx.prefix}\n */\n\nreturn array(\n${rows.join('\\n')}\n);\n`;\n}\n\n/** wp-build's `routes-page-functions.php.template`, one block per page. */\nfunction renderRoutesPageFunctions(ctx: PhpContext, page: GeneratedPage): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst slugUnderscore = toUnderscore(page.slug);\n\tconst blocks: string[] = [];\n\n\tfor (const mode of ALL_PAGE_MODES) {\n\t\tif (!page.modes.includes(mode)) continue;\n\t\tconst { handle, fn } = pageNames(page, mode);\n\t\tconst label = mode === 'wp-admin' ? 'wp-admin mode' : 'full-page mode';\n\t\tblocks.push(`/**\n * Register routes for the ${page.slug} page (${label}).\n */\nfunction ${prefix}_register_${fn}_page_routes() {\n\tglobal $${prefix}_${slugUnderscore}_routes_data;\n\t${prefix}_register_page_routes( $${prefix}_${slugUnderscore}_routes_data, '${prefix}_register_${fn}_route' );\n}\nadd_action( '${handle}_init', '${prefix}_register_${fn}_page_routes' );`);\n\t}\n\n\treturn `// Page-specific route registration functions for ${page.slug}.\n${blocks.join('\\n\\n')}`;\n}\n\nexport function renderRoutesPhp(ctx: PhpContext, pages: GeneratedPage[]): string {\n\tconst prefix = toUnderscore(ctx.prefix);\n\tconst pageFunctions = pages.map((page) => renderRoutesPageFunctions(ctx, page)).join('\\n\\n');\n\n\treturn `<?php\n/**\n * Routes registration - Auto-generated by build process.\n * Registers all routes on their respective page init hooks.\n * Do not edit this file manually.\n *\n * @package ${ctx.prefix}\n */\n\n// Load routes registry.\n$routes_file = __DIR__ . '/routes/registry.php';\nif ( ! file_exists( $routes_file ) ) {\n\treturn;\n}\n\n$routes = require $routes_file;\n\n// Group routes by page and store in globals for page-specific functions.\n$routes_by_page = array();\nforeach ( $routes as $route ) {\n\t$page_slug = $route['page'];\n\tif ( ! isset( $routes_by_page[ $page_slug ] ) ) {\n\t\t$routes_by_page[ $page_slug ] = array();\n\t}\n\t$routes_by_page[ $page_slug ][] = $route;\n}\n\n// Store routes data in globals for each page.\nforeach ( $routes_by_page as $page_slug => $page_routes ) {\n\t$page_slug_underscore = str_replace( '-', '_', $page_slug );\n\t$GLOBALS[ '${prefix}_' . $page_slug_underscore . '_routes_data' ] = $page_routes;\n}\n\n/**\n * Generic helper function to register routes for a page.\n *\n * @param array $page_routes Array of route data for the page.\n * @param string $register_function_name Name of the function to call for registering each route.\n */\nfunction ${prefix}_register_page_routes( $page_routes, $register_function_name ) {\n\t// Load build constants.\n\t$build_constants = require __DIR__ . '/constants.php';\n\n\tforeach ( $page_routes as $route ) {\n\t\t$content_handle = null;\n\t\t$route_handle = null;\n\t\t$module_prefix = ${phpString(ctx.handlePrefix)} . '/routes/' . $route['page'] . '/' . $route['name'];\n\n\t\t// Register the content module when the build produced one.\n\t\tif ( $route['has_content'] ) {\n\t\t\t$content_asset_path = __DIR__ . '/' . $route['dir'] . '/content.asset.php';\n\t\t\tif ( file_exists( $content_asset_path ) ) {\n\t\t\t\t$content_asset = require $content_asset_path;\n\t\t\t\t$content_handle = $module_prefix . '/content';\n\t\t\t\t// Deregister first to override any previously registered version\n\t\t\t\t// (e.g., Core's default modules when running as a plugin).\n\t\t\t\twp_deregister_script_module( $content_handle );\n\t\t\t\twp_register_script_module(\n\t\t\t\t\t$content_handle,\n\t\t\t\t\t$build_constants['build_url'] . $route['dir'] . '/content.js',\n\t\t\t\t\t$content_asset['module_dependencies'] ?? array(),\n\t\t\t\t\t$content_asset['version'] ?? false\n\t\t\t\t);\n\n\t\t\t\t// The page stylesheet, when the entry imported any CSS.\n\t\t\t\t$content_style_path = __DIR__ . '/' . $route['dir'] . '/content.css';\n\t\t\t\tif ( file_exists( $content_style_path ) ) {\n\t\t\t\t\t$style_handle = str_replace( '/', '-', $content_handle );\n\t\t\t\t\twp_register_style(\n\t\t\t\t\t\t$style_handle,\n\t\t\t\t\t\t$build_constants['build_url'] . $route['dir'] . '/content.css',\n\t\t\t\t\t\tarray(),\n\t\t\t\t\t\t$content_asset['version'] ?? false\n\t\t\t\t\t);\n\t\t\t\t\twp_enqueue_style( $style_handle );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Register the route module when the build produced one.\n\t\tif ( $route['has_route'] ) {\n\t\t\t$route_asset_path = __DIR__ . '/' . $route['dir'] . '/route.asset.php';\n\t\t\tif ( file_exists( $route_asset_path ) ) {\n\t\t\t\t$route_asset = require $route_asset_path;\n\t\t\t\t$route_handle = $module_prefix . '/route';\n\t\t\t\t// Deregister first to override any previously registered version\n\t\t\t\t// (e.g., Core's default modules when running as a plugin).\n\t\t\t\twp_deregister_script_module( $route_handle );\n\t\t\t\twp_register_script_module(\n\t\t\t\t\t$route_handle,\n\t\t\t\t\t$build_constants['build_url'] . $route['dir'] . '/route.js',\n\t\t\t\t\t$route_asset['module_dependencies'] ?? array(),\n\t\t\t\t\t$route_asset['version'] ?? false\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Register route with page.\n\t\tif ( function_exists( $register_function_name ) ) {\n\t\t\tcall_user_func( $register_function_name, $route['path'], $content_handle, $route_handle );\n\t\t}\n\t}\n}\n\n${pageFunctions}\n`;\n}\n\n/* -------------------------------------------------------------------------\n * dev-server.php — the Vite dev-server bridge\n * ---------------------------------------------------------------------- */\n\n/**\n * Everything `renderDevServerPhp()` needs.\n *\n * Deliberately *not* `PhpContext`: the bridge is emitted by every build, not\n * just ones that declared admin pages, so there is no `version`,\n * `handlePrefix` or `textdomain` to hand it. All it needs is a namespace for\n * its identifiers and the name of the file whose presence flips it on.\n */\nexport interface DevServerPhpContext {\n\t/** Identifier prefix for the generated functions, handles and `@package`. */\n\tprefix: string;\n\t/** Hot-file name, resolved relative to the generated file's own directory. */\n\thotFile: string;\n}\n\n/**\n * `dist/dev-server.php` — the PHP half of the dev-server bridge.\n *\n * WordPress enqueues URLs that were decided at registration time, from PHP, on\n * a request that has no idea a bundler exists. This file is what teaches it\n * otherwise: while `<hotFile>` sits next to it, every script, stylesheet and\n * Script Module WordPress would have loaded out of this directory is repointed\n * at the running Vite server, using the `source` key each `.asset.php` sidecar\n * carries (see `wpExternals` and `wpDevServer`).\n *\n * Three properties the generated code has to keep, because a consumer\n * `require_once`s it unconditionally from their theme or plugin bootstrap:\n *\n * - **A no-op when cold.** One `file_exists()` per request, cached in a\n * static, and nothing else happens. No port probing, no HTTP.\n * - **Safe to require twice.** A `function_exists()` bail at the top; every\n * identifier is prefixed, so two packages' bridges coexist in one request.\n * - **Never fatal.** Every WordPress API it touches beyond the enqueue\n * basics is behind a `function_exists()` / `class_exists()` / `defined()`\n * guard, and degrades instead of throwing.\n *\n * The three rewrite paths, and why each is the one it is:\n *\n * - **Classic scripts** — `script_loader_src` (the URL) plus\n * `script_loader_tag` (`type=\"module\"`, via `WP_HTML_Tag_Processor`).\n * Filters rather than a registry walk, so a script registered during\n * printing is caught too.\n * - **Script Modules** — `script_module_loader_src` (WP 6.5+, unchanged\n * through 7.x). It is the single choke point inside\n * `WP_Script_Modules::get_src()` for all three outputs — the\n * `<script type=\"module\">` tag, its `<link rel=\"modulepreload\">`, and the\n * import map — so one filter keeps them consistent. The alternative,\n * deregister + re-register, is both blind (`$registered` is private, with\n * no bulk getter in any version) and a silent no-op (`register()` skips\n * ids it already knows), so it was never a real option.\n * - **Stylesheets** — dequeued and replaced with a module script, because\n * Vite serves CSS *through* JavaScript in dev; that is how it hot-swaps a\n * stylesheet without a reload. A `<link>` pointed at a `.css` the dev\n * server owns gets JavaScript back.\n *\n * Two more behaviors layered on top of the rewrite paths:\n *\n * - **React Fast Refresh.** When the hot file's `plugins` list contains\n * `vite:react-refresh`, the refresh runtime's preamble is attached to the\n * vite-client handle via `wp_add_inline_script( …, 'after' )`, with a\n * `wp_inline_script_attributes` filter stamping `type=\"module\"` on\n * exactly that inline block (matched by its `<handle>-js-after` id).\n * Attaching to the client handle — rather than to each rewritten script —\n * is what guarantees the preamble runs first: it is a dependency of every\n * handle this bridge repoints.\n * - **Stale hot file guard.** Opt-in, off by default: a `kill -9`'d dev\n * server can leave the hot file behind pointing at a socket nothing\n * answers on. Enabling the `<PREFIX>_WP_VITE_CHECK_DEV_SERVER` constant\n * (or the matching filter) adds a short-timeout `wp_remote_head()` probe\n * of `<origin><base>@vite/client`, cached with the rest of the decoded\n * hot file for the request. Off by default because every other check in\n * this file is a single `file_exists()` — this one is a real HTTP\n * request, on every request the bridge participates in.\n */\nexport function renderDevServerPhp(ctx: DevServerPhpContext): string {\n\tconst prefixUnderscore = toUnderscore(ctx.prefix);\n\tconst fn = `${prefixUnderscore}_wp_vite_dev`;\n\tconst client = `${ctx.prefix}-vite-client`;\n\t// Stale-hot-file guard: opt-in only (see `${fn}_should_verify_dev_server`\n\t// below). A constant for the common case, a filter for anything dynamic.\n\tconst checkConstant = `${prefixUnderscore.toUpperCase()}_WP_VITE_CHECK_DEV_SERVER`;\n\tconst checkFilter = `${prefixUnderscore}_wp_vite_check_dev_server`;\n\n\treturn `<?php\n/**\n * Vite dev-server bridge.\n * Auto-generated by build process. Do not edit this file manually.\n *\n * Require it once, unconditionally, next to the rest of your dist requires:\n *\n * $wp_vite_dev = __DIR__ . '/dist/dev-server.php';\n * if ( file_exists( $wp_vite_dev ) ) {\n * require_once $wp_vite_dev;\n * }\n *\n * With no dev server running it costs a single \\`file_exists()\\` and returns.\n * When ${ctx.hotFile} is sitting next to it, it repoints every script,\n * stylesheet and Script Module WordPress would have loaded out of this\n * directory at the running Vite server instead.\n *\n * @package ${ctx.prefix}\n */\n\n/*\n * Two loaders, a theme that also boots its own mu-plugin: requiring this file\n * twice must not redeclare anything or stack a second set of filters.\n *\n * The guard has to *wrap* the declarations rather than \\`return\\` above them.\n * PHP binds an unconditionally-declared top-level function when it compiles the\n * file — before a single statement in it runs — so an early return would fatal\n * on the second require anyway. Conditional declarations are bound at run time,\n * which is what makes the check mean something.\n */\nif ( ! function_exists( '${fn}_hot' ) ) :\n\n/**\n * Whether ${fn}_hot() should verify the dev server is actually reachable\n * before trusting the hot file's mere presence.\n *\n * Off by default. Every other check in this bridge is a single\n * \\`file_exists()\\` because a running dev server keeps that contract\n * deliberately — write on 'listening', delete on exit, exit handlers bound\n * once. The one hole is a \\`kill -9\\`'d process, which leaves the file behind\n * pointing at a socket nothing is listening on any more. Closing that hole\n * costs a real HTTP request — timed short, but still a round trip — on every\n * single request this bridge participates in, so it stays opt-in rather than\n * something every site pays for.\n *\n * Enable it with the \\`${checkConstant}\\` constant, or the\n * \\`${checkFilter}\\` filter for anything more dynamic (e.g. only inside a\n * container where \\`kill -9\\`ing the dev server is routine).\n *\n * @return bool\n */\nfunction ${fn}_should_verify_dev_server() {\n\t$default = defined( '${checkConstant}' ) && constant( '${checkConstant}' );\n\n\t/**\n\t * Filters whether the dev-server bridge verifies the running server is\n\t * reachable before trusting the hot file.\n\t *\n\t * @param bool $verify Whether to probe. Default from the\n\t * ${checkConstant} constant, else false.\n\t */\n\treturn (bool) apply_filters( '${checkFilter}', $default );\n}\n\n/**\n * The decoded hot file, or null when no dev server is running.\n *\n * The presence of the file is the entire protocol — a running server writes it\n * on 'listening' and deletes it on exit. Cached in a static because this is on\n * the request path for every enqueued asset.\n *\n * @return array|null Array with 'origin', 'base' and 'plugins' keys, or null.\n */\nfunction ${fn}_hot() {\n\tstatic $hot = false;\n\n\tif ( false !== $hot ) {\n\t\treturn $hot;\n\t}\n\n\t$hot = null;\n\t$hot_file = __DIR__ . '/${ctx.hotFile}';\n\n\tif ( ! file_exists( $hot_file ) ) {\n\t\treturn $hot;\n\t}\n\n\t// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents\n\t$contents = file_get_contents( $hot_file );\n\t$decoded = is_string( $contents ) ? json_decode( $contents, true ) : null;\n\n\tif ( ! is_array( $decoded ) || empty( $decoded['origin'] ) || ! is_string( $decoded['origin'] ) ) {\n\t\treturn $hot;\n\t}\n\n\t$base = isset( $decoded['base'] ) && is_string( $decoded['base'] ) ? $decoded['base'] : '/';\n\t$base = '/' . ltrim( $base, '/' );\n\tif ( '/' !== substr( $base, -1 ) ) {\n\t\t$base .= '/';\n\t}\n\n\t$hot = array(\n\t\t'origin' => rtrim( $decoded['origin'], '/' ),\n\t\t'base' => $base,\n\t\t'plugins' => isset( $decoded['plugins'] ) && is_array( $decoded['plugins'] ) ? $decoded['plugins'] : array(),\n\t);\n\n\t// Stale hot file: the file is there, but nothing answers for it (a\n\t// \\`kill -9\\`'d dev server). See ${fn}_should_verify_dev_server() above —\n\t// off by default, so this whole block is skipped on the common path.\n\tif ( ${fn}_should_verify_dev_server() && function_exists( 'wp_remote_head' ) ) {\n\t\t$response = wp_remote_head(\n\t\t\t$hot['origin'] . $hot['base'] . '@vite/client',\n\t\t\tarray( 'timeout' => 0.2, 'blocking' => true )\n\t\t);\n\n\t\t$status_code = is_wp_error( $response ) ? 0 : (int) wp_remote_retrieve_response_code( $response );\n\n\t\tif ( $status_code < 200 || $status_code >= 400 ) {\n\t\t\t$hot = null;\n\t\t}\n\t}\n\n\treturn $hot;\n}\n\n/**\n * Turn a project-relative source path into the URL the dev server serves it at.\n *\n * @param string $source Project-relative path from an .asset.php 'source' key.\n * @return string Absolute URL, or '' when no dev server is running.\n */\nfunction ${fn}_url( $source ) {\n\t$hot = ${fn}_hot();\n\n\tif ( null === $hot ) {\n\t\treturn '';\n\t}\n\n\treturn $hot['origin'] . $hot['base'] . ltrim( (string) $source, '/' );\n}\n\n/**\n * URL of the directory this file lives in.\n *\n * Derived from __DIR__ rather than configured, so the same generated file works\n * whether it was built into a theme, a plugin or an mu-plugin. The candidates\n * are tried most-specific first: content_url() is the general answer, but a\n * theme under a custom theme root — or anything reached through a symlink — is\n * only spelled correctly by its own helper.\n *\n * @return string Trailing-slashed URL, or '' when this directory is outside\n * every location WordPress can build a URL for.\n */\nfunction ${fn}_dist_url() {\n\tstatic $dist_url = false;\n\n\tif ( false !== $dist_url ) {\n\t\treturn $dist_url;\n\t}\n\n\t$dist_url = '';\n\t$dir = rtrim( str_replace( '\\\\\\\\', '/', __DIR__ ), '/' );\n\t$roots = array();\n\n\tif ( function_exists( 'get_stylesheet_directory' ) && function_exists( 'get_stylesheet_directory_uri' ) ) {\n\t\t$roots[] = array( get_stylesheet_directory(), get_stylesheet_directory_uri() );\n\t}\n\tif ( function_exists( 'get_template_directory' ) && function_exists( 'get_template_directory_uri' ) ) {\n\t\t$roots[] = array( get_template_directory(), get_template_directory_uri() );\n\t}\n\tif ( defined( 'WPMU_PLUGIN_DIR' ) && defined( 'WPMU_PLUGIN_URL' ) ) {\n\t\t$roots[] = array( WPMU_PLUGIN_DIR, WPMU_PLUGIN_URL );\n\t}\n\tif ( defined( 'WP_PLUGIN_DIR' ) && defined( 'WP_PLUGIN_URL' ) ) {\n\t\t$roots[] = array( WP_PLUGIN_DIR, WP_PLUGIN_URL );\n\t}\n\tif ( defined( 'WP_CONTENT_DIR' ) && function_exists( 'content_url' ) ) {\n\t\t$roots[] = array( WP_CONTENT_DIR, content_url() );\n\t}\n\n\tforeach ( $roots as $root ) {\n\t\tlist( $root_dir, $root_url ) = $root;\n\n\t\tif ( ! is_string( $root_dir ) || ! is_string( $root_url ) || '' === $root_dir || '' === $root_url ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t$root_dir = rtrim( str_replace( '\\\\\\\\', '/', $root_dir ), '/' );\n\n\t\tif ( '' === $root_dir || 0 !== strpos( $dir . '/', $root_dir . '/' ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t$dist_url = rtrim( $root_url, '/' ) . substr( $dir, strlen( $root_dir ) ) . '/';\n\t\tbreak;\n\t}\n\n\treturn $dist_url;\n}\n\n/**\n * Map an asset URL pointing into this directory back to the file the dev\n * server serves it from.\n *\n * The lookup is the .asset.php sidecar next to where the built file would have\n * been: dist-relative URL, extension stripped, '.asset.php' appended. Its\n * 'source' key — written by both a build and a running dev server — is the\n * project-relative path of the file Vite compiles on demand.\n *\n * @param string $url Asset URL as WordPress is about to print it, '?ver=' and all.\n * @return string|null Project-relative source path, or null when this URL is\n * not ours or has no sidecar.\n */\nfunction ${fn}_source( $url ) {\n\tstatic $cache = array();\n\n\tif ( ! is_string( $url ) || '' === $url ) {\n\t\treturn null;\n\t}\n\n\t$dist_url = ${fn}_dist_url();\n\n\tif ( '' === $dist_url ) {\n\t\treturn null;\n\t}\n\n\t// The filters hand us the versioned URL; the sidecar lives at the\n\t// unversioned path.\n\t$query = strpos( $url, '?' );\n\tif ( false !== $query ) {\n\t\t$url = substr( $url, 0, $query );\n\t}\n\n\tif ( array_key_exists( $url, $cache ) ) {\n\t\treturn $cache[ $url ];\n\t}\n\n\t$cache[ $url ] = null;\n\t$relative = null;\n\n\t// A protocol-relative src, and an http/https mismatch between the enqueued\n\t// URL and content_url(), are both routine; neither should stop a match. The\n\t// path-only form additionally catches root-relative and CDN-fronted srcs.\n\t$path_only = preg_replace( '#^([a-z][a-z0-9+.-]*:)?//[^/]*#i', '', $dist_url );\n\tforeach ( array( $dist_url, is_string( $path_only ) ? $path_only : '' ) as $prefix ) {\n\t\tif ( '' === $prefix ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t$bare_prefix = preg_replace( '#^[a-z][a-z0-9+.-]*:#i', '', $prefix );\n\t\t$bare_url = preg_replace( '#^[a-z][a-z0-9+.-]*:#i', '', $url );\n\n\t\tif ( 0 !== strpos( $bare_url, $bare_prefix ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t$relative = substr( $bare_url, strlen( $bare_prefix ) );\n\t\tbreak;\n\t}\n\n\t// The relative path reaches a require(), and it came out of a URL. Nothing\n\t// but the shape a build actually emits gets through.\n\tif ( null === $relative || ! preg_match( '#^[A-Za-z0-9_][A-Za-z0-9_./-]*$#', $relative ) || false !== strpos( $relative, '..' ) ) {\n\t\treturn null;\n\t}\n\n\t$asset_file = __DIR__ . '/' . preg_replace( '/\\\\.(js|mjs|css)$/', '', $relative ) . '.asset.php';\n\n\tif ( ! file_exists( $asset_file ) ) {\n\t\treturn null;\n\t}\n\n\t$asset = require $asset_file;\n\n\tif ( ! is_array( $asset ) || empty( $asset['source'] ) || ! is_string( $asset['source'] ) ) {\n\t\treturn null;\n\t}\n\n\t$cache[ $url ] = $asset['source'];\n\n\treturn $cache[ $url ];\n}\n\n/**\n * Registry of handles whose <script> tag has to be stamped type=\"module\".\n *\n * Everything the dev server serves is ESM — that is the point of dev mode — so\n * every handle this file repoints joins the set.\n *\n * @param string $handle Script handle.\n * @param bool $mark Add the handle to the registry.\n * @return bool Whether the handle prints as a module.\n */\nfunction ${fn}_is_module( $handle, $mark = false ) {\n\tstatic $handles = array();\n\n\tif ( $mark ) {\n\t\t$handles[ $handle ] = true;\n\t}\n\n\treturn isset( $handles[ $handle ] );\n}\n\n// Nothing below this line matters when no dev server is running.\nif ( null === ${fn}_hot() ) {\n\treturn;\n}\n\n/**\n * Register and enqueue Vite's HMR client, early.\n *\n * It opens the websocket, applies hot updates, and renders the error overlay.\n * Every handle this file repoints gets it as a dependency, so it is always the\n * first module in the document.\n */\nfunction ${fn}_enqueue_client() {\n\t$src = ${fn}_url( '@vite/client' );\n\n\tif ( '' === $src ) {\n\t\treturn;\n\t}\n\n\twp_register_script( '${client}', $src, array(), null, false );\n\twp_enqueue_script( '${client}' );\n\t${fn}_is_module( '${client}', true );\n\n\t${fn}_enqueue_react_refresh_preamble();\n}\nadd_action( 'wp_enqueue_scripts', '${fn}_enqueue_client', -1000 );\nadd_action( 'admin_enqueue_scripts', '${fn}_enqueue_client', -1000 );\n\n/**\n * Attach the React Fast Refresh preamble to the vite-client handle, when the\n * running dev server reports \\`vite:react-refresh\\` in the hot file's plugin\n * list.\n *\n * The preamble has to run before any React component module evaluates —\n * @vitejs/plugin-react's transform assumes \\`window.$RefreshReg$\\` already\n * exists, and every transformed component module throws otherwise. Attaching\n * it to the vite-client handle rather than to each rewritten script gets that\n * ordering for free, two different ways depending on how the component reaches\n * the page:\n *\n * - **Classic scripts.** ${fn}_prepare() (below) makes the client a\n * dependency of every classic handle this bridge repoints, so WordPress's\n * own dependency graph orders the client — and the inline block\n * \\`wp_add_inline_script( …, 'after' )\\` attaches to it — before them.\n * - **Script Modules.** There is no cross-system dependency a classic handle\n * can declare on a Script Module, so this relies on where WordPress prints\n * each group instead: the client is a classic-registered handle (its\n * \\`type=\"module\"\\` is only a printed attribute, stamped by\n * ${fn}_script_tag() below), and every generated page in this package\n * prints classic scripts — the client included — before it prints Script\n * Modules. Same-document module scripts without \\`async\\` execute in that\n * print order, so the preamble still runs first.\n *\n * Same mechanics vite-for-wp uses for the classic-script half.\n *\n * Guarded by a static so a request that somehow fires both enqueue hooks\n * cannot attach the preamble, and its type=\"module\" filter, twice.\n */\nfunction ${fn}_enqueue_react_refresh_preamble() {\n\tstatic $attached = false;\n\n\tif ( $attached ) {\n\t\treturn;\n\t}\n\n\t$hot = ${fn}_hot();\n\n\tif ( null === $hot || ! in_array( 'vite:react-refresh', $hot['plugins'], true ) ) {\n\t\treturn;\n\t}\n\n\t$attached = true;\n\n\t$preamble = sprintf(\n\t\t'import RefreshRuntime from \"%1$s\"\nRefreshRuntime.injectIntoGlobalHook(window)\nwindow.$RefreshReg$ = () => {}\nwindow.$RefreshSig$ = () => (type) => type\nwindow.__vite_plugin_react_preamble_installed__ = true',\n\t\tesc_js( ${fn}_url( '@react-refresh' ) )\n\t);\n\n\twp_add_inline_script( '${client}', $preamble, 'after' );\n\tadd_filter( 'wp_inline_script_attributes', '${fn}_react_refresh_inline_attributes' );\n}\n\n/**\n * Stamp type=\"module\" on exactly the inline block ${fn}_enqueue_react_refresh_preamble()\n * attached — the preamble is a top-level \\`import\\`, so it must not print as a\n * classic inline script the way an 'after' block otherwise would.\n *\n * WordPress assigns an inline block printed at the 'after' position the id\n * \\`<handle>-js-after\\`; matching on it (rather than the handle alone) is what\n * keeps this from touching some other inline script attached to the same\n * vite-client handle by unrelated code.\n *\n * @param array $attributes Attributes about to be printed on the inline <script> tag.\n * @return array\n */\nfunction ${fn}_react_refresh_inline_attributes( $attributes ) {\n\tif ( is_array( $attributes ) && isset( $attributes['id'] ) && '${client}-js-after' === $attributes['id'] ) {\n\t\t$attributes['type'] = 'module';\n\t}\n\n\treturn $attributes;\n}\n\n/**\n * The one pass that has to happen while the queues are still mutable: wire the\n * HMR client into everything about to be repointed, and swap this directory's\n * stylesheets for the JS modules Vite serves them as.\n *\n * Runs last on the enqueue hooks — the URL rewriting itself happens later, in\n * script_loader_src, which also catches handles registered after this point.\n */\nfunction ${fn}_prepare() {\n\t$claimed = array();\n\n\tif ( function_exists( 'wp_scripts' ) && function_exists( 'wp_script_is' ) ) {\n\t\t$has_client = wp_script_is( '${client}', 'registered' );\n\n\t\tforeach ( wp_scripts()->registered as $handle => $script ) {\n\t\t\tif ( '${client}' === $handle || empty( $script->src ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t$source = ${fn}_source( $script->src );\n\n\t\t\tif ( null === $source ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t$claimed[ $source ] = true;\n\n\t\t\t// Ordering only. A missing client handle would make WordPress drop\n\t\t\t// the script entirely, so never depend on one that isn't there.\n\t\t\tif ( $has_client && is_array( $script->deps ) && ! in_array( '${client}', $script->deps, true ) ) {\n\t\t\t\t$script->deps[] = '${client}';\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! function_exists( 'wp_styles' ) ) {\n\t\treturn;\n\t}\n\n\t$styles = wp_styles();\n\n\tforeach ( $styles->queue as $handle ) {\n\t\tif ( ! isset( $styles->registered[ $handle ] ) || empty( $styles->registered[ $handle ]->src ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t$source = ${fn}_source( $styles->registered[ $handle ]->src );\n\n\t\tif ( null === $source ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\twp_dequeue_style( $handle );\n\n\t\t// A stylesheet whose source is already served by a repointed script is\n\t\t// covered: in dev the entry imports its own CSS.\n\t\tif ( isset( $claimed[ $source ] ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t$claimed[ $source ] = true;\n\t\t$shim = $handle . '-vite-dev';\n\n\t\twp_register_script(\n\t\t\t$shim,\n\t\t\t${fn}_url( $source ),\n\t\t\twp_script_is( '${client}', 'registered' ) ? array( '${client}' ) : array(),\n\t\t\tnull,\n\t\t\tfalse\n\t\t);\n\t\twp_enqueue_script( $shim );\n\t\t${fn}_is_module( $shim, true );\n\t}\n}\nadd_action( 'wp_enqueue_scripts', '${fn}_prepare', PHP_INT_MAX );\nadd_action( 'admin_enqueue_scripts', '${fn}_prepare', PHP_INT_MAX );\n\n/**\n * Repoint a classic script at the dev server.\n *\n * @param string $src Script URL.\n * @param string $handle Script handle.\n * @return string Rewritten URL, or the original.\n */\nfunction ${fn}_script_src( $src, $handle ) {\n\t$source = ${fn}_source( $src );\n\n\tif ( null === $source ) {\n\t\treturn $src;\n\t}\n\n\t// script_loader_src always runs before script_loader_tag for the same\n\t// handle (both live in WP_Scripts::do_item()), so marking here is enough.\n\t${fn}_is_module( $handle, true );\n\n\treturn ${fn}_url( $source );\n}\nadd_filter( 'script_loader_src', '${fn}_script_src', 10, 2 );\n\n/**\n * Stamp type=\"module\" on the handles this file repointed.\n *\n * @param string $tag Script tag HTML.\n * @param string $handle Script handle.\n * @return string Rewritten tag.\n */\nfunction ${fn}_script_tag( $tag, $handle ) {\n\tif ( ! is_string( $tag ) || ! ${fn}_is_module( $handle ) ) {\n\t\treturn $tag;\n\t}\n\n\t// WP 6.2+. Without it, the crude rewrite is still better than letting an\n\t// ESM file load as a classic script and throw on its first import.\n\tif ( ! class_exists( 'WP_HTML_Tag_Processor' ) ) {\n\t\treturn false === strpos( $tag, 'type=\"module\"' )\n\t\t\t? str_replace( '<script ', '<script type=\"module\" ', $tag )\n\t\t\t: $tag;\n\t}\n\n\t$processor = new WP_HTML_Tag_Processor( $tag );\n\n\twhile ( $processor->next_tag( 'script' ) ) {\n\t\t// Inline blocks attached to the same handle stay classic; only the\n\t\t// src'd tag is the module.\n\t\tif ( null === $processor->get_attribute( 'src' ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t$processor->set_attribute( 'type', 'module' );\n\t}\n\n\treturn $processor->get_updated_html();\n}\nadd_filter( 'script_loader_tag', '${fn}_script_tag', 10, 2 );\n\n/**\n * Repoint a Script Module at the dev server.\n *\n * script_module_loader_src (WP 6.5+) is the single choke point inside\n * WP_Script_Modules::get_src() for all three Script Module outputs — the\n * <script type=\"module\"> tag, its <link rel=\"modulepreload\">, and the import\n * map — so one filter keeps all three consistent and no consumer registration\n * has to change.\n *\n * @param string $src Script Module URL.\n * @param string $id Script Module identifier.\n * @return string Rewritten URL, or the original.\n */\nfunction ${fn}_script_module_src( $src, $id ) {\n\t$source = ${fn}_source( $src );\n\n\treturn null === $source ? $src : ${fn}_url( $source );\n}\nadd_filter( 'script_module_loader_src', '${fn}_script_module_src', 10, 2 );\n\n/**\n * Last resort for a stylesheet ${fn}_prepare() never saw — one registered\n * after the enqueue hooks, or pulled in as another stylesheet's dependency.\n *\n * Vite's '?direct' serves the compiled CSS with a text/css content type instead\n * of the JS module a bare .css request returns. Correct styles, no hot reload.\n *\n * @param string $src Stylesheet URL.\n * @param string $handle Stylesheet handle.\n * @return string Rewritten URL, or the original.\n */\nfunction ${fn}_style_src( $src, $handle ) {\n\t$source = ${fn}_source( $src );\n\n\treturn null === $source ? $src : ${fn}_url( $source ) . '?direct';\n}\nadd_filter( 'style_loader_src', '${fn}_style_src', 10, 2 );\n\nendif;\n`;\n}\n\n/* -------------------------------------------------------------------------\n * Entry point\n * ---------------------------------------------------------------------- */\n\n/**\n * Every generated PHP file for the given pages, as dist-relative\n * `{ fileName, source }` pairs ready for Rollup's `emitFile`.\n */\nexport function generatePhpFiles(ctx: PhpContext, pages: GeneratedPage[]): GeneratedPhpFile[] {\n\tconst files: GeneratedPhpFile[] = [\n\t\t{ fileName: 'build.php', source: renderBuildPhp(ctx) },\n\t\t{ fileName: 'constants.php', source: renderConstantsPhp(ctx) },\n\t];\n\n\tif (pages.length === 0) return files;\n\n\tfiles.push({ fileName: 'pages.php', source: renderPagesPhp(ctx, pages) });\n\n\tfor (const page of pages) {\n\t\tif (page.modes.includes('full-page')) {\n\t\t\tfiles.push({\n\t\t\t\tfileName: `pages/${page.slug}/page.php`,\n\t\t\t\tsource: renderPagePhp(ctx, page),\n\t\t\t});\n\t\t}\n\t\tif (page.modes.includes('wp-admin')) {\n\t\t\tfiles.push({\n\t\t\t\tfileName: `pages/${page.slug}/page-wp-admin.php`,\n\t\t\t\tsource: renderPageWpAdminPhp(ctx, page),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst hasRoutes = pages.some((page) => page.routes.length > 0);\n\tif (hasRoutes) {\n\t\tfiles.push({ fileName: 'routes.php', source: renderRoutesPhp(ctx, pages) });\n\t\tfiles.push({\n\t\t\tfileName: 'routes/registry.php',\n\t\t\tsource: renderRouteRegistryPhp(ctx, pages),\n\t\t});\n\t}\n\n\treturn files;\n}\n","/**\n * vite-plugin-wp-admin-pages\n *\n * Builds `@wordpress/boot`-powered admin pages (WP 6.9+ Script Module admin\n * screens) as part of the regular **module pass**, replacing the hand-rolled\n * `esbuild.boot.mjs` pipelines projects run next to their main build.\n *\n * Every immediate subdirectory of `adminPagesDir` containing a `content`\n * entry file is a page. Each page contributes one or two Rollup inputs plus\n * a generated `loader.js` anchor:\n *\n * dist/modules/<page>/\n * ├── content.js # ESM entry (required)\n * ├── content.asset.php # via wpExternals\n * ├── content.css # CSS imported by content.js, normalized here\n * ├── route.js # ESM entry (optional)\n * ├── route.asset.php # via wpExternals\n * ├── loader.js # empty anchor module PHP registers the graph on\n * └── routes/<name>/ # additional routes (content / route entries)\n *\n * The externalization strategy those pages need (`@wordpress/boot` stays a\n * bare ESM specifier, `@wordpress/dataviews` gets bundled, `wp-components`\n * & friends become `window.wp.*` reads with their classic handles collected\n * into `.asset.php`) falls out of [`wpExternals`](./wp-externals.ts) — this\n * plugin only owns discovery, the loader anchor, the CSS file naming, and\n * (opt-in via `php`) the generated PHP registration layer described in\n * [`php-templates.ts`](./php-templates.ts).\n *\n * JSX note: Vite does not parse JSX out of `.js` files. Pages whose entries\n * contain JSX must use `.jsx` / `.tsx`.\n */\nimport { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport type { Plugin, Rollup, UserConfig } from 'vite';\nimport {\n\tALL_PAGE_MODES,\n\tDEFAULT_REST_PRELOAD,\n\tgeneratePhpFiles,\n\tisValidPhpIdentifier,\n\tisValidSlug,\n\ttype GeneratedPage,\n\ttype GeneratedPhpFile,\n\ttype GeneratedRoute,\n\ttype PageMenu,\n\ttype PageMode,\n\ttype PhpContext,\n\ttype RestPreloadEntry,\n} from './php-templates';\n\n/** Source extensions probed for a page entry, in wpBlocks' resolution order. */\nconst ENTRY_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'] as const;\n\n/** Anchor module PHP registers with the page's static/dynamic import graph. */\nconst LOADER_SOURCE = '// Empty module loader for page dependencies.\\n';\n\n/**\n * Enables generation of the `@wordpress/build`-style PHP layer next to the\n * built modules — `build.php`, `constants.php`, `pages.php`,\n * `pages/<slug>/page{,-wp-admin}.php`, `routes.php` and\n * `routes/registry.php`. A consuming plugin then needs no hand-written PHP\n * beyond `require_once __DIR__ . '/dist/build.php';`.\n */\nexport interface WpAdminPagesPhpOptions {\n\t/**\n\t * Identifier prefix for every generated function, global and hook.\n\t * Default: `wpPlugin.name` from the consumer's package.json, else its\n\t * (de-scoped) package name. Dashes are underscored for PHP identifiers;\n\t * the result must be a valid PHP identifier fragment.\n\t */\n\tprefix?: string;\n\t/**\n\t * Script Module id prefix — route modules are registered as\n\t * `<handlePrefix>/routes/<page>/<route>/{content,route}`.\n\t * Default: `wpPlugin.handlePrefix`, else `prefix`.\n\t */\n\thandlePrefix?: string;\n\t/**\n\t * Raw PHP expression for the URL of the build directory, interpolated\n\t * into `constants.php` verbatim. Default `plugin_dir_url( __FILE__ )`\n\t * (`build.php` and friends live in the build directory itself).\n\t */\n\tbaseUrl?: string;\n\t/** Text domain for the generated `__()` calls. Default `'default'`. */\n\ttextdomain?: string;\n}\n\nexport interface WpAdminPagesOptions {\n\t/**\n\t * Directory whose immediate subdirectories are pages. A subdirectory is\n\t * a page when it contains a `content.{tsx,ts,jsx,js}` entry; a sibling\n\t * `route.{tsx,ts,jsx,js}` is picked up when present, as are additional\n\t * routes under `<page>/routes/<name>/`.\n\t */\n\tadminPagesDir: string;\n\t/**\n\t * Admin pages are Script Modules, so they only build in the module pass.\n\t * In `'script'` mode (the default, matching the other plugins) this\n\t * plugin contributes nothing.\n\t */\n\tbuildType?: 'script' | 'module';\n\t/**\n\t * Generate the PHP registration layer. Presence enables it; every key\n\t * is optional.\n\t */\n\tphp?: WpAdminPagesPhpOptions;\n\t/**\n\t * Root whose `package.json` supplies the generated `version` and the\n\t * `wpPlugin.name` / `wpPlugin.handlePrefix` defaults. Defaults to Vite's\n\t * `root`, else `process.cwd()`.\n\t */\n\tprojectRoot?: string;\n}\n\n/** Per-page `page.json`, all keys optional. */\nexport interface PageConfig {\n\ttitle?: string;\n\tmenu?: PageMenu;\n\tinit?: string[];\n\tmodes?: PageMode[];\n\trestPreload?: RestPreloadEntry[];\n}\n\n/** An additional route under `<page>/routes/<name>/`. */\nexport interface AdminPageRoute {\n\t/** Route directory name. */\n\tname: string;\n\t/** Route path — `route.json` `path`, else `/<name>`. */\n\tpath: string;\n\t/** Absolute path of the resolved `content` entry, when present. */\n\tcontent?: string;\n\t/** Absolute path of the resolved `route` entry, when present. */\n\troute?: string;\n}\n\nexport interface AdminPage {\n\t/** Page directory name — the `modules/<dirName>/…` output namespace. */\n\tdirName: string;\n\t/** Absolute path of the resolved `content` entry. */\n\tcontent: string;\n\t/** Absolute path of the resolved `route` entry, when the page has one. */\n\troute?: string;\n\t/** Additional routes discovered under `<page>/routes/`. */\n\tsubRoutes: AdminPageRoute[];\n\t/** Parsed `page.json` (`{}` when the page has none). */\n\tpageConfig: PageConfig;\n}\n\nexport function wpAdminPages(options: WpAdminPagesOptions): Plugin {\n\tconst buildType = options.buildType ?? 'script';\n\tlet pages: AdminPage[] = [];\n\tlet phpFiles: GeneratedPhpFile[] = [];\n\n\treturn {\n\t\tname: 'wp-admin-pages',\n\t\tenforce: 'pre',\n\n\t\tconfig(userConfig?: UserConfig) {\n\t\t\t// Pages are module-pass only — the script pass contributes nothing.\n\t\t\tif (buildType !== 'module') return;\n\n\t\t\tconst adminPagesDirAbs = resolve(process.cwd(), options.adminPagesDir);\n\t\t\tpages = discoverPages(adminPagesDirAbs);\n\t\t\t// No pages (yet) — stay out of the config entirely.\n\t\t\tif (pages.length === 0) return;\n\n\t\t\t// PHP generation is opt-in; validation runs here so a bad prefix\n\t\t\t// or page slug fails the config, not the write.\n\t\t\tif (options.php) {\n\t\t\t\tconst projectRoot = resolve(\n\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\toptions.projectRoot ?? userConfig?.root ?? '.',\n\t\t\t\t);\n\t\t\t\tconst phpContext = resolvePhpContext(options.php, projectRoot);\n\t\t\t\tphpFiles = generatePhpFiles(phpContext, pages.map(toGeneratedPage));\n\t\t\t}\n\n\t\t\tconst input: Record<string, string> = {};\n\t\t\tfor (const page of pages) {\n\t\t\t\tinput[`modules/${page.dirName}/content`] = page.content;\n\t\t\t\tif (page.route) input[`modules/${page.dirName}/route`] = page.route;\n\t\t\t\tfor (const subRoute of page.subRoutes) {\n\t\t\t\t\tconst base = `modules/${page.dirName}/routes/${subRoute.name}`;\n\t\t\t\t\tif (subRoute.content) input[`${base}/content`] = subRoute.content;\n\t\t\t\t\tif (subRoute.route) input[`${base}/route`] = subRoute.route;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tbuild: {\n\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\t// Vite defaults app builds to `preserveEntrySignatures:\n\t\t\t\t\t\t// false`, which tree-shakes an entry's exports away. A\n\t\t\t\t\t\t// boot page IS its exports (`export const stage`,\n\t\t\t\t\t\t// `export const route` — imported by\n\t\t\t\t\t\t// `@wordpress/boot` at runtime), so they have to\n\t\t\t\t\t\t// survive.\n\t\t\t\t\t\tpreserveEntrySignatures: 'exports-only',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\n\t\tgenerateBundle(_outputOptions, bundle) {\n\t\t\tif (buildType !== 'module' || pages.length === 0) return;\n\n\t\t\t// The loader is an empty anchor: PHP registers it as the page's\n\t\t\t// Script Module and hangs the static/dynamic import graph\n\t\t\t// (`@wordpress/boot`, `<slug>-route`, `<slug>-content`) off it.\n\t\t\tfor (const page of pages) {\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: `modules/${page.dirName}/loader.js`,\n\t\t\t\t\tsource: LOADER_SOURCE,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// The generated PHP registration layer (opt-in via `php`).\n\t\t\tfor (const file of phpFiles) {\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: file.fileName,\n\t\t\t\t\tsource: file.source,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!bundle) return;\n\n\t\t\tconst entryNames = new Set<string>();\n\t\t\tfor (const page of pages) {\n\t\t\t\tentryNames.add(`modules/${page.dirName}/content`);\n\t\t\t\tif (page.route) entryNames.add(`modules/${page.dirName}/route`);\n\t\t\t\tfor (const subRoute of page.subRoutes) {\n\t\t\t\t\tconst base = `modules/${page.dirName}/routes/${subRoute.name}`;\n\t\t\t\t\tif (subRoute.content) entryNames.add(`${base}/content`);\n\t\t\t\t\tif (subRoute.route) entryNames.add(`${base}/route`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Which chunks reference which extracted stylesheet, captured\n\t\t\t// before anything is rewritten.\n\t\t\tconst referencingChunks = new Map<string, Set<string>>();\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk') continue;\n\t\t\t\tfor (const cssFileName of output.viteMetadata?.importedCss ?? []) {\n\t\t\t\t\tlet chunks = referencingChunks.get(cssFileName);\n\t\t\t\t\tif (!chunks) referencingChunks.set(cssFileName, (chunks = new Set()));\n\t\t\t\t\tchunks.add(fileName);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst pageEntries: Array<[string, Rollup.OutputChunk]> = [];\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk' || !output.isEntry) continue;\n\t\t\t\tif (!entryNames.has(output.name)) continue;\n\t\t\t\tpageEntries.push([fileName, output]);\n\t\t\t}\n\n\t\t\t// Every chunk reachable from an entry that is *not* a page — the\n\t\t\t// safety net for deleting the stylesheets we fold into the\n\t\t\t// per-page CSS files.\n\t\t\tconst pageEntryFileNames = new Set(pageEntries.map(([fileName]) => fileName));\n\t\t\tconst reachableFromOtherEntries = new Set<string>();\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk' || !output.isEntry) continue;\n\t\t\t\tif (pageEntryFileNames.has(fileName)) continue;\n\t\t\t\tfor (const chunkFileName of reachableChunks(bundle, fileName)) {\n\t\t\t\t\treachableFromOtherEntries.add(chunkFileName);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst foldedIntoPages = new Set<string>();\n\n\t\t\tfor (const [fileName, chunk] of pageEntries) {\n\t\t\t\t// Vite names an extracted stylesheet after the chunk that\n\t\t\t\t// carries it (`content.css` at the dist root for an entry,\n\t\t\t\t// `<shared-chunk>.css` when two pages share the import), so\n\t\t\t\t// the contract path `modules/<page>/content.css` has to be\n\t\t\t\t// re-established here.\n\t\t\t\tconst cssFileNames = collectImportedCss(bundle, fileName);\n\t\t\t\tif (cssFileNames.length === 0) continue;\n\n\t\t\t\tconst targetFileName = fileName.replace(/\\.m?js$/, '.css');\n\t\t\t\tconst sources: string[] = [];\n\t\t\t\tfor (const cssFileName of cssFileNames) {\n\t\t\t\t\tconst asset = bundle[cssFileName];\n\t\t\t\t\tif (!asset || asset.type !== 'asset') continue;\n\t\t\t\t\tsources.push(assetSourceToString(asset.source));\n\t\t\t\t\tif (cssFileName !== targetFileName) foldedIntoPages.add(cssFileName);\n\t\t\t\t}\n\t\t\t\tif (sources.length === 0) continue;\n\n\t\t\t\t// Already exactly the contract path (single, correctly named\n\t\t\t\t// stylesheet) — nothing to re-emit.\n\t\t\t\tif (!(cssFileNames.length === 1 && cssFileNames[0] === targetFileName)) {\n\t\t\t\t\tthis.emitFile({\n\t\t\t\t\t\ttype: 'asset',\n\t\t\t\t\t\tfileName: targetFileName,\n\t\t\t\t\t\tsource: sources.join('\\n'),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Point the entry at its own stylesheet so wpExternals folds\n\t\t\t\t// the CSS into the `.asset.php` version hash.\n\t\t\t\tconst importedCss = chunk.viteMetadata?.importedCss;\n\t\t\t\tif (importedCss) {\n\t\t\t\t\tfor (const cssFileName of [...importedCss]) importedCss.delete(cssFileName);\n\t\t\t\t\timportedCss.add(targetFileName);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Drop the originals, but only when no other entry (a block's view\n\t\t\t// module, a theme entry) still needs them.\n\t\t\tfor (const cssFileName of foldedIntoPages) {\n\t\t\t\tconst referencing = referencingChunks.get(cssFileName) ?? new Set<string>();\n\t\t\t\tlet pagesOnly = true;\n\t\t\t\tfor (const chunkFileName of referencing) {\n\t\t\t\t\tif (reachableFromOtherEntries.has(chunkFileName)) pagesOnly = false;\n\t\t\t\t}\n\t\t\t\tif (!pagesOnly) continue;\n\n\t\t\t\tdelete bundle[cssFileName];\n\t\t\t\tfor (const output of Object.values(bundle)) {\n\t\t\t\t\tif (output.type !== 'chunk') continue;\n\t\t\t\t\toutput.viteMetadata?.importedCss.delete(cssFileName);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Immediate subdirectories of `adminPagesDirAbs` that carry a `content`\n * entry. A missing directory is a silent no-op (same as wpBlocks globbing a\n * directory that isn't there yet).\n */\nexport function discoverPages(adminPagesDirAbs: string): AdminPage[] {\n\tlet dirEntries;\n\ttry {\n\t\tdirEntries = readdirSync(adminPagesDirAbs, { withFileTypes: true });\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst pages: AdminPage[] = [];\n\tfor (const dirEntry of [...dirEntries].sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tif (!dirEntry.isDirectory()) continue;\n\t\tconst pageDir = join(adminPagesDirAbs, dirEntry.name);\n\n\t\t// No `content` entry → not a page (shared helpers, `components/`, …).\n\t\tconst content = resolveEntryFile(pageDir, 'content');\n\t\tif (!content) continue;\n\n\t\tconst route = resolveEntryFile(pageDir, 'route');\n\t\tpages.push({\n\t\t\tdirName: dirEntry.name,\n\t\t\tcontent,\n\t\t\t...(route ? { route } : {}),\n\t\t\tsubRoutes: discoverSubRoutes(pageDir),\n\t\t\tpageConfig: readPageConfig(pageDir),\n\t\t});\n\t}\n\treturn pages;\n}\n\n/**\n * Additional routes: every immediate subdirectory of `<pageDir>/routes/` that\n * carries a `content` or `route` entry. `route.json`'s `path` overrides the\n * default `/<name>`.\n */\nfunction discoverSubRoutes(pageDir: string): AdminPageRoute[] {\n\tconst routesDir = join(pageDir, 'routes');\n\tlet dirEntries;\n\ttry {\n\t\tdirEntries = readdirSync(routesDir, { withFileTypes: true });\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst subRoutes: AdminPageRoute[] = [];\n\tfor (const dirEntry of [...dirEntries].sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tif (!dirEntry.isDirectory()) continue;\n\t\tconst routeDir = join(routesDir, dirEntry.name);\n\t\tconst content = resolveEntryFile(routeDir, 'content');\n\t\tconst route = resolveEntryFile(routeDir, 'route');\n\t\t// Neither entry → not a route (shared code under `routes/`).\n\t\tif (!content && !route) continue;\n\n\t\tsubRoutes.push({\n\t\t\tname: dirEntry.name,\n\t\t\tpath: readRoutePath(routeDir, dirEntry.name),\n\t\t\t...(content ? { content } : {}),\n\t\t\t...(route ? { route } : {}),\n\t\t});\n\t}\n\treturn subRoutes;\n}\n\n/** Read and validate the optional `page.json` next to a page's entries. */\nfunction readPageConfig(pageDir: string): PageConfig {\n\tconst configPath = join(pageDir, 'page.json');\n\tif (!existsSync(configPath)) return {};\n\n\tconst raw = readJsonFile(configPath);\n\tconst config: PageConfig = {};\n\n\tif (raw.title !== undefined) {\n\t\tif (typeof raw.title !== 'string') {\n\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"title\" must be a string.`);\n\t\t}\n\t\tconfig.title = raw.title;\n\t}\n\n\tif (raw.menu !== undefined) {\n\t\tif (typeof raw.menu !== 'object' || raw.menu === null || Array.isArray(raw.menu)) {\n\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"menu\" must be an object.`);\n\t\t}\n\t\tconst menu = raw.menu as Record<string, unknown>;\n\t\tconst parsed: PageMenu = {};\n\t\tif (menu.parent !== undefined) {\n\t\t\tif (typeof menu.parent !== 'string' && menu.parent !== false) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`wpAdminPages: ${configPath} — \"menu.parent\" must be a string or false.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tparsed.parent = menu.parent;\n\t\t}\n\t\tif (menu.capability !== undefined) {\n\t\t\tif (typeof menu.capability !== 'string') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`wpAdminPages: ${configPath} — \"menu.capability\" must be a string.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tparsed.capability = menu.capability;\n\t\t}\n\t\tif (menu.position !== undefined) {\n\t\t\tif (typeof menu.position !== 'number' || !Number.isFinite(menu.position)) {\n\t\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"menu.position\" must be a number.`);\n\t\t\t}\n\t\t\tparsed.position = menu.position;\n\t\t}\n\t\tif (menu.icon !== undefined) {\n\t\t\tif (typeof menu.icon !== 'string') {\n\t\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"menu.icon\" must be a string.`);\n\t\t\t}\n\t\t\tparsed.icon = menu.icon;\n\t\t}\n\t\tconfig.menu = parsed;\n\t}\n\n\tif (raw.init !== undefined) {\n\t\tif (!Array.isArray(raw.init) || raw.init.some((id) => typeof id !== 'string')) {\n\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"init\" must be an array of strings.`);\n\t\t}\n\t\tfor (const moduleId of raw.init as string[]) {\n\t\t\tif (!/^[A-Za-z0-9@._/-]+$/.test(moduleId)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`wpAdminPages: ${configPath} — \"init\" entry \"${moduleId}\" is not a valid script module id.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconfig.init = raw.init as string[];\n\t}\n\n\tif (raw.modes !== undefined) {\n\t\tif (\n\t\t\t!Array.isArray(raw.modes) ||\n\t\t\traw.modes.length === 0 ||\n\t\t\traw.modes.some((mode) => !ALL_PAGE_MODES.includes(mode as PageMode))\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`wpAdminPages: ${configPath} — \"modes\" must be a non-empty array of ${ALL_PAGE_MODES.map(\n\t\t\t\t\t(mode) => `\"${mode}\"`,\n\t\t\t\t).join(' / ')}.`,\n\t\t\t);\n\t\t}\n\t\tconfig.modes = raw.modes as PageMode[];\n\t}\n\n\tif (raw.restPreload !== undefined) {\n\t\tif (!Array.isArray(raw.restPreload)) {\n\t\t\tthrow new Error(`wpAdminPages: ${configPath} — \"restPreload\" must be an array.`);\n\t\t}\n\t\tconst entries: RestPreloadEntry[] = [];\n\t\tfor (const entry of raw.restPreload) {\n\t\t\tif (typeof entry === 'string') {\n\t\t\t\tentries.push(entry);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tArray.isArray(entry) &&\n\t\t\t\tentry.length === 2 &&\n\t\t\t\tentry.every((part) => typeof part === 'string')\n\t\t\t) {\n\t\t\t\tentries.push([entry[0] as string, entry[1] as string]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\t`wpAdminPages: ${configPath} — \"restPreload\" entries must be a path string or a [path, method] pair.`,\n\t\t\t);\n\t\t}\n\t\tconfig.restPreload = entries;\n\t}\n\n\treturn config;\n}\n\n/** `route.json`'s `path`, defaulting to `/<name>`. */\nfunction readRoutePath(routeDir: string, name: string): string {\n\tconst configPath = join(routeDir, 'route.json');\n\tif (!existsSync(configPath)) return `/${name}`;\n\n\tconst raw = readJsonFile(configPath);\n\tif (raw.path === undefined) return `/${name}`;\n\tif (typeof raw.path !== 'string' || !raw.path.startsWith('/')) {\n\t\tthrow new Error(`wpAdminPages: ${configPath} — \"path\" must be a string starting with \"/\".`);\n\t}\n\treturn raw.path;\n}\n\nfunction readJsonFile(filePath: string): Record<string, unknown> {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(readFileSync(filePath, 'utf8'));\n\t} catch (error) {\n\t\tthrow new Error(`wpAdminPages: could not parse ${filePath} — ${(error as Error).message}`, {\n\t\t\tcause: error,\n\t\t});\n\t}\n\tif (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n\t\tthrow new Error(`wpAdminPages: ${filePath} must contain a JSON object.`);\n\t}\n\treturn parsed as Record<string, unknown>;\n}\n\n/** Internal registry name of the page-root `content` / `route` pair (path `/`). */\nconst PAGE_ROOT_ROUTE_NAME = 'index';\n\n/** Discovery result → the shape the PHP templates consume. */\nfunction toGeneratedPage(page: AdminPage): GeneratedPage {\n\tif (!isValidSlug(page.dirName)) {\n\t\tthrow new Error(\n\t\t\t`wpAdminPages: page directory \"${page.dirName}\" is not a valid page slug — use lowercase letters, digits and dashes.`,\n\t\t);\n\t}\n\n\tconst routes: GeneratedRoute[] = [\n\t\t{\n\t\t\tname: PAGE_ROOT_ROUTE_NAME,\n\t\t\tpath: '/',\n\t\t\tdir: `modules/${page.dirName}`,\n\t\t\thasContent: true,\n\t\t\thasRoute: !!page.route,\n\t\t},\n\t];\n\n\tfor (const subRoute of page.subRoutes) {\n\t\tif (!isValidSlug(subRoute.name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`wpAdminPages: route directory \"${page.dirName}/routes/${subRoute.name}\" is not a valid route name — use lowercase letters, digits and dashes.`,\n\t\t\t);\n\t\t}\n\t\troutes.push({\n\t\t\tname: subRoute.name,\n\t\t\tpath: subRoute.path,\n\t\t\tdir: `modules/${page.dirName}/routes/${subRoute.name}`,\n\t\t\thasContent: !!subRoute.content,\n\t\t\thasRoute: !!subRoute.route,\n\t\t});\n\t}\n\n\tconst config = page.pageConfig;\n\treturn {\n\t\tslug: page.dirName,\n\t\ttitle: config.title ?? titleCase(page.dirName),\n\t\tmodes: config.modes ?? ALL_PAGE_MODES,\n\t\tinitModules: config.init ?? [],\n\t\trestPreload: config.restPreload ?? DEFAULT_REST_PRELOAD,\n\t\t...(config.menu ? { menu: config.menu } : {}),\n\t\troutes,\n\t};\n}\n\n/** `site-health` → `Site Health`. Fallback when `page.json` has no title. */\nfunction titleCase(slug: string): string {\n\treturn slug\n\t\t.split('-')\n\t\t.filter(Boolean)\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t.join(' ');\n}\n\n/**\n * Resolve prefix / handle prefix / base URL / version, defaulting from the\n * consumer's package.json the way `@wordpress/build` does (`wpPlugin.name`).\n */\nfunction resolvePhpContext(php: WpAdminPagesPhpOptions, projectRoot: string): PhpContext {\n\tconst packageJsonPath = join(projectRoot, 'package.json');\n\tlet packageJson: {\n\t\tname?: string;\n\t\tversion?: string;\n\t\twpPlugin?: { name?: string; handlePrefix?: string };\n\t} = {};\n\tif (existsSync(packageJsonPath)) {\n\t\tpackageJson = readJsonFile(packageJsonPath) as typeof packageJson;\n\t}\n\n\tconst packageName = (packageJson.name ?? '').replace(/^@[^/]+\\//, '');\n\tconst prefix = php.prefix ?? packageJson.wpPlugin?.name ?? packageName;\n\tif (!prefix) {\n\t\tthrow new Error(\n\t\t\t'wpAdminPages: PHP generation needs an identifier prefix — set `adminPages.php.prefix`, or `wpPlugin.name` / `name` in package.json.',\n\t\t);\n\t}\n\tif (!isValidPhpIdentifier(prefix)) {\n\t\tthrow new Error(\n\t\t\t`wpAdminPages: \"${prefix}\" is not a usable PHP identifier prefix. Use letters, digits, underscores and dashes (dashes become underscores), and don't start with a digit. Set \\`adminPages.php.prefix\\` or \\`wpPlugin.name\\` in package.json.`,\n\t\t);\n\t}\n\n\tconst handlePrefix = php.handlePrefix ?? packageJson.wpPlugin?.handlePrefix ?? prefix;\n\tif (!/^[A-Za-z0-9@._/-]+$/.test(handlePrefix)) {\n\t\tthrow new Error(\n\t\t\t`wpAdminPages: \"${handlePrefix}\" is not a usable script module id prefix. Use letters, digits and \\`@ . _ / -\\`.`,\n\t\t);\n\t}\n\n\tconst textdomain = php.textdomain ?? 'default';\n\tif (!/^[A-Za-z0-9._-]+$/.test(textdomain)) {\n\t\tthrow new Error(\n\t\t\t`wpAdminPages: \"${textdomain}\" is not a usable text domain. Use letters, digits, dots, underscores and dashes.`,\n\t\t);\n\t}\n\n\treturn {\n\t\tprefix,\n\t\thandlePrefix,\n\t\tbaseUrl: php.baseUrl ?? 'plugin_dir_url( __FILE__ )',\n\t\tversion: packageJson.version ?? '0.0.0',\n\t\ttextdomain,\n\t};\n}\n\n/** Probe `<pageDir>/<basename>.{tsx,ts,jsx,js}` in wpBlocks' order. */\nfunction resolveEntryFile(pageDir: string, basename: string): string | null {\n\tfor (const extension of ENTRY_EXTENSIONS) {\n\t\tconst candidate = join(pageDir, `${basename}${extension}`);\n\t\tif (existsSync(candidate)) return candidate;\n\t}\n\treturn null;\n}\n\n/** Chunk file names reachable from `entryFileName` (static + dynamic imports). */\nfunction reachableChunks(bundle: Rollup.OutputBundle, entryFileName: string): Set<string> {\n\tconst visited = new Set<string>();\n\tconst queue = [entryFileName];\n\twhile (queue.length > 0) {\n\t\tconst fileName = queue.shift()!;\n\t\tif (visited.has(fileName)) continue;\n\t\tconst output = bundle[fileName];\n\t\t// Missing names are externals, not chunks in this bundle.\n\t\tif (!output || output.type !== 'chunk') continue;\n\t\tvisited.add(fileName);\n\t\tfor (const imported of [...(output.imports ?? []), ...(output.dynamicImports ?? [])]) {\n\t\t\tif (!visited.has(imported)) queue.push(imported);\n\t\t}\n\t}\n\treturn visited;\n}\n\n/**\n * Stylesheets reachable from an entry chunk, dependencies first (post-order)\n * so the concatenated CSS keeps a sane cascade.\n */\nfunction collectImportedCss(bundle: Rollup.OutputBundle, entryFileName: string): string[] {\n\tconst visited = new Set<string>();\n\tconst seen = new Set<string>();\n\tconst ordered: string[] = [];\n\n\tconst visit = (fileName: string): void => {\n\t\tif (visited.has(fileName)) return;\n\t\tvisited.add(fileName);\n\t\tconst output = bundle[fileName];\n\t\tif (!output || output.type !== 'chunk') return;\n\t\tfor (const imported of [...(output.imports ?? []), ...(output.dynamicImports ?? [])]) {\n\t\t\tvisit(imported);\n\t\t}\n\t\tfor (const cssFileName of output.viteMetadata?.importedCss ?? []) {\n\t\t\tif (seen.has(cssFileName)) continue;\n\t\t\tseen.add(cssFileName);\n\t\t\tordered.push(cssFileName);\n\t\t}\n\t};\n\n\tvisit(entryFileName);\n\treturn ordered;\n}\n\nfunction assetSourceToString(source: string | Uint8Array): string {\n\treturn typeof source === 'string' ? source : Buffer.from(source).toString('utf8');\n}\n","/**\n * vite-plugin-wp-blocks\n *\n * Scans `blocksDir` for `block.json` files and turns the `file:`-prefixed\n * asset references into Rollup input entries. Also copies each `block.json`\n * and any sibling PHP files into the dist tree so registration paths line up.\n *\n * Recognized block.json fields:\n * editorScript, script, viewScript, scriptModule, viewScriptModule,\n * style, editorStyle, viewStyle\n */\nimport { readFileSync, existsSync } from 'node:fs';\nimport { createHash } from 'node:crypto';\nimport { dirname, extname, join, relative, resolve } from 'node:path';\nimport fg from 'fast-glob';\nimport type { Plugin } from 'vite';\n\nconst SCRIPT_FIELDS = ['editorScript', 'script', 'viewScript'] as const;\nconst MODULE_FIELDS = ['scriptModule', 'viewScriptModule'] as const;\nconst STYLE_FIELDS = ['style', 'editorStyle', 'viewStyle'] as const;\n\ntype BlockJson = Partial<\n\tRecord<\n\t\t(typeof SCRIPT_FIELDS | typeof MODULE_FIELDS | typeof STYLE_FIELDS)[number],\n\t\tstring | string[]\n\t>\n>;\n\nexport interface WpBlocksOptions {\n\tblocksDir: string;\n\tbuildType?: 'script' | 'module';\n\t/**\n\t * Emit `blocks-manifest.php` (returns one PHP array of all block.json\n\t * contents). Lets PHP use `wp_register_block_types_from_metadata_collection`\n\t * (WP 6.7+) instead of N filesystem reads + JSON parses on every request.\n\t * Default: `true`.\n\t */\n\temitManifest?: boolean;\n\t/**\n\t * Block directory names (relative to `blocksDir`) to skip entirely —\n\t * neither discovered as entries nor included in the manifest.\n\t */\n\tskip?: string[];\n}\n\n/**\n * Virtual entry used to keep an entry-less module pass alive. A dual-pass\n * consumer runs `vite build --mode modules` unconditionally, but most\n * projects start with zero Script Module blocks — and Rollup/Rolldown\n * error on an empty input. The stub gives the pass one no-op entry, and\n * `generateBundle` deletes its chunk so nothing extra lands in dist/.\n */\nconst EMPTY_MODULE_PASS_ENTRY = '\\0wp-blocks-empty-module-pass';\n\nexport function wpBlocks(options: WpBlocksOptions): Plugin {\n\tconst buildType = options.buildType ?? 'script';\n\tconst emitManifest = options.emitManifest ?? true;\n\tconst skip = new Set(options.skip ?? []);\n\tlet blocksDirAbs: string;\n\n\treturn {\n\t\tname: 'wp-blocks',\n\t\tenforce: 'pre',\n\n\t\tconfig() {\n\t\t\tblocksDirAbs = resolve(process.cwd(), options.blocksDir);\n\t\t\treturn {\n\t\t\t\tbuild: {\n\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\tinput: discoverEntries(blocksDirAbs, buildType, skip),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\n\t\toptions(inputOptions) {\n\t\t\t// Module pass with no entries at all (no Script Module blocks and\n\t\t\t// no user-supplied input) → substitute the no-op stub entry so the\n\t\t\t// build succeeds as a no-op instead of erroring.\n\t\t\tif (buildType !== 'module') return null;\n\t\t\tconst input = inputOptions.input;\n\t\t\tconst isEmpty =\n\t\t\t\tinput == null ||\n\t\t\t\t(Array.isArray(input) && input.length === 0) ||\n\t\t\t\t(typeof input === 'object' &&\n\t\t\t\t\t!Array.isArray(input) &&\n\t\t\t\t\tObject.keys(input).length === 0);\n\t\t\tif (!isEmpty) return null;\n\t\t\treturn {\n\t\t\t\t...inputOptions,\n\t\t\t\tinput: { 'wp-blocks-empty-module-pass': EMPTY_MODULE_PASS_ENTRY },\n\t\t\t};\n\t\t},\n\n\t\tresolveId(source) {\n\t\t\treturn source === EMPTY_MODULE_PASS_ENTRY ? source : null;\n\t\t},\n\n\t\tload(id) {\n\t\t\treturn id === EMPTY_MODULE_PASS_ENTRY ? 'export {};' : null;\n\t\t},\n\n\t\tasync buildStart() {\n\t\t\t// Watch every block.json so adding a new block triggers a reload in dev.\n\t\t\tconst blockJsons = await fg(`${blocksDirAbs.replace(/\\\\/g, '/')}/**/block.json`, {\n\t\t\t\tabsolute: true,\n\t\t\t});\n\t\t\tfor (const file of blockJsons) {\n\t\t\t\tthis.addWatchFile(file);\n\t\t\t}\n\t\t},\n\n\t\tasync generateBundle(_outputOptions, bundle) {\n\t\t\t// Drop the stub chunk from an entry-less module pass (runs in the\n\t\t\t// pre phase, before wpExternals' post-phase generateBundle would\n\t\t\t// emit an .asset.php for it).\n\t\t\tfor (const [fileName, item] of Object.entries(bundle ?? {})) {\n\t\t\t\tif (item.type === 'chunk' && item.facadeModuleId === EMPTY_MODULE_PASS_ENTRY) {\n\t\t\t\t\tdelete bundle[fileName];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Only the script pass copies block.json + PHP and emits the manifest.\n\t\t\t// In a dual (script + module) build both passes write to the same dist\n\t\t\t// dir, and these outputs are identical either way — gating to the\n\t\t\t// script pass keeps the second pass purely additive.\n\t\t\tif (buildType !== 'script') return;\n\n\t\t\tconst files = await fg(\n\t\t\t\t[\n\t\t\t\t\t`${blocksDirAbs.replace(/\\\\/g, '/')}/**/block.json`,\n\t\t\t\t\t`${blocksDirAbs.replace(/\\\\/g, '/')}/**/*.php`,\n\t\t\t\t],\n\t\t\t\t{ absolute: true },\n\t\t\t);\n\t\t\tfor (const file of files) {\n\t\t\t\tconst relativePath = relative(blocksDirAbs, file).replace(/\\\\/g, '/');\n\t\t\t\t// block.json gets `file:` refs rewritten so they point at the\n\t\t\t\t// built output (.tsx → .js, .scss → .css), and a `version`\n\t\t\t\t// gets stamped from the style content hash when missing.\n\t\t\t\tconst isBlockJson = relativePath.endsWith('block.json');\n\t\t\t\tconst source = isBlockJson\n\t\t\t\t\t? transformBlockJson(readFileSync(file, 'utf8'), file)\n\t\t\t\t\t: readFileSync(file);\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: `blocks/${relativePath}`,\n\t\t\t\t\tsource,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (emitManifest) {\n\t\t\t\tconst manifest = buildBlocksManifest(blocksDirAbs, skip);\n\t\t\t\tif (manifest) {\n\t\t\t\t\tthis.emitFile({\n\t\t\t\t\t\ttype: 'asset',\n\t\t\t\t\t\tfileName: 'blocks-manifest.php',\n\t\t\t\t\t\tsource: manifest,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Rewrite `file:` references in block.json so they point at the built\n * output, and stamp a `version` from the source style content hash when\n * the block doesn't declare one.\n *\n * editorScript / script / viewScript / scriptModule / viewScriptModule → .js\n * style / editorStyle / viewStyle → .css\n * version (missing) ← SHA-256 of each `file:` style/viewStyle's source\n *\n * Why hash the *source* styles (not the built ones)? The goal is a stable\n * cache-bust key that changes only when authors edit content. Built CSS\n * bytes are sensitive to incidental postcss/minifier output drift; source\n * bytes aren't.\n */\nexport function transformBlockJson(raw: string, blockJsonPath: string): string {\n\tlet parsed: Record<string, unknown>;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn raw;\n\t}\n\n\tconst scriptFields = [\n\t\t'editorScript',\n\t\t'script',\n\t\t'viewScript',\n\t\t'scriptModule',\n\t\t'viewScriptModule',\n\t];\n\tconst styleFields = ['style', 'editorStyle', 'viewStyle'];\n\n\tconst rewriteRef = (ref: unknown, builtExtension: '.js' | '.css'): unknown => {\n\t\tif (typeof ref !== 'string' || !ref.startsWith('file:')) return ref;\n\t\treturn ref.replace(/\\.(tsx?|jsx?|s?css|sass)$/, builtExtension);\n\t};\n\n\t// Version stamping has to happen BEFORE rewriting refs so we hash the\n\t// source file (e.g. style.scss), not the renamed one (style.css).\n\tconst explicitVersion = typeof parsed.version === 'string' && parsed.version.length > 0;\n\tif (!explicitVersion) {\n\t\tconst blockDir = dirname(blockJsonPath);\n\t\tconst versionHash = hashStyleContent(parsed, ['style', 'viewStyle'], blockDir);\n\t\tif (versionHash) {\n\t\t\tparsed.version = versionHash;\n\t\t}\n\t}\n\n\tfor (const field of scriptFields) {\n\t\tconst fieldValue = parsed[field];\n\t\tif (Array.isArray(fieldValue)) {\n\t\t\tparsed[field] = fieldValue.map((ref) => rewriteRef(ref, '.js'));\n\t\t} else {\n\t\t\tparsed[field] = rewriteRef(fieldValue, '.js');\n\t\t}\n\t}\n\tfor (const field of styleFields) {\n\t\tconst fieldValue = parsed[field];\n\t\tif (Array.isArray(fieldValue)) {\n\t\t\tparsed[field] = fieldValue.map((ref) => rewriteRef(ref, '.css'));\n\t\t} else {\n\t\t\tparsed[field] = rewriteRef(fieldValue, '.css');\n\t\t}\n\t}\n\n\treturn JSON.stringify(parsed, null, '\\t') + '\\n';\n}\n\n/**\n * SHA-256 the concatenated source contents of every `file:` ref in the\n * given style fields. Returns `''` if no style file refs were found —\n * which signals to leave `version` unset.\n */\nfunction hashStyleContent(\n\tmetadata: Record<string, unknown>,\n\tfields: string[],\n\tblockDir: string,\n): string {\n\tconst hash = createHash('sha256');\n\tlet hashedAnyFile = false;\n\n\tfor (const field of fields) {\n\t\tconst fieldValue = metadata[field];\n\t\tconst refs = Array.isArray(fieldValue) ? fieldValue : [fieldValue];\n\t\tfor (const ref of refs) {\n\t\t\tif (typeof ref !== 'string' || !ref.startsWith('file:')) continue;\n\t\t\tconst relativePath = ref.replace(/^file:/, '');\n\t\t\tconst absolutePath = join(blockDir, relativePath);\n\t\t\ttry {\n\t\t\t\thash.update(readFileSync(absolutePath));\n\t\t\t\thashedAnyFile = true;\n\t\t\t} catch {\n\t\t\t\t// Style file missing — skip; the block.json author can fix.\n\t\t\t}\n\t\t}\n\t}\n\n\treturn hashedAnyFile ? hash.digest('hex') : '';\n}\n\n/**\n * Build the WP 6.7+ blocks manifest — one PHP file returning\n * `array( '<dir>' => <block.json contents>, ... )`. Consumed by\n * `wp_register_block_types_from_metadata_collection( $dir, $manifest )`.\n *\n * The manifest's metadata also needs `file:` refs rewritten — same reason\n * as the per-block.json transform above.\n */\nexport function buildBlocksManifest(blocksDirAbs: string, skip: Set<string>): string | null {\n\tconst blockJsons = fg.sync(`${blocksDirAbs.replace(/\\\\/g, '/')}/**/block.json`, {\n\t\tabsolute: true,\n\t});\n\n\tconst entries: Array<[string, unknown]> = [];\n\tfor (const file of blockJsons) {\n\t\ttry {\n\t\t\tconst metadata = JSON.parse(transformBlockJson(readFileSync(file, 'utf8'), file));\n\t\t\t// Key = directory containing block.json, relative to blocksDir.\n\t\t\tconst blockDirName = relative(blocksDirAbs, file)\n\t\t\t\t.replace(/[\\\\/]block\\.json$/, '')\n\t\t\t\t.replace(/\\\\/g, '/');\n\t\t\tif (skip.has(blockDirName)) continue;\n\t\t\tentries.push([blockDirName, metadata]);\n\t\t} catch {\n\t\t\t// Skip malformed block.json.\n\t\t}\n\t}\n\n\tif (entries.length === 0) return null;\n\n\tconst body = entries\n\t\t.map(([blockDirName, metadata]) => `\\t'${blockDirName}' => ${phpExport(metadata, 1)},`)\n\t\t.join('\\n');\n\n\treturn `<?php\\n// This file is generated. Do not modify it manually.\\nreturn array(\\n${body}\\n);\\n`;\n}\n\n/** Minimal JSON → PHP array literal exporter. Handles strings/numbers/bools/arrays/objects. */\nfunction phpExport(value: unknown, indent: number): string {\n\tconst pad = '\\t'.repeat(indent);\n\tconst padInner = '\\t'.repeat(indent + 1);\n\n\tif (value === null) return 'null';\n\tif (typeof value === 'boolean') return value ? 'true' : 'false';\n\tif (typeof value === 'number') return String(value);\n\tif (typeof value === 'string') return `'${value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n\tif (Array.isArray(value)) {\n\t\tif (value.length === 0) return 'array()';\n\t\tconst items = value.map((item) => `${padInner}${phpExport(item, indent + 1)}`).join(',\\n');\n\t\treturn `array(\\n${items},\\n${pad})`;\n\t}\n\tif (typeof value === 'object') {\n\t\tconst keys = Object.keys(value as Record<string, unknown>);\n\t\tif (keys.length === 0) return 'array()';\n\t\tconst items = keys\n\t\t\t.map((key) => {\n\t\t\t\tconst entryValue = (value as Record<string, unknown>)[key];\n\t\t\t\tconst phpKey = `'${key.replace(/'/g, \"\\\\'\")}'`;\n\t\t\t\treturn `${padInner}${phpKey} => ${phpExport(entryValue, indent + 1)}`;\n\t\t\t})\n\t\t\t.join(',\\n');\n\t\treturn `array(\\n${items},\\n${pad})`;\n\t}\n\treturn 'null';\n}\n\nexport function discoverEntries(\n\tblocksDirAbs: string,\n\tbuildType: 'script' | 'module',\n\tskip: Set<string>,\n): Record<string, string> {\n\tconst entries: Record<string, string> = {};\n\n\tconst blockJsons = fg.sync(`${blocksDirAbs.replace(/\\\\/g, '/')}/**/block.json`, {\n\t\tabsolute: true,\n\t});\n\n\tfor (const blockJsonPath of blockJsons) {\n\t\tconst blockDirName = relative(blocksDirAbs, blockJsonPath)\n\t\t\t.replace(/[\\\\/]block\\.json$/, '')\n\t\t\t.replace(/\\\\/g, '/');\n\t\tif (skip.has(blockDirName)) continue;\n\n\t\tlet metadata: BlockJson;\n\t\ttry {\n\t\t\tmetadata = JSON.parse(readFileSync(blockJsonPath, 'utf8')) as BlockJson;\n\t\t} catch {\n\t\t\t// Empty/malformed block.json is normal during scaffolding — skip silently.\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst fields =\n\t\t\tbuildType === 'module'\n\t\t\t\t? (MODULE_FIELDS as readonly string[])\n\t\t\t\t: ([...SCRIPT_FIELDS, ...STYLE_FIELDS] as readonly string[]);\n\n\t\tconst refs: string[] = [];\n\t\tfor (const field of fields) {\n\t\t\tconst fieldValue = (metadata as Record<string, unknown>)[field];\n\t\t\tif (typeof fieldValue === 'string') refs.push(fieldValue);\n\t\t\telse if (Array.isArray(fieldValue))\n\t\t\t\trefs.push(...fieldValue.filter((item): item is string => typeof item === 'string'));\n\t\t}\n\n\t\tfor (const ref of refs) {\n\t\t\tif (!ref.startsWith('file:')) continue; // handles aren't files, skip\n\t\t\tconst declaredPath = ref.replace(/^file:/, '');\n\t\t\t// Strip extension so we can resolve to whatever source extension exists.\n\t\t\tconst pathWithoutExtension = declaredPath.replace(\n\t\t\t\t/\\.(js|ts|tsx|jsx|css|scss|sass)$/,\n\t\t\t\t'',\n\t\t\t);\n\t\t\tconst candidatePaths = [\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.tsx`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.ts`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.jsx`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.js`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.scss`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.sass`),\n\t\t\t\tjoin(dirname(blockJsonPath), `${pathWithoutExtension}.css`),\n\t\t\t];\n\t\t\tconst sourcePath = candidatePaths.find((candidate) => existsSync(candidate));\n\t\t\tif (!sourcePath) {\n\t\t\t\tconsole.warn(`[wp-blocks] no source file found for ${ref} in ${blockJsonPath}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst entryName = `blocks/${relative(blocksDirAbs, sourcePath)\n\t\t\t\t.replace(extname(sourcePath), '')\n\t\t\t\t.replace(/\\\\/g, '/')}`;\n\n\t\t\tentries[entryName] = sourcePath;\n\t\t}\n\t}\n\n\treturn entries;\n}\n","/**\n * vite-plugin-wp-block-styles\n *\n * Every stylesheet under `blocksStylesDir` becomes its own entry, so each\n * gets a dedicated CSS file in dist that PHP can selectively enqueue\n * per block.\n *\n * Source: `assets/css/blocks/<block-name>/<file>.scss`\n * Output: `dist/autoenqueue/<block-name>/<file>.css`\n *\n * Guarantee: one output stylesheet per source stylesheet, always. Rollup\n * (and Rolldown) content-address emitted assets, so two byte-identical\n * outputs — copy-pasted per-block styles, or placeholder files that are\n * comment-only and minify to nothing — collapse into a single emitted\n * file even though `assetFileNames` gives them distinct names. The\n * second name then silently never lands in dist, and PHP still enqueues\n * it, producing a 404. To prevent that, every discovered source gets a\n * unique marker rule appended at `transform` time so no two outputs can\n * ever be byte-identical; `generateBundle` strips the marker back out of\n * the emitted CSS, then double-checks every expected output actually\n * made it into the bundle.\n */\nimport { extname, resolve, relative } from 'node:path';\nimport { realpathSync } from 'node:fs';\nimport fg from 'fast-glob';\nimport type { Plugin } from 'vite';\n\nexport interface WpBlockStylesOptions {\n\tblocksStylesDir: string;\n}\n\n/**\n * Resolves symlinks so the source path a `transform` id carries always\n * matches the path discovered in `config()`. Vite resolves module ids\n * through `fs.realpath`, but `fast-glob`'s output isn't realpath'd — on\n * macOS `os.tmpdir()` itself is a `/var` -> `/private/var` symlink, so\n * without this every id lookup below would silently miss inside a tmp\n * fixture and the marker would never get appended.\n */\nfunction normalizePath(filePath: string): string {\n\ttry {\n\t\treturn realpathSync.native(filePath);\n\t} catch {\n\t\treturn filePath;\n\t}\n}\n\n/** Custom property carrying the dedup-busting marker. Namespaced to avoid colliding with real declarations. */\nconst MARKER_PROPERTY = '--wp-vite-entry';\n\n/**\n * Matches the marker declaration only — not the surrounding `:root` rule,\n * which may already exist in the source and carry real declarations that\n * must survive. Tolerant of minifier whitespace/quote-style changes.\n */\nconst MARKER_DECLARATION_RE = new RegExp(\n\t`${MARKER_PROPERTY}\\\\s*:\\\\s*(?:\"[^\"]*\"|'[^']*')\\\\s*;?`,\n\t'g',\n);\n\n/** A `:root` rule left empty once the marker declaration is stripped out of it. */\nconst EMPTY_ROOT_RULE_RE = /:root\\s*\\{\\s*\\}/g;\n\n/**\n * The marker rule appended to a source stylesheet. `.sass` is indentation\n * syntax — no braces or semicolons allowed — everything else (`.css`,\n * `.scss`) accepts plain CSS syntax, which a custom property on `:root`\n * survives sass compilation and cssnano/lightningcss minification intact\n * because minifiers can't safely rewrite an arbitrary string value.\n */\nfunction markerRule(entryName: string, isIndentedSass: boolean): string {\n\tif (isIndentedSass) {\n\t\treturn `\\n:root\\n\\t${MARKER_PROPERTY}: \"${entryName}\"\\n`;\n\t}\n\treturn `\\n:root{${MARKER_PROPERTY}:\"${entryName}\"}\\n`;\n}\n\n/** Strips the marker declaration, and any `:root{}` left empty by doing so, from emitted CSS. */\nfunction stripMarker(source: string): string {\n\treturn source.replace(MARKER_DECLARATION_RE, '').replace(EMPTY_ROOT_RULE_RE, '');\n}\n\nexport function wpBlockStyles(options: WpBlockStylesOptions): Plugin {\n\tlet stylesDirAbs: string;\n\t// Absolute source path -> `autoenqueue/<name>` entry name, populated in\n\t// `config()` so `transform`/`generateBundle` can map source -> output\n\t// without re-globbing.\n\tconst entryNameByFile = new Map<string, string>();\n\n\treturn {\n\t\tname: 'wp-block-styles',\n\t\tenforce: 'pre',\n\n\t\tconfig() {\n\t\t\tstylesDirAbs = resolve(process.cwd(), options.blocksStylesDir);\n\n\t\t\tconst stylesheets = fg.sync(\n\t\t\t\t`${stylesDirAbs.replace(/\\\\/g, '/')}/**/*.{css,scss,sass}`,\n\t\t\t\t{ absolute: true },\n\t\t\t);\n\n\t\t\tentryNameByFile.clear();\n\t\t\tconst entries: Record<string, string> = {};\n\t\t\tfor (const filePath of stylesheets) {\n\t\t\t\tconst blockName = relative(stylesDirAbs, filePath)\n\t\t\t\t\t.replace(extname(filePath), '')\n\t\t\t\t\t.replace(/\\\\/g, '/');\n\t\t\t\tconst entryName = `autoenqueue/${blockName}`;\n\t\t\t\tentries[entryName] = filePath;\n\t\t\t\tentryNameByFile.set(normalizePath(filePath), entryName);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tbuild: {\n\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\tinput: entries,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\n\t\ttransform(code, id) {\n\t\t\t// Strip query/hash suffixes some pipelines append to module ids\n\t\t\t// before matching against the discovered source paths.\n\t\t\tconst [rawPath] = id.split('?');\n\t\t\tconst filePath = normalizePath(rawPath);\n\t\t\tconst entryName = entryNameByFile.get(filePath);\n\t\t\tif (!entryName) return null;\n\n\t\t\treturn code + markerRule(entryName, extname(rawPath) === '.sass');\n\t\t},\n\n\t\tgenerateBundle(_options, bundle) {\n\t\t\t// Expected output fileName -> source path, for both stripping and\n\t\t\t// the missing-output safety net below.\n\t\t\tconst expected = new Map<string, string>();\n\t\t\tfor (const [filePath, entryName] of entryNameByFile) {\n\t\t\t\texpected.set(`${entryName}.css`, filePath);\n\t\t\t}\n\n\t\t\tfor (const output of Object.values(bundle)) {\n\t\t\t\tif (output.type !== 'asset' || !expected.has(output.fileName)) continue;\n\t\t\t\tif (typeof output.source === 'string') {\n\t\t\t\t\toutput.source = stripMarker(output.source);\n\t\t\t\t} else {\n\t\t\t\t\toutput.source = Buffer.from(\n\t\t\t\t\t\tstripMarker(Buffer.from(output.source).toString('utf-8')),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst missing: string[] = [];\n\t\t\tfor (const [fileName, filePath] of expected) {\n\t\t\t\tif (!(fileName in bundle)) missing.push(`${fileName} (from ${filePath})`);\n\t\t\t}\n\t\t\tif (missing.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'wpBlockStyles: expected stylesheet(s) missing from the build output — ' +\n\t\t\t\t\t\t'each source under blocksStylesDir must produce its own dist file:\\n' +\n\t\t\t\t\t\tmissing.map((entry) => ` - ${entry}`).join('\\n'),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * vite-plugin-wp-copy-assets\n *\n * Copies `assets/**` to `dist/` so theme/plugin PHP can reference paths\n * like `dist/images/logo.svg` even though those files never pass through\n * the bundler.\n *\n * Default pattern:\n * `**\\/*.{jpg,jpeg,png,gif,webp,avif,ico,svg,eot,ttf,woff,woff2,otf}`\n *\n * Path semantics: a file at `<copyAssetsDir>/images/logo.svg` lands at\n * `dist/images/logo.svg` (the `copyAssetsDir` is the \"context\", and the\n * relative subpath is preserved).\n */\nimport { readFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport fg from 'fast-glob';\nimport type { Plugin } from 'vite';\n\nconst DEFAULT_PATTERN = '**/*.{jpg,jpeg,png,gif,webp,avif,ico,svg,eot,ttf,woff,woff2,otf}';\n\nexport interface WpCopyAssetsOptions {\n\t/** Source directory (default: `./assets`). */\n\tcopyAssetsDir: string;\n\t/** Override the glob pattern (relative to `copyAssetsDir`). */\n\tpattern?: string;\n\t/** Only run during the script pass — module pass would emit duplicates. */\n\tbuildType?: 'script' | 'module';\n}\n\nexport function wpCopyAssets(options: WpCopyAssetsOptions): Plugin {\n\tconst pattern = options.pattern ?? DEFAULT_PATTERN;\n\tconst buildType = options.buildType ?? 'script';\n\tlet copyDirAbs: string;\n\n\treturn {\n\t\tname: `wp-copy-assets(${buildType})`,\n\t\tenforce: 'pre',\n\n\t\tconfig() {\n\t\t\tcopyDirAbs = resolve(process.cwd(), options.copyAssetsDir);\n\t\t},\n\n\t\tasync generateBundle() {\n\t\t\t// Module pass would write the same files a second time; skip.\n\t\t\tif (buildType !== 'script') return;\n\n\t\t\tconst matches = await fg(pattern, {\n\t\t\t\tcwd: copyDirAbs,\n\t\t\t\tabsolute: true,\n\t\t\t\tonlyFiles: true,\n\t\t\t});\n\n\t\t\tfor (const file of matches) {\n\t\t\t\tconst relativePath = relative(copyDirAbs, file).replace(/\\\\/g, '/');\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: relativePath,\n\t\t\t\t\tsource: readFileSync(file),\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * Package-metadata reader for the metadata-driven externals path.\n *\n * Mirrors `@wordpress/wp-build`'s `package-utils.mjs`. Resolves a package's\n * `package.json` via Node's module-resolution and surfaces the two fields\n * that determine whether a package is externalizable:\n *\n * wpScript: true\n * Package is registered as a classic <script> in WP core.\n * Externalize against `window.wp.<camelCased name>` with the\n * script handle `wp-<name>`.\n *\n * wpScriptModuleExports: string | Record<string, string>\n * Package is registered as a Script Module. The value lists the\n * entry points; root import maps to `'.'` or a string value,\n * subpath imports (`@wordpress/blocks/sub/path`) map to keys\n * like `'./sub/path'`. Externalize by leaving the bare specifier\n * intact for WP's import map to resolve at runtime.\n *\n * Neither field\n * Package is *not* externalizable — bundle it into the consumer's\n * output. Drops the maintenance burden of a hand-maintained\n * BUNDLED_PACKAGES list (`@wordpress/icons`, `@wordpress/dataviews`,\n * etc.) by deriving the answer from each package's own metadata.\n *\n * Also hosts `resolvePackageEsmEntry`, the entry-point lookup the force-bundle\n * escape hatch needs for packages whose metadata *lies* about externalizability\n * (see `bundle` in `wp-externals.ts`).\n */\nimport { createRequire } from 'node:module';\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join, resolve as resolvePath } from 'node:path';\n\nexport interface WpPackageJson {\n\tname: string;\n\tversion: string;\n\twpScript?: true;\n\twpScriptModuleExports?: string | Record<string, string>;\n\tsideEffects?: boolean | string[];\n\tmain?: string;\n\tmodule?: string;\n\texports?: unknown;\n}\n\n// Cache keyed by package name @ project root. Two different projects in\n// the same Node process might have different versions installed.\nconst cache = new Map<string, WpPackageJson | null>();\n\n/**\n * Resolve a package's `package.json` from the project root, cache, return.\n * Returns `null` when the package isn't installed.\n */\nexport function readPackageMetadata(\n\tpackageName: string,\n\tprojectRoot: string,\n): WpPackageJson | null {\n\tconst cacheKey = `${packageName}@${projectRoot}`;\n\tif (cache.has(cacheKey)) {\n\t\treturn cache.get(cacheKey) ?? null;\n\t}\n\n\ttry {\n\t\tconst require = createRequire(join(projectRoot, 'package.json'));\n\t\tconst packageJsonPath = require.resolve(`${packageName}/package.json`);\n\t\tconst metadata = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as WpPackageJson;\n\t\tcache.set(cacheKey, metadata);\n\t\treturn metadata;\n\t} catch {\n\t\tcache.set(cacheKey, null);\n\t\treturn null;\n\t}\n}\n\n/**\n * Given an import like `@wordpress/blocks` or `@wordpress/blocks/sub`,\n * return the root package name and the subpath portion. Subpath is\n * `null` for root imports.\n *\n * `@wordpress/blocks` → { name: '@wordpress/blocks', subpath: null }\n * `@wordpress/blocks/sub` → { name: '@wordpress/blocks', subpath: 'sub' }\n * `@wordpress/blocks/sub/path` → { name: '@wordpress/blocks', subpath: 'sub/path' }\n * `lodash` → { name: 'lodash', subpath: null }\n * `lodash/get` → { name: 'lodash', subpath: 'get' }\n */\nexport function splitImport(specifier: string): { name: string; subpath: string | null } {\n\tconst parts = specifier.split('/');\n\tif (specifier.startsWith('@')) {\n\t\t// Scoped: `@scope/pkg[/subpath...]`\n\t\tif (parts.length < 2) return { name: specifier, subpath: null };\n\t\tconst name = `${parts[0]}/${parts[1]}`;\n\t\tconst subpath = parts.length > 2 ? parts.slice(2).join('/') : null;\n\t\treturn { name, subpath };\n\t}\n\treturn {\n\t\tname: parts[0] ?? specifier,\n\t\tsubpath: parts.length > 1 ? parts.slice(1).join('/') : null,\n\t};\n}\n\n/**\n * Does the given package + subpath qualify as a Script Module import?\n * Mirrors wp-build's `isScriptModuleImport`:\n * - Root import (`subpath: null`): `wpScriptModuleExports` is a string\n * OR an object with a `'.'` key.\n * - Subpath import: an object with a `'./<subpath>'` key.\n */\nexport function isScriptModule(metadata: WpPackageJson, subpath: string | null): boolean {\n\tconst exports = metadata.wpScriptModuleExports;\n\tif (!exports) return false;\n\tif (subpath === null) {\n\t\tif (typeof exports === 'string') return true;\n\t\treturn typeof exports === 'object' && '.' in exports;\n\t}\n\treturn typeof exports === 'object' && `./${subpath}` in exports;\n}\n\n/**\n * Convert `block-editor` → `blockEditor`. Matches the camelCasing\n * `wp.<name>` uses for `@wordpress/<name>` packages.\n */\nexport function camelize(kebabCaseName: string): string {\n\treturn kebabCaseName.replace(/-(.)/g, (_match, letter: string) => letter.toUpperCase());\n}\n\n/**\n * Pick the ESM-ish entry out of an `exports` value. Handles the three shapes\n * that appear in the wild: a bare string, a subpath map (`{ '.': … }`), and a\n * conditions map (`{ import: …, require: … }`), plus fallback arrays.\n *\n * Conditions are tried in the order that lands on ESM when the package ships\n * both builds; `require`/`node` are deliberately never consulted.\n */\nfunction pickExportsEntry(value: unknown): string | null {\n\tif (typeof value === 'string') return value;\n\tif (Array.isArray(value)) {\n\t\tfor (const candidate of value) {\n\t\t\tconst picked = pickExportsEntry(candidate);\n\t\t\tif (picked) return picked;\n\t\t}\n\t\treturn null;\n\t}\n\tif (!value || typeof value !== 'object') return null;\n\tconst record = value as Record<string, unknown>;\n\t// Subpath map — only the root entry is relevant here.\n\tif ('.' in record) return pickExportsEntry(record['.']);\n\tfor (const condition of ['module', 'import', 'browser', 'default']) {\n\t\tif (!(condition in record)) continue;\n\t\tconst picked = pickExportsEntry(record[condition]);\n\t\tif (picked) return picked;\n\t}\n\treturn null;\n}\n\n/**\n * Resolve a package's ESM entry point to an absolute file path.\n *\n * Used by the force-bundle path in `wpExternals`, which rewrites a bare\n * specifier to a marker id and then has to answer with a real file. Plain\n * `require.resolve('<pkg>')` would apply the `require` condition and land on\n * the CJS build (`@wordpress/icons` ships `main: build/index.js` alongside\n * `module: build-module/index.js`), costing tree-shaking. So resolve the\n * `package.json` — always reachable, even behind an `exports` map — and read\n * the entry fields ourselves.\n *\n * `fromPaths` are tried in order; each must be a *file* path createRequire can\n * anchor on. Force-bundled packages are often only reachable from inside\n * another dependency, so the importer belongs in that list ahead of the\n * project root.\n */\nexport function resolvePackageEsmEntry(packageName: string, fromPaths: string[]): string | null {\n\tfor (const from of fromPaths) {\n\t\tconst packageJsonPath = findPackageJson(packageName, from);\n\t\tif (!packageJsonPath) continue;\n\t\tlet metadata: WpPackageJson;\n\t\ttry {\n\t\t\tmetadata = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as WpPackageJson;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tconst entry =\n\t\t\tpickExportsEntry(metadata.exports) ??\n\t\t\t(typeof metadata.module === 'string' ? metadata.module : null) ??\n\t\t\t(typeof metadata.main === 'string' ? metadata.main : null) ??\n\t\t\t'./index.js';\n\t\tconst entryPath = resolvePath(dirname(packageJsonPath), entry);\n\t\tif (!existsSync(entryPath)) continue;\n\t\t// Vite resolves through symlinks by default (`preserveSymlinks: false`),\n\t\t// so hand back the real path or the same file ends up in the graph twice\n\t\t// under two ids.\n\t\ttry {\n\t\t\treturn realpathSync(entryPath);\n\t\t} catch {\n\t\t\treturn entryPath;\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Locate a package's `package.json`, anchored on a file path.\n *\n * `require.resolve('<pkg>/package.json')` is the direct route but throws\n * `ERR_PACKAGE_PATH_NOT_EXPORTED` for the growing number of packages whose\n * `exports` map doesn't list `./package.json`, so fall back to walking\n * `node_modules` up from the anchor — which also finds nested copies installed\n * for a single dependency.\n */\nfunction findPackageJson(packageName: string, from: string): string | null {\n\ttry {\n\t\treturn createRequire(from).resolve(`${packageName}/package.json`);\n\t} catch {\n\t\t// Fall through to the manual walk.\n\t}\n\tlet dir = dirname(from);\n\tfor (;;) {\n\t\tconst candidate = join(dir, 'node_modules', packageName, 'package.json');\n\t\tif (existsSync(candidate)) return candidate;\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return null;\n\t\tdir = parent;\n\t}\n}\n","/**\n * vite-plugin-wp-externals\n *\n * Two responsibilities, modeled on `@wordpress/wp-build`'s\n * `wordpress-externals-plugin.mjs`:\n *\n * 1. Decide whether each import should be externalized, and if so, in what\n * form. The decision reads each `@wordpress/*` package's *own*\n * `package.json` for `wpScript` / `wpScriptModuleExports` fields rather\n * than hardcoding a whitelist. Packages with neither field get bundled\n * automatically. This requires consumers to install the `@wordpress/*`\n * packages they import (rather than relying on globals provided by WP),\n * which is the tradeoff for self-documenting external-ness and\n * out-of-the-box TypeScript types.\n *\n * 2. Emit a `<entry>.asset.php` sidecar for every entry chunk with a\n * content-hash `version` covering the chunk code *and* its extracted\n * CSS. Module-mode assets also get `'type' => 'module'` so WP registers\n * them via `wp_register_script_module`. Dependencies come in two shapes,\n * because the two consumers disagree:\n *\n * - Default (block Script Modules): WordPress core reads\n * `dependencies` as the *module* dependency list — static specifiers\n * as plain strings, dynamic as\n * `array( 'id' => '...', 'import' => 'dynamic' )` — plus the\n * additive `script_dependencies` key for the classic handles the\n * module reads off `window.*`.\n * - Entries matching `wpBuildAssetMatchers` (admin pages): the\n * `@wordpress/build` shape — `dependencies` = classic handles,\n * `module_dependencies` = `array( 'id' => ..., 'import' => ... )`\n * entries, omitted when empty.\n *\n * Non-`@wordpress/*` imports use the legacy hardcoded path: `react`,\n * `react-dom`, `jquery`, `lodash` map to fixed globals; other namespaces\n * (`@woo/...`, `@acme/...`) get config-driven externalization via\n * `externalNamespaces`.\n *\n * 3. Force-bundle the packages whose metadata contradicts what WordPress core\n * registers (`DEFAULT_BUNDLED_PACKAGES`, plus the `bundle` option). This is\n * a specifier-text rewrite rather than a resolver decision, because the\n * transform above matches raw source text — see `bundlePlugin`.\n */\nimport crypto from 'node:crypto';\nimport { isAbsolute, join, relative } from 'node:path';\nimport { init, parse, type ImportSpecifier } from 'es-module-lexer';\nimport MagicString from 'magic-string';\nimport type { Plugin, Rollup } from 'vite';\nimport {\n\tcamelize,\n\tisScriptModule,\n\treadPackageMetadata,\n\tresolvePackageEsmEntry,\n\tsplitImport,\n} from './package-metadata';\n\nexport interface ExternalNamespace {\n\t/** Window global path, e.g. `wp` for `@wordpress/*`, `woo` for `@woo/*`. */\n\tglobal: string;\n\t/** Script-handle prefix used in `.asset.php`. `wp` → `wp-block-editor`. */\n\thandlePrefix: string;\n}\n\nexport interface WpExternalsOptions {\n\t/**\n\t * Project root used to resolve `@wordpress/*` (and other) package.jsons.\n\t * Defaults to `process.cwd()`. Pass the absolute project root for\n\t * deterministic resolution in monorepos / weird CWDs.\n\t */\n\tprojectRoot?: string;\n\t/**\n\t * Additional namespaces to externalize. The metadata-driven path covers\n\t * `@wordpress/*` automatically; this lets you add `woo`, `acme`, etc.\n\t * as classic-script externals (no metadata read — global/handle config\n\t * only).\n\t */\n\texternalNamespaces?: Record<string, ExternalNamespace>;\n\t/**\n\t * Non-scoped vendor externals (`react`, `jquery`, etc.). These don't\n\t * carry WP metadata so we keep the hardcoded mapping. Pass `{}` to\n\t * disable.\n\t */\n\tadditionalExternals?: Record<string, { global: string; handle: string | null }>;\n\t/**\n\t * 'script' (default) rewrites `import { x } from '@wordpress/y'` into\n\t * `const { x } = window.wp.y;` so the resulting bundle works as a\n\t * classic <script>. `.asset.php` lists `wp-y`-style handles for\n\t * `wp_register_script`.\n\t *\n\t * 'module' leaves ESM imports of Script-Module-eligible packages intact\n\t * (resolved at runtime by WP's import map) for use with\n\t * `wp_register_script_module` — required for the Interactivity API and\n\t * Script Modules generally. `.asset.php` lists those specifiers under\n\t * `module_dependencies` and includes `'type' => 'module'`. Script-only\n\t * packages (`wpScript`, vendor globals) have no module form, so they're\n\t * still rewritten to their `window.*` global with the classic handle\n\t * recorded in `dependencies`.\n\t */\n\tbuildType?: 'script' | 'module';\n\t/**\n\t * Substring matchers for file paths that should *always* be treated as\n\t * `module`-mode regardless of the plugin-level `buildType`. Lets a\n\t * single Vite dev server (which can only run one global mode at a time)\n\t * still serve Script Module entries with their ESM imports intact.\n\t *\n\t * Example: `['/view.ts', '/view-module.ts', '/view-module.js']`\n\t */\n\tmoduleEntryMatchers?: string[];\n\t/**\n\t * Substring matchers for entry *source* paths (the entry chunk's\n\t * `facadeModuleId`) whose `.asset.php` should use the\n\t * `@wordpress/build` shape:\n\t *\n\t * 'dependencies' => classic script handles\n\t * 'module_dependencies' => array( 'id' => …, 'import' => 'static'|'dynamic' )\n\t *\n\t * Entries that don't match keep the shape WordPress core reads when it\n\t * registers a Script Module from `block.json`\n\t * (`register_block_script_module_id()` passes `dependencies` straight\n\t * into `wp_register_script_module()`), so module specifiers stay in\n\t * `dependencies` there.\n\t *\n\t * `wp()` wires this automatically for `adminPagesDir`. Set it yourself\n\t * when composing plugins by hand.\n\t *\n\t * Example: `['/assets/js/admin-pages/']`\n\t */\n\twpBuildAssetMatchers?: string[];\n\t/**\n\t * Plugin-local Script Module namespaces — exact names or `prefix-*` globs.\n\t * Imports matching `@<ns>/<anything>` are externalized as Script Modules:\n\t * the ESM import is preserved (no global rewrite) and the specifier is\n\t * recorded in the `.asset.php` dependency list.\n\t *\n\t * Example: `['ignite-wp-navigation', 'ignite-*']`\n\t */\n\tscriptModuleNamespaces?: string[];\n\t/**\n\t * Populated during the build with specifier → window global for every\n\t * script-eligible external. `wpScriptIife` uses it to build a `require`\n\t * shim for CJS deps, which Rolldown resolves at runtime rather than\n\t * through the import rewrite.\n\t */\n\tglobalsSink?: Map<string, string>;\n\t/**\n\t * Bare package names to **force-bundle**: their externalization is\n\t * suppressed and their imports are rewritten to resolve against the\n\t * installed package's ESM entry instead.\n\t *\n\t * The escape hatch for packages whose WP metadata does not match what\n\t * WordPress core actually registers. Merges with (never replaces)\n\t * `DEFAULT_BUNDLED_PACKAGES`.\n\t *\n\t * Bare names only — `@wordpress/dataviews/wp` and other subpath entries\n\t * throw at config time, because force-bundling is a whole-package verdict.\n\t *\n\t * Example: `['@wordpress/icons', 'some-lying-package']`\n\t */\n\tbundle?: string[];\n}\n\n/**\n * Packages that claim externalizability they don't have. Same rationale as\n * core's `dependency-extraction-webpack-plugin` keeping a hardcoded\n * `BUNDLED_PACKAGES` list: the metadata is wrong with respect to what core\n * registers, and there is nowhere else to record that.\n *\n * `@wordpress/icons@10.x` ships `wpScript: true`, but WordPress core registers\n * no `wp-icons` script — it's absent from `script-loader-packages.php`. Trusting\n * the metadata produces two failures at once: `window.wp.icons` is undefined,\n * *and* the unregistered `wp-icons` dependency makes WordPress refuse to\n * enqueue the script at all. (`@wordpress/icons@11.x` dropped `wpScript`, so\n * without this list the behavior depends on which copy the resolver hoists.)\n */\nexport const DEFAULT_BUNDLED_PACKAGES = ['@wordpress/icons'];\n\n/**\n * Specifier prefix the force-bundle pre-transform swaps a bare package name\n * for. Two jobs: wpExternals' own transform never sees the bare specifier (so\n * it cannot rewrite it to a `window.*` read), and the resolver gets to point at\n * the package's *ESM* entry rather than whatever condition the native resolver\n * would pick.\n *\n * Deliberately not `\\0`-prefixed: Rolldown's native resolver has to hand the\n * id to our `resolveId` hook, and `\\0` ids take different code paths in parts\n * of the Vite/Rolldown pipeline.\n */\nconst BUNDLED_MARKER_PREFIX = 'wp-vite-bundled:';\n\n/** File extensions whose contents must lex as JavaScript. */\nconst JS_SOURCE_EXTENSION = /\\.[mc]?[jt]sx?$/;\n\nfunction escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Bare package name — `lodash`, `@wordpress/icons`; no subpath, no path. */\nfunction isBarePackageName(name: string): boolean {\n\tif (name.startsWith('@')) {\n\t\tconst parts = name.split('/');\n\t\treturn parts.length === 2 && parts[0]!.length > 1 && !!parts[1];\n\t}\n\treturn name.length > 0 && !name.includes('/') && !name.startsWith('.');\n}\n\n/**\n * Project-relative, posix-separated source path for an entry's `.asset.php`\n * `source` field. Returns `null` — the field is omitted rather than emitting\n * a nonsensical value — when `facadeModuleId` is absent (virtual entries)\n * or resolves outside `root` (a `..`-escaping relative path, or an\n * unrelated absolute path on a different drive/mount).\n */\nfunction entrySourcePath(facadeModuleId: string | null | undefined, root: string): string | null {\n\tif (!facadeModuleId) return null;\n\tconst relativePath = relative(root, facadeModuleId).replace(/\\\\/g, '/');\n\tif (relativePath === '' || relativePath === '..' || relativePath.startsWith('../')) {\n\t\treturn null;\n\t}\n\tif (isAbsolute(relativePath)) return null;\n\treturn relativePath;\n}\n\n/** Escape a string for embedding in a single-quoted PHP string literal. */\nfunction phpSingleQuoteEscape(value: string): string {\n\treturn value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\n/**\n * Vendor externals — non-`@wordpress/*` packages that need fixed\n * global/handle mappings because they're not WP-published packages and\n * don't carry `wpScript` metadata. Maps `react`, `react-dom`,\n * `react/jsx-runtime`, `react/jsx-dev-runtime`, `jquery`, `lodash`.\n *\n * Matches wp-build's `vendorExternals` map verbatim.\n */\nconst DEFAULT_VENDOR: Record<string, { global: string; handle: string | null }> = {\n\treact: { global: 'React', handle: 'react' },\n\t'react-dom': { global: 'ReactDOM', handle: 'react-dom' },\n\t'react-dom/client': { global: 'ReactDOM', handle: 'react-dom' },\n\t'react/jsx-runtime': {\n\t\tglobal: 'ReactJSXRuntime',\n\t\thandle: 'react-jsx-runtime',\n\t},\n\t'react/jsx-dev-runtime': {\n\t\tglobal: 'ReactJSXRuntime',\n\t\thandle: 'react-jsx-runtime',\n\t},\n\tmoment: { global: 'moment', handle: 'moment' },\n\tjquery: { global: 'jQuery', handle: 'jquery' },\n\tlodash: { global: 'lodash', handle: 'lodash' },\n\t'lodash-es': { global: 'lodash', handle: 'lodash' },\n};\n\n/**\n * Virtual module id prefix for the CJS-consumer shim.\n *\n * Rolldown parses CommonJS natively and, for a `require()` of a module we\n * mark `external: true`, keeps the call as a runtime `require(...)`. In a\n * browser that throws:\n *\n * Calling `require` for \"react\" in an environment that doesn't expose the\n * `require` function.\n *\n * Real dependency trees hit this constantly — `use-sync-external-store`'s\n * CJS shims (pulled in transitively by `@wordpress/dataviews` →\n * `@ariakit/react`), `react-is`, `prop-types`, etc. all `require('react')`.\n *\n * So when Rolldown tells us a specifier came from a `require()` site\n * (`options.kind === 'require-call'`), we resolve it to this virtual module\n * instead of externalizing it. `load()` answers with a one-line CommonJS\n * module that assigns the window global — the same trick the hand-rolled\n * esbuild boot pipelines use with their `wp-global:` namespace:\n *\n * module.exports = window.React;\n *\n * Rolldown wraps that in its `__commonJSMin` helper, so `require('react')`\n * becomes a plain function call returning `window.React`. No runtime\n * `require` survives.\n *\n * Note the deliberate `\\0` prefix: it keeps Vite's other plugins (and its\n * import analysis) away from the id.\n */\nconst CJS_GLOBAL_SHIM_PREFIX = '\\0wp-external-global:';\n\nexport interface ResolvedExternal {\n\t/** Window global path for script-mode rewrite. `null` if module-only. */\n\tglobal: string | null;\n\t/** Script handle (`wp-element`, `react-jsx-runtime`). `null` if module-only. */\n\thandle: string | null;\n\t/** Raw import specifier preserved for module-mode `.asset.php`. */\n\tspecifier: string;\n\t/** Whether this package can be used as a Script Module. */\n\tmoduleEligible: boolean;\n\t/** Whether this package can be used as a classic script. */\n\tscriptEligible: boolean;\n}\n\n/**\n * Config `resolveExternal` needs to make its verdict, extracted so the\n * resolver can be reused outside `wpExternals()` itself (e.g. a dev server\n * doing its own static dependency scan) without re-deriving `wpExternals`'\n * option defaults.\n */\nexport interface ResolveExternalOptions {\n\t/** Project root used to resolve `@wordpress/*` package.jsons. */\n\tprojectRoot: string;\n\t/** Vendor external map (`react`, `jquery`, …). Defaults to `DEFAULT_VENDOR`. */\n\tvendorExternals?: Record<string, { global: string; handle: string | null }>;\n\t/** Config-driven classic-script namespaces (`@woo/*`, etc.). */\n\texternalNamespaces?: Record<string, ExternalNamespace>;\n\t/** Script Module namespaces — exact names or `prefix-*` globs. */\n\tscriptModuleNamespaces?: string[];\n\t/** Bare package names to force-bundle (never externalized). */\n\tbundledPackages?: ReadonlySet<string> | string[];\n}\n\n/** Match `@<namespace>/anything` against an exact or `prefix-*` glob namespace. */\nfunction matchesScriptModuleNamespace(\n\tpackageName: string,\n\tscriptModuleNamespaces: string[],\n): boolean {\n\tif (!packageName.startsWith('@')) return false;\n\tconst slashIndex = packageName.indexOf('/');\n\tif (slashIndex < 0) return false;\n\tconst namespace = packageName.slice(1, slashIndex);\n\tfor (const pattern of scriptModuleNamespaces) {\n\t\tif (pattern.endsWith('*')) {\n\t\t\tif (namespace.startsWith(pattern.slice(0, -1))) return true;\n\t\t} else if (namespace === pattern) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Look up how a given import specifier should be externalized.\n * Returns `null` if it shouldn't be (i.e. should be bundled normally).\n *\n * Resolution order:\n * 0. Force-bundled packages — never external, whatever their metadata\n * says.\n * 1. Vendor map (`react`, `jquery`, etc.) — hardcoded.\n * 2. `@wordpress/*` — read the package's `package.json` for\n * `wpScript` / `wpScriptModuleExports`.\n * 3. Other configured namespaces (`@woo/*`, etc.) — config only,\n * no metadata read (treated like classic scripts).\n * 4. Script Module namespaces — preserve ESM import, record in\n * .asset.php for the runtime import-map.\n */\nexport function resolveExternal(\n\tspecifier: string,\n\toptions: ResolveExternalOptions,\n): ResolvedExternal | null {\n\tconst projectRoot = options.projectRoot;\n\tconst vendorExternals = options.vendorExternals ?? DEFAULT_VENDOR;\n\tconst externalNamespaces = options.externalNamespaces ?? {};\n\tconst scriptModuleNamespaces = options.scriptModuleNamespaces ?? [];\n\tconst bundledPackages =\n\t\toptions.bundledPackages instanceof Set\n\t\t\t? options.bundledPackages\n\t\t\t: new Set(options.bundledPackages ?? []);\n\n\t// 0. Force-bundled — short-circuits *before* any metadata read, so a\n\t// package with a wrong `wpScript` can never reach the rewrite. The\n\t// pre-transform below normally keeps the bare specifier from ever\n\t// getting here; this covers whatever syntax it didn't match.\n\tif (bundledPackages.has(splitImport(specifier).name)) return null;\n\n\t// 1. Vendor (react, jquery, …) — exact match including subpath.\n\tif (vendorExternals[specifier]) {\n\t\tconst vendor = vendorExternals[specifier];\n\t\treturn {\n\t\t\tglobal: vendor.global,\n\t\t\thandle: vendor.handle,\n\t\t\tspecifier,\n\t\t\tmoduleEligible: false,\n\t\t\tscriptEligible: true,\n\t\t};\n\t}\n\n\tconst { name, subpath } = splitImport(specifier);\n\n\t// 2. @wordpress/* — metadata-driven via package.json.\n\tif (name.startsWith('@wordpress/')) {\n\t\tconst meta = readPackageMetadata(name, projectRoot);\n\t\tif (!meta) {\n\t\t\t// Not installed locally. Two real failure modes:\n\t\t\t// a) consumer forgot to `npm install @wordpress/element`\n\t\t\t// b) package exists but is bundled-only (@wordpress/icons etc.)\n\t\t\t// Without metadata we can't tell — the safer default is\n\t\t\t// \"not externalizable; let Vite resolve/bundle or fail loudly\n\t\t\t// with a missing-module error\".\n\t\t\treturn null;\n\t\t}\n\n\t\tconst shortName = name.slice('@wordpress/'.length);\n\t\tconst moduleEligible = isScriptModule(meta, subpath);\n\t\tconst scriptEligible = !!meta.wpScript;\n\n\t\tif (!moduleEligible && !scriptEligible) {\n\t\t\t// Bundled package (@wordpress/icons, @wordpress/dataviews, …).\n\t\t\treturn null;\n\t\t}\n\n\t\treturn {\n\t\t\tglobal: scriptEligible ? `wp.${camelize(shortName)}` : null,\n\t\t\thandle: scriptEligible ? `wp-${shortName}` : null,\n\t\t\tspecifier,\n\t\t\tmoduleEligible,\n\t\t\tscriptEligible,\n\t\t};\n\t}\n\n\t// 3. Other configured classic-script namespaces (`@woo/*`, etc.) —\n\t// no metadata, treated like classic scripts only.\n\tfor (const [namespace, config] of Object.entries(externalNamespaces)) {\n\t\tif (name.startsWith(`@${namespace}/`)) {\n\t\t\tconst shortName = name.slice(`@${namespace}/`.length);\n\t\t\treturn {\n\t\t\t\tglobal: `${config.global}.${camelize(shortName)}`,\n\t\t\t\thandle: `${config.handlePrefix}-${shortName}`,\n\t\t\t\tspecifier,\n\t\t\t\tmoduleEligible: false,\n\t\t\t\tscriptEligible: true,\n\t\t\t};\n\t\t}\n\t}\n\n\t// 4. Script Module namespaces — these IDs are registered server-side\n\t// via `wp_register_script_module()`. Preserve the ESM import\n\t// untouched; record specifier in .asset.php for the runtime\n\t// import-map. Module-only, never available as a classic script.\n\tif (matchesScriptModuleNamespace(name, scriptModuleNamespaces)) {\n\t\treturn {\n\t\t\tglobal: null,\n\t\t\thandle: null,\n\t\t\tspecifier,\n\t\t\tmoduleEligible: true,\n\t\t\tscriptEligible: false,\n\t\t};\n\t}\n\n\treturn null;\n}\n\n/**\n * Parse a single ES import statement and produce equivalent code that reads\n * from a global instead. Handles the four shapes that appear in real code:\n *\n * import foo from '@x/y'; → const foo = (g && g.default) || g;\n * import * as foo from '@x/y'; → const foo = g;\n * import { a, b as c } from '@x/y'; → const { a, b: c } = g;\n * import '@x/y'; → (drops the statement; rare)\n */\n// JS identifiers can contain `$` (bundlers routinely mint `Fragment$1`-style\n// deduped names), but the regex shorthand `\\w` does NOT include `$` — using\n// it here silently failed to match those bindings, leaving the ESM `as`\n// keyword in place inside a `const { ... } = window.X` destructure (invalid\n// syntax; `:` renames in destructuring, not `as`). Real-world packages hit\n// this — e.g. `@ariakit/react-components`' published\n// `import { Fragment as Fragment$1, jsx, jsxs } from \"react/jsx-runtime\"`.\nconst JS_IDENTIFIER = '[A-Za-z_$][\\\\w$]*';\n\n/**\n * A side-effect import (`import '@x/y';` — no bindings, no `from`). The whole\n * point of externalizing is that the global is already on the page, so there\n * is no side effect left to run: the statement is dropped. `\\s*` before the\n * quote for the minified spelling (`import\"@x/y\";`).\n */\nconst SIDE_EFFECT_IMPORT = /^\\s*import\\s*['\"][^'\"]+['\"]\\s*;?\\s*$/;\n\nfunction rewriteImport(importStatement: string, globalAccess: string): string | null {\n\t// Must be checked before the `from` match below, which a side-effect import\n\t// can never satisfy. Returning '' (not null) is what drops the statement —\n\t// leaving it intact would ship a bare `import \"@wordpress/foo\";` into a\n\t// classic script, a SyntaxError the browser reports for the whole file.\n\t// wpScriptIife's leading-side-effect stripper happens to rescue this in the\n\t// composed path, which is exactly why it has to be handled here too: with\n\t// `iife: false`, or wpExternals used standalone, nothing else catches it.\n\tif (SIDE_EFFECT_IMPORT.test(importStatement)) return '';\n\n\t// `\\s*`, not `\\s+`, around `import`/`from`: published dist bundles (Parcel,\n\t// esbuild scope-hoisting, etc. — seen in @headlessui/react, @radix-ui/*,\n\t// react-aria) frequently ship zero-whitespace `import{a as b}from\"react\"`.\n\t// A `\\s+` here silently failed to match minified statements like that.\n\tconst match = importStatement.match(/^\\s*import\\s*(.*?)\\s*from\\s*['\"][^'\"]+['\"]\\s*;?\\s*$/s);\n\t// On no match, return null (leave the statement untouched) rather than an\n\t// empty string. An empty string tells the caller to blank the statement\n\t// out — for a shape this function doesn't recognize, that silently\n\t// deletes whatever the import defined (real bug: broke @headlessui/react's\n\t// `use-id.js`, whose `r` binding disappeared, leaving `export { r as\n\t// useId }` referencing nothing). `null` falls back to leaving Rollup to\n\t// bundle the real package for that one import instead — always valid\n\t// syntax, just occasionally not externalized.\n\tif (!match || !match[1]) return null;\n\tconst bindings = match[1].trim();\n\n\t// `\\s*` after `*`, not `\\s+`: `*` is punctuation, so minifiers emit\n\t// `import*as j from\"react\"` (@headlessui/react does). The named-import\n\t// branch below is safe as-is — `{a as b}` can't lose its whitespace.\n\tconst namespaceImport = bindings.match(new RegExp(`^\\\\*\\\\s*as\\\\s+(${JS_IDENTIFIER})$`));\n\tif (namespaceImport) return `const ${namespaceImport[1]} = ${globalAccess};`;\n\n\tconst defaultWithNamed = bindings.match(\n\t\tnew RegExp(`^(${JS_IDENTIFIER})\\\\s*,\\\\s*\\\\{(.+)\\\\}$`, 's'),\n\t);\n\tif (defaultWithNamed) {\n\t\tconst destructured = namedImportsToDestructuring(defaultWithNamed[2]!.trim());\n\t\tif (destructured === null) return null;\n\t\treturn [\n\t\t\t`const ${defaultWithNamed[1]} = (${globalAccess} && ${globalAccess}.default) || ${globalAccess};`,\n\t\t\t`const { ${destructured} } = ${globalAccess};`,\n\t\t].join(' ');\n\t}\n\n\tif (bindings.startsWith('{')) {\n\t\tconst namedImports = bindings.replace(/^\\{|\\}$/g, '').trim();\n\t\tconst destructured = namedImportsToDestructuring(namedImports);\n\t\tif (destructured === null) return null;\n\t\treturn `const { ${destructured} } = ${globalAccess};`;\n\t}\n\n\tif (new RegExp(`^${JS_IDENTIFIER}$`).test(bindings)) {\n\t\treturn `const ${bindings} = (${globalAccess} && ${globalAccess}.default) || ${globalAccess};`;\n\t}\n\n\treturn null;\n}\n\n/**\n * Convert named-import bindings (`a, b as c`) into destructuring syntax\n * (`a, b: c`), or `null` if any binding isn't a shape we can rewrite.\n *\n * `null` rather than passing the raw text through: ES2022 arbitrary module\n * namespace names (`import { \"a-b\" as c } from 'react'`) are neither a plain\n * identifier nor an `id as id` pair, and emitting them verbatim produces\n * `const { \"a-b\" as c } = window.React;` — a SyntaxError. Bailing out leaves\n * the statement alone and lets Rollup bundle the package for that one import,\n * which is always valid, just not externalized.\n */\nfunction namedImportsToDestructuring(namedImports: string): string | null {\n\tconst aliasPattern = new RegExp(`^(${JS_IDENTIFIER})\\\\s+as\\\\s+(${JS_IDENTIFIER})$`);\n\tconst plainPattern = new RegExp(`^${JS_IDENTIFIER}$`);\n\tconst bindings: string[] = [];\n\n\tfor (const raw of namedImports.split(',')) {\n\t\tconst binding = raw.trim();\n\t\tif (!binding) continue;\n\t\tconst aliased = binding.match(aliasPattern);\n\t\tif (aliased) {\n\t\t\tbindings.push(`${aliased[1]}: ${aliased[2]}`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (plainPattern.test(binding)) {\n\t\t\tbindings.push(binding);\n\t\t\tcontinue;\n\t\t}\n\t\treturn null;\n\t}\n\n\treturn bindings.join(', ');\n}\n\nexport function wpExternals(options: WpExternalsOptions = {}): Plugin[] {\n\tconst projectRoot = options.projectRoot ?? process.cwd();\n\tconst externalNamespaces = options.externalNamespaces ?? {};\n\tconst vendorExternals = options.additionalExternals ?? DEFAULT_VENDOR;\n\tconst buildType = options.buildType ?? 'script';\n\tconst moduleEntryMatchers = options.moduleEntryMatchers ?? [];\n\tconst wpBuildAssetMatchers = options.wpBuildAssetMatchers ?? [];\n\tconst scriptModuleNamespaces = options.scriptModuleNamespaces ?? [];\n\tconst globalsSink = options.globalsSink;\n\n\tfor (const name of options.bundle ?? []) {\n\t\tif (isBarePackageName(name)) continue;\n\t\tconst { name: rootName, subpath } = splitImport(name);\n\t\tthrow new Error(\n\t\t\t`wpExternals: \\`bundle\\` accepts bare package names only, got '${name}'.` +\n\t\t\t\t(subpath\n\t\t\t\t\t? ` Force-bundling is a whole-package verdict — list '${rootName}' instead of the '${subpath}' subpath.`\n\t\t\t\t\t: ''),\n\t\t);\n\t}\n\tconst bundledPackages = new Set([...DEFAULT_BUNDLED_PACKAGES, ...(options.bundle ?? [])]);\n\tconst resolveExternalOptions: ResolveExternalOptions = {\n\t\tprojectRoot,\n\t\tvendorExternals,\n\t\texternalNamespaces,\n\t\tscriptModuleNamespaces,\n\t\tbundledPackages,\n\t};\n\n\t/**\n\t * Bound to this plugin instance's resolved options — see module-level\n\t * `resolveExternal`.\n\t *\n\t * Every specifier → global verdict this plugin reaches is also recorded in\n\t * `globalsSink`, which `wpScriptIife` turns into a `require` shim. Recording\n\t * here rather than inside `resolveExternal` is deliberate on two counts: the\n\t * module-level function is shared with `wpDevServer`, which has no sink; and\n\t * this wrapper is the single funnel for *all* of the plugin's lookups —\n\t * `resolveId` and the CJS `require()` path included, which is exactly where\n\t * the specifiers that need the shim come from (the import rewrite in\n\t * `transform` never sees them).\n\t */\n\tfunction resolveExternalForThisPlugin(specifier: string): ResolvedExternal | null {\n\t\tconst external = resolveExternal(specifier, resolveExternalOptions);\n\t\tif (external?.global) globalsSink?.set(external.specifier, external.global);\n\t\treturn external;\n\t}\n\n\t// Separators are normalized on both sides so a matcher can always be written\n\t// with forward slashes — the same rule `usesWpBuildAssetShape` below already\n\t// applies. It matters more here now that `wpDevServer` fills this array with\n\t// absolute paths it discovered on disk, which carry the platform separator\n\t// while Vite module ids always use `/`.\n\tfunction buildModeForFile(moduleId: string): 'script' | 'module' {\n\t\tconst filePath = (moduleId.split('?')[0] ?? moduleId).replace(/\\\\/g, '/');\n\t\tfor (const pattern of moduleEntryMatchers) {\n\t\t\tif (filePath.includes(pattern.replace(/\\\\/g, '/'))) return 'module';\n\t\t}\n\t\treturn buildType;\n\t}\n\n\t/**\n\t * Does this entry's source path opt into the `@wordpress/build` asset\n\t * shape? Path separators are normalized so matchers can always be\n\t * written with forward slashes.\n\t */\n\tfunction usesWpBuildAssetShape(facadeModuleId: string | null | undefined): boolean {\n\t\tif (!facadeModuleId) return false;\n\t\tconst filePath = (facadeModuleId.split('?')[0] ?? facadeModuleId).replace(/\\\\/g, '/');\n\t\tfor (const pattern of wpBuildAssetMatchers) {\n\t\t\tif (filePath.includes(pattern.replace(/\\\\/g, '/'))) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t// In module mode, only specific @wordpress packages support dynamic\n\t// imports per wp-build. Static is the safer default.\n\tfunction moduleImportKind(specifier: string, isDynamic: boolean): 'static' | 'dynamic' {\n\t\t// `@wordpress/interactivity` MUST be static (DEWP comment:\n\t\t// \"Interactivity does not support dynamic imports at this time\").\n\t\tif (specifier === '@wordpress/interactivity') return 'static';\n\t\treturn isDynamic ? 'dynamic' : 'static';\n\t}\n\n\t// Per-module dep tracking. Keyed by Rollup module id.\n\tconst staticDepsByModule = new Map<string, Set<string>>();\n\tconst dynamicDepsByModule = new Map<string, Set<string>>();\n\tconst handleDepsByModule = new Map<string, Set<string>>();\n\n\t/**\n\t * Merge into a per-module dep set. Two hooks write to `handleDepsByModule`\n\t * (the transform's ESM rewrite and the resolver's CJS shim), so a plain\n\t * `.set()` would let one clobber the other.\n\t */\n\tfunction recordDeps(\n\t\tmap: Map<string, Set<string>>,\n\t\tmoduleId: string,\n\t\tvalues: Iterable<string>,\n\t): void {\n\t\tlet set = map.get(moduleId);\n\t\tif (!set) {\n\t\t\tset = new Set<string>();\n\t\t\tmap.set(moduleId, set);\n\t\t}\n\t\tfor (const value of values) set.add(value);\n\t}\n\n\tconst resolverPlugin: Plugin = {\n\t\tname: `wp-externals-resolver(${buildType})`,\n\t\tenforce: 'pre',\n\n\t\tresolveId(source, _importer, options) {\n\t\t\t// Rolldown tags `require()` sites with `kind: 'require-call'`\n\t\t\t// (Rollup passes no `kind` at all, so this branch is inert there\n\t\t\t// and @rollup/plugin-commonjs' `?commonjs-external` path below\n\t\t\t// keeps handling that bundler).\n\t\t\tconst isRequireCall =\n\t\t\t\t(options as { kind?: string } | undefined)?.kind === 'require-call';\n\n\t\t\tconst external = resolveExternalForThisPlugin(source);\n\t\t\tif (external) {\n\t\t\t\tif (isRequireCall) {\n\t\t\t\t\tif (external.global) {\n\t\t\t\t\t\t// Serve a CJS global shim instead of externalizing, so\n\t\t\t\t\t\t// no runtime `require` survives into the browser.\n\t\t\t\t\t\treturn CJS_GLOBAL_SHIM_PREFIX + source;\n\t\t\t\t\t}\n\t\t\t\t\t// Module-only external (Script Module namespaces, or a\n\t\t\t\t\t// `@wordpress/*` package with `wpScriptModuleExports` but\n\t\t\t\t\t// no `wpScript`). There's no global to read and a CJS\n\t\t\t\t\t// consumer can't await an ESM import, so we can only warn.\n\t\t\t\t\tif (typeof this?.warn === 'function') {\n\t\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t\t`${source} is required from CommonJS but is module-only (no wpScript in its package.json, so there is no window global to read). ` +\n\t\t\t\t\t\t\t\t`The bundled \\`require('${source}')\\` will throw at runtime — import it from ESM instead.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { id: source, external: true };\n\t\t\t}\n\t\t\t// CJS-wrapped externals (`\\0<specifier>?commonjs-external`) —\n\t\t\t// @rollup/plugin-commonjs' convention, used by Rollup-based Vite.\n\t\t\tconst commonjsMatch = source.match(/^\\0([^?]+)\\?commonjs-external$/);\n\t\t\tif (\n\t\t\t\tcommonjsMatch &&\n\t\t\t\tcommonjsMatch[1] &&\n\t\t\t\tresolveExternalForThisPlugin(commonjsMatch[1])\n\t\t\t) {\n\t\t\t\treturn source;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(CJS_GLOBAL_SHIM_PREFIX)) {\n\t\t\t\tconst specifier = id.slice(CJS_GLOBAL_SHIM_PREFIX.length);\n\t\t\t\tconst external = resolveExternalForThisPlugin(specifier);\n\t\t\t\tif (!external || !external.global) return null;\n\t\t\t\t// The shim carries the classic handle: `.asset.php` still has\n\t\t\t\t// to list `react` so WP enqueues the script that defines\n\t\t\t\t// `window.React`. Virtual ids show up in `chunk.modules`, so\n\t\t\t\t// generateBundle's walk finds this.\n\t\t\t\tif (external.handle) recordDeps(handleDepsByModule, id, [external.handle]);\n\t\t\t\t// CommonJS on purpose: Rolldown detects the format from\n\t\t\t\t// `module.exports` and turns the `require()` into a call to\n\t\t\t\t// this module's wrapper.\n\t\t\t\treturn `module.exports = (typeof window !== \"undefined\" ? window.${external.global} : {});\\n`;\n\t\t\t}\n\t\t\tconst commonjsMatch = id.match(/^\\0([^?]+)\\?commonjs-external$/);\n\t\t\tif (!commonjsMatch || !commonjsMatch[1]) return null;\n\t\t\tconst external = resolveExternalForThisPlugin(commonjsMatch[1]);\n\t\t\tif (!external) return null;\n\t\t\tif (buildModeForFile(id) === 'module' && external.moduleEligible) {\n\t\t\t\treturn `export default {};`;\n\t\t\t}\n\t\t\tif (!external.global) {\n\t\t\t\treturn `export default {};`;\n\t\t\t}\n\t\t\tif (external.handle) recordDeps(handleDepsByModule, id, [external.handle]);\n\t\t\treturn `const __wpExternal = (typeof window !== \"undefined\" ? window.${external.global} : {}); export default __wpExternal;`;\n\t\t},\n\t};\n\n\t// Resolved Vite project root, captured in `configResolved` — the basis\n\t// for the `.asset.php` `source` field's project-relative path. Distinct\n\t// from `projectRoot` above (which drives `@wordpress/*` package.json\n\t// resolution and defaults to `process.cwd()`): this one is Vite's own\n\t// `config.root`, which is what a chunk's `facadeModuleId` is actually\n\t// relative to.\n\tlet resolvedRoot = projectRoot;\n\n\tconst transformPlugin: Plugin = {\n\t\tname: `wp-externals(${buildType})`,\n\t\tenforce: 'post',\n\n\t\tconfigResolved(config) {\n\t\t\tresolvedRoot = config.root;\n\t\t},\n\n\t\tasync transform(code, id) {\n\t\t\t// Fast-path bail.\n\t\t\tif (\n\t\t\t\t!code.includes('@wordpress/') &&\n\t\t\t\t!Object.keys(vendorExternals).some((packageName) => code.includes(packageName)) &&\n\t\t\t\t!Object.keys(externalNamespaces).some((namespace) =>\n\t\t\t\t\tcode.includes(`@${namespace}/`),\n\t\t\t\t) &&\n\t\t\t\t!scriptModuleNamespaces.some((pattern) =>\n\t\t\t\t\tcode.includes(`@${pattern.endsWith('*') ? pattern.slice(0, -1) : pattern}`),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tawait init;\n\t\t\tlet imports: readonly ImportSpecifier[];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code, id);\n\t\t\t} catch (error) {\n\t\t\t\t// A swallowed parse failure here is the worst possible outcome:\n\t\t\t\t// the module got past the fast-path, so it *does* reference\n\t\t\t\t// something externalizable, and bailing quietly ships the bare\n\t\t\t\t// `@wordpress/*` imports un-rewritten with an incomplete\n\t\t\t\t// `.asset.php` — a runtime failure in the editor with zero\n\t\t\t\t// build signal. Fail the build instead.\n\t\t\t\t//\n\t\t\t\t// Only for modules whose extension promises JavaScript: this\n\t\t\t\t// hook also sees CSS and other non-JS module content (it runs\n\t\t\t\t// before Vite's own post-build plugins), and those must stay\n\t\t\t\t// silent bails.\n\t\t\t\tconst filePath = id.split('?')[0] ?? id;\n\t\t\t\tif (!JS_SOURCE_EXTENSION.test(filePath)) return null;\n\t\t\t\treturn this.error(\n\t\t\t\t\t`wp-externals could not parse the imports of ${filePath}: ${\n\t\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t\t}\\n` +\n\t\t\t\t\t\t`Its @wordpress/* imports would ship un-rewritten (broken window.wp.* reads and an incomplete .asset.php), so this is a hard error.\\n` +\n\t\t\t\t\t\t`Most likely cause: JSX in a file that isn't .jsx/.tsx. JSX must live in .jsx/.tsx files — do not use \\`rollupOptions.moduleTypes\\` to map .js to jsx; rename the files instead. ` +\n\t\t\t\t\t\t`The JSX transform runs *after* plugin transform hooks, so \\`moduleTypes\\` makes the build pass while this plugin still sees raw JSX and produces broken output.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (imports.length === 0) return null;\n\n\t\t\tconst magicString = new MagicString(code);\n\t\t\tlet codeChanged = false;\n\t\t\tconst fileMode = buildModeForFile(id);\n\n\t\t\tconst staticDeps = new Set<string>();\n\t\t\tconst dynamicDeps = new Set<string>();\n\t\t\tconst handleDeps = new Set<string>();\n\n\t\t\t/**\n\t\t\t * Rewrite one import statement into a `window.*` read and record\n\t\t\t * its classic script handle. Returns whether code changed.\n\t\t\t */\n\t\t\tconst rewriteToGlobal = (\n\t\t\t\texternal: ResolvedExternal,\n\t\t\t\timportRecord: ImportSpecifier,\n\t\t\t): boolean => {\n\t\t\t\tconst importStatement = code.slice(importRecord.ss, importRecord.se);\n\t\t\t\tconst rewritten = rewriteImport(importStatement, `(window.${external.global})`);\n\t\t\t\tif (rewritten === null) return false;\n\t\t\t\tmagicString.overwrite(importRecord.ss, importRecord.se, rewritten);\n\t\t\t\tif (external.handle) handleDeps.add(external.handle);\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\tfor (const importRecord of imports) {\n\t\t\t\tconst importedSpecifier = importRecord.n;\n\t\t\t\tif (importedSpecifier === undefined) continue;\n\t\t\t\tconst external = resolveExternalForThisPlugin(importedSpecifier);\n\t\t\t\tif (!external) continue;\n\n\t\t\t\tconst isDynamic = importRecord.d > -1;\n\n\t\t\t\tif (fileMode === 'script') {\n\t\t\t\t\tif (isDynamic || !external.scriptEligible) {\n\t\t\t\t\t\t// Dynamic imports → leave alone. Module-only packages\n\t\t\t\t\t\t// (no wpScript) → leave alone too; Rollup will keep\n\t\t\t\t\t\t// the bare ESM import which is fine in a module\n\t\t\t\t\t\t// context but problematic in a classic script. We\n\t\t\t\t\t\t// warn rather than fail to surface the issue.\n\t\t\t\t\t\tif (!external.scriptEligible && !isDynamic) {\n\t\t\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t\t\t`${importedSpecifier} is module-only (no wpScript in its package.json) but imported into a script-mode entry. ` +\n\t\t\t\t\t\t\t\t\t`Move this import to a viewScriptModule entry, or this script will fail at runtime.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (rewriteToGlobal(external, importRecord)) codeChanged = true;\n\t\t\t\t} else if (!external.moduleEligible) {\n\t\t\t\t\t// Module mode, script-only package (`wpScript: true` or a\n\t\t\t\t\t// vendor global like `react`). A Script Module can still\n\t\t\t\t\t// use it: WP enqueues the classic script — collected into\n\t\t\t\t\t// the sidecar's `dependencies` for PHP to depend on — and\n\t\t\t\t\t// the module reads its `window.*` global. This is the\n\t\t\t\t\t// three-tier strategy wp-build (and the hand-rolled\n\t\t\t\t\t// esbuild boot pipelines) apply, and it's what makes\n\t\t\t\t\t// `@wordpress/boot` admin pages buildable: they pull in\n\t\t\t\t\t// `wp-components`, `wp-data`, `react`, … which have no\n\t\t\t\t\t// Script Module form.\n\t\t\t\t\tif (isDynamic) {\n\t\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t\t`${importedSpecifier} is not Script-Module-eligible (no wpScriptModuleExports in its package.json) and can't be dynamically imported from a module-mode entry. ` +\n\t\t\t\t\t\t\t\t`Import it statically (it gets read off its window global) or move it to a script-mode entry.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (rewriteToGlobal(external, importRecord)) codeChanged = true;\n\t\t\t\t} else {\n\t\t\t\t\t// Module mode, Script Module package — leave the bare ESM\n\t\t\t\t\t// specifier for WP's runtime import map.\n\t\t\t\t\tconst importKind = moduleImportKind(importedSpecifier, isDynamic);\n\t\t\t\t\tif (importKind === 'static') {\n\t\t\t\t\t\tstaticDeps.add(external.specifier);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdynamicDeps.add(external.specifier);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (staticDeps.size > 0) recordDeps(staticDepsByModule, id, staticDeps);\n\t\t\tif (dynamicDeps.size > 0) recordDeps(dynamicDepsByModule, id, dynamicDeps);\n\t\t\tif (handleDeps.size > 0) recordDeps(handleDepsByModule, id, handleDeps);\n\n\t\t\tif (!codeChanged) return null;\n\n\t\t\treturn {\n\t\t\t\tcode: magicString.toString(),\n\t\t\t\tmap: magicString.generateMap({ hires: true }),\n\t\t\t};\n\t\t},\n\n\t\tgenerateBundle(_outputOptions, bundle) {\n\t\t\tconst chunksByFileName = new Map<string, Rollup.OutputChunk>();\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type === 'chunk') chunksByFileName.set(fileName, output);\n\t\t\t}\n\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk' || !output.isEntry) continue;\n\t\t\t\tif (!fileName.endsWith('.js') && !fileName.endsWith('.mjs')) continue;\n\n\t\t\t\t// Walk the local chunk graph: code an entry shares with\n\t\t\t\t// another entry (two admin pages both pulling in\n\t\t\t\t// `@wordpress/dataviews`, a shared components module) lands in\n\t\t\t\t// its own chunk, and the dependencies that travelled with it\n\t\t\t\t// still belong in *each* entry's sidecar.\n\t\t\t\tconst reachableChunks: Rollup.OutputChunk[] = [];\n\t\t\t\tconst visited = new Set<string>([fileName]);\n\t\t\t\tconst queue = [fileName];\n\t\t\t\twhile (queue.length > 0) {\n\t\t\t\t\tconst currentFileName = queue.shift()!;\n\t\t\t\t\tconst chunk = chunksByFileName.get(currentFileName);\n\t\t\t\t\tif (!chunk) continue;\n\t\t\t\t\treachableChunks.push(chunk);\n\t\t\t\t\tfor (const imported of [\n\t\t\t\t\t\t...(chunk.imports ?? []),\n\t\t\t\t\t\t...(chunk.dynamicImports ?? []),\n\t\t\t\t\t]) {\n\t\t\t\t\t\t// Names absent from the bundle are externals.\n\t\t\t\t\t\tif (!chunksByFileName.has(imported) || visited.has(imported)) continue;\n\t\t\t\t\t\tvisited.add(imported);\n\t\t\t\t\t\tqueue.push(imported);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst entryHandles = new Set<string>();\n\t\t\t\tconst entryStaticDeps = new Set<string>();\n\t\t\t\tconst entryDynamicDeps = new Set<string>();\n\n\t\t\t\tfor (const chunk of reachableChunks) {\n\t\t\t\t\tfor (const moduleId of Object.keys(chunk.modules ?? {})) {\n\t\t\t\t\t\tconst handles = handleDepsByModule.get(moduleId);\n\t\t\t\t\t\tif (handles) for (const handle of handles) entryHandles.add(handle);\n\t\t\t\t\t\tconst staticDeps = staticDepsByModule.get(moduleId);\n\t\t\t\t\t\tif (staticDeps) for (const dep of staticDeps) entryStaticDeps.add(dep);\n\t\t\t\t\t\tconst dynamicDeps = dynamicDepsByModule.get(moduleId);\n\t\t\t\t\t\tif (dynamicDeps) for (const dep of dynamicDeps) entryDynamicDeps.add(dep);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// The `module`/`script` verdict stays a property of the entry\n\t\t\t\t// itself — a shared chunk must never flip a classic entry.\n\t\t\t\tlet entryMode: 'script' | 'module' = buildType;\n\t\t\t\tfor (const moduleId of Object.keys(output.modules ?? {})) {\n\t\t\t\t\tif (buildModeForFile(moduleId) === 'module') entryMode = 'module';\n\t\t\t\t}\n\n\t\t\t\t// Version hashes the chunk code *plus* every stylesheet Vite\n\t\t\t\t// extracted for it (and for the chunks it reaches), so a\n\t\t\t\t// CSS-only edit busts WP's cache. `viteMetadata` is absent\n\t\t\t\t// under plain Rollup — then it's a code-only hash.\n\t\t\t\tconst hash = crypto.createHash('md5').update(output.code);\n\t\t\t\tconst cssFileNames = new Set<string>();\n\t\t\t\tfor (const chunk of reachableChunks) {\n\t\t\t\t\tfor (const cssFileName of chunk.viteMetadata?.importedCss ?? []) {\n\t\t\t\t\t\tcssFileNames.add(cssFileName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const cssFileName of [...cssFileNames].sort()) {\n\t\t\t\t\tconst cssAsset = bundle[cssFileName];\n\t\t\t\t\tif (!cssAsset || cssAsset.type !== 'asset') continue;\n\t\t\t\t\thash.update(cssAsset.source);\n\t\t\t\t}\n\t\t\t\tconst version = hash.digest('hex').slice(0, 20);\n\n\t\t\t\tconst handles = [...entryHandles].sort();\n\t\t\t\tconst phpList = (items: string[]) =>\n\t\t\t\t\titems.length > 0 ? ` ${items.join(', ')} ` : '';\n\n\t\t\t\t// One id per dependency. Static wins over dynamic: a dep\n\t\t\t\t// imported both ways has to be there up front either way.\n\t\t\t\tconst moduleImportKinds = new Map<string, 'static' | 'dynamic'>();\n\t\t\t\tfor (const dep of entryDynamicDeps) moduleImportKinds.set(dep, 'dynamic');\n\t\t\t\tfor (const dep of entryStaticDeps) moduleImportKinds.set(dep, 'static');\n\t\t\t\tconst sortedModuleDeps = [...moduleImportKinds.entries()].sort(([a], [b]) =>\n\t\t\t\t\ta < b ? -1 : a > b ? 1 : 0,\n\t\t\t\t);\n\n\t\t\t\tconst fields: string[] = [];\n\n\t\t\t\tif (usesWpBuildAssetShape(output.facadeModuleId)) {\n\t\t\t\t\t// `@wordpress/build` shape. `dependencies` carries classic\n\t\t\t\t\t// script handles in both modes — a Script Module reading\n\t\t\t\t\t// `window.wp.components` still needs PHP to enqueue\n\t\t\t\t\t// `wp-components` — and Script Module specifiers get their\n\t\t\t\t\t// own key. Consumed by project PHP (boot admin pages), not\n\t\t\t\t\t// by core's block-metadata registration.\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\t`'dependencies' => array(${phpList(handles.map((handle) => `'${handle}'`))})`,\n\t\t\t\t\t);\n\t\t\t\t\tconst moduleDependencies = sortedModuleDeps.map(\n\t\t\t\t\t\t([dep, kind]) => `array( 'id' => '${dep}', 'import' => '${kind}' )`,\n\t\t\t\t\t);\n\t\t\t\t\tif (moduleDependencies.length > 0) {\n\t\t\t\t\t\tfields.push(\n\t\t\t\t\t\t\t`'module_dependencies' => array(${phpList(moduleDependencies)})`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (entryMode === 'module') {\n\t\t\t\t\t// Core-compatible shape: WordPress reads `dependencies`\n\t\t\t\t\t// as the Script Module dependency list\n\t\t\t\t\t// (`register_block_script_module_id()` hands it straight to\n\t\t\t\t\t// `wp_register_script_module()`), so module specifiers stay\n\t\t\t\t\t// there — static as plain strings, dynamic in WP's\n\t\t\t\t\t// `array( 'id' => …, 'import' => 'dynamic' )` form.\n\t\t\t\t\tconst moduleDependencies = sortedModuleDeps.map(([dep, kind]) =>\n\t\t\t\t\t\tkind === 'static'\n\t\t\t\t\t\t\t? `'${dep}'`\n\t\t\t\t\t\t\t: `array( 'id' => '${dep}', 'import' => 'dynamic' )`,\n\t\t\t\t\t);\n\t\t\t\t\tfields.push(`'dependencies' => array(${phpList(moduleDependencies)})`);\n\t\t\t\t\t// Additive: the classic handles this module reads off\n\t\t\t\t\t// `window.*`. Core ignores unknown keys; project PHP can\n\t\t\t\t\t// enqueue them. Omitted when empty.\n\t\t\t\t\tif (handles.length > 0) {\n\t\t\t\t\t\tfields.push(\n\t\t\t\t\t\t\t`'script_dependencies' => array(${phpList(\n\t\t\t\t\t\t\t\thandles.map((handle) => `'${handle}'`),\n\t\t\t\t\t\t\t)})`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Classic script entry — handles only.\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\t`'dependencies' => array(${phpList(handles.map((handle) => `'${handle}'`))})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tfields.push(`'version' => '${version}'`);\n\t\t\t\tif (entryMode === 'module') fields.push(`'type' => 'module'`);\n\n\t\t\t\t// Additive: project-relative source path, so PHP (a dev-server\n\t\t\t\t// bridge, cache warmers, tooling) can map a built asset back to\n\t\t\t\t// the file that produced it without re-deriving Vite's entry\n\t\t\t\t// naming. Omitted for virtual/synthetic entries and anything\n\t\t\t\t// that resolves outside the project root.\n\t\t\t\tconst sourcePath = entrySourcePath(output.facadeModuleId, resolvedRoot);\n\t\t\t\tif (sourcePath) {\n\t\t\t\t\tfields.push(`'source' => '${phpSingleQuoteEscape(sourcePath)}'`);\n\t\t\t\t}\n\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: 'asset',\n\t\t\t\t\tfileName: fileName.replace(/\\.m?js$/, '.asset.php'),\n\t\t\t\t\tsource: `<?php return array( ${fields.join(', ')} );\\n`,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t};\n\n\t/**\n\t * Force-bundle plugin. `resolve.alias` cannot do this job: the transform\n\t * above matches the *raw specifier text* in the source, so the rewrite to\n\t * `window.wp.*` happens regardless of how the id resolves. Only changing\n\t * the specifier text itself works — hence a `pre` transform (ordered ahead\n\t * of the `post` transform above by `enforce` alone) plus a `pre` resolveId\n\t * that answers the marker id.\n\t *\n\t * `pre` on resolveId is load-bearing under Vite 8 / Rolldown: normal-bucket\n\t * resolveId hooks are never called, because Rolldown's native resolver\n\t * answers first.\n\t */\n\tconst bundlePlugin: Plugin = {\n\t\tname: `wp-externals-bundle(${buildType})`,\n\t\tenforce: 'pre',\n\n\t\ttransform(code, id) {\n\t\t\tif (bundledPackages.size === 0) return null;\n\t\t\t// Virtual modules are ours (or another plugin's) and carry no bare\n\t\t\t// specifiers worth rewriting.\n\t\t\tif (id.startsWith('\\0')) return null;\n\t\t\tconst filePath = (id.split('?')[0] ?? id).replace(/\\\\/g, '/');\n\t\t\t// Deliberately NOT filtered on `/node_modules/`: force-bundled\n\t\t\t// packages are frequently reached only from inside another\n\t\t\t// dependency (`@wordpress/route` is imported solely by\n\t\t\t// `@wordpress/admin-ui/breadcrumbs`), and skipping node_modules\n\t\t\t// would leave exactly those imports externalized.\n\t\t\tconst magicString = new MagicString(code);\n\t\t\tlet codeChanged = false;\n\n\t\t\tfor (const packageName of bundledPackages) {\n\t\t\t\tif (!code.includes(packageName)) continue;\n\t\t\t\t// A package's own files must keep their bare self-references,\n\t\t\t\t// or the marker would resolve the entry back to itself.\n\t\t\t\tif (filePath.includes(`/node_modules/${packageName}/`)) continue;\n\n\t\t\t\t// Anchored to syntactic import position on purpose. A naive\n\t\t\t\t// `replaceAll` on the quoted name corrupts string *data* — an\n\t\t\t\t// unminified `[ '@wordpress/icons', … ]` allow-list inside a\n\t\t\t\t// dependency is real, and rewriting it changes behavior.\n\t\t\t\tconst pattern = new RegExp(\n\t\t\t\t\t`(?:\\\\bfrom|\\\\bimport|\\\\brequire)\\\\s*\\\\(?\\\\s*(['\"])${escapeRegExp(\n\t\t\t\t\t\tpackageName,\n\t\t\t\t\t)}\\\\1`,\n\t\t\t\t\t'g',\n\t\t\t\t);\n\t\t\t\tfor (const match of code.matchAll(pattern)) {\n\t\t\t\t\t// Overwrite just the specifier text between the quotes.\n\t\t\t\t\tconst end = match.index + match[0].length - 1;\n\t\t\t\t\tmagicString.overwrite(\n\t\t\t\t\t\tend - packageName.length,\n\t\t\t\t\t\tend,\n\t\t\t\t\t\tBUNDLED_MARKER_PREFIX + packageName,\n\t\t\t\t\t);\n\t\t\t\t\tcodeChanged = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!codeChanged) return null;\n\t\t\treturn {\n\t\t\t\tcode: magicString.toString(),\n\t\t\t\tmap: magicString.generateMap({ hires: true }),\n\t\t\t};\n\t\t},\n\n\t\tresolveId(source, importer) {\n\t\t\tif (!source.startsWith(BUNDLED_MARKER_PREFIX)) return null;\n\t\t\tconst packageName = source.slice(BUNDLED_MARKER_PREFIX.length);\n\t\t\t// Importer first: a force-bundled package reached from inside a\n\t\t\t// dependency may only exist in that dependency's nested\n\t\t\t// node_modules.\n\t\t\tconst fromPaths = [\n\t\t\t\t...(importer && !importer.startsWith('\\0') ? [importer.split('?')[0]!] : []),\n\t\t\t\tjoin(projectRoot, 'package.json'),\n\t\t\t];\n\t\t\tconst entry = resolvePackageEsmEntry(packageName, fromPaths);\n\t\t\tif (!entry) {\n\t\t\t\treturn this.error(\n\t\t\t\t\t`wp-externals is configured to bundle '${packageName}' (see the \\`bundle\\` option), but the package is not installed` +\n\t\t\t\t\t\t`${importer ? ` — resolved from ${importer} and ` : ' under '}${projectRoot}.\\n` +\n\t\t\t\t\t\t`Force-bundling requires the package in node_modules, since its code has to be compiled into your output. Run \\`npm install ${packageName}\\`.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Rewriting a specifier that CJS code `require()`s makes Rolldown\n\t\t\t// emit a lazy-init wrapper around the module. That's acceptable —\n\t\t\t// unlike the externalized case, no runtime `require` survives.\n\t\t\treturn entry;\n\t\t},\n\t};\n\n\t// Appended, not prepended: `enforce` already guarantees the pre/post\n\t// ordering this needs, and `wp()` spreads the whole array anyway.\n\treturn [resolverPlugin, transformPlugin, bundlePlugin];\n}\n","/**\n * vite-plugin-wp-script-dedupe\n *\n * Restores webpack-style per-entry duplication for script-mode builds.\n *\n * WordPress registers `editorScript`, `viewScript`, admin-page scripts and\n * friends with `wp_register_script()` — a classic `<script>` tag. A classic\n * script may not contain an `import` statement, so every script-mode entry\n * has to be *self-contained*. Rolldown's default is the opposite: any module\n * two entries both import is hoisted into a shared chunk and each entry keeps\n * a live `import { … } from '../chunks/…js'`. Wrapped in an IIFE by\n * `wpScriptIife` that file is a hard `SyntaxError` in the browser\n * (\"Cannot use import statement outside a module\").\n *\n * Neither Rolldown knob fixes it: `output.codeSplitting: false` is rejected\n * outright for multi-input builds, and `output.advancedChunks` only regroups\n * chunks — it cannot duplicate one module into several. webpack (and thus\n * 10up-toolkit) duplicated statically shared modules into every entry chunk,\n * which is exactly what classic scripts need. This plugin does the same, with\n * two mechanisms:\n *\n * 1. **Module-graph partitioning.** A `resolveId` hook tags every resolved id\n * with `?wp-entry=<marker>` inherited from its importer. An untagged\n * importer *is* an entry, so it mints the marker — no entry list needed.\n * Rolldown then sees N distinct ids for one file and inlines a private copy\n * per entry. Externals, `\\0` virtual ids, ids that already carry a query and\n * non-JS files pass through untouched. The hook must answer before every\n * other resolver (`enforce: 'pre'` *and* hook-level `order: 'pre'`, see\n * below), since whoever answers first fixes the id.\n *\n * 2. **Synthetic-chunk inlining.** Rolldown's interop runtime\n * (`\\0rolldown/runtime.js`) and wpExternals' CJS global shims\n * (`\\0wp-external-global:*`) are injected below the resolver, so no\n * taggable hook ever sees them and any two entries needing them still\n * share a chunk. At `generateBundle` those chunks are textually inlined\n * into each consumer as `const { … } = (() => { … return { … } })()` and\n * dropped, iterating to a fixpoint (the CJS `react` shim is itself a chunk\n * that imports the runtime). Only import-free chunks made up entirely of\n * allowlisted synthetic ids are inlined; anything else that survives\n * produces a warning naming the modules, and `wpScriptIife` then fails the\n * build.\n *\n * `wpExternals` builds each `.asset.php` dependency list by walking\n * `chunk.modules` across the chunks an entry reaches, and the shim modules are\n * what carry the `react` / `wp-components` handles. Inlined chunks' `modules`\n * maps are therefore merged into the host chunk — but under Vite 8 that merge\n * is belt-and-braces only (Rolldown hands every plugin a freshly built bundle\n * object and drops `modules` mutations on write-back). What actually keeps the\n * union correct is the `order: 'post'` on this plugin's `generateBundle`: the\n * sidecars are emitted while the shim chunk is still there.\n *\n * Build-only: dev never bundles, and marked ids would break HMR.\n */\nimport crypto from 'node:crypto';\nimport { init, parse } from 'es-module-lexer';\nimport MagicString from 'magic-string';\nimport type { Plugin, Rollup } from 'vite';\n\n/** Query parameter carrying the owning entry's marker. */\nconst MARKER_PARAM = 'wp-entry';\nconst MARKER_RE = new RegExp(`[?&]${MARKER_PARAM}=([^&]*)`);\n\n/**\n * Only real JS/TS source files get partitioned. CSS, assets and everything\n * Vite addresses through its own query conventions (`?raw`, `?url`,\n * `?worker`) keep their ids verbatim — appending a marker there would break\n * the plugin that owns the convention.\n *\n * JSON is deliberately excluded even though it compiles to a JS module: Vite's\n * JSON plugin matches on a bare `.json` id, so `block.json?wp-entry=…` reaches\n * the JS parser as raw JSON (\"Expected a semicolon…\"). A shared JSON module is\n * a byte or two of duplication we forgo, not a correctness problem.\n */\nconst PARTITIONABLE_EXTENSION = /\\.[cm]?[jt]sx?$/;\n\n/**\n * Synthetic module ids safe to inline textually. Both are bundler-injected,\n * import-free helper modules; nothing else may be duplicated blindly.\n */\nconst INLINABLE_SYNTHETIC_ID = [/^\\0?rolldown[:/]runtime(\\.[cm]?js)?$/, /^\\0wp-external-global:/];\n\nfunction markerOf(id: string): string | undefined {\n\treturn id.match(MARKER_RE)?.[1];\n}\n\nfunction withMarker(id: string, marker: string): string {\n\treturn `${id}${id.includes('?') ? '&' : '?'}${MARKER_PARAM}=${marker}`;\n}\n\n/** Drop the marker again so filesystem loads and other plugins see clean ids. */\nfunction stripEntryMarker(id: string): string {\n\treturn id\n\t\t.replace(new RegExp(`([?&])${MARKER_PARAM}=[^&]*&?`), (_match, lead: string) =>\n\t\t\tlead === '?' ? '?' : '&',\n\t\t)\n\t\t.replace(/[?&]$/, '');\n}\n\n/** Stable per-entry marker — same input, same dist, build after build. */\nfunction mintMarker(entryId: string): string {\n\treturn crypto.createHash('sha1').update(entryId).digest('hex').slice(0, 8);\n}\n\nfunction isPartitionable(id: string): boolean {\n\t// `\\0` ids are virtual (Rolldown's runtime, wpExternals' CJS shims, Vite's\n\t// internal proxies); a query means another plugin owns the id's meaning.\n\tif (id.includes('\\0') || id.includes('?')) return false;\n\treturn PARTITIONABLE_EXTENSION.test(id);\n}\n\nfunction isInlinableSyntheticChunk(chunk: Rollup.OutputChunk): boolean {\n\tconst moduleIds = Object.keys(chunk.modules ?? {});\n\tif (moduleIds.length === 0) return false;\n\treturn moduleIds.every((id) => INLINABLE_SYNTHETIC_ID.some((pattern) => pattern.test(id)));\n}\n\n/** Object-literal / destructuring key — quoted so `default` and friends are safe. */\nfunction objectKey(name: string): string {\n\treturn JSON.stringify(name);\n}\n\ninterface ImportClause {\n\t/** `{ a as b }` bindings, exported name → local name. */\n\tnamed: { imported: string; local: string }[];\n\t/** `import * as ns from …` */\n\tnamespace?: string;\n\t/** `import def from …` */\n\tdefault?: string;\n}\n\n/**\n * Parse the binding clause of a static import statement. Returns `null` for\n * shapes we refuse to rewrite (rather than emitting something broken).\n */\nfunction parseImportClause(statement: string): ImportClause | null {\n\tconst match = statement.match(/^\\s*import\\s*(?:([\\s\\S]*?)\\s*from\\s*)?['\"][^'\"]*['\"]\\s*;?\\s*$/);\n\tif (!match) return null;\n\tconst bindings = match[1]?.trim();\n\t// `import \"./chunk.js\";` — side effects only.\n\tif (!bindings) return { named: [] };\n\n\tconst clause: ImportClause = { named: [] };\n\tlet rest = bindings;\n\n\tconst leadingDefault = rest.match(/^([A-Za-z_$][\\w$]*)\\s*(?:,\\s*([\\s\\S]*))?$/);\n\tif (leadingDefault) {\n\t\tclause.default = leadingDefault[1]!;\n\t\trest = leadingDefault[2]?.trim() ?? '';\n\t}\n\n\tif (rest.startsWith('*')) {\n\t\tconst namespace = rest.match(/^\\*\\s*as\\s+([A-Za-z_$][\\w$]*)$/);\n\t\tif (!namespace) return null;\n\t\tclause.namespace = namespace[1]!;\n\t\treturn clause;\n\t}\n\n\tif (rest.startsWith('{')) {\n\t\tif (!rest.endsWith('}')) return null;\n\t\tfor (const binding of rest.slice(1, -1).split(',')) {\n\t\t\tconst trimmed = binding.trim();\n\t\t\tif (!trimmed) continue;\n\t\t\tconst aliased = trimmed.match(/^([A-Za-z_$][\\w$]*)\\s+as\\s+([A-Za-z_$][\\w$]*)$/);\n\t\t\tif (aliased) {\n\t\t\t\tclause.named.push({ imported: aliased[1]!, local: aliased[2]! });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!/^[A-Za-z_$][\\w$]*$/.test(trimmed)) return null;\n\t\t\tclause.named.push({ imported: trimmed, local: trimmed });\n\t\t}\n\t\treturn clause;\n\t}\n\n\treturn rest === '' ? clause : null;\n}\n\n/**\n * Locate the `export { … }` clause by offset, using the lexer's exported-name\n * spans as the anchor.\n *\n * Nothing here may be line-anchored. A minified chunk is a single line, so a\n * `/^export\\s*\\{…\\}$/m` strip silently matches nothing and the whole inlining\n * pass turns into a no-op — visible only in production builds. `ExportSpecifier`\n * carries no statement span (unlike `ImportSpecifier`'s `ss`/`se`), so the\n * clause is derived: back from the first exported name to `{` and the `export`\n * keyword before it, forward from the last name to `}` and an optional `;`.\n * The result is validated as a lone clause, so anything else (two clauses,\n * `export default`, a re-export) returns `null` and leaves the chunk alone.\n */\nfunction exportClauseRange(\n\tcode: string,\n\texports: readonly { s: number; e: number; ls: number; le: number }[],\n): { start: number; end: number } | null {\n\tlet firstName = Number.POSITIVE_INFINITY;\n\tlet lastName = -1;\n\tfor (const record of exports) {\n\t\tfirstName = Math.min(firstName, record.s, record.ls >= 0 ? record.ls : record.s);\n\t\tlastName = Math.max(lastName, record.e, record.le >= 0 ? record.le : record.e);\n\t}\n\tif (lastName < 0) return null;\n\n\tconst brace = code.lastIndexOf('{', firstName);\n\tif (brace < 0) return null;\n\tconst beforeBrace = code.slice(0, brace).trimEnd();\n\tif (!beforeBrace.endsWith('export')) return null;\n\tconst start = beforeBrace.length - 'export'.length;\n\t// `export` has to be its own token — not the tail of `__wpExport`.\n\tif (start > 0 && /[\\w$]/.test(code[start - 1]!)) return null;\n\n\tconst close = code.indexOf('}', lastName);\n\tif (close < 0) return null;\n\tlet end = close + 1;\n\twhile (end < code.length && /\\s/.test(code[end]!)) end += 1;\n\tif (code[end] === ';') end += 1;\n\n\t// One clause and nothing else: a nested `{`/`}` in the slice means the\n\t// derived range swallowed real code between two export statements.\n\tif (!/^export\\s*\\{[^{}]*\\}\\s*;?$/.test(code.slice(start, end))) return null;\n\treturn { start, end };\n}\n\n/**\n * Turn an import-free chunk into a self-executing expression that returns its\n * export map. Returns `null` when the chunk isn't the plain\n * `<body> + export { … }` shape we can safely rewrite.\n */\nfunction toInlineExpression(code: string): string | null {\n\tconst [imports, exports] = parse(code);\n\t// Any import record — static, dynamic, or `import.meta` — means this chunk\n\t// can't become a function body.\n\tif (imports.length > 0) return null;\n\n\tlet body = code;\n\tif (exports.length > 0) {\n\t\tconst range = exportClauseRange(code, exports);\n\t\tif (!range) return null;\n\t\tbody = code.slice(0, range.start) + code.slice(range.end);\n\t}\n\n\t// The lexer is the check, not a regex: a body that still declares module\n\t// syntax after the splice is not safe to wrap.\n\ttry {\n\t\tconst [bodyImports, bodyExports] = parse(body);\n\t\tif (bodyImports.length > 0 || bodyExports.length > 0) return null;\n\t} catch {\n\t\treturn null;\n\t}\n\n\tconst returned = exports\n\t\t.map((record) => `${objectKey(record.n)}: ${record.ln ?? record.n}`)\n\t\t.join(', ');\n\t// The lone `;` on its own line covers both minified bodies (no trailing\n\t// semicolon, ASI) and unminified ones ending in a `//#endregion` comment.\n\treturn `(() => {\\n${body.trim()}\\n;\\nreturn { ${returned} };\\n})()`;\n}\n\n/** Resolve a chunk-relative import specifier back to its bundle file name. */\nfunction resolveChunkSpecifier(hostFileName: string, specifier: string): string {\n\tconst segments = hostFileName.split('/').slice(0, -1);\n\tfor (const segment of specifier.split('/')) {\n\t\tif (segment === '.' || segment === '') continue;\n\t\tif (segment === '..') segments.pop();\n\t\telse segments.push(segment);\n\t}\n\treturn segments.join('/');\n}\n\n/**\n * Shift a chunk's sourcemap by the lines an inline insertion added. The\n * `mappings` field is `;`-separated per generated line, so inserting empty\n * entries after the rewritten line keeps everything below it aligned.\n */\nfunction shiftMappings(\n\tmap: { mappings?: string } | null,\n\tatLine: number,\n\taddedLines: number,\n): void {\n\tif (!map || typeof map.mappings !== 'string' || addedLines <= 0) return;\n\tconst lines = map.mappings.split(';');\n\tif (atLine > lines.length) return;\n\tlines.splice(atLine + 1, 0, ...new Array<string>(addedLines).fill(''));\n\tmap.mappings = lines.join(';');\n}\n\nexport function wpScriptDedupe(): Plugin {\n\t// Keyed on the MARKED importer: keying on the cleaned id lets two entry\n\t// subtrees asking the same (file, specifier) question collide under\n\t// Rolldown's parallel resolution, and the loser comes back unpartitioned\n\t// (non-deterministic output).\n\tconst inFlight = new Set<string>();\n\n\treturn {\n\t\tname: 'wp-script-dedupe',\n\t\t// Mandatory: normal-bucket `resolveId` hooks are never called during a\n\t\t// Vite 8 build — Rolldown's native resolver answers between the `pre`\n\t\t// and normal buckets.\n\t\tenforce: 'pre',\n\t\tapply: 'build',\n\n\t\tresolveId: {\n\t\t\t// `enforce: 'pre'` alone only puts this plugin in the pre bucket —\n\t\t\t// *within* it, array position decides, and any pre-bucket resolver\n\t\t\t// registered earlier answers first and hands back an untagged id.\n\t\t\t// wpExternals' force-bundle resolver is exactly that: it answers\n\t\t\t// `wp-vite-bundled:@wordpress/icons` itself, so the barrel came back\n\t\t\t// unpartitioned and its whole subtree inherited one marker minted\n\t\t\t// from the barrel — identical for every entry, i.e. a shared chunk\n\t\t\t// (issue #23). Hook-level `order: 'pre'` puts this resolver ahead of\n\t\t\t// every other resolveId hook no matter how the plugins are composed;\n\t\t\t// it delegates through `this.resolve`, so those resolvers still\n\t\t\t// decide *what* an id resolves to. This plugin only tags the answer.\n\t\t\torder: 'pre',\n\t\t\tasync handler(source, importer, options) {\n\t\t\t\t// No importer → this is an entry. Entries keep their clean id, and\n\t\t\t\t// being untagged is what makes them mint a marker for their subtree.\n\t\t\t\tif (!importer) return null;\n\t\t\t\tif (source.includes('\\0')) return null;\n\n\t\t\t\tconst key = `${importer}\\n${source}`;\n\t\t\t\tif (inFlight.has(key)) return null;\n\t\t\t\tconst marker = markerOf(importer) ?? mintMarker(importer);\n\n\t\t\t\tinFlight.add(key);\n\t\t\t\tlet resolved: Rollup.ResolvedId | null;\n\t\t\t\ttry {\n\t\t\t\t\tresolved = await this.resolve(\n\t\t\t\t\t\tstripEntryMarker(source),\n\t\t\t\t\t\tstripEntryMarker(importer),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// `kind` rides along so plugins keying on `require-call`\n\t\t\t\t\t\t\t// (wpExternals' CJS shim) still see the truth.\n\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t\tskipSelf: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} finally {\n\t\t\t\t\tinFlight.delete(key);\n\t\t\t\t}\n\n\t\t\t\tif (!resolved || resolved.external) return resolved;\n\t\t\t\tif (!isPartitionable(resolved.id)) return resolved;\n\t\t\t\treturn { ...resolved, id: withMarker(resolved.id, marker) };\n\t\t\t},\n\t\t},\n\n\t\tgenerateBundle: {\n\t\t\t// Load-bearing, not cosmetic: wpExternals emits its `.asset.php`\n\t\t\t// sidecars from `generateBundle`, unioning the dependencies of every\n\t\t\t// chunk an entry reaches — including the synthetic shim chunks this\n\t\t\t// hook inlines and deletes. Rolldown hands each plugin a freshly built\n\t\t\t// `bundle` object and drops `modules` mutations on write-back\n\t\t\t// (`collectChangedBundle` sends `modules: {}`), so the merge below\n\t\t\t// cannot be what keeps that union correct under Vite 8 — running after\n\t\t\t// the sidecars are emitted is.\n\t\t\torder: 'post',\n\t\t\tasync handler(_outputOptions, bundle) {\n\t\t\t\tawait init;\n\n\t\t\t\t// Fixpoint: inlining the runtime into the CJS-shim chunk is what\n\t\t\t\t// makes that shim chunk import-free and inlinable in turn.\n\t\t\t\tlet inlinedSomething = true;\n\t\t\t\twhile (inlinedSomething) {\n\t\t\t\t\tinlinedSomething = false;\n\t\t\t\t\tfor (const [fileName, chunk] of Object.entries(bundle)) {\n\t\t\t\t\t\tif (chunk.type !== 'chunk') continue;\n\t\t\t\t\t\tif (chunk.isEntry || chunk.isDynamicEntry) continue;\n\t\t\t\t\t\tif (!isInlinableSyntheticChunk(chunk)) continue;\n\t\t\t\t\t\tconst expression = toInlineExpression(chunk.code);\n\t\t\t\t\t\tif (!expression) continue;\n\n\t\t\t\t\t\tlet consumers = 0;\n\t\t\t\t\t\tlet failures = 0;\n\t\t\t\t\t\tfor (const [hostFileName, host] of Object.entries(bundle)) {\n\t\t\t\t\t\t\tif (host.type !== 'chunk' || hostFileName === fileName) continue;\n\t\t\t\t\t\t\tif (!(host.imports ?? []).includes(fileName)) continue;\n\t\t\t\t\t\t\tconsumers += 1;\n\t\t\t\t\t\t\tif (!inlineChunkInto(host, hostFileName, fileName, expression)) {\n\t\t\t\t\t\t\t\tfailures += 1;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tabsorbChunkMetadata(host, chunk, fileName);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (consumers > 0 && failures === 0) {\n\t\t\t\t\t\t\tdelete bundle[fileName];\n\t\t\t\t\t\t\tinlinedSomething = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Anything left that another chunk still imports is a shared chunk\n\t\t\t\t// we could not duplicate — name the modules so the failure is\n\t\t\t\t// actionable instead of a browser SyntaxError.\n\t\t\t\tfor (const [fileName, chunk] of Object.entries(bundle)) {\n\t\t\t\t\tif (chunk.type !== 'chunk' || chunk.isEntry || chunk.isDynamicEntry) continue;\n\t\t\t\t\tconst consumers = Object.entries(bundle)\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t([, host]) =>\n\t\t\t\t\t\t\t\thost.type === 'chunk' && (host.imports ?? []).includes(fileName),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map(([hostFileName]) => hostFileName);\n\t\t\t\t\tif (consumers.length === 0) continue;\n\t\t\t\t\tconst moduleIds = Object.keys(chunk.modules ?? {});\n\t\t\t\t\t// A non-JS module (typically a shared `.json`) is the one\n\t\t\t\t\t// cause with a remedy the consumer can apply themselves.\n\t\t\t\t\tconst unpartitionable = moduleIds.filter(\n\t\t\t\t\t\t(id) =>\n\t\t\t\t\t\t\t!id.includes('\\0') && !PARTITIONABLE_EXTENSION.test(id.split('?')[0]!),\n\t\t\t\t\t);\n\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t`wp-script-dedupe: shared chunk ${fileName} could not be duplicated into its consumers (${consumers.join(', ')}). ` +\n\t\t\t\t\t\t\t`It holds: ${moduleIds.join(', ')}. ` +\n\t\t\t\t\t\t\t(unpartitionable.length > 0\n\t\t\t\t\t\t\t\t? `Only JS/TS modules can be partitioned per entry, so a shared non-JS module (${unpartitionable.join(', ')}) stays in a chunk a classic script cannot import. ` +\n\t\t\t\t\t\t\t\t\t`Re-export it from a per-entry .ts module, give each entry its own copy, or build these entries in module mode.`\n\t\t\t\t\t\t\t\t: `A classic script cannot import, so those entries will not load — report the module list above upstream.`),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Fold an inlined chunk's bookkeeping into its host: module maps (so a\n * Rollup-driven pipeline's `chunk.modules` walk still sees the shim modules\n * that carry the `react` / `wp-components` handles), the import edge, and\n * Vite's CSS/asset metadata.\n */\nfunction absorbChunkMetadata(\n\thost: Rollup.OutputChunk,\n\tinlined: Rollup.OutputChunk,\n\tinlinedFileName: string,\n): void {\n\thost.modules = { ...host.modules, ...inlined.modules };\n\thost.moduleIds = [...new Set([...(host.moduleIds ?? []), ...(inlined.moduleIds ?? [])])];\n\thost.imports = (host.imports ?? []).filter((imported) => imported !== inlinedFileName);\n\tconst importedBindings = (host as unknown as { importedBindings?: Record<string, string[]> })\n\t\t.importedBindings;\n\tif (importedBindings) delete importedBindings[inlinedFileName];\n\tmergeViteMetadata(host, inlined);\n}\n\n/** Merge an inlined chunk's Vite metadata so CSS/asset bookkeeping survives. */\nfunction mergeViteMetadata(host: Rollup.OutputChunk, inlined: Rollup.OutputChunk): void {\n\tconst hostMetadata = host.viteMetadata;\n\tconst inlinedMetadata = inlined.viteMetadata;\n\tif (!hostMetadata || !inlinedMetadata) return;\n\tfor (const cssFileName of inlinedMetadata.importedCss ?? []) {\n\t\thostMetadata.importedCss?.add(cssFileName);\n\t}\n\tfor (const assetFileName of inlinedMetadata.importedAssets ?? []) {\n\t\thostMetadata.importedAssets?.add(assetFileName);\n\t}\n}\n\n/**\n * Replace every static import of `targetFileName` in `host` with the inline\n * expression. Returns false when a statement's shape isn't rewritable, in\n * which case the caller keeps the chunk (and the warning path fires).\n */\nfunction inlineChunkInto(\n\thost: Rollup.OutputChunk,\n\thostFileName: string,\n\ttargetFileName: string,\n\texpression: string,\n): boolean {\n\tconst [imports] = parse(host.code);\n\tconst replacements: { start: number; end: number; code: string }[] = [];\n\tlet counter = 0;\n\n\tfor (const record of imports) {\n\t\t// Static imports only — a dynamic `import()` of a synthetic chunk\n\t\t// cannot be inlined (and never happens for these ids).\n\t\tif (record.d !== -1) continue;\n\t\tif (!record.n) continue;\n\t\tif (resolveChunkSpecifier(hostFileName, record.n) !== targetFileName) continue;\n\n\t\tconst clause = parseImportClause(host.code.slice(record.ss, record.se));\n\t\tif (!clause) return false;\n\n\t\tconst named = clause.named\n\t\t\t.map(({ imported, local }) => `${objectKey(imported)}: ${local}`)\n\t\t\t.join(', ');\n\t\tlet code: string;\n\t\tif (clause.default || (clause.namespace && clause.named.length > 0)) {\n\t\t\tconst temp = `__wpInlined${counter++}`;\n\t\t\tconst parts = [`const ${temp} = ${expression};`];\n\t\t\tif (clause.default) parts.push(`const ${clause.default} = ${temp}[\"default\"];`);\n\t\t\tif (clause.namespace) parts.push(`const ${clause.namespace} = ${temp};`);\n\t\t\tif (named) parts.push(`const { ${named} } = ${temp};`);\n\t\t\tcode = parts.join('\\n');\n\t\t} else if (clause.namespace) {\n\t\t\tcode = `const ${clause.namespace} = ${expression};`;\n\t\t} else if (named) {\n\t\t\tcode = `const { ${named} } = ${expression};`;\n\t\t} else {\n\t\t\tcode = `${expression};`;\n\t\t}\n\t\treplacements.push({ start: record.ss, end: record.se, code });\n\t}\n\n\tif (replacements.length === 0) return false;\n\n\tconst magicString = new MagicString(host.code);\n\t// Last-to-first so each sourcemap shift is computed against line numbers\n\t// that haven't moved yet.\n\tfor (const replacement of replacements.reverse()) {\n\t\tmagicString.overwrite(replacement.start, replacement.end, replacement.code);\n\t\tconst line = host.code.slice(0, replacement.start).split('\\n').length - 1;\n\t\tconst addedLines =\n\t\t\treplacement.code.split('\\n').length -\n\t\t\thost.code.slice(replacement.start, replacement.end).split('\\n').length;\n\t\tshiftMappings(host.map as { mappings?: string } | null, line, addedLines);\n\t}\n\thost.code = magicString.toString();\n\treturn true;\n}\n","/**\n * vite-plugin-wp-script-iife\n *\n * Wraps each script-mode entry chunk in an IIFE post-write — esbuild/oxc's\n * minifier would otherwise inline a plain intro/outro IIFE for var-heavy\n * bodies, defeating the global-scope isolation needed when WP enqueues\n * these as classic <script> tags.\n *\n * It is also the gate that guarantees the output *is* a valid classic script:\n * every chunk is parsed before it's wrapped, and one that doesn't compile fails\n * the build instead of shipping a file the browser cannot load. The two causes\n * worth diagnosing by name are a live `import`/`export` statement (a shared\n * chunk Rolldown refused to duplicate) and an `import.meta` reference (Vite's\n * dynamic-import preload helper). The `import.meta` members that helper touches\n * are rewritten to classic-script-safe expressions through an injected\n * `define`, so the failure only fires for cases the define can't reach.\n *\n * Only run this in script mode. Module-mode entries (`wp_register_script_module`)\n * must stay as bare ESM for WP's import map to resolve them at runtime.\n */\nimport type { Plugin, UserConfig } from 'vite';\n\n/**\n * `import.meta` is a hard SyntaxError in a classic script, and Vite injects\n * its module-preload helper (which reads `import.meta.url`) whenever the\n * bundled graph contains a dynamic `import()` — `build.modulePreload: false`\n * does not stop that, it only controls link-preload emission. Replacing the\n * members at build time is the only thing that keeps such an entry loadable.\n */\nconst CLASSIC_SCRIPT_DEFINE: Record<string, string> = {\n\t'import.meta.url': 'document.currentScript && document.currentScript.src',\n\t'import.meta.resolve': 'undefined',\n};\n\n/**\n * Match a top-level `import`/`export` *statement* that survived stripping.\n * Deliberately narrow: `import(` / `import.meta` are expressions, and an\n * object property named `export:` starts a line often enough in unminified\n * chunk bodies that `/^export\\b/` alone would cry wolf.\n */\nconst LIVE_MODULE_STATEMENT =\n\t/^[ \\t]*(?:import\\s*(?:[{*\"']|[A-Za-z_$][\\w$]*\\s*(?:,|from\\b))|export\\s*(?:[{*]|(?:default|const|let|var|function|class|async)\\b))[^\\n]*/m;\n\n/**\n * Rolldown's runtime `require` shim, matched on its *shape* rather than on the\n * docs URL in its error message. The generated code is\n * `(e=>typeof require<\"u\"?require:e)(function(e){throw Error(…)})` — the\n * `typeof require` guard is the load-bearing part (it's what makes an in-scope\n * `require` win), and unlike the URL it can't change without changing what the\n * shim does. Keying on the URL failed in both directions: a docs-path rename\n * would silently stop the shim from being injected, and user code that merely\n * mentions the URL in a string or comment would get a `require` it never needed.\n */\nconst ROLLDOWN_REQUIRE_SHIM = /typeof\\s+require\\s*(?:<|!==?|===?)/;\n\n/** A surviving `require(…)` call, used only to warn when the shim is missing. */\nconst REQUIRE_CALL = /(?:^|[^.\\w$])require\\s*\\(/;\n\n/**\n * Rolldown resolves `require()` of an external in a CJS dep at *runtime*, via\n * a shim that throws unless a `require` is in scope (that shim prefers a real\n * one when it finds it — esbuild-style). The import rewrite never sees those,\n * so map them here instead. `use-sync-external-store` reaching `require(\"react\")`\n * through @headlessui/react is the case that surfaced this.\n */\nfunction buildRequireShim(globals: Map<string, string>): string {\n\tconst cases = [...globals.entries()]\n\t\t.map(([specifier, global]) => `case ${JSON.stringify(specifier)}:return window.${global};`)\n\t\t.join('');\n\n\treturn (\n\t\t`const require=(id)=>{switch(id){${cases}}` +\n\t\t`throw new Error('require(\"'+id+'\") is not mapped to a global in this classic script.');};`\n\t);\n}\n\nexport interface WpScriptIifeOptions {\n\t/**\n\t * Specifier → window global, used to shim `require()` for CJS dependencies\n\t * whose `require` Rolldown resolves at runtime rather than through\n\t * `wpExternals`' import rewrite.\n\t *\n\t * `wp()` passes `wpExternals`' `globalsSink` automatically.\n\t */\n\tglobals?: Map<string, string>;\n}\n\nexport function wpScriptIife(options: WpScriptIifeOptions = {}): Plugin {\n\tconst globals = options.globals ?? new Map<string, string>();\n\n\treturn {\n\t\tname: 'wp-script-iife',\n\t\t// Build-only. Vite filters plugins by `apply` before it runs `config`,\n\t\t// which is what keeps the `import.meta` define below out of `vite serve`\n\t\t// — the dev server ships real ESM to the browser, where `import.meta.url`\n\t\t// is both legal and load-bearing.\n\t\tapply: 'build',\n\n\t\tconfig(userConfig: UserConfig) {\n\t\t\t// User-supplied values win: someone may have a better answer for\n\t\t\t// their runtime than `document.currentScript`.\n\t\t\tconst define: Record<string, string> = {};\n\t\t\tfor (const [key, value] of Object.entries(CLASSIC_SCRIPT_DEFINE)) {\n\t\t\t\tif (userConfig.define && key in userConfig.define) continue;\n\t\t\t\tdefine[key] = value;\n\t\t\t}\n\t\t\treturn Object.keys(define).length > 0 ? { define } : null;\n\t\t},\n\n\t\tasync writeBundle(options, bundle) {\n\t\t\tconst { readFile, writeFile } = await import('node:fs/promises');\n\t\t\tconst { join } = await import('node:path');\n\t\t\tconst outDir = options.dir ?? '.';\n\n\t\t\t// Validate every chunk before writing any of them. Erroring mid-loop\n\t\t\t// would leave dist/ half-processed — chunks 1..N-1 wrapped, chunk N\n\t\t\t// raw ESM, the rest untouched — and a watch-mode iteration against\n\t\t\t// that directory loads a build that never existed as a whole.\n\t\t\tconst pending: { filePath: string; body: string }[] = [];\n\t\t\tconst failures: string[] = [];\n\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk') continue;\n\t\t\t\tif (!fileName.endsWith('.js') && !fileName.endsWith('.mjs')) continue;\n\t\t\t\tif (!output.isEntry && !output.isDynamicEntry) continue;\n\t\t\t\tconst filePath = join(outDir, fileName);\n\t\t\t\tlet chunkSource = await readFile(filePath, 'utf8');\n\t\t\t\t// `\\s*`, not `\\s+`: minified output writes `import\"react\";`.\n\t\t\t\tconst sideEffectImport = /^\\s*import\\s*[\"'][^\"']+[\"'];?\\s*\\n?/;\n\t\t\t\twhile (sideEffectImport.test(chunkSource)) {\n\t\t\t\t\tchunkSource = chunkSource.replace(sideEffectImport, '');\n\t\t\t\t}\n\n\t\t\t\t// A live import/export or `import.meta` reference would make the\n\t\t\t\t// whole IIFE unparseable in the browser.\n\t\t\t\tconst failure = classicScriptFailure(\n\t\t\t\t\tfileName,\n\t\t\t\t\tchunkSource,\n\t\t\t\t\toutput.isEntry !== true,\n\t\t\t\t);\n\t\t\t\tif (failure) {\n\t\t\t\t\tfailures.push(failure);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Only when Rolldown actually emitted its require shim — defining\n\t\t\t\t// a bare `require` otherwise can flip UMD deps onto their CJS path.\n\t\t\t\tif (ROLLDOWN_REQUIRE_SHIM.test(chunkSource)) {\n\t\t\t\t\t// Nested, not concatenated: a dependency with its own\n\t\t\t\t\t// top-level `var require` (browserify-style preludes, UMD\n\t\t\t\t\t// files Rolldown didn't rename) would collide at the same\n\t\t\t\t\t// scope — `Identifier 'require' has already been declared`.\n\t\t\t\t\t// An inner IIFE shadows it instead, which is also what a\n\t\t\t\t\t// module scope would have done.\n\t\t\t\t\tpending.push({\n\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\tbody: `${buildRequireShim(globals)}(()=>{\\n${chunkSource}\\n})();`,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (globals.size > 0 && REQUIRE_CALL.test(chunkSource)) {\n\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t`${fileName} calls \\`require()\\` but carries none of Rolldown's runtime require shim, so no global mapping was injected. ` +\n\t\t\t\t\t\t\t`If this is a CJS dependency reaching for an external, it will throw at runtime — please report it, as the shim's shape may have changed.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tpending.push({ filePath, body: chunkSource });\n\t\t\t}\n\n\t\t\tif (failures.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`wp-script-iife: ${failures.length} chunk(s) are not valid as classic scripts, so nothing was wrapped:\\n\\n${failures.join('\\n\\n')}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfor (const { filePath, body } of pending) {\n\t\t\t\tawait writeFile(filePath, `(()=>{\\n${body}\\n})();\\n`);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Diagnose a chunk that isn't valid as a classic script, returning the message\n * to report — or `null` when the chunk is fine. Reporting is left to the\n * caller, which collects every offender and fails once, so a bad chunk never\n * leaves dist/ partly rewritten.\n *\n * The parser is the ground truth, not the regexes: `new Function(code)` compiles\n * the body under the same rules a classic `<script>` applies to the things we\n * care about (a top-level `import`/`export` statement and `import.meta` are all\n * SyntaxErrors inside a function body), so a chunk that merely *mentions*\n * `import.meta` in a string — feature detection, an error message — can never\n * fail the build. The regexes only run afterwards, to turn the parse error into\n * a diagnosis worth reading. Anything the regexes don't explain still fails,\n * with the parser's own message: that's how we catch classic-script syntax\n * errors we didn't anticipate.\n *\n * Two constructs differ between a function body and a script top level:\n * top-level `await` (legal in a module, SyntaxError here) and `return` (legal\n * here, SyntaxError in a script). Neither appears in valid Rolldown script-mode\n * output — and this code is about to be wrapped in an IIFE anyway, which gives\n * it exactly a function body's rules.\n */\nfunction classicScriptFailure(\n\tfileName: string,\n\tcode: string,\n\tisDynamicOnly = false,\n): string | null {\n\tlet parseError: unknown;\n\ttry {\n\t\tnew Function(code);\n\t\treturn null;\n\t} catch (error) {\n\t\tif (!(error instanceof SyntaxError)) throw error;\n\t\tparseError = error;\n\t}\n\n\tconst liveStatement = code.match(LIVE_MODULE_STATEMENT);\n\tif (liveStatement) {\n\t\tconst specifiers = [...code.matchAll(/^[ \\t]*(?:import|export)\\b[^\\n]*?[\"']([^\"']+)[\"']/gm)]\n\t\t\t.map((match) => match[1]!)\n\t\t\t.filter((specifier, index, all) => all.indexOf(specifier) === index);\n\t\treturn (\n\t\t\t`wp-script-iife: ${fileName} still contains a top-level module statement, which is a SyntaxError once WordPress enqueues it as a classic script:\\n` +\n\t\t\t` ${liveStatement[0].trim()}\\n` +\n\t\t\t(specifiers.length > 0 ? ` Imported chunk(s): ${specifiers.join(', ')}\\n` : '') +\n\t\t\t(isDynamicOnly\n\t\t\t\t? ` This file is a dynamic-import chunk, so it needs its \\`export\\`s and cannot be an IIFE. A script-mode entry can't lazily load one either (WP has no module context to resolve it in) — drop the dynamic \\`import()\\`, or build this entry in module mode.`\n\t\t\t\t: ` This is almost always a shared chunk: a module two or more script-mode entries import gets hoisted into its own chunk instead of being duplicated into each entry. ` +\n\t\t\t\t\t`Add the wpScriptDedupe() plugin (auto-included by wp() in script mode — check you haven't set \\`scriptDedupe: false\\`), or build this entry in module mode.\\n` +\n\t\t\t\t\t` If the specifier above is a bare \\`@wordpress/*\\` package rather than a relative chunk path, this is instead a module-only package (no \\`wpScript\\` in its package.json) imported into a script-mode entry — wpExternals warns about it by name earlier in the build. Move that import to a viewScriptModule entry, or build this entry in module mode.`)\n\t\t);\n\t}\n\n\tif (/\\bimport\\.meta\\b/.test(code)) {\n\t\treturn (\n\t\t\t`wp-script-iife: ${fileName} references \\`import.meta\\`, which is a SyntaxError once WordPress enqueues it as a classic script.\\n` +\n\t\t\t` Vite injects its module-preload helper (which reads \\`import.meta.url\\`) whenever the bundled graph contains a dynamic \\`import()\\` — \\`build.modulePreload: false\\` does not remove it. ` +\n\t\t\t`This plugin's \\`config()\\` hook defines \\`import.meta.url\\`/\\`import.meta.resolve\\` away; a surviving reference means either that define was overridden, or the code touches another \\`import.meta\\` member. ` +\n\t\t\t`Extend \\`define\\` in your Vite config, or move this entry to module mode.`\n\t\t);\n\t}\n\n\treturn (\n\t\t`wp-script-iife: ${fileName} does not parse as a classic script, so WordPress could not load it:\\n` +\n\t\t` ${(parseError as SyntaxError).message}\\n` +\n\t\t` Nothing in this plugin's usual suspects (a shared chunk's \\`import\\`, an \\`import.meta\\` reference) explains it — inspect the written file, and report it upstream if the source is valid.`\n\t);\n}\n","/**\n * vite-plugin-wp-clean-css-chunks\n *\n * Deletes the empty `.js` shim Vite leaves next to a CSS-only entry.\n *\n * Vite's Rollup-driven model treats every entry as a JS module that may\n * pull in CSS via side-effect imports. For an entry whose source IS a CSS\n * file (e.g. each per-block stylesheet produced by wpBlockStyles), Vite\n * still emits a tiny empty `.js` chunk that just imports the `.css`.\n * Useless for WP enqueueing.\n */\nimport type { Plugin } from 'vite';\n\nexport function wpCleanCssChunks(): Plugin {\n\treturn {\n\t\tname: 'wp-clean-css-chunks',\n\t\tgenerateBundle(_options, bundle) {\n\t\t\tfor (const [fileName, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== 'chunk') continue;\n\t\t\t\tconst facadeModuleId = output.facadeModuleId ?? '';\n\t\t\t\tif (/\\.(s?css|sass)$/.test(facadeModuleId)) {\n\t\t\t\t\tdelete bundle[fileName];\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * vite-plugin-wp-css-asset-info\n *\n * Emits a `<name>.asset.php` sidecar for CSS-only entries — a stylesheet\n * declared directly in `build.rollupOptions.input` with no JS twin.\n *\n * 10up-toolkit (webpack) emitted a sidecar for every entry, JS or CSS, and\n * `TenupFramework\\Assets\\GetAssetInfo::get_asset_info()` reads it for the\n * cache-busting `version` PHP passes to `wp_enqueue_style()`. Rolldown emits\n * no JS chunk for a stylesheet entry (there's no code to bundle), so\n * `wpExternals`' chunk walk — which builds sidecars from `chunk.modules` —\n * never sees anything to write one for. Without this plugin, every CSS-only\n * enqueue migrated from toolkit silently falls back to a hardcoded version:\n * the build succeeds, nothing warns, and cache-busting just stops working.\n */\nimport crypto from 'node:crypto';\nimport { realpathSync } from 'node:fs';\nimport { isAbsolute, relative, resolve } from 'node:path';\nimport type { Plugin, Rollup } from 'vite';\n\n/** Extensions treated as \"this entry's source IS a stylesheet\". */\nconst STYLESHEET_EXTENSION = /\\.(css|scss|sass)$/i;\n\n/**\n * Resolve symlinks when the path exists on disk; otherwise return it\n * unchanged. Vite resolves `config.root` through `fs.realpath` internally\n * (macOS resolves its `/tmp` through a `/var` -> `/private/var` symlink, so\n * this bites every temp-dir-based fixture), while `rollupOptions.input`\n * values pass through untouched — comparing one against the other without\n * normalizing both would make `entrySourcePath()` see two different\n * filesystem paths and wrongly conclude the source lives outside `root`.\n */\nfunction tryRealpath(path: string): string {\n\ttry {\n\t\treturn realpathSync(path);\n\t} catch {\n\t\treturn path;\n\t}\n}\n\n/**\n * Project-relative, posix-separated source path for a CSS entry's\n * `.asset.php` `source` field. Returns `null` — the field is omitted rather\n * than emitting a nonsensical value — when the entry's source resolves\n * outside `root`.\n *\n * Mirrors `wp-externals.ts`' `entrySourcePath()`: same shape, same omission\n * rule, kept as a sibling copy rather than a shared import so each plugin\n * stays independently readable (this repo's modules are flat, not layered).\n */\nfunction entrySourcePath(sourcePath: string, root: string): string | null {\n\tconst relativePath = relative(tryRealpath(root), tryRealpath(sourcePath)).replace(/\\\\/g, '/');\n\tif (relativePath === '' || relativePath === '..' || relativePath.startsWith('../')) {\n\t\treturn null;\n\t}\n\tif (isAbsolute(relativePath)) return null;\n\treturn relativePath;\n}\n\n/** Escape a string for embedding in a single-quoted PHP string literal. */\nfunction phpSingleQuoteEscape(value: string): string {\n\treturn value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\nexport function wpCssAssetInfo(): Plugin {\n\t// entryName -> absolute source path, populated in configResolved so\n\t// generateBundle doesn't need to re-derive entry identity from the bundle.\n\tconst cssEntries = new Map<string, string>();\n\tlet resolvedRoot = process.cwd();\n\n\treturn {\n\t\tname: 'wp-css-asset-info',\n\n\t\tconfigResolved(config) {\n\t\t\tcssEntries.clear();\n\t\t\tresolvedRoot = config.root;\n\t\t\tconst input = config.build?.rollupOptions?.input;\n\t\t\t// Object input is the shape every entry in this project (and\n\t\t\t// wpBlockStyles' autoenqueue entries) uses — a name -> source map.\n\t\t\t// String/array inputs don't carry an explicit entry name to key a\n\t\t\t// sidecar off of, so they're left alone rather than guessed at.\n\t\t\tif (!input || typeof input !== 'object' || Array.isArray(input)) return;\n\n\t\t\tfor (const [entryName, source] of Object.entries(input as Record<string, unknown>)) {\n\t\t\t\tif (typeof source === 'string' && STYLESHEET_EXTENSION.test(source)) {\n\t\t\t\t\t// Resolved against `root` here so `entrySourcePath()` sees an\n\t\t\t\t\t// absolute path regardless of whether the config declared\n\t\t\t\t\t// this entry relatively or absolutely — `rollupOptions.input`\n\t\t\t\t\t// allows either.\n\t\t\t\t\tcssEntries.set(entryName, resolve(config.root, source));\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tgenerateBundle: {\n\t\t\t// MUST be post: wpBlockStyles strips its dedup markers from CSS\n\t\t\t// assets in its own normal-order generateBundle, and the version has\n\t\t\t// to hash the FINAL shipped bytes, not the pre-strip content.\n\t\t\torder: 'post',\n\t\t\thandler(_outputOptions, bundle) {\n\t\t\t\tfor (const [entryName, sourcePath] of cssEntries) {\n\t\t\t\t\tconst expectedFileName = `${entryName}.css`;\n\t\t\t\t\tconst cssAsset = findCssAsset(bundle, expectedFileName, sourcePath);\n\t\t\t\t\tif (!cssAsset) continue;\n\n\t\t\t\t\tconst assetPhpFileName = cssAsset.fileName.replace(/\\.css$/i, '.asset.php');\n\t\t\t\t\tif (bundle[assetPhpFileName]) continue; // already emitted (by us, or another plugin)\n\n\t\t\t\t\tconst version = crypto.createHash('md5').update(cssAsset.source).digest('hex');\n\n\t\t\t\t\tconst fields = [`'dependencies' => array()`, `'version' => '${version}'`];\n\t\t\t\t\tconst source = entrySourcePath(sourcePath, resolvedRoot);\n\t\t\t\t\tif (source) fields.push(`'source' => '${phpSingleQuoteEscape(source)}'`);\n\n\t\t\t\t\tthis.emitFile({\n\t\t\t\t\t\ttype: 'asset',\n\t\t\t\t\t\tfileName: assetPhpFileName,\n\t\t\t\t\t\tsource: `<?php return array( ${fields.join(', ')} );\\n`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Find the CSS asset an entry produced. `assetFileNames: '[name][extname]'`\n * (the common WP setup) makes the bundle key match `<entryName>.css`\n * directly; a different pattern (default Vite hashed names, a nested output\n * dir) loses that, so `names` — which Vite/Rolldown populates from the entry\n * name regardless of the actual emitted path — is the robust fallback.\n * `originalFileNames` (the source path, root-relative) is checked too for\n * setups where neither of the above lines up.\n */\nfunction findCssAsset(\n\tbundle: Rollup.OutputBundle,\n\texpectedFileName: string,\n\tsourcePath: string,\n): Rollup.OutputAsset | undefined {\n\tconst direct = bundle[expectedFileName];\n\tif (direct && direct.type === 'asset') return direct;\n\n\tfor (const output of Object.values(bundle)) {\n\t\tif (output.type !== 'asset') continue;\n\t\tif (output.names?.includes(expectedFileName)) return output;\n\t\tif (output.originalFileNames?.some((name) => sourcePath.endsWith(name))) return output;\n\t}\n\treturn undefined;\n}\n","/**\n * vite-plugin-wp-dev-server\n *\n * The serve-mode half of the WordPress story. Everything else in this package\n * builds files; this plugin makes a *running* Vite dev server usable from PHP.\n *\n * WordPress never asks a bundler for a URL — it enqueues whatever\n * `wp_register_script()` was handed at registration time, from PHP, on a\n * request that has no idea a dev server exists. So the bridge has to be a\n * file on disk that PHP can `is_file()` and read. That is the prior art every\n * PHP framework converged on (Laravel's `public/hot`, vite-for-wp's dev\n * manifest), and it is what this plugin writes:\n *\n * <outDir>/.wp-vite-dev.json { origin, base, plugins }\n *\n * Present ⇒ the server is up and PHP should point assets at `origin`.\n * Absent ⇒ business as usual, serve the built files. Nothing else to check,\n * no port probing on the request path.\n *\n * Alongside it the plugin writes the three things PHP reads that normally\n * only a build produces:\n *\n * 1. `<entry>.asset.php` sidecars, so `get_asset_info()`-style helpers and\n * the generated `dev-server.php` bridge find the same keys they find\n * after a build — including the `source` key that maps a dist asset back\n * to the file the dev server serves it from.\n * 2. the transformed `block.json` / sibling `*.php` / `blocks-manifest.php`\n * tree, because `register_block_type()` reads metadata off disk whether\n * or not a bundler is running.\n * 3. `dev-server.php`, the generated bridge that reads all of the above and\n * repoints WordPress's enqueues at `origin`. Every *build* emits it too\n * (`wpDevServerPhp`, at the bottom of this file) so the consumer's\n * `require_once` is never a dead path; both halves render it from the one\n * template in `php-templates.ts`.\n * 4. nothing else. Dev never emits JS or CSS into `outDir` — that is the\n * whole point; the browser fetches those from `origin`.\n *\n * **Why `node:fs` and not `this.emitFile`.** `emitFile` is a Rollup *build*\n * hook facility: in serve mode there is no bundle, no `generateBundle`, and\n * nothing writes to `outDir` at all. Every filesystem write in this package\n * that isn't part of a bundle lives in this file, deliberately, so the blast\n * radius of \"the dev server touches the user's dist/\" is one module.\n *\n * **Why the bare specifiers survive.** A Script Module entry must keep\n * `import { store } from '@wordpress/interactivity'` verbatim — WordPress's\n * runtime import map resolves it in the browser, and there is nothing on the\n * dev server to resolve it to. Vite's dev import-analysis disagrees: an id a\n * `resolveId` hook marks `external: true` is rewritten to `/@id/<id>` (see\n * `normalizeResolvedIdToUrl` in Vite 8's dev pipeline — a bare id always gets\n * `wrapId()`-prefixed), and an unresolvable one is a hard 500. Neither\n * `resolve.external` nor `optimizeDeps.exclude` changes that for the client\n * environment, and `vite:import-analysis` is the *last* plugin in the dev\n * chain, so no `enforce: 'post'` transform can undo it. The one seam left is\n * the environment's own `transformRequest`, which is public API on\n * `DevEnvironment` — this plugin decorates it and unwraps `/@id/<specifier>`\n * back to `<specifier>` for exactly the specifiers `resolveExternal()`\n * recognizes. See `installBareSpecifierEscape` below.\n */\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { isAbsolute, dirname, extname, join, relative, resolve } from 'node:path';\nimport type { AddressInfo } from 'node:net';\nimport fg from 'fast-glob';\nimport { init, parse } from 'es-module-lexer';\nimport type { Plugin, ResolvedConfig, ViteDevServer } from 'vite';\nimport { buildBlocksManifest, discoverEntries, transformBlockJson } from './wp-blocks';\nimport { discoverPages } from './wp-admin-pages';\nimport { resolveExternal, type ResolveExternalOptions } from './wp-externals';\nimport { isValidPhpIdentifier, renderDevServerPhp } from './php-templates';\n\n/**\n * Name of the hot file, relative to the resolved `build.outDir`.\n *\n * Exported because the generated PHP bridge has to spell the same name, and a\n * drifting constant here is a silently dead dev server there.\n */\nexport const HOT_FILE_NAME = '.wp-vite-dev.json';\n\n/**\n * Name of the generated PHP bridge, relative to the resolved `build.outDir`.\n *\n * Written by *both* halves of this module: `wpDevServerPhp` emits it into every\n * build so a consumer's `require_once` is never a dead path, and `wpDevServer`\n * writes the identical bytes on server start so a `dist/` that has never been\n * built still bridges.\n */\nexport const DEV_SERVER_PHP_NAME = 'dev-server.php';\n\n/** Fallback identifier prefix when the project's package.json yields nothing usable. */\nconst DEFAULT_PHP_PREFIX = 'wp-vite';\n\n/**\n * Plugin names worth telling PHP about. The hot file's `plugins` array is not\n * an inventory — it is a list of things the PHP side has to *do something\n * about*. Today that is exactly one: `@vitejs/plugin-react`'s refresh\n * runtime, whose preamble must be printed before any component module\n * evaluates or every transformed module throws.\n */\nconst REPORTED_PLUGINS = ['vite:react-refresh'];\n\n/** Extensions probed when resolving a relative import during the dep scan. */\nconst SCAN_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'] as const;\n\n/** Entry sources that are stylesheets, not JavaScript — never lexed. */\nconst STYLESHEET_EXTENSION = /\\.(css|scss|sass)$/i;\n\n/** Sources whose JSX the transform pipeline compiles into a runtime import. */\nconst JSX_SOURCE_EXTENSION = /\\.[jt]sx$/i;\n\n/**\n * The import the automatic JSX runtime injects. Vite's serve default is the\n * *dev* runtime, but `wpDevServer`'s `config()` hook turns that off — see the\n * note there — so this is the specifier the transform actually emits.\n */\nconst JSX_RUNTIME_SPECIFIER = 'react/jsx-runtime';\n\n/** How deep the static import walk follows local files before giving up. */\nconst DEFAULT_MAX_SCAN_DEPTH = 24;\n\n/**\n * How long a burst of watcher events is allowed to settle before the entry set\n * is rediscovered. Creating a block is three or four events in a row\n * (`block.json`, `index.tsx`, `render.php`, `style.css`), and re-globbing the\n * tree plus rescanning every entry once per event is pure waste.\n */\nconst REDISCOVER_DEBOUNCE_MS = 50;\n\nexport interface WpDevServerOptions {\n\t/** Blocks directory — same value `wpBlocks` gets. Enables block discovery. */\n\tblocksDir?: string;\n\t/** Per-block stylesheet directory — same value `wpBlockStyles` gets. */\n\tblocksStylesDir?: string;\n\t/** Admin pages directory — same value `wpAdminPages` gets. */\n\tadminPagesDir?: string;\n\t/** Block directory names to skip, mirroring `wpBlocks`' `skip`. */\n\tskip?: string[];\n\t/**\n\t * The mode this server's config maps to — the same `buildType` the build\n\t * plugins get. Only the entries declared in `build.rollupOptions.input`\n\t * need it; blocks and admin pages carry their own verdict from discovery.\n\t * Default: `'script'`, which is what a dual-pass consumer's serve-mode\n\t * config resolves to.\n\t */\n\tbuildType?: 'script' | 'module';\n\t/** Write `blocks-manifest.php` into `outDir`. Default: `true`. */\n\temitManifest?: boolean;\n\t/**\n\t * Root used to resolve `@wordpress/*` package.jsons during the dependency\n\t * scan. Must match `wpExternals`' `projectRoot` or the two disagree about\n\t * what is external. Defaults to `process.cwd()`.\n\t */\n\tprojectRoot?: string;\n\t/**\n\t * The rest of `wpExternals`' externalization config, so the dev scan\n\t * reaches the same verdicts the build does. `wp()` forwards these.\n\t */\n\texternalNamespaces?: ResolveExternalOptions['externalNamespaces'];\n\tadditionalExternals?: ResolveExternalOptions['vendorExternals'];\n\tscriptModuleNamespaces?: string[];\n\tbundledPackages?: string[];\n\t/**\n\t * Live array shared with `wpExternals`' `moduleEntryMatchers`. The plugin\n\t * *pushes* every discovered module-pass entry path into it during\n\t * `configResolved`, which is what makes one dev server serve both passes\n\t * correctly — see the note on `syncModuleEntryMatchers()`.\n\t */\n\tmoduleEntryMatchers?: string[];\n\t/**\n\t * Entry source paths whose sidecar uses the `@wordpress/build` shape,\n\t * mirroring `wpExternals`' option of the same name. `wp()` wires\n\t * `adminPagesDir` in automatically.\n\t */\n\twpBuildAssetMatchers?: string[];\n\t/** Depth limit for the static import walk. Default: 24. */\n\tmaxScanDepth?: number;\n\t/**\n\t * Identifier prefix for `dev-server.php`'s functions and script handles.\n\t * Defaults to `wpPlugin.name`, else the de-scoped `name`, from the\n\t * package.json at Vite's `root` — else `'wp-vite'`.\n\t */\n\tphpPrefix?: string;\n}\n\n/** `wpDevServerPhp`'s options — the build-side half of the bridge. */\nexport interface WpDevServerPhpOptions {\n\t/** Identifier prefix. Same default as `wpDevServer`'s option of the same name. */\n\tphpPrefix?: string;\n\t/** Root whose package.json supplies the prefix default. Defaults to Vite's `root`. */\n\tprojectRoot?: string;\n}\n\n/** What the hot file contains. Consumed by the generated PHP bridge. */\nexport interface WpDevServerHotFile {\n\t/** Scheme + host + port the browser should fetch assets from. No trailing slash. */\n\torigin: string;\n\t/** Vite's `base`, with its leading and trailing slash intact (`/` by default). */\n\tbase: string;\n\t/** Names of the plugins in the resolved config that PHP has to react to. */\n\tplugins: string[];\n}\n\n/** One thing the dev server has to write an `.asset.php` for. */\nexport interface DevEntry {\n\t/** Output-relative name without extension — `blocks/hello/view`. */\n\tname: string;\n\t/** Absolute path of the source file the dev server serves. */\n\tfile: string;\n\t/** Which externalization mode this entry's code is transformed in. */\n\tmode: 'script' | 'module';\n\t/** Stylesheet entries get an empty dependency list and no `type`. */\n\tkind: 'js' | 'css';\n}\n\n/** Result of walking one entry's local import graph. */\nexport interface DevDependencyScan {\n\t/** Script Module ids imported statically (module-mode entries only). */\n\tmoduleIds: string[];\n\t/** Script Module ids imported dynamically. */\n\tdynamicModuleIds: string[];\n\t/** Classic script handles the entry needs enqueued. */\n\thandles: string[];\n\t/** Every local file the walk read, entry included — the watch set. */\n\tfiles: string[];\n}\n\nexport function wpDevServer(options: WpDevServerOptions = {}): Plugin {\n\tconst projectRoot = options.projectRoot ?? process.cwd();\n\tconst emitManifest = options.emitManifest ?? true;\n\tconst buildType = options.buildType ?? 'script';\n\tconst skip = new Set(options.skip ?? []);\n\tconst maxScanDepth = options.maxScanDepth ?? DEFAULT_MAX_SCAN_DEPTH;\n\tconst moduleEntryMatchers = options.moduleEntryMatchers;\n\tconst wpBuildAssetMatchers = (options.wpBuildAssetMatchers ?? []).map(toPosix);\n\n\tconst resolveExternalOptions: ResolveExternalOptions = {\n\t\tprojectRoot,\n\t\t...(options.additionalExternals ? { vendorExternals: options.additionalExternals } : {}),\n\t\t...(options.externalNamespaces ? { externalNamespaces: options.externalNamespaces } : {}),\n\t\t...(options.scriptModuleNamespaces\n\t\t\t? { scriptModuleNamespaces: options.scriptModuleNamespaces }\n\t\t\t: {}),\n\t\t...(options.bundledPackages ? { bundledPackages: options.bundledPackages } : {}),\n\t};\n\n\tconst blocksDirAbs = options.blocksDir ? resolve(process.cwd(), options.blocksDir) : null;\n\tconst blockStylesDirAbs = options.blocksStylesDir\n\t\t? resolve(process.cwd(), options.blocksStylesDir)\n\t\t: null;\n\tconst adminPagesDirAbs = options.adminPagesDir\n\t\t? resolve(process.cwd(), options.adminPagesDir)\n\t\t: null;\n\n\tlet config: ResolvedConfig;\n\tlet outDirAbs = '';\n\tlet entries: DevEntry[] = [];\n\tlet configuredEntries: Record<string, string> = {};\n\t/** Source file -> the entries whose sidecar has to be rewritten when it changes. */\n\tlet entriesByFile = new Map<string, Set<string>>();\n\t/**\n\t * Everything this session has written into `outDir`, so a rediscovery can\n\t * delete what it would no longer write. Only ever files *this process*\n\t * wrote: a `dist/` left by an earlier build is shadowed, never cleaned.\n\t */\n\tlet writtenSidecars = new Set<string>();\n\tlet writtenBlockFiles = new Set<string>();\n\n\tconst collectEntries = (): DevEntry[] =>\n\t\tdiscoverDevEntries({\n\t\t\tblocksDirAbs,\n\t\t\tblockStylesDirAbs,\n\t\t\tadminPagesDirAbs,\n\t\t\tskip,\n\t\t\tconfiguredEntries,\n\t\t\tbuildType,\n\t\t});\n\n\t/**\n\t * One dev server, two passes' worth of entries. A serve-mode config maps to\n\t * `buildType: 'script'` (there is no `--mode modules` second server), so\n\t * without this every Script Module entry would have its bare `@wordpress/*`\n\t * imports rewritten to `window.wp.*` reads and stop being a Script Module.\n\t *\n\t * Pushing the discovered module entries into the very array `wpExternals`\n\t * already consults per file (`moduleEntryMatchers`) is what splits the\n\t * rewrite behavior back apart — no extra user config, and the array stays\n\t * untouched in build because this plugin is `apply: 'serve'`.\n\t */\n\tconst syncModuleEntryMatchers = (): void => {\n\t\tif (!moduleEntryMatchers) return;\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.mode !== 'module' || entry.kind !== 'js') continue;\n\t\t\tconst matcher = toPosix(entry.file);\n\t\t\tif (!moduleEntryMatchers.includes(matcher)) moduleEntryMatchers.push(matcher);\n\t\t}\n\t};\n\n\treturn {\n\t\tname: 'wp-dev-server',\n\t\t// Build is untouched: every write below exists only because there is no\n\t\t// bundle to emit into.\n\t\tapply: 'serve',\n\n\t\t/**\n\t\t * WordPress ships the *production* JSX runtime and nothing else. Core's\n\t\t * `react-jsx-runtime` handle is built from `react/jsx-runtime`, so\n\t\t * `window.ReactJSXRuntime` carries `jsx`, `jsxs` and `Fragment` — there\n\t\t * is no `jsxDEV` on it, in `SCRIPT_DEBUG` or out of it.\n\t\t *\n\t\t * Vite's serve default is the opposite: JSX compiles against the dev\n\t\t * runtime, `react/jsx-dev-runtime`. `wpExternals` then does exactly what\n\t\t * it is supposed to and rewrites that import to the global WordPress\n\t\t * registers for it, so every block editor script with JSX in it comes\n\t\t * out as `const { jsxDEV: _jsxDEV } = (window.ReactJSXRuntime)` —\n\t\t * `undefined`, and a `_jsxDEV is not a function` the moment anything\n\t\t * renders. Builds never see it (`development` is off there), which makes\n\t\t * it a dev-only cliff that a passing build tells you nothing about.\n\t\t *\n\t\t * Filled in only where the user has no opinion, the same rule\n\t\t * `wpScriptIife`'s `define` injection and `wpModuleEntrySignatures`\n\t\t * follow. The cost is the `__source`/`__self` debug props; the benefit is\n\t\t * that the editor script runs at all.\n\t\t */\n\t\tconfig(userConfig) {\n\t\t\tconst oxc = userConfig.oxc;\n\t\t\tif (oxc === false) return null;\n\t\t\tconst jsx = oxc?.jsx;\n\t\t\tif (jsx === 'preserve') return null;\n\t\t\tif (jsx && typeof jsx === 'object' && jsx.development !== undefined) return null;\n\t\t\treturn { oxc: { jsx: { development: false } } };\n\t\t},\n\n\t\tconfigResolved(resolvedConfig) {\n\t\t\tconfig = resolvedConfig;\n\t\t\toutDirAbs = resolve(resolvedConfig.root, resolvedConfig.build.outDir);\n\t\t\tconfiguredEntries = readConfiguredEntries(resolvedConfig);\n\t\t\tentries = collectEntries();\n\t\t\tsyncModuleEntryMatchers();\n\t\t},\n\n\t\t/**\n\t\t * Answer for the bare specifiers the escape above hands back to the\n\t\t * browser.\n\t\t *\n\t\t * `installBareSpecifierEscape` rewrites the served code *after*\n\t\t * import-analysis, which means Vite's module graph still holds the\n\t\t * `/@id/@wordpress/interactivity` form it produced — and Vite eagerly\n\t\t * pre-transforms every import it recorded. That request resolves to a\n\t\t * bare specifier nothing on disk backs, and the console gets a red\n\t\t * `Pre-transform error: Failed to load url @wordpress/interactivity` for\n\t\t * every Script Module entry, on a server that is working perfectly.\n\t\t *\n\t\t * An empty module makes the warm-up succeed and changes nothing else:\n\t\t * the URL is not in the code any browser receives, so it is never\n\t\t * fetched — WordPress's import map resolves the specifier instead.\n\t\t * Narrow by construction: only ids `resolveExternal()` recognizes (i.e.\n\t\t * an installed package whose own metadata says it is externalizable),\n\t\t * and never a path, so a genuinely missing module still fails loudly.\n\t\t */\n\t\tload(id) {\n\t\t\tif (id.startsWith('.') || id.startsWith('/') || id.startsWith('\\0')) return null;\n\t\t\tif (isAbsolute(id) || !resolveExternal(id, resolveExternalOptions)) return null;\n\t\t\treturn 'export {};\\n';\n\t\t},\n\n\t\tasync configureServer(server) {\n\t\t\tinstallBareSpecifierEscape(server, config, resolveExternalOptions);\n\n\t\t\tconst refreshAll = async () => {\n\t\t\t\tconst { index, written } = await writeAllSidecars({\n\t\t\t\t\tentries,\n\t\t\t\t\toutDirAbs,\n\t\t\t\t\troot: config.root,\n\t\t\t\t\tresolveExternalOptions,\n\t\t\t\t\twpBuildAssetMatchers,\n\t\t\t\t\tmaxScanDepth,\n\t\t\t\t});\n\t\t\t\tentriesByFile = index;\n\t\t\t\tpruneStale(writtenSidecars, written);\n\t\t\t\twrittenSidecars = written;\n\t\t\t};\n\n\t\t\tconst refreshFor = async (file: string) => {\n\t\t\t\tconst affected = entriesByFile.get(toPosix(file));\n\t\t\t\tif (!affected || affected.size === 0) return;\n\t\t\t\tconst subset = entries.filter((entry) => affected.has(entry.name));\n\t\t\t\tconst { index: rescanned } = await writeAllSidecars({\n\t\t\t\t\tentries: subset,\n\t\t\t\t\toutDirAbs,\n\t\t\t\t\troot: config.root,\n\t\t\t\t\tresolveExternalOptions,\n\t\t\t\t\twpBuildAssetMatchers,\n\t\t\t\t\tmaxScanDepth,\n\t\t\t\t});\n\t\t\t\t// Merge, don't replace: this only rescanned the affected entries,\n\t\t\t\t// and the map has to keep pointing every *other* entry's files at\n\t\t\t\t// their entries.\n\t\t\t\tfor (const [scannedFile, names] of rescanned) {\n\t\t\t\t\tconst existing = entriesByFile.get(scannedFile);\n\t\t\t\t\tif (existing) for (const name of names) existing.add(name);\n\t\t\t\t\telse entriesByFile.set(scannedFile, new Set(names));\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst refreshBlocksTree = () => {\n\t\t\t\tconst written = writeBlocksTree({ blocksDirAbs, outDirAbs, emitManifest, skip });\n\t\t\t\tpruneStale(writtenBlockFiles, written);\n\t\t\t\twrittenBlockFiles = written;\n\t\t\t};\n\n\t\t\t// `server.watcher` only watches Vite's `root` by default, and a\n\t\t\t// plugin/theme's blocks or admin pages frequently live outside it (or\n\t\t\t// are simply not in any module graph yet — nothing has imported a\n\t\t\t// brand-new block's `view.ts`). Re-run on every rediscovery so a\n\t\t\t// directory that did not exist at startup starts being watched the\n\t\t\t// moment it appears.\n\t\t\tconst addWatchDirs = () => {\n\t\t\t\tfor (const dir of [blocksDirAbs, blockStylesDirAbs, adminPagesDirAbs]) {\n\t\t\t\t\tif (dir && existsSync(dir)) server.watcher.add(dir);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * The whole on-disk picture, from scratch.\n\t\t\t *\n\t\t\t * Anything that changes *which entries exist* has to come through\n\t\t\t * here rather than through the per-file refresh: a new block\n\t\t\t * directory, a deleted admin page, a stylesheet dropped into the\n\t\t\t * block-styles folder. Rediscovery re-globs, rewrites the metadata\n\t\t\t * tree, deletes the sidecars of entries that went away, and — the\n\t\t\t * part with teeth — re-runs `syncModuleEntryMatchers()`, so a\n\t\t\t * brand-new `viewScriptModule` is treated as module-mode by\n\t\t\t * `wpExternals` the very first time the browser asks for it.\n\t\t\t */\n\t\t\tconst rediscover = () => {\n\t\t\t\taddWatchDirs();\n\t\t\t\trefreshBlocksTree();\n\t\t\t\t// Re-read rather than reuse: the config cannot change without a\n\t\t\t\t// restart, but a declared entry whose source file did not exist\n\t\t\t\t// yet at boot was skipped, and creating it should be enough.\n\t\t\t\tconfiguredEntries = readConfiguredEntries(config);\n\t\t\t\tentries = collectEntries();\n\t\t\t\tsyncModuleEntryMatchers();\n\t\t\t\treturn refreshAll();\n\t\t\t};\n\n\t\t\t// Blocks metadata first: `register_block_type()` reads it off disk on\n\t\t\t// every request, dev server or not.\n\t\t\trefreshBlocksTree();\n\t\t\t// The bridge every build emits too — written here as well because a\n\t\t\t// `dist/` that has never been built (fresh clone, `npm run dev`\n\t\t\t// first) still has to bridge, and because the file is where the\n\t\t\t// consumer's `require_once` already points.\n\t\t\twriteFileTree(\n\t\t\t\tjoin(outDirAbs, DEV_SERVER_PHP_NAME),\n\t\t\t\trenderDevServerPhp({\n\t\t\t\t\tprefix: resolvePhpPrefix(options.phpPrefix, config.root),\n\t\t\t\t\thotFile: HOT_FILE_NAME,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tawait refreshAll();\n\n\t\t\taddWatchDirs();\n\t\t\twatchSources({\n\t\t\t\tserver,\n\t\t\t\tsourceDirs: [blocksDirAbs, blockStylesDirAbs, adminPagesDirAbs],\n\t\t\t\tblocksDirAbs,\n\t\t\t\tonRediscover: rediscover,\n\t\t\t\tonFileChange: (file) => refreshFor(file),\n\t\t\t});\n\n\t\t\t// The hot file is the last thing written and the first thing removed:\n\t\t\t// its presence is PHP's only signal, so it must never be visible\n\t\t\t// before the server can actually answer a request. `listening` is\n\t\t\t// also the earliest moment the bound port is known.\n\t\t\t//\n\t\t\t// In `middlewareMode` there is no `httpServer` and no address to\n\t\t\t// advertise — the embedding server owns the socket. Everything else\n\t\t\t// above still runs; only the hot file is skipped, which leaves PHP\n\t\t\t// correctly in the \"not hot\" state.\n\t\t\tconst hotFilePath = join(outDirAbs, HOT_FILE_NAME);\n\t\t\tconst httpServer = server.httpServer;\n\t\t\tif (httpServer) {\n\t\t\t\thttpServer.once('listening', () => {\n\t\t\t\t\tconst hotFile = buildHotFile(config, httpServer.address());\n\t\t\t\t\twriteFileTree(hotFilePath, `${JSON.stringify(hotFile, null, '\\t')}\\n`);\n\t\t\t\t\tregisterHotFileCleanup(hotFilePath);\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Vite closes the plugin container on `server.close()`, which is what\n\t\t * makes this fire for a programmatically-created server (tests, a\n\t\t * wrapper process). The `process` handlers registered above cover the\n\t\t * interactive case, where nothing calls `close()` at all.\n\t\t */\n\t\tcloseBundle() {\n\t\t\tremoveHotFile(join(outDirAbs, HOT_FILE_NAME));\n\t\t},\n\t};\n}\n\n/* -------------------------------------------------------------------------- */\n/* dev-server.php */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Emit `dist/dev-server.php` — the build-side half of the bridge.\n *\n * Its own plugin, `apply: 'build'`, for one reason: the consumer's PHP holds a\n * single unconditional `require_once __DIR__ . '/dist/dev-server.php'`, and\n * that line has to be true of *every* build — a block plugin with no admin\n * pages, a theme with nothing but a stylesheet entry, the module pass of a\n * dual-pass build. Hanging the emission off `wpAdminPages` (which owns the rest\n * of the generated PHP) or off `wpExternals` (which owns the sidecars the\n * bridge reads) would have made it conditional on something unrelated.\n *\n * The file itself is inert in a built site: nothing writes a hot file next to\n * it, so it returns after one `file_exists()`.\n */\nexport function wpDevServerPhp(options: WpDevServerPhpOptions = {}): Plugin {\n\tlet projectRoot = options.projectRoot ?? process.cwd();\n\n\treturn {\n\t\tname: 'wp-dev-server-php',\n\t\tapply: 'build',\n\n\t\tconfigResolved(resolvedConfig) {\n\t\t\tprojectRoot = options.projectRoot ?? resolvedConfig.root;\n\t\t},\n\n\t\tgenerateBundle() {\n\t\t\tthis.emitFile({\n\t\t\t\ttype: 'asset',\n\t\t\t\tfileName: DEV_SERVER_PHP_NAME,\n\t\t\t\tsource: renderDevServerPhp({\n\t\t\t\t\tprefix: resolvePhpPrefix(options.phpPrefix, projectRoot),\n\t\t\t\t\thotFile: HOT_FILE_NAME,\n\t\t\t\t}),\n\t\t\t});\n\t\t},\n\t};\n}\n\n/**\n * Namespace for every identifier in the generated PHP.\n *\n * Unlike `wpAdminPages`, which throws when it can't derive a usable prefix,\n * this one always answers: the bridge ships with every build, and a package.json\n * without a usable name is not a reason to fail one. Two packages that both\n * fall back to the default still work — the generated functions are guarded by\n * `function_exists()`, so the first bridge loaded wins for its own `dist/` and\n * the second is a no-op (documented in docs/wp-dev-server.md).\n */\nexport function resolvePhpPrefix(explicit: string | undefined, projectRoot: string): string {\n\tconst fromOption = sanitizePhpPrefix(explicit);\n\tif (fromOption) return fromOption;\n\n\tlet packageJson: { name?: string; wpPlugin?: { name?: string } } = {};\n\ttry {\n\t\tpackageJson = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8')) as {\n\t\t\tname?: string;\n\t\t\twpPlugin?: { name?: string };\n\t\t};\n\t} catch {\n\t\t// No package.json, or an unreadable one — the default is fine.\n\t}\n\n\treturn (\n\t\tsanitizePhpPrefix(packageJson.wpPlugin?.name) ??\n\t\tsanitizePhpPrefix(packageJson.name?.replace(/^@[^/]+\\//, '')) ??\n\t\tDEFAULT_PHP_PREFIX\n\t);\n}\n\n/** Dashes survive (they're underscored per-identifier); anything else doesn't. */\nfunction sanitizePhpPrefix(value: string | undefined): string | null {\n\tif (!value) return null;\n\tconst cleaned = value.replace(/[^A-Za-z0-9_-]/g, '-').replace(/^-+|-+$/g, '');\n\treturn cleaned !== '' && isValidPhpIdentifier(cleaned) ? cleaned : null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Hot file */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Resolve the origin the browser should fetch dev assets from, then package it\n * with everything else PHP needs.\n *\n * The resolution order is Laravel's, because it is the one that survives every\n * real deployment shape (a containerized WP talking to a host-bound Vite, a\n * proxied https vhost, Herd/Valet):\n *\n * 1. an explicit `server.origin` — the user told us, believe them;\n * 2. the HMR client config (`protocol`, `host`, `clientPort`), which already\n * describes how a *browser* reaches this server;\n * 3. `server.host` from the config;\n * 4. the address the socket actually bound to.\n *\n * The one deviation: a wildcard bind (`0.0.0.0`, `::`) is reported as\n * `localhost`. Laravel binds to a concrete host by default; Vite does not, and\n * `http://[::]:5173` is not a URL PHP can hand to a browser.\n */\nexport function buildHotFile(\n\tconfig: ResolvedConfig,\n\taddress: AddressInfo | string | null,\n): WpDevServerHotFile {\n\treturn {\n\t\torigin: resolveDevOrigin(config, address),\n\t\tbase: config.base,\n\t\tplugins: REPORTED_PLUGINS.filter((name) =>\n\t\t\tconfig.plugins.some((plugin) => plugin.name === name),\n\t\t),\n\t};\n}\n\n/**\n * Bound addresses that must not be reported verbatim.\n *\n * Wildcards (`0.0.0.0`, `::`) mean \"every interface\" and are not browsable at\n * all. Loopback literals are browsable but wrong to publish: Vite itself\n * prints `http://localhost:<port>/`, and a hot file that disagrees with the\n * banner (`http://[::1]:5173`) is a support ticket waiting to happen — plus\n * `[::1]` breaks the moment anything but the same host loads the page. Both\n * collapse to `localhost`. Only the *fallback* is normalized: a host the user\n * configured explicitly is always honored.\n */\nconst UNPUBLISHABLE_ADDRESSES = new Set([\n\t'0.0.0.0',\n\t'::',\n\t'::0',\n\t'0000:0000:0000:0000:0000:0000:0000:0000',\n\t'127.0.0.1',\n\t'::1',\n\t'0000:0000:0000:0000:0000:0000:0000:0001',\n]);\n\nexport function resolveDevOrigin(\n\tconfig: ResolvedConfig,\n\taddress: AddressInfo | string | null,\n): string {\n\tconst explicitOrigin = config.server?.origin;\n\tif (typeof explicitOrigin === 'string' && explicitOrigin.length > 0) {\n\t\treturn explicitOrigin.replace(/\\/+$/, '');\n\t}\n\n\tconst hmr = typeof config.server?.hmr === 'object' ? config.server.hmr : null;\n\n\t// `wss` is the only HMR protocol that implies an https page.\n\tconst hmrProtocol = hmr && 'protocol' in hmr ? hmr.protocol : undefined;\n\tconst protocol = hmrProtocol\n\t\t? hmrProtocol === 'wss'\n\t\t\t? 'https'\n\t\t\t: 'http'\n\t\t: config.server?.https\n\t\t\t? 'https'\n\t\t\t: 'http';\n\n\tconst hmrHost = hmr && 'host' in hmr && typeof hmr.host === 'string' ? hmr.host : undefined;\n\tconst configHost = typeof config.server?.host === 'string' ? config.server.host : undefined;\n\tconst boundHost = address && typeof address === 'object' ? address.address : undefined;\n\tconst host = hmrHost ?? configHost ?? (boundHost ? normalizeBoundHost(boundHost) : 'localhost');\n\n\tconst hmrClientPort =\n\t\thmr && 'clientPort' in hmr && typeof hmr.clientPort === 'number'\n\t\t\t? hmr.clientPort\n\t\t\t: undefined;\n\tconst boundPort = address && typeof address === 'object' ? address.port : undefined;\n\tconst port = hmrClientPort ?? boundPort;\n\n\treturn port === undefined ? `${protocol}://${host}` : `${protocol}://${host}:${port}`;\n}\n\n/** Wildcards and loopbacks become `localhost`; other IPv6 literals get bracketed. */\nfunction normalizeBoundHost(host: string): string {\n\tif (UNPUBLISHABLE_ADDRESSES.has(host)) return 'localhost';\n\tif (host.includes(':') && !host.startsWith('[')) return `[${host}]`;\n\treturn host;\n}\n\n/**\n * Hot files to delete when this process goes away, plus the one-time signal\n * wiring. Module-level on purpose: `configureServer` can run more than once in\n * a single process (a config reload restarts the server), and stacking a fresh\n * set of `process` listeners per restart is how a long dev session ends up\n * warning about a MaxListeners leak.\n */\nconst pendingHotFiles = new Set<string>();\nlet hotFileHandlersBound = false;\n\nfunction registerHotFileCleanup(hotFilePath: string): void {\n\tpendingHotFiles.add(hotFilePath);\n\tif (hotFileHandlersBound) return;\n\thotFileHandlersBound = true;\n\n\tconst cleanAll = () => {\n\t\tfor (const filePath of pendingHotFiles) removeHotFile(filePath);\n\t\tpendingHotFiles.clear();\n\t};\n\tprocess.on('exit', cleanAll);\n\t// A signalled dev server must still leave PHP in the \"not hot\" state, and\n\t// `exit` alone never fires for a signal that Node handles by default. Once\n\t// a listener exists the default terminate is suppressed, so these have to\n\t// exit themselves — the same shape laravel-vite-plugin uses.\n\tfor (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP'] as const) {\n\t\tprocess.on(signal, () => {\n\t\t\tcleanAll();\n\t\t\tprocess.exit();\n\t\t});\n\t}\n}\n\nfunction removeHotFile(hotFilePath: string): void {\n\tpendingHotFiles.delete(hotFilePath);\n\ttry {\n\t\trmSync(hotFilePath, { force: true });\n\t} catch {\n\t\t// A dist/ that vanished under us is not worth crashing a shutdown over.\n\t}\n}\n\n/* -------------------------------------------------------------------------- */\n/* Bare-specifier escape */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Undo Vite's `/@id/` wrapping for the specifiers WordPress resolves itself.\n *\n * Vite's dev import-analysis rewrites every non-relative import to a URL the\n * dev server can serve. For an id a plugin marked `external: true` that URL is\n * `<base>@id/<id>` — a real request the browser would make and the server\n * would 404. Script Modules need the opposite: the specifier has to reach the\n * browser untouched so WordPress's import map (`wp_register_script_module()`\n * + core's generated `<script type=\"importmap\">`) can resolve it.\n *\n * `vite:import-analysis` is the final plugin in the dev chain, so there is no\n * `transform` slot after it. `DevEnvironment.transformRequest` is the next\n * seam out and part of Vite's environment API, so the plugin decorates it and\n * rewrites the wrapped ids back on the way out. The check is narrow by\n * construction: only ids `resolveExternal()` recognizes are unwrapped, so a\n * genuinely unresolvable import still fails loudly.\n */\nconst decoratedEnvironments = new WeakSet<object>();\n\nexport function installBareSpecifierEscape(\n\tserver: ViteDevServer,\n\tconfig: ResolvedConfig,\n\tresolveExternalOptions: ResolveExternalOptions,\n): void {\n\tconst base = config.base ?? '/';\n\t// `joinUrlSegments(base, '/@id/x')` — base always has a trailing slash.\n\tconst wrappedPrefix = `${base.replace(/\\/+$/, '')}/@id/`;\n\tconst pattern = new RegExp(`([\"'])${escapeRegExp(wrappedPrefix)}([^\"'\\\\s]+)\\\\1`, 'g');\n\n\tconst unwrap = (code: string): string =>\n\t\tcode.replace(pattern, (match, quote: string, specifier: string) =>\n\t\t\tresolveExternal(specifier, resolveExternalOptions)\n\t\t\t\t? `${quote}${specifier}${quote}`\n\t\t\t\t: match,\n\t\t);\n\n\tfor (const environment of Object.values(server.environments)) {\n\t\t// A restart builds new environments, but a config that composes the\n\t\t// plugin twice would otherwise stack decorators on the same one.\n\t\tif (decoratedEnvironments.has(environment)) continue;\n\t\tdecoratedEnvironments.add(environment);\n\t\tconst original = environment.transformRequest.bind(environment);\n\t\tenvironment.transformRequest = async (url: string) => {\n\t\t\tconst result = await original(url);\n\t\t\tif (!result || typeof result.code !== 'string') return result;\n\t\t\tif (!result.code.includes(wrappedPrefix)) return result;\n\t\t\tconst code = unwrap(result.code);\n\t\t\treturn code === result.code ? result : { ...result, code };\n\t\t};\n\t}\n}\n\nfunction escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/* -------------------------------------------------------------------------- */\n/* Entry discovery */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Every entry a dev sidecar has to exist for, in the same output-name space\n * the build uses — `blocks/<block>/<name>`, `autoenqueue/<name>`,\n * `modules/<page>/…`. Matching the build's names is what lets PHP written for\n * a built plugin keep working verbatim against a running dev server.\n */\nexport function discoverDevEntries(options: {\n\tblocksDirAbs: string | null;\n\tblockStylesDirAbs: string | null;\n\tadminPagesDirAbs: string | null;\n\tskip: Set<string>;\n\t/** Entries declared in `build.rollupOptions.input` — see `readConfiguredEntries`. */\n\tconfiguredEntries?: Record<string, string>;\n\t/** Mode for those declared entries. Default: `'script'`. */\n\tbuildType?: 'script' | 'module';\n}): DevEntry[] {\n\tconst { blocksDirAbs, blockStylesDirAbs, adminPagesDirAbs, skip } = options;\n\tconst byName = new Map<string, DevEntry>();\n\n\tconst add = (entry: DevEntry) => {\n\t\tif (!byName.has(entry.name)) byName.set(entry.name, entry);\n\t};\n\n\tif (blocksDirAbs && existsSync(blocksDirAbs)) {\n\t\t// Both field sets, from one server. `discoverEntries` already resolves\n\t\t// `file:` refs and probes source extensions the same way the build does.\n\t\tfor (const [name, file] of Object.entries(discoverEntries(blocksDirAbs, 'module', skip))) {\n\t\t\tadd({ name, file, mode: 'module', kind: entryKind(file) });\n\t\t}\n\t\tfor (const [name, file] of Object.entries(discoverEntries(blocksDirAbs, 'script', skip))) {\n\t\t\tadd({ name, file, mode: 'script', kind: entryKind(file) });\n\t\t}\n\t}\n\n\tif (blockStylesDirAbs && existsSync(blockStylesDirAbs)) {\n\t\t// Mirrors `wpBlockStyles`' own globbing: one entry per stylesheet.\n\t\tconst stylesheets = fg.sync(`${toPosix(blockStylesDirAbs)}/**/*.{css,scss,sass}`, {\n\t\t\tabsolute: true,\n\t\t});\n\t\tfor (const file of stylesheets) {\n\t\t\tconst blockName = relative(blockStylesDirAbs, file)\n\t\t\t\t.replace(extname(file), '')\n\t\t\t\t.replace(/\\\\/g, '/');\n\t\t\tadd({ name: `autoenqueue/${blockName}`, file, mode: 'script', kind: 'css' });\n\t\t}\n\t}\n\n\tif (adminPagesDirAbs && existsSync(adminPagesDirAbs)) {\n\t\t// Admin pages are Script Modules by construction — they only exist in\n\t\t// the module pass.\n\t\tfor (const page of discoverPages(adminPagesDirAbs)) {\n\t\t\tadd({\n\t\t\t\tname: `modules/${page.dirName}/content`,\n\t\t\t\tfile: page.content,\n\t\t\t\tmode: 'module',\n\t\t\t\tkind: 'js',\n\t\t\t});\n\t\t\tif (page.route) {\n\t\t\t\tadd({\n\t\t\t\t\tname: `modules/${page.dirName}/route`,\n\t\t\t\t\tfile: page.route,\n\t\t\t\t\tmode: 'module',\n\t\t\t\t\tkind: 'js',\n\t\t\t\t});\n\t\t\t}\n\t\t\tfor (const subRoute of page.subRoutes) {\n\t\t\t\tconst base = `modules/${page.dirName}/routes/${subRoute.name}`;\n\t\t\t\tif (subRoute.content) {\n\t\t\t\t\tadd({\n\t\t\t\t\t\tname: `${base}/content`,\n\t\t\t\t\t\tfile: subRoute.content,\n\t\t\t\t\t\tmode: 'module',\n\t\t\t\t\t\tkind: 'js',\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (subRoute.route) {\n\t\t\t\t\tadd({\n\t\t\t\t\t\tname: `${base}/route`,\n\t\t\t\t\t\tfile: subRoute.route,\n\t\t\t\t\t\tmode: 'module',\n\t\t\t\t\t\tkind: 'js',\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Declared inputs last, because `add()` is first-wins: the block and admin\n\t// page plugins put their own entries into this very config, and discovery\n\t// above is the only place that knows a `viewScriptModule` is module-mode —\n\t// a serve-mode config lists it as just another script-pass input. What is\n\t// left after the dedupe is what only the config knows: the project's own\n\t// `js/frontend`, `css/frontend`, editor scripts.\n\tfor (const [name, file] of Object.entries(options.configuredEntries ?? {})) {\n\t\tadd({ name, file, mode: options.buildType ?? 'script', kind: entryKind(file) });\n\t}\n\n\treturn [...byName.values()].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n}\n\n/**\n * The entries `build.rollupOptions.input` declares.\n *\n * `discoverDevEntries` re-derives blocks, block styles and admin pages from\n * disk because a serve-mode config can only describe one pass. What it cannot\n * invent is the *project's own* entries — `js/frontend`, `css/frontend`, a\n * theme's editor script — which exist nowhere but the config, and which every\n * project migrated off `10up-toolkit` enqueues straight out of `dist/`.\n * Without a sidecar for those, the PHP bridge has no `source` to read and they\n * are the one thing on the page still being served from a stale build.\n *\n * Only the object form of `input` carries the entry names the sidecar path is\n * keyed on, so a string/array input is left alone rather than guessed at — the\n * same rule `wpCssAssetInfo` applies. Sources that do not exist are skipped:\n * Rollup would fail the build on them, and a dev server should not write a\n * sidecar pointing at nothing.\n */\nexport function readConfiguredEntries(config: ResolvedConfig): Record<string, string> {\n\tconst input = config.build?.rollupOptions?.input;\n\tif (!input || typeof input !== 'object' || Array.isArray(input)) return {};\n\n\tconst entries: Record<string, string> = {};\n\tfor (const [name, source] of Object.entries(input as Record<string, unknown>)) {\n\t\tif (typeof source !== 'string') continue;\n\t\t// `input` allows relative or absolute; the sidecar's `source` key needs\n\t\t// an absolute path to make project-relative from.\n\t\tconst file = resolve(config.root, source);\n\t\tif (existsSync(file)) entries[name] = file;\n\t}\n\treturn entries;\n}\n\nfunction entryKind(file: string): 'js' | 'css' {\n\treturn STYLESHEET_EXTENSION.test(file) ? 'css' : 'js';\n}\n\n/* -------------------------------------------------------------------------- */\n/* Static dependency scan */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Walk an entry's *local* import graph with `es-module-lexer` and collect the\n * WordPress dependencies its `.asset.php` has to declare.\n *\n * A build gets this for free — Rollup hands `wpExternals` the finished module\n * graph. In serve mode nothing has been bundled when the sidecars are written,\n * so the graph has to be approximated statically. The approximation is\n * deliberately conservative:\n *\n * - only relative/absolute imports are followed, resolved by the same\n * extension probing `discoverEntries` uses;\n * - `node_modules` is never entered. A bundled dependency's own externals\n * (the `require('react')` inside a CJS shim, say) are invisible to an ESM\n * lexer anyway, and walking third-party trees on every keystroke is not\n * worth the accuracy;\n * - bare specifiers stop the walk and go through `resolveExternal()`, the\n * same verdict function `wpExternals` uses.\n *\n * Cycles are guarded by the visited set and runaway graphs by `maxDepth`.\n */\nexport async function scanEntryDependencies(\n\tentryFile: string,\n\toptions: {\n\t\tmode: 'script' | 'module';\n\t\tresolveExternalOptions: ResolveExternalOptions;\n\t\tmaxDepth?: number;\n\t},\n): Promise<DevDependencyScan> {\n\tconst maxDepth = options.maxDepth ?? DEFAULT_MAX_SCAN_DEPTH;\n\tconst moduleIds = new Set<string>();\n\tconst dynamicModuleIds = new Set<string>();\n\tconst handles = new Set<string>();\n\tconst visited = new Set<string>();\n\tconst files: string[] = [];\n\tlet hasJsxSource = false;\n\n\tawait init;\n\n\tconst queue: Array<{ file: string; depth: number }> = [{ file: entryFile, depth: 0 }];\n\twhile (queue.length > 0) {\n\t\tconst { file, depth } = queue.shift()!;\n\t\tconst key = toPosix(file);\n\t\tif (visited.has(key)) continue;\n\t\tvisited.add(key);\n\t\tfiles.push(key);\n\t\tif (JSX_SOURCE_EXTENSION.test(key)) hasJsxSource = true;\n\t\tif (depth >= maxDepth) continue;\n\t\tif (STYLESHEET_EXTENSION.test(file)) continue;\n\n\t\tlet code: string;\n\t\ttry {\n\t\t\tcode = readFileSync(file, 'utf8');\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const { specifier, isDynamic } of lexImports(code, file)) {\n\t\t\tif (specifier.startsWith('.') || isAbsolute(specifier)) {\n\t\t\t\tconst resolved = resolveLocalImport(specifier, file);\n\t\t\t\tif (resolved) queue.push({ file: resolved, depth: depth + 1 });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst external = resolveExternal(specifier, options.resolveExternalOptions);\n\t\t\tif (!external) continue;\n\n\t\t\tif (options.mode === 'module' && external.moduleEligible) {\n\t\t\t\t// `@wordpress/interactivity` has no dynamic form — core's\n\t\t\t\t// dependency extraction hardcodes the same exception.\n\t\t\t\tif (isDynamic && specifier !== '@wordpress/interactivity') {\n\t\t\t\t\tdynamicModuleIds.add(external.specifier);\n\t\t\t\t} else {\n\t\t\t\t\tmoduleIds.add(external.specifier);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (external.handle) handles.add(external.handle);\n\t\t}\n\t}\n\n\t/**\n\t * The automatic JSX runtime's import exists in no file on disk — the\n\t * transform injects it — but it is very much in the module graph Rollup\n\t * hands `wpExternals`, which is why a *built* `.asset.php` for a `.tsx`\n\t * editor script lists `react-jsx-runtime`. This scan reads raw source, so\n\t * without this the dev sidecar quietly omits it, WordPress never enqueues\n\t * the handle, and `window.ReactJSXRuntime` is undefined the moment the\n\t * editor renders the block.\n\t *\n\t * Keyed off the extension rather than the content: a `.tsx` file with no\n\t * JSX in it costs one redundant core script in the dependency list, while\n\t * missing one costs a blank block editor.\n\t */\n\tif (hasJsxSource) {\n\t\tconst jsxRuntime = resolveExternal(JSX_RUNTIME_SPECIFIER, options.resolveExternalOptions);\n\t\tif (jsxRuntime?.handle) handles.add(jsxRuntime.handle);\n\t}\n\n\t// Static wins: a dependency imported both ways has to be there up front.\n\tfor (const id of moduleIds) dynamicModuleIds.delete(id);\n\n\treturn {\n\t\tmoduleIds: [...moduleIds].sort(),\n\t\tdynamicModuleIds: [...dynamicModuleIds].sort(),\n\t\thandles: [...handles].sort(),\n\t\tfiles,\n\t};\n}\n\n/** One import site found in a module's source. */\ninterface LexedImport {\n\tspecifier: string;\n\tisDynamic: boolean;\n}\n\n/**\n * Static `import`/`export … from` and dynamic `import()` sites in a file.\n *\n * `es-module-lexer` is the fast path and the accurate one — but it lexes\n * *JavaScript*, and the entries this scan starts from are routinely `.tsx`\n * (`registerBlockType` with a JSX `edit`). `wpExternals` never hits this\n * because Vite hands its `transform` hook code that has already been through\n * the TS/JSX transform; here there is no pipeline to borrow, only the file on\n * disk. A raw `.tsx` throws at the first `<`.\n *\n * So a JSX/TS parse failure falls back to a regex sweep over the\n * comment-stripped source. Coarser, and knowingly so: it can miss an exotic\n * import form or pick one out of a string literal. The blast radius is one\n * extra (or one missing) entry in a dev `.asset.php` — a WordPress dependency\n * handle that was already going to be registered either way — and the build,\n * which uses the real module graph, is unaffected.\n */\nexport function lexImports(code: string, file: string): LexedImport[] {\n\ttry {\n\t\tconst [imports] = parse(code, file);\n\t\tconst found: LexedImport[] = [];\n\t\tfor (const importRecord of imports) {\n\t\t\tif (importRecord.n === undefined) continue;\n\t\t\tfound.push({ specifier: importRecord.n, isDynamic: importRecord.d > -1 });\n\t\t}\n\t\treturn found;\n\t} catch {\n\t\treturn regexImports(code);\n\t}\n}\n\n/** Comments removed so a commented-out import can't reach the sweep below. */\nfunction stripComments(code: string): string {\n\treturn code.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').replace(/(^|[^:\"'`\\\\])\\/\\/[^\\n]*/g, '$1');\n}\n\nconst DYNAMIC_IMPORT_RE = /\\bimport\\s*\\(\\s*(['\"])([^'\"]+)\\1\\s*\\)/g;\nconst STATIC_FROM_RE = /(?:^|[\\s;}(])(?:import|export)\\b[^;]*?\\bfrom\\s*(['\"])([^'\"]+)\\1/g;\nconst BARE_IMPORT_RE = /(?:^|[\\s;}])import\\s*(['\"])([^'\"]+)\\1/g;\n\nfunction regexImports(code: string): LexedImport[] {\n\tconst source = stripComments(code);\n\tconst found = new Map<string, LexedImport>();\n\tconst record = (specifier: string, isDynamic: boolean) => {\n\t\t// Static wins if the same specifier appears both ways.\n\t\tconst existing = found.get(specifier);\n\t\tif (existing && !existing.isDynamic) return;\n\t\tfound.set(specifier, { specifier, isDynamic });\n\t};\n\tfor (const match of source.matchAll(DYNAMIC_IMPORT_RE)) record(match[2]!, true);\n\tfor (const match of source.matchAll(STATIC_FROM_RE)) record(match[2]!, false);\n\tfor (const match of source.matchAll(BARE_IMPORT_RE)) record(match[2]!, false);\n\treturn [...found.values()];\n}\n\n/**\n * Resolve a relative import to a file on disk, probing extensions the way\n * `discoverEntries` does — plus the TypeScript convention of writing\n * `./thing.js` for `./thing.ts`, and `./dir` for `./dir/index.ts`.\n */\nexport function resolveLocalImport(specifier: string, importerFile: string): string | null {\n\tconst withoutQuery = specifier.split('?')[0] ?? specifier;\n\tconst target = isAbsolute(withoutQuery)\n\t\t? withoutQuery\n\t\t: join(dirname(importerFile), withoutQuery);\n\n\tif (existsSync(target) && !isDirectory(target)) return target;\n\n\tconst candidates: string[] = [];\n\t// `./thing.js` in TypeScript source usually means `./thing.ts`.\n\tconst withoutJsExtension = target.replace(/\\.[mc]?js$/, '');\n\tfor (const extension of SCAN_EXTENSIONS) {\n\t\tcandidates.push(`${target}${extension}`);\n\t\tif (withoutJsExtension !== target) candidates.push(`${withoutJsExtension}${extension}`);\n\t}\n\tfor (const extension of SCAN_EXTENSIONS) candidates.push(join(target, `index${extension}`));\n\n\treturn candidates.find((candidate) => existsSync(candidate)) ?? null;\n}\n\nfunction isDirectory(filePath: string): boolean {\n\ttry {\n\t\treturn existsSync(filePath) && extname(filePath) === '';\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/* -------------------------------------------------------------------------- */\n/* Sidecars */\n/* -------------------------------------------------------------------------- */\n\nexport interface DevAssetPhpInput {\n\tscan: Pick<DevDependencyScan, 'moduleIds' | 'dynamicModuleIds' | 'handles'>;\n\tmode: 'script' | 'module';\n\tkind: 'js' | 'css';\n\t/** Project-relative posix source path, or `null` to omit the key. */\n\tsource: string | null;\n\t/** Use the `@wordpress/build` sidecar shape (admin pages). */\n\twpBuildShape?: boolean;\n}\n\n/**\n * Render a dev `.asset.php`.\n *\n * Same keys, same shapes, same consumers as the build-time sidecars — with two\n * differences that PHP can act on:\n *\n * - `'version' => null`. There is nothing stable to hash: the file the\n * browser gets is transformed per request and changes on every keystroke.\n * Cache-busting in dev is Vite's job (`?t=` timestamps), not WordPress's.\n * - `'dev' => true`. An unambiguous marker so PHP never mistakes a sidecar\n * left behind by a dev session for build output. It is additive; every\n * existing reader ignores it.\n *\n * These files fully replace whatever a previous build wrote. That is\n * deliberate — a half-dev, half-build sidecar would be worse than either — and\n * they are left in place on shutdown, where the missing hot file makes them\n * inert until the next build overwrites them.\n */\nexport function renderDevAssetPhp(input: DevAssetPhpInput): string {\n\tconst { scan, mode, kind, source } = input;\n\tconst phpList = (items: string[]) => (items.length > 0 ? ` ${items.join(', ')} ` : '');\n\tconst quoted = (items: string[]) => items.map((item) => `'${phpSingleQuoteEscape(item)}'`);\n\tconst fields: string[] = [];\n\n\tif (kind === 'css') {\n\t\tfields.push(`'dependencies' => array()`);\n\t} else if (input.wpBuildShape) {\n\t\t// `@wordpress/build` shape: classic handles in `dependencies`, module\n\t\t// ids in their own key with an explicit import kind.\n\t\tfields.push(`'dependencies' => array(${phpList(quoted(scan.handles))})`);\n\t\tconst moduleDependencies = [\n\t\t\t...scan.moduleIds.map(\n\t\t\t\t(id) => `array( 'id' => '${phpSingleQuoteEscape(id)}', 'import' => 'static' )`,\n\t\t\t),\n\t\t\t...scan.dynamicModuleIds.map(\n\t\t\t\t(id) => `array( 'id' => '${phpSingleQuoteEscape(id)}', 'import' => 'dynamic' )`,\n\t\t\t),\n\t\t];\n\t\tif (moduleDependencies.length > 0) {\n\t\t\tfields.push(`'module_dependencies' => array(${phpList(moduleDependencies)})`);\n\t\t}\n\t} else if (mode === 'module') {\n\t\t// Core-compatible shape: WordPress reads `dependencies` as the Script\n\t\t// Module dependency list when it registers a `viewScriptModule`.\n\t\tconst moduleDependencies = [\n\t\t\t...quoted(scan.moduleIds),\n\t\t\t...scan.dynamicModuleIds.map(\n\t\t\t\t(id) => `array( 'id' => '${phpSingleQuoteEscape(id)}', 'import' => 'dynamic' )`,\n\t\t\t),\n\t\t];\n\t\tfields.push(`'dependencies' => array(${phpList(moduleDependencies)})`);\n\t\tif (scan.handles.length > 0) {\n\t\t\tfields.push(`'script_dependencies' => array(${phpList(quoted(scan.handles))})`);\n\t\t}\n\t} else {\n\t\tfields.push(`'dependencies' => array(${phpList(quoted(scan.handles))})`);\n\t}\n\n\tfields.push(`'version' => null`);\n\tif (kind === 'js' && mode === 'module') fields.push(`'type' => 'module'`);\n\tif (source) fields.push(`'source' => '${phpSingleQuoteEscape(source)}'`);\n\tfields.push(`'dev' => true`);\n\n\treturn `<?php return array( ${fields.join(', ')} );\\n`;\n}\n\n/**\n * Write one `.asset.php` per entry.\n *\n * Returns both the source-file -> entries index (what a per-file refresh\n * consults) and the set of sidecar paths written (what a rediscovery diffs to\n * find the ones an entry left behind when it was deleted).\n */\nasync function writeAllSidecars(options: {\n\tentries: DevEntry[];\n\toutDirAbs: string;\n\troot: string;\n\tresolveExternalOptions: ResolveExternalOptions;\n\twpBuildAssetMatchers: string[];\n\tmaxScanDepth: number;\n}): Promise<{ index: Map<string, Set<string>>; written: Set<string> }> {\n\tconst index = new Map<string, Set<string>>();\n\tconst written = new Set<string>();\n\n\tfor (const entry of options.entries) {\n\t\tconst scan =\n\t\t\tentry.kind === 'css'\n\t\t\t\t? { moduleIds: [], dynamicModuleIds: [], handles: [], files: [toPosix(entry.file)] }\n\t\t\t\t: await scanEntryDependencies(entry.file, {\n\t\t\t\t\t\tmode: entry.mode,\n\t\t\t\t\t\tresolveExternalOptions: options.resolveExternalOptions,\n\t\t\t\t\t\tmaxDepth: options.maxScanDepth,\n\t\t\t\t\t});\n\n\t\tconst php = renderDevAssetPhp({\n\t\t\tscan,\n\t\t\tmode: entry.mode,\n\t\t\tkind: entry.kind,\n\t\t\tsource: projectRelativeSource(entry.file, options.root),\n\t\t\twpBuildShape: options.wpBuildAssetMatchers.some((matcher) =>\n\t\t\t\ttoPosix(entry.file).includes(matcher),\n\t\t\t),\n\t\t});\n\t\tconst sidecarPath = join(options.outDirAbs, `${entry.name}.asset.php`);\n\t\twriteFileTree(sidecarPath, php);\n\t\twritten.add(sidecarPath);\n\n\t\tfor (const file of scan.files) {\n\t\t\tlet names = index.get(file);\n\t\t\tif (!names) index.set(file, (names = new Set()));\n\t\t\tnames.add(entry.name);\n\t\t}\n\t}\n\n\treturn { index, written };\n}\n\n/**\n * Delete what this session wrote and would no longer write.\n *\n * A block deleted mid-session has to stop being registered *and* stop having a\n * sidecar, or the PHP bridge keeps happily rewriting an enqueue for a file the\n * server no longer serves. Scoped to paths this process wrote itself: an\n * earlier build's `dist/` is shadowed by a dev session, never cleaned up by\n * one.\n */\nfunction pruneStale(previous: Set<string>, current: Set<string>): void {\n\tfor (const filePath of previous) {\n\t\tif (current.has(filePath)) continue;\n\t\ttry {\n\t\t\trmSync(filePath, { force: true });\n\t\t} catch {\n\t\t\t// A dist/ that vanished under us is not worth crashing a refresh over.\n\t\t}\n\t}\n}\n\n/**\n * Project-relative, posix source path — the `source` key PHP maps a dist asset\n * back to a dev-server URL with. Same omission rule as the build-time sidecars:\n * anything outside `root` gets no key rather than a nonsensical one.\n */\nexport function projectRelativeSource(file: string, root: string): string | null {\n\tconst relativePath = relative(root, file).replace(/\\\\/g, '/');\n\tif (relativePath === '' || relativePath === '..' || relativePath.startsWith('../')) return null;\n\tif (isAbsolute(relativePath)) return null;\n\treturn relativePath;\n}\n\nfunction phpSingleQuoteEscape(value: string): string {\n\treturn value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\n/* -------------------------------------------------------------------------- */\n/* Blocks metadata */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Copy the blocks tree into `outDir` exactly as the script pass' bundle does:\n * `block.json` through `transformBlockJson` (so `file:` refs point at the\n * built names PHP expects and `version` is stamped), sibling `*.php` verbatim,\n * and `blocks-manifest.php` for `wp_register_block_types_from_metadata_collection()`.\n *\n * Registration is a PHP-side, disk-side concern — it has to work on the very\n * first request of a dev session, before any browser has fetched anything.\n *\n * Returns every path written, so a rediscovery can delete the copies a deleted\n * block left behind — including `blocks-manifest.php` itself, which\n * `buildBlocksManifest` declines to produce once the last block is gone.\n */\nexport function writeBlocksTree(options: {\n\tblocksDirAbs: string | null;\n\toutDirAbs: string;\n\temitManifest: boolean;\n\tskip: Set<string>;\n}): Set<string> {\n\tconst { blocksDirAbs, outDirAbs, emitManifest, skip } = options;\n\tconst written = new Set<string>();\n\tif (!blocksDirAbs || !existsSync(blocksDirAbs)) return written;\n\n\tconst files = fg.sync(\n\t\t[`${toPosix(blocksDirAbs)}/**/block.json`, `${toPosix(blocksDirAbs)}/**/*.php`],\n\t\t{ absolute: true },\n\t);\n\tfor (const file of files) {\n\t\tconst relativePath = relative(blocksDirAbs, file).replace(/\\\\/g, '/');\n\t\tconst blockDirName = relativePath.replace(/\\/?[^/]+$/, '');\n\t\tif (blockDirName && skip.has(blockDirName)) continue;\n\t\tconst source = relativePath.endsWith('block.json')\n\t\t\t? transformBlockJson(readFileSync(file, 'utf8'), file)\n\t\t\t: readFileSync(file);\n\t\tconst target = join(outDirAbs, 'blocks', relativePath);\n\t\twriteFileTree(target, source);\n\t\twritten.add(target);\n\t}\n\n\tif (!emitManifest) return written;\n\tconst manifest = buildBlocksManifest(blocksDirAbs, skip);\n\tif (manifest) {\n\t\tconst target = join(outDirAbs, 'blocks-manifest.php');\n\t\twriteFileTree(target, manifest);\n\t\twritten.add(target);\n\t}\n\treturn written;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Watching */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Keep the on-disk artifacts in step with the source tree.\n *\n * Two very different costs, so two paths:\n *\n * - **Rediscovery** (re-glob everything, rewrite the metadata tree, rescan\n * every entry). Reserved for the events that can change *which entries\n * exist*: a file appearing or disappearing anywhere under a source\n * directory, and any edit to block metadata (a `block.json` gains a\n * `viewScriptModule`; a `render.php` is added). This is the case PR 2 could\n * not handle — a brand-new block's `index.tsx` is not in any entry's\n * dependency graph, so the per-file path had nothing to look it up by, and\n * the block stayed invisible until the server restarted.\n * - **Per-file refresh** for everything else, i.e. ordinary edits: look the\n * file up in the reverse index the last scan built and rescan only the\n * entries that reach it.\n *\n * The rediscovery trigger is deliberately scoped to the *source* directories.\n * Vite's watcher covers `root`, which usually contains `outDir` too — and this\n * plugin writes into `outDir`, so reacting to every `add` anywhere would have\n * it chasing its own tail.\n */\nfunction watchSources(options: {\n\tserver: ViteDevServer;\n\t/** Directories whose add/unlink events mean the entry set may have changed. */\n\tsourceDirs: Array<string | null>;\n\tblocksDirAbs: string | null;\n\tonRediscover: () => void | Promise<void>;\n\tonFileChange: (file: string) => void | Promise<void>;\n}): void {\n\tconst { server, blocksDirAbs } = options;\n\tconst sourceDirs = options.sourceDirs\n\t\t.filter((dir): dir is string => !!dir)\n\t\t.map((dir) => `${toPosix(dir)}/`);\n\n\tconst isUnderSourceDir = (posixFile: string): boolean =>\n\t\tsourceDirs.some((dir) => posixFile.startsWith(dir));\n\n\tconst isBlocksMetadata = (posixFile: string): boolean => {\n\t\tif (!blocksDirAbs) return false;\n\t\tif (!posixFile.startsWith(`${toPosix(blocksDirAbs)}/`)) return false;\n\t\treturn posixFile.endsWith('/block.json') || posixFile.endsWith('.php');\n\t};\n\n\tconst run = (work: void | Promise<void>, file: string) => {\n\t\tvoid Promise.resolve(work).catch((error: unknown) => {\n\t\t\tserver.config.logger.error(\n\t\t\t\t`[wp-dev-server] failed to refresh after ${file}: ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t);\n\t\t});\n\t};\n\n\t// Coalesce a burst into one pass — scaffolding a block is `block.json`,\n\t// `index.tsx`, `render.php` and `style.css` in the same tick.\n\tlet pending: ReturnType<typeof setTimeout> | null = null;\n\tconst scheduleRediscover = (file: string) => {\n\t\tif (pending) clearTimeout(pending);\n\t\tpending = setTimeout(() => {\n\t\t\tpending = null;\n\t\t\trun(options.onRediscover(), file);\n\t\t}, REDISCOVER_DEBOUNCE_MS);\n\t\t// Never let a queued refresh be the reason the process stays alive.\n\t\tpending.unref?.();\n\t};\n\n\tconst handle = (event: 'add' | 'change' | 'unlink', file: string) => {\n\t\tconst posixFile = toPosix(file);\n\t\tif (isBlocksMetadata(posixFile) || (event !== 'change' && isUnderSourceDir(posixFile))) {\n\t\t\tscheduleRediscover(file);\n\t\t\treturn;\n\t\t}\n\t\trun(options.onFileChange(file), file);\n\t};\n\n\tfor (const event of ['add', 'change', 'unlink'] as const) {\n\t\tserver.watcher.on(event, (file: string) => handle(event, file));\n\t}\n}\n\n/* -------------------------------------------------------------------------- */\n/* Small shared helpers */\n/* -------------------------------------------------------------------------- */\n\n/** `mkdir -p` + write. The only place this module touches the filesystem. */\nfunction writeFileTree(filePath: string, contents: string | Uint8Array): void {\n\tmkdirSync(dirname(filePath), { recursive: true });\n\twriteFileSync(filePath, contents);\n}\n\nfunction toPosix(filePath: string): string {\n\treturn filePath.replace(/\\\\/g, '/');\n}\n","/**\n * `wp()` — thin composer for the four WP Vite plugins plus the two helpers.\n *\n * Top-level shortcuts cover the 90% case (just point at the dirs you have).\n * Per-plugin nested keys are the escape hatch for advanced options.\n *\n * - `blocksDir`, `blocksStylesDir`, `copyAssetsDir`, `adminPagesDir`: when\n * set, the corresponding plugin is included.\n * - `blocks`, `blockStyles`, `copyAssets`, `adminPages`, `externals`: pass\n * a full options object for that plugin. Nested keys win on conflict.\n * Pass `false` to disable the plugin entirely (overrides top-level).\n * - `externals` is always included by default (it has no required\n * options); pass `false` to disable. When `adminPagesDir` is set, its\n * resolved path is appended to the externals plugin's\n * `wpBuildAssetMatchers` so admin-page sidecars get the\n * `@wordpress/build` shape while block Script Modules keep the shape\n * WordPress core reads.\n * - `wpScriptIife` and `wpScriptDedupe` auto-included when\n * `buildType === 'script'` (a classic script has to be self-contained —\n * see docs/wp-script-dedupe.md).\n * - `wpCleanCssChunks` always included (it's a no-op without CSS-only\n * entries); pass `cleanCssChunks: false` to disable.\n * - `wpCssAssetInfo` always included (it's a no-op without CSS-only\n * entries); pass `cssAssetInfo: false` to disable.\n * - `wpDevServer` always included; it is `apply: 'serve'`, so a build never\n * sees it. Pass `devServer: false` to opt out. It reuses the same\n * directories and externals config the build plugins get, and shares a\n * live `moduleEntryMatchers` array with `wpExternals` so one dev server\n * can serve classic scripts and Script Modules at once.\n * - `wpDevServerPhp` is its `apply: 'build'` twin, added under the same\n * `devServer` switch: it emits `dist/dev-server.php` into every build so\n * the consumer's one `require_once` line is never a dead path.\n * - In module mode, a tiny inline `wp-module-entry-signatures` plugin sets\n * `build.rollupOptions.preserveEntrySignatures: 'exports-only'` unless\n * the user already set it themselves — see the comment on\n * `wpModuleEntrySignatures` below for why.\n *\n * For dual-pass (script + module) builds the consumer maps Vite mode to\n * `buildType` themselves:\n *\n * export default defineConfig(({ mode }) => ({\n * plugins: [\n * wp({\n * buildType: mode === 'modules' ? 'module' : 'script',\n * blocksDir: './includes/blocks',\n * }),\n * ],\n * }));\n */\nimport { resolve } from 'node:path';\nimport type { Plugin, UserConfig } from 'vite';\nimport { wpAdminPages, type WpAdminPagesOptions } from './wp-admin-pages';\nimport { wpBlocks, type WpBlocksOptions } from './wp-blocks';\nimport { wpBlockStyles, type WpBlockStylesOptions } from './wp-block-styles';\nimport { wpCopyAssets, type WpCopyAssetsOptions } from './wp-copy-assets';\nimport { wpExternals, DEFAULT_BUNDLED_PACKAGES, type WpExternalsOptions } from './wp-externals';\nimport { wpScriptDedupe } from './wp-script-dedupe';\nimport { wpScriptIife } from './wp-script-iife';\nimport { wpCleanCssChunks } from './wp-clean-css-chunks';\nimport { wpCssAssetInfo } from './wp-css-asset-info';\nimport { wpDevServer, wpDevServerPhp, type WpDevServerOptions } from './wp-dev-server';\n\n/**\n * A module-mode entry's export list IS its public contract: PHP registers it\n * with `wp_register_script_module()` and other code reaches it only through\n * WordPress's runtime import map, never through the build-time bundle graph.\n * Vite's app-build default, `preserveEntrySignatures: false`, tree-shakes an\n * entry's exports away whenever nothing in the graph imports them — which,\n * for these entries, is always. Worst case (`export * from 'focus-trap'`)\n * the built file comes out 0 bytes; short of that, an export gets stripped\n * while the module still emits, leaving importers with an empty namespace.\n * Either way the build succeeds silently.\n *\n * `preserveEntrySignatures: 'exports-only'` is the verified fix. This mirrors\n * `wpScriptIife`'s `define` injection: only fill in the setting if the user\n * config doesn't already have an opinion, so an explicit user value always\n * wins (Vite merges a plugin's `config()` result with the *plugin* winning\n * scalar conflicts, so the user check has to happen here, not via merge\n * order).\n */\nfunction wpModuleEntrySignatures(): Plugin {\n\treturn {\n\t\tname: 'wp-module-entry-signatures',\n\n\t\tconfig(userConfig: UserConfig) {\n\t\t\tif (userConfig.build?.rollupOptions?.preserveEntrySignatures !== undefined) return null;\n\t\t\treturn {\n\t\t\t\tbuild: { rollupOptions: { preserveEntrySignatures: 'exports-only' } },\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport interface WpOptions {\n\t/** Build mode for sub-plugins. Default: `'script'`. */\n\tbuildType?: 'script' | 'module';\n\n\t// Top-level convenience: pass a dir to enable the plugin.\n\tblocksDir?: string;\n\tblocksStylesDir?: string;\n\tcopyAssetsDir?: string;\n\tadminPagesDir?: string;\n\n\t/**\n\t * Per-plugin escape hatches. Pass `false` to disable; pass an object\n\t * to merge extra options into the sub-plugin. Nested wins on conflict.\n\t */\n\tblocks?: Partial<WpBlocksOptions> | false;\n\tblockStyles?: Partial<WpBlockStylesOptions> | false;\n\tcopyAssets?: Partial<WpCopyAssetsOptions> | false;\n\tadminPages?: Partial<WpAdminPagesOptions> | false;\n\texternals?: WpExternalsOptions | false;\n\t/**\n\t * The `apply: 'serve'` dev-server bridge — hot file, dev `.asset.php`\n\t * sidecars, blocks metadata, and the bare-specifier escape that keeps\n\t * Script Module entries servable. Included by default and completely inert\n\t * in a build; pass `false` to leave dev alone, or an object to override its\n\t * options (the directories and externals config are wired from the\n\t * top-level keys automatically).\n\t */\n\tdevServer?: WpDevServerOptions | false;\n\n\t/** Disable the auto-included script-IIFE helper. Default: enabled in script mode. */\n\tiife?: false;\n\t/**\n\t * Disable the auto-included per-entry module duplication. Default: enabled\n\t * in script mode. Without it, a module two script entries share becomes a\n\t * shared chunk each entry `import`s — invalid as a classic script.\n\t */\n\tscriptDedupe?: false;\n\t/** Disable the auto-included CSS-only-chunk cleanup. Default: always enabled. */\n\tcleanCssChunks?: false;\n\t/** Disable the auto-included CSS-only-entry `.asset.php` sidecars. Default: always enabled. */\n\tcssAssetInfo?: false;\n}\n\nexport function wp(options: WpOptions = {}): Plugin[] {\n\tconst buildType = options.buildType ?? 'script';\n\tconst plugins: Plugin[] = [];\n\t// Filled by wpExternals during the build, read by wpScriptIife at write time.\n\tconst globalsSink = new Map<string, string>();\n\n\t// The directories the dev-server bridge has to rediscover for itself, and\n\t// the two block options that change what it writes. Captured as each\n\t// plugin is composed so `wpDevServer` never re-derives them differently.\n\tlet activeBlocksDir: string | undefined;\n\tlet activeBlocksSkip: string[] | undefined;\n\tlet activeEmitManifest: boolean | undefined;\n\tlet activeBlockStylesDir: string | undefined;\n\n\t// wpBlocks\n\tif (options.blocks !== false) {\n\t\tconst blocksOptions = typeof options.blocks === 'object' ? options.blocks : undefined;\n\t\tconst blocksDir = blocksOptions?.blocksDir ?? options.blocksDir;\n\t\tif (blocksDir) {\n\t\t\tactiveBlocksDir = blocksDir;\n\t\t\tactiveBlocksSkip = blocksOptions?.skip;\n\t\t\tactiveEmitManifest = blocksOptions?.emitManifest;\n\t\t\tplugins.push(\n\t\t\t\twpBlocks({\n\t\t\t\t\tblocksDir,\n\t\t\t\t\tbuildType,\n\t\t\t\t\t...blocksOptions,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t// wpBlockStyles\n\tif (options.blockStyles !== false) {\n\t\tconst blockStylesOptions =\n\t\t\ttypeof options.blockStyles === 'object' ? options.blockStyles : undefined;\n\t\tconst blocksStylesDir = blockStylesOptions?.blocksStylesDir ?? options.blocksStylesDir;\n\t\tif (blocksStylesDir) {\n\t\t\tactiveBlockStylesDir = blocksStylesDir;\n\t\t\tplugins.push(\n\t\t\t\twpBlockStyles({\n\t\t\t\t\tblocksStylesDir,\n\t\t\t\t\t...blockStylesOptions,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t// wpCopyAssets\n\tif (options.copyAssets !== false) {\n\t\tconst copyAssetsOptions =\n\t\t\ttypeof options.copyAssets === 'object' ? options.copyAssets : undefined;\n\t\tconst copyAssetsDir = copyAssetsOptions?.copyAssetsDir ?? options.copyAssetsDir;\n\t\tif (copyAssetsDir) {\n\t\t\tplugins.push(\n\t\t\t\twpCopyAssets({\n\t\t\t\t\tcopyAssetsDir,\n\t\t\t\t\tbuildType,\n\t\t\t\t\t...copyAssetsOptions,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t// wpAdminPages\n\tlet activeAdminPagesDir: string | undefined;\n\tif (options.adminPages !== false) {\n\t\tconst adminPagesOptions =\n\t\t\ttypeof options.adminPages === 'object' ? options.adminPages : undefined;\n\t\tconst adminPagesDir = adminPagesOptions?.adminPagesDir ?? options.adminPagesDir;\n\t\tif (adminPagesDir) {\n\t\t\tactiveAdminPagesDir = adminPagesDir;\n\t\t\tplugins.push(\n\t\t\t\twpAdminPages({\n\t\t\t\t\tadminPagesDir,\n\t\t\t\t\tbuildType,\n\t\t\t\t\t...adminPagesOptions,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tconst externalsOptions = typeof options.externals === 'object' ? options.externals : undefined;\n\n\t// Admin pages are consumed by project PHP, not by core's block\n\t// registration, so their sidecars get the `@wordpress/build` shape.\n\t// Wiring the matcher here is what makes that zero-config.\n\tconst wpBuildAssetMatchers = [...(externalsOptions?.wpBuildAssetMatchers ?? [])];\n\tif (activeAdminPagesDir) {\n\t\tconst matcher = resolve(process.cwd(), activeAdminPagesDir).replace(/\\\\/g, '/');\n\t\tif (!wpBuildAssetMatchers.includes(matcher)) wpBuildAssetMatchers.push(matcher);\n\t}\n\n\t/**\n\t * Shared, deliberately *mutable*: `wpExternals` captures this array once and\n\t * consults it per file at transform time, and `wpDevServer` appends the\n\t * module-pass entries it discovers to it during `configResolved`. That live\n\t * hand-off is what lets a single dev server (which only ever has one\n\t * `buildType`) serve classic scripts and Script Modules side by side —\n\t * without asking the consumer to configure anything. In a build the array\n\t * only ever holds what the user passed, because `wpDevServer` is\n\t * `apply: 'serve'` and never runs.\n\t */\n\tconst moduleEntryMatchers = [...(externalsOptions?.moduleEntryMatchers ?? [])];\n\n\t// wpExternals — always included unless explicitly disabled.\n\tif (options.externals !== false) {\n\t\tplugins.push(\n\t\t\t...wpExternals({\n\t\t\t\tbuildType,\n\t\t\t\t...externalsOptions,\n\t\t\t\tmoduleEntryMatchers,\n\t\t\t\t// After the spread, deliberately: `globalsSink` is an internal\n\t\t\t\t// out-param, not user config. A consumer passing their own Map\n\t\t\t\t// through `externals: { globalsSink }` would otherwise sever the\n\t\t\t\t// wiring — wpExternals would fill their map, wpScriptIife would\n\t\t\t\t// read an empty one, and every shimmed `require()` would throw\n\t\t\t\t// at runtime with nothing said at build time.\n\t\t\t\tglobalsSink,\n\t\t\t\t...(wpBuildAssetMatchers.length > 0 ? { wpBuildAssetMatchers } : {}),\n\t\t\t}),\n\t\t);\n\t}\n\n\t// wpDevServer — serve-only, so this costs a build nothing.\n\tif (options.devServer !== false) {\n\t\tconst devServerOptions =\n\t\t\ttypeof options.devServer === 'object' ? options.devServer : undefined;\n\t\tplugins.push(\n\t\t\twpDevServer({\n\t\t\t\t// The mode the *declared* entries (`build.rollupOptions.input`)\n\t\t\t\t// are served in. Block and admin-page entries carry their own\n\t\t\t\t// verdict from discovery, so this only decides the project's own.\n\t\t\t\tbuildType,\n\t\t\t\t...(activeBlocksDir ? { blocksDir: activeBlocksDir } : {}),\n\t\t\t\t...(activeBlockStylesDir ? { blocksStylesDir: activeBlockStylesDir } : {}),\n\t\t\t\t...(activeAdminPagesDir ? { adminPagesDir: activeAdminPagesDir } : {}),\n\t\t\t\t...(activeBlocksSkip ? { skip: activeBlocksSkip } : {}),\n\t\t\t\t...(activeEmitManifest !== undefined ? { emitManifest: activeEmitManifest } : {}),\n\t\t\t\t// The dev dependency scan has to reach the same externalization\n\t\t\t\t// verdicts `wpExternals` does, so it gets the same inputs.\n\t\t\t\t...(externalsOptions?.projectRoot\n\t\t\t\t\t? { projectRoot: externalsOptions.projectRoot }\n\t\t\t\t\t: {}),\n\t\t\t\t...(externalsOptions?.externalNamespaces\n\t\t\t\t\t? { externalNamespaces: externalsOptions.externalNamespaces }\n\t\t\t\t\t: {}),\n\t\t\t\t...(externalsOptions?.additionalExternals\n\t\t\t\t\t? { additionalExternals: externalsOptions.additionalExternals }\n\t\t\t\t\t: {}),\n\t\t\t\t...(externalsOptions?.scriptModuleNamespaces\n\t\t\t\t\t? { scriptModuleNamespaces: externalsOptions.scriptModuleNamespaces }\n\t\t\t\t\t: {}),\n\t\t\t\t...(externalsOptions?.bundle\n\t\t\t\t\t? { bundledPackages: [...DEFAULT_BUNDLED_PACKAGES, ...externalsOptions.bundle] }\n\t\t\t\t\t: {}),\n\t\t\t\tmoduleEntryMatchers,\n\t\t\t\t...(wpBuildAssetMatchers.length > 0 ? { wpBuildAssetMatchers } : {}),\n\t\t\t\t...devServerOptions,\n\t\t\t}),\n\t\t);\n\t\t// The build-side twin: emits `dist/dev-server.php` into every build so\n\t\t// the consumer's `require_once` line is true whether or not a dev\n\t\t// server has ever run. Inert in a built site — no hot file, no work.\n\t\tplugins.push(\n\t\t\twpDevServerPhp(\n\t\t\t\tdevServerOptions?.phpPrefix ? { phpPrefix: devServerOptions.phpPrefix } : {},\n\t\t\t),\n\t\t);\n\t}\n\n\t// Helpers — auto-included; opt-out via `false`.\n\t// Position in this array is NOT what orders wpScriptDedupe's resolver.\n\t// It has to see every id before any other resolver answers — including\n\t// wpExternals' force-bundle resolver, pushed above — and it guarantees that\n\t// with a hook-level `order: 'pre'` instead, which no array shuffling here\n\t// (or by a consumer composing plugins by hand) can undo.\n\tif (buildType === 'script' && options.scriptDedupe !== false) {\n\t\tplugins.push(wpScriptDedupe());\n\t}\n\tif (buildType === 'script' && options.iife !== false) {\n\t\tplugins.push(wpScriptIife({ globals: globalsSink }));\n\t}\n\t// Always on: any CSS-only entry (per-block styles, theme stylesheets\n\t// passed as first-class entries) leaves an empty JS shim behind, and the\n\t// cleanup is a no-op when none exist.\n\tif (options.cleanCssChunks !== false) {\n\t\tplugins.push(wpCleanCssChunks());\n\t}\n\t// Always on for the same reason: a CSS-only entry gets no sidecar from\n\t// wpExternals (there's no JS chunk for its chunk walk to find), and this\n\t// is a no-op when every entry has a JS twin.\n\tif (options.cssAssetInfo !== false) {\n\t\tplugins.push(wpCssAssetInfo());\n\t}\n\t// Module-mode-only: script-mode entries are already self-contained by\n\t// construction (wpScriptDedupe partitions the graph, wpScriptIife fails\n\t// the build otherwise), so no export ever needs preserving there.\n\tif (buildType === 'module') {\n\t\tplugins.push(wpModuleEntrySignatures());\n\t}\n\n\treturn plugins;\n}\n"]}