@mulanjs/mulanjs 1.0.1-dev.20260219085559 → 1.0.1-dev.20260219161219
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/infinity-list.js +110 -0
- package/dist/index.js +8 -4
- package/dist/mulan.esm.js +188 -5
- package/dist/mulan.js +12 -2
- package/dist/router/index.js +53 -1
- package/dist/types/components/infinity-list.d.ts +17 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/router/index.d.ts +1 -0
- package/dist/types/src/compiler/compiler.d.ts +7 -0
- package/dist/types/src/compiler/script-compiler.d.ts +8 -0
- package/dist/types/src/compiler/sfc-parser.d.ts +21 -0
- package/dist/types/src/compiler/style-compiler.d.ts +7 -0
- package/dist/types/src/compiler/template-compiler.d.ts +7 -0
- package/dist/types/src/components/bloch-sphere.d.ts +16 -0
- package/dist/types/src/components/infinity-list.d.ts +17 -0
- package/dist/types/src/core/component.d.ts +54 -0
- package/dist/types/src/core/hooks.d.ts +49 -0
- package/dist/types/src/core/quantum.d.ts +50 -0
- package/dist/types/src/core/query.d.ts +14 -0
- package/dist/types/src/core/reactive.d.ts +21 -0
- package/dist/types/src/core/renderer.d.ts +4 -0
- package/dist/types/src/core/vault.d.ts +12 -0
- package/dist/types/src/index.d.ts +79 -0
- package/dist/types/src/router/index.d.ts +25 -0
- package/dist/types/src/security/sanitizer.d.ts +22 -0
- package/dist/types/src/store/index.d.ts +10 -0
- package/dist/types/tests/ssg_repro/src/main.d.ts +6 -0
- package/package.json +1 -1
- package/src/cli/index.js +8 -0
- package/src/cli/static-generator.js +183 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export class MuInfinity extends HTMLElement {
|
|
2
|
+
constructor() {
|
|
3
|
+
super();
|
|
4
|
+
this._items = [];
|
|
5
|
+
this._itemHeight = 50; // Default height
|
|
6
|
+
this._template = '';
|
|
7
|
+
this.attachShadow({ mode: 'open' });
|
|
8
|
+
// Structure:
|
|
9
|
+
// :host { overflow-y: auto; display: block; height: 100%; }
|
|
10
|
+
// .spacer { height: totalHeight; position: relative; }
|
|
11
|
+
// .content { position: absolute; top: padding; width: 100%; }
|
|
12
|
+
this.shadowRoot.innerHTML = `
|
|
13
|
+
<style>
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
overflow-y: auto;
|
|
17
|
+
height: 100%;
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
20
|
+
.spacer {
|
|
21
|
+
position: relative;
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
.content {
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 0;
|
|
27
|
+
left: 0;
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
31
|
+
<div class="spacer">
|
|
32
|
+
<div class="content"></div>
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
35
|
+
this.container = this.shadowRoot.host; // The host itself scrolls
|
|
36
|
+
this.spacer = this.shadowRoot.querySelector('.spacer');
|
|
37
|
+
this.content = this.shadowRoot.querySelector('.content');
|
|
38
|
+
this.onScroll = this.onScroll.bind(this);
|
|
39
|
+
}
|
|
40
|
+
static get observedAttributes() {
|
|
41
|
+
return ['item-height'];
|
|
42
|
+
}
|
|
43
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
44
|
+
if (name === 'item-height') {
|
|
45
|
+
this._itemHeight = parseInt(newValue, 10) || 50;
|
|
46
|
+
this.renderVisible();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
// Find the template provided by the user (Support both standard and branded tags)
|
|
51
|
+
const templateTag = this.querySelector('template') || this.querySelector('mu-template');
|
|
52
|
+
if (templateTag) {
|
|
53
|
+
this._template = templateTag.innerHTML;
|
|
54
|
+
}
|
|
55
|
+
this.addEventListener('scroll', this.onScroll);
|
|
56
|
+
// Wait for next frame to get initial height if not set
|
|
57
|
+
requestAnimationFrame(() => this.renderVisible());
|
|
58
|
+
}
|
|
59
|
+
disconnectedCallback() {
|
|
60
|
+
this.removeEventListener('scroll', this.onScroll);
|
|
61
|
+
}
|
|
62
|
+
set items(value) {
|
|
63
|
+
this._items = value;
|
|
64
|
+
this.renderVisible();
|
|
65
|
+
}
|
|
66
|
+
get items() { return this._items; }
|
|
67
|
+
onScroll() {
|
|
68
|
+
requestAnimationFrame(() => this.renderVisible());
|
|
69
|
+
}
|
|
70
|
+
renderVisible() {
|
|
71
|
+
if (!this._items.length)
|
|
72
|
+
return;
|
|
73
|
+
const scrollTop = this.scrollTop;
|
|
74
|
+
const hostHeight = this.clientHeight || 400; // Default fallback if not sized
|
|
75
|
+
const totalHeight = this._items.length * this._itemHeight;
|
|
76
|
+
this.spacer.style.height = `${totalHeight}px`;
|
|
77
|
+
// Windowing Math
|
|
78
|
+
const startIndex = Math.floor(scrollTop / this._itemHeight);
|
|
79
|
+
const buffer = 5;
|
|
80
|
+
const visibleCount = Math.ceil(hostHeight / this._itemHeight);
|
|
81
|
+
const renderStart = Math.max(0, startIndex - buffer);
|
|
82
|
+
const renderEnd = Math.min(this._items.length, startIndex + visibleCount + buffer);
|
|
83
|
+
const startOffset = renderStart * this._itemHeight;
|
|
84
|
+
this.content.style.transform = `translateY(${startOffset}px)`;
|
|
85
|
+
// Render specific slice
|
|
86
|
+
const visibleItems = this._items.slice(renderStart, renderEnd);
|
|
87
|
+
// Simple string replacement template engine for the demo
|
|
88
|
+
// In a real Mulan compilation, this would be an optimized ASTR render
|
|
89
|
+
let html = '';
|
|
90
|
+
visibleItems.forEach((item, index) => {
|
|
91
|
+
const absoluteIndex = renderStart + index;
|
|
92
|
+
// Basic mustache replacement {{ item.prop }}
|
|
93
|
+
let rowHtml = this._template
|
|
94
|
+
.replace(/{{\s*item\s*}}/g, String(item)) // {{ item }}
|
|
95
|
+
.replace(/{{\s*index\s*}}/g, String(absoluteIndex)); // {{ index }}
|
|
96
|
+
// Handle object properties: {{ item.name }}
|
|
97
|
+
if (typeof item === 'object' && item !== null) {
|
|
98
|
+
rowHtml = rowHtml.replace(/{{\s*item\.(\w+)\s*}}/g, (_, prop) => {
|
|
99
|
+
return String(item[prop] || '');
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
html += `<div style="height: ${this._itemHeight}px; overflow: hidden;">${rowHtml}</div>`;
|
|
103
|
+
});
|
|
104
|
+
this.content.innerHTML = html;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Register
|
|
108
|
+
if (typeof customElements !== 'undefined' && !customElements.get('mu-infinity')) {
|
|
109
|
+
customElements.define('mu-infinity', MuInfinity);
|
|
110
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -9,18 +9,20 @@ export * from './core/query';
|
|
|
9
9
|
export * from './core/vault';
|
|
10
10
|
export * from './core/quantum';
|
|
11
11
|
export * from './components/bloch-sphere';
|
|
12
|
+
export * from './components/infinity-list';
|
|
12
13
|
// Global Mulan Object for non-module usage
|
|
13
14
|
import { reactive, effect } from './core/reactive';
|
|
14
15
|
import { MuComponent, defineComponent } from './core/component';
|
|
15
|
-
import { MuRouter } from './router/index';
|
|
16
|
+
import { MuRouter, createRouter } from './router/index';
|
|
16
17
|
import { MuStore } from './store/index';
|
|
17
18
|
import { Security } from './security/sanitizer';
|
|
18
19
|
import * as Hooks from './core/hooks';
|
|
19
20
|
import * as Query from './core/query';
|
|
20
21
|
import { render } from './core/renderer';
|
|
21
22
|
import * as Quantum from './core/quantum';
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
import * as InfinityList from './components/infinity-list';
|
|
24
|
+
const Mulan = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ reactive,
|
|
25
|
+
effect, Component: MuComponent, defineComponent, Router: MuRouter, createRouter, Store: MuStore, Security: Security }, Hooks), Query), Quantum), InfinityList), { render,
|
|
24
26
|
// MULAN INSIGHT: Branded Logging
|
|
25
27
|
log: (msg, ...args) => {
|
|
26
28
|
console.log(`%c[MulanJS]%c ${msg}`, "color: #ff3e00; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;", "", ...args);
|
|
@@ -49,5 +51,7 @@ if (typeof window !== 'undefined') {
|
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
}
|
|
52
|
-
window
|
|
54
|
+
if (typeof window !== 'undefined') {
|
|
55
|
+
window.Mulan = Mulan;
|
|
56
|
+
}
|
|
53
57
|
export default Mulan;
|
package/dist/mulan.esm.js
CHANGED
|
@@ -265,6 +265,130 @@ if (typeof customElements !== 'undefined') {
|
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
|
|
268
|
+
/***/ },
|
|
269
|
+
|
|
270
|
+
/***/ "./src/components/infinity-list.ts"
|
|
271
|
+
/*!*****************************************!*\
|
|
272
|
+
!*** ./src/components/infinity-list.ts ***!
|
|
273
|
+
\*****************************************/
|
|
274
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
275
|
+
|
|
276
|
+
__webpack_require__.r(__webpack_exports__);
|
|
277
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
278
|
+
/* harmony export */ MuInfinity: () => (/* binding */ MuInfinity)
|
|
279
|
+
/* harmony export */ });
|
|
280
|
+
class MuInfinity extends HTMLElement {
|
|
281
|
+
constructor() {
|
|
282
|
+
super();
|
|
283
|
+
this._items = [];
|
|
284
|
+
this._itemHeight = 50; // Default height
|
|
285
|
+
this._template = '';
|
|
286
|
+
this.attachShadow({ mode: 'open' });
|
|
287
|
+
// Structure:
|
|
288
|
+
// :host { overflow-y: auto; display: block; height: 100%; }
|
|
289
|
+
// .spacer { height: totalHeight; position: relative; }
|
|
290
|
+
// .content { position: absolute; top: padding; width: 100%; }
|
|
291
|
+
this.shadowRoot.innerHTML = `
|
|
292
|
+
<style>
|
|
293
|
+
:host {
|
|
294
|
+
display: block;
|
|
295
|
+
overflow-y: auto;
|
|
296
|
+
height: 100%;
|
|
297
|
+
position: relative;
|
|
298
|
+
}
|
|
299
|
+
.spacer {
|
|
300
|
+
position: relative;
|
|
301
|
+
width: 100%;
|
|
302
|
+
}
|
|
303
|
+
.content {
|
|
304
|
+
position: absolute;
|
|
305
|
+
top: 0;
|
|
306
|
+
left: 0;
|
|
307
|
+
width: 100%;
|
|
308
|
+
}
|
|
309
|
+
</style>
|
|
310
|
+
<div class="spacer">
|
|
311
|
+
<div class="content"></div>
|
|
312
|
+
</div>
|
|
313
|
+
`;
|
|
314
|
+
this.container = this.shadowRoot.host; // The host itself scrolls
|
|
315
|
+
this.spacer = this.shadowRoot.querySelector('.spacer');
|
|
316
|
+
this.content = this.shadowRoot.querySelector('.content');
|
|
317
|
+
this.onScroll = this.onScroll.bind(this);
|
|
318
|
+
}
|
|
319
|
+
static get observedAttributes() {
|
|
320
|
+
return ['item-height'];
|
|
321
|
+
}
|
|
322
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
323
|
+
if (name === 'item-height') {
|
|
324
|
+
this._itemHeight = parseInt(newValue, 10) || 50;
|
|
325
|
+
this.renderVisible();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
connectedCallback() {
|
|
329
|
+
// Find the template provided by the user (Support both standard and branded tags)
|
|
330
|
+
const templateTag = this.querySelector('template') || this.querySelector('mu-template');
|
|
331
|
+
if (templateTag) {
|
|
332
|
+
this._template = templateTag.innerHTML;
|
|
333
|
+
}
|
|
334
|
+
this.addEventListener('scroll', this.onScroll);
|
|
335
|
+
// Wait for next frame to get initial height if not set
|
|
336
|
+
requestAnimationFrame(() => this.renderVisible());
|
|
337
|
+
}
|
|
338
|
+
disconnectedCallback() {
|
|
339
|
+
this.removeEventListener('scroll', this.onScroll);
|
|
340
|
+
}
|
|
341
|
+
set items(value) {
|
|
342
|
+
this._items = value;
|
|
343
|
+
this.renderVisible();
|
|
344
|
+
}
|
|
345
|
+
get items() { return this._items; }
|
|
346
|
+
onScroll() {
|
|
347
|
+
requestAnimationFrame(() => this.renderVisible());
|
|
348
|
+
}
|
|
349
|
+
renderVisible() {
|
|
350
|
+
if (!this._items.length)
|
|
351
|
+
return;
|
|
352
|
+
const scrollTop = this.scrollTop;
|
|
353
|
+
const hostHeight = this.clientHeight || 400; // Default fallback if not sized
|
|
354
|
+
const totalHeight = this._items.length * this._itemHeight;
|
|
355
|
+
this.spacer.style.height = `${totalHeight}px`;
|
|
356
|
+
// Windowing Math
|
|
357
|
+
const startIndex = Math.floor(scrollTop / this._itemHeight);
|
|
358
|
+
const buffer = 5;
|
|
359
|
+
const visibleCount = Math.ceil(hostHeight / this._itemHeight);
|
|
360
|
+
const renderStart = Math.max(0, startIndex - buffer);
|
|
361
|
+
const renderEnd = Math.min(this._items.length, startIndex + visibleCount + buffer);
|
|
362
|
+
const startOffset = renderStart * this._itemHeight;
|
|
363
|
+
this.content.style.transform = `translateY(${startOffset}px)`;
|
|
364
|
+
// Render specific slice
|
|
365
|
+
const visibleItems = this._items.slice(renderStart, renderEnd);
|
|
366
|
+
// Simple string replacement template engine for the demo
|
|
367
|
+
// In a real Mulan compilation, this would be an optimized ASTR render
|
|
368
|
+
let html = '';
|
|
369
|
+
visibleItems.forEach((item, index) => {
|
|
370
|
+
const absoluteIndex = renderStart + index;
|
|
371
|
+
// Basic mustache replacement {{ item.prop }}
|
|
372
|
+
let rowHtml = this._template
|
|
373
|
+
.replace(/{{\s*item\s*}}/g, String(item)) // {{ item }}
|
|
374
|
+
.replace(/{{\s*index\s*}}/g, String(absoluteIndex)); // {{ index }}
|
|
375
|
+
// Handle object properties: {{ item.name }}
|
|
376
|
+
if (typeof item === 'object' && item !== null) {
|
|
377
|
+
rowHtml = rowHtml.replace(/{{\s*item\.(\w+)\s*}}/g, (_, prop) => {
|
|
378
|
+
return String(item[prop] || '');
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
html += `<div style="height: ${this._itemHeight}px; overflow: hidden;">${rowHtml}</div>`;
|
|
382
|
+
});
|
|
383
|
+
this.content.innerHTML = html;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
// Register
|
|
387
|
+
if (typeof customElements !== 'undefined' && !customElements.get('mu-infinity')) {
|
|
388
|
+
customElements.define('mu-infinity', MuInfinity);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
|
|
268
392
|
/***/ },
|
|
269
393
|
|
|
270
394
|
/***/ "./src/core/component.ts"
|
|
@@ -1604,6 +1728,33 @@ class MuRouter {
|
|
|
1604
1728
|
}
|
|
1605
1729
|
});
|
|
1606
1730
|
}
|
|
1731
|
+
// [Chronos] Prefetch a route's component code in the background
|
|
1732
|
+
prefetch(path) {
|
|
1733
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1734
|
+
if (this.isServer)
|
|
1735
|
+
return;
|
|
1736
|
+
const { route } = this.matchRoute(path);
|
|
1737
|
+
if (route) {
|
|
1738
|
+
let componentToRender = route.component;
|
|
1739
|
+
// Check if it's a lazy-loaded function that hasn't been resolved yet
|
|
1740
|
+
if (typeof componentToRender === 'function' && !componentToRender.prototype) {
|
|
1741
|
+
// If it's already a resolved module (from previous prefetch), componentToRender might be the result.
|
|
1742
|
+
// But typically in our simple implementation, route.component stays as the function until we replace it.
|
|
1743
|
+
// To avoid double-fetching, we can check if it has a specific flag or property.
|
|
1744
|
+
// For this implementation, we'll just run it and let the browser cache the module request (standard ES Module behavior).
|
|
1745
|
+
try {
|
|
1746
|
+
// console.log(`[Chronos] Prefetching ${path}...`);
|
|
1747
|
+
yield componentToRender();
|
|
1748
|
+
// We don't need to do anything with the result here.
|
|
1749
|
+
// The browser's module cache will handle the speedup when the user actually navigates.
|
|
1750
|
+
}
|
|
1751
|
+
catch (e) {
|
|
1752
|
+
console.warn(`[Chronos] Failed to prefetch ${path}`, e);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1607
1758
|
navigate(path) {
|
|
1608
1759
|
if (this.isServer) {
|
|
1609
1760
|
this.currentPath = path;
|
|
@@ -1615,7 +1766,12 @@ class MuRouter {
|
|
|
1615
1766
|
}
|
|
1616
1767
|
// --- Factory for Easy Usage ---
|
|
1617
1768
|
const createRouter = (options) => {
|
|
1618
|
-
|
|
1769
|
+
// Expose the router instance globally for <mu-link> to access
|
|
1770
|
+
const router = new MuRouter(options.routes, options.rootContainer);
|
|
1771
|
+
if (typeof window !== 'undefined') {
|
|
1772
|
+
window.__MULAN_ROUTER__ = router;
|
|
1773
|
+
}
|
|
1774
|
+
return router;
|
|
1619
1775
|
};
|
|
1620
1776
|
// --- Web Component: <mu-link> ---
|
|
1621
1777
|
// Usage: <mu-link to="/about">About Us</mu-link>
|
|
@@ -1631,6 +1787,26 @@ if (typeof window !== 'undefined' && !customElements.get('mu-link')) {
|
|
|
1631
1787
|
window.location.hash = to;
|
|
1632
1788
|
}
|
|
1633
1789
|
});
|
|
1790
|
+
// [Chronos] Intelligent Pre-fetching
|
|
1791
|
+
this.addEventListener('mouseenter', () => {
|
|
1792
|
+
const to = this.getAttribute('to');
|
|
1793
|
+
if (to) {
|
|
1794
|
+
const router = window.__MULAN_ROUTER__;
|
|
1795
|
+
if (router && typeof router.prefetch === 'function') {
|
|
1796
|
+
router.prefetch(to);
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
// [Chronos] Also prefetch on focus for keyboard users
|
|
1801
|
+
this.addEventListener('focus', () => {
|
|
1802
|
+
const to = this.getAttribute('to');
|
|
1803
|
+
if (to) {
|
|
1804
|
+
const router = window.__MULAN_ROUTER__;
|
|
1805
|
+
if (router && typeof router.prefetch === 'function') {
|
|
1806
|
+
router.prefetch(to);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1634
1810
|
}
|
|
1635
1811
|
connectedCallback() {
|
|
1636
1812
|
this.style.cursor = 'pointer';
|
|
@@ -1841,6 +2017,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1841
2017
|
/* harmony export */ Component: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent),
|
|
1842
2018
|
/* harmony export */ MuBlochSphereElement: () => (/* reexport safe */ _components_bloch_sphere__WEBPACK_IMPORTED_MODULE_10__.MuBlochSphereElement),
|
|
1843
2019
|
/* harmony export */ MuComponent: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent),
|
|
2020
|
+
/* harmony export */ MuInfinity: () => (/* reexport safe */ _components_infinity_list__WEBPACK_IMPORTED_MODULE_11__.MuInfinity),
|
|
1844
2021
|
/* harmony export */ MuRouter: () => (/* reexport safe */ _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter),
|
|
1845
2022
|
/* harmony export */ MuStore: () => (/* reexport safe */ _store_index__WEBPACK_IMPORTED_MODULE_4__.MuStore),
|
|
1846
2023
|
/* harmony export */ Router: () => (/* reexport safe */ _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter),
|
|
@@ -1892,6 +2069,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1892
2069
|
/* harmony import */ var _core_vault__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./core/vault */ "./src/core/vault.ts");
|
|
1893
2070
|
/* harmony import */ var _core_quantum__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./core/quantum */ "./src/core/quantum.ts");
|
|
1894
2071
|
/* harmony import */ var _components_bloch_sphere__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./components/bloch-sphere */ "./src/components/bloch-sphere.ts");
|
|
2072
|
+
/* harmony import */ var _components_infinity_list__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./components/infinity-list */ "./src/components/infinity-list.ts");
|
|
2073
|
+
|
|
1895
2074
|
|
|
1896
2075
|
|
|
1897
2076
|
|
|
@@ -1913,8 +2092,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1913
2092
|
|
|
1914
2093
|
|
|
1915
2094
|
|
|
1916
|
-
|
|
1917
|
-
|
|
2095
|
+
|
|
2096
|
+
const Mulan = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ reactive: _core_reactive__WEBPACK_IMPORTED_MODULE_0__.reactive,
|
|
2097
|
+
effect: _core_reactive__WEBPACK_IMPORTED_MODULE_0__.effect, Component: _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent, defineComponent: _core_component__WEBPACK_IMPORTED_MODULE_1__.defineComponent, Router: _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter, createRouter: _router_index__WEBPACK_IMPORTED_MODULE_3__.createRouter, Store: _store_index__WEBPACK_IMPORTED_MODULE_4__.MuStore, Security: _security_sanitizer__WEBPACK_IMPORTED_MODULE_5__.Security }, _core_hooks__WEBPACK_IMPORTED_MODULE_6__), _core_query__WEBPACK_IMPORTED_MODULE_7__), _core_quantum__WEBPACK_IMPORTED_MODULE_9__), _components_infinity_list__WEBPACK_IMPORTED_MODULE_11__), { render: _core_renderer__WEBPACK_IMPORTED_MODULE_2__.render,
|
|
1918
2098
|
// MULAN INSIGHT: Branded Logging
|
|
1919
2099
|
log: (msg, ...args) => {
|
|
1920
2100
|
console.log(`%c[MulanJS]%c ${msg}`, "color: #ff3e00; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;", "", ...args);
|
|
@@ -1943,7 +2123,9 @@ if (typeof window !== 'undefined') {
|
|
|
1943
2123
|
}
|
|
1944
2124
|
};
|
|
1945
2125
|
}
|
|
1946
|
-
window
|
|
2126
|
+
if (typeof window !== 'undefined') {
|
|
2127
|
+
window.Mulan = Mulan;
|
|
2128
|
+
}
|
|
1947
2129
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Mulan);
|
|
1948
2130
|
|
|
1949
2131
|
})();
|
|
@@ -1951,6 +2133,7 @@ window.Mulan = Mulan;
|
|
|
1951
2133
|
const __webpack_exports__Component = __webpack_exports__.Component;
|
|
1952
2134
|
const __webpack_exports__MuBlochSphereElement = __webpack_exports__.MuBlochSphereElement;
|
|
1953
2135
|
const __webpack_exports__MuComponent = __webpack_exports__.MuComponent;
|
|
2136
|
+
const __webpack_exports__MuInfinity = __webpack_exports__.MuInfinity;
|
|
1954
2137
|
const __webpack_exports__MuRouter = __webpack_exports__.MuRouter;
|
|
1955
2138
|
const __webpack_exports__MuStore = __webpack_exports__.MuStore;
|
|
1956
2139
|
const __webpack_exports__Router = __webpack_exports__.Router;
|
|
@@ -1990,4 +2173,4 @@ const __webpack_exports__sanitize = __webpack_exports__.sanitize;
|
|
|
1990
2173
|
const __webpack_exports__setCurrentInstance = __webpack_exports__.setCurrentInstance;
|
|
1991
2174
|
const __webpack_exports__useMutation = __webpack_exports__.useMutation;
|
|
1992
2175
|
const __webpack_exports__useQuery = __webpack_exports__.useQuery;
|
|
1993
|
-
export { __webpack_exports__Component as Component, __webpack_exports__MuBlochSphereElement as MuBlochSphereElement, __webpack_exports__MuComponent as MuComponent, __webpack_exports__MuRouter as MuRouter, __webpack_exports__MuStore as MuStore, __webpack_exports__Router as Router, __webpack_exports__Security as Security, __webpack_exports__Signal as Signal, __webpack_exports__default as default, __webpack_exports__defineComponent as defineComponent, __webpack_exports__effect as effect, __webpack_exports__getCurrentInstance as getCurrentInstance, __webpack_exports__hydrate as hydrate, __webpack_exports__muEffect as muEffect, __webpack_exports__muEntangle as muEntangle, __webpack_exports__muGate as muGate, __webpack_exports__muGeom as muGeom, __webpack_exports__muMeasure as muMeasure, __webpack_exports__muMemo as muMemo, __webpack_exports__muPulse as muPulse, __webpack_exports__muQubit as muQubit, __webpack_exports__muRegister as muRegister, __webpack_exports__muSearch as muSearch, __webpack_exports__muState as muState, __webpack_exports__muTeleport as muTeleport, __webpack_exports__muVault as muVault, __webpack_exports__onMuDestroy as onMuDestroy, __webpack_exports__onMuIdle as onMuIdle, __webpack_exports__onMuInit as onMuInit, __webpack_exports__onMuMount as onMuMount, __webpack_exports__onMuResume as onMuResume, __webpack_exports__onMuShake as onMuShake, __webpack_exports__onMuVoice as onMuVoice, __webpack_exports__persistent as persistent, __webpack_exports__reactive as reactive, __webpack_exports__ref as ref, __webpack_exports__render as render, __webpack_exports__renderToString as renderToString, __webpack_exports__sanitize as sanitize, __webpack_exports__setCurrentInstance as setCurrentInstance, __webpack_exports__useMutation as useMutation, __webpack_exports__useQuery as useQuery };
|
|
2176
|
+
export { __webpack_exports__Component as Component, __webpack_exports__MuBlochSphereElement as MuBlochSphereElement, __webpack_exports__MuComponent as MuComponent, __webpack_exports__MuInfinity as MuInfinity, __webpack_exports__MuRouter as MuRouter, __webpack_exports__MuStore as MuStore, __webpack_exports__Router as Router, __webpack_exports__Security as Security, __webpack_exports__Signal as Signal, __webpack_exports__default as default, __webpack_exports__defineComponent as defineComponent, __webpack_exports__effect as effect, __webpack_exports__getCurrentInstance as getCurrentInstance, __webpack_exports__hydrate as hydrate, __webpack_exports__muEffect as muEffect, __webpack_exports__muEntangle as muEntangle, __webpack_exports__muGate as muGate, __webpack_exports__muGeom as muGeom, __webpack_exports__muMeasure as muMeasure, __webpack_exports__muMemo as muMemo, __webpack_exports__muPulse as muPulse, __webpack_exports__muQubit as muQubit, __webpack_exports__muRegister as muRegister, __webpack_exports__muSearch as muSearch, __webpack_exports__muState as muState, __webpack_exports__muTeleport as muTeleport, __webpack_exports__muVault as muVault, __webpack_exports__onMuDestroy as onMuDestroy, __webpack_exports__onMuIdle as onMuIdle, __webpack_exports__onMuInit as onMuInit, __webpack_exports__onMuMount as onMuMount, __webpack_exports__onMuResume as onMuResume, __webpack_exports__onMuShake as onMuShake, __webpack_exports__onMuVoice as onMuVoice, __webpack_exports__persistent as persistent, __webpack_exports__reactive as reactive, __webpack_exports__ref as ref, __webpack_exports__render as render, __webpack_exports__renderToString as renderToString, __webpack_exports__sanitize as sanitize, __webpack_exports__setCurrentInstance as setCurrentInstance, __webpack_exports__useMutation as useMutation, __webpack_exports__useQuery as useQuery };
|
package/dist/mulan.js
CHANGED
|
@@ -30,6 +30,16 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
30
30
|
|
|
31
31
|
/***/ },
|
|
32
32
|
|
|
33
|
+
/***/ "./src/components/infinity-list.ts"
|
|
34
|
+
/*!*****************************************!*\
|
|
35
|
+
!*** ./src/components/infinity-list.ts ***!
|
|
36
|
+
\*****************************************/
|
|
37
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
38
|
+
|
|
39
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MuInfinity: () => (/* binding */ MuInfinity)\n/* harmony export */ });\nclass MuInfinity extends HTMLElement {\n constructor() {\n super();\n this._items = [];\n this._itemHeight = 50; // Default height\n this._template = '';\n this.attachShadow({ mode: 'open' });\n // Structure:\n // :host { overflow-y: auto; display: block; height: 100%; }\n // .spacer { height: totalHeight; position: relative; }\n // .content { position: absolute; top: padding; width: 100%; }\n this.shadowRoot.innerHTML = `\r\n <style>\r\n :host {\r\n display: block;\r\n overflow-y: auto;\r\n height: 100%;\r\n position: relative;\r\n }\r\n .spacer {\r\n position: relative;\r\n width: 100%;\r\n }\r\n .content {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n }\r\n </style>\r\n <div class=\"spacer\">\r\n <div class=\"content\"></div>\r\n </div>\r\n `;\n this.container = this.shadowRoot.host; // The host itself scrolls\n this.spacer = this.shadowRoot.querySelector('.spacer');\n this.content = this.shadowRoot.querySelector('.content');\n this.onScroll = this.onScroll.bind(this);\n }\n static get observedAttributes() {\n return ['item-height'];\n }\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'item-height') {\n this._itemHeight = parseInt(newValue, 10) || 50;\n this.renderVisible();\n }\n }\n connectedCallback() {\n // Find the template provided by the user (Support both standard and branded tags)\n const templateTag = this.querySelector('template') || this.querySelector('mu-template');\n if (templateTag) {\n this._template = templateTag.innerHTML;\n }\n this.addEventListener('scroll', this.onScroll);\n // Wait for next frame to get initial height if not set\n requestAnimationFrame(() => this.renderVisible());\n }\n disconnectedCallback() {\n this.removeEventListener('scroll', this.onScroll);\n }\n set items(value) {\n this._items = value;\n this.renderVisible();\n }\n get items() { return this._items; }\n onScroll() {\n requestAnimationFrame(() => this.renderVisible());\n }\n renderVisible() {\n if (!this._items.length)\n return;\n const scrollTop = this.scrollTop;\n const hostHeight = this.clientHeight || 400; // Default fallback if not sized\n const totalHeight = this._items.length * this._itemHeight;\n this.spacer.style.height = `${totalHeight}px`;\n // Windowing Math\n const startIndex = Math.floor(scrollTop / this._itemHeight);\n const buffer = 5;\n const visibleCount = Math.ceil(hostHeight / this._itemHeight);\n const renderStart = Math.max(0, startIndex - buffer);\n const renderEnd = Math.min(this._items.length, startIndex + visibleCount + buffer);\n const startOffset = renderStart * this._itemHeight;\n this.content.style.transform = `translateY(${startOffset}px)`;\n // Render specific slice\n const visibleItems = this._items.slice(renderStart, renderEnd);\n // Simple string replacement template engine for the demo\n // In a real Mulan compilation, this would be an optimized ASTR render\n let html = '';\n visibleItems.forEach((item, index) => {\n const absoluteIndex = renderStart + index;\n // Basic mustache replacement {{ item.prop }}\n let rowHtml = this._template\n .replace(/{{\\s*item\\s*}}/g, String(item)) // {{ item }}\n .replace(/{{\\s*index\\s*}}/g, String(absoluteIndex)); // {{ index }}\n // Handle object properties: {{ item.name }}\n if (typeof item === 'object' && item !== null) {\n rowHtml = rowHtml.replace(/{{\\s*item\\.(\\w+)\\s*}}/g, (_, prop) => {\n return String(item[prop] || '');\n });\n }\n html += `<div style=\"height: ${this._itemHeight}px; overflow: hidden;\">${rowHtml}</div>`;\n });\n this.content.innerHTML = html;\n }\n}\n// Register\nif (typeof customElements !== 'undefined' && !customElements.get('mu-infinity')) {\n customElements.define('mu-infinity', MuInfinity);\n}\n\n\n//# sourceURL=webpack://Mulan/./src/components/infinity-list.ts?\n}");
|
|
40
|
+
|
|
41
|
+
/***/ },
|
|
42
|
+
|
|
33
43
|
/***/ "./src/core/component.ts"
|
|
34
44
|
/*!*******************************!*\
|
|
35
45
|
!*** ./src/core/component.ts ***!
|
|
@@ -106,7 +116,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
106
116
|
\**********************/
|
|
107
117
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
108
118
|
|
|
109
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Component: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent),\n/* harmony export */ MuBlochSphereElement: () => (/* reexport safe */ _components_bloch_sphere__WEBPACK_IMPORTED_MODULE_10__.MuBlochSphereElement),\n/* harmony export */ MuComponent: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent),\n/* harmony export */ MuRouter: () => (/* reexport safe */ _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter),\n/* harmony export */ MuStore: () => (/* reexport safe */ _store_index__WEBPACK_IMPORTED_MODULE_4__.MuStore),\n/* harmony export */ Router: () => (/* reexport safe */ _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter),\n/* harmony export */ Security: () => (/* reexport safe */ _security_sanitizer__WEBPACK_IMPORTED_MODULE_5__.Security),\n/* harmony export */ Signal: () => (/* reexport safe */ _core_reactive__WEBPACK_IMPORTED_MODULE_0__.Signal),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ defineComponent: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.defineComponent),\n/* harmony export */ effect: () => (/* reexport safe */ _core_reactive__WEBPACK_IMPORTED_MODULE_0__.effect),\n/* harmony export */ getCurrentInstance: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.getCurrentInstance),\n/* harmony export */ hydrate: () => (/* reexport safe */ _core_renderer__WEBPACK_IMPORTED_MODULE_2__.hydrate),\n/* harmony export */ muEffect: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muEffect),\n/* harmony export */ muEntangle: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muEntangle),\n/* harmony export */ muGate: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muGate),\n/* harmony export */ muGeom: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muGeom),\n/* harmony export */ muMeasure: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muMeasure),\n/* harmony export */ muMemo: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muMemo),\n/* harmony export */ muPulse: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muPulse),\n/* harmony export */ muQubit: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muQubit),\n/* harmony export */ muRegister: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muRegister),\n/* harmony export */ muSearch: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muSearch),\n/* harmony export */ muState: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muState),\n/* harmony export */ muTeleport: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muTeleport),\n/* harmony export */ muVault: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muVault),\n/* harmony export */ onMuDestroy: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuDestroy),\n/* harmony export */ onMuIdle: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuIdle),\n/* harmony export */ onMuInit: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuInit),\n/* harmony export */ onMuMount: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuMount),\n/* harmony export */ onMuResume: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuResume),\n/* harmony export */ onMuShake: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuShake),\n/* harmony export */ onMuVoice: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuVoice),\n/* harmony export */ persistent: () => (/* reexport safe */ _core_vault__WEBPACK_IMPORTED_MODULE_8__.persistent),\n/* harmony export */ reactive: () => (/* reexport safe */ _core_reactive__WEBPACK_IMPORTED_MODULE_0__.reactive),\n/* harmony export */ ref: () => (/* reexport safe */ _core_reactive__WEBPACK_IMPORTED_MODULE_0__.ref),\n/* harmony export */ render: () => (/* reexport safe */ _core_renderer__WEBPACK_IMPORTED_MODULE_2__.render),\n/* harmony export */ renderToString: () => (/* reexport safe */ _core_renderer__WEBPACK_IMPORTED_MODULE_2__.renderToString),\n/* harmony export */ sanitize: () => (/* reexport safe */ _core_renderer__WEBPACK_IMPORTED_MODULE_2__.sanitize),\n/* harmony export */ setCurrentInstance: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.setCurrentInstance),\n/* harmony export */ useMutation: () => (/* reexport safe */ _core_query__WEBPACK_IMPORTED_MODULE_7__.useMutation),\n/* harmony export */ useQuery: () => (/* reexport safe */ _core_query__WEBPACK_IMPORTED_MODULE_7__.useQuery)\n/* harmony export */ });\n/* harmony import */ var _core_reactive__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core/reactive */ \"./src/core/reactive.ts\");\n/* harmony import */ var _core_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/component */ \"./src/core/component.ts\");\n/* harmony import */ var _core_renderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./core/renderer */ \"./src/core/renderer.ts\");\n/* harmony import */ var _router_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./router/index */ \"./src/router/index.ts\");\n/* harmony import */ var _store_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./store/index */ \"./src/store/index.ts\");\n/* harmony import */ var _security_sanitizer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./security/sanitizer */ \"./src/security/sanitizer.ts\");\n/* harmony import */ var _core_hooks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./core/hooks */ \"./src/core/hooks.ts\");\n/* harmony import */ var _core_query__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./core/query */ \"./src/core/query.ts\");\n/* harmony import */ var _core_vault__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./core/vault */ \"./src/core/vault.ts\");\n/* harmony import */ var _core_quantum__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./core/quantum */ \"./src/core/quantum.ts\");\n/* harmony import */ var _components_bloch_sphere__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./components/bloch-sphere */ \"./src/components/bloch-sphere.ts\");\n\n\n\n\n\n\n\n\n\n\n\n// Global Mulan Object for non-module usage\n\n\n\n\n\n\n\n\n\nconst Mulan = Object.assign(Object.assign(Object.assign(Object.assign({ reactive: _core_reactive__WEBPACK_IMPORTED_MODULE_0__.reactive,\n effect: _core_reactive__WEBPACK_IMPORTED_MODULE_0__.effect, Component: _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent, defineComponent: _core_component__WEBPACK_IMPORTED_MODULE_1__.defineComponent, Router: _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter, Store: _store_index__WEBPACK_IMPORTED_MODULE_4__.MuStore, Security: _security_sanitizer__WEBPACK_IMPORTED_MODULE_5__.Security }, _core_hooks__WEBPACK_IMPORTED_MODULE_6__), _core_query__WEBPACK_IMPORTED_MODULE_7__), _core_quantum__WEBPACK_IMPORTED_MODULE_9__), { render: _core_renderer__WEBPACK_IMPORTED_MODULE_2__.render, \n // MULAN INSIGHT: Branded Logging\n log: (msg, ...args) => {\n console.log(`%c[MulanJS]%c ${msg}`, \"color: #ff3e00; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;\", \"\", ...args);\n }, warn: (msg, ...args) => {\n console.warn(`%c[MulanJS]%c ${msg}`, \"color: #ffcc00; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;\", \"\", ...args);\n }, error: (msg, ...args) => {\n console.error(`%c[MulanJS]%c ${msg}`, \"color: #ff0000; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;\", \"\", ...args);\n } });\n// Security: Freeze the object to prevent runtime tampering\nObject.freeze(Mulan);\nObject.freeze(Mulan.Security);\n// MULAN INSIGHT: Initialize Global Registry\nif (typeof window !== 'undefined') {\n window.__MULAN_INSIGHT__ = window.__MULAN_INSIGHT__ || { components: new Map() };\n // MULAN INSIGHT: HMR Support\n window.__MULAN_REFRESH__ = () => {\n var _a;\n const components = (_a = window.__MULAN_INSIGHT__) === null || _a === void 0 ? void 0 : _a.components;\n if (components) {\n components.forEach((comp) => {\n if (comp && typeof comp.update === 'function') {\n // Force refresh\n comp.update();\n }\n });\n }\n };\n}\
|
|
119
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Component: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent),\n/* harmony export */ MuBlochSphereElement: () => (/* reexport safe */ _components_bloch_sphere__WEBPACK_IMPORTED_MODULE_10__.MuBlochSphereElement),\n/* harmony export */ MuComponent: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent),\n/* harmony export */ MuInfinity: () => (/* reexport safe */ _components_infinity_list__WEBPACK_IMPORTED_MODULE_11__.MuInfinity),\n/* harmony export */ MuRouter: () => (/* reexport safe */ _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter),\n/* harmony export */ MuStore: () => (/* reexport safe */ _store_index__WEBPACK_IMPORTED_MODULE_4__.MuStore),\n/* harmony export */ Router: () => (/* reexport safe */ _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter),\n/* harmony export */ Security: () => (/* reexport safe */ _security_sanitizer__WEBPACK_IMPORTED_MODULE_5__.Security),\n/* harmony export */ Signal: () => (/* reexport safe */ _core_reactive__WEBPACK_IMPORTED_MODULE_0__.Signal),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ defineComponent: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.defineComponent),\n/* harmony export */ effect: () => (/* reexport safe */ _core_reactive__WEBPACK_IMPORTED_MODULE_0__.effect),\n/* harmony export */ getCurrentInstance: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.getCurrentInstance),\n/* harmony export */ hydrate: () => (/* reexport safe */ _core_renderer__WEBPACK_IMPORTED_MODULE_2__.hydrate),\n/* harmony export */ muEffect: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muEffect),\n/* harmony export */ muEntangle: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muEntangle),\n/* harmony export */ muGate: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muGate),\n/* harmony export */ muGeom: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muGeom),\n/* harmony export */ muMeasure: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muMeasure),\n/* harmony export */ muMemo: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muMemo),\n/* harmony export */ muPulse: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muPulse),\n/* harmony export */ muQubit: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muQubit),\n/* harmony export */ muRegister: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muRegister),\n/* harmony export */ muSearch: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muSearch),\n/* harmony export */ muState: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muState),\n/* harmony export */ muTeleport: () => (/* reexport safe */ _core_quantum__WEBPACK_IMPORTED_MODULE_9__.muTeleport),\n/* harmony export */ muVault: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.muVault),\n/* harmony export */ onMuDestroy: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuDestroy),\n/* harmony export */ onMuIdle: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuIdle),\n/* harmony export */ onMuInit: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuInit),\n/* harmony export */ onMuMount: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuMount),\n/* harmony export */ onMuResume: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuResume),\n/* harmony export */ onMuShake: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuShake),\n/* harmony export */ onMuVoice: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.onMuVoice),\n/* harmony export */ persistent: () => (/* reexport safe */ _core_vault__WEBPACK_IMPORTED_MODULE_8__.persistent),\n/* harmony export */ reactive: () => (/* reexport safe */ _core_reactive__WEBPACK_IMPORTED_MODULE_0__.reactive),\n/* harmony export */ ref: () => (/* reexport safe */ _core_reactive__WEBPACK_IMPORTED_MODULE_0__.ref),\n/* harmony export */ render: () => (/* reexport safe */ _core_renderer__WEBPACK_IMPORTED_MODULE_2__.render),\n/* harmony export */ renderToString: () => (/* reexport safe */ _core_renderer__WEBPACK_IMPORTED_MODULE_2__.renderToString),\n/* harmony export */ sanitize: () => (/* reexport safe */ _core_renderer__WEBPACK_IMPORTED_MODULE_2__.sanitize),\n/* harmony export */ setCurrentInstance: () => (/* reexport safe */ _core_hooks__WEBPACK_IMPORTED_MODULE_6__.setCurrentInstance),\n/* harmony export */ useMutation: () => (/* reexport safe */ _core_query__WEBPACK_IMPORTED_MODULE_7__.useMutation),\n/* harmony export */ useQuery: () => (/* reexport safe */ _core_query__WEBPACK_IMPORTED_MODULE_7__.useQuery)\n/* harmony export */ });\n/* harmony import */ var _core_reactive__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core/reactive */ \"./src/core/reactive.ts\");\n/* harmony import */ var _core_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/component */ \"./src/core/component.ts\");\n/* harmony import */ var _core_renderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./core/renderer */ \"./src/core/renderer.ts\");\n/* harmony import */ var _router_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./router/index */ \"./src/router/index.ts\");\n/* harmony import */ var _store_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./store/index */ \"./src/store/index.ts\");\n/* harmony import */ var _security_sanitizer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./security/sanitizer */ \"./src/security/sanitizer.ts\");\n/* harmony import */ var _core_hooks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./core/hooks */ \"./src/core/hooks.ts\");\n/* harmony import */ var _core_query__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./core/query */ \"./src/core/query.ts\");\n/* harmony import */ var _core_vault__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./core/vault */ \"./src/core/vault.ts\");\n/* harmony import */ var _core_quantum__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./core/quantum */ \"./src/core/quantum.ts\");\n/* harmony import */ var _components_bloch_sphere__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./components/bloch-sphere */ \"./src/components/bloch-sphere.ts\");\n/* harmony import */ var _components_infinity_list__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./components/infinity-list */ \"./src/components/infinity-list.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n// Global Mulan Object for non-module usage\n\n\n\n\n\n\n\n\n\n\nconst Mulan = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ reactive: _core_reactive__WEBPACK_IMPORTED_MODULE_0__.reactive,\n effect: _core_reactive__WEBPACK_IMPORTED_MODULE_0__.effect, Component: _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent, defineComponent: _core_component__WEBPACK_IMPORTED_MODULE_1__.defineComponent, Router: _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter, createRouter: _router_index__WEBPACK_IMPORTED_MODULE_3__.createRouter, Store: _store_index__WEBPACK_IMPORTED_MODULE_4__.MuStore, Security: _security_sanitizer__WEBPACK_IMPORTED_MODULE_5__.Security }, _core_hooks__WEBPACK_IMPORTED_MODULE_6__), _core_query__WEBPACK_IMPORTED_MODULE_7__), _core_quantum__WEBPACK_IMPORTED_MODULE_9__), _components_infinity_list__WEBPACK_IMPORTED_MODULE_11__), { render: _core_renderer__WEBPACK_IMPORTED_MODULE_2__.render, \n // MULAN INSIGHT: Branded Logging\n log: (msg, ...args) => {\n console.log(`%c[MulanJS]%c ${msg}`, \"color: #ff3e00; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;\", \"\", ...args);\n }, warn: (msg, ...args) => {\n console.warn(`%c[MulanJS]%c ${msg}`, \"color: #ffcc00; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;\", \"\", ...args);\n }, error: (msg, ...args) => {\n console.error(`%c[MulanJS]%c ${msg}`, \"color: #ff0000; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;\", \"\", ...args);\n } });\n// Security: Freeze the object to prevent runtime tampering\nObject.freeze(Mulan);\nObject.freeze(Mulan.Security);\n// MULAN INSIGHT: Initialize Global Registry\nif (typeof window !== 'undefined') {\n window.__MULAN_INSIGHT__ = window.__MULAN_INSIGHT__ || { components: new Map() };\n // MULAN INSIGHT: HMR Support\n window.__MULAN_REFRESH__ = () => {\n var _a;\n const components = (_a = window.__MULAN_INSIGHT__) === null || _a === void 0 ? void 0 : _a.components;\n if (components) {\n components.forEach((comp) => {\n if (comp && typeof comp.update === 'function') {\n // Force refresh\n comp.update();\n }\n });\n }\n };\n}\nif (typeof window !== 'undefined') {\n window.Mulan = Mulan;\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Mulan);\n\n\n//# sourceURL=webpack://Mulan/./src/index.ts?\n}");
|
|
110
120
|
|
|
111
121
|
/***/ },
|
|
112
122
|
|
|
@@ -116,7 +126,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
116
126
|
\*****************************/
|
|
117
127
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
118
128
|
|
|
119
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MuRouter: () => (/* binding */ MuRouter),\n/* harmony export */ createRouter: () => (/* binding */ createRouter)\n/* harmony export */ });\n/* harmony import */ var _core_renderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/renderer */ \"./src/core/renderer.ts\");\n/* harmony import */ var _security_sanitizer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../security/sanitizer */ \"./src/security/sanitizer.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nclass MuRouter {\n constructor(routes, rootContainer = null) {\n this.currentPath = '';\n this.currentComponent = null;\n this.lastRouteId = 0;\n this.routes = routes;\n this.rootContainer = rootContainer;\n this.isServer = rootContainer === null; // If no container, assume server/headless mode\n if (!this.isServer) {\n window.addEventListener('hashchange', this.handleRoute.bind(this));\n this.handleRoute(); // Initial load\n }\n }\n // SSR Method: Simulate a route visit on the server\n serverLookup(path) {\n return __awaiter(this, void 0, void 0, function* () {\n this.currentPath = path;\n const { route, params } = this.matchRoute(path);\n if (route) {\n // Run guards/resolvers here if needed\n let componentToRender = route.component;\n // Support Lazy Loading\n if (typeof componentToRender === 'function' && !componentToRender.prototype) {\n const module = yield componentToRender();\n componentToRender = module.default || module;\n }\n if (typeof componentToRender === 'function') {\n // Class component SSR\n // We need a dummy container for the component to \"render\" into its own buffer\n // For simplicity in this string-based framework, we mock the container\n const mockContainer = { innerHTML: '' };\n const instance = new componentToRender(mockContainer);\n if (instance.setParams)\n instance.setParams(params);\n // Manually trigger mount logic without DOM effects if possible, or just template()\n // Ideally, we just want the template string.\n return instance.template();\n }\n else {\n return componentToRender;\n }\n }\n return '<!-- 404 -->';\n });\n }\n matchRoute(hash) {\n // Simple exact match first\n let route = this.routes.find((r) => r.path === hash);\n if (route)\n return { route, params: {} };\n // Regex match for params e.g. /user/:id\n for (const r of this.routes) {\n const paramNames = [];\n const regexPath = r.path.replace(/:([^/]+)/g, (_, key) => {\n paramNames.push(key);\n return '([^/]+)';\n });\n const match = new RegExp(`^${regexPath}$`).exec(hash);\n if (match) {\n const params = {};\n paramNames.forEach((name, i) => {\n // SECURE: Automatically sanitize all route parameters\n params[name] = _security_sanitizer__WEBPACK_IMPORTED_MODULE_1__.Security.sanitize(match[i + 1]);\n });\n return { route: r, params };\n }\n }\n return { route: undefined, params: {} };\n }\n handleRoute() {\n return __awaiter(this, void 0, void 0, function* () {\n if (this.isServer)\n return;\n const currentRouteId = ++this.lastRouteId;\n const hash = window.location.hash.slice(1) || '/';\n const { route, params } = this.matchRoute(hash);\n // Security Check: Validate URL to prevent malicious hash injection\n if (hash !== '/' && !_security_sanitizer__WEBPACK_IMPORTED_MODULE_1__.Security.validateUrl('http://dummy.com' + hash)) {\n console.error(\"Security Alert: Malformed URL detected.\");\n return;\n }\n // Navigation Guard (Middleware)\n if (route === null || route === void 0 ? void 0 : route.beforeEnter) {\n yield new Promise((resolve) => {\n route.beforeEnter(hash, this.currentPath, (allow) => {\n if (allow)\n resolve();\n else {\n console.warn(`Navigation to ${hash} blocked by guard.`);\n // Ideally redirect or stay, here we just stop processing\n throw new Error('Navigation Blocked');\n }\n });\n }).catch(() => { return; }); // Stop execution if blocked\n }\n this.currentPath = hash;\n if (route) {\n if (route.title) {\n document.title = route.title;\n }\n else if (route.meta && route.meta.title) {\n // Fallback to meta.title if used\n document.title = route.meta.title;\n }\n if (this.rootContainer) {\n // Mulan Cycle: Destroy previous component before rendering new one\n if (this.currentComponent) {\n console.log(`[Router] Navigation from ${this.currentPath} to ${hash}. Destroying previous component.`);\n if (this.currentComponent.onDestroy) {\n this.currentComponent.onDestroy();\n }\n }\n this.rootContainer.innerHTML = ''; // Clear previous content\n }\n let componentToRender = route.component;\n // Support Lazy Loading\n if (typeof componentToRender === 'function' && !componentToRender.prototype) {\n try {\n const module = yield componentToRender();\n if (currentRouteId !== this.lastRouteId) {\n console.log(`[Router] Navigation to ${hash} interrupted by newer navigation. Abandoning.`);\n return;\n }\n componentToRender = module.default || module;\n }\n catch (e) {\n console.error(\"Failed to lazy load component\", e);\n return;\n }\n }\n if (typeof componentToRender === 'function') {\n // It's a class component\n if (this.rootContainer) {\n const instance = new componentToRender(this.rootContainer);\n this.currentComponent = instance;\n // Inject params if the component accepts them\n if (instance.setParams) {\n instance.setParams(params);\n }\n instance.mount();\n }\n }\n else if (typeof componentToRender === 'object' && componentToRender.template) {\n // Object Component (Simple SFC without script or Options API)\n const html = componentToRender.template();\n if (this.rootContainer)\n (0,_core_renderer__WEBPACK_IMPORTED_MODULE_0__.render)(html, this.rootContainer);\n this.currentComponent = null;\n }\n else {\n // Simple HTML string/template\n if (this.rootContainer)\n (0,_core_renderer__WEBPACK_IMPORTED_MODULE_0__.render)(componentToRender, this.rootContainer);\n this.currentComponent = null; // String templates don't have lifecycle instances\n }\n }\n else {\n if (this.rootContainer)\n (0,_core_renderer__WEBPACK_IMPORTED_MODULE_0__.render)('<div style=\"text-align:center; padding:50px;\"><h1>404</h1><p>Page Not Found</p></div>', this.rootContainer);\n }\n });\n }\n navigate(path) {\n if (this.isServer) {\n this.currentPath = path;\n }\n else {\n window.location.hash = path;\n }\n }\n}\n// --- Factory for Easy Usage ---\nconst createRouter = (options) => {\n return new MuRouter(options.routes, options.rootContainer);\n};\n// --- Web Component: <mu-link> ---\n// Usage: <mu-link to=\"/about\">About Us</mu-link>\nif (typeof window !== 'undefined' && !customElements.get('mu-link')) {\n class MuLink extends HTMLElement {\n constructor() {\n super();\n this.addEventListener('click', (e) => {\n e.preventDefault();\n const to = this.getAttribute('to');\n if (to) {\n // Update Hash for SPA Navigation\n window.location.hash = to;\n }\n });\n }\n connectedCallback() {\n this.style.cursor = 'pointer';\n this.style.color = 'var(--primary, #9C27B0)'; // Default to brand color if available\n this.style.textDecoration = 'none';\n }\n static get observedAttributes() { return ['to']; }\n }\n customElements.define('mu-link', MuLink);\n}\n\n\n//# sourceURL=webpack://Mulan/./src/router/index.ts?\n}");
|
|
129
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MuRouter: () => (/* binding */ MuRouter),\n/* harmony export */ createRouter: () => (/* binding */ createRouter)\n/* harmony export */ });\n/* harmony import */ var _core_renderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/renderer */ \"./src/core/renderer.ts\");\n/* harmony import */ var _security_sanitizer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../security/sanitizer */ \"./src/security/sanitizer.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nclass MuRouter {\n constructor(routes, rootContainer = null) {\n this.currentPath = '';\n this.currentComponent = null;\n this.lastRouteId = 0;\n this.routes = routes;\n this.rootContainer = rootContainer;\n this.isServer = rootContainer === null; // If no container, assume server/headless mode\n if (!this.isServer) {\n window.addEventListener('hashchange', this.handleRoute.bind(this));\n this.handleRoute(); // Initial load\n }\n }\n // SSR Method: Simulate a route visit on the server\n serverLookup(path) {\n return __awaiter(this, void 0, void 0, function* () {\n this.currentPath = path;\n const { route, params } = this.matchRoute(path);\n if (route) {\n // Run guards/resolvers here if needed\n let componentToRender = route.component;\n // Support Lazy Loading\n if (typeof componentToRender === 'function' && !componentToRender.prototype) {\n const module = yield componentToRender();\n componentToRender = module.default || module;\n }\n if (typeof componentToRender === 'function') {\n // Class component SSR\n // We need a dummy container for the component to \"render\" into its own buffer\n // For simplicity in this string-based framework, we mock the container\n const mockContainer = { innerHTML: '' };\n const instance = new componentToRender(mockContainer);\n if (instance.setParams)\n instance.setParams(params);\n // Manually trigger mount logic without DOM effects if possible, or just template()\n // Ideally, we just want the template string.\n return instance.template();\n }\n else {\n return componentToRender;\n }\n }\n return '<!-- 404 -->';\n });\n }\n matchRoute(hash) {\n // Simple exact match first\n let route = this.routes.find((r) => r.path === hash);\n if (route)\n return { route, params: {} };\n // Regex match for params e.g. /user/:id\n for (const r of this.routes) {\n const paramNames = [];\n const regexPath = r.path.replace(/:([^/]+)/g, (_, key) => {\n paramNames.push(key);\n return '([^/]+)';\n });\n const match = new RegExp(`^${regexPath}$`).exec(hash);\n if (match) {\n const params = {};\n paramNames.forEach((name, i) => {\n // SECURE: Automatically sanitize all route parameters\n params[name] = _security_sanitizer__WEBPACK_IMPORTED_MODULE_1__.Security.sanitize(match[i + 1]);\n });\n return { route: r, params };\n }\n }\n return { route: undefined, params: {} };\n }\n handleRoute() {\n return __awaiter(this, void 0, void 0, function* () {\n if (this.isServer)\n return;\n const currentRouteId = ++this.lastRouteId;\n const hash = window.location.hash.slice(1) || '/';\n const { route, params } = this.matchRoute(hash);\n // Security Check: Validate URL to prevent malicious hash injection\n if (hash !== '/' && !_security_sanitizer__WEBPACK_IMPORTED_MODULE_1__.Security.validateUrl('http://dummy.com' + hash)) {\n console.error(\"Security Alert: Malformed URL detected.\");\n return;\n }\n // Navigation Guard (Middleware)\n if (route === null || route === void 0 ? void 0 : route.beforeEnter) {\n yield new Promise((resolve) => {\n route.beforeEnter(hash, this.currentPath, (allow) => {\n if (allow)\n resolve();\n else {\n console.warn(`Navigation to ${hash} blocked by guard.`);\n // Ideally redirect or stay, here we just stop processing\n throw new Error('Navigation Blocked');\n }\n });\n }).catch(() => { return; }); // Stop execution if blocked\n }\n this.currentPath = hash;\n if (route) {\n if (route.title) {\n document.title = route.title;\n }\n else if (route.meta && route.meta.title) {\n // Fallback to meta.title if used\n document.title = route.meta.title;\n }\n if (this.rootContainer) {\n // Mulan Cycle: Destroy previous component before rendering new one\n if (this.currentComponent) {\n console.log(`[Router] Navigation from ${this.currentPath} to ${hash}. Destroying previous component.`);\n if (this.currentComponent.onDestroy) {\n this.currentComponent.onDestroy();\n }\n }\n this.rootContainer.innerHTML = ''; // Clear previous content\n }\n let componentToRender = route.component;\n // Support Lazy Loading\n if (typeof componentToRender === 'function' && !componentToRender.prototype) {\n try {\n const module = yield componentToRender();\n if (currentRouteId !== this.lastRouteId) {\n console.log(`[Router] Navigation to ${hash} interrupted by newer navigation. Abandoning.`);\n return;\n }\n componentToRender = module.default || module;\n }\n catch (e) {\n console.error(\"Failed to lazy load component\", e);\n return;\n }\n }\n if (typeof componentToRender === 'function') {\n // It's a class component\n if (this.rootContainer) {\n const instance = new componentToRender(this.rootContainer);\n this.currentComponent = instance;\n // Inject params if the component accepts them\n if (instance.setParams) {\n instance.setParams(params);\n }\n instance.mount();\n }\n }\n else if (typeof componentToRender === 'object' && componentToRender.template) {\n // Object Component (Simple SFC without script or Options API)\n const html = componentToRender.template();\n if (this.rootContainer)\n (0,_core_renderer__WEBPACK_IMPORTED_MODULE_0__.render)(html, this.rootContainer);\n this.currentComponent = null;\n }\n else {\n // Simple HTML string/template\n if (this.rootContainer)\n (0,_core_renderer__WEBPACK_IMPORTED_MODULE_0__.render)(componentToRender, this.rootContainer);\n this.currentComponent = null; // String templates don't have lifecycle instances\n }\n }\n else {\n if (this.rootContainer)\n (0,_core_renderer__WEBPACK_IMPORTED_MODULE_0__.render)('<div style=\"text-align:center; padding:50px;\"><h1>404</h1><p>Page Not Found</p></div>', this.rootContainer);\n }\n });\n }\n // [Chronos] Prefetch a route's component code in the background\n prefetch(path) {\n return __awaiter(this, void 0, void 0, function* () {\n if (this.isServer)\n return;\n const { route } = this.matchRoute(path);\n if (route) {\n let componentToRender = route.component;\n // Check if it's a lazy-loaded function that hasn't been resolved yet\n if (typeof componentToRender === 'function' && !componentToRender.prototype) {\n // If it's already a resolved module (from previous prefetch), componentToRender might be the result.\n // But typically in our simple implementation, route.component stays as the function until we replace it.\n // To avoid double-fetching, we can check if it has a specific flag or property. \n // For this implementation, we'll just run it and let the browser cache the module request (standard ES Module behavior).\n try {\n // console.log(`[Chronos] Prefetching ${path}...`);\n yield componentToRender();\n // We don't need to do anything with the result here. \n // The browser's module cache will handle the speedup when the user actually navigates.\n }\n catch (e) {\n console.warn(`[Chronos] Failed to prefetch ${path}`, e);\n }\n }\n }\n });\n }\n navigate(path) {\n if (this.isServer) {\n this.currentPath = path;\n }\n else {\n window.location.hash = path;\n }\n }\n}\n// --- Factory for Easy Usage ---\nconst createRouter = (options) => {\n // Expose the router instance globally for <mu-link> to access\n const router = new MuRouter(options.routes, options.rootContainer);\n if (typeof window !== 'undefined') {\n window.__MULAN_ROUTER__ = router;\n }\n return router;\n};\n// --- Web Component: <mu-link> ---\n// Usage: <mu-link to=\"/about\">About Us</mu-link>\nif (typeof window !== 'undefined' && !customElements.get('mu-link')) {\n class MuLink extends HTMLElement {\n constructor() {\n super();\n this.addEventListener('click', (e) => {\n e.preventDefault();\n const to = this.getAttribute('to');\n if (to) {\n // Update Hash for SPA Navigation\n window.location.hash = to;\n }\n });\n // [Chronos] Intelligent Pre-fetching\n this.addEventListener('mouseenter', () => {\n const to = this.getAttribute('to');\n if (to) {\n const router = window.__MULAN_ROUTER__;\n if (router && typeof router.prefetch === 'function') {\n router.prefetch(to);\n }\n }\n });\n // [Chronos] Also prefetch on focus for keyboard users\n this.addEventListener('focus', () => {\n const to = this.getAttribute('to');\n if (to) {\n const router = window.__MULAN_ROUTER__;\n if (router && typeof router.prefetch === 'function') {\n router.prefetch(to);\n }\n }\n });\n }\n connectedCallback() {\n this.style.cursor = 'pointer';\n this.style.color = 'var(--primary, #9C27B0)'; // Default to brand color if available\n this.style.textDecoration = 'none';\n }\n static get observedAttributes() { return ['to']; }\n }\n customElements.define('mu-link', MuLink);\n}\n\n\n//# sourceURL=webpack://Mulan/./src/router/index.ts?\n}");
|
|
120
130
|
|
|
121
131
|
/***/ },
|
|
122
132
|
|
package/dist/router/index.js
CHANGED
|
@@ -171,6 +171,33 @@ export class MuRouter {
|
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
+
// [Chronos] Prefetch a route's component code in the background
|
|
175
|
+
prefetch(path) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
if (this.isServer)
|
|
178
|
+
return;
|
|
179
|
+
const { route } = this.matchRoute(path);
|
|
180
|
+
if (route) {
|
|
181
|
+
let componentToRender = route.component;
|
|
182
|
+
// Check if it's a lazy-loaded function that hasn't been resolved yet
|
|
183
|
+
if (typeof componentToRender === 'function' && !componentToRender.prototype) {
|
|
184
|
+
// If it's already a resolved module (from previous prefetch), componentToRender might be the result.
|
|
185
|
+
// But typically in our simple implementation, route.component stays as the function until we replace it.
|
|
186
|
+
// To avoid double-fetching, we can check if it has a specific flag or property.
|
|
187
|
+
// For this implementation, we'll just run it and let the browser cache the module request (standard ES Module behavior).
|
|
188
|
+
try {
|
|
189
|
+
// console.log(`[Chronos] Prefetching ${path}...`);
|
|
190
|
+
yield componentToRender();
|
|
191
|
+
// We don't need to do anything with the result here.
|
|
192
|
+
// The browser's module cache will handle the speedup when the user actually navigates.
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
console.warn(`[Chronos] Failed to prefetch ${path}`, e);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
174
201
|
navigate(path) {
|
|
175
202
|
if (this.isServer) {
|
|
176
203
|
this.currentPath = path;
|
|
@@ -182,7 +209,12 @@ export class MuRouter {
|
|
|
182
209
|
}
|
|
183
210
|
// --- Factory for Easy Usage ---
|
|
184
211
|
export const createRouter = (options) => {
|
|
185
|
-
|
|
212
|
+
// Expose the router instance globally for <mu-link> to access
|
|
213
|
+
const router = new MuRouter(options.routes, options.rootContainer);
|
|
214
|
+
if (typeof window !== 'undefined') {
|
|
215
|
+
window.__MULAN_ROUTER__ = router;
|
|
216
|
+
}
|
|
217
|
+
return router;
|
|
186
218
|
};
|
|
187
219
|
// --- Web Component: <mu-link> ---
|
|
188
220
|
// Usage: <mu-link to="/about">About Us</mu-link>
|
|
@@ -198,6 +230,26 @@ if (typeof window !== 'undefined' && !customElements.get('mu-link')) {
|
|
|
198
230
|
window.location.hash = to;
|
|
199
231
|
}
|
|
200
232
|
});
|
|
233
|
+
// [Chronos] Intelligent Pre-fetching
|
|
234
|
+
this.addEventListener('mouseenter', () => {
|
|
235
|
+
const to = this.getAttribute('to');
|
|
236
|
+
if (to) {
|
|
237
|
+
const router = window.__MULAN_ROUTER__;
|
|
238
|
+
if (router && typeof router.prefetch === 'function') {
|
|
239
|
+
router.prefetch(to);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
// [Chronos] Also prefetch on focus for keyboard users
|
|
244
|
+
this.addEventListener('focus', () => {
|
|
245
|
+
const to = this.getAttribute('to');
|
|
246
|
+
if (to) {
|
|
247
|
+
const router = window.__MULAN_ROUTER__;
|
|
248
|
+
if (router && typeof router.prefetch === 'function') {
|
|
249
|
+
router.prefetch(to);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
201
253
|
}
|
|
202
254
|
connectedCallback() {
|
|
203
255
|
this.style.cursor = 'pointer';
|