2026-06-11 13:20:39 +08:00
|
|
|
import './utils.js';
|
|
|
|
|
import './observer.js';
|
|
|
|
|
import { _unbindTree, _scanTree } from './engine.js';
|
|
|
|
|
import './core.js';
|
2026-06-11 11:19:59 +08:00
|
|
|
|
2026-06-11 13:20:39 +08:00
|
|
|
/**
|
|
|
|
|
* Entry Point
|
|
|
|
|
* Orchestrates initialization and MutationObserver.
|
|
|
|
|
*/
|
2026-06-11 11:19:59 +08:00
|
|
|
|
|
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
|
const init = () => {
|
2026-06-11 13:20:39 +08:00
|
|
|
if (globalThis.Component && globalThis.Component._initPending) {
|
|
|
|
|
globalThis.Component._initPending();
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-11 11:19:59 +08:00
|
|
|
const htmlNode = document.documentElement;
|
|
|
|
|
if (!htmlNode.hasAttribute('$data-bs-theme') && !htmlNode.hasAttribute('data-bs-theme')) {
|
|
|
|
|
htmlNode.setAttribute('$data-bs-theme', "LocalStorage.darkMode?'dark':'light'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new MutationObserver(mutations => {
|
|
|
|
|
mutations.forEach(mutation => {
|
|
|
|
|
mutation.addedNodes.forEach(newNode => {
|
|
|
|
|
if (newNode.isConnected) _scanTree(newNode);
|
|
|
|
|
});
|
|
|
|
|
mutation.removedNodes.forEach(oldNode => _unbindTree(oldNode));
|
|
|
|
|
});
|
|
|
|
|
}).observe(document.documentElement, { childList: true, subtree: true });
|
|
|
|
|
|
|
|
|
|
_scanTree(document.documentElement);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (document.readyState !== 'loading') init();
|
|
|
|
|
else document.addEventListener('DOMContentLoaded', init, true);
|
|
|
|
|
}
|
2026-06-11 13:20:39 +08:00
|
|
|
|
2026-07-04 09:57:23 +08:00
|
|
|
export { NewState, _setActiveBinding as setActiveBinding, _onNotifyUpdate as onNotifyUpdate } from './observer.js';
|
2026-06-11 13:20:39 +08:00
|
|
|
export { Component, SetTranslator } from './engine.js';
|
|
|
|
|
export { $, $$, Util } from './utils.js';
|
2026-07-04 09:57:23 +08:00
|
|
|
export { Hash, LocalStorage, State, _runCode, _returnCode } from './core.js';
|
2026-06-11 13:20:39 +08:00
|
|
|
export const __unsafeRefreshState = _scanTree;
|