• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
noche

noche

valwidgets

Public
Like
valwidgets
Home
Code
27
.cursor
.git
6
backend
3
bundle
2
dist
dist-r
dist-valtown
dist-valtown-ui
docs
frontend
3
npm
schemas
shared
1
src
valwidgets
3
.gitignore
.vtignore
NEWS.md
README.md
deno.json
deno.lock
index.html
H
main.http.tsx
package.json
tsconfig.json
vite.config.ts
widgets.json
Environment variables
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
Viewing readonly version of main branch: v76
View latest version
README.md

dswidgetsengine

Schema-driven widget engine for npm, Deno, and bindings (R via reactR, Python).
First version ships the Checkbox widget only.

Install

npm

npm install dswidgetsengine

Deno

import * as widgets from "npm:dswidgetsengine";

Usage

Schema runtime (validation and defaults)

import { validateCheckbox, getCheckboxDefaults, getSchema, applyDefaults, createValidator, } from "dswidgetsengine"; // Default config for a checkbox (then set a unique `id`) const defaults = getCheckboxDefaults(); // Validate and normalize a config (applies schema defaults, then validates) const result = validateCheckbox({ type: "checkbox", id: "my-checkbox", value: true, }); if (result.valid) { console.log(result.data); // full CheckboxConfig } else { console.log(result.errors); } // Load schema and validate generically const schema = getSchema("checkbox", 1); const validator = createValidator(schema); const out = validator({ type: "checkbox", id: "x", value: false });

React Checkbox (e.g. for reactR from R)

import { Checkbox } from "dswidgetsengine"; <Checkbox id="agree" label="I agree" value={checked} onChange={setChecked} />

Props match CheckboxConfig plus optional onChange(value: boolean).

Widget manifest (JSON con múltiples widgets)

Lee un JSON con varios widgets, aplica defaults y mantiene los valores actualizados:

import { WidgetForm, parseManifest, toManifestJSON } from "dswidgetsengine"; const manifest = { widgets: [ { type: "checkbox", id: "chk1", label: "Acepto", value: false }, { type: "radio", id: "r1", label: "Opción", choices: [...], selected: "a" }, ], }; <WidgetForm manifest={manifest} onChange={(values, getManifestJSON) => { console.log(values); // { chk1: true, r1: "b" } console.log(getManifestJSON()); // JSON con valores actualizados }} />

Formatos aceptados: { widgets: [...] }, [...] o string JSON. Los widgets siguen siendo usables por separado (<Checkbox ... />, <Radio ... />).

API

  • getSchema(widgetType, version?) – load widget JSON Schema
  • getRegisteredTypes() – list registered widget types
  • getDefaultsFromSchema(schema) – default values from schema
  • applyDefaults(schema, config) – merge config with schema defaults
  • createValidator(schema) – compile validator for a schema
  • validate(schema, data) – validate data against schema
  • validateCheckbox(config) – validate and normalize checkbox config
  • getCheckboxDefaults() – default CheckboxConfig
  • Checkbox – React component for checkbox widget
  • parseManifest(input) – parse and validate manifest JSON
  • getDefaultValues(manifest) – extract default values from manifest
  • manifestWithValues(manifest, values) – manifest with updated values
  • toManifestJSON(manifest, values) – serialize manifest as JSON

Build (Val Town only)

Esta rama está enfocada solo en despliegue para Val Town.

ComandoSalidaUso
npm run build:backendbundle/backend.jsRuntime backend para validación y manifest
npm run build:uibundle/ui.jsBundle React para render en browser
npm run build:valtownbundle/backend.js + bundle/ui.jsBuild completo para deploy

Estructura Val Town

backend/ index.ts widgets.ts frontend/ App.tsx main.tsx shared/ types.ts bundle/ backend.js ui.js widgets.json main.http.tsx

Deploy

  1. Ejecutar npm run build:valtown.
  2. Subir a Val Town:
    • main.http.tsx
    • bundle/backend.js
    • bundle/ui.js
    • widgets.json
  3. Usar .vtignore para excluir archivos no necesarios.

Schemas

Widget schemas live under schemas/<widget>/vN.schema.json (JSON Schema Draft-07).
Checkbox: schemas/checkbox/v1.schema.json.

License

MIT

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.