Hyperfun
Tiny JavaScript packages to build Front End applications
Install / Use
/learn @gc-victor/HyperfunREADME
hyperfun
Tiny JavaScript packages to build Front End applications.
Packages
| Package | Version | Dependencies | DevDependencies |
|--------|-------|------------|----------|
| run | |
|
|
| router |
|
|
|
| dom |
|
|
|
| component |
|
|
|
- run: template agnostic package to create an unidirectional user interface architecture
- router: hyperfun plugin to integrate a router in your hyperfun applications
- dom: Hyper Script Helpers and Incremental DOM/String mixed to create a template engine that can be rendered on the server and the client
- component: designed to be used in those cases when is needed to re-render a part of the app or when an action has to be executed in the life cycle. It uses Incremental DOM as a dependency to render and update the DOM tree
Example:
import { run, update } from '@hyperfun/run';
import { h1, li, p, patch, ul } from '@hyperfun/dom';
/* Types */
interface CounterState {
counter: number;
}
/* State */
const state: CounterState = {
counter: 0
};
/* Update */
const increment = () =>
update({
type: 'INCREMENT_COUNTER',
payload: (state: State) => ({ counter: state.counter + 1 }),
});
const decrement = () =>
update({
type: 'DECREMENT_COUNTER',
payload: (state: State) => ({ counter: state.counter - 1 }),
});
const reset = () =>
update({
type: 'RESET_COUNTER',
payload: () => ({ counter: 0 }),
});
/* View */
const counter = (state: CounterState) => p([state.counter]);
const view: View = (state: CounterState) =>
section([
counter(state),
ul([
li([button({ onClick: increment }, 'Increase')]),
li([button({ onClick: decrement }, 'Decrement')]),
li([button({ onClick: reset }, 'Reset')]),
])
]);
/* Render */
const render = (element, options) =>
patch(options.element ? options.element() : document.getElementById('app'), element);
/* Run */
run({
view,
render,
state
});
You can find more examples in the examples folder.
References
Compatible Versioning
Summary
Given a version number MAJOR.MINOR, increment the:
- MAJOR version when you make backwards-incompatible updates of any kind
- MINOR version when you make 100% backwards-compatible updates
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR format.
Contribute
First off, thanks for taking the time to contribute! Now, take a moment to be sure your contributions make sense to everyone else.
Reporting Issues
Found a problem? Want a new feature? First of all, see if your issue or idea has already been reported. If it hasn't, just open a new clear and descriptive issue.
Submitting pull requests
Pull requests are the greatest contributions, so be sure they are focused in scope and do avoid unrelated commits.
- Fork it!
- Clone your fork:
git clone https://github.com/<your-username>/hyperfun - Navigate to the newly cloned directory:
cd hyperfun - Create a new branch for the new feature:
git checkout -b my-new-feature - Install the tools necessary for development:
npm install - Make your changes.
npm run buildto verify your change doesn't increase output size.npm testto make sure your change doesn't break anything.- Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request with full remarks documenting your changes.
License
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
