Build cross-platform applications with the technologies you love!
Lossely coupled, zero-fat, lightweight, vanilla-flavored π¦ yet featureful & opinionated JavaScript framework π₯
It features:
- Cross-Platform Integration thanks to Capacitor.
- Reactivity thanks to AlpineJS.
- Routing with Pinecone Router.
- Partials with Alpine Component.
- Storage with Alpine Persist.
- Localization with Alpine i18n.
- Validation with Iodine.
- Security with JS Obfuscator and Encrypt Storage.
With tailored helpers and configurations for a smooth development.
βββ dist/
βββ src/
βΒ Β βββ css/
βΒ Β βΒ Β βββ base.css
βΒ Β βΒ Β βββ style.css
βΒ Β β
βΒ Β βββ js/
βΒ Β βΒ Β βββ alpine.js
βΒ Β βΒ Β βββ app.js
βΒ Β βΒ Β βββ bootstrap/
βΒ Β βΒ Β βΒ Β βββ alcata.js
βΒ Β βΒ Β βΒ Β βββ providers/
βΒ Β βΒ Β βΒ Β βββ components.js
βΒ Β βΒ Β βΒ Β βββ mobile.js
βΒ Β βΒ Β βΒ Β βββ router.js
βΒ Β βΒ Β βΒ Β βββ translation.js
βΒ Β βΒ Β β
βΒ Β βΒ Β βββ lang/
βΒ Β βΒ Β βΒ Β βββ locale.json # Language files
βΒ Β βΒ Β β
βΒ Β βΒ Β βββ stores/
βΒ Β βΒ Β βΒ Β βββ app.js
βΒ Β βΒ Β β
βΒ Β βΒ Β βββ routes.js
βΒ Β βΒ Β βββ storage.js
βΒ Β β
βΒ Β βββ components/ # HTML partials go here
βΒ Β β
βΒ Β βββ views/ # HTML pages go here
βΒ Β β
βΒ Β βββ index.html
β
βββ capacitor.config.json
βββ tailwind.config.js
βββ vite.config.ts
βββ vite.util.ts
The entry point for Alcata is /src/js/app.js
:
import { System } from "./bootstrap/alcata";
import { Alpine } from "./alpine";
import app from "./stores/app";
Alpine.store('app', app);
System.boot();
Here, an Alpine instance with loaded plugins and custom magics is imported to load stores, x-data
components, and everything you may need. Then, the system is booted.
The src/js/bootstrap/
directory, contains files that you shouldn't modify besides some configurations on the providers.
The file src/js/bootstrap/alcata.js
is where the Service Providers and Alpine are registered and initialized.
Service Providers are small JavaScript objects that provide to Alcata, some extra functionality on top of the stack of libraries that the framework is built-on. They consist of two functions:
- A
register()
function, that runs beforeAlpine.init()
. - A
boot()
function, that runs afterAlpine.init()
.
They're meant to be left mostly unchanged, with the possibility of tweaking some configurations.
An example of this, is the TranslationProvider, that boots up Alpine i18n, with the given locale and fallback locale:
import locale from '../../lang/locale.json';
export const TranslationProvider = {
locale: 'en',
fallbackLocale: 'en',
boot() {
window.AlpineI18n.fallbackLocale = this.fallbackLocale;
window.AlpineI18n.create(this.locale, locale);
}
}
Adds the option to set the window.onback
, on your views to handle mobile back button events.
You can define routes over src/js/routes.js
. In any of the following ways:
export default {
'/': '/views/home.html',
'/about/:redirect?': {
handlers: [
(context) => {
if(context.params.redirect){
return context.redirect(context.params.redirect);
}
}
],
view: ['/views/about.html']
},
notfound(context) {
return context.redirect('/');
}
};
- A string path to fetch a view.
- An object, with several options such
handlers
orview
, specially useful for creating routes with Middlewares. - A
Handler
, a method with theContext
instance.
The routes will be loaded by the RouterProvider
.
You can find more documentation over Pinecone Router.
Alcata comes with an app
Alpine Store by default. And can be accessed through the magic function $app
.
You can save data easily using Alpine Persist. Just wrap the store property with Alpine.$persist
and an optional storage key with as()
.
{
_firstTimeAt: Alpine.$persist(null).as('app:firstTimeAt'),
}
On src/js/storage.js
you'll find very useful storage drivers for Alpine Persist.
import { EncryptStorage as encryption } from "./storage";
import { CompressionStorage as compression } from "./storage";
{
_secretValue: Alpine.$persist(null).as('app:secret').using(encryption),
_compressedValue: Alpine.$persist(null).as('app:compressed').using(compression)
}
The EncryptStorage
will use the VITE_KEY
(set on your .env
file), to encrypt the data using encrypt-storage. This is useful when you want to prevent the client reading/writing on the Local Storage as easily.
The CompressionStorage
will compress the data using the LZ Algorithm. Useful for fighting the browser's Local Storage constraints.
WIP
WIP
WIP