vorth
v0.14.2
Published
client side reactive library
Maintainers
Readme
vorth is a client-side javascipt library for handling element lifecycle and data to dom reactivity, which have:
- 🐤 lightweight core;
- less then
10KBgzipped
- 🎯 declarative;
- dom reactivity follows this pattern:[
attributeName="attributeOrPropertySelector1;attributeOrPropertySelector2;...;attributeOrPropertySelectorN"], to reflect and bind the input to the signal valuerealtime;
v0.12.x🗜prebundled-firstapproach;- core are already prebuild in this
npm or github./vorthInitiator.mjs;
- we drop this feature, in order to achieve full typehint support;
- 📃 comprehensive typehint;
vorthfunctionality are fullytypehinted,v0.12.xYES, even if you chose to develop DIRECTLY at the staticendpointsyou still gotlimited yet powerfull enoughtypehint;- purely for supporting full typehint across all files;
- 📊 data layer;
vorthprovidesynchronized data layerout of the box viavirstsignalanddomReflector;
- 💪 strong integration support with
npmclient-side📚 packages;
vorthhave preparednpx vorththat functions as a directory watcher for developement (in.mjs,.ts, or.mts) tobundleandminify1 to 1.mjsendpoints, for which you canbundleandminifyadditional client sidenpm packagesaslibs;
- YES, you can put
typescriptandjavascipton the same source folder;
- ⌛ on demand dom update via virst
Lifecycle;
- with the possibility of offloading the templating responsibility to server, your premade static html stack, or even on demand update by
HATEOASapporach,vorthcan handle the client sidelogicat ⚡O(1)⚡ starts, without compromising the ability of html templating when it's neccessary;
- ⚡ blazingly responsive ⚡;
- supports
webWorkerout of the box for more expensive computation, without blocking client interactivity;
- 🔌 embeddable;
- by adding
vorth="lifecycle/name"to your element, you can easily embed yourvorthcode into any templating library/framework, even those that are purely run on the browser runtime;- the only rule is
vorth="lifecycle/name"is to exist at the same time when element is connected to the dom;
documentation for signal
refer to virst:
!!!avoid importing on the endpoint!!!
- there are cases that browser would
autocachethe imported library; - we already profided
importDatas,importLets,importLib, andimportWorkerthat will optimize the cache with the browser session; - if you use
__vorthAppand find generated endpoint contains static import statement, please report as bug, along with the source and the produced endpoint;
!!!avoid importing on the endpoint!!!
how to install starter project
- install by running this script:
npm i vorth- then for empty starter:
npx vorth-starter- or for starter with examples:
npx vorth-example- you'll then have this folder structure like this:
.vscode: snippets collection.jsconfig.json: typehint helper for.mtsand.tsfiles.vorth.config.mjs: builder configvorth-src: source folder.
vorthInitiator.mjs:vorthentry point.datalibslifecyclesworkers
node_modules
- modify
vorth.config.mjsto suit your setting; - to start develop your
vorthcode, run:
npx vorth
vorthdetects.mjs,.ts, and.mtsextentions insidesourcePathdirectory, and bundles them totargetPath1 to 1(it have to be inesm style);- all static imports will be bundled;
- due to
vorthextensively generate types on the fly while also uses custom string generation and only generatejsdoc(no.d.ts),vorthneed to putjsconfig.jsonon your project, so if you have any settings for thiscompilerOptionssettings will be overwritten
{
...
"compilerOptions": {
...
"baseUrl": ".",
"allowJs": true,
"module": "esnext",
"target": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"allowSyntheticDefaultImports": true
}
}- check at Vorth for
property control;
versions
v0.11.x:
- fixed
onViewPortbugs;- beta for full release;
- need to be checked for edge cases;
v0.12.x:
- drop direct writing on endpoint support, to achieve full typehint on all files;
- streamlined
install methodandbuilder script;- beta for full release;
- need to be checked for edge cases;
v0.12.9+:
- updated
virstversion for security;- example with
htmlfile;for_.ofalso returns parentData;
v0.13.x:
- main
modules(lifecycles,derivedData, andlibs)optionsare no longer passed toarg0but are binded tothisfor eachmodules;
- reasoning by doing this, you need no longer to scroll to function declaration and
destructure/unwraparg0, all you need to do is referthis.${optionName}directly on the line you need to call that option, while ofcoursedestructure/unwrapthisis also an option;
v0.14.x:
- added
indexedDBfordata;- move
options.importDatatoimportDatas, mainly for concise imports on single command instead of multiple calls;- added
options.importLets, essentially the same asimportDatasbut only for pure nonderivedsignal;- added helper using
options.promises, it is just syntatic sugar forPromise.all;- added
vivthto dependency for workerThread, usevivth.NewPingUniqueto optimize rapid calls, although it will slightly increase the file size, however the optimized calls should be worth the size;
importable-classes
how to:
- load
{targetPath}/vorthInitiator.mjsto yourhtml;
<script type="module" src="{targetPath}/vorthInitiator.mjs"></script>- add neccessary
attributetovorthInitiator.mjslikedeferorasync(if you put it in the head tag); - structure of your static end point path should be like this:
{targetPath}
vorthInitiator.mjsdatalibslifecyclesworkers
- use this snippets for quick typehinting(prefixed by
>>symbol):
>>dataSignal;>>dataDerived;>>lib;>>lifecycle;>>workerThread;
- ⚠⚠⚠ do NOT put the types outside the snippets recomended place ⚠⚠⚠;
vorthdoesn't use custom type detection which madevorth:
- able to natively support both
jsandtson the same directory, without convertingtstojsfirst, just directly to the generatedendpoint;- strictly need
devto follow thesnippets, as it is made to be detected byvorthregexbasedtypeGenerator;
- as of
version0.13.0, onlyvscodesnippetsare supported;
- add
property controls(contentattribute) for vorth in the head tag if neccessary;
<meta property="vorth-batch" content="10" />
- [
property="vorth-batch"]:contentused to tellvorthmaximum element to be loaded at batch when crossing theviewPort;- you can add
;prelike this [vorth="lifecycle/name;pre"] to directly process theelementwithout waiting for it to cross theviewPort;"lifecycle/name"means you are pointing to"{targetPath}/lifecycles/lifecycle/name.mjs", this patterns also applied toimportData,lifecycleAttr,importWorker,importLib, to their respective folder;
<meta property="vorth-versionMin" content="1738851920151" />
- [
property="vorth-versionMin"]:contentused to tellvorthminimumcachedDateinunix date msis allowed;- you can dynamically provide this tag from the server, and that will refresh the
cachedDateofvorthcode (managed internally), while keeping client's session and local storage;
- both
property controlsare monitored, so when it's changed dynamically in the runtime,vorthwill reactively apply the new value to it's logic;
how to add the lifecycle handler to html:
<div vorth="path/fileName"></div>- this will target
{targetPath}/lifecycles/path/fileName.mjs;
further documentation and examples
- will be posted in html-first documentation website
- this class is to be used as helper to setup
vorth.config.mjson your project root.
