Refactor jqhtml integration to use jqhtml.boot() and migrate blade highlighting to jqhtml extension
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
20
node_modules/@jqhtml/core/dist/boot.d.ts
generated
vendored
Normal file
20
node_modules/@jqhtml/core/dist/boot.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* JQHTML Boot - Component Hydration System
|
||||
*
|
||||
* Bridges server-rendered HTML and client-side jqhtml components.
|
||||
*
|
||||
* Server output: <div class="_Component_Init" data-component-init-name="User_Card" data-component-args='{"id":1}'></div>
|
||||
* After boot(): <div class="User_Card Component">...rendered template...</div>
|
||||
*
|
||||
* Usage:
|
||||
* await jqhtml.boot(); // Hydrate all placeholders, wait for ready
|
||||
* jqhtml.boot($('#container')); // Hydrate within scope
|
||||
*/
|
||||
/**
|
||||
* Hydrate all _Component_Init placeholders within a scope.
|
||||
*
|
||||
* @param scope - jQuery object, HTMLElement, or undefined (defaults to body)
|
||||
* @returns Promise that resolves when all components (including nested) are ready
|
||||
*/
|
||||
export declare function boot(scope?: any): Promise<void[]>;
|
||||
//# sourceMappingURL=boot.d.ts.map
|
||||
1
node_modules/@jqhtml/core/dist/boot.d.ts.map
generated
vendored
Normal file
1
node_modules/@jqhtml/core/dist/boot.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAiDjD"}
|
||||
2
node_modules/@jqhtml/core/dist/component.d.ts.map
generated
vendored
2
node_modules/@jqhtml/core/dist/component.d.ts.map
generated
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"m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OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,gBAAgB;IAcxB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,UAAU;IAUlB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,0BAA0B;CAqEnC"}
|
||||
145
node_modules/@jqhtml/core/dist/index.cjs
generated
vendored
145
node_modules/@jqhtml/core/dist/index.cjs
generated
vendored
@@ -1852,6 +1852,14 @@ class Jqhtml_Component {
|
||||
* @private
|
||||
*/
|
||||
async _wait_for_children_ready() {
|
||||
// Server-rendered components (created via jqhtml.boot()) may have children
|
||||
// that were hydrated asynchronously during the 'render' event callback.
|
||||
// Those children couldn't register via _find_dom_parent() because they were
|
||||
// created after the parent's lifecycle started. Force DOM traversal fallback
|
||||
// to reliably discover all children, including boot-hydrated ones.
|
||||
if (this.args._inner_html !== undefined) {
|
||||
this._use_dom_fallback = true;
|
||||
}
|
||||
const children = this._get_dom_children();
|
||||
if (children.length === 0) {
|
||||
return; // No children, nothing to wait for
|
||||
@@ -2957,6 +2965,136 @@ function escape_html(str) {
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* JQHTML Boot - Component Hydration System
|
||||
*
|
||||
* Bridges server-rendered HTML and client-side jqhtml components.
|
||||
*
|
||||
* Server output: <div class="_Component_Init" data-component-init-name="User_Card" data-component-args='{"id":1}'></div>
|
||||
* After boot(): <div class="User_Card Component">...rendered template...</div>
|
||||
*
|
||||
* Usage:
|
||||
* await jqhtml.boot(); // Hydrate all placeholders, wait for ready
|
||||
* jqhtml.boot($('#container')); // Hydrate within scope
|
||||
*/
|
||||
/**
|
||||
* Hydrate all _Component_Init placeholders within a scope.
|
||||
*
|
||||
* @param scope - jQuery object, HTMLElement, or undefined (defaults to body)
|
||||
* @returns Promise that resolves when all components (including nested) are ready
|
||||
*/
|
||||
function boot(scope) {
|
||||
const jQ = typeof jQuery !== 'undefined' ? jQuery : $;
|
||||
if (!scope) {
|
||||
scope = jQ('body');
|
||||
}
|
||||
else if (!(scope instanceof jQ)) {
|
||||
scope = jQ(scope);
|
||||
}
|
||||
const readyPromises = [];
|
||||
// Find top-level placeholders only (skip those nested inside other placeholders)
|
||||
scope.find('._Component_Init').each(function () {
|
||||
const $element = jQ(this);
|
||||
// Skip if removed from DOM
|
||||
if (!document.contains($element[0])) {
|
||||
return;
|
||||
}
|
||||
// Skip nested placeholders - they'll be hydrated by parent's render callback
|
||||
let parent = $element[0].parentElement;
|
||||
while (parent) {
|
||||
if (parent.classList.contains('_Component_Init')) {
|
||||
return;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
// Hydrate this placeholder
|
||||
const component = hydrateElement($element);
|
||||
if (!component)
|
||||
return;
|
||||
// On render, recursively hydrate any nested placeholders
|
||||
component.on('render', function () {
|
||||
hydrateNested(component.$, jQ);
|
||||
});
|
||||
// Collect ready promise - parent.ready() waits for all children via _wait_for_children_ready()
|
||||
readyPromises.push(component.ready());
|
||||
});
|
||||
// Fire jqhtml:ready event when all top-level components are ready
|
||||
const result = Promise.all(readyPromises);
|
||||
result.then(() => {
|
||||
document.dispatchEvent(new CustomEvent('jqhtml:ready'));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Hydrate nested _Component_Init placeholders within a component's DOM.
|
||||
* Called from parent's 'render' event.
|
||||
*/
|
||||
function hydrateNested($scope, jQ) {
|
||||
$scope.find('._Component_Init').each(function () {
|
||||
const $element = jQ(this);
|
||||
if (!document.contains($element[0])) {
|
||||
return;
|
||||
}
|
||||
// Skip if nested inside another placeholder
|
||||
let parent = $element[0].parentElement;
|
||||
while (parent && parent !== $scope[0]) {
|
||||
if (parent.classList.contains('_Component_Init')) {
|
||||
return;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
const component = hydrateElement($element);
|
||||
if (!component)
|
||||
return;
|
||||
// Recursively handle deeper nesting
|
||||
component.on('render', function () {
|
||||
hydrateNested(component.$, jQ);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Hydrate a single _Component_Init element into a live component.
|
||||
*/
|
||||
function hydrateElement($element, jQ) {
|
||||
const componentName = $element.attr('data-component-init-name');
|
||||
if (!componentName)
|
||||
return null;
|
||||
// Parse args
|
||||
const argsString = $element.attr('data-component-args');
|
||||
let args = {};
|
||||
if (argsString) {
|
||||
try {
|
||||
args = JSON.parse(argsString);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[jqhtml.boot] Failed to parse args for ${componentName}:`, e);
|
||||
}
|
||||
}
|
||||
// Strip data- prefix from args if present
|
||||
const filteredArgs = {};
|
||||
for (const [key, value] of Object.entries(args)) {
|
||||
filteredArgs[key.startsWith('data-') ? key.substring(5) : key] = value;
|
||||
}
|
||||
// Capture innerHTML for content() and mark as boot-created
|
||||
filteredArgs._inner_html = $element.html();
|
||||
filteredArgs._component_name = componentName;
|
||||
// Cleanup placeholder
|
||||
$element.removeAttr('data-component-init-name');
|
||||
$element.removeAttr('data-component-args');
|
||||
$element.removeData('component-init-name');
|
||||
$element.removeData('component-args');
|
||||
$element.removeClass('_Component_Init');
|
||||
$element.empty();
|
||||
// Create component
|
||||
try {
|
||||
return $element.component(componentName, filteredArgs).component();
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`[jqhtml.boot] Failed to create ${componentName}:`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* JQHTML Debug Overlay
|
||||
*
|
||||
@@ -4237,7 +4375,7 @@ function init(jQuery) {
|
||||
}
|
||||
}
|
||||
// Version - will be replaced during build with actual version from package.json
|
||||
const version = '2.2.222';
|
||||
const version = '2.3.4';
|
||||
// Default export with all functionality
|
||||
const jqhtml = {
|
||||
// Core
|
||||
@@ -4329,7 +4467,9 @@ const jqhtml = {
|
||||
// Cache key setter - enables component caching via local storage
|
||||
set_cache_key(cache_key) {
|
||||
Jqhtml_Local_Storage.set_cache_key(cache_key);
|
||||
}
|
||||
},
|
||||
// Boot - hydrate server-rendered component placeholders
|
||||
boot
|
||||
};
|
||||
// Auto-register on window for browser environments
|
||||
// This is REQUIRED for compiled templates which use window.jqhtml.register_template()
|
||||
@@ -4354,6 +4494,7 @@ exports.Jqhtml_Local_Storage = Jqhtml_Local_Storage;
|
||||
exports.LifecycleManager = LifecycleManager;
|
||||
exports.Load_Coordinator = Load_Coordinator;
|
||||
exports.applyDebugDelay = applyDebugDelay;
|
||||
exports.boot = boot;
|
||||
exports.create_component = create_component;
|
||||
exports.default = jqhtml;
|
||||
exports.devWarn = devWarn;
|
||||
|
||||
2
node_modules/@jqhtml/core/dist/index.cjs.map
generated
vendored
2
node_modules/@jqhtml/core/dist/index.cjs.map
generated
vendored
File diff suppressed because one or more lines are too long
3
node_modules/@jqhtml/core/dist/index.d.ts
generated
vendored
3
node_modules/@jqhtml/core/dist/index.d.ts
generated
vendored
@@ -11,6 +11,7 @@ export type { ComponentConstructor, TemplateFunction, TemplateDefinition } from
|
||||
export { process_instructions, extract_slots } from './instruction-processor.js';
|
||||
export type { Instruction, TagInstruction, ComponentInstruction, SlotInstruction } from './instruction-processor.js';
|
||||
export { render_template, escape_html } from './template-renderer.js';
|
||||
export { boot } from './boot.js';
|
||||
export { logLifecycle, applyDebugDelay, logDispatch, logInstruction, logDataChange, isSequentialProcessing, handleComponentError, devWarn } from './debug.js';
|
||||
export { DebugOverlay, showDebugOverlay, hideDebugOverlay } from './debug-overlay.js';
|
||||
export type { DebugOverlayOptions } from './debug-overlay.js';
|
||||
@@ -23,6 +24,7 @@ import { LifecycleManager } from './lifecycle-manager.js';
|
||||
import { register_component, get_component_class, register_template, get_template, get_template_by_class, create_component, has_component, get_component_names, get_registered_templates, list_components } from './component-registry.js';
|
||||
import { process_instructions, extract_slots } from './instruction-processor.js';
|
||||
import { render_template, escape_html } from './template-renderer.js';
|
||||
import { boot } from './boot.js';
|
||||
import { DebugOverlay } from './debug-overlay.js';
|
||||
import './jquery-plugin.js';
|
||||
import { Jqhtml_Local_Storage } from './local-storage.js';
|
||||
@@ -86,6 +88,7 @@ declare const jqhtml: {
|
||||
_version(): any;
|
||||
version(): string;
|
||||
set_cache_key(cache_key: string): void;
|
||||
boot: typeof boot;
|
||||
};
|
||||
export default jqhtml;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
2
node_modules/@jqhtml/core/dist/index.d.ts.map
generated
vendored
2
node_modules/@jqhtml/core/dist/index.d.ts.map
generated
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG1G,OAAO,EACL,oBAAoB,EACpB,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,OAAO,EACR,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,oBAAoB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MAAM,MAAM;;;;;;;;;;;;;;;;;;WA8BL,aAAa,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE;+BAGhC,aAAa;4BAIjB,OAAO,GAAG,MAAM;;+BAmBZ,GAAG;;;;;;6BA+CL,MAAM;;CAMhC,CAAC;AAmBF,eAAe,MAAM,CAAC"}
|
||||
146
node_modules/@jqhtml/core/dist/index.js
generated
vendored
146
node_modules/@jqhtml/core/dist/index.js
generated
vendored
@@ -1848,6 +1848,14 @@ class Jqhtml_Component {
|
||||
* @private
|
||||
*/
|
||||
async _wait_for_children_ready() {
|
||||
// Server-rendered components (created via jqhtml.boot()) may have children
|
||||
// that were hydrated asynchronously during the 'render' event callback.
|
||||
// Those children couldn't register via _find_dom_parent() because they were
|
||||
// created after the parent's lifecycle started. Force DOM traversal fallback
|
||||
// to reliably discover all children, including boot-hydrated ones.
|
||||
if (this.args._inner_html !== undefined) {
|
||||
this._use_dom_fallback = true;
|
||||
}
|
||||
const children = this._get_dom_children();
|
||||
if (children.length === 0) {
|
||||
return; // No children, nothing to wait for
|
||||
@@ -2953,6 +2961,136 @@ function escape_html(str) {
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* JQHTML Boot - Component Hydration System
|
||||
*
|
||||
* Bridges server-rendered HTML and client-side jqhtml components.
|
||||
*
|
||||
* Server output: <div class="_Component_Init" data-component-init-name="User_Card" data-component-args='{"id":1}'></div>
|
||||
* After boot(): <div class="User_Card Component">...rendered template...</div>
|
||||
*
|
||||
* Usage:
|
||||
* await jqhtml.boot(); // Hydrate all placeholders, wait for ready
|
||||
* jqhtml.boot($('#container')); // Hydrate within scope
|
||||
*/
|
||||
/**
|
||||
* Hydrate all _Component_Init placeholders within a scope.
|
||||
*
|
||||
* @param scope - jQuery object, HTMLElement, or undefined (defaults to body)
|
||||
* @returns Promise that resolves when all components (including nested) are ready
|
||||
*/
|
||||
function boot(scope) {
|
||||
const jQ = typeof jQuery !== 'undefined' ? jQuery : $;
|
||||
if (!scope) {
|
||||
scope = jQ('body');
|
||||
}
|
||||
else if (!(scope instanceof jQ)) {
|
||||
scope = jQ(scope);
|
||||
}
|
||||
const readyPromises = [];
|
||||
// Find top-level placeholders only (skip those nested inside other placeholders)
|
||||
scope.find('._Component_Init').each(function () {
|
||||
const $element = jQ(this);
|
||||
// Skip if removed from DOM
|
||||
if (!document.contains($element[0])) {
|
||||
return;
|
||||
}
|
||||
// Skip nested placeholders - they'll be hydrated by parent's render callback
|
||||
let parent = $element[0].parentElement;
|
||||
while (parent) {
|
||||
if (parent.classList.contains('_Component_Init')) {
|
||||
return;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
// Hydrate this placeholder
|
||||
const component = hydrateElement($element);
|
||||
if (!component)
|
||||
return;
|
||||
// On render, recursively hydrate any nested placeholders
|
||||
component.on('render', function () {
|
||||
hydrateNested(component.$, jQ);
|
||||
});
|
||||
// Collect ready promise - parent.ready() waits for all children via _wait_for_children_ready()
|
||||
readyPromises.push(component.ready());
|
||||
});
|
||||
// Fire jqhtml:ready event when all top-level components are ready
|
||||
const result = Promise.all(readyPromises);
|
||||
result.then(() => {
|
||||
document.dispatchEvent(new CustomEvent('jqhtml:ready'));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Hydrate nested _Component_Init placeholders within a component's DOM.
|
||||
* Called from parent's 'render' event.
|
||||
*/
|
||||
function hydrateNested($scope, jQ) {
|
||||
$scope.find('._Component_Init').each(function () {
|
||||
const $element = jQ(this);
|
||||
if (!document.contains($element[0])) {
|
||||
return;
|
||||
}
|
||||
// Skip if nested inside another placeholder
|
||||
let parent = $element[0].parentElement;
|
||||
while (parent && parent !== $scope[0]) {
|
||||
if (parent.classList.contains('_Component_Init')) {
|
||||
return;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
const component = hydrateElement($element);
|
||||
if (!component)
|
||||
return;
|
||||
// Recursively handle deeper nesting
|
||||
component.on('render', function () {
|
||||
hydrateNested(component.$, jQ);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Hydrate a single _Component_Init element into a live component.
|
||||
*/
|
||||
function hydrateElement($element, jQ) {
|
||||
const componentName = $element.attr('data-component-init-name');
|
||||
if (!componentName)
|
||||
return null;
|
||||
// Parse args
|
||||
const argsString = $element.attr('data-component-args');
|
||||
let args = {};
|
||||
if (argsString) {
|
||||
try {
|
||||
args = JSON.parse(argsString);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[jqhtml.boot] Failed to parse args for ${componentName}:`, e);
|
||||
}
|
||||
}
|
||||
// Strip data- prefix from args if present
|
||||
const filteredArgs = {};
|
||||
for (const [key, value] of Object.entries(args)) {
|
||||
filteredArgs[key.startsWith('data-') ? key.substring(5) : key] = value;
|
||||
}
|
||||
// Capture innerHTML for content() and mark as boot-created
|
||||
filteredArgs._inner_html = $element.html();
|
||||
filteredArgs._component_name = componentName;
|
||||
// Cleanup placeholder
|
||||
$element.removeAttr('data-component-init-name');
|
||||
$element.removeAttr('data-component-args');
|
||||
$element.removeData('component-init-name');
|
||||
$element.removeData('component-args');
|
||||
$element.removeClass('_Component_Init');
|
||||
$element.empty();
|
||||
// Create component
|
||||
try {
|
||||
return $element.component(componentName, filteredArgs).component();
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`[jqhtml.boot] Failed to create ${componentName}:`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* JQHTML Debug Overlay
|
||||
*
|
||||
@@ -4233,7 +4371,7 @@ function init(jQuery) {
|
||||
}
|
||||
}
|
||||
// Version - will be replaced during build with actual version from package.json
|
||||
const version = '2.2.222';
|
||||
const version = '2.3.4';
|
||||
// Default export with all functionality
|
||||
const jqhtml = {
|
||||
// Core
|
||||
@@ -4325,7 +4463,9 @@ const jqhtml = {
|
||||
// Cache key setter - enables component caching via local storage
|
||||
set_cache_key(cache_key) {
|
||||
Jqhtml_Local_Storage.set_cache_key(cache_key);
|
||||
}
|
||||
},
|
||||
// Boot - hydrate server-rendered component placeholders
|
||||
boot
|
||||
};
|
||||
// Auto-register on window for browser environments
|
||||
// This is REQUIRED for compiled templates which use window.jqhtml.register_template()
|
||||
@@ -4343,5 +4483,5 @@ if (typeof window !== 'undefined' && !window.jqhtml) {
|
||||
}
|
||||
}
|
||||
|
||||
export { DebugOverlay, Jqhtml_Component, LifecycleManager as Jqhtml_LifecycleManager, Jqhtml_Local_Storage, LifecycleManager, Load_Coordinator, applyDebugDelay, create_component, jqhtml as default, devWarn, escape_html, extract_slots, get_component_class, get_component_names, get_registered_templates, get_template, get_template_by_class, handleComponentError, has_component, hideDebugOverlay, init, init_jquery_plugin, isSequentialProcessing, list_components, logDataChange, logDispatch, logInstruction, logLifecycle, process_instructions, register_component, register_template, render_template, showDebugOverlay, version };
|
||||
export { DebugOverlay, Jqhtml_Component, LifecycleManager as Jqhtml_LifecycleManager, Jqhtml_Local_Storage, LifecycleManager, Load_Coordinator, applyDebugDelay, boot, create_component, jqhtml as default, devWarn, escape_html, extract_slots, get_component_class, get_component_names, get_registered_templates, get_template, get_template_by_class, handleComponentError, has_component, hideDebugOverlay, init, init_jquery_plugin, isSequentialProcessing, list_components, logDataChange, logDispatch, logInstruction, logLifecycle, process_instructions, register_component, register_template, render_template, showDebugOverlay, version };
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
2
node_modules/@jqhtml/core/dist/index.js.map
generated
vendored
2
node_modules/@jqhtml/core/dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
148
node_modules/@jqhtml/core/dist/jqhtml-core.esm.js
generated
vendored
148
node_modules/@jqhtml/core/dist/jqhtml-core.esm.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* JQHTML Core v2.2.222
|
||||
* JQHTML Core v2.3.4
|
||||
* (c) 2025 JQHTML Team
|
||||
* Released under the MIT License
|
||||
*/
|
||||
@@ -1853,6 +1853,14 @@ class Jqhtml_Component {
|
||||
* @private
|
||||
*/
|
||||
async _wait_for_children_ready() {
|
||||
// Server-rendered components (created via jqhtml.boot()) may have children
|
||||
// that were hydrated asynchronously during the 'render' event callback.
|
||||
// Those children couldn't register via _find_dom_parent() because they were
|
||||
// created after the parent's lifecycle started. Force DOM traversal fallback
|
||||
// to reliably discover all children, including boot-hydrated ones.
|
||||
if (this.args._inner_html !== undefined) {
|
||||
this._use_dom_fallback = true;
|
||||
}
|
||||
const children = this._get_dom_children();
|
||||
if (children.length === 0) {
|
||||
return; // No children, nothing to wait for
|
||||
@@ -2958,6 +2966,136 @@ function escape_html(str) {
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* JQHTML Boot - Component Hydration System
|
||||
*
|
||||
* Bridges server-rendered HTML and client-side jqhtml components.
|
||||
*
|
||||
* Server output: <div class="_Component_Init" data-component-init-name="User_Card" data-component-args='{"id":1}'></div>
|
||||
* After boot(): <div class="User_Card Component">...rendered template...</div>
|
||||
*
|
||||
* Usage:
|
||||
* await jqhtml.boot(); // Hydrate all placeholders, wait for ready
|
||||
* jqhtml.boot($('#container')); // Hydrate within scope
|
||||
*/
|
||||
/**
|
||||
* Hydrate all _Component_Init placeholders within a scope.
|
||||
*
|
||||
* @param scope - jQuery object, HTMLElement, or undefined (defaults to body)
|
||||
* @returns Promise that resolves when all components (including nested) are ready
|
||||
*/
|
||||
function boot(scope) {
|
||||
const jQ = typeof jQuery !== 'undefined' ? jQuery : $;
|
||||
if (!scope) {
|
||||
scope = jQ('body');
|
||||
}
|
||||
else if (!(scope instanceof jQ)) {
|
||||
scope = jQ(scope);
|
||||
}
|
||||
const readyPromises = [];
|
||||
// Find top-level placeholders only (skip those nested inside other placeholders)
|
||||
scope.find('._Component_Init').each(function () {
|
||||
const $element = jQ(this);
|
||||
// Skip if removed from DOM
|
||||
if (!document.contains($element[0])) {
|
||||
return;
|
||||
}
|
||||
// Skip nested placeholders - they'll be hydrated by parent's render callback
|
||||
let parent = $element[0].parentElement;
|
||||
while (parent) {
|
||||
if (parent.classList.contains('_Component_Init')) {
|
||||
return;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
// Hydrate this placeholder
|
||||
const component = hydrateElement($element);
|
||||
if (!component)
|
||||
return;
|
||||
// On render, recursively hydrate any nested placeholders
|
||||
component.on('render', function () {
|
||||
hydrateNested(component.$, jQ);
|
||||
});
|
||||
// Collect ready promise - parent.ready() waits for all children via _wait_for_children_ready()
|
||||
readyPromises.push(component.ready());
|
||||
});
|
||||
// Fire jqhtml:ready event when all top-level components are ready
|
||||
const result = Promise.all(readyPromises);
|
||||
result.then(() => {
|
||||
document.dispatchEvent(new CustomEvent('jqhtml:ready'));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Hydrate nested _Component_Init placeholders within a component's DOM.
|
||||
* Called from parent's 'render' event.
|
||||
*/
|
||||
function hydrateNested($scope, jQ) {
|
||||
$scope.find('._Component_Init').each(function () {
|
||||
const $element = jQ(this);
|
||||
if (!document.contains($element[0])) {
|
||||
return;
|
||||
}
|
||||
// Skip if nested inside another placeholder
|
||||
let parent = $element[0].parentElement;
|
||||
while (parent && parent !== $scope[0]) {
|
||||
if (parent.classList.contains('_Component_Init')) {
|
||||
return;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
const component = hydrateElement($element);
|
||||
if (!component)
|
||||
return;
|
||||
// Recursively handle deeper nesting
|
||||
component.on('render', function () {
|
||||
hydrateNested(component.$, jQ);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Hydrate a single _Component_Init element into a live component.
|
||||
*/
|
||||
function hydrateElement($element, jQ) {
|
||||
const componentName = $element.attr('data-component-init-name');
|
||||
if (!componentName)
|
||||
return null;
|
||||
// Parse args
|
||||
const argsString = $element.attr('data-component-args');
|
||||
let args = {};
|
||||
if (argsString) {
|
||||
try {
|
||||
args = JSON.parse(argsString);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[jqhtml.boot] Failed to parse args for ${componentName}:`, e);
|
||||
}
|
||||
}
|
||||
// Strip data- prefix from args if present
|
||||
const filteredArgs = {};
|
||||
for (const [key, value] of Object.entries(args)) {
|
||||
filteredArgs[key.startsWith('data-') ? key.substring(5) : key] = value;
|
||||
}
|
||||
// Capture innerHTML for content() and mark as boot-created
|
||||
filteredArgs._inner_html = $element.html();
|
||||
filteredArgs._component_name = componentName;
|
||||
// Cleanup placeholder
|
||||
$element.removeAttr('data-component-init-name');
|
||||
$element.removeAttr('data-component-args');
|
||||
$element.removeData('component-init-name');
|
||||
$element.removeData('component-args');
|
||||
$element.removeClass('_Component_Init');
|
||||
$element.empty();
|
||||
// Create component
|
||||
try {
|
||||
return $element.component(componentName, filteredArgs).component();
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`[jqhtml.boot] Failed to create ${componentName}:`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* JQHTML Debug Overlay
|
||||
*
|
||||
@@ -4238,7 +4376,7 @@ function init(jQuery) {
|
||||
}
|
||||
}
|
||||
// Version - will be replaced during build with actual version from package.json
|
||||
const version = '2.2.222';
|
||||
const version = '2.3.4';
|
||||
// Default export with all functionality
|
||||
const jqhtml = {
|
||||
// Core
|
||||
@@ -4330,7 +4468,9 @@ const jqhtml = {
|
||||
// Cache key setter - enables component caching via local storage
|
||||
set_cache_key(cache_key) {
|
||||
Jqhtml_Local_Storage.set_cache_key(cache_key);
|
||||
}
|
||||
},
|
||||
// Boot - hydrate server-rendered component placeholders
|
||||
boot
|
||||
};
|
||||
// Auto-register on window for browser environments
|
||||
// This is REQUIRED for compiled templates which use window.jqhtml.register_template()
|
||||
@@ -4348,5 +4488,5 @@ if (typeof window !== 'undefined' && !window.jqhtml) {
|
||||
}
|
||||
}
|
||||
|
||||
export { DebugOverlay, Jqhtml_Component, LifecycleManager as Jqhtml_LifecycleManager, Jqhtml_Local_Storage, LifecycleManager, Load_Coordinator, applyDebugDelay, create_component, jqhtml as default, devWarn, escape_html, extract_slots, get_component_class, get_component_names, get_registered_templates, get_template, get_template_by_class, handleComponentError, has_component, hideDebugOverlay, init, init_jquery_plugin, isSequentialProcessing, list_components, logDataChange, logDispatch, logInstruction, logLifecycle, process_instructions, register_component, register_template, render_template, showDebugOverlay, version };
|
||||
export { DebugOverlay, Jqhtml_Component, LifecycleManager as Jqhtml_LifecycleManager, Jqhtml_Local_Storage, LifecycleManager, Load_Coordinator, applyDebugDelay, boot, create_component, jqhtml as default, devWarn, escape_html, extract_slots, get_component_class, get_component_names, get_registered_templates, get_template, get_template_by_class, handleComponentError, has_component, hideDebugOverlay, init, init_jquery_plugin, isSequentialProcessing, list_components, logDataChange, logDispatch, logInstruction, logLifecycle, process_instructions, register_component, register_template, render_template, showDebugOverlay, version };
|
||||
//# sourceMappingURL=jqhtml-core.esm.js.map
|
||||
|
||||
2
node_modules/@jqhtml/core/dist/jqhtml-core.esm.js.map
generated
vendored
2
node_modules/@jqhtml/core/dist/jqhtml-core.esm.js.map
generated
vendored
File diff suppressed because one or more lines are too long
7
node_modules/@jqhtml/core/package.json
generated
vendored
Executable file → Normal file
7
node_modules/@jqhtml/core/package.json
generated
vendored
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@jqhtml/core",
|
||||
"version": "2.2.222",
|
||||
"version": "2.3.4",
|
||||
"description": "Core runtime library for JQHTML",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
@@ -48,11 +48,6 @@
|
||||
],
|
||||
"author": "JQHTML Team",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jqhtml/jqhtml.git",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||
"@rollup/plugin-replace": "^6.0.2",
|
||||
|
||||
Reference in New Issue
Block a user