@wordpress/build 0.4.1-next.8b30e05b0.0 → 0.4.1-next.8fd3f8831.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.
- package/.cache/tsconfig.tsbuildinfo +1 -1
- package/README.md +54 -6
- package/package.json +6 -8
- package/src/build.mjs +175 -59
- package/src/dependency-graph.mjs +36 -110
- package/src/package-utils.mjs +45 -10
- package/src/php-generator.mjs +8 -3
- package/src/route-utils.mjs +13 -4
- package/src/wordpress-externals-plugin.mjs +78 -15
- package/templates/module-registration.php.template +1 -1
- package/templates/page-wp-admin.php.template +65 -28
- package/templates/page.php.template +2 -2
- package/templates/routes-registration.php.template +2 -2
- package/templates/script-registration.php.template +1 -1
- package/templates/style-registration.php.template +1 -1
|
@@ -128,8 +128,16 @@ if ( ! function_exists( '{{PAGE_SLUG_UNDERSCORE}}_wp_admin_enqueue_scripts' ) )
|
|
|
128
128
|
* @param string $hook_suffix The current admin page.
|
|
129
129
|
*/
|
|
130
130
|
function {{PAGE_SLUG_UNDERSCORE}}_wp_admin_enqueue_scripts( $hook_suffix ) {
|
|
131
|
-
//
|
|
132
|
-
|
|
131
|
+
// Check all possible ways this page can be accessed:
|
|
132
|
+
// 1. Menu page via admin.php?page={{PAGE_SLUG}}-wp-admin (plugin)
|
|
133
|
+
// 2. Direct file via {{PAGE_SLUG}}.php (Core) - screen ID will be '{{PAGE_SLUG}}'
|
|
134
|
+
$current_screen = get_current_screen();
|
|
135
|
+
$is_our_page = (
|
|
136
|
+
( isset( $_GET['page'] ) && '{{PAGE_SLUG}}-wp-admin' === $_GET['page'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
137
|
+
( $current_screen && '{{PAGE_SLUG}}' === $current_screen->id )
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
if ( ! $is_our_page ) {
|
|
133
141
|
return;
|
|
134
142
|
}
|
|
135
143
|
|
|
@@ -143,7 +151,7 @@ if ( ! function_exists( '{{PAGE_SLUG_UNDERSCORE}}_wp_admin_enqueue_scripts' ) )
|
|
|
143
151
|
$routes = get_{{PAGE_SLUG_UNDERSCORE}}_wp_admin_routes();
|
|
144
152
|
|
|
145
153
|
// Get boot module asset file for dependencies
|
|
146
|
-
$asset_file =
|
|
154
|
+
$asset_file = __DIR__ . '/../../modules/boot/index.min.asset.php';
|
|
147
155
|
if ( file_exists( $asset_file ) ) {
|
|
148
156
|
$asset = require $asset_file;
|
|
149
157
|
|
|
@@ -198,7 +206,7 @@ if ( ! function_exists( '{{PAGE_SLUG_UNDERSCORE}}_wp_admin_enqueue_scripts' ) )
|
|
|
198
206
|
// Dummy script module to ensure dependencies are loaded
|
|
199
207
|
wp_register_script_module(
|
|
200
208
|
'{{PAGE_SLUG}}-wp-admin',
|
|
201
|
-
|
|
209
|
+
{{BASE_URL}} . '/pages/{{PAGE_SLUG}}/loader.js',
|
|
202
210
|
$boot_dependencies
|
|
203
211
|
);
|
|
204
212
|
|
|
@@ -218,6 +226,59 @@ if ( ! function_exists( '{{PAGE_SLUG_UNDERSCORE}}_wp_admin_render_page' ) ) {
|
|
|
218
226
|
*/
|
|
219
227
|
function {{PAGE_SLUG_UNDERSCORE}}_wp_admin_render_page() {
|
|
220
228
|
?>
|
|
229
|
+
<style>
|
|
230
|
+
/* Critical styles to prevent layout shifts - inlined for immediate application */
|
|
231
|
+
|
|
232
|
+
/* Background colors */
|
|
233
|
+
#wpwrap {
|
|
234
|
+
background: var(--wpds-color-fg-content-neutral, #1e1e1e);
|
|
235
|
+
overflow-y: auto;
|
|
236
|
+
}
|
|
237
|
+
body {
|
|
238
|
+
background: #fff;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* Reset wp-admin padding */
|
|
242
|
+
#wpcontent {
|
|
243
|
+
padding-left: 0;
|
|
244
|
+
}
|
|
245
|
+
#wpbody-content {
|
|
246
|
+
padding-bottom: 0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* Hide legacy admin elements */
|
|
250
|
+
#wpbody-content > div:not(.boot-layout-container):not(#screen-meta) {
|
|
251
|
+
display: none;
|
|
252
|
+
}
|
|
253
|
+
#wpfooter {
|
|
254
|
+
display: none;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* Accessibility regions */
|
|
258
|
+
.a11y-speak-region {
|
|
259
|
+
left: -1px;
|
|
260
|
+
top: -1px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* Admin menu indicators */
|
|
264
|
+
ul#adminmenu a.wp-has-current-submenu::after,
|
|
265
|
+
ul#adminmenu > li.current > a.current::after {
|
|
266
|
+
border-right-color: #fff;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* Media frame fix */
|
|
270
|
+
.media-frame select.attachment-filters:last-of-type {
|
|
271
|
+
width: auto;
|
|
272
|
+
max-width: 100%;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/* Responsive overflow fix for #wpwrap */
|
|
276
|
+
@media (min-width: 782px) {
|
|
277
|
+
#wpwrap {
|
|
278
|
+
overflow-y: initial;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
</style>
|
|
221
282
|
<div id="{{PAGE_SLUG}}-wp-admin-app" class="boot-layout-container"></div>
|
|
222
283
|
<?php
|
|
223
284
|
}
|
|
@@ -226,27 +287,3 @@ if ( ! function_exists( '{{PAGE_SLUG_UNDERSCORE}}_wp_admin_render_page' ) ) {
|
|
|
226
287
|
// Hook the enqueue function to admin_enqueue_scripts
|
|
227
288
|
add_action( 'admin_enqueue_scripts', '{{PAGE_SLUG_UNDERSCORE}}_wp_admin_enqueue_scripts' );
|
|
228
289
|
|
|
229
|
-
if ( ! function_exists( '{{PAGE_SLUG_UNDERSCORE}}_wp_admin_register_page' ) ) {
|
|
230
|
-
/**
|
|
231
|
-
* Register the {{PAGE_SLUG}}-wp-admin base page handler.
|
|
232
|
-
* This is hidden from the menu but provides the page callback for URL routing.
|
|
233
|
-
* Visible menu items should use the full URL pattern with query parameters.
|
|
234
|
-
*
|
|
235
|
-
* Example:
|
|
236
|
-
* $url = admin_url( 'admin.php?page={{PAGE_SLUG}}-wp-admin&p=' . urlencode( '/your/route' ) );
|
|
237
|
-
* add_menu_page( 'Title', 'Menu', 'capability', $url, '', 'icon', 10 );
|
|
238
|
-
*/
|
|
239
|
-
function {{PAGE_SLUG_UNDERSCORE}}_wp_admin_register_page() {
|
|
240
|
-
add_submenu_page(
|
|
241
|
-
'nothing-{{PAGE_SLUG}}', // Hidden page (no parent)
|
|
242
|
-
__( '{{PAGE_SLUG}} (WP Admin)', '{{PREFIX}}' ), // Page title
|
|
243
|
-
__( '{{PAGE_SLUG}} (WP Admin)', '{{PREFIX}}' ), // Menu title (not visible)
|
|
244
|
-
'read', // Minimum capability
|
|
245
|
-
'{{PAGE_SLUG}}-wp-admin', // Menu slug for URL routing
|
|
246
|
-
'{{PAGE_SLUG_UNDERSCORE}}_wp_admin_render_page' // Callback function
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Hook the registration to admin_menu
|
|
252
|
-
add_action( 'admin_menu', '{{PAGE_SLUG_UNDERSCORE}}_wp_admin_register_page' );
|
|
@@ -152,7 +152,7 @@ if ( ! function_exists( '{{PAGE_SLUG_UNDERSCORE}}_render_page' ) ) {
|
|
|
152
152
|
$routes = get_{{PAGE_SLUG_UNDERSCORE}}_routes();
|
|
153
153
|
|
|
154
154
|
// Get boot module asset file for dependencies
|
|
155
|
-
$asset_file =
|
|
155
|
+
$asset_file = __DIR__ . '/../../modules/boot/index.min.asset.php';
|
|
156
156
|
if ( file_exists( $asset_file ) ) {
|
|
157
157
|
$asset = require $asset_file;
|
|
158
158
|
|
|
@@ -213,7 +213,7 @@ if ( ! function_exists( '{{PAGE_SLUG_UNDERSCORE}}_render_page' ) ) {
|
|
|
213
213
|
// Dummy script module to ensure dependencies are loaded
|
|
214
214
|
wp_register_script_module(
|
|
215
215
|
'{{PAGE_SLUG}}',
|
|
216
|
-
|
|
216
|
+
{{BASE_URL}} . '/pages/{{PAGE_SLUG}}/loader.js',
|
|
217
217
|
$boot_dependencies
|
|
218
218
|
);
|
|
219
219
|
|
|
@@ -41,7 +41,7 @@ $register_routes_callback = function ( $page_routes, $page_slug_underscore, $reg
|
|
|
41
41
|
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
|
|
42
42
|
wp_register_script_module(
|
|
43
43
|
$content_handle,
|
|
44
|
-
|
|
44
|
+
{{BASE_URL}} . '/routes/' . $route['name'] . '/content' . $extension,
|
|
45
45
|
$content_asset['module_dependencies'] ?? array(),
|
|
46
46
|
$content_asset['version'] ?? false
|
|
47
47
|
);
|
|
@@ -57,7 +57,7 @@ $register_routes_callback = function ( $page_routes, $page_slug_underscore, $reg
|
|
|
57
57
|
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
|
|
58
58
|
wp_register_script_module(
|
|
59
59
|
$route_handle,
|
|
60
|
-
|
|
60
|
+
{{BASE_URL}} . '/routes/' . $route['name'] . '/route' . $extension,
|
|
61
61
|
$route_asset['module_dependencies'] ?? array(),
|
|
62
62
|
$route_asset['version'] ?? false
|
|
63
63
|
);
|
|
@@ -75,7 +75,7 @@ if ( ! function_exists( '{{PREFIX}}_register_package_scripts' ) ) {
|
|
|
75
75
|
{{PREFIX}}_override_script(
|
|
76
76
|
$scripts,
|
|
77
77
|
$script_data['handle'],
|
|
78
|
-
|
|
78
|
+
{{BASE_URL}} . '/scripts/' . $script_data['path'] . $extension,
|
|
79
79
|
$dependencies,
|
|
80
80
|
$version,
|
|
81
81
|
true
|
|
@@ -59,7 +59,7 @@ if ( ! function_exists( '{{PREFIX}}_register_package_styles' ) ) {
|
|
|
59
59
|
{{PREFIX}}_override_style(
|
|
60
60
|
$styles,
|
|
61
61
|
$style_data['handle'],
|
|
62
|
-
|
|
62
|
+
{{BASE_URL}} . '/styles/' . $style_data['path'] . '.css',
|
|
63
63
|
$style_data['dependencies'],
|
|
64
64
|
$default_version
|
|
65
65
|
);
|