Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
literium-runner
Advanced tools
This project is part of Literium WEB-framework.
The runner includes some independent parts which can be used to run your application. The application must be implemented as a component. Same components can be run both on client to interact with user or on server to build HTML pages.
export interface Run<State, Event> {
(app: Component<State, Event>, elm?: Node): void;
}
function init<State, Event>(doc: Document = document): Run<State, Event>;
The proper way to run your app on client is like so:
// import polyfills
// import runner parts (initializer)
import { init } from 'literium-runner/es/client';
// import application component (initializer)
import { main } from './main';
// initialize runner
const run = init();
// initialize app
const app = main();
// run app using runner on whole document (full-page app)
run(app);
// run app using runner on a body node
run(app, document.body);
Depending on your needs you does or doesn't use additional parts.
The first thing that we would like to determine before application runs is a base URL.
Usually Web-applications available from root of Web-site, so related-links, resources and requests can use the protocol and domain as base URL.
To get base URL you can use getBase()
as described in examples below.
On client (uses Location
object of window):
import { getBase } from 'literium-runner/es/client';
getBase(window) // => "https://example.tld"
On server (uses Host
header of request):
import { getBase } from 'literium-runner/server';
getBase(window) // => "http://example.tld"
Internationalized applications requires a way to determine preferred language from user environment.
You can get user-preferred languages using getLangs()
as described below.
On client it tries to determine language from Navigator
.
import { getLangs } from 'literium-runner/es/client';
getLangs(window) // => ['ru', 'en', ...]
On server it determines language using Accept-Language
header of request.
import { getLangs } from 'literium-runner/server';
getLangs(request) // => ['ru', 'en', ...]
Modern user-agents provides advanced History API which allows client-side navigation (also known HTML5 History API). This allows us speed-up our apps by reducing direct client-server interaction (i.e. from now we won't need requesting html pages itself at all).
Navigation API provided by literium is simple:
interface Nav<AppEvent> {
// change path events handling
on(fork: Fork<AppEvent>): void;
// set local path checker
is(fn: (path: string) => boolean): void;
// process navigation directly
go(url: string): void;
// process click to link event
ev(evt: Event): void;
}
type SetPath = Keyed<'path', string>; /* change path event */
Your application can accept SetPath
event.
Set navigation event listener using on()
and local path checker using is()
on creating your application.
Use go()
to change current path manually or ev()
to process clicks on links locally.
Initializing navigation on client:
import { initNav } from 'literium-runner/es/client';
const nav = initNav(window); // => Nav<Event extends SetPath>
Initializing navigation on server:
import { initNav } from 'literium-runner/server';
const nav = initNav(request); // => Nav<Event extends SetPath>
FAQs
Runner module for Literium web-framework.
We found that literium-runner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.