ladrillosjs 2.0.0-beta.1.1 → 2.0.0-beta.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # LadrillosJS
2
2
 
3
- <img src="https://raw.githubusercontent.com/drubiodev/LadrillosJS/refs/heads/main/LadrillosJS.png" alt="LadrillosJS" width="400"/>
3
+ <img src="https://raw.githubusercontent.com/drubiodev/LadrillosJS/refs/heads/main/LadrillosJS.jpg" alt="LadrillosJS" width="400"/>
4
4
 
5
5
  A lightweight, zero-dependency web component framework for building modular web applications.
6
6
 
@@ -19,15 +19,22 @@ A lightweight, zero-dependency web component framework for building modular web
19
19
  - [Event Handling](#event-handling)
20
20
  - [Data Binding](#data-binding)
21
21
  - [Conditional Rendering](#conditional-rendering)
22
+ - [List Rendering](#list-rendering)
22
23
  - [Slots](#slots)
24
+ - [Component Props](#component-props)
23
25
  - [Advanced Features](#advanced-features)
24
26
  - [Global Event Bus](#global-event-bus)
25
27
  - [External Scripts](#external-scripts)
26
28
  - [Shadow DOM](#shadow-dom)
29
+ - [Styling Components](#styling-components)
27
30
  - [Performance & Caching](#performance--caching)
31
+ - [Common Patterns](#common-patterns)
32
+ - [Keyboard Events](#keyboard-events)
33
+ - [Form Validation](#form-validation)
34
+ - [Loading States](#loading-states)
28
35
  - [API Reference](#api-reference)
29
- - [Examples](#examples)
30
36
  - [Development](#development)
37
+ - [Attribution](#attribution)
31
38
  - [License](#license)
32
39
 
33
40
  ## Features
@@ -41,7 +48,8 @@ A lightweight, zero-dependency web component framework for building modular web
41
48
  - 🔌 **Slots** - Content projection with named and default slots
42
49
  - 📝 **TypeScript** - Full type definitions and TypeScript source code
43
50
  - 🎭 **Conditional Rendering** - `$if`, `$else-if`, and `$else` directives
44
- - 🚄 **Smart Caching** - LRU cache for components and compiled functions
51
+ - **List Rendering** - `$for` directive for rendering arrays
52
+ - �🚄 **Smart Caching** - LRU cache for components and compiled functions
45
53
  - 🔧 **Framework Utilities** - Helper functions for common tasks
46
54
  - 🧩 **External Scripts** - Load and bind external JavaScript modules
47
55
 
@@ -155,6 +163,7 @@ Check out the `samples/apps/` directory for complete examples:
155
163
  - **[Business Card](samples/apps/biz)** - Form with two-way data binding
156
164
  - **[Slideshow](samples/apps/slideshow)** - Multi-slide presentation
157
165
  - **[Markdown Editor](samples/apps/markdown)** - Real-time markdown preview
166
+ - **[List Rendering](samples/apps/list-test)** - Dynamic lists with `$for` directive
158
167
 
159
168
  Run the development server to view examples:
160
169
 
@@ -403,6 +412,87 @@ Show or hide elements based on conditions:
403
412
  - `$else-if="{expression}"`: Chain multiple conditions
404
413
  - `$else`: Fallback when previous conditions are false
405
414
 
415
+ ### List Rendering
416
+
417
+ Render lists of items using the `$for` directive:
418
+
419
+ ```html
420
+ <div>
421
+ <h2>My Fruits</h2>
422
+ <ul>
423
+ <li $for="fruit in fruits">{fruit}</li>
424
+ </ul>
425
+ <button onclick="addFruit()">Add Fruit</button>
426
+ </div>
427
+
428
+ <script>
429
+ let fruits = ["Apple", "Banana", "Orange"];
430
+
431
+ const addFruit = () => {
432
+ const newFruit = prompt("Enter a fruit name:");
433
+ if (newFruit) {
434
+ fruits = [...fruits, newFruit]; // Triggers re-render
435
+ }
436
+ };
437
+ </script>
438
+ ```
439
+
440
+ **List Rendering with Objects:**
441
+
442
+ ```html
443
+ <div>
444
+ <h2>User List</h2>
445
+ <div class="user-card" $for="user in users">
446
+ <h3>{user.name}</h3>
447
+ <p>Email: {user.email}</p>
448
+ </div>
449
+ </div>
450
+
451
+ <script>
452
+ let users = [
453
+ { name: "John Doe", email: "john@example.com" },
454
+ { name: "Jane Smith", email: "jane@example.com" },
455
+ ];
456
+ </script>
457
+ ```
458
+
459
+ **With Index:**
460
+
461
+ ```html
462
+ <ul>
463
+ <li $for="(item, index) in items">{index + 1}. {item}</li>
464
+ </ul>
465
+
466
+ <script>
467
+ let items = ["First", "Second", "Third"];
468
+ </script>
469
+ ```
470
+
471
+ **Performance Optimization with `$key`:**
472
+
473
+ Use the `$key` attribute to help LadrillosJS track items efficiently:
474
+
475
+ ```html
476
+ <div>
477
+ <div class="user-card" $for="user in users" $key="user.id">
478
+ <h3>{user.name}</h3>
479
+ <p>Email: {user.email}</p>
480
+ <button onclick="removeUser(user.id)">Remove</button>
481
+ </div>
482
+ </div>
483
+
484
+ <script>
485
+ let users = [
486
+ { id: 1, name: "John", email: "john@example.com" },
487
+ { id: 2, name: "Jane", email: "jane@example.com" },
488
+ ];
489
+
490
+ const removeUser = (id) => {
491
+ users = users.filter((u) => u.id !== id);
492
+ };
493
+ </script>
494
+ ```
495
+
406
496
  ### Slots
407
497
 
408
498
  Project content from parent to child components:
@@ -451,6 +541,31 @@ Project content from parent to child components:
451
541
  </my-card>
452
542
  ```
453
543
 
544
+ ### Component Props
545
+
546
+ Pass data to components using HTML attributes:
547
+
548
+ ```html
549
+ <!-- greeting.html -->
550
+ <div>
551
+ <h1>Hello, {name}!</h1>
552
+ <p>Age: {age}</p>
553
+ </div>
554
+
555
+ <script>
556
+ // Access attributes passed to the component
557
+ let name = this.getAttribute("name") || "Guest";
558
+ let age = this.getAttribute("age") || "unknown";
559
+ </script>
560
+ ```
561
+
562
+ **Usage:**
563
+
564
+ ```html
565
+ <my-greeting name="John" age="25"></my-greeting>
566
+ <my-greeting name="Jane" age="30"></my-greeting>
567
+ ```
568
+
454
569
  ## Advanced Features
455
570
 
456
571
  ### Global Event Bus
@@ -640,6 +755,71 @@ await registerComponent("global-styles", "./global.html", false);
640
755
  - Using third-party libraries that expect normal DOM
641
756
  - Easier debugging without shadow boundaries
642
757
 
758
+ ### Styling Components
759
+
760
+ LadrillosJS supports multiple ways to style your components:
761
+
762
+ #### 1. Inline Styles (Scoped)
763
+
764
+ ```html
765
+ <div class="button">{label}</div>
766
+
767
+ <style>
768
+ .button {
769
+ padding: 10px 20px;
770
+ background: #007bff;
771
+ color: white;
772
+ }
773
+ </style>
774
+
775
+ <script>
776
+ let label = "Click me";
777
+ </script>
778
+ ```
779
+
780
+ #### 2. External Stylesheets
781
+
782
+ ```html
783
+ <link rel="stylesheet" href="./styles.css" />
784
+ <div class="container">Content</div>
785
+ ```
786
+
787
+ #### 3. Import Fonts and External CSS
788
+
789
+ ```html
790
+ <style>
791
+ @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap");
792
+
793
+ body {
794
+ font-family: "Roboto", sans-serif;
795
+ }
796
+ </style>
797
+ ```
798
+
799
+ #### 4. Using `:host` Selector (Shadow DOM)
800
+
801
+ When using Shadow DOM, style the component's container with `:host`:
802
+
803
+ ```html
804
+ <style>
805
+ :host {
806
+ display: block;
807
+ padding: 1rem;
808
+ background: white;
809
+ }
810
+
811
+ :host(.highlighted) {
812
+ border: 2px solid gold;
813
+ }
814
+ </style>
815
+ ```
816
+
817
+ **Usage:**
818
+
819
+ ```html
820
+ <my-component class="highlighted"></my-component>
821
+ ```
822
+
643
823
  ### Performance & Caching
644
824
 
645
825
  LadrillosJS includes built-in performance optimizations:
@@ -663,6 +843,101 @@ LadrillosJS includes built-in performance optimizations:
663
843
  - Event listeners are automatically cleaned up
664
844
  - Conditional rendering skips hidden elements
665
845
 
846
+ ## Common Patterns
847
+
848
+ ### Keyboard Events
849
+
850
+ Handle keyboard input for interactive features:
851
+
852
+ ```html
853
+ <div>
854
+ <p>Press arrow keys to navigate. Current: {direction}</p>
855
+ <p>Press Enter to submit</p>
856
+ </div>
857
+
858
+ <script>
859
+ let direction = "none";
860
+
861
+ document.addEventListener("keyup", (event) => {
862
+ if (event.key === "ArrowRight") {
863
+ direction = "right";
864
+ } else if (event.key === "ArrowLeft") {
865
+ direction = "left";
866
+ } else if (event.key === "ArrowUp") {
867
+ direction = "up";
868
+ } else if (event.key === "ArrowDown") {
869
+ direction = "down";
870
+ } else if (event.key === "Enter") {
871
+ direction = "submitted!";
872
+ }
873
+ });
874
+ </script>
875
+ ```
876
+
877
+ ### Form Validation
878
+
879
+ Real-time form validation with reactive state:
880
+
881
+ ```html
882
+ <form onsubmit="handleSubmit(event)">
883
+ <input type="email" $bind="email" placeholder="Email" onkeyup="validate()" />
884
+ <p $if="{!isValid}" style="color: red">Please enter a valid email</p>
885
+ <button type="submit" $if="{isValid}">Submit</button>
886
+ </form>
887
+
888
+ <script>
889
+ let email = "";
890
+ let isValid = false;
891
+
892
+ const validate = () => {
893
+ isValid = email.includes("@") && email.length > 5;
894
+ };
895
+
896
+ const handleSubmit = (e) => {
897
+ e.preventDefault();
898
+ if (isValid) {
899
+ alert(`Submitted: ${email}`);
900
+ }
901
+ };
902
+ </script>
903
+ ```
904
+
905
+ ### Loading States
906
+
907
+ Show loading indicators while fetching data:
908
+
909
+ ```html
910
+ <div>
911
+ <div $if="{isLoading}">Loading...</div>
912
+ <div $else-if="{error}">Error: {error}</div>
913
+ <div $else>
914
+ <h2>{data.title}</h2>
915
+ <p>{data.description}</p>
916
+ </div>
917
+ <button onclick="fetchData()">Refresh</button>
918
+ </div>
919
+
920
+ <script>
921
+ let isLoading = false;
922
+ let error = null;
923
+ let data = { title: "", description: "" };
924
+
925
+ const fetchData = async () => {
926
+ isLoading = true;
927
+ error = null;
928
+
929
+ try {
930
+ const response = await fetch("https://api.example.com/data");
931
+ data = await response.json();
932
+ } catch (e) {
933
+ error = e.message;
934
+ } finally {
935
+ isLoading = false;
936
+ }
937
+ };
938
+ </script>
939
+ ```
940
+
666
941
  ## API Reference
667
942
 
668
943
  ### Registration Functions
@@ -704,6 +979,11 @@ $reactive(name: string, initialValue: any): (value: any) => void
704
979
  <div $else-if="{anotherCondition}">...</div>
705
980
  <div $else>...</div>
706
981
 
982
+ <!-- List rendering -->
983
+ <li $for="item in items">{item}</li>
984
+ <li $for="(item, index) in items">{index}: {item}</li>
985
+ <div $for="user in users" $key="user.id">{user.name}</div>
986
+
707
987
  <!-- Event handlers -->
708
988
  <button onclick="methodName()">Click</button>
709
989
  <button onclick="method(arg1, arg2)">Call with args</button>
@@ -811,6 +1091,10 @@ npm run test:coverage # Run tests with coverage report
811
1091
  npm run preview # Preview production build
812
1092
  ```
813
1093
 
1094
+ ## Attribution
1095
+
1096
+ If you use LadrillosJS in your project, I'd appreciate a mention or link back to this repository, though it's not required. It helps others discover the framework and motivates continued development!
1097
+
814
1098
  ## License
815
1099
 
816
1100
  MIT License - see [LICENSE](LICENSE) file for details.
@@ -1,4 +1,4 @@
1
- import { BindingDescriptor, ConditionalDescriptor } from "../../types/LadrilloTypes";
1
+ import { BindingDescriptor, ConditionalDescriptor, LoopDescriptor } from "../../types/LadrilloTypes";
2
2
  /**
3
3
  * Safely sets a nested value in an object using a path array.
4
4
  * Example: setValue({ user: {} }, ['user', 'name'], 'John') sets user.name to 'John'
@@ -16,3 +16,8 @@ export declare const renderBindings: (bindings: BindingDescriptor[], context: un
16
16
  * Shows/hides elements based on their $if, $else-if, $else conditions.
17
17
  */
18
18
  export declare const renderConditionals: (conditionalGroups: ConditionalDescriptor[][], context: unknown, component?: any) => void;
19
+ /**
20
+ * Renders loop elements based on array data.
21
+ * Creates clones of the template for each item in the array.
22
+ */
23
+ export declare const renderLoops: (loops: LoopDescriptor[], context: unknown, component?: any) => void;
@@ -1,4 +1,4 @@
1
- import { BindingDescriptor, TwoWayBindingDescriptor, ConditionalDescriptor } from "../../types/LadrilloTypes";
1
+ import { BindingDescriptor, TwoWayBindingDescriptor, ConditionalDescriptor, LoopDescriptor } from "../../types/LadrilloTypes";
2
2
  /**
3
3
  * Injects the template HTML into the host element and scans for data bindings.
4
4
  * Returns a list of all bindings found in text nodes and attributes.
@@ -7,6 +7,7 @@ export declare const loadTemplate: (host: HTMLElement | ShadowRoot, template: st
7
7
  bindings: BindingDescriptor[];
8
8
  twoWayBindings: TwoWayBindingDescriptor[];
9
9
  conditionals: ConditionalDescriptor[][];
10
+ loops: LoopDescriptor[];
10
11
  };
11
12
  /**
12
13
  * Extracts variable names from conditional expressions.
@@ -14,3 +15,8 @@ export declare const loadTemplate: (host: HTMLElement | ShadowRoot, template: st
14
15
  * e.g., "{sending}" → ["sending"], "{count > 5}" → ["count"]
15
16
  */
16
17
  export declare const extractConditionalVariables: (conditionalGroups: ConditionalDescriptor[][]) => Set<string>;
18
+ /**
19
+ * Extracts variable names from loop expressions.
20
+ * e.g., "item in items" → ["items"], "(user, index) in users" → ["users"]
21
+ */
22
+ export declare const extractLoopVariables: (loops: LoopDescriptor[]) => Set<string>;
@@ -4,5 +4,5 @@
4
4
  `).replace(/\\n/g,`
5
5
  `).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):t.includes("import")||t.includes("export")?(m.warn("CSS file returned JavaScript module format. CSS may not load correctly."),""):t},O=t=>a(null,null,function*(){let e="";const r=t.querySelectorAll("style, link[rel='stylesheet']");for(const s of r){if(s.tagName==="LINK"){const n=yield j(s.href),c=K(n);c&&(e+=`
6
6
  `+c)}else if(s.tagName==="STYLE"){const o=s;if(o.textContent){let n=o.textContent.trim();n=n.replace(d.comments.css,"").trim(),e+=`
7
- `+n}}s.remove()}return e.trim()});var p,x;class W{constructor(){S(this,p);this.components={}}registerComponent(e,r,s=!0){return a(this,null,function*(){if(this.components[e]){m.warn(`Component with name "${e}" is already registered.`);return}try{const o=yield L(r),n=yield N(o,e);this.components[e]={tagName:e,template:n.template,scripts:n.scripts,externalScripts:n.externalScripts,styles:n.styles,sourcePath:r},m.log(`Component ${e} registered successfully`),yield C(this,p,x).call(this,e,s)}catch(o){m.error(`Failed to register component "${e}": ${o.message}`);return}})}}p=new WeakSet,x=function(e,r){return a(this,null,function*(){const{defineWebComponent:s}=yield Promise.resolve().then(()=>require("./webcomponent-oNIeezqN.js"));this.components[e]&&s(this.components[e],r)})};const v=new W;class X{constructor(){this.listeners=new Map}emit(e,r){const s=new CustomEvent(e,{detail:r,bubbles:!0,composed:!0});document.dispatchEvent(s);const o=this.listeners.get(e);if(!o||o.size===0)return Promise.resolve();const n=[];return o.forEach(c=>{try{const i=c(r);i instanceof Promise&&n.push(i)}catch(i){console.error(`Error in event listener for "${e}":`,i),n.push(Promise.reject(i))}}),n.length>0?Promise.all(n).then(()=>{}):Promise.resolve()}listen(e,r){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(r),()=>{this.off(e,r)}}off(e,r){const s=this.listeners.get(e);s&&(s.delete(r),s.size===0&&this.listeners.delete(e))}clear(e){e?this.listeners.delete(e):this.listeners.clear()}listenerCount(e){var r,s;return(s=(r=this.listeners.get(e))==null?void 0:r.size)!=null?s:0}}const g=new X,E=(t,e,r)=>v.registerComponent(t,e,r),_=t=>a(null,null,function*(){yield Promise.all(t.map(({name:e,path:r,useShadowDOM:s})=>v.registerComponent(e,r,s)))}),q=(t,e)=>g.listen(t,e),P=(t,e)=>{g.emit(t,e)},I=(t,e)=>{if(e){const r=e.tagName.toLowerCase();window.__ladrilloContexts||(window.__ladrilloContexts=new Map),window.__ladrilloContexts.set(r,{shadowRoot:t,element:e})}},w=()=>{const t=window.__ladrilloContexts;if(t&&t.size>0){const e=Array.from(t.values());return e[e.length-1]}return null},b=()=>{const t=w();return t&&t.element?t.element.state||{}:{}},f=t=>{const e=w();e&&e.setState&&e.setState(t)},A=(t,e)=>(f({[t]:e}),r=>{f({[t]:r})}),T=(t,e)=>{if(e)return e.querySelector(t);const r=w();if(r){const s=r.shadowRoot||r.element;if(s){const o=s.querySelector(t);if(o)return o}}return document.querySelector(t)},k=(t,e)=>{if(e)return e.querySelectorAll(t);const r=w();if(r){const s=r.shadowRoot||r.element;if(s){const o=s.querySelectorAll(t);if(o.length>0)return o}}return document.querySelectorAll(t)};typeof window!="undefined"&&(window.ladrillosjs={registerComponent:E,registerComponents:_},window.$listen=q,window.$emit=P,window.$querySelector=T,window.$querySelectorAll=k,window.$reactive=A,window.$setState=f,window.$getState=b);exports.$emit=P;exports.$getState=b;exports.$listen=q;exports.$querySelector=T;exports.$querySelectorAll=k;exports.$reactive=A;exports.$setState=f;exports.REGEX_PATTERNS=d;exports.__setComponentContext=I;exports.eventBus=g;exports.logger=m;exports.registerComponent=E;exports.registerComponents=_;
8
- //# sourceMappingURL=index-CPSzLUwq.js.map
7
+ `+n}}s.remove()}return e.trim()});var p,x;class W{constructor(){S(this,p);this.components={}}registerComponent(e,r,s=!0){return a(this,null,function*(){if(this.components[e]){m.warn(`Component with name "${e}" is already registered.`);return}try{const o=yield L(r),n=yield N(o,e);this.components[e]={tagName:e,template:n.template,scripts:n.scripts,externalScripts:n.externalScripts,styles:n.styles,sourcePath:r},m.log(`Component ${e} registered successfully`),yield C(this,p,x).call(this,e,s)}catch(o){m.error(`Failed to register component "${e}": ${o.message}`);return}})}}p=new WeakSet,x=function(e,r){return a(this,null,function*(){const{defineWebComponent:s}=yield Promise.resolve().then(()=>require("./webcomponent-DNeyn3kB.js"));this.components[e]&&s(this.components[e],r)})};const v=new W;class X{constructor(){this.listeners=new Map}emit(e,r){const s=new CustomEvent(e,{detail:r,bubbles:!0,composed:!0});document.dispatchEvent(s);const o=this.listeners.get(e);if(!o||o.size===0)return Promise.resolve();const n=[];return o.forEach(c=>{try{const i=c(r);i instanceof Promise&&n.push(i)}catch(i){console.error(`Error in event listener for "${e}":`,i),n.push(Promise.reject(i))}}),n.length>0?Promise.all(n).then(()=>{}):Promise.resolve()}listen(e,r){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(r),()=>{this.off(e,r)}}off(e,r){const s=this.listeners.get(e);s&&(s.delete(r),s.size===0&&this.listeners.delete(e))}clear(e){e?this.listeners.delete(e):this.listeners.clear()}listenerCount(e){var r,s;return(s=(r=this.listeners.get(e))==null?void 0:r.size)!=null?s:0}}const g=new X,E=(t,e,r)=>v.registerComponent(t,e,r),_=t=>a(null,null,function*(){yield Promise.all(t.map(({name:e,path:r,useShadowDOM:s})=>v.registerComponent(e,r,s)))}),q=(t,e)=>g.listen(t,e),P=(t,e)=>{g.emit(t,e)},I=(t,e)=>{if(e){const r=e.tagName.toLowerCase();window.__ladrilloContexts||(window.__ladrilloContexts=new Map),window.__ladrilloContexts.set(r,{shadowRoot:t,element:e})}},w=()=>{const t=window.__ladrilloContexts;if(t&&t.size>0){const e=Array.from(t.values());return e[e.length-1]}return null},b=()=>{const t=w();return t&&t.element?t.element.state||{}:{}},f=t=>{const e=w();e&&e.setState&&e.setState(t)},A=(t,e)=>(f({[t]:e}),r=>{f({[t]:r})}),T=(t,e)=>{if(e)return e.querySelector(t);const r=w();if(r){const s=r.shadowRoot||r.element;if(s){const o=s.querySelector(t);if(o)return o}}return document.querySelector(t)},k=(t,e)=>{if(e)return e.querySelectorAll(t);const r=w();if(r){const s=r.shadowRoot||r.element;if(s){const o=s.querySelectorAll(t);if(o.length>0)return o}}return document.querySelectorAll(t)};typeof window!="undefined"&&(window.ladrillosjs={registerComponent:E,registerComponents:_},window.$listen=q,window.$emit=P,window.$querySelector=T,window.$querySelectorAll=k,window.$reactive=A,window.$setState=f,window.$getState=b);exports.$emit=P;exports.$getState=b;exports.$listen=q;exports.$querySelector=T;exports.$querySelectorAll=k;exports.$reactive=A;exports.$setState=f;exports.REGEX_PATTERNS=d;exports.__setComponentContext=I;exports.eventBus=g;exports.logger=m;exports.registerComponent=E;exports.registerComponents=_;
8
+ //# sourceMappingURL=index-63mcJ9Hl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-CPSzLUwq.js","sources":["../src/utils/logger.ts","../src/cache/index.ts","../src/core/componentSource.ts","../src/utils/regex.ts","../src/core/componentParser.ts","../src/core/main.ts","../src/core/eventBus.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Utility for conditional logging based on environment\r\n */\r\n\r\n// Type guard for Vite environment\r\nconst isDevelopment = (): boolean => {\r\n try {\r\n return (import.meta as any).env?.DEV === true;\r\n } catch {\r\n return process.env.NODE_ENV === 'development';\r\n }\r\n};\r\n\r\nexport const logger = {\r\n /**\r\n * Log a message only in development mode\r\n * @param message - The message to log\r\n * @param args - Additional arguments to log\r\n */\r\n log(message: string, ...args: any[]): void {\r\n if (isDevelopment()) {\r\n console.log(message, ...args);\r\n }\r\n },\r\n\r\n /**\r\n * Log an error (always logs in both dev and production)\r\n * @param message - The error message\r\n * @param args - Additional arguments to log\r\n */\r\n error(message: string, ...args: any[]): void {\r\n console.error(message, ...args);\r\n },\r\n\r\n /**\r\n * Log a warning only in development mode\r\n * @param message - The warning message\r\n * @param args - Additional arguments to log\r\n */\r\n warn(message: string, ...args: any[]): void {\r\n if (isDevelopment()) {\r\n console.warn(message, ...args);\r\n }\r\n },\r\n};\r\n","const cache = new Map<string, string>();\r\nconst maxCacheSize = 25; // TODO: make configurable for developer to set\r\n\r\n/**\r\n * LRU Cache: Gets cached content and marks it as recently used\r\n * Moves the accessed item to the end of the Map (most recently used position)\r\n * This ensures frequently accessed components stay in cache longer\r\n * @param path - The file path to retrieve from cache\r\n * @returns The cached content or undefined if not found\r\n */\r\nexport const getCached = (path: string): string | undefined => {\r\n const cached = cache.get(path);\r\n if (cached) {\r\n // LRU: Move to end (most recently used position)\r\n cache.delete(path);\r\n cache.set(path, cached);\r\n }\r\n return cached;\r\n};\r\n\r\n/**\r\n * LRU Cache: Stores content with automatic eviction of least recently used items\r\n * Maintains cache size limit by removing oldest items when full\r\n * Updates existing items without affecting cache size\r\n * @param path - The file path to cache\r\n * @param content - The content to store\r\n */\r\nexport const setCache = (path: string, content: string): void => {\r\n if (cache.has(path)) {\r\n // Update existing: remove and re-add to mark as most recent\r\n cache.delete(path);\r\n } else if (cache.size >= maxCacheSize) {\r\n // Cache full: remove least recently used (first item in Map)\r\n const firstKey = cache.keys().next().value;\r\n if (firstKey) {\r\n cache.delete(firstKey);\r\n }\r\n }\r\n // Add/update as most recently used (end of Map)\r\n cache.set(path, content);\r\n};\r\n","import { getCached, setCache } from \"../cache\";\r\nimport { logger } from \"../utils/logger\";\r\n\r\n/**\r\n * Fetches component source with caching support\r\n * @param path - The file path to fetch\r\n * @returns The component source content\r\n */\r\nexport const fetchComponentSource = async (\r\n path: string\r\n): Promise<string | undefined> => {\r\n if (!path) {\r\n throw new Error(\"Path cannot be null or empty\");\r\n }\r\n\r\n const cached = getCached(path);\r\n if (cached) return cached;\r\n\r\n // fetch and cache\r\n try {\r\n const response = await fetch(path);\r\n\r\n if (!response.ok) {\r\n throw new Error(\r\n `Failed to fetch component from ${path}: ${response.statusText}`\r\n );\r\n }\r\n\r\n const text = await response.text();\r\n setCache(path, text);\r\n\r\n return text;\r\n } catch (error) {\r\n logger.error(\r\n `Error fetching component from ${path}: ${(error as Error).message}`\r\n );\r\n }\r\n};\r\n\r\n/**\r\n * Safe fetch helper that returns empty string on error\r\n * @param url - The URL to fetch\r\n * @returns The fetched content or empty string\r\n */\r\nexport const safeFetch = async (url: string): Promise<string> => {\r\n try {\r\n const res = await fetch(url);\r\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\r\n return await res.text();\r\n } catch (err) {\r\n logger.error(`Failed to fetch resource at ${url}:`, err);\r\n return \"\";\r\n }\r\n};\r\n","import { RegexPatterns } from \"../types/LadrilloTypes\";\r\n\r\nexport const REGEX_PATTERNS: RegexPatterns = {\r\n bindings: /{([^}]+)}/g,\r\n comments: {\r\n js: /\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*$/gm,\r\n css: /\\/\\*[\\s\\S]*?\\*\\//g,\r\n html: /<!--[\\s\\S]*?-->/g,\r\n },\r\n};\r\n","import {\r\n ExternalScriptElement,\r\n LadrillosComponent,\r\n ScriptElement,\r\n} from \"../types/LadrilloTypes\";\r\nimport { REGEX_PATTERNS } from \"../utils/regex\";\r\nimport { logger } from \"../utils/logger\";\r\nimport { safeFetch } from \"./componentSource\";\r\n\r\nconst parser = new DOMParser();\r\n\r\n/**\r\n * Parses component HTML and extracts scripts and styles\r\n * @param source - The HTML source of the component\r\n * @param name - The name of the component\r\n * @returns Parsed component object\r\n */\r\nexport const parseComponent = async (\r\n source: string,\r\n name: string\r\n): Promise<LadrillosComponent> => {\r\n const doc = parseComponentHTML(source);\r\n const { scripts, externalScripts } = extractScripts(doc);\r\n const styles = await extractStyles(doc);\r\n const template = doc.body.innerHTML.trim();\r\n\r\n return {\r\n tagName: name,\r\n template,\r\n scripts,\r\n externalScripts,\r\n styles,\r\n };\r\n};\r\n\r\n/**\r\n * Parses HTML content and removes comments\r\n * @param source - The HTML source to parse\r\n * @returns Parsed DOM document\r\n */\r\nexport const parseComponentHTML = (source: string): Document => {\r\n return parser.parseFromString(\r\n source.replace(REGEX_PATTERNS.comments.html, \"\"),\r\n \"text/html\"\r\n );\r\n};\r\n\r\n/**\r\n * Checks if a script URL is a development server script that should be ignored.\r\n * Dev server scripts (Vite, Webpack HMR, etc.) are injected by the dev environment\r\n * and should not be processed as part of the component.\r\n */\r\nconst isDevServerScript = (src: string): boolean => {\r\n const devPatterns = [\r\n \"/@vite/\", // Vite dev client\r\n \"/__vite\", // Vite internal\r\n \"/webpack-dev-server\", // Webpack dev server\r\n \"/hot-update\", // Webpack HMR\r\n \"/__webpack_hmr\", // Webpack HMR\r\n \"/browser-sync/\", // Browser Sync\r\n \"/livereload.js\", // LiveReload\r\n ];\r\n\r\n return devPatterns.some((pattern) => src.includes(pattern));\r\n};\r\n\r\n/**\r\n * Extracts and processes script elements from the document\r\n * @param doc - The parsed document\r\n * @returns Object containing scripts and external scripts\r\n */\r\nexport const extractScripts = (\r\n doc: Document\r\n): {\r\n scripts: ScriptElement[];\r\n externalScripts: ExternalScriptElement[];\r\n} => {\r\n const scripts: ScriptElement[] = [];\r\n const externalScripts: ExternalScriptElement[] = [];\r\n\r\n for (const el of doc.querySelectorAll(\"script\")) {\r\n if (el.src) {\r\n // Skip dev server scripts (Vite, Webpack, etc.)\r\n if (isDevServerScript(el.src)) {\r\n el.remove();\r\n continue;\r\n }\r\n\r\n // Only mark as external if the 'external' attribute is explicitly present\r\n const isExternal = el.hasAttribute(\"external\");\r\n\r\n externalScripts.push({\r\n src: el.getAttribute(\"src\") || el.src, // Use getAttribute to preserve relative paths\r\n type: el.type ?? null,\r\n external: isExternal,\r\n });\r\n } else if (el.textContent) {\r\n let content = el.textContent.trim();\r\n // strip JavaScript comments (single‑line and block)\r\n content = content.replace(REGEX_PATTERNS.comments.js, \"\").trim();\r\n scripts.push({\r\n content,\r\n type: el.type ?? null,\r\n });\r\n }\r\n el.remove();\r\n }\r\n\r\n return { scripts, externalScripts };\r\n};\r\n\r\n/**\r\n * Extracts CSS content from various response formats\r\n * Handles:\r\n * - Vite dev server (wrapped in __vite__css variable)\r\n * - Plain CSS files (production/CDN)\r\n * - Other build tool formats\r\n */\r\nconst extractCSSFromResponse = (response: string): string => {\r\n // Check if this is a Vite HMR response (contains __vite__css)\r\n // Use a regex that properly handles escaped quotes within the string\r\n const viteMatch = response.match(/const __vite__css = \"((?:[^\"\\\\]|\\\\.)*)\"/);\r\n if (viteMatch && viteMatch[1]) {\r\n // Unescape the CSS string\r\n return viteMatch[1]\r\n .replace(/\\\\r\\\\n/g, \"\\n\")\r\n .replace(/\\\\n/g, \"\\n\")\r\n .replace(/\\\\t/g, \"\\t\")\r\n .replace(/\\\\\"/g, '\"')\r\n .replace(/\\\\\\\\/g, \"\\\\\");\r\n }\r\n\r\n // Check for other module formats (e.g., \"export default ...\")\r\n const exportMatch = response.match(/export\\s+default\\s+\"((?:[^\"\\\\]|\\\\.)*)\"/);\r\n if (exportMatch && exportMatch[1]) {\r\n return exportMatch[1]\r\n .replace(/\\\\r\\\\n/g, \"\\n\")\r\n .replace(/\\\\n/g, \"\\n\")\r\n .replace(/\\\\t/g, \"\\t\")\r\n .replace(/\\\\\"/g, '\"')\r\n .replace(/\\\\\\\\/g, \"\\\\\");\r\n }\r\n\r\n // If it looks like JavaScript (not CSS), warn and return empty\r\n if (response.includes(\"import\") || response.includes(\"export\")) {\r\n logger.warn(\r\n \"CSS file returned JavaScript module format. CSS may not load correctly.\"\r\n );\r\n return \"\";\r\n }\r\n\r\n // If not a module format, assume it's plain CSS (production or direct file)\r\n return response;\r\n};\r\n\r\n/**\r\n * Extracts and processes style elements from the document\r\n * @param doc - The parsed document\r\n * @returns Concatenated CSS content\r\n */\r\nexport const extractStyles = async (doc: Document): Promise<string> => {\r\n let style = \"\";\r\n\r\n // Process styles in document order (inline styles and external stylesheets)\r\n const styleElements = doc.querySelectorAll(\"style, link[rel='stylesheet']\");\r\n\r\n for (const element of styleElements) {\r\n if (element.tagName === \"LINK\") {\r\n const linkElement = element as HTMLLinkElement;\r\n const response = await safeFetch(linkElement.href);\r\n const cssContent = extractCSSFromResponse(response);\r\n if (cssContent) {\r\n style += \"\\n\" + cssContent;\r\n }\r\n } else if (element.tagName === \"STYLE\") {\r\n const styleEl = element as HTMLStyleElement;\r\n if (styleEl.textContent) {\r\n let css = styleEl.textContent.trim();\r\n // strip CSS comments\r\n css = css.replace(REGEX_PATTERNS.comments.css, \"\").trim();\r\n style += \"\\n\" + css;\r\n }\r\n }\r\n element.remove();\r\n }\r\n\r\n return style.trim();\r\n};\r\n","import { LadrillosComponent } from \"../types/LadrilloTypes\";\r\nimport { logger } from \"../utils/logger\";\r\nimport { fetchComponentSource } from \"./componentSource\";\r\nimport { parseComponent } from \"./componentParser\";\r\n\r\nclass Ladrillos {\r\n // properties\r\n components: Record<string, LadrillosComponent>;\r\n\r\n constructor() {\r\n // Initialize the Ladrillos instance\r\n this.components = {};\r\n }\r\n\r\n async registerComponent(\r\n name: string,\r\n path: string,\r\n useShadowDOM: boolean = true\r\n ): Promise<void> {\r\n if (this.components[name]) {\r\n logger.warn(`Component with name \"${name}\" is already registered.`);\r\n return;\r\n }\r\n\r\n try {\r\n const source = await fetchComponentSource(path);\r\n const component = await parseComponent(source!, name);\r\n\r\n this.components[name] = {\r\n tagName: name,\r\n template: component.template,\r\n scripts: component.scripts,\r\n externalScripts: component.externalScripts,\r\n styles: component.styles,\r\n sourcePath: path,\r\n };\r\n\r\n // Define the web component\r\n logger.log(`Component ${name} registered successfully`);\r\n await this.#defineWebComponent(name, useShadowDOM);\r\n } catch (error) {\r\n logger.error(\r\n `Failed to register component \"${name}\": ${(error as Error).message}`\r\n );\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * Defines the web component using the webcomponent module\r\n * @param name - Component name\r\n * @param useShadowDOM - Whether to use Shadow DOM\r\n */\r\n async #defineWebComponent(\r\n name: string,\r\n useShadowDOM: boolean\r\n ): Promise<void> {\r\n const { defineWebComponent } = await import(\"./webcomponent\");\r\n\r\n // safety check\r\n if (this.components[name]) {\r\n defineWebComponent(this.components[name], useShadowDOM);\r\n }\r\n }\r\n}\r\n\r\nexport const ladrillos = new Ladrillos();\r\n","/**\r\n * Global Event Bus for component-to-component communication\r\n * Allows components to emit events and listen to events from other components\r\n */\r\n\r\ntype EventCallback = (data?: any) => void | Promise<void>;\r\ntype EventListeners = Map<string, Set<EventCallback>>;\r\n\r\nclass EventBus {\r\n private listeners: EventListeners = new Map();\r\n\r\n /**\r\n * Emit an event with optional data\r\n * @param eventName - The name of the event to emit\r\n * @param data - Optional data to pass to listeners\r\n * @returns Promise that resolves when all listeners have been called\r\n */\r\n emit(eventName: string, data?: any): Promise<void> {\r\n // Also dispatch as a native DOM CustomEvent so document.addEventListener works\r\n const customEvent = new CustomEvent(eventName, {\r\n detail: data,\r\n bubbles: true,\r\n composed: true,\r\n });\r\n document.dispatchEvent(customEvent);\r\n\r\n const callbacks = this.listeners.get(eventName);\r\n\r\n if (!callbacks || callbacks.size === 0) {\r\n // No listeners, resolve immediately\r\n return Promise.resolve();\r\n }\r\n\r\n // Execute all callbacks and collect promises\r\n const promises: Promise<void>[] = [];\r\n\r\n callbacks.forEach((callback) => {\r\n try {\r\n const result = callback(data);\r\n // If callback returns a promise, add it to promises array\r\n if (result instanceof Promise) {\r\n promises.push(result);\r\n }\r\n } catch (error) {\r\n console.error(`Error in event listener for \"${eventName}\":`, error);\r\n promises.push(Promise.reject(error));\r\n }\r\n });\r\n\r\n // If any callbacks returned promises, wait for all of them\r\n if (promises.length > 0) {\r\n return Promise.all(promises).then(() => undefined);\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Listen to an event\r\n * @param eventName - The name of the event to listen for\r\n * @param callback - Function to call when event is emitted\r\n * @returns Function to remove the listener\r\n */\r\n listen(eventName: string, callback: EventCallback): () => void {\r\n if (!this.listeners.has(eventName)) {\r\n this.listeners.set(eventName, new Set());\r\n }\r\n\r\n this.listeners.get(eventName)!.add(callback);\r\n\r\n // Return unsubscribe function\r\n return () => {\r\n this.off(eventName, callback);\r\n };\r\n }\r\n\r\n /**\r\n * Remove a specific event listener\r\n * @param eventName - The name of the event\r\n * @param callback - The callback to remove\r\n */\r\n off(eventName: string, callback: EventCallback): void {\r\n const callbacks = this.listeners.get(eventName);\r\n if (callbacks) {\r\n callbacks.delete(callback);\r\n // Clean up empty sets\r\n if (callbacks.size === 0) {\r\n this.listeners.delete(eventName);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Remove all listeners for an event, or all listeners if no event specified\r\n * @param eventName - Optional event name to clear listeners for\r\n */\r\n clear(eventName?: string): void {\r\n if (eventName) {\r\n this.listeners.delete(eventName);\r\n } else {\r\n this.listeners.clear();\r\n }\r\n }\r\n\r\n /**\r\n * Get count of listeners for an event\r\n * @param eventName - The event name\r\n * @returns Number of listeners\r\n */\r\n listenerCount(eventName: string): number {\r\n return this.listeners.get(eventName)?.size ?? 0;\r\n }\r\n}\r\n\r\n// Export singleton instance\r\nexport const eventBus = new EventBus();\r\n","import { ladrillos } from \"./core/main.js\";\r\nimport { eventBus } from \"./core/eventBus.js\";\r\n\r\ndeclare global {\r\n interface Window {\r\n ladrillosjs: {\r\n registerComponent: typeof registerComponent;\r\n registerComponents: typeof registerComponents;\r\n };\r\n $listen: typeof $listen;\r\n $emit: typeof $emit;\r\n $querySelector: typeof $querySelector;\r\n $querySelectorAll: typeof $querySelectorAll;\r\n $reactive: typeof $reactive;\r\n $setState: typeof $setState;\r\n $getState: typeof $getState;\r\n }\r\n}\r\n\r\nexport const registerComponent = (\r\n name: string,\r\n path: string,\r\n useShadowDOM?: boolean\r\n) => ladrillos.registerComponent(name, path, useShadowDOM);\r\n\r\nexport const registerComponents = async (\r\n components: Array<{ name: string; path: string; useShadowDOM?: boolean }>\r\n): Promise<void> => {\r\n await Promise.all(\r\n components.map(({ name, path, useShadowDOM }) =>\r\n ladrillos.registerComponent(name, path, useShadowDOM)\r\n )\r\n );\r\n};\r\n\r\n// Event bus helper functions\r\nexport const $listen = (event: string, callback: (data?: any) => void) => {\r\n return eventBus.listen(event, callback);\r\n};\r\n\r\nexport const $emit = (event: string, data?: any) => {\r\n eventBus.emit(event, data);\r\n};\r\n\r\n// Component context management\r\n// Maps script URLs to their component contexts for persistent association\r\nconst scriptContextMap = new Map<\r\n string,\r\n { shadowRoot?: ShadowRoot; element?: HTMLElement }\r\n>();\r\nconst activeContext: { shadowRoot?: ShadowRoot; element?: HTMLElement } | null =\r\n null;\r\n\r\n/**\r\n * Internal: Set component context for a script\r\n * Called by the framework when loading scripts from components\r\n */\r\nexport const __setComponentContext = (\r\n shadowRoot?: ShadowRoot,\r\n element?: HTMLElement\r\n) => {\r\n // Store in the global registry by component tag name\r\n if (element) {\r\n const tagName = element.tagName.toLowerCase();\r\n if (!(window as any).__ladrilloContexts) {\r\n (window as any).__ladrilloContexts = new Map();\r\n }\r\n (window as any).__ladrilloContexts.set(tagName, { shadowRoot, element });\r\n }\r\n};\r\n\r\n/**\r\n * Internal: Get component context for the current script\r\n */\r\nconst getComponentContext = () => {\r\n const registry = (window as any).__ladrilloContexts as Map<string, any>;\r\n if (registry && registry.size > 0) {\r\n // For now, return the last registered context\r\n // In the future, we could track which script belongs to which component\r\n const contexts = Array.from(registry.values());\r\n return contexts[contexts.length - 1];\r\n }\r\n return null;\r\n};\r\n\r\n/**\r\n * Get the component's reactive state (for use in module scripts with bind attribute)\r\n * Returns a Proxy that allows direct property access to component.state\r\n * @returns Proxy to component state or empty object if no component context\r\n */\r\nexport const $getState = (): any => {\r\n const ctx = getComponentContext();\r\n if (ctx && ctx.element) {\r\n return (ctx.element as any).state || {};\r\n }\r\n return {};\r\n};\r\n\r\n/**\r\n * Set component state (for use in module scripts with bind attribute)\r\n * @param updates - Object with state updates\r\n */\r\nexport const $setState = (updates: any) => {\r\n const ctx = getComponentContext();\r\n if (ctx && ctx.setState) {\r\n ctx.setState(updates);\r\n }\r\n};\r\n\r\n/**\r\n * Creates a reactive variable that automatically updates the component when changed.\r\n * For use in ES module scripts with the bind attribute.\r\n * @param name - The variable name (must match the binding in the template)\r\n * @param initialValue - The initial value\r\n * @returns A setter function to update the value\r\n *\r\n * @example\r\n * ```javascript\r\n * import { $reactive } from 'ladrillosjs';\r\n *\r\n * // In your module script:\r\n * const setBeers = $reactive('beers', 'loading...');\r\n *\r\n * // Later, update it:\r\n * setBeers('<card>...</card>');\r\n * ```\r\n */\r\nexport const $reactive = <T = any>(\r\n name: string,\r\n initialValue: T\r\n): ((value: T) => void) => {\r\n // Initialize the state\r\n $setState({ [name]: initialValue });\r\n\r\n // Return a setter function\r\n return (value: T) => {\r\n $setState({ [name]: value });\r\n };\r\n};\r\n\r\n// DOM query helpers with smart component context detection\r\n// Automatically searches within component context when appropriate\r\nexport const $querySelector = (\r\n selector: string,\r\n root?: Element | Document | ShadowRoot\r\n): Element | null => {\r\n if (root) {\r\n return root.querySelector(selector);\r\n }\r\n\r\n // Try to get component context\r\n const ctx = getComponentContext();\r\n if (ctx) {\r\n const searchRoot = ctx.shadowRoot || ctx.element;\r\n if (searchRoot) {\r\n const result = searchRoot.querySelector(selector);\r\n if (result) return result;\r\n }\r\n }\r\n\r\n // Fallback to document\r\n return document.querySelector(selector);\r\n};\r\n\r\nexport const $querySelectorAll = (\r\n selector: string,\r\n root?: Element | Document | ShadowRoot\r\n): NodeListOf<Element> => {\r\n if (root) {\r\n return root.querySelectorAll(selector);\r\n }\r\n\r\n // Try to get component context\r\n const ctx = getComponentContext();\r\n if (ctx) {\r\n const searchRoot = ctx.shadowRoot || ctx.element;\r\n if (searchRoot) {\r\n const result = searchRoot.querySelectorAll(selector);\r\n if (result.length > 0) return result;\r\n }\r\n }\r\n\r\n // Fallback to document\r\n return document.querySelectorAll(selector);\r\n};\r\n\r\n// for a browser‑global via <script src=\"…ladrillosjs.js\"></script>\r\nif (typeof window !== \"undefined\") {\r\n window.ladrillosjs = {\r\n registerComponent,\r\n registerComponents,\r\n };\r\n\r\n // Expose helper functions globally for non-module scripts\r\n window.$listen = $listen;\r\n window.$emit = $emit;\r\n window.$querySelector = $querySelector;\r\n window.$querySelectorAll = $querySelectorAll;\r\n window.$reactive = $reactive;\r\n window.$setState = $setState;\r\n window.$getState = $getState;\r\n}\r\n"],"names":["isDevelopment","e","logger","message","args","cache","maxCacheSize","getCached","path","cached","setCache","content","firstKey","fetchComponentSource","__async","response","text","error","safeFetch","url","res","err","REGEX_PATTERNS","parser","parseComponent","source","name","doc","parseComponentHTML","scripts","externalScripts","extractScripts","styles","extractStyles","template","isDevServerScript","src","pattern","el","isExternal","_a","_b","extractCSSFromResponse","viteMatch","exportMatch","style","styleElements","element","cssContent","styleEl","css","Ladrillos","__privateAdd","_Ladrillos_instances","useShadowDOM","component","__privateMethod","defineWebComponent_fn","defineWebComponent","ladrillos","EventBus","eventName","data","customEvent","callbacks","promises","callback","result","eventBus","registerComponent","registerComponents","components","$listen","event","$emit","__setComponentContext","shadowRoot","tagName","getComponentContext","registry","contexts","$getState","ctx","$setState","updates","$reactive","initialValue","value","$querySelector","selector","root","searchRoot","$querySelectorAll"],"mappings":"0cAKA,MAAMA,EAAgB,IAAe,CACnC,GAAI,CACF,MAAQ,EACV,OAAQC,EAAA,CACN,OAAO,QAAQ,IAAI,WAAa,aAClC,CACF,EAEaC,EAAS,CAMpB,IAAIC,KAAoBC,EAAmB,CACrCJ,KACF,QAAQ,IAAIG,EAAS,GAAGC,CAAI,CAEhC,EAOA,MAAMD,KAAoBC,EAAmB,CAC3C,QAAQ,MAAMD,EAAS,GAAGC,CAAI,CAChC,EAOA,KAAKD,KAAoBC,EAAmB,CACtCJ,KACF,QAAQ,KAAKG,EAAS,GAAGC,CAAI,CAEjC,CACF,EC5C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oB,CAC/BH,EACAC,IACwB,CACxB,GAAIA,EACF,OAAOA,EAAK,iBAAiBD,CAAQ,EAIvC,MAAMP,EAAMJ,EAAA,EACZ,GAAII,EAAK,CACP,MAAMS,EAAaT,EAAI,YAAcA,EAAI,QACzC,GAAIS,EAAY,CACd,MAAMxB,EAASwB,EAAW,iBAAiBF,CAAQ,EACnD,GAAItB,EAAO,OAAS,EAAG,OAAOA,CAChC,CACF,CAGA,OAAO,SAAS,iBAAiBsB,CAAQ,CAC3C,EAGI,OAAO,QAAW,cACpB,OAAO,YAAc,CACnB,kBAAApB,EACA,mBAAAC,CAAA,EAIF,OAAO,QAAUE,EACjB,OAAO,MAAQE,EACf,OAAO,eAAiBc,EACxB,OAAO,kBAAoBI,EAC3B,OAAO,UAAYP,EACnB,OAAO,UAAYF,EACnB,OAAO,UAAYF"}
1
+ {"version":3,"file":"index-63mcJ9Hl.js","sources":["../src/utils/logger.ts","../src/cache/index.ts","../src/core/componentSource.ts","../src/utils/regex.ts","../src/core/componentParser.ts","../src/core/main.ts","../src/core/eventBus.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Utility for conditional logging based on environment\r\n */\r\n\r\n// Type guard for Vite environment\r\nconst isDevelopment = (): boolean => {\r\n try {\r\n return (import.meta as any).env?.DEV === true;\r\n } catch {\r\n return process.env.NODE_ENV === 'development';\r\n }\r\n};\r\n\r\nexport const logger = {\r\n /**\r\n * Log a message only in development mode\r\n * @param message - The message to log\r\n * @param args - Additional arguments to log\r\n */\r\n log(message: string, ...args: any[]): void {\r\n if (isDevelopment()) {\r\n console.log(message, ...args);\r\n }\r\n },\r\n\r\n /**\r\n * Log an error (always logs in both dev and production)\r\n * @param message - The error message\r\n * @param args - Additional arguments to log\r\n */\r\n error(message: string, ...args: any[]): void {\r\n console.error(message, ...args);\r\n },\r\n\r\n /**\r\n * Log a warning only in development mode\r\n * @param message - The warning message\r\n * @param args - Additional arguments to log\r\n */\r\n warn(message: string, ...args: any[]): void {\r\n if (isDevelopment()) {\r\n console.warn(message, ...args);\r\n }\r\n },\r\n};\r\n","const cache = new Map<string, string>();\r\nconst maxCacheSize = 25; // TODO: make configurable for developer to set\r\n\r\n/**\r\n * LRU Cache: Gets cached content and marks it as recently used\r\n * Moves the accessed item to the end of the Map (most recently used position)\r\n * This ensures frequently accessed components stay in cache longer\r\n * @param path - The file path to retrieve from cache\r\n * @returns The cached content or undefined if not found\r\n */\r\nexport const getCached = (path: string): string | undefined => {\r\n const cached = cache.get(path);\r\n if (cached) {\r\n // LRU: Move to end (most recently used position)\r\n cache.delete(path);\r\n cache.set(path, cached);\r\n }\r\n return cached;\r\n};\r\n\r\n/**\r\n * LRU Cache: Stores content with automatic eviction of least recently used items\r\n * Maintains cache size limit by removing oldest items when full\r\n * Updates existing items without affecting cache size\r\n * @param path - The file path to cache\r\n * @param content - The content to store\r\n */\r\nexport const setCache = (path: string, content: string): void => {\r\n if (cache.has(path)) {\r\n // Update existing: remove and re-add to mark as most recent\r\n cache.delete(path);\r\n } else if (cache.size >= maxCacheSize) {\r\n // Cache full: remove least recently used (first item in Map)\r\n const firstKey = cache.keys().next().value;\r\n if (firstKey) {\r\n cache.delete(firstKey);\r\n }\r\n }\r\n // Add/update as most recently used (end of Map)\r\n cache.set(path, content);\r\n};\r\n","import { getCached, setCache } from \"../cache\";\r\nimport { logger } from \"../utils/logger\";\r\n\r\n/**\r\n * Fetches component source with caching support\r\n * @param path - The file path to fetch\r\n * @returns The component source content\r\n */\r\nexport const fetchComponentSource = async (\r\n path: string\r\n): Promise<string | undefined> => {\r\n if (!path) {\r\n throw new Error(\"Path cannot be null or empty\");\r\n }\r\n\r\n const cached = getCached(path);\r\n if (cached) return cached;\r\n\r\n // fetch and cache\r\n try {\r\n const response = await fetch(path);\r\n\r\n if (!response.ok) {\r\n throw new Error(\r\n `Failed to fetch component from ${path}: ${response.statusText}`\r\n );\r\n }\r\n\r\n const text = await response.text();\r\n setCache(path, text);\r\n\r\n return text;\r\n } catch (error) {\r\n logger.error(\r\n `Error fetching component from ${path}: ${(error as Error).message}`\r\n );\r\n }\r\n};\r\n\r\n/**\r\n * Safe fetch helper that returns empty string on error\r\n * @param url - The URL to fetch\r\n * @returns The fetched content or empty string\r\n */\r\nexport const safeFetch = async (url: string): Promise<string> => {\r\n try {\r\n const res = await fetch(url);\r\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\r\n return await res.text();\r\n } catch (err) {\r\n logger.error(`Failed to fetch resource at ${url}:`, err);\r\n return \"\";\r\n }\r\n};\r\n","import { RegexPatterns } from \"../types/LadrilloTypes\";\r\n\r\nexport const REGEX_PATTERNS: RegexPatterns = {\r\n bindings: /{([^}]+)}/g,\r\n comments: {\r\n js: /\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*$/gm,\r\n css: /\\/\\*[\\s\\S]*?\\*\\//g,\r\n html: /<!--[\\s\\S]*?-->/g,\r\n },\r\n};\r\n","import {\r\n ExternalScriptElement,\r\n LadrillosComponent,\r\n ScriptElement,\r\n} from \"../types/LadrilloTypes\";\r\nimport { REGEX_PATTERNS } from \"../utils/regex\";\r\nimport { logger } from \"../utils/logger\";\r\nimport { safeFetch } from \"./componentSource\";\r\n\r\nconst parser = new DOMParser();\r\n\r\n/**\r\n * Parses component HTML and extracts scripts and styles\r\n * @param source - The HTML source of the component\r\n * @param name - The name of the component\r\n * @returns Parsed component object\r\n */\r\nexport const parseComponent = async (\r\n source: string,\r\n name: string\r\n): Promise<LadrillosComponent> => {\r\n const doc = parseComponentHTML(source);\r\n const { scripts, externalScripts } = extractScripts(doc);\r\n const styles = await extractStyles(doc);\r\n const template = doc.body.innerHTML.trim();\r\n\r\n return {\r\n tagName: name,\r\n template,\r\n scripts,\r\n externalScripts,\r\n styles,\r\n };\r\n};\r\n\r\n/**\r\n * Parses HTML content and removes comments\r\n * @param source - The HTML source to parse\r\n * @returns Parsed DOM document\r\n */\r\nexport const parseComponentHTML = (source: string): Document => {\r\n return parser.parseFromString(\r\n source.replace(REGEX_PATTERNS.comments.html, \"\"),\r\n \"text/html\"\r\n );\r\n};\r\n\r\n/**\r\n * Checks if a script URL is a development server script that should be ignored.\r\n * Dev server scripts (Vite, Webpack HMR, etc.) are injected by the dev environment\r\n * and should not be processed as part of the component.\r\n */\r\nconst isDevServerScript = (src: string): boolean => {\r\n const devPatterns = [\r\n \"/@vite/\", // Vite dev client\r\n \"/__vite\", // Vite internal\r\n \"/webpack-dev-server\", // Webpack dev server\r\n \"/hot-update\", // Webpack HMR\r\n \"/__webpack_hmr\", // Webpack HMR\r\n \"/browser-sync/\", // Browser Sync\r\n \"/livereload.js\", // LiveReload\r\n ];\r\n\r\n return devPatterns.some((pattern) => src.includes(pattern));\r\n};\r\n\r\n/**\r\n * Extracts and processes script elements from the document\r\n * @param doc - The parsed document\r\n * @returns Object containing scripts and external scripts\r\n */\r\nexport const extractScripts = (\r\n doc: Document\r\n): {\r\n scripts: ScriptElement[];\r\n externalScripts: ExternalScriptElement[];\r\n} => {\r\n const scripts: ScriptElement[] = [];\r\n const externalScripts: ExternalScriptElement[] = [];\r\n\r\n for (const el of doc.querySelectorAll(\"script\")) {\r\n if (el.src) {\r\n // Skip dev server scripts (Vite, Webpack, etc.)\r\n if (isDevServerScript(el.src)) {\r\n el.remove();\r\n continue;\r\n }\r\n\r\n // Only mark as external if the 'external' attribute is explicitly present\r\n const isExternal = el.hasAttribute(\"external\");\r\n\r\n externalScripts.push({\r\n src: el.getAttribute(\"src\") || el.src, // Use getAttribute to preserve relative paths\r\n type: el.type ?? null,\r\n external: isExternal,\r\n });\r\n } else if (el.textContent) {\r\n let content = el.textContent.trim();\r\n // strip JavaScript comments (single‑line and block)\r\n content = content.replace(REGEX_PATTERNS.comments.js, \"\").trim();\r\n scripts.push({\r\n content,\r\n type: el.type ?? null,\r\n });\r\n }\r\n el.remove();\r\n }\r\n\r\n return { scripts, externalScripts };\r\n};\r\n\r\n/**\r\n * Extracts CSS content from various response formats\r\n * Handles:\r\n * - Vite dev server (wrapped in __vite__css variable)\r\n * - Plain CSS files (production/CDN)\r\n * - Other build tool formats\r\n */\r\nconst extractCSSFromResponse = (response: string): string => {\r\n // Check if this is a Vite HMR response (contains __vite__css)\r\n // Use a regex that properly handles escaped quotes within the string\r\n const viteMatch = response.match(/const __vite__css = \"((?:[^\"\\\\]|\\\\.)*)\"/);\r\n if (viteMatch && viteMatch[1]) {\r\n // Unescape the CSS string\r\n return viteMatch[1]\r\n .replace(/\\\\r\\\\n/g, \"\\n\")\r\n .replace(/\\\\n/g, \"\\n\")\r\n .replace(/\\\\t/g, \"\\t\")\r\n .replace(/\\\\\"/g, '\"')\r\n .replace(/\\\\\\\\/g, \"\\\\\");\r\n }\r\n\r\n // Check for other module formats (e.g., \"export default ...\")\r\n const exportMatch = response.match(/export\\s+default\\s+\"((?:[^\"\\\\]|\\\\.)*)\"/);\r\n if (exportMatch && exportMatch[1]) {\r\n return exportMatch[1]\r\n .replace(/\\\\r\\\\n/g, \"\\n\")\r\n .replace(/\\\\n/g, \"\\n\")\r\n .replace(/\\\\t/g, \"\\t\")\r\n .replace(/\\\\\"/g, '\"')\r\n .replace(/\\\\\\\\/g, \"\\\\\");\r\n }\r\n\r\n // If it looks like JavaScript (not CSS), warn and return empty\r\n if (response.includes(\"import\") || response.includes(\"export\")) {\r\n logger.warn(\r\n \"CSS file returned JavaScript module format. CSS may not load correctly.\"\r\n );\r\n return \"\";\r\n }\r\n\r\n // If not a module format, assume it's plain CSS (production or direct file)\r\n return response;\r\n};\r\n\r\n/**\r\n * Extracts and processes style elements from the document\r\n * @param doc - The parsed document\r\n * @returns Concatenated CSS content\r\n */\r\nexport const extractStyles = async (doc: Document): Promise<string> => {\r\n let style = \"\";\r\n\r\n // Process styles in document order (inline styles and external stylesheets)\r\n const styleElements = doc.querySelectorAll(\"style, link[rel='stylesheet']\");\r\n\r\n for (const element of styleElements) {\r\n if (element.tagName === \"LINK\") {\r\n const linkElement = element as HTMLLinkElement;\r\n const response = await safeFetch(linkElement.href);\r\n const cssContent = extractCSSFromResponse(response);\r\n if (cssContent) {\r\n style += \"\\n\" + cssContent;\r\n }\r\n } else if (element.tagName === \"STYLE\") {\r\n const styleEl = element as HTMLStyleElement;\r\n if (styleEl.textContent) {\r\n let css = styleEl.textContent.trim();\r\n // strip CSS comments\r\n css = css.replace(REGEX_PATTERNS.comments.css, \"\").trim();\r\n style += \"\\n\" + css;\r\n }\r\n }\r\n element.remove();\r\n }\r\n\r\n return style.trim();\r\n};\r\n","import { LadrillosComponent } from \"../types/LadrilloTypes\";\r\nimport { logger } from \"../utils/logger\";\r\nimport { fetchComponentSource } from \"./componentSource\";\r\nimport { parseComponent } from \"./componentParser\";\r\n\r\nclass Ladrillos {\r\n // properties\r\n components: Record<string, LadrillosComponent>;\r\n\r\n constructor() {\r\n // Initialize the Ladrillos instance\r\n this.components = {};\r\n }\r\n\r\n async registerComponent(\r\n name: string,\r\n path: string,\r\n useShadowDOM: boolean = true\r\n ): Promise<void> {\r\n if (this.components[name]) {\r\n logger.warn(`Component with name \"${name}\" is already registered.`);\r\n return;\r\n }\r\n\r\n try {\r\n const source = await fetchComponentSource(path);\r\n const component = await parseComponent(source!, name);\r\n\r\n this.components[name] = {\r\n tagName: name,\r\n template: component.template,\r\n scripts: component.scripts,\r\n externalScripts: component.externalScripts,\r\n styles: component.styles,\r\n sourcePath: path,\r\n };\r\n\r\n // Define the web component\r\n logger.log(`Component ${name} registered successfully`);\r\n await this.#defineWebComponent(name, useShadowDOM);\r\n } catch (error) {\r\n logger.error(\r\n `Failed to register component \"${name}\": ${(error as Error).message}`\r\n );\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * Defines the web component using the webcomponent module\r\n * @param name - Component name\r\n * @param useShadowDOM - Whether to use Shadow DOM\r\n */\r\n async #defineWebComponent(\r\n name: string,\r\n useShadowDOM: boolean\r\n ): Promise<void> {\r\n const { defineWebComponent } = await import(\"./webcomponent\");\r\n\r\n // safety check\r\n if (this.components[name]) {\r\n defineWebComponent(this.components[name], useShadowDOM);\r\n }\r\n }\r\n}\r\n\r\nexport const ladrillos = new Ladrillos();\r\n","/**\r\n * Global Event Bus for component-to-component communication\r\n * Allows components to emit events and listen to events from other components\r\n */\r\n\r\ntype EventCallback = (data?: any) => void | Promise<void>;\r\ntype EventListeners = Map<string, Set<EventCallback>>;\r\n\r\nclass EventBus {\r\n private listeners: EventListeners = new Map();\r\n\r\n /**\r\n * Emit an event with optional data\r\n * @param eventName - The name of the event to emit\r\n * @param data - Optional data to pass to listeners\r\n * @returns Promise that resolves when all listeners have been called\r\n */\r\n emit(eventName: string, data?: any): Promise<void> {\r\n // Also dispatch as a native DOM CustomEvent so document.addEventListener works\r\n const customEvent = new CustomEvent(eventName, {\r\n detail: data,\r\n bubbles: true,\r\n composed: true,\r\n });\r\n document.dispatchEvent(customEvent);\r\n\r\n const callbacks = this.listeners.get(eventName);\r\n\r\n if (!callbacks || callbacks.size === 0) {\r\n // No listeners, resolve immediately\r\n return Promise.resolve();\r\n }\r\n\r\n // Execute all callbacks and collect promises\r\n const promises: Promise<void>[] = [];\r\n\r\n callbacks.forEach((callback) => {\r\n try {\r\n const result = callback(data);\r\n // If callback returns a promise, add it to promises array\r\n if (result instanceof Promise) {\r\n promises.push(result);\r\n }\r\n } catch (error) {\r\n console.error(`Error in event listener for \"${eventName}\":`, error);\r\n promises.push(Promise.reject(error));\r\n }\r\n });\r\n\r\n // If any callbacks returned promises, wait for all of them\r\n if (promises.length > 0) {\r\n return Promise.all(promises).then(() => undefined);\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Listen to an event\r\n * @param eventName - The name of the event to listen for\r\n * @param callback - Function to call when event is emitted\r\n * @returns Function to remove the listener\r\n */\r\n listen(eventName: string, callback: EventCallback): () => void {\r\n if (!this.listeners.has(eventName)) {\r\n this.listeners.set(eventName, new Set());\r\n }\r\n\r\n this.listeners.get(eventName)!.add(callback);\r\n\r\n // Return unsubscribe function\r\n return () => {\r\n this.off(eventName, callback);\r\n };\r\n }\r\n\r\n /**\r\n * Remove a specific event listener\r\n * @param eventName - The name of the event\r\n * @param callback - The callback to remove\r\n */\r\n off(eventName: string, callback: EventCallback): void {\r\n const callbacks = this.listeners.get(eventName);\r\n if (callbacks) {\r\n callbacks.delete(callback);\r\n // Clean up empty sets\r\n if (callbacks.size === 0) {\r\n this.listeners.delete(eventName);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Remove all listeners for an event, or all listeners if no event specified\r\n * @param eventName - Optional event name to clear listeners for\r\n */\r\n clear(eventName?: string): void {\r\n if (eventName) {\r\n this.listeners.delete(eventName);\r\n } else {\r\n this.listeners.clear();\r\n }\r\n }\r\n\r\n /**\r\n * Get count of listeners for an event\r\n * @param eventName - The event name\r\n * @returns Number of listeners\r\n */\r\n listenerCount(eventName: string): number {\r\n return this.listeners.get(eventName)?.size ?? 0;\r\n }\r\n}\r\n\r\n// Export singleton instance\r\nexport const eventBus = new EventBus();\r\n","import { ladrillos } from \"./core/main.js\";\r\nimport { eventBus } from \"./core/eventBus.js\";\r\n\r\ndeclare global {\r\n interface Window {\r\n ladrillosjs: {\r\n registerComponent: typeof registerComponent;\r\n registerComponents: typeof registerComponents;\r\n };\r\n $listen: typeof $listen;\r\n $emit: typeof $emit;\r\n $querySelector: typeof $querySelector;\r\n $querySelectorAll: typeof $querySelectorAll;\r\n $reactive: typeof $reactive;\r\n $setState: typeof $setState;\r\n $getState: typeof $getState;\r\n }\r\n}\r\n\r\nexport const registerComponent = (\r\n name: string,\r\n path: string,\r\n useShadowDOM?: boolean\r\n) => ladrillos.registerComponent(name, path, useShadowDOM);\r\n\r\nexport const registerComponents = async (\r\n components: Array<{ name: string; path: string; useShadowDOM?: boolean }>\r\n): Promise<void> => {\r\n await Promise.all(\r\n components.map(({ name, path, useShadowDOM }) =>\r\n ladrillos.registerComponent(name, path, useShadowDOM)\r\n )\r\n );\r\n};\r\n\r\n// Event bus helper functions\r\nexport const $listen = (event: string, callback: (data?: any) => void) => {\r\n return eventBus.listen(event, callback);\r\n};\r\n\r\nexport const $emit = (event: string, data?: any) => {\r\n eventBus.emit(event, data);\r\n};\r\n\r\n// Component context management\r\n// Maps script URLs to their component contexts for persistent association\r\nconst scriptContextMap = new Map<\r\n string,\r\n { shadowRoot?: ShadowRoot; element?: HTMLElement }\r\n>();\r\nconst activeContext: { shadowRoot?: ShadowRoot; element?: HTMLElement } | null =\r\n null;\r\n\r\n/**\r\n * Internal: Set component context for a script\r\n * Called by the framework when loading scripts from components\r\n */\r\nexport const __setComponentContext = (\r\n shadowRoot?: ShadowRoot,\r\n element?: HTMLElement\r\n) => {\r\n // Store in the global registry by component tag name\r\n if (element) {\r\n const tagName = element.tagName.toLowerCase();\r\n if (!(window as any).__ladrilloContexts) {\r\n (window as any).__ladrilloContexts = new Map();\r\n }\r\n (window as any).__ladrilloContexts.set(tagName, { shadowRoot, element });\r\n }\r\n};\r\n\r\n/**\r\n * Internal: Get component context for the current script\r\n */\r\nconst getComponentContext = () => {\r\n const registry = (window as any).__ladrilloContexts as Map<string, any>;\r\n if (registry && registry.size > 0) {\r\n // For now, return the last registered context\r\n // In the future, we could track which script belongs to which component\r\n const contexts = Array.from(registry.values());\r\n return contexts[contexts.length - 1];\r\n }\r\n return null;\r\n};\r\n\r\n/**\r\n * Get the component's reactive state (for use in module scripts with bind attribute)\r\n * Returns a Proxy that allows direct property access to component.state\r\n * @returns Proxy to component state or empty object if no component context\r\n */\r\nexport const $getState = (): any => {\r\n const ctx = getComponentContext();\r\n if (ctx && ctx.element) {\r\n return (ctx.element as any).state || {};\r\n }\r\n return {};\r\n};\r\n\r\n/**\r\n * Set component state (for use in module scripts with bind attribute)\r\n * @param updates - Object with state updates\r\n */\r\nexport const $setState = (updates: any) => {\r\n const ctx = getComponentContext();\r\n if (ctx && ctx.setState) {\r\n ctx.setState(updates);\r\n }\r\n};\r\n\r\n/**\r\n * Creates a reactive variable that automatically updates the component when changed.\r\n * For use in ES module scripts with the bind attribute.\r\n * @param name - The variable name (must match the binding in the template)\r\n * @param initialValue - The initial value\r\n * @returns A setter function to update the value\r\n *\r\n * @example\r\n * ```javascript\r\n * import { $reactive } from 'ladrillosjs';\r\n *\r\n * // In your module script:\r\n * const setBeers = $reactive('beers', 'loading...');\r\n *\r\n * // Later, update it:\r\n * setBeers('<card>...</card>');\r\n * ```\r\n */\r\nexport const $reactive = <T = any>(\r\n name: string,\r\n initialValue: T\r\n): ((value: T) => void) => {\r\n // Initialize the state\r\n $setState({ [name]: initialValue });\r\n\r\n // Return a setter function\r\n return (value: T) => {\r\n $setState({ [name]: value });\r\n };\r\n};\r\n\r\n// DOM query helpers with smart component context detection\r\n// Automatically searches within component context when appropriate\r\nexport const $querySelector = (\r\n selector: string,\r\n root?: Element | Document | ShadowRoot\r\n): Element | null => {\r\n if (root) {\r\n return root.querySelector(selector);\r\n }\r\n\r\n // Try to get component context\r\n const ctx = getComponentContext();\r\n if (ctx) {\r\n const searchRoot = ctx.shadowRoot || ctx.element;\r\n if (searchRoot) {\r\n const result = searchRoot.querySelector(selector);\r\n if (result) return result;\r\n }\r\n }\r\n\r\n // Fallback to document\r\n return document.querySelector(selector);\r\n};\r\n\r\nexport const $querySelectorAll = (\r\n selector: string,\r\n root?: Element | Document | ShadowRoot\r\n): NodeListOf<Element> => {\r\n if (root) {\r\n return root.querySelectorAll(selector);\r\n }\r\n\r\n // Try to get component context\r\n const ctx = getComponentContext();\r\n if (ctx) {\r\n const searchRoot = ctx.shadowRoot || ctx.element;\r\n if (searchRoot) {\r\n const result = searchRoot.querySelectorAll(selector);\r\n if (result.length > 0) return result;\r\n }\r\n }\r\n\r\n // Fallback to document\r\n return document.querySelectorAll(selector);\r\n};\r\n\r\n// for a browser‑global via <script src=\"…ladrillosjs.js\"></script>\r\nif (typeof window !== \"undefined\") {\r\n window.ladrillosjs = {\r\n registerComponent,\r\n registerComponents,\r\n };\r\n\r\n // Expose helper functions globally for non-module scripts\r\n window.$listen = $listen;\r\n window.$emit = $emit;\r\n window.$querySelector = $querySelector;\r\n window.$querySelectorAll = $querySelectorAll;\r\n window.$reactive = $reactive;\r\n window.$setState = $setState;\r\n window.$getState = $getState;\r\n}\r\n"],"names":["isDevelopment","e","logger","message","args","cache","maxCacheSize","getCached","path","cached","setCache","content","firstKey","fetchComponentSource","__async","response","text","error","safeFetch","url","res","err","REGEX_PATTERNS","parser","parseComponent","source","name","doc","parseComponentHTML","scripts","externalScripts","extractScripts","styles","extractStyles","template","isDevServerScript","src","pattern","el","isExternal","_a","_b","extractCSSFromResponse","viteMatch","exportMatch","style","styleElements","element","cssContent","styleEl","css","Ladrillos","__privateAdd","_Ladrillos_instances","useShadowDOM","component","__privateMethod","defineWebComponent_fn","defineWebComponent","ladrillos","EventBus","eventName","data","customEvent","callbacks","promises","callback","result","eventBus","registerComponent","registerComponents","components","$listen","event","$emit","__setComponentContext","shadowRoot","tagName","getComponentContext","registry","contexts","$getState","ctx","$setState","updates","$reactive","initialValue","value","$querySelector","selector","root","searchRoot","$querySelectorAll"],"mappings":"0cAKA,MAAMA,EAAgB,IAAe,CACnC,GAAI,CACF,MAAQ,EACV,OAAQC,EAAA,CACN,OAAO,QAAQ,IAAI,WAAa,aAClC,CACF,EAEaC,EAAS,CAMpB,IAAIC,KAAoBC,EAAmB,CACrCJ,KACF,QAAQ,IAAIG,EAAS,GAAGC,CAAI,CAEhC,EAOA,MAAMD,KAAoBC,EAAmB,CAC3C,QAAQ,MAAMD,EAAS,GAAGC,CAAI,CAChC,EAOA,KAAKD,KAAoBC,EAAmB,CACtCJ,KACF,QAAQ,KAAKG,EAAS,GAAGC,CAAI,CAEjC,CACF,EC5CMC,MAAY,IACZC,EAAe,GASRC,EAAaC,GAAqC,CAC7D,MAAMC,EAASJ,EAAM,IAAIG,CAAI,EAC7B,OAAIC,IAEFJ,EAAM,OAAOG,CAAI,EACjBH,EAAM,IAAIG,EAAMC,CAAM,GAEjBA,CACT,EASaC,EAAW,CAACF,EAAcG,IAA0B,CAC/D,GAAIN,EAAM,IAAIG,CAAI,EAEhBH,EAAM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OAAOA,CAChC,CACF,CAGA,OAAO,SAAS,iBAAiBsB,CAAQ,CAC3C,EAGI,OAAO,QAAW,cACpB,OAAO,YAAc,CACnB,kBAAApB,EACA,mBAAAC,CAAA,EAIF,OAAO,QAAUE,EACjB,OAAO,MAAQE,EACf,OAAO,eAAiBc,EACxB,OAAO,kBAAoBI,EAC3B,OAAO,UAAYP,EACnB,OAAO,UAAYF,EACnB,OAAO,UAAYF"}
@@ -213,7 +213,7 @@ class j {
213
213
  }
214
214
  f = new WeakSet(), C = function(e, s) {
215
215
  return a(this, null, function* () {
216
- const { defineWebComponent: r } = yield import("./webcomponent-Vt40CdPC.mjs");
216
+ const { defineWebComponent: r } = yield import("./webcomponent-DzBRHkic.mjs");
217
217
  this.components[e] && r(this.components[e], s);
218
218
  });
219
219
  };
@@ -358,4 +358,4 @@ export {
358
358
  m as l,
359
359
  H as r
360
360
  };
361
- //# sourceMappingURL=index-I-w3IPex.mjs.map
361
+ //# sourceMappingURL=index-CUJmLlUh.mjs.map