// Simple Node-based headless-like test for built bundle const path = require('path'); const fs = require('fs'); // capture registrations const blockRegs = []; const formatRegs = []; const regsByName = {}; const formatsByName = {}; // Minimal fake implementations expected by the bundle global.window = { prompt: function (msg) { return null; }, wp: { blocks: { registerBlockType: function (name, settings) { blockRegs.push(name); regsByName[name] = settings || {}; }, getBlockType: function (name) { return null; } }, element: { createElement: function (tag, props) { // return a serializable placeholder const children = Array.prototype.slice.call(arguments, 2); return { tag: tag, props: props || null, children: children }; }, useState: function () { return [null, function () {}]; }, useEffect: function () {} }, blockEditor: { InnerBlocks: function () {}, InspectorControls: function () {}, RichText: { applyFormat: null, toggleFormat: null }, BlockControls: function () {}, ToolbarButton: function () {} }, components: { PanelBody: function () {}, SelectControl: function () {}, Spinner: function () {}, TextControl: function () {}, RangeControl: function () {}, ToolbarButton: function () {} }, richText: { registerFormatType: function (name, settings) { formatRegs.push(name); formatsByName[name] = settings || {}; }, getFormatType: function (name) { return null; } }, i18n: { __: function (s, domain) { return s; } }, data: {} } }; // require the built bundle const bundlePath = path.resolve(__dirname, '../assets/build/index.js'); if (!fs.existsSync(bundlePath)) { console.error('Built bundle not found at', bundlePath); process.exit(2); } try { require(bundlePath); } catch (err) { console.error('Error while executing bundle:', err && err.stack ? err.stack : err); process.exit(3); } // report findings const out = { blockRegistrations: blockRegs, formatRegistrations: formatRegs, hasContextBlock: blockRegs.indexOf('swi-foot/context') !== -1, hasInlineFormat: formatRegs.indexOf('swi-foot/inline-format') !== -1 }; console.log(JSON.stringify(out, null, 2)); process.exit(0);