@10up/wp-vite-plugins 1.0.0-alpha.0

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.
@@ -0,0 +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-iife.ts","../src/wp-clean-css-chunks.ts","../src/wp.ts"],"names":["resolve","readFileSync","join","existsSync","fg","relative","extname","require","options","external","reachableChunks","handles"],"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,KAAK,CAAC,CAAA;AAC3D;AAGO,SAAS,YAAY,KAAA,EAAwB;AACnD,EAAA,OAAO,cAAA,CAAe,KAAK,KAAK,CAAA;AACj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;AAAA,UACA,GAAG;AAAA,SACH;AAAA,OACF;AAAA,IACD;AAAA,EACD;AAGA,EAAA,IAAI,OAAA,CAAQ,cAAc,KAAA,EAAO;AAChC,IAAA,MAAM,mBACL,OAAO,OAAA,CAAQ,SAAA,KAAc,QAAA,GAAW,QAAQ,SAAA,GAAY,MAAA;AAI7D,IAAA,MAAM,uBAAuB,CAAC,GAAI,gBAAA,EAAkB,oBAAA,IAAwB,EAAG,CAAA;AAC/E,IAAA,IAAI,mBAAA,EAAqB;AACxB,MAAA,MAAM,OAAA,GAAUF,QAAQ,OAAA,CAAQ,GAAA,IAAO,mBAAmB,CAAA,CAAE,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA;AAC9E,MAAA,IAAI,CAAC,oBAAA,CAAqB,QAAA,CAAS,OAAO,CAAA,EAAG,oBAAA,CAAqB,KAAK,OAAO,CAAA;AAAA,IAC/E;AACA,IAAA,OAAA,CAAQ,IAAA;AAAA,MACP,GAAG,WAAA,CAAY;AAAA,QACd,SAAA;AAAA,QACA,GAAG,gBAAA;AAAA,QACH,GAAI,oBAAA,CAAqB,MAAA,GAAS,IAAI,EAAE,oBAAA,KAAyB;AAAC,OAClE;AAAA,KACF;AAAA,EACD;AAGA,EAAA,IAAI,SAAA,KAAc,QAAA,IAAY,OAAA,CAAQ,IAAA,KAAS,KAAA,EAAO;AACrD,IAAA,OAAA,CAAQ,IAAA,CAAK,cAAc,CAAA;AAAA,EAC5B;AAIA,EAAA,IAAI,OAAA,CAAQ,mBAAmB,KAAA,EAAO;AACrC,IAAA,OAAA,CAAQ,IAAA,CAAK,kBAAkB,CAAA;AAAA,EAChC;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 */\nimport { extname, resolve, relative } from 'node:path';\nimport fg from 'fast-glob';\nimport type { Plugin } from 'vite';\n\nexport interface WpBlockStylesOptions {\n\tblocksStylesDir: string;\n}\n\nexport function wpBlockStyles(options: WpBlockStylesOptions): Plugin {\n\tlet stylesDirAbs: 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\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\tentries[`autoenqueue/${blockName}`] = filePath;\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\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 */\nimport { createRequire } from 'node:module';\nimport { readFileSync } from 'node:fs';\nimport { join } 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}\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 * 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 */\nimport crypto from 'node:crypto';\nimport { init, parse, type ImportSpecifier } from 'es-module-lexer';\nimport MagicString from 'magic-string';\nimport type { Plugin, Rollup } from 'vite';\nimport { camelize, isScriptModule, readPackageMetadata, splitImport } 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}\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\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 * 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// 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);\n\t\t\t} catch {\n\t\t\t\treturn null;\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\treturn [resolverPlugin, transformPlugin];\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 * 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 } from 'vite';\n\nexport function wpScriptIife(): Plugin {\n\treturn {\n\t\tname: 'wp-script-iife',\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\tawait writeFile(filePath, `(()=>{\\n${chunkSource}\\n})();\\n`);\n\t\t\t}\n\t\t},\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 * `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` auto-included when `buildType === 'script'`.\n * - `wpCleanCssChunks` always included (it's a no-op without CSS-only\n * entries); pass `cleanCssChunks: false` to disable.\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 } 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 { wpScriptIife } from './wp-script-iife';\nimport { wpCleanCssChunks } from './wp-clean-css-chunks';\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/** Disable the auto-included CSS-only-chunk cleanup. Default: always enabled. */\n\tcleanCssChunks?: 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\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\n\treturn plugins;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@10up/wp-vite-plugins",
3
+ "version": "1.0.0-alpha.0",
4
+ "description": "Vite plugins for building modern WordPress projects the 10up way.",
5
+ "keywords": [
6
+ "vite",
7
+ "vite-plugin",
8
+ "rolldown",
9
+ "wordpress",
10
+ "gutenberg",
11
+ "10up"
12
+ ],
13
+ "author": {
14
+ "name": "10up",
15
+ "email": "info@10up.com",
16
+ "url": "https://10up.com"
17
+ },
18
+ "license": "GPL-2.0-or-later",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/10up/wp-vite-plugins.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/10up/wp-vite-plugins/issues"
25
+ },
26
+ "homepage": "https://github.com/10up/wp-vite-plugins#readme",
27
+ "type": "module",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
35
+ "types": "./dist/index.d.ts",
36
+ "files": [
37
+ "dist",
38
+ "README.md",
39
+ "LICENSE"
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "tag": "beta"
44
+ },
45
+ "engines": {
46
+ "node": ">=20.11"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "dev": "tsup --watch",
51
+ "test": "vitest run",
52
+ "test:watch": "vitest",
53
+ "lint": "eslint .",
54
+ "format": "prettier --write \"src/**/*.{ts,js,json}\"",
55
+ "typecheck": "tsc --noEmit",
56
+ "prepublishOnly": "npm run build",
57
+ "changeset": "changeset",
58
+ "prepare": "husky"
59
+ },
60
+ "dependencies": {
61
+ "es-module-lexer": "^2.1.0",
62
+ "fast-glob": "^3.3.3",
63
+ "magic-string": "^0.30.21"
64
+ },
65
+ "peerDependencies": {
66
+ "vite": "^8.0.0"
67
+ },
68
+ "devDependencies": {
69
+ "@changesets/cli": "^2.27.0",
70
+ "@eslint/js": "^9.0.0",
71
+ "@types/node": "^22.0.0",
72
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
73
+ "@typescript-eslint/parser": "^8.0.0",
74
+ "eslint": "^9.0.0",
75
+ "eslint-config-prettier": "^9.1.0",
76
+ "globals": "^17.6.0",
77
+ "husky": "^9.1.0",
78
+ "lint-staged": "^15.2.0",
79
+ "prettier": "^3.3.0",
80
+ "tsup": "^8.3.0",
81
+ "typescript": "^5.6.0",
82
+ "vite": "^8.0.0",
83
+ "vitest": "^4.1.8"
84
+ }
85
+ }