TEXT PROMPT

Framework Forge JavaScript UI Builder

Prompt

Build “Framework Forge”, a developer tool for creating small, customizable JavaScript UI frameworks from modular building blocks.

This must be a working application, not a landing page or a mock dashboard. Users should be able to configure a framework, inspect and edit its generated source files, try it in a live playground, and download a standalone project.

## Product goal

Help developers design their own framework instead of merely scaffolding an application built with an existing framework.

The generated output must contain the framework’s implementation, a working example application, basic tests, and documentation. It must not depend on Framework Forge at runtime.

## Scope

Build a focused MVP for client-side UI frameworks only.

Include:
- A small DOM rendering core.
- Optional reactive state.
- Optional hash-based routing.
- Optional lifecycle hooks.
- A configurable framework name.
- An editable source-code workspace.
- A live playground.
- Downloadable project export.

Do not implement SSR, backend frameworks, authentication, billing, collaboration, AI integrations, or a plugin marketplace.

## Technology

Use:
- React and TypeScript for the builder interface.
- Vite for development and production builds.
- Tailwind CSS for styling.
- Monaco Editor for source editing.
- JSZip for ZIP export.
- Vitest for generator and generated-framework tests.

Generate the framework itself as readable vanilla JavaScript using ES modules. Do not use React or another UI framework inside the generated framework.

Keep the builder’s dependencies separate from the generated project’s dependencies.

## Main interface

Create a responsive, developer-focused workspace with:

1. Left sidebar: framework configuration.
2. Center panel: file explorer and tabbed code editor.
3. Right panel: live preview and captured console output.
4. Top toolbar: project name, regenerate, run, reset, and download actions.

Use a restrained dark theme, readable typography, clear borders, and accessible controls. On smaller screens, let users switch between configuration, code, and preview tabs.

Do not spend time building a marketing homepage.

## Configuration

Support:
- Framework name.
- Derived npm package name with validation.
- Reactive state: enabled or disabled.
- Hash router: enabled or disabled.
- Lifecycle hooks: enabled or disabled.

Use “Nava” as the initial example name.

Validate names and never interpolate unchecked user input directly into executable JavaScript.

Store configuration and edited files locally with a versioned localStorage format.

Changing configuration must not silently overwrite edited files. Mark the configuration as changed and require an explicit regeneration action. Ask for confirmation before discarding edits.

## Generated framework API

Implement a small, coherent API such as:

import { element, mount, state } from "nava";

const count = state(0);

const app = element(
"button",
{
onClick: () => count.value++
},
() => `Count: ${count.value}`
);

const unmount = mount(app, document.querySelector("#app"));

Define the behavior clearly:

- element(tag, props, ...children) creates a DOM element.
- Children may include text, numbers, DOM nodes, nested arrays, and reactive getter functions.
- null, undefined, and booleans do not render visible text.
- onClick and other supported event props register event listeners.
- Text content must be inserted safely using text nodes, not innerHTML.
- state(initialValue) exposes a reactive .value property.
- Reactive getter children update when their tracked state dependencies change.
- Dependency subscriptions must be cleaned up when a mounted tree is unmounted.
- mount() returns an unmount function.
- Event listeners and other registered resources must also be disposed during unmount.

Keep the rendering model intentionally small. Do not build a virtual DOM or JSX compiler.

When reactive state is disabled:
- Do not generate or export the state module.
- Generate a working nonreactive example.
- Explain any unsupported reactive behavior in the generated documentation.

## Optional router

When enabled, generate a minimal hash router with:
- Route registration.
- A route outlet.
- Navigation.
- A not-found view.
- Cleanup of hashchange listeners and the previous route’s mounted content.

Include a small two-page example.

Use hash-based routing so the exported demo does not require server-side fallback configuration.

## Optional lifecycle hooks

When enabled, provide clearly scoped mount and cleanup hooks.

Document where hooks may be registered and when they run. Avoid implicit global lifecycle state that breaks with multiple mounted trees.

When disabled, omit the lifecycle module and its public exports.

## Generator architecture

Build a deterministic generator:

generateProject(config) => Record

Its output should map relative file paths to file contents.

Keep generation logic independent from the React interface. Use readable template modules and shared configuration validation.

The same configuration should produce the same files and contents.

Generate only the selected modules. Ensure all imports, exports, examples, tests, and documentation remain consistent with the selected options.

Suggested exported structure:

nava
package.json
README.md
index.html
src
index.js
core
element.js
mount.js
cleanup.js
state
index.js
router
index.js
lifecycle
index.js
examples
main.js
tests
core.test.js
state.test.js
router.test.js
vite.config.js

Optional directories and tests must be omitted when their features are disabled.

Include the dependencies and scripts required for the exported project to support:

npm install
npm run dev
npm test
npm run build

The exported example must import the locally generated framework, not an unrelated package from a registry.

## Editor and playground

- Show generated files in a file tree.
- Allow editing of generated text files.
- Track unsaved or modified files visually.
- Run the current edited files, not a separate hardcoded implementation.
- Provide an explicit Run button.
- Clearly show when the preview is out of date.
- Display syntax errors and runtime errors without crashing the builder.
- Capture console.log, console.warn, console.error, and unhandled rejections.
- Include a clear-console action.

For the MVP, preview source files should use browser-native ES modules and relative imports. You do not need to implement an arbitrary npm dependency bundler.

Implement local module resolution deliberately, for example by producing Blob module URLs in dependency order for the generated acyclic module graph. Report missing modules, unsupported imports, and circular dependencies clearly.

Run preview code in a sandboxed iframe:
- Use allow-scripts without allow-same-origin.
- Do not execute generated code in the parent application.
- Recreate the iframe for a fresh run.
- Use a restricted preview CSP to block network connections and unnecessary external resources.
- Validate postMessage events against the current iframe window and expected message schema.
- Revoke Blob URLs and remove listeners when they are no longer needed.

Explain the preview’s limitations honestly. Do not describe the sandbox as a complete security boundary for hostile code or a guarantee against infinite loops.

## Export

Download the current workspace as a ZIP file.

Export edited files exactly as shown in the editor, rather than silently regenerating them.

The ZIP must include:
- Framework implementation.
- Working example.
- package.json and development configuration.
- Relevant tests.
- README.

The generated README should explain:
- What the framework includes.
- How to install and run the example.
- Public API usage.
- Reactivity and cleanup behavior.
- Routing, if enabled.
- Known limitations.
- How to extend the generated code.

## Tests and acceptance criteria

Add meaningful tests for:
- Deterministic generation.
- Configuration validation.
- All combinations of the three optional features.
- Consistent imports and exports.
- Basic DOM rendering.
- Event handling.
- Reactive updates when enabled.
- Subscription cleanup after unmount.
- Router navigation and cleanup when enabled.
- Correct omission of disabled modules.

The implementation is complete when:
1. The builder runs locally.
2. Changing configuration changes the generated project.
3. Editing a source file affects the next preview run.
4. The default counter works with reactive state enabled.
5. The nonreactive configuration also produces a working demo.
6. Routing works when selected.
7. Errors appear in the playground console.
8. Downloaded projects can run independently of the builder.
9. Implemented tests pass.

## Implementation priorities

Build a working vertical slice first:
configuration → generation → editor → preview → ZIP export.

Then add optional features, persistence, tests, and visual polish.

Prefer simple, maintainable code over unnecessary abstractions. Do not add placeholder buttons, fake terminal output, mocked functionality, or TODOs for core features.

If a requirement cannot be completed, identify it explicitly rather than pretending it works.

Start implementing the application. At the end, summarize what was built, how to run it, which tests were actually executed, and any remaining limitations.
Be the first to rate this article.

Discussion

Comments & Questions (0)

Captcha
Please be respectful — let's keep the conversation friendly.

No comments yet

Be the first to comment!