ladrillosjs 2.0.0-beta.3.7 → 2.0.0-beta.4
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 +112 -0
- package/dist/{index-DZqKSX8_.mjs → index-BcPgsuUl.mjs} +99 -77
- package/dist/{index-DZqKSX8_.mjs.map → index-BcPgsuUl.mjs.map} +1 -1
- package/dist/{index-Bx3jQFpE.js → index-FW6ZH_yR.js} +8 -8
- package/dist/{index-Bx3jQFpE.js.map → index-FW6ZH_yR.js.map} +1 -1
- package/dist/index.d.ts +94 -0
- package/dist/ladrillosjs.cjs.js +1 -1
- package/dist/ladrillosjs.es.js +14 -10
- package/dist/ladrillosjs.umd.js +25 -25
- package/dist/ladrillosjs.umd.js.map +1 -1
- package/dist/types/LadrilloTypes.d.ts +85 -0
- package/dist/{webcomponent-BRRZJV0q.js → webcomponent-BbbpAvoT.js} +2 -2
- package/dist/{webcomponent-BRRZJV0q.js.map → webcomponent-BbbpAvoT.js.map} +1 -1
- package/dist/{webcomponent-DyrhK3aa.mjs → webcomponent-Dt-f2pQx.mjs} +2 -2
- package/dist/{webcomponent-DyrhK3aa.mjs.map → webcomponent-Dt-f2pQx.mjs.map} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,7 @@ A lightweight, zero-dependency web component framework for building modular web
|
|
|
31
31
|
- [Shadow DOM](#shadow-dom)
|
|
32
32
|
- [Styling Components](#styling-components)
|
|
33
33
|
- [Performance & Caching](#performance--caching)
|
|
34
|
+
- [Creating Component Libraries](#creating-component-libraries)
|
|
34
35
|
- [Common Patterns](#common-patterns)
|
|
35
36
|
- [Keyboard Events](#keyboard-events)
|
|
36
37
|
- [Form Validation](#form-validation)
|
|
@@ -1594,6 +1595,117 @@ LadrillosJS includes built-in performance optimizations:
|
|
|
1594
1595
|
- Event listeners are automatically cleaned up
|
|
1595
1596
|
- Conditional rendering skips hidden elements
|
|
1596
1597
|
|
|
1598
|
+
## Creating Component Libraries
|
|
1599
|
+
|
|
1600
|
+
LadrillosJS makes it easy to create and publish reusable component libraries. Developers can use your components in their projects with full TypeScript support.
|
|
1601
|
+
|
|
1602
|
+
### Quick Example
|
|
1603
|
+
|
|
1604
|
+
**Create a library:**
|
|
1605
|
+
|
|
1606
|
+
```typescript
|
|
1607
|
+
// src/types/index.ts - Define interfaces
|
|
1608
|
+
export interface ButtonProps {
|
|
1609
|
+
variant?: 'primary' | 'secondary';
|
|
1610
|
+
size?: 'sm' | 'md' | 'lg';
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
export interface AwesomeButton extends HTMLElement {
|
|
1614
|
+
variant?: ButtonProps['variant'];
|
|
1615
|
+
size?: ButtonProps['size'];
|
|
1616
|
+
setLoading(state: boolean): void;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
// src/components/Button/button.html
|
|
1620
|
+
<button class="btn-{variant}" onclick="handleClick()">
|
|
1621
|
+
<slot>{label}</slot>
|
|
1622
|
+
</button>
|
|
1623
|
+
|
|
1624
|
+
<script>
|
|
1625
|
+
let variant = this.getAttribute('variant') || 'primary';
|
|
1626
|
+
let label = this.getAttribute('label') || 'Click';
|
|
1627
|
+
|
|
1628
|
+
export const handleClick = () => {
|
|
1629
|
+
$emit('button:click', { timestamp: Date.now() });
|
|
1630
|
+
};
|
|
1631
|
+
</script>
|
|
1632
|
+
|
|
1633
|
+
// src/index.ts - Export registry
|
|
1634
|
+
export * from './types';
|
|
1635
|
+
export * from './components/Button';
|
|
1636
|
+
|
|
1637
|
+
export const AWESOME_COMPONENTS = [
|
|
1638
|
+
{ name: 'awesome-button', path: './components/Button/button.html' }
|
|
1639
|
+
];
|
|
1640
|
+
|
|
1641
|
+
export const registerAwesomeComponents = async () => {
|
|
1642
|
+
const { registerComponents } = await import('ladrillosjs');
|
|
1643
|
+
return registerComponents(AWESOME_COMPONENTS);
|
|
1644
|
+
};
|
|
1645
|
+
```
|
|
1646
|
+
|
|
1647
|
+
**Consumers use it:**
|
|
1648
|
+
|
|
1649
|
+
```typescript
|
|
1650
|
+
import {
|
|
1651
|
+
registerAwesomeComponents,
|
|
1652
|
+
createButton,
|
|
1653
|
+
type AwesomeButton,
|
|
1654
|
+
} from "@awesome/ui";
|
|
1655
|
+
|
|
1656
|
+
// Register all components
|
|
1657
|
+
await registerAwesomeComponents();
|
|
1658
|
+
|
|
1659
|
+
// Use in HTML
|
|
1660
|
+
<awesome-button variant="primary" label="Click Me"></awesome-button>;
|
|
1661
|
+
|
|
1662
|
+
// Or programmatically with types
|
|
1663
|
+
const btn = createButton() as AwesomeButton;
|
|
1664
|
+
btn.setAttribute("variant", "secondary");
|
|
1665
|
+
btn.setLoading(true);
|
|
1666
|
+
|
|
1667
|
+
// Type-safe events
|
|
1668
|
+
btn.addEventListener("button:click", (e) => {
|
|
1669
|
+
console.log("Clicked:", e.detail.timestamp);
|
|
1670
|
+
});
|
|
1671
|
+
```
|
|
1672
|
+
|
|
1673
|
+
### Key Features for Libraries
|
|
1674
|
+
|
|
1675
|
+
✅ **TypeScript Interfaces** - Full type definitions for all props, events, and methods
|
|
1676
|
+
✅ **Component Registry** - Easy batch registration
|
|
1677
|
+
✅ **Helper Functions** - `createButton()`, `configureCard()`, etc.
|
|
1678
|
+
✅ **Metadata Export** - Component documentation and metadata
|
|
1679
|
+
✅ **Multiple Formats** - ESM, CJS, UMD outputs
|
|
1680
|
+
✅ **Tree-Shakeable** - Only import what you use
|
|
1681
|
+
|
|
1682
|
+
### Creating Your Library
|
|
1683
|
+
|
|
1684
|
+
1. **Define TypeScript interfaces** for props, events, and typed element references
|
|
1685
|
+
2. **Create single-file `.html` components** with template, styles, and scripts
|
|
1686
|
+
3. **Export helper functions** for programmatic component creation
|
|
1687
|
+
4. **Create component registry** for batch registration
|
|
1688
|
+
5. **Configure package.json** with exports field for subpath imports
|
|
1689
|
+
6. **Build and publish** to NPM
|
|
1690
|
+
|
|
1691
|
+
### Example Projects
|
|
1692
|
+
|
|
1693
|
+
- **[Full Example Library](samples/component-library/)** - Complete Button, Card, Modal components with TypeScript
|
|
1694
|
+
- **[Library Demo App](samples/apps/component-library-demo/)** - Shows all usage patterns and integrations
|
|
1695
|
+
|
|
1696
|
+
### Complete Guide
|
|
1697
|
+
|
|
1698
|
+
For detailed instructions on creating, building, and publishing component libraries, see the **[Library Authoring Guide](docs/LIBRARY_AUTHORING.md)**.
|
|
1699
|
+
|
|
1700
|
+
Topics covered:
|
|
1701
|
+
|
|
1702
|
+
- Project structure and best practices
|
|
1703
|
+
- Component creation with HTML + TypeScript
|
|
1704
|
+
- Building with Vite
|
|
1705
|
+
- Publishing to NPM
|
|
1706
|
+
- Consumer usage examples
|
|
1707
|
+
- React/Vue integration patterns
|
|
1708
|
+
|
|
1597
1709
|
## Common Patterns
|
|
1598
1710
|
|
|
1599
1711
|
### Keyboard Events
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var D = Object.defineProperty, B = Object.defineProperties;
|
|
2
|
+
var W = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var P = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
4
|
+
var O = Object.prototype.hasOwnProperty, J = Object.prototype.propertyIsEnumerable;
|
|
5
5
|
var k = (t) => {
|
|
6
6
|
throw TypeError(t);
|
|
7
7
|
};
|
|
8
|
-
var _ = (t, e, r) => e in t ?
|
|
8
|
+
var _ = (t, e, r) => e in t ? D(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, h = (t, e) => {
|
|
9
9
|
for (var r in e || (e = {}))
|
|
10
|
-
|
|
10
|
+
O.call(e, r) && _(t, r, e[r]);
|
|
11
11
|
if (P)
|
|
12
12
|
for (var r of P(e))
|
|
13
|
-
|
|
13
|
+
J.call(e, r) && _(t, r, e[r]);
|
|
14
14
|
return t;
|
|
15
|
-
}, w = (t, e) => B(t,
|
|
16
|
-
var
|
|
15
|
+
}, w = (t, e) => B(t, W(e));
|
|
16
|
+
var K = (t, e, r) => e.has(t) || k("Cannot " + r);
|
|
17
17
|
var L = (t, e, r) => e.has(t) ? k("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r);
|
|
18
|
-
var
|
|
18
|
+
var v = (t, e, r) => (K(t, e, "access private method"), r);
|
|
19
19
|
var p = (t, e, r) => new Promise((s, o) => {
|
|
20
20
|
var i = (c) => {
|
|
21
21
|
try {
|
|
@@ -32,7 +32,7 @@ var p = (t, e, r) => new Promise((s, o) => {
|
|
|
32
32
|
}, l = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(i, a);
|
|
33
33
|
l((r = r.apply(t, e)).next());
|
|
34
34
|
});
|
|
35
|
-
const
|
|
35
|
+
const z = () => {
|
|
36
36
|
try {
|
|
37
37
|
return !1;
|
|
38
38
|
} catch (t) {
|
|
@@ -45,7 +45,7 @@ const j = () => {
|
|
|
45
45
|
* @param args - Additional arguments to log
|
|
46
46
|
*/
|
|
47
47
|
log(t, ...e) {
|
|
48
|
-
|
|
48
|
+
z() && console.log(t, ...e);
|
|
49
49
|
},
|
|
50
50
|
/**
|
|
51
51
|
* Log an error (always logs in both dev and production)
|
|
@@ -61,9 +61,9 @@ const j = () => {
|
|
|
61
61
|
* @param args - Additional arguments to log
|
|
62
62
|
*/
|
|
63
63
|
warn(t, ...e) {
|
|
64
|
-
|
|
64
|
+
z() && console.warn(t, ...e);
|
|
65
65
|
}
|
|
66
|
-
},
|
|
66
|
+
}, g = (t, e) => {
|
|
67
67
|
const r = [t];
|
|
68
68
|
return e && (e.componentName && r.push(`
|
|
69
69
|
Component: <${e.componentName}>`), e.componentPath && r.push(`
|
|
@@ -74,7 +74,7 @@ const j = () => {
|
|
|
74
74
|
Element: <${e.elementTag}>`), e.lineHint && r.push(`
|
|
75
75
|
Location: ${e.lineHint}`)), r.join("");
|
|
76
76
|
}, me = (t, e, r) => {
|
|
77
|
-
const s =
|
|
77
|
+
const s = g(
|
|
78
78
|
"⚠️ Binding Error: Failed to evaluate expression",
|
|
79
79
|
w(h({}, r), {
|
|
80
80
|
expression: t,
|
|
@@ -82,8 +82,8 @@ const j = () => {
|
|
|
82
82
|
})
|
|
83
83
|
);
|
|
84
84
|
n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
|
|
85
|
-
},
|
|
86
|
-
const o =
|
|
85
|
+
}, fe = (t, e, r, s) => {
|
|
86
|
+
const o = g(
|
|
87
87
|
"⚠️ Event Handler Error: Failed to execute handler",
|
|
88
88
|
w(h({}, s), {
|
|
89
89
|
eventType: t,
|
|
@@ -92,8 +92,8 @@ const j = () => {
|
|
|
92
92
|
})
|
|
93
93
|
);
|
|
94
94
|
n.error(o), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
|
|
95
|
-
},
|
|
96
|
-
const s =
|
|
95
|
+
}, ge = (t, e, r) => {
|
|
96
|
+
const s = g(
|
|
97
97
|
"⚠️ Conditional Error: Failed to evaluate condition",
|
|
98
98
|
w(h({}, r), {
|
|
99
99
|
expression: t,
|
|
@@ -102,7 +102,7 @@ const j = () => {
|
|
|
102
102
|
);
|
|
103
103
|
n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
|
|
104
104
|
}, he = (t, e, r) => {
|
|
105
|
-
const s =
|
|
105
|
+
const s = g(
|
|
106
106
|
"⚠️ Loop Error: Failed to process loop",
|
|
107
107
|
w(h({}, r), {
|
|
108
108
|
expression: t,
|
|
@@ -110,8 +110,8 @@ const j = () => {
|
|
|
110
110
|
})
|
|
111
111
|
);
|
|
112
112
|
n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
|
|
113
|
-
},
|
|
114
|
-
const s =
|
|
113
|
+
}, j = (t, e, r) => {
|
|
114
|
+
const s = g(
|
|
115
115
|
"⚠️ Registration Error: Failed to register component",
|
|
116
116
|
{
|
|
117
117
|
componentName: t,
|
|
@@ -120,7 +120,7 @@ const j = () => {
|
|
|
120
120
|
);
|
|
121
121
|
n.error(s), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
|
|
122
122
|
}, N = (t, e, r) => {
|
|
123
|
-
const s =
|
|
123
|
+
const s = g(
|
|
124
124
|
"⚠️ Fetch Error: Failed to load resource",
|
|
125
125
|
w(h({}, r), {
|
|
126
126
|
componentPath: t
|
|
@@ -128,19 +128,19 @@ const j = () => {
|
|
|
128
128
|
);
|
|
129
129
|
n.error(s), n.error(` Error details: ${e.message}`);
|
|
130
130
|
}, x = (t, e) => {
|
|
131
|
-
const r =
|
|
131
|
+
const r = g(
|
|
132
132
|
`⚠️ Parse Error: ${t}`,
|
|
133
133
|
e
|
|
134
134
|
);
|
|
135
135
|
n.error(r);
|
|
136
136
|
}, we = (t, e) => {
|
|
137
|
-
const r =
|
|
137
|
+
const r = g(
|
|
138
138
|
"⚠️ Script Error: Failed to execute component script",
|
|
139
139
|
e
|
|
140
140
|
);
|
|
141
141
|
n.error(r), n.error(` Error details: ${t.message}`), t.stack && console.debug(" Stack trace:", t.stack);
|
|
142
142
|
}, ye = (t, e, r) => {
|
|
143
|
-
const s =
|
|
143
|
+
const s = g(
|
|
144
144
|
"⚠️ Two-Way Binding Error: Failed to setup binding",
|
|
145
145
|
w(h({}, r), {
|
|
146
146
|
expression: t,
|
|
@@ -154,21 +154,21 @@ const j = () => {
|
|
|
154
154
|
componentName: (t == null ? void 0 : t.tagName) || ((r = t == null ? void 0 : t.constructor) == null ? void 0 : r.name),
|
|
155
155
|
componentPath: (t == null ? void 0 : t.sourcePath) || (t == null ? void 0 : t._sourcePath)
|
|
156
156
|
}, e);
|
|
157
|
-
},
|
|
158
|
-
const e =
|
|
159
|
-
return e && (
|
|
160
|
-
},
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
else if (
|
|
164
|
-
const r =
|
|
165
|
-
r &&
|
|
157
|
+
}, f = /* @__PURE__ */ new Map(), U = 25, G = (t) => {
|
|
158
|
+
const e = f.get(t);
|
|
159
|
+
return e && (f.delete(t), f.set(t, e)), e;
|
|
160
|
+
}, Q = (t, e) => {
|
|
161
|
+
if (f.has(t))
|
|
162
|
+
f.delete(t);
|
|
163
|
+
else if (f.size >= U) {
|
|
164
|
+
const r = f.keys().next().value;
|
|
165
|
+
r && f.delete(r);
|
|
166
166
|
}
|
|
167
|
-
|
|
168
|
-
},
|
|
167
|
+
f.set(t, e);
|
|
168
|
+
}, M = (t) => p(null, null, function* () {
|
|
169
169
|
if (!t)
|
|
170
170
|
throw new Error("Path cannot be null or empty");
|
|
171
|
-
const e =
|
|
171
|
+
const e = G(t);
|
|
172
172
|
if (e) return e;
|
|
173
173
|
try {
|
|
174
174
|
const r = yield fetch(t);
|
|
@@ -177,11 +177,11 @@ const j = () => {
|
|
|
177
177
|
`Failed to fetch component from ${t}: ${r.statusText}`
|
|
178
178
|
);
|
|
179
179
|
const s = yield r.text();
|
|
180
|
-
return
|
|
180
|
+
return Q(t, s), s;
|
|
181
181
|
} catch (r) {
|
|
182
182
|
N(t, r, { componentPath: t });
|
|
183
183
|
}
|
|
184
|
-
}),
|
|
184
|
+
}), V = (t) => p(null, null, function* () {
|
|
185
185
|
try {
|
|
186
186
|
const e = yield fetch(t);
|
|
187
187
|
if (!e.ok) throw new Error(`HTTP ${e.status}`);
|
|
@@ -196,8 +196,8 @@ const j = () => {
|
|
|
196
196
|
css: /\/\*[\s\S]*?\*\//g,
|
|
197
197
|
html: /<!--[\s\S]*?-->/g
|
|
198
198
|
}
|
|
199
|
-
},
|
|
200
|
-
const r =
|
|
199
|
+
}, X = new DOMParser(), F = (t, e) => p(null, null, function* () {
|
|
200
|
+
const r = Y(t), { scripts: s, externalScripts: o } = ee(r), i = yield re(r), a = r.body.innerHTML.trim();
|
|
201
201
|
return {
|
|
202
202
|
tagName: e,
|
|
203
203
|
template: a,
|
|
@@ -205,10 +205,10 @@ const j = () => {
|
|
|
205
205
|
externalScripts: o,
|
|
206
206
|
styles: i
|
|
207
207
|
};
|
|
208
|
-
}),
|
|
208
|
+
}), Y = (t) => X.parseFromString(
|
|
209
209
|
t.replace(b.comments.html, ""),
|
|
210
210
|
"text/html"
|
|
211
|
-
),
|
|
211
|
+
), Z = (t) => [
|
|
212
212
|
"/@vite/",
|
|
213
213
|
// Vite dev client
|
|
214
214
|
"/__vite",
|
|
@@ -223,12 +223,12 @@ const j = () => {
|
|
|
223
223
|
// Browser Sync
|
|
224
224
|
"/livereload.js"
|
|
225
225
|
// LiveReload
|
|
226
|
-
].some((r) => t.includes(r)),
|
|
226
|
+
].some((r) => t.includes(r)), ee = (t) => {
|
|
227
227
|
var s, o;
|
|
228
228
|
const e = [], r = [];
|
|
229
229
|
for (const i of t.querySelectorAll("script")) {
|
|
230
230
|
if (i.src) {
|
|
231
|
-
if (
|
|
231
|
+
if (Z(i.src)) {
|
|
232
232
|
i.remove();
|
|
233
233
|
continue;
|
|
234
234
|
}
|
|
@@ -249,7 +249,7 @@ const j = () => {
|
|
|
249
249
|
i.remove();
|
|
250
250
|
}
|
|
251
251
|
return { scripts: e, externalScripts: r };
|
|
252
|
-
},
|
|
252
|
+
}, te = (t) => {
|
|
253
253
|
const e = t.match(/const __vite__css = "((?:[^"\\]|\\.)*)"/);
|
|
254
254
|
if (e && e[1])
|
|
255
255
|
return e[1].replace(/\\r\\n/g, `
|
|
@@ -261,12 +261,12 @@ const j = () => {
|
|
|
261
261
|
`).replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\") : t.includes("import") || t.includes("export") ? (n.warn(
|
|
262
262
|
"CSS file returned JavaScript module format. CSS may not load correctly."
|
|
263
263
|
), "") : t;
|
|
264
|
-
},
|
|
264
|
+
}, re = (t) => p(null, null, function* () {
|
|
265
265
|
let e = "";
|
|
266
266
|
const r = t.querySelectorAll("style, link[rel='stylesheet']");
|
|
267
267
|
for (const s of r) {
|
|
268
268
|
if (s.tagName === "LINK") {
|
|
269
|
-
const i = yield
|
|
269
|
+
const i = yield V(s.href), a = te(i);
|
|
270
270
|
a && (e += `
|
|
271
271
|
` + a);
|
|
272
272
|
} else if (s.tagName === "STYLE") {
|
|
@@ -282,7 +282,7 @@ const j = () => {
|
|
|
282
282
|
return e.trim();
|
|
283
283
|
});
|
|
284
284
|
var C, T, H;
|
|
285
|
-
class
|
|
285
|
+
class se {
|
|
286
286
|
constructor() {
|
|
287
287
|
L(this, C);
|
|
288
288
|
this.components = {}, this.lazyComponents = /* @__PURE__ */ new Set(), this.intersectionObserver = null, this.lazyLoadingInProgress = /* @__PURE__ */ new Map(), this.lazyComponentsLoaded = /* @__PURE__ */ new Set();
|
|
@@ -294,11 +294,11 @@ class re {
|
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
296
|
if (o) {
|
|
297
|
-
this.lazyComponents.add(e),
|
|
297
|
+
this.lazyComponents.add(e), v(this, C, T).call(this, e, r, s), n.log(`Component ${e} registered as lazy-loaded`);
|
|
298
298
|
return;
|
|
299
299
|
}
|
|
300
300
|
try {
|
|
301
|
-
const i = yield
|
|
301
|
+
const i = yield M(r), a = yield F(i, e);
|
|
302
302
|
this.components[e] = {
|
|
303
303
|
tagName: e,
|
|
304
304
|
template: a.template,
|
|
@@ -307,9 +307,9 @@ class re {
|
|
|
307
307
|
styles: a.styles,
|
|
308
308
|
sourcePath: r,
|
|
309
309
|
lazy: !1
|
|
310
|
-
}, n.log(`Component ${e} registered successfully`), yield
|
|
310
|
+
}, n.log(`Component ${e} registered successfully`), yield v(this, C, H).call(this, e, s);
|
|
311
311
|
} catch (i) {
|
|
312
|
-
|
|
312
|
+
j(e, r, i);
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
315
|
});
|
|
@@ -369,7 +369,7 @@ T = function(e, r, s) {
|
|
|
369
369
|
const l = this.performLoad();
|
|
370
370
|
o.lazyLoadingInProgress.set(e, l), yield l, o.lazyLoadingInProgress.delete(e), o.lazyComponentsLoaded.add(e), o.lazyComponents.delete(e), n.log(`Component ${e} lazy-loaded successfully`);
|
|
371
371
|
} catch (l) {
|
|
372
|
-
o.lazyLoadingInProgress.delete(e),
|
|
372
|
+
o.lazyLoadingInProgress.delete(e), j(e, r, l);
|
|
373
373
|
}
|
|
374
374
|
});
|
|
375
375
|
}
|
|
@@ -384,7 +384,7 @@ T = function(e, r, s) {
|
|
|
384
384
|
});
|
|
385
385
|
return;
|
|
386
386
|
}
|
|
387
|
-
const c = yield
|
|
387
|
+
const c = yield M(r), d = yield F(c, e);
|
|
388
388
|
n.log(`Component ${e} parsed successfully`), o.components[e] = {
|
|
389
389
|
tagName: e,
|
|
390
390
|
template: d.template,
|
|
@@ -398,7 +398,7 @@ T = function(e, r, s) {
|
|
|
398
398
|
n.log(`Defining real component with temp name: ${m}`);
|
|
399
399
|
const y = o.components[e].tagName;
|
|
400
400
|
o.components[e].tagName = m;
|
|
401
|
-
const { defineWebComponent: S } = yield import("./webcomponent-
|
|
401
|
+
const { defineWebComponent: S } = yield import("./webcomponent-Dt-f2pQx.mjs");
|
|
402
402
|
S(o.components[e], s), n.log(`Real component ${m} defined`), o.components[e].tagName = y, this.upgradePlaceholder();
|
|
403
403
|
});
|
|
404
404
|
}
|
|
@@ -422,12 +422,12 @@ T = function(e, r, s) {
|
|
|
422
422
|
customElements.get(e) || customElements.define(e, i);
|
|
423
423
|
}, H = function(e, r) {
|
|
424
424
|
return p(this, null, function* () {
|
|
425
|
-
const { defineWebComponent: s } = yield import("./webcomponent-
|
|
425
|
+
const { defineWebComponent: s } = yield import("./webcomponent-Dt-f2pQx.mjs");
|
|
426
426
|
this.components[e] && s(this.components[e], r);
|
|
427
427
|
});
|
|
428
428
|
};
|
|
429
|
-
const A = new
|
|
430
|
-
class
|
|
429
|
+
const A = new se();
|
|
430
|
+
class oe {
|
|
431
431
|
constructor() {
|
|
432
432
|
this.listeners = /* @__PURE__ */ new Map();
|
|
433
433
|
}
|
|
@@ -497,14 +497,14 @@ class se {
|
|
|
497
497
|
return (s = (r = this.listeners.get(e)) == null ? void 0 : r.size) != null ? s : 0;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
const R = new
|
|
501
|
-
function
|
|
500
|
+
const R = new oe(), u = {};
|
|
501
|
+
function I(t) {
|
|
502
502
|
return p(this, null, function* () {
|
|
503
503
|
const e = yield u.readdir(t, { withFileTypes: !0 });
|
|
504
504
|
for (const r of e) {
|
|
505
505
|
const s = u.resolve(t, r.name);
|
|
506
506
|
if (r.isDirectory())
|
|
507
|
-
yield
|
|
507
|
+
yield I(s);
|
|
508
508
|
else if (r.name.endsWith(".html")) {
|
|
509
509
|
let o = yield u.readFile(s, "utf-8");
|
|
510
510
|
o = o.replace(
|
|
@@ -595,7 +595,7 @@ function Se(t = {}) {
|
|
|
595
595
|
try {
|
|
596
596
|
u.existsSync(d) && u.rmSync(d, { recursive: !0, force: !0 }), u.cpSync(c, d, { recursive: !0 }), console.log(
|
|
597
597
|
`[ladrillosjs:copy-components] Copied components from ${c} to ${d}`
|
|
598
|
-
), o && (yield
|
|
598
|
+
), o && (yield I(d), console.log(
|
|
599
599
|
`[ladrillosjs:copy-components] Processed component scripts in ${d}`
|
|
600
600
|
));
|
|
601
601
|
} catch (m) {
|
|
@@ -608,7 +608,7 @@ function Se(t = {}) {
|
|
|
608
608
|
}
|
|
609
609
|
};
|
|
610
610
|
}
|
|
611
|
-
const
|
|
611
|
+
const ne = (t, e, r, s) => A.registerComponent(t, e, r, s), q = (t) => p(null, null, function* () {
|
|
612
612
|
yield Promise.all(
|
|
613
613
|
t.map(
|
|
614
614
|
({ name: e, path: r, useShadowDOM: s, lazy: o }) => A.registerComponent(e, r, s, o)
|
|
@@ -631,11 +631,11 @@ const oe = (t, e, r, s) => A.registerComponent(t, e, r, s), ne = (t) => p(null,
|
|
|
631
631
|
}, ae = () => {
|
|
632
632
|
const t = $();
|
|
633
633
|
return t && t.element ? t.element.state || {} : {};
|
|
634
|
-
},
|
|
634
|
+
}, E = (t) => {
|
|
635
635
|
const e = $();
|
|
636
636
|
e && e.setState && e.setState(t);
|
|
637
|
-
}, ce = (t, e) => (
|
|
638
|
-
|
|
637
|
+
}, ce = (t, e) => (E({ [t]: e }), (r) => {
|
|
638
|
+
E({ [t]: r });
|
|
639
639
|
}), de = (t, e) => {
|
|
640
640
|
if (e)
|
|
641
641
|
return e.querySelector(t);
|
|
@@ -662,9 +662,27 @@ const oe = (t, e, r, s) => A.registerComponent(t, e, r, s), ne = (t) => p(null,
|
|
|
662
662
|
return document.querySelectorAll(t);
|
|
663
663
|
};
|
|
664
664
|
typeof window != "undefined" && (window.ladrillosjs = {
|
|
665
|
-
registerComponent:
|
|
666
|
-
registerComponents:
|
|
667
|
-
}, window.$listen = ie, window.$emit = le, window.$querySelector = de, window.$querySelectorAll = pe, window.$reactive = ce, window.$setState =
|
|
665
|
+
registerComponent: ne,
|
|
666
|
+
registerComponents: q
|
|
667
|
+
}, window.$listen = ie, window.$emit = le, window.$querySelector = de, window.$querySelectorAll = pe, window.$reactive = ce, window.$setState = E, window.$getState = ae);
|
|
668
|
+
const ve = (t) => t, Ee = (t) => {
|
|
669
|
+
var e, r;
|
|
670
|
+
return {
|
|
671
|
+
registration: {
|
|
672
|
+
name: t.name,
|
|
673
|
+
path: t.path,
|
|
674
|
+
useShadowDOM: (e = t.useShadowDOM) != null ? e : !0,
|
|
675
|
+
lazy: (r = t.lazy) != null ? r : !1
|
|
676
|
+
},
|
|
677
|
+
interface: t.interface,
|
|
678
|
+
version: t.version,
|
|
679
|
+
library: t.library
|
|
680
|
+
};
|
|
681
|
+
}, be = (t, e) => t ? (e && t.tagName.toLowerCase() !== e.toLowerCase() && console.warn(
|
|
682
|
+
`Expected element with tag "${e}", got "${t.tagName.toLowerCase()}"`
|
|
683
|
+
), t) : null, Pe = (t, e) => p(null, null, function* () {
|
|
684
|
+
return q(t);
|
|
685
|
+
});
|
|
668
686
|
export {
|
|
669
687
|
ie as $,
|
|
670
688
|
b as R,
|
|
@@ -672,21 +690,25 @@ export {
|
|
|
672
690
|
me as a,
|
|
673
691
|
he as b,
|
|
674
692
|
Ce as c,
|
|
675
|
-
|
|
676
|
-
|
|
693
|
+
ge as d,
|
|
694
|
+
fe as e,
|
|
677
695
|
R as f,
|
|
678
696
|
we as g,
|
|
679
697
|
n as h,
|
|
680
698
|
ye as i,
|
|
681
|
-
|
|
699
|
+
q as j,
|
|
682
700
|
le as k,
|
|
683
701
|
x as l,
|
|
684
702
|
ae as m,
|
|
685
|
-
|
|
703
|
+
E as n,
|
|
686
704
|
ce as o,
|
|
687
705
|
de as p,
|
|
688
706
|
pe as q,
|
|
689
|
-
|
|
690
|
-
|
|
707
|
+
ne as r,
|
|
708
|
+
ve as s,
|
|
709
|
+
Ee as t,
|
|
710
|
+
be as u,
|
|
711
|
+
Pe as v,
|
|
712
|
+
Se as w
|
|
691
713
|
};
|
|
692
|
-
//# sourceMappingURL=index-
|
|
714
|
+
//# sourceMappingURL=index-BcPgsuUl.mjs.map
|