Build and test locally
A live preview sandbox for UI plugins, and an offline test pattern for library and dbs plugins, both run from the plugin's own folder.
Every plugin folder under plugins/@xuda.io/ builds with Vite (npm run dev / npm run build
inside the plugin's own directory), and each kind has its own pattern for trying the plugin out
before it is uploaded anywhere.
UI plugins: the plugin-sandbox live preview
@xuda.io/plugin-sandbox is a small package that renders a live configurator for one UI plugin: a
dropdown per property, a preview pane that re-renders as you change them. A UI plugin's
tests/index.html wires it up directly against the plugin's own source, no build step needed:
initializeUiPlugin(el, plugin, properties, previewHtml) takes the runtime module, the property
schema, and the HTML to preview the plugin against. Run npm run dev in the plugin's folder
(Vite serves tests/ as the root, per the plugin's vite.config.js) to open it.
Library and dbs plugins: an offline test script
A plugin whose work happens in server.mjs tests itself with a plain Node script rather than a
browser sandbox. xuda-library-plugin-xlsx is the pattern to follow: server.mjs exports an
internals object with its pure functions (normalize_book, render_book, load_workbook,
apply_operations, cell_value_of, ...), and tests/local.mjs imports { internals } and
exercises them directly, no drive, no AI, no platform connection:
which runs node ./tests/local.mjs (see the plugin's package.json scripts.test:local). Writing
the exercised logic as named exports on internals is what makes this possible; a server.mjs
that keeps everything as unexported local functions has nothing a test script can call.
plugin_tester/
plugin_tester/ at the repo root is an older tester: index.html boots a full
xuda-runtime-slim.js page against _default/xu-single-page markup, and index.js is a
jQuery-based plugin runner (func.UI.widgets, $(el), fields_ret = get_fields_data(...))
calling a ppi.xuda.io plugin API. Its shape (jQuery, xu-single-page, a ppi.xuda.io endpoint,
looking for runtime/index.js rather than runtime.mjs) does not match the manifest, kinds and
fn(plugin_name, element, properties) runtime signature documented on this section's other pages,
and none of the plugins under plugins/@xuda.io/ reference it. It looks like it predates the
current plugin-sandbox workflow rather than being the maintained way to test a plugin locally.