mam_mol Documentation
repository·master·Indexed 20 days ago
https://github.com/hyoo-ru/mam_molA reactive micro-modular UI framework featuring zero configuration, automatic dependency tracking, and cross-platform support for NodeJS, Web, and Cordova. The framework focuses on lazy rendering and full reactivity, providing utilities for ambient context management ($mol_ambient), array operations ($mol_array), structural assertions ($mol_assert), file uploads ($mol_attach), and a modular audio system ($mol_audio) including rooms, melodies, and samples.
What's inside mam_mol
- $mol_state_shared is a shared, local-first, and offline-ready state store. It is designed to handle synchronization across multiple tabs automatically and uses the CROWD algorithm for conflict resolution. It is suitable for applications requiring long-term offline capabilities and persistent storage via IndexedDB.
Overview of $mol_server
master$mol_server is a wrapper around the Express web framework that includes built-in support for WebSockets. It is primarily utilized as the underlying server implementation for the$mol_build_servercomponent.Overview of $mol_check variants
master$mol_check is a checkbox UI component. Depending on your use case, you can use one of the following specialized variants:
$mol_check_box: A simple checkbox.$mol_check_group: A group of checkboxes.$mol_check_expand: An expander for trees, lists, or other hierarchical structures.$mol_check_icon: A checkbox represented by an icon.$mol_check_list: A list of checkboxes.
Overview of $mol_wire API categories
masterThe
$mol_wireecosystem is divided into several functional layers:High level API
- Decorators:
@$mol_wire_solo,@$mol_wire_plex,@$mol_wire_field,@$mol_wire_method. - Proxies:
$mol_wire_sync(async to sync) and$mol_wire_async(sync to async). - Functions:
$mol_wire_easing(transition atom values),$mol_wire_probe(run code without state changes),$mol_wire_solid(make current fiber immortal). - Structures:
$mol_wire_set(reactive Set),$mol_wire_dict(reactive Dictionary),$mol_wire_dom(reactive DOM).
Low level API
- Debug:
$mol_wire_log(state changes logger). - Pub/Sub:
$mol_wire_pub(publisher),$mol_wire_sub(subscriber),$mol_wire_pub_sub(subscriber with retranslation),$mol_wire_auto(current tracking subscriber). - Reactivity:
$mol_wire_fiber(pausable task),$mol_wire_task(one-shot fiber),$mol_wire_atom(repeatable fiber),$mol_wire_cursor(subscription statuses).
- Decorators:
Use $mol_array for common array operations
master$mol_array provides a set of helper functions for common array manipulations, including chunking, random selection, and trimming. Note that some operations likechunksandtrimmutate the original array.Use $mol_book for responsive page management
master$mol_book is a component designed for lazy adding or removing pages based on the container's size. It supports a 'pop left' behavior for the front page, which can be configured to hide when it is blurred. This is useful for creating responsive layouts where sidebars or main content areas appear or disappear based on available width.
$my_app $mol_book pages / <= Nav_bar $side_menu minimal_width 100 <= Main $main_page minimal_width 400Use $mol_wire_fiber for pausable synchronous execution
master$mol_wire_fiber provides a tiny SuspenseAPI implementation for pausable synchronous execution.
Important: Idempotency Requirement Code inside fibers that calls other fibers must be idempotent. Because fibers may be restarted to continue execution, any non-idempotent code (code with side effects that shouldn't run twice) must be wrapped to ensure it only executes when the fiber is in a valid state.
Instead of using
$mol_wire_fiberdirectly, it is preferred to use higher-level abstractions:- Decorators:
$mol_wire_method,$mol_wire_solo,$mol_wire_plex - Proxies:
$mol_wire_sync,$mol_wire_async
// Prefer these abstractions over direct $mol_wire_fiber usage: // Decorators: $mol_wire_method, $mol_wire_solo, $mol_wire_plex // Proxies: $mol_wire_sync, $mol_wire_async- Decorators:
Use $mol_stack for layouts with overlapping elements
master$mol_stackis a layout component designed to manage UI elements that need to overlap. It provides a mechanism for stacking components on top of one another within a layout context.Use $mol_theme_auto to define themes based on lights
master$mol_theme_auto is a plugin designed to automatically define a theme based on the configuration of$mol_lights. It acts as a bridge between your light definitions and the application's theme system.Use $mol_svg to display SVG images or icons
masterThe$mol_svgcomponent serves as the base SVG component in the$mol_svgpackage, designed to render SVG images or icons within your application.Use $mol_text for Markdown visualization
master$mol_textis a Markdown visualizer component within the$molecosystem. It is designed to render and visualize Markdown content within a tree-based structure.<= Description $mol_text highlight <= search \mam text <= description \ \# Quick start \ \## Start dev server \n \git clone https://github.com/nin-jin/mam.git \cd mam \npm install \npm startAccess and manipulate argument state with $mol_state_arg
masterThe
$mol_state_argmodule provides a way to interact with argument states across different environments.In NodeJS, it parses command line arguments in the format
key=value(e.g.,foo=bar xxx).In the Web environment, it parses arguments from the document location, supporting both hash fragments (
#foo=bar/xxx) and query parameters (?foo=bar&xxx).// NodeJS example: command line 'foo=bar xxx' $mol_state_arg.value( 'foo' ) // 'bar' $mol_state_arg.value( 'xxx' ) // '' $mol_state_arg.value( 'help' ) // null // Web example: location '#foo=bar/xxx' $mol_state_arg.value( 'foo' ) // 'bar' $mol_state_arg.value( 'xxx' ) // '' $mol_state_arg.value( 'help' ) // null