@jqhtml/core 2.3.61 → 2.3.64

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.d.ts CHANGED
@@ -8,6 +8,7 @@ export { LifecycleManager } from './lifecycle-manager.js';
8
8
  export type { LifecyclePhase } from './lifecycle-manager.js';
9
9
  export { register, register_component, register_template, get_component_class, get_template, get_template_by_class, create_component, has_component, get_component_names, get_registered_templates, list_components } from './component-registry.js';
10
10
  export type { ComponentConstructor, TemplateFunction, TemplateDefinition } from './component-registry.js';
11
+ export { COMPONENT_NAME_PATTERN, COMPONENT_NAME_RULE, is_component_name } from './component-name.js';
11
12
  export { process_instructions, extract_slots } from './instruction-processor.js';
12
13
  export type { Instruction, TagInstruction, ComponentInstruction, SlotInstruction } from './instruction-processor.js';
13
14
  export { render_template, escape_html, escape_html_nl2br } from './template-renderer.js';
@@ -1 +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,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,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;AAG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AY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAGD,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;WAuCL,aAAa,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE;+BAGhC,aAAa;4BAIjB,OAAO,GAAG,MAAM;;;;;6BAuDd,MAAM,eAAc,MAAM,GAAG,MAAM;;;;;;;;;CAsB7D,CAAC;AAgCF,eAAe,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -199,6 +199,21 @@ class LifecycleManager {
199
199
  }
200
200
  }
201
201
 
202
+ /**
203
+ * The one rule for "is this name a component?"
204
+ *
205
+ * An optional SINGLE leading underscore, then a capital letter, then letters,
206
+ * digits and underscores. The underscore prefix is a namespace reserved for
207
+ * framework-provided components (`_Root_Layout`) so they cannot collide with
208
+ * application components. Two or more leading underscores are not a component
209
+ * name; a lower-case first letter after the optional underscore is an HTML tag.
210
+ */
211
+ const COMPONENT_NAME_PATTERN = /^_?[A-Z][A-Za-z0-9_]*$/;
212
+ const COMPONENT_NAME_RULE = 'must start with a capital letter, optionally preceded by a single underscore';
213
+ function is_component_name(name) {
214
+ return COMPONENT_NAME_PATTERN.test(name);
215
+ }
216
+
202
217
  /**
203
218
  * JQHTML v2 Component Registry
204
219
  *
@@ -245,9 +260,9 @@ function register_component(nameOrClass, component_class, template) {
245
260
  if (!component_class) {
246
261
  throw new Error('Component class is required when registering by name');
247
262
  }
248
- // Validate component name starts with capital letter
249
- if (!/^[A-Z]/.test(name)) {
250
- throw new Error(`Component name '${name}' must start with a capital letter. Convention is First_Letter_With_Underscores.`);
263
+ // Validate component name against the shared rule
264
+ if (!is_component_name(name)) {
265
+ throw new Error(`Component name '${name}' ${COMPONENT_NAME_RULE}. Convention is First_Letter_With_Underscores.`);
251
266
  }
252
267
  component_classes.set(name, component_class);
253
268
  // If template provided, register it
@@ -316,9 +331,9 @@ function register_template(template_def) {
316
331
  if (!name) {
317
332
  throw new Error('Template must have a name property');
318
333
  }
319
- // Validate template name starts with capital letter
320
- if (!/^[A-Z]/.test(name)) {
321
- throw new Error(`Template name '${name}' must start with a capital letter. Convention is First_Letter_With_Underscores.`);
334
+ // Validate template name against the shared rule
335
+ if (!is_component_name(name)) {
336
+ throw new Error(`Template name '${name}' ${COMPONENT_NAME_RULE}. Convention is First_Letter_With_Underscores.`);
322
337
  }
323
338
  // Check for duplicate registration
324
339
  if (component_templates.has(name)) {
@@ -1847,7 +1862,7 @@ Load_Coordinator._registry = new Map();
1847
1862
  const class_registry = Object.create(null);
1848
1863
  // Markers for serialized class instances (unique to avoid collisions with user data)
1849
1864
  // Replaced at build time by rollup (see rollup.config.js).
1850
- const CORE_VERSION = '2.3.61';
1865
+ const CORE_VERSION = '2.3.64';
1851
1866
  const CLASS_MARKER = '__jqhtml_class__';
1852
1867
  const PROPS_MARKER = '__jqhtml_props__';
1853
1868
  /**
@@ -4982,7 +4997,8 @@ class Jqhtml_Component {
4982
4997
  * Find closest ancestor component matching selector
4983
4998
  *
4984
4999
  * A bare component name - a plain identifier starting with a capital letter,
4985
- * such as 'Parent_Dashboard' - is treated as the component-name class
5000
+ * optionally preceded by a single underscore, such as 'Parent_Dashboard' or
5001
+ * '_Root_Layout' - is treated as the component-name class
4986
5002
  * selector '.Parent_Dashboard'. Components carry a CSS class for every name
4987
5003
  * in their prototype chain, so a base class name matches its subclasses too.
4988
5004
  * Every other selector ('.Foo', '#id', '[attr]', 'div > .Component') is
@@ -5059,14 +5075,16 @@ class Jqhtml_Component {
5059
5075
  // Add component name at the beginning (most specific)
5060
5076
  classesToAdd.unshift(this.args._component_name);
5061
5077
  }
5062
- // Filter out private classes (starting with _) and invalid class names
5078
+ // Filter out private/mangled classes (starting with _) and invalid class names.
5079
+ // A component name with the reserved single-underscore prefix (_Root_Layout)
5080
+ // is public and is kept - see component-name.ts.
5063
5081
  const publicClasses = classesToAdd.filter(className => {
5064
5082
  // Guard against undefined, null, or non-string values
5065
5083
  if (!className || typeof className !== 'string') {
5066
5084
  console.warn('[JQHTML] Filtered out invalid class name:', className);
5067
5085
  return false;
5068
5086
  }
5069
- return !className.startsWith('_');
5087
+ return !className.startsWith('_') || is_component_name(className);
5070
5088
  });
5071
5089
  if (publicClasses.length > 0) {
5072
5090
  this.$.addClass(publicClasses.join(' '));
@@ -5272,7 +5290,7 @@ class Jqhtml_Component {
5272
5290
  // Static properties
5273
5291
  Jqhtml_Component.__jqhtml_component = true; // Marker for unified register() detection
5274
5292
  // A bare component name, as accepted by closest() in place of a class selector
5275
- Jqhtml_Component.COMPONENT_NAME_PATTERN = /^[A-Z][A-Za-z0-9_]*$/;
5293
+ Jqhtml_Component.COMPONENT_NAME_PATTERN = COMPONENT_NAME_PATTERN;
5276
5294
 
5277
5295
  /**
5278
5296
  * JQHTML v2 Template Renderer
@@ -5794,16 +5812,20 @@ function init_jquery_plugin(jQuery) {
5794
5812
  catch (error) {
5795
5813
  console.warn('[JQHTML] Error stopping existing component during replacement:', error);
5796
5814
  }
5797
- // Remove component classes (any class starting with capital letter, except BEM classes)
5815
+ // Remove component classes (any class starting with a capital letter, or a
5816
+ // component name with the reserved underscore prefix - except BEM classes)
5798
5817
  const classes = element.attr('class');
5799
5818
  if (classes) {
5800
5819
  const classList = classes.split(/\s+/);
5801
5820
  const nonComponentClasses = classList.filter((cls) => {
5802
5821
  // Keep class if:
5803
5822
  // 1. It's empty
5804
- // 2. It doesn't start with a capital letter
5823
+ // 2. It is neither capital-first nor a component name (see component-name.ts)
5805
5824
  // 3. It's a BEM-style class (contains __) - these persist across reinitialization
5806
- return !cls || cls[0] !== cls[0].toUpperCase() || cls[0] === cls[0].toLowerCase() || cls.includes('__');
5825
+ if (!cls || cls.includes('__'))
5826
+ return true;
5827
+ const capital_first = cls[0] === cls[0].toUpperCase() && cls[0] !== cls[0].toLowerCase();
5828
+ return !capital_first && !is_component_name(cls);
5807
5829
  });
5808
5830
  element.attr('class', nonComponentClasses.join(' '));
5809
5831
  }
@@ -6169,7 +6191,7 @@ function init(jQuery, config) {
6169
6191
  }
6170
6192
  }
6171
6193
  // Version - will be replaced during build with actual version from package.json
6172
- const version = '2.3.61';
6194
+ const version = '2.3.64';
6173
6195
  // Default export with all functionality
6174
6196
  const jqhtml = {
6175
6197
  // Core
@@ -6305,5 +6327,5 @@ if (typeof window !== 'undefined' && !window.jqhtml) {
6305
6327
  }
6306
6328
  }
6307
6329
 
6308
- export { Jqhtml_Component, LifecycleManager as Jqhtml_LifecycleManager, Jqhtml_Local_Storage, LifecycleManager, Load_Coordinator, applyDebugDelay, boot, clear_preload_data, configure, create_component, jqhtml as default, devWarn, escape_html, escape_html_nl2br, extract_slots, get_captured_data, get_component_class, get_component_names, get_config, 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_cache_class, register_component, register_template, render_template, set_preload_data, start_data_capture, stop_data_capture, version };
6330
+ export { COMPONENT_NAME_PATTERN, COMPONENT_NAME_RULE, Jqhtml_Component, LifecycleManager as Jqhtml_LifecycleManager, Jqhtml_Local_Storage, LifecycleManager, Load_Coordinator, applyDebugDelay, boot, clear_preload_data, configure, create_component, jqhtml as default, devWarn, escape_html, escape_html_nl2br, extract_slots, get_captured_data, get_component_class, get_component_names, get_config, get_registered_templates, get_template, get_template_by_class, handleComponentError, has_component, init, init_jquery_plugin, isSequentialProcessing, is_component_name, list_components, logDataChange, logDispatch, logInstruction, logLifecycle, process_instructions, register, register_cache_class, register_component, register_template, render_template, set_preload_data, start_data_capture, stop_data_capture, version };
6309
6331
  //# sourceMappingURL=index.js.map