Rename after_load to on_loaded, add load_children option to load_detached_action, update npm

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2026-03-06 23:14:25 +00:00
parent d1ac456279
commit 198cd42ce1
26 changed files with 1024 additions and 145 deletions

View File

@@ -1087,6 +1087,10 @@ class Spa {
* These are merged with URL-extracted args (extra_args take precedence).
* Pass {use_cached_data: true} to have the action load with cached data
* without revalidation if cached data is available.
* @param {object} options - Optional behavior options
* @param {boolean} options.load_children - If true, renders the full component tree
* so all children (datagrids, views, etc.) also run their on_load(). Uses
* _load_render_only instead of _load_only. Useful for preloading/warming cache.
* @returns {Promise<Spa_Action|null>} The fully-loaded action instance, or null if route not found
*
* @example
@@ -1101,8 +1105,13 @@ class Spa {
* @example
* // With cached data (faster, no network request if cached)
* const action = await Spa.load_detached_action('/contacts/123', {use_cached_data: true});
*
* @example
* // Preload with children (warms cache for entire page tree)
* const action = await Spa.load_detached_action('/contacts/123', {}, {load_children: true});
* action.stop();
*/
static async load_detached_action(url, extra_args = {}) {
static async load_detached_action(url, extra_args = {}, options = {}) {
// Parse URL and match to route
const parsed = Spa.parse_url(url);
const url_without_hash = parsed.path + parsed.search;
@@ -1116,12 +1125,14 @@ class Spa {
const action_class = route_match.action_class;
const action_name = action_class.name;
// Merge URL args with extra_args (extra_args take precedence)
// Include _load_only to skip render/on_ready (detached, no DOM needed)
// _load_only: action on_load() only, no children
// _load_render_only: renders full tree, all children run on_load() too
const lifecycle_flag = options.load_children ? '_load_render_only' : '_load_only';
const args = {
...route_match.args,
...extra_args,
_load_only: true
[lifecycle_flag]: true
};
console_debug('Spa', `load_detached_action: Loading ${action_name} with args:`, args);