ypy

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 2 Imported by: 0

README

YPY

ypy-develop/ypy

The hypermedia framework: any element issues a request and swaps the HTML the server returns.

YPY (from Old Tupi ypy: origin, foundation) is a hypermedia-oriented JavaScript framework. Any HTML element can issue an HTTP request and swap the HTML fragment the server returns into the page. No build step, no runtime dependencies, one script tag.

What this is

The browser side of the YPY conversation: the core (src/ypy.js), the extensions (src/ext/), the TypeScript types, the editor data and the Go tool ypy that builds, tests, checks and migrates. The server side for Go is a separate repository, ypy-develop/go.

The documentation lives on the website, ypy.dev, not in this repository.

Install

Load one script. dist/ holds the built files (ypy.min.js, ypy.max.min.js with every extension, and one file per extension under dist/ext/); to build them yourself you need Go 1.26 or later:

go run ./cmd/ypy build

The version is written once, in the file VERSION at the root; the build stamps it into ypy.version.

Source maps

Each .min.js of dist/ ends with //# sourceMappingURL=<name>.map and sits next to its .map, which is what a CDN serves and what DevTools follows. If you copy or embed only the .min.js (into a Go binary, a bundle, your own static/ directory), DevTools asks for a .map that is not there and logs a 404. Use the same files from dist/embed/ instead: dist/embed/ypy.min.js, dist/embed/ypy.esm.min.js, dist/embed/ypy.max.min.js and dist/embed/ext/*.min.js are byte for byte the code of dist/, without the comment. To debug an embedded file with the map, copy the .map next to the .min.js from dist/ and add the comment back.

Use

<script src="/dist/ypy.min.js"></script>

<button ypy-post="/clicked" ypy-target="#result" ypy-swap="outerHTML">Click me</button>
<div id="result"></div>

The server answers /clicked with an HTML fragment, and YPY swaps it into #result. Attributes are ypy-* or data-ypy-*, headers are YPY-*, events are ypy:*.

Learn more

Develop

go run ./cmd/ypy test  # the browser tests (needs Chrome or Chromium)
go run ./cmd/ypy ci    # every gate, as in CI

Each command has --help. See CONTRIBUTING.md before sending a change, SECURITY.md to report a problem and CHANGELOG.md for what changed.

License

MIT. See LICENSE.

Documentation

Overview

Package ypy holds the one version of the repository. The file VERSION at the root is the source: the build stamps it into the core (ypy.version), `ypy gen` writes it into the editor data, and the tools report it through Version.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version is the content of the VERSION file, for example "0.1.1".

Types

This section is empty.

Directories

Path Synopsis
cmd
ypy command
Command ypy is the YPY toolbox: one binary, explicit subcommands.
Command ypy is the YPY toolbox: one binary, explicit subcommands.
examples
server command
Command server is the example server of the end to end suite.
Command server is the example server of the end to end suite.
internal
assets
Package assets implements "ypy gen assets": it takes the CSS and the small scripts an author writes next to a template and extracts them into files whose names carry a hash of their content, so the page that results has nothing inline and passes a strict Content-Security-Policy.
Package assets implements "ypy gen assets": it takes the CSS and the small scripts an author writes next to a template and extracts them into files whose names carry a hash of their content, so the page that results has nothing inline and passes a strict Content-Security-Policy.
bench
Package bench is "ypy bench": the performance harness of the framework.
Package bench is "ypy bench": the performance harness of the framework.
browsers
Package browsers finds and drives the browsers that run the YPY test suites: Chrome or Chromium through the DevTools protocol (chromedp), Safari through safaridriver and Firefox through geckodriver (the WebDriver HTTP protocol).
Package browsers finds and drives the browsers that run the YPY test suites: Chrome or Chromium through the DevTools protocol (chromedp), Safari through safaridriver and Firefox through geckodriver (the WebDriver HTTP protocol).
build
Package build generates the dist/ directory of the framework from src/: the unminified and minified bundles (script and ES module), the extensions, the ypy.max bundle, the editor files, the skills, the type declarations and the brotli copies.
Package build generates the dist/ directory of the framework from src/: the unminified and minified bundles (script and ES module), the extensions, the ypy.max bundle, the editor files, the skills, the type declarations and the brotli copies.
cli
Package cli is the small command framework behind the ypy binary: an explicit list of subcommands, a usage printer and a flag parser that accepts flags and positional arguments in any order.
Package cli is the small command framework behind the ypy binary: an explicit list of subcommands, a usage printer and a flag parser that accepts flags and positional arguments in any order.
e2e
Package e2e runs the end to end scenarios of the example app (examples/native), driven in Chrome, Firefox and Safari against the Go example server (examples/server).
Package e2e runs the end to end scenarios of the example app (examples/native), driven in Chrome, Firefox and Safari against the Go example server (examples/server).
gates
Package gates is "ypy ci": the checks every change passes before it is pushed.
Package gates is "ypy ci": the checks every change passes before it is pushed.
gen
Package gen is "ypy gen": it reads the table of YPY names (src/attributes.json and one fragment per extension in src/attributes.d/) and generates the editor data from it: the VS Code HTML Custom Data, the JetBrains web-types and the JSON schema of ypy.config.
Package gen is "ypy gen": it reads the table of YPY names (src/attributes.json and one fragment per extension in src/attributes.d/) and generates the editor data from it: the VS Code HTML Custom Data, the JetBrains web-types and the JSON schema of ypy.config.
styling
Package styling holds the checks of the styling contract of the framework (MISSION section 7): the optional stylesheet and the Tailwind variants in src/css, the names the core and the extensions put on elements, and the CSS fixtures of the visual matrix.
Package styling holds the checks of the styling contract of the framework (MISSION section 7): the optional stylesheet and the Tailwind variants in src/css, the names the core and the extensions put on elements, and the CSS fixtures of the visual matrix.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL