@jqhtml/core 2.3.4 → 2.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -351,6 +351,50 @@ function list_components() {
351
351
  }
352
352
  return result;
353
353
  }
354
+ /**
355
+ * Unified registration function - auto-detects source type and delegates
356
+ *
357
+ * Accepts either:
358
+ * - A compiled JQHTML template (has __jqhtml_template: true)
359
+ * - A component class extending Jqhtml_Component (has static __jqhtml_component: true and static component_name)
360
+ *
361
+ * @param source - Compiled template or component class
362
+ */
363
+ function register(source) {
364
+ // Check for template (compiled .jqhtml file)
365
+ if (source && typeof source === 'object' && '__jqhtml_template' in source && source.__jqhtml_template === true) {
366
+ register_template(source);
367
+ return;
368
+ }
369
+ // Check for component class (extends Jqhtml_Component)
370
+ if (source && typeof source === 'function' && '__jqhtml_component' in source && source.__jqhtml_component === true) {
371
+ const component_name = source.component_name;
372
+ if (!component_name || typeof component_name !== 'string') {
373
+ throw new Error('[JQHTML] Component class must define static component_name property.\n\n' +
374
+ 'Example:\n' +
375
+ ' class My_Component extends Jqhtml_Component {\n' +
376
+ ' static component_name = "My_Component";\n' +
377
+ ' // ...\n' +
378
+ ' }\n\n' +
379
+ 'Alternatively, use register_component(name, class) to specify the name explicitly:\n' +
380
+ ' jqhtml.register_component("My_Component", My_Component);');
381
+ }
382
+ register_component(component_name, source);
383
+ return;
384
+ }
385
+ // Unknown type - provide helpful error
386
+ throw new Error('[JQHTML] register() requires a compiled JQHTML template or a component class.\n\n' +
387
+ 'For templates:\n' +
388
+ ' import My_Template from "./my_component.jqhtml";\n' +
389
+ ' jqhtml.register(My_Template);\n\n' +
390
+ 'For classes (with static component_name):\n' +
391
+ ' class My_Component extends Jqhtml_Component {\n' +
392
+ ' static component_name = "My_Component";\n' +
393
+ ' }\n' +
394
+ ' jqhtml.register(My_Component);\n\n' +
395
+ 'For classes (without static component_name):\n' +
396
+ ' jqhtml.register_component("My_Component", My_Component);');
397
+ }
354
398
 
355
399
  /**
356
400
  * JQHTML v2 Instruction Processor
@@ -879,7 +923,7 @@ function devWarn(message) {
879
923
  console.warn(`[JQHTML Dev Warning] ${message}`);
880
924
  }
881
925
  // Get global jqhtml object
882
- function getJqhtml$1() {
926
+ function getJqhtml() {
883
927
  if (typeof window !== 'undefined' && window.jqhtml) {
884
928
  return window.jqhtml;
885
929
  }
@@ -892,7 +936,7 @@ function getJqhtml$1() {
892
936
  }
893
937
  // Visual flash effect
894
938
  function flashComponent(component, eventType) {
895
- const jqhtml = getJqhtml$1();
939
+ const jqhtml = getJqhtml();
896
940
  if (!jqhtml?.debug?.flashComponents)
897
941
  return;
898
942
  const duration = jqhtml.debug.flashDuration || 500;
@@ -914,7 +958,7 @@ function flashComponent(component, eventType) {
914
958
  }
915
959
  // Log lifecycle event
916
960
  function logLifecycle(component, phase, status) {
917
- const jqhtml = getJqhtml$1();
961
+ const jqhtml = getJqhtml();
918
962
  if (!jqhtml?.debug)
919
963
  return;
920
964
  const shouldLog = jqhtml.debug.logFullLifecycle ||
@@ -960,7 +1004,7 @@ function logLifecycle(component, phase, status) {
960
1004
  }
961
1005
  // Apply delays based on lifecycle phase
962
1006
  function applyDebugDelay(phase) {
963
- const jqhtml = getJqhtml$1();
1007
+ const jqhtml = getJqhtml();
964
1008
  if (!jqhtml?.debug)
965
1009
  return;
966
1010
  let delayMs = 0;
@@ -981,14 +1025,14 @@ function applyDebugDelay(phase) {
981
1025
  }
982
1026
  // Log instruction processing
983
1027
  function logInstruction(type, data) {
984
- const jqhtml = getJqhtml$1();
1028
+ const jqhtml = getJqhtml();
985
1029
  if (!jqhtml?.debug?.logInstructionProcessing)
986
1030
  return;
987
1031
  console.log(`[JQHTML Instruction] ${type}:`, data);
988
1032
  }
989
1033
  // Log data changes
990
1034
  function logDataChange(component, property, oldValue, newValue) {
991
- const jqhtml = getJqhtml$1();
1035
+ const jqhtml = getJqhtml();
992
1036
  if (!jqhtml?.debug?.traceDataFlow)
993
1037
  return;
994
1038
  console.log(`[JQHTML Data] ${component.constructor.name}#${component._cid}.data.${property}:`, { old: oldValue, new: newValue });
@@ -1001,7 +1045,7 @@ function updateComponentTree() {
1001
1045
  }
1002
1046
  // Router dispatch logging
1003
1047
  function logDispatch(url, route, params, verbose = false) {
1004
- const jqhtml = getJqhtml$1();
1048
+ const jqhtml = getJqhtml();
1005
1049
  if (!jqhtml?.debug)
1006
1050
  return;
1007
1051
  const shouldLog = jqhtml.debug.logDispatch || jqhtml.debug.logDispatchVerbose;
@@ -1023,12 +1067,12 @@ function logDispatch(url, route, params, verbose = false) {
1023
1067
  }
1024
1068
  // Check if sequential processing is enabled
1025
1069
  function isSequentialProcessing() {
1026
- const jqhtml = getJqhtml$1();
1070
+ const jqhtml = getJqhtml();
1027
1071
  return jqhtml?.debug?.sequentialProcessing || false;
1028
1072
  }
1029
1073
  // Error handling with break on error
1030
1074
  function handleComponentError(component, phase, error) {
1031
- const jqhtml = getJqhtml$1();
1075
+ const jqhtml = getJqhtml();
1032
1076
  console.error(`[JQHTML Error] ${component.constructor.name}#${component._cid} failed in ${phase}:`, error);
1033
1077
  if (jqhtml?.debug?.breakOnError) {
1034
1078
  debugger; // This will pause execution in dev tools
@@ -1056,6 +1100,9 @@ function handleComponentError(component, phase, error) {
1056
1100
  * - Scoped IDs using _cid pattern
1057
1101
  * - Event emission and CSS class hierarchy
1058
1102
  */
1103
+ // WeakMap storage for protected lifecycle method implementations (Option 2)
1104
+ // See docs/internal/lifecycle-method-protection.md for design details
1105
+ const lifecycle_impls = new WeakMap();
1059
1106
  class Jqhtml_Component {
1060
1107
  constructor(element, args = {}) {
1061
1108
  this._ready_state = 0; // 0=created, 1=init, 2=loaded, 3=rendered, 4=ready
@@ -1076,6 +1123,7 @@ class Jqhtml_Component {
1076
1123
  this.__initial_data_snapshot = null; // Snapshot of this.data after on_create() for restoration before on_load()
1077
1124
  this.__data_frozen = false; // Track if this.data is currently frozen
1078
1125
  this.next_reload_force_refresh = null; // State machine for reload()/refresh() debounce precedence
1126
+ this.__lifecycle_authorized = false; // Flag for lifecycle method protection
1079
1127
  this._cid = this._generate_cid();
1080
1128
  this._lifecycle_manager = LifecycleManager.get_instance();
1081
1129
  // Create or wrap element
@@ -1189,6 +1237,63 @@ class Jqhtml_Component {
1189
1237
  this.state = {};
1190
1238
  this._log_lifecycle('construct', 'complete');
1191
1239
  }
1240
+ /**
1241
+ * Protect lifecycle methods from manual invocation
1242
+ * Stores original implementations in WeakMap, replaces with guarded wrappers
1243
+ * @private
1244
+ */
1245
+ _protect_lifecycle_methods() {
1246
+ const methods = {
1247
+ on_create: 'Called automatically during creation.',
1248
+ on_render: 'Use render() to trigger a re-render.',
1249
+ on_load: 'Use reload() to refresh data.',
1250
+ on_ready: 'Called automatically when ready.',
1251
+ on_stop: 'Use stop() to stop the component.'
1252
+ };
1253
+ const impls = {};
1254
+ const self = this;
1255
+ for (const [name, help] of Object.entries(methods)) {
1256
+ const original = this[name];
1257
+ // Skip if using base class default (empty method)
1258
+ if (original === Jqhtml_Component.prototype[name])
1259
+ continue;
1260
+ impls[name] = original;
1261
+ // Create wrapper with same function name (for stack traces)
1262
+ this[name] = {
1263
+ [name](...args) {
1264
+ if (!self.__lifecycle_authorized) {
1265
+ throw new Error(`[JQHTML] ${name}() cannot be called manually. ${help}\n` +
1266
+ `Component: ${self.component_name()} (_cid: ${self._cid})`);
1267
+ }
1268
+ return lifecycle_impls.get(self)[name].apply(self, args);
1269
+ }
1270
+ }[name];
1271
+ }
1272
+ lifecycle_impls.set(this, impls);
1273
+ }
1274
+ /**
1275
+ * Call a lifecycle method with authorization (async)
1276
+ * Framework calls this to invoke lifecycle methods, bypassing the protection wrapper.
1277
+ * The flag is set momentarily for the wrapper check, then reset BEFORE user code runs.
1278
+ * This ensures any nested lifecycle calls from user code will fail the flag check.
1279
+ * @private
1280
+ */
1281
+ async _call_lifecycle(name, context) {
1282
+ // Get the original implementation (bypasses wrapper entirely)
1283
+ const impl = lifecycle_impls.get(this)?.[name] || this[name];
1284
+ // Call original directly - no flag needed since we bypass the wrapper
1285
+ return await impl.call(context || this);
1286
+ }
1287
+ /**
1288
+ * Call a lifecycle method with authorization (sync version for sync methods like on_stop)
1289
+ * @private
1290
+ */
1291
+ _call_lifecycle_sync(name) {
1292
+ // Get the original implementation (bypasses wrapper entirely)
1293
+ const impl = lifecycle_impls.get(this)?.[name] || this[name];
1294
+ // Call original directly - no flag needed since we bypass the wrapper
1295
+ return impl.call(this);
1296
+ }
1192
1297
  /**
1193
1298
  * Boot - Start the full component lifecycle
1194
1299
  * Called immediately after construction by instruction processor
@@ -1202,6 +1307,8 @@ class Jqhtml_Component {
1202
1307
  if (this._booted)
1203
1308
  return;
1204
1309
  this._booted = true;
1310
+ // Protect lifecycle methods from manual invocation (must happen after subclass constructor)
1311
+ this._protect_lifecycle_methods();
1205
1312
  await this._lifecycle_manager.boot_component(this);
1206
1313
  }
1207
1314
  // -------------------------------------------------------------------------
@@ -1412,9 +1519,9 @@ class Jqhtml_Component {
1412
1519
  // Don't update ready state here - let phases complete in order
1413
1520
  this._update_debug_attrs();
1414
1521
  this._log_lifecycle('render', 'complete');
1415
- // Call on_render() immediately after render completes
1522
+ // Call on_render() with authorization (sync) immediately after render completes
1416
1523
  // This ensures event handlers are always re-attached after DOM updates
1417
- const renderResult = this.on_render();
1524
+ const renderResult = this._call_lifecycle_sync('on_render');
1418
1525
  if (renderResult && typeof renderResult.then === 'function') {
1419
1526
  console.warn(`[JQHTML] Component "${this.component_name()}" returned a Promise from on_render(). ` +
1420
1527
  `on_render() must be synchronous code. Remove 'async' from the function declaration.`);
@@ -1479,8 +1586,8 @@ class Jqhtml_Component {
1479
1586
  if (this._render_count !== render_id) {
1480
1587
  return; // Stale render, don't call on_ready
1481
1588
  }
1482
- // Call on_ready hook
1483
- await this.on_ready();
1589
+ // Call on_ready hook with authorization
1590
+ await this._call_lifecycle('on_ready');
1484
1591
  // Trigger ready event
1485
1592
  await this.trigger('ready');
1486
1593
  })();
@@ -1500,8 +1607,8 @@ class Jqhtml_Component {
1500
1607
  if (this._stopped || this._ready_state >= 1)
1501
1608
  return;
1502
1609
  this._log_lifecycle('create', 'start');
1503
- // Call on_create() and validate it's synchronous
1504
- const result = this.on_create();
1610
+ // Call on_create() with authorization and validate it's synchronous
1611
+ const result = await this._call_lifecycle('on_create');
1505
1612
  if (result && typeof result.then === 'function') {
1506
1613
  console.warn(`[JQHTML] Component "${this.component_name()}" returned a Promise from on_create(). ` +
1507
1614
  `on_create() must be synchronous code. Remove 'async' from the function declaration.`);
@@ -1616,8 +1723,8 @@ class Jqhtml_Component {
1616
1723
  if (window.jqhtml?.debug?.verbose) {
1617
1724
  console.log(`[Cache] Component ${this._cid} (${this.component_name()}) has non-serializable args - load deduplication and caching disabled`, { uncacheable_property });
1618
1725
  }
1619
- // Execute on_load() without deduplication or caching
1620
- await this.on_load();
1726
+ // Execute on_load() with authorization, without deduplication or caching
1727
+ await this._call_lifecycle('on_load');
1621
1728
  this.__data_frozen = true;
1622
1729
  return;
1623
1730
  }
@@ -1726,7 +1833,7 @@ class Jqhtml_Component {
1726
1833
  // - Should errors reset state machine flags (next_reload_force_refresh)?
1727
1834
  // - Should partial data be preserved or rolled back?
1728
1835
  // - Should followers be notified differently based on error type?
1729
- await this.on_load.call(restricted_this);
1836
+ await this._call_lifecycle('on_load', restricted_this);
1730
1837
  }
1731
1838
  catch (error) {
1732
1839
  // Handle error and notify coordinator
@@ -1798,7 +1905,7 @@ class Jqhtml_Component {
1798
1905
  this._log_lifecycle('ready', 'start');
1799
1906
  // Wait for all children to reach ready state (bottom-up execution)
1800
1907
  await this._wait_for_children_ready();
1801
- await this.on_ready();
1908
+ await this._call_lifecycle('on_ready');
1802
1909
  this._ready_state = 4;
1803
1910
  this._update_debug_attrs();
1804
1911
  this._log_lifecycle('ready', 'complete');
@@ -2014,7 +2121,7 @@ class Jqhtml_Component {
2014
2121
  this.data = JSON.parse(JSON.stringify(this.__initial_data_snapshot));
2015
2122
  }
2016
2123
  try {
2017
- await this.on_load();
2124
+ await this._call_lifecycle('on_load');
2018
2125
  }
2019
2126
  finally {
2020
2127
  // Freeze this.data after on_load() completes
@@ -2090,7 +2197,7 @@ class Jqhtml_Component {
2090
2197
  // STEP 3.5 & 4: Wait for children and call on_ready (only if we rendered)
2091
2198
  if (rendered_from_cache || should_render) {
2092
2199
  await this._wait_for_children_ready();
2093
- await this.on_ready();
2200
+ await this._call_lifecycle('on_ready');
2094
2201
  }
2095
2202
  this._log_lifecycle('reload', 'complete');
2096
2203
  }
@@ -2124,16 +2231,14 @@ class Jqhtml_Component {
2124
2231
  this.$.addClass('_Component_Stopped');
2125
2232
  // Unregister from lifecycle manager
2126
2233
  this._lifecycle_manager.unregister_component(this);
2127
- // Call user's on_stop() hook
2128
- const stopResult = this.on_stop();
2234
+ // Call user's on_stop() hook with authorization (sync)
2235
+ const stopResult = this._call_lifecycle_sync('on_stop');
2129
2236
  if (stopResult && typeof stopResult.then === 'function') {
2130
2237
  console.warn(`[JQHTML] Component "${this.component_name()}" returned a Promise from on_stop(). ` +
2131
2238
  `on_stop() must be synchronous code. Remove 'async' from the function declaration.`);
2132
2239
  }
2133
- // Fire registered destroy callbacks
2134
- this.trigger('destroy');
2135
- // Trigger jQuery destroy event
2136
- this.$.trigger('destroy');
2240
+ // Fire registered stop callbacks
2241
+ this.trigger('stop');
2137
2242
  // Remove from DOM parent's children
2138
2243
  if (this._dom_parent) {
2139
2244
  this._dom_parent._dom_children.delete(this);
@@ -2696,6 +2801,8 @@ class Jqhtml_Component {
2696
2801
  };
2697
2802
  }
2698
2803
  }
2804
+ // Static properties
2805
+ Jqhtml_Component.__jqhtml_component = true; // Marker for unified register() detection
2699
2806
 
2700
2807
  /**
2701
2808
  * JQHTML v2 Template Renderer
@@ -3091,388 +3198,6 @@ function hydrateElement($element, jQ) {
3091
3198
  }
3092
3199
  }
3093
3200
 
3094
- /**
3095
- * JQHTML Debug Overlay
3096
- *
3097
- * Independent debug controls using pure jQuery DOM manipulation.
3098
- * Does NOT use JQHTML components so it works even when components are broken.
3099
- */
3100
- // Get global jQuery
3101
- function getJQuery() {
3102
- if (typeof window !== 'undefined' && window.$) {
3103
- return window.$;
3104
- }
3105
- if (typeof window !== 'undefined' && window.jQuery) {
3106
- return window.jQuery;
3107
- }
3108
- throw new Error('FATAL: jQuery is not defined. jQuery must be loaded before using JQHTML. ' +
3109
- 'Add <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> before loading JQHTML.');
3110
- }
3111
- // Get global jqhtml object
3112
- function getJqhtml() {
3113
- if (typeof window !== 'undefined' && window.jqhtml) {
3114
- return window.jqhtml;
3115
- }
3116
- if (typeof globalThis !== 'undefined' && globalThis.jqhtml) {
3117
- return globalThis.jqhtml;
3118
- }
3119
- throw new Error('FATAL: window.jqhtml is not defined. The JQHTML runtime must be loaded before using JQHTML components. ' +
3120
- 'Ensure @jqhtml/core is imported and initialized before attempting to use debug features.');
3121
- }
3122
- class DebugOverlay {
3123
- constructor(options = {}) {
3124
- this.$container = null;
3125
- this.$statusIndicator = null;
3126
- this.$ = getJQuery();
3127
- if (!this.$) {
3128
- throw new Error('jQuery is required for DebugOverlay');
3129
- }
3130
- this.options = {
3131
- position: 'bottom',
3132
- theme: 'dark',
3133
- compact: false,
3134
- showStatus: true,
3135
- autoHide: false,
3136
- ...options
3137
- };
3138
- }
3139
- /**
3140
- * Static method to show debug overlay (singleton pattern)
3141
- */
3142
- static show(options) {
3143
- if (!DebugOverlay.instance) {
3144
- DebugOverlay.instance = new DebugOverlay(options);
3145
- }
3146
- DebugOverlay.instance.display();
3147
- return DebugOverlay.instance;
3148
- }
3149
- /**
3150
- * Static method to hide debug overlay
3151
- */
3152
- static hide() {
3153
- if (DebugOverlay.instance) {
3154
- DebugOverlay.instance.hide();
3155
- }
3156
- }
3157
- /**
3158
- * Static method to toggle debug overlay visibility
3159
- */
3160
- static toggle() {
3161
- if (DebugOverlay.instance && DebugOverlay.instance.$container) {
3162
- if (DebugOverlay.instance.$container.is(':visible')) {
3163
- DebugOverlay.hide();
3164
- }
3165
- else {
3166
- DebugOverlay.instance.display();
3167
- }
3168
- }
3169
- else {
3170
- DebugOverlay.show();
3171
- }
3172
- }
3173
- /**
3174
- * Static method to destroy debug overlay
3175
- */
3176
- static destroy() {
3177
- if (DebugOverlay.instance) {
3178
- DebugOverlay.instance.destroy();
3179
- DebugOverlay.instance = null;
3180
- }
3181
- }
3182
- /**
3183
- * Display the debug overlay
3184
- */
3185
- display() {
3186
- if (this.$container) {
3187
- this.$container.show();
3188
- return;
3189
- }
3190
- this.createOverlay();
3191
- if (this.options.showStatus) {
3192
- this.createStatusIndicator();
3193
- }
3194
- }
3195
- /**
3196
- * Hide the debug overlay
3197
- */
3198
- hide() {
3199
- if (this.$container) {
3200
- this.$container.hide();
3201
- }
3202
- if (this.$statusIndicator) {
3203
- this.$statusIndicator.hide();
3204
- }
3205
- }
3206
- /**
3207
- * Remove the debug overlay completely
3208
- */
3209
- destroy() {
3210
- if (this.$container) {
3211
- this.$container.remove();
3212
- this.$container = null;
3213
- }
3214
- if (this.$statusIndicator) {
3215
- this.$statusIndicator.remove();
3216
- this.$statusIndicator = null;
3217
- }
3218
- }
3219
- /**
3220
- * Update the status indicator
3221
- */
3222
- updateStatus(mode) {
3223
- if (!this.$statusIndicator)
3224
- return;
3225
- this.$statusIndicator.text('Debug: ' + mode);
3226
- this.$statusIndicator.attr('class', 'jqhtml-debug-status' + (mode !== 'Off' ? ' active' : ''));
3227
- }
3228
- createOverlay() {
3229
- // Add styles first
3230
- this.addStyles();
3231
- // Create container using jQuery
3232
- this.$container = this.$('<div>')
3233
- .addClass(`jqhtml-debug-overlay ${this.options.theme} ${this.options.position}`);
3234
- // Create content structure
3235
- const $content = this.$('<div>').addClass('jqhtml-debug-content');
3236
- const $controls = this.$('<div>').addClass('jqhtml-debug-controls');
3237
- // Add title
3238
- const $title = this.$('<span>')
3239
- .addClass('jqhtml-debug-title')
3240
- .html('<strong>🐛 JQHTML Debug:</strong>');
3241
- $controls.append($title);
3242
- // Create buttons
3243
- const buttons = [
3244
- { text: 'Slow Motion + Flash', action: 'enableSlowMotionDebug', class: 'success' },
3245
- { text: 'Basic Debug', action: 'enableBasicDebug', class: '' },
3246
- { text: 'Full Debug', action: 'enableFullDebug', class: '' },
3247
- { text: 'Sequential', action: 'enableSequentialMode', class: '' },
3248
- { text: 'Clear Debug', action: 'clearAllDebug', class: 'danger' },
3249
- { text: 'Settings', action: 'showDebugInfo', class: '' }
3250
- ];
3251
- buttons.forEach(btn => {
3252
- const $button = this.$('<button>')
3253
- .text(btn.text)
3254
- .addClass('jqhtml-debug-btn' + (btn.class ? ` ${btn.class}` : ''))
3255
- .on('click', () => this.executeAction(btn.action));
3256
- $controls.append($button);
3257
- });
3258
- // Add minimize/close button
3259
- const $toggleBtn = this.$('<button>')
3260
- .text(this.options.compact ? '▼' : '▲')
3261
- .addClass('jqhtml-debug-toggle')
3262
- .on('click', () => this.toggle());
3263
- $controls.append($toggleBtn);
3264
- // Assemble and add to page
3265
- $content.append($controls);
3266
- this.$container.append($content);
3267
- this.$('body').append(this.$container);
3268
- }
3269
- createStatusIndicator() {
3270
- this.$statusIndicator = this.$('<div>')
3271
- .addClass('jqhtml-debug-status')
3272
- .text('Debug: Off')
3273
- .css({
3274
- position: 'fixed',
3275
- top: '10px',
3276
- right: '10px',
3277
- background: '#2c3e50',
3278
- color: 'white',
3279
- padding: '5px 10px',
3280
- borderRadius: '4px',
3281
- fontSize: '0.75rem',
3282
- zIndex: '10001',
3283
- opacity: '0.8',
3284
- fontFamily: 'monospace'
3285
- });
3286
- this.$('body').append(this.$statusIndicator);
3287
- }
3288
- addStyles() {
3289
- // Check if styles already exist
3290
- if (this.$('#jqhtml-debug-styles').length > 0)
3291
- return;
3292
- // Create and inject CSS using jQuery - concatenated strings for better minification
3293
- const $style = this.$('<style>')
3294
- .attr('id', 'jqhtml-debug-styles')
3295
- .text('.jqhtml-debug-overlay {' +
3296
- 'position: fixed;' +
3297
- 'left: 0;' +
3298
- 'right: 0;' +
3299
- 'z-index: 10000;' +
3300
- 'font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;' +
3301
- 'font-size: 0.8rem;' +
3302
- 'box-shadow: 0 2px 10px rgba(0,0,0,0.2);' +
3303
- '}' +
3304
- '.jqhtml-debug-overlay.top {' +
3305
- 'top: 0;' +
3306
- '}' +
3307
- '.jqhtml-debug-overlay.bottom {' +
3308
- 'bottom: 0;' +
3309
- '}' +
3310
- '.jqhtml-debug-overlay.dark {' +
3311
- 'background: #34495e;' +
3312
- 'color: #ecf0f1;' +
3313
- '}' +
3314
- '.jqhtml-debug-overlay.light {' +
3315
- 'background: #f8f9fa;' +
3316
- 'color: #333;' +
3317
- 'border-bottom: 1px solid #dee2e6;' +
3318
- '}' +
3319
- '.jqhtml-debug-content {' +
3320
- 'padding: 0.5rem 1rem;' +
3321
- '}' +
3322
- '.jqhtml-debug-controls {' +
3323
- 'display: flex;' +
3324
- 'flex-wrap: wrap;' +
3325
- 'gap: 8px;' +
3326
- 'align-items: center;' +
3327
- '}' +
3328
- '.jqhtml-debug-title {' +
3329
- 'margin-right: 10px;' +
3330
- 'font-weight: bold;' +
3331
- '}' +
3332
- '.jqhtml-debug-btn {' +
3333
- 'padding: 4px 8px;' +
3334
- 'border: none;' +
3335
- 'border-radius: 3px;' +
3336
- 'background: #3498db;' +
3337
- 'color: white;' +
3338
- 'cursor: pointer;' +
3339
- 'font-size: 0.75rem;' +
3340
- 'transition: background 0.2s;' +
3341
- '}' +
3342
- '.jqhtml-debug-btn:hover {' +
3343
- 'background: #2980b9;' +
3344
- '}' +
3345
- '.jqhtml-debug-btn.success {' +
3346
- 'background: #27ae60;' +
3347
- '}' +
3348
- '.jqhtml-debug-btn.success:hover {' +
3349
- 'background: #229954;' +
3350
- '}' +
3351
- '.jqhtml-debug-btn.danger {' +
3352
- 'background: #e74c3c;' +
3353
- '}' +
3354
- '.jqhtml-debug-btn.danger:hover {' +
3355
- 'background: #c0392b;' +
3356
- '}' +
3357
- '.jqhtml-debug-toggle {' +
3358
- 'padding: 4px 8px;' +
3359
- 'border: none;' +
3360
- 'border-radius: 3px;' +
3361
- 'background: #7f8c8d;' +
3362
- 'color: white;' +
3363
- 'cursor: pointer;' +
3364
- 'font-size: 0.75rem;' +
3365
- 'margin-left: auto;' +
3366
- '}' +
3367
- '.jqhtml-debug-toggle:hover {' +
3368
- 'background: #6c7b7d;' +
3369
- '}' +
3370
- '.jqhtml-debug-status.active {' +
3371
- 'background: #27ae60 !important;' +
3372
- '}' +
3373
- '@media (max-width: 768px) {' +
3374
- '.jqhtml-debug-controls {' +
3375
- 'flex-direction: column;' +
3376
- 'align-items: flex-start;' +
3377
- '}' +
3378
- '.jqhtml-debug-title {' +
3379
- 'margin-bottom: 5px;' +
3380
- '}' +
3381
- '}');
3382
- this.$('head').append($style);
3383
- }
3384
- toggle() {
3385
- // Toggle between compact and full view
3386
- this.options.compact = !this.options.compact;
3387
- const $toggleBtn = this.$container.find('.jqhtml-debug-toggle');
3388
- $toggleBtn.text(this.options.compact ? '▼' : '▲');
3389
- const $buttons = this.$container.find('.jqhtml-debug-btn');
3390
- if (this.options.compact) {
3391
- $buttons.hide();
3392
- }
3393
- else {
3394
- $buttons.show();
3395
- }
3396
- }
3397
- executeAction(action) {
3398
- const jqhtml = getJqhtml();
3399
- if (!jqhtml) {
3400
- console.warn('JQHTML not available - make sure it\'s loaded and exposed globally');
3401
- return;
3402
- }
3403
- switch (action) {
3404
- case 'enableSlowMotionDebug':
3405
- jqhtml.setDebugSettings({
3406
- logFullLifecycle: true,
3407
- sequentialProcessing: true,
3408
- delayAfterComponent: 150,
3409
- delayAfterRender: 200,
3410
- delayAfterRerender: 250,
3411
- flashComponents: true,
3412
- flashDuration: 800,
3413
- flashColors: {
3414
- create: '#3498db',
3415
- render: '#27ae60',
3416
- ready: '#9b59b6'
3417
- },
3418
- profilePerformance: true,
3419
- highlightSlowRenders: 30,
3420
- logDispatch: true
3421
- });
3422
- this.updateStatus('Slow Motion');
3423
- console.log('🐛 Slow Motion Debug Mode Enabled');
3424
- break;
3425
- case 'enableBasicDebug':
3426
- jqhtml.enableDebugMode('basic');
3427
- this.updateStatus('Basic');
3428
- console.log('🐛 Basic Debug Mode Enabled');
3429
- break;
3430
- case 'enableFullDebug':
3431
- jqhtml.enableDebugMode('full');
3432
- this.updateStatus('Full');
3433
- console.log('🐛 Full Debug Mode Enabled');
3434
- break;
3435
- case 'enableSequentialMode':
3436
- jqhtml.setDebugSettings({
3437
- logCreationReady: true,
3438
- sequentialProcessing: true,
3439
- flashComponents: true,
3440
- profilePerformance: true
3441
- });
3442
- this.updateStatus('Sequential');
3443
- console.log('🐛 Sequential Processing Mode Enabled');
3444
- break;
3445
- case 'clearAllDebug':
3446
- jqhtml.clearDebugSettings();
3447
- this.updateStatus('Off');
3448
- console.log('🐛 All Debug Modes Disabled');
3449
- break;
3450
- case 'showDebugInfo':
3451
- const settings = JSON.stringify(jqhtml.debug, null, 2);
3452
- console.log('🐛 Current Debug Settings:', settings);
3453
- alert('Debug settings logged to console:\n\n' + (Object.keys(jqhtml.debug).length > 0 ? settings : 'No debug settings active'));
3454
- break;
3455
- }
3456
- }
3457
- }
3458
- DebugOverlay.instance = null;
3459
- // Simplified global convenience functions that use static methods
3460
- function showDebugOverlay(options) {
3461
- return DebugOverlay.show(options);
3462
- }
3463
- function hideDebugOverlay() {
3464
- DebugOverlay.hide();
3465
- }
3466
- // Auto-initialize if debug query parameter is present
3467
- if (typeof window !== 'undefined') {
3468
- const urlParams = new URLSearchParams(window.location.search);
3469
- if (urlParams.get('debug') === 'true' || urlParams.get('jqhtml-debug') === 'true') {
3470
- document.addEventListener('DOMContentLoaded', () => {
3471
- DebugOverlay.show();
3472
- });
3473
- }
3474
- }
3475
-
3476
3201
  /**
3477
3202
  * JQHTML v2 jQuery Plugin
3478
3203
  *
@@ -3669,47 +3394,6 @@ function init_jquery_plugin(jQuery) {
3669
3394
  // Return the jQuery element to enable chaining (fluent interface pattern)
3670
3395
  return targetElement;
3671
3396
  };
3672
- // Store original jQuery methods for overriding
3673
- const _jqhtml_jquery_overrides = {};
3674
- // EXPERIMENTAL: Override DOM manipulation methods to support component instances as arguments
3675
- // and to trigger ready() when components are added to the DOM
3676
- // NOTE: This feature needs thorough testing in production scenarios
3677
- const dom_insertion_methods = ['append', 'prepend', 'before', 'after', 'replaceWith'];
3678
- for (const fnname of dom_insertion_methods) {
3679
- _jqhtml_jquery_overrides[fnname] = jQuery.fn[fnname];
3680
- jQuery.fn[fnname] = function (...args) {
3681
- // Resolve all component instances into jQuery elements
3682
- const resolvedArgs = args.map(arg => {
3683
- if (arg && typeof arg === 'object' && arg instanceof Jqhtml_Component) {
3684
- return arg.$;
3685
- }
3686
- return arg;
3687
- });
3688
- // Make a list of all jQuery elements in the arguments
3689
- const $elements = resolvedArgs.filter((arg) => arg instanceof jQuery);
3690
- // Call the original jQuery method with resolved arguments
3691
- const ret = _jqhtml_jquery_overrides[fnname].apply(this, resolvedArgs);
3692
- // For each jQuery element that is now in the DOM and hasn't triggered ready yet,
3693
- // find any uninitialized components and boot them
3694
- for (const $e of $elements) {
3695
- // Check if element is in the DOM
3696
- if ($e.closest('html').length > 0) {
3697
- // Find any components that haven't been initialized yet
3698
- $e.find('.Component').addBack('.Component').each(function () {
3699
- const $comp = jQuery(this);
3700
- const component = $comp.data('_component');
3701
- // If component exists and hasn't been booted yet, boot it
3702
- if (component && !component._ready_state) {
3703
- component._boot();
3704
- }
3705
- });
3706
- }
3707
- }
3708
- return ret;
3709
- };
3710
- }
3711
- // Note: Component destruction is handled automatically by MutationObserver
3712
- // in lifecycle-manager.ts. No jQuery method overrides needed for cleanup.
3713
3397
  /**
3714
3398
  * shallowFind - Find nearest descendants matching selector
3715
3399
  *
@@ -4371,16 +4055,17 @@ function init(jQuery) {
4371
4055
  }
4372
4056
  }
4373
4057
  // Version - will be replaced during build with actual version from package.json
4374
- const version = '2.3.4';
4058
+ const version = '2.3.9';
4375
4059
  // Default export with all functionality
4376
4060
  const jqhtml = {
4377
4061
  // Core
4378
4062
  Jqhtml_Component,
4379
4063
  LifecycleManager,
4380
4064
  // Registry
4065
+ register,
4381
4066
  register_component,
4382
- get_component_class,
4383
4067
  register_template,
4068
+ get_component_class,
4384
4069
  get_template,
4385
4070
  get_template_by_class,
4386
4071
  create_component,
@@ -4395,6 +4080,8 @@ const jqhtml = {
4395
4080
  escape_html,
4396
4081
  // Version property - internal
4397
4082
  __version: version,
4083
+ // state facts
4084
+ tombstone: 'pepperoni and cheese',
4398
4085
  // Debug settings
4399
4086
  debug: {
4400
4087
  enabled: false,
@@ -4421,15 +4108,6 @@ const jqhtml = {
4421
4108
  clearDebugSettings() {
4422
4109
  this.debug = {};
4423
4110
  },
4424
- // Debug overlay methods
4425
- showDebugOverlay(options) {
4426
- return DebugOverlay.show(options);
4427
- },
4428
- hideDebugOverlay() {
4429
- return DebugOverlay.hide();
4430
- },
4431
- // Export DebugOverlay class for direct access
4432
- DebugOverlay,
4433
4111
  // Install globals function
4434
4112
  installGlobals() {
4435
4113
  if (typeof window !== 'undefined') {
@@ -4483,5 +4161,5 @@ if (typeof window !== 'undefined' && !window.jqhtml) {
4483
4161
  }
4484
4162
  }
4485
4163
 
4486
- 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 };
4164
+ export { 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, init, init_jquery_plugin, isSequentialProcessing, list_components, logDataChange, logDispatch, logInstruction, logLifecycle, process_instructions, register, register_component, register_template, render_template, version };
4487
4165
  //# sourceMappingURL=index.js.map