@mulanjs/mulanjs 1.0.1-dev.20260219055338 → 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/core/renderer.js +39 -0
- package/dist/index.js +9 -4
- package/dist/mulan.esm.js +228 -5
- package/dist/mulan.js +13 -3
- package/dist/router/index.js +53 -1
- package/dist/types/components/infinity-list.d.ts +17 -0
- package/dist/types/index.d.ts +9 -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/core/renderer.js
CHANGED
|
@@ -15,6 +15,18 @@ export function render(template, container) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
// [Anima] 1. Pre-Update: Snapshot positions of animated elements
|
|
19
|
+
const animationSnapshots = new Map();
|
|
20
|
+
// Only query if we might have animations to save perf
|
|
21
|
+
if (template.includes('mu-animate')) {
|
|
22
|
+
const animatedEls = container.querySelectorAll('[mu-animate]');
|
|
23
|
+
animatedEls.forEach(el => {
|
|
24
|
+
const key = el.getAttribute('mu-key') || el.id;
|
|
25
|
+
if (key) {
|
|
26
|
+
animationSnapshots.set(key, el.getBoundingClientRect());
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
18
30
|
container.innerHTML = template;
|
|
19
31
|
// Restore Focus and Value
|
|
20
32
|
if (focusedId) {
|
|
@@ -35,6 +47,33 @@ export function render(template, container) {
|
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
49
|
}
|
|
50
|
+
// [Anima] 2. Post-Update: FLIP (First, Last, Invert, Play)
|
|
51
|
+
if (animationSnapshots.size > 0) {
|
|
52
|
+
const newAnimatedEls = container.querySelectorAll('[mu-animate]');
|
|
53
|
+
newAnimatedEls.forEach(el => {
|
|
54
|
+
const key = el.getAttribute('mu-key') || el.id;
|
|
55
|
+
if (key && animationSnapshots.has(key)) {
|
|
56
|
+
const oldRect = animationSnapshots.get(key);
|
|
57
|
+
const newRect = el.getBoundingClientRect();
|
|
58
|
+
const dx = oldRect.left - newRect.left;
|
|
59
|
+
const dy = oldRect.top - newRect.top;
|
|
60
|
+
// Only animate if moved
|
|
61
|
+
if (dx !== 0 || dy !== 0) {
|
|
62
|
+
const htmlEl = el;
|
|
63
|
+
// INVERT: Move it back to where it was instantly
|
|
64
|
+
htmlEl.style.transform = `translate(${dx}px, ${dy}px)`;
|
|
65
|
+
htmlEl.style.transition = 'none';
|
|
66
|
+
// PLAY: Animate to zero (new position)
|
|
67
|
+
requestAnimationFrame(() => {
|
|
68
|
+
// Force reflow
|
|
69
|
+
// void htmlEl.offsetWidth;
|
|
70
|
+
htmlEl.style.transition = 'transform 500ms cubic-bezier(0.25, 0.8, 0.25, 1)';
|
|
71
|
+
htmlEl.style.transform = '';
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
38
77
|
}
|
|
39
78
|
export function hydrate(template, container) {
|
|
40
79
|
// In a string-based framework, hydration is often just "take over".
|
package/dist/index.js
CHANGED
|
@@ -9,17 +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';
|
|
21
|
+
import { render } from './core/renderer';
|
|
20
22
|
import * as Quantum from './core/quantum';
|
|
21
|
-
|
|
22
|
-
|
|
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,
|
|
23
26
|
// MULAN INSIGHT: Branded Logging
|
|
24
27
|
log: (msg, ...args) => {
|
|
25
28
|
console.log(`%c[MulanJS]%c ${msg}`, "color: #ff3e00; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;", "", ...args);
|
|
@@ -48,5 +51,7 @@ if (typeof window !== 'undefined') {
|
|
|
48
51
|
}
|
|
49
52
|
};
|
|
50
53
|
}
|
|
51
|
-
window
|
|
54
|
+
if (typeof window !== 'undefined') {
|
|
55
|
+
window.Mulan = Mulan;
|
|
56
|
+
}
|
|
52
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"
|
|
@@ -1225,6 +1349,18 @@ function render(template, container) {
|
|
|
1225
1349
|
}
|
|
1226
1350
|
}
|
|
1227
1351
|
}
|
|
1352
|
+
// [Anima] 1. Pre-Update: Snapshot positions of animated elements
|
|
1353
|
+
const animationSnapshots = new Map();
|
|
1354
|
+
// Only query if we might have animations to save perf
|
|
1355
|
+
if (template.includes('mu-animate')) {
|
|
1356
|
+
const animatedEls = container.querySelectorAll('[mu-animate]');
|
|
1357
|
+
animatedEls.forEach(el => {
|
|
1358
|
+
const key = el.getAttribute('mu-key') || el.id;
|
|
1359
|
+
if (key) {
|
|
1360
|
+
animationSnapshots.set(key, el.getBoundingClientRect());
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1228
1364
|
container.innerHTML = template;
|
|
1229
1365
|
// Restore Focus and Value
|
|
1230
1366
|
if (focusedId) {
|
|
@@ -1245,6 +1381,33 @@ function render(template, container) {
|
|
|
1245
1381
|
}
|
|
1246
1382
|
}
|
|
1247
1383
|
}
|
|
1384
|
+
// [Anima] 2. Post-Update: FLIP (First, Last, Invert, Play)
|
|
1385
|
+
if (animationSnapshots.size > 0) {
|
|
1386
|
+
const newAnimatedEls = container.querySelectorAll('[mu-animate]');
|
|
1387
|
+
newAnimatedEls.forEach(el => {
|
|
1388
|
+
const key = el.getAttribute('mu-key') || el.id;
|
|
1389
|
+
if (key && animationSnapshots.has(key)) {
|
|
1390
|
+
const oldRect = animationSnapshots.get(key);
|
|
1391
|
+
const newRect = el.getBoundingClientRect();
|
|
1392
|
+
const dx = oldRect.left - newRect.left;
|
|
1393
|
+
const dy = oldRect.top - newRect.top;
|
|
1394
|
+
// Only animate if moved
|
|
1395
|
+
if (dx !== 0 || dy !== 0) {
|
|
1396
|
+
const htmlEl = el;
|
|
1397
|
+
// INVERT: Move it back to where it was instantly
|
|
1398
|
+
htmlEl.style.transform = `translate(${dx}px, ${dy}px)`;
|
|
1399
|
+
htmlEl.style.transition = 'none';
|
|
1400
|
+
// PLAY: Animate to zero (new position)
|
|
1401
|
+
requestAnimationFrame(() => {
|
|
1402
|
+
// Force reflow
|
|
1403
|
+
// void htmlEl.offsetWidth;
|
|
1404
|
+
htmlEl.style.transition = 'transform 500ms cubic-bezier(0.25, 0.8, 0.25, 1)';
|
|
1405
|
+
htmlEl.style.transform = '';
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1248
1411
|
}
|
|
1249
1412
|
function hydrate(template, container) {
|
|
1250
1413
|
// In a string-based framework, hydration is often just "take over".
|
|
@@ -1565,6 +1728,33 @@ class MuRouter {
|
|
|
1565
1728
|
}
|
|
1566
1729
|
});
|
|
1567
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
|
+
}
|
|
1568
1758
|
navigate(path) {
|
|
1569
1759
|
if (this.isServer) {
|
|
1570
1760
|
this.currentPath = path;
|
|
@@ -1576,7 +1766,12 @@ class MuRouter {
|
|
|
1576
1766
|
}
|
|
1577
1767
|
// --- Factory for Easy Usage ---
|
|
1578
1768
|
const createRouter = (options) => {
|
|
1579
|
-
|
|
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;
|
|
1580
1775
|
};
|
|
1581
1776
|
// --- Web Component: <mu-link> ---
|
|
1582
1777
|
// Usage: <mu-link to="/about">About Us</mu-link>
|
|
@@ -1592,6 +1787,26 @@ if (typeof window !== 'undefined' && !customElements.get('mu-link')) {
|
|
|
1592
1787
|
window.location.hash = to;
|
|
1593
1788
|
}
|
|
1594
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
|
+
});
|
|
1595
1810
|
}
|
|
1596
1811
|
connectedCallback() {
|
|
1597
1812
|
this.style.cursor = 'pointer';
|
|
@@ -1802,6 +2017,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1802
2017
|
/* harmony export */ Component: () => (/* reexport safe */ _core_component__WEBPACK_IMPORTED_MODULE_1__.MuComponent),
|
|
1803
2018
|
/* harmony export */ MuBlochSphereElement: () => (/* reexport safe */ _components_bloch_sphere__WEBPACK_IMPORTED_MODULE_10__.MuBlochSphereElement),
|
|
1804
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),
|
|
1805
2021
|
/* harmony export */ MuRouter: () => (/* reexport safe */ _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter),
|
|
1806
2022
|
/* harmony export */ MuStore: () => (/* reexport safe */ _store_index__WEBPACK_IMPORTED_MODULE_4__.MuStore),
|
|
1807
2023
|
/* harmony export */ Router: () => (/* reexport safe */ _router_index__WEBPACK_IMPORTED_MODULE_3__.MuRouter),
|
|
@@ -1853,6 +2069,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1853
2069
|
/* harmony import */ var _core_vault__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./core/vault */ "./src/core/vault.ts");
|
|
1854
2070
|
/* harmony import */ var _core_quantum__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./core/quantum */ "./src/core/quantum.ts");
|
|
1855
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
|
+
|
|
1856
2074
|
|
|
1857
2075
|
|
|
1858
2076
|
|
|
@@ -1873,8 +2091,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1873
2091
|
|
|
1874
2092
|
|
|
1875
2093
|
|
|
1876
|
-
|
|
1877
|
-
|
|
2094
|
+
|
|
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,
|
|
1878
2098
|
// MULAN INSIGHT: Branded Logging
|
|
1879
2099
|
log: (msg, ...args) => {
|
|
1880
2100
|
console.log(`%c[MulanJS]%c ${msg}`, "color: #ff3e00; font-weight: bold; background: #222; padding: 2px 4px; border-radius: 3px;", "", ...args);
|
|
@@ -1903,7 +2123,9 @@ if (typeof window !== 'undefined') {
|
|
|
1903
2123
|
}
|
|
1904
2124
|
};
|
|
1905
2125
|
}
|
|
1906
|
-
window
|
|
2126
|
+
if (typeof window !== 'undefined') {
|
|
2127
|
+
window.Mulan = Mulan;
|
|
2128
|
+
}
|
|
1907
2129
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Mulan);
|
|
1908
2130
|
|
|
1909
2131
|
})();
|
|
@@ -1911,6 +2133,7 @@ window.Mulan = Mulan;
|
|
|
1911
2133
|
const __webpack_exports__Component = __webpack_exports__.Component;
|
|
1912
2134
|
const __webpack_exports__MuBlochSphereElement = __webpack_exports__.MuBlochSphereElement;
|
|
1913
2135
|
const __webpack_exports__MuComponent = __webpack_exports__.MuComponent;
|
|
2136
|
+
const __webpack_exports__MuInfinity = __webpack_exports__.MuInfinity;
|
|
1914
2137
|
const __webpack_exports__MuRouter = __webpack_exports__.MuRouter;
|
|
1915
2138
|
const __webpack_exports__MuStore = __webpack_exports__.MuStore;
|
|
1916
2139
|
const __webpack_exports__Router = __webpack_exports__.Router;
|
|
@@ -1950,4 +2173,4 @@ const __webpack_exports__sanitize = __webpack_exports__.sanitize;
|
|
|
1950
2173
|
const __webpack_exports__setCurrentInstance = __webpack_exports__.setCurrentInstance;
|
|
1951
2174
|
const __webpack_exports__useMutation = __webpack_exports__.useMutation;
|
|
1952
2175
|
const __webpack_exports__useQuery = __webpack_exports__.useQuery;
|
|
1953
|
-
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 };
|