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

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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,CAAK,cAAc,CAAA;AAAA,EAC5B;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 * 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.** An `enforce: 'pre'` `resolveId` hook tags\n * every resolved id with `?wp-entry=<marker>` inherited from its importer.\n * An untagged importer *is* an entry, so it mints the marker — no entry\n * list needed. Rolldown then sees N distinct ids for one file and inlines a\n * private copy per entry. Externals, `\\0` virtual ids, ids that already\n * carry a query and non-JS files pass through untouched.\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 * 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\tif (imports.length > 0) return null;\n\n\t// Rolldown emits a single trailing `export { local as exported, … };` for\n\t// these chunks. Anything else (re-exports, `export default`, live bindings)\n\t// is out of scope.\n\tconst body = code.replace(/^[ \\t]*export\\s*\\{[^}]*\\}\\s*;?[ \\t]*$/gm, '');\n\tif (body === code && exports.length > 0) return null;\n\tif (/^\\s*(?:import|export)\\b/m.test(body)) return null;\n\n\tconst returned = exports\n\t\t.map((record) => `${objectKey(record.n)}: ${record.ln ?? record.n}`)\n\t\t.join(', ');\n\treturn `(() => {\\n${body.trim()}\\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\tasync resolveId(source, importer, options) {\n\t\t\t// No importer → this is an entry. Entries keep their clean id, and\n\t\t\t// being untagged is what makes them mint a marker for their subtree.\n\t\t\tif (!importer) return null;\n\t\t\tif (source.includes('\\0')) return null;\n\n\t\t\tconst key = `${importer}\\n${source}`;\n\t\t\tif (inFlight.has(key)) return null;\n\t\t\tconst marker = markerOf(importer) ?? mintMarker(importer);\n\n\t\t\tinFlight.add(key);\n\t\t\tlet resolved: Rollup.ResolvedId | null;\n\t\t\ttry {\n\t\t\t\tresolved = await this.resolve(\n\t\t\t\t\tstripEntryMarker(source),\n\t\t\t\t\tstripEntryMarker(importer),\n\t\t\t\t\t{\n\t\t\t\t\t\t// `kind` rides along so plugins keying on `require-call`\n\t\t\t\t\t\t// (wpExternals' CJS shim) still see the truth.\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tskipSelf: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tinFlight.delete(key);\n\t\t\t}\n\n\t\t\tif (!resolved || resolved.external) return resolved;\n\t\t\tif (!isPartitionable(resolved.id)) return resolved;\n\t\t\treturn { ...resolved, id: withMarker(resolved.id, marker) };\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// Dedupe first: it partitions the module graph so no script entry is left\n\t// importing a shared chunk, which is what makes the IIFE wrapper legal.\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.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;AAC7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,IAAA,CAAK,cAAc,CAAA;AAAA,EAC5B;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 * 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"]}