aral, to SmallWeb
@aral@mastodon.ar.al avatar

Just deployed a new version of Kitten.

It uses the latest version of JSDB (5.1.3) which fixes an issue where instances of EventEmitter subclasses persisted to the database were erroneously persisting their (by convention private) _events arrays containing AsyncFunction instances and thereby causing a crash on the database open attempt when the AsyncFunction class could not be found as it wasn’t provided to the JSDB.open() method.

https://codeberg.org/kitten/app

:kitten: 💕

aral,
@aral@mastodon.ar.al avatar

… JSDB, by the way, is short for JavaScript Database, which is, umm, a JavaScript database.

It’s an in-process, in-memory database for Node.js for Small Web use that persists to an append-only JavaScript – not JSON, JavaScript – transaction log.

JSDB’s very easy to work with because you just use native JavaScript objects and they just automatically get persisted for you.

e.g., Here’s a quick 6-line Kitten app that persists a counter:

https://codeberg.org/kitten/app#using-javascript-database-jsdb-a-not-so-scary-database

aral, to javascript
@aral@mastodon.ar.al avatar

Just published a minor update (version 5.1.1) to JavaScript Database (JSDB) that optimises the custom data type¹ serialisation code by removing a redundant return statement:

https://www.npmjs.com/package/@small-tech/jsdb

This change is backwards compatible and shouldn’t require and updates to your projects, including the ones you have in Kitten (which uses JSDB internally).

¹ https://codeberg.org/small-tech/jsdb#custom-data-types
² https://codeberg.org/kitten/app

#JavaScriptDatabase #JavaScript #database #JSDB #Kitten #SmallWeb #NodeJS #web #dev

aral, to javascript
@aral@mastodon.ar.al avatar
aral, to SmallWeb
@aral@mastodon.ar.al avatar

Watching The Doors live at The Hollywood Bowl (1968)¹ and hacking on Kitten² and Domain³.

All in all, not a bad way to spend a Saturday afternoon in my book.

(I’ve almost got database backup/restore working in Kitten and I’ve just finished porting Domain to the latest Kitten with JSDB 5⁴.)

¹ https://yewtu.be/watch?v=Q76QBhKHQGc
² https://codeberg.org/kitten/app
³ https://codeberg.org/domain/app
https://codeberg.org/small-tech/jsdb

aral, to javascript
@aral@mastodon.ar.al avatar

Assign properties in a constructor’s parameter object (with defaults) to object being instantiated in JavaScript

https://codeberg.org/aral/gists/src/branch/main/assign-properties-in-a-constructors-parameter-object-with-defaults-to-object-being-instantiated-in-JavaScript.md

This is a little something I ended up playing around with this morning before figuring out how to do it (after spending far too much time down a rabbit hole with object destructuring when what I really needed was creative use of the spread operator).

(Useful for custom objects in JSDB 5 – https://codeberg.org/small-tech/jsdb#custom-data-types)

aral, to SmallWeb
@aral@mastodon.ar.al avatar

Heads up anyone playing with Kitten at the moment (yes, both of you):

I’m in the process of upgrading Kitten’s version of JSDB from 4 to 5.

This is a breaking change.

This will affect you if you’re persisting custom objects (instances of your custom model classes) in your databases.

Please see the details in this JSDB announcement post and the linked-to details page to prepare:

https://mastodon.ar.al/@aral/112361559531645603

(I should have the update out this afternoon.)

aral, to programming
@aral@mastodon.ar.al avatar

JSDB 5.0.0 published 🎉

• Custom classes must have a constructor that accepts a parameter object as its only argument. Constructors are run during deserialisation.

• Custom classes can now safely extend other classes (e.g., EventEmitter).

• Properties that begin with an underscore (_) are treated as private and ignored.

• Objects with null prototypes are supported. i.e., objects created with Object.create(null, …).

Full details: https://codeberg.org/small-tech/jsdb#migrating-from-earlier-versions-of-jsdf

#JSDB #NodeJS #database

aral,
@aral@mastodon.ar.al avatar

Philosophically, JSDB – which writes out to native JavaScript logs – is very much the JavaScript version of SWX, the native data format for Flash that I released around 2007 (where data was written out in native SWF format). I have to say that I’m glad I didn’t have to reverse engineer SWF bytecode this time around :)

Here’s a video of a younger me doing an impromptu demo of SWX at some conference or other from 16 years ago.

https://m.youtube.com/watch?v=OM9qOADsO3w

aral, to javascript
@aral@mastodon.ar.al avatar

100% test coverage doesn’t mean your code’s bug free but it did just lead me to find and fix an issue in JavaScript Database (JSDB)¹ with a code path that wasn’t being hit that I would have otherwise missed because it was causing the relevant test to pass.

¹ JSDB is a zero-dependency, transparent, in-memory, streaming write-on-update JavaScript database for the Small Web that persists to a JavaScript transaction log (an append-only log).

https://codeberg.org/small-tech/jsdb

#JavaScript #database #JSDB

aral,
@aral@mastodon.ar.al avatar

To really drive home the above 👆 point that 100% test coverage does not mean ‘bug free’, just found a bug in JSDB¹ 5.0.0 where running JSON.stringify() on a complex custom object (actually: the automatic Proxy of the custom object created by JSDB) results in an error.

Already have a failing test and about to implement fix.

(It’s at this point where the test harness is invaluable.)

¹ https://codeberg.org/small-tech/jsdb

aral, to javascript
@aral@mastodon.ar.al avatar

Realised last night that JavaScript Database (JSDB) doesn’t run the constructor on persisted custom objects (https://codeberg.org/small-tech/jsdb#custom-data-types) when deserialising them because I didn’t know that you apparently have to define your constructor manually when using Object.create().

Will fix it today but it’s something to watch out for if you’re using Object.create() directly.

For more info, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create

aral, to SmallWeb
@aral@mastodon.ar.al avatar

This is a niche one and will likely not affect any of the (three?) people playing with Kitten¹ right now but, in any case:

If you persist custom types to your Kitten database, you might be hit by this bug that was introduced when I released versions of Kitten with minified identifiers.

I briefly wrote about what happened, how you can identify if you’re affected, and how you can fix it here:

https://codeberg.org/kitten/app/issues/160#issuecomment-1775375

¹ https://codeberg.org/kitten/app

aral, to SmallWeb
@aral@mastodon.ar.al avatar
aral, to SmallWeb
@aral@mastodon.ar.al avatar

Coming soon: it’s going to be trivial to deploy a different app on your Small Web server. Useful if you’re a dev and you’re playing around with different apps.

https://vimeo.com/932120624

(Also, notice the speed at which deployment happens. I’m one step away from implementing this in Domain using pre-warmed Kitten instances – called toasty kittens – thereby bringing the time it takes to deploy your own Small Web place down to a handful of seconds.)

:kitten: 💕

aral, (edited )
@aral@mastodon.ar.al avatar

When I speak about spending the last few years “building infrastructure”, you might be wondering what sorts of things I’m talking about.

Here are some examples:

JSDB: an in-memory, in-process database that writes to a JavaScript append-only transaction log and which you can use as if you were interacting with regular JavaScript objects.

https://codeberg.org/small-tech/jsdb

(I’ve been developing it for the last four years and it is integrated into Kitten.)

#SmallTech #SmallWeb #JSDB

cvennevik, to webdev
@cvennevik@hachyderm.io avatar

I want to make a web app for viewing, creating, and modifying entries saved to a local file. I will use it on my old budget Android phone, and I want it to be as performant as I can possibly make it.

What do I use to build it?

aral,
@aral@mastodon.ar.al avatar

@cvennevik (Behind the magic is the built-in JSDB database exposed via the kitten.db global: https://codeberg.org/small-tech/jsdb)

aral, to web
@aral@mastodon.ar.al avatar

Just released @small/state v3.0.2

🎉 Persistence is not futile! 🎉

Persist custom State objects in JSDB¹.

https://codeberg.org/small-tech/state

Just got it working in Domain² (a Kitten³ app). It’s such a sweet workflow. Store state keyed to session keys and use Streaming HTML⁴ to stream hypermedia interface updates.

:kitten: 💕

¹ https://codeberg.org/small-tech/jsdb
² https://codeberg.org/domain/app
³ https://codeberg.org/kitten/app
https://ar.al/2024/03/08/streaming-html/

SmallWeb

Screenshot of split terminal window showing, on top, a log of the state objects: Progress indicator state: RegistrationFormState { _state: 'CHECKING_AVAILABILITY', _states: { INITIAL: {}, CHECKING_AVAILABILITY: {}, AVAILABLE: {}, UNAVAILABLE: {}, ERROR: {} }, domain: 'small-web.org', application: { name: 'Place', source: 'https://codeberg.org/small-web/place.git' }, subdomain: '', customApplicationSource: '' } … RegistrationFormState { _state: 'AVAILABLE', _states: { INITIAL: {}, CHECKING_AVAILABILITY: {}, AVAILABLE: {}, UNAVAILABLE: {}, ERROR: {} }, On the button pane is a tail of JSDB database (append only JavaScript log) where the states are stored, keyed to session IDs: _['UB2WuGmK1ltayWBv4J_SlV_d']['registrationFormState'] = Object.create(typeof RegistrationFormState === 'function' ? RegistrationFormState.prototype : {}, Object.getOwnPropertyDescriptors({ '_state':
Screenshot of code. Highlighted area reads: page.on('subdomain', (/**
Screenshot of code. Highlighted area, which is after the one if the previous screenshot, towards the end of the file, reads: switch (true) { case (subdomain.trim() === ''): // Disallow queries comprised solely of whitespace. // (But no need to display an error, so we just set it back to the initial state.) state.set(state.states.INITIAL) break case (

aral, to javascript
@aral@mastodon.ar.al avatar

Just released v3.0 of @small/state

(A tiny – 42 lines of code¹ – JavaScript state management class.)

https://codeberg.org/small-tech/state

The state class is no longer a proxy itself but instead uses a proxy to guard access/update of states. This means instances/subclasses of State can now be persisted in JavaScript Database (JSDB)² objects. e.g., for use in Kitten³ apps.

¹ Sans comments and empty lines.
² https://codeberg.org/small-tech/jsdb
³ https://codeberg.org/kitten/app

aral, to SmallWeb
@aral@mastodon.ar.al avatar

:kitten: 🎉 Kitten is now using the new versioning/deployments system hosted on https://kittens.small-web.org

This is going to allow us to handle automatic updates of Small Web places rather elegantly.

Installation is also now much faster.

You can find out more about Kitten at https://codeberg.org/kitten/app#kitten

Known issue: commit links on the Kittens site are 404ing right now. I just opened an issue to see if @forgejo can add support for 6-digit git hashes*

aral,
@aral@mastodon.ar.al avatar

Also, if you are looking at the code, notice how I’m persisting and retrieving custom JavaScript objects from the database and generally interacting with the database as I would with any JavaScript object.

e.g., https://codeberg.org/kitten/kittens.small-web.org/src/branch/main/upload.post.js#L80

That’s thanks to the built-in JavaScript Database (JSDB) that Kitten uses:

https://codeberg.org/small-tech/jsdb#javascript-database-jsdb

To see how the custom classes are created, see the database app module:

e.g., https://codeberg.org/kitten/kittens.small-web.org/src/branch/main/app_modules/database

aral, to programming
@aral@mastodon.ar.al avatar

JSDB (JavaScript Database) version 4.0.0 released

This is a breaking change.

Removed table-level proxies for the table delete(), addEventListener(), and removeEventListener() methods. These were erroneously being injected not just into table objects but into every data object in them (which was destructive in the case of delete()).

Given you can persist custom JavaScript objects in JSDB, this namespace pollution was a problem.

Change log: https://codeberg.org/small-tech/jsdb/src/branch/main/CHANGELOG.md#4-0-0-2023-11-02

aral, to javascript
@aral@mastodon.ar.al avatar

Just published JavaScript Database (JSDB)¹ version 3.0.4.

  • Null and undefined values are correctly persisted. Setting object property to null no longer results in error².

  • Tests no longer crash on Windows due to path issue³.

  • Code coverage is back to 100%.

Many thanks to @koteisaev for making this release possible with his contributions.

¹ https://codeberg.org/small-tech/jsdb#javascript-database-jsdb
² https://codeberg.org/small-tech/jsdb/issues/2
³ https://codeberg.org/small-tech/jsdb/issues/9

aral, to SmallWeb
@aral@mastodon.ar.al avatar

Kitten¹ now keeps two JSDB² databases per project: an internal one ('kitten._db) that holds data Kitten manages (sessions, uploads, etc.) and the default one (kitten.db`) that holds your own tables.

You’ll mostly only care about the latter.

I also took the opportunity to create a Database App Module example and document it in the readme:

https://codeberg.org/kitten/app#database-app-module

¹ https://codeberg.org/kitten/app
² https://codeberg.org/small-tech/jsdb

aral, (edited ) to SmallWeb
@aral@mastodon.ar.al avatar

It’s so cool to be able to tail your database (append-only JavaScript log¹) when playing with Kitten².

(If I do say so myself.)

The output on the right is the initial state of running the following command on your project folder to tail the domains table when the project is being served on the domain dev.ar.al:

kitten db tail domains --domain=dev.ar.al --all

:kitten: 💕

¹ https://codeberg.org/kitten/app#using-javascript-database-jsdb-a-not-so-scary-database
² https://codeberg.org/kitten/app#kitten

aral, to javascript
@aral@mastodon.ar.al avatar

Just released JavaScript Database (JSDB)¹ version 3.0.3

This is a bug fix patch that fixes options defaults not being applied when an options object is passed to the JSDB and JSTable constructors².

¹ JSDB is a zero-dependency, transparent, in-memory, streaming write-on-update JavaScript database for the Small Web that persists to a JavaScript transaction log (https://codeberg.org/small-tech/jsdb)

² https://codeberg.org/small-tech/jsdb/issues/6

aral, to SmallWeb
@aral@mastodon.ar.al avatar

Just published Kitten’s¹ new database² commands:

  • kitten db [table name] to see info the database/a specific table
  • kitten db delete [table name] to delete the database/a specific table
  • kitten db tail <table name> to follow a specific table

Full docs: https://codeberg.org/kitten/app#database-commands

¹ https://codeberg.org/kitten/app
² https://codeberg.org/small-tech/jsdb

aral, (edited ) to SmallWeb
@aral@mastodon.ar.al avatar

Sitting at the hotel bar in Paris, sipping some red wine and adding a new database command to the Kitten¹ command-line interface.

You can now tail JavaScript Database (JSDB)² tables with:

kitten db <table name>

(Remember that JSDB writes its tables as append-only JavaScript logs.)

¹ https://codeberg.org/kitten/app
² https://codeberg.org/small-tech/jsdb

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • ethstaker
  • magazineikmin
  • vwfavf
  • InstantRegret
  • Youngstown
  • Durango
  • khanakhh
  • slotface
  • ngwrru68w68
  • rosin
  • thenastyranch
  • kavyap
  • PowerRangers
  • anitta
  • DreamBathrooms
  • everett
  • tacticalgear
  • osvaldo12
  • cubers
  • mdbf
  • cisconetworking
  • normalnudes
  • GTA5RPClips
  • tester
  • modclub
  • Leos
  • megavids
  • All magazines