2026-05-14 17:12:01 +08:00
|
|
|
// src/index.js
|
|
|
|
|
export { NewState } from './observer.js';
|
|
|
|
|
export { Component } from './component.js';
|
2026-06-06 23:16:17 +08:00
|
|
|
export { $, $$, _unsafeRefreshState as RefreshState, SetTranslator, _scanTree, _unbindTree } from './dom.js';
|
2026-05-14 17:12:01 +08:00
|
|
|
export { Util } from './utils.js';
|
2026-06-05 19:03:52 +08:00
|
|
|
export { Hash, LocalStorage, State } from './globals.js';
|
2026-05-14 17:12:01 +08:00
|
|
|
|
|
|
|
|
import { Component } from './component.js';
|
2026-06-06 23:16:17 +08:00
|
|
|
import { _scanTree, _unbindTree, $, $$, _unsafeRefreshState, SetTranslator } from './dom.js';
|
2026-06-06 11:45:52 +08:00
|
|
|
import { LocalStorage, Hash, State } from './globals.js';
|
2026-06-06 23:16:17 +08:00
|
|
|
import { NewState, _onNotifyUpdate, _setActiveBinding } from './observer.js';
|
2026-06-05 19:03:52 +08:00
|
|
|
import { Util } from './utils.js';
|
2026-06-06 11:45:52 +08:00
|
|
|
import { _runCode, _returnCode } from './core.js';
|
2026-06-05 19:03:52 +08:00
|
|
|
|
|
|
|
|
const ApigoState = {
|
2026-06-06 23:16:17 +08:00
|
|
|
NewState, Component, $, $$, RefreshState: _unsafeRefreshState, SetTranslator, _scanTree, _unbindTree, Util, Hash, LocalStorage, State
|
2026-06-05 19:03:52 +08:00
|
|
|
};
|
|
|
|
|
|
2026-06-06 11:45:52 +08:00
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
|
window.ApigoState = ApigoState;
|
2026-06-05 19:03:52 +08:00
|
|
|
}
|
2026-05-14 17:12:01 +08:00
|
|
|
|
|
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
|
const init = () => {
|
2026-06-06 22:30:12 +08:00
|
|
|
Component._initPending();
|
2026-06-06 11:45:52 +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'");
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-14 17:12:01 +08:00
|
|
|
new MutationObserver(mutations => {
|
|
|
|
|
mutations.forEach(mutation => {
|
|
|
|
|
mutation.addedNodes.forEach(newNode => {
|
2026-06-06 11:45:52 +08:00
|
|
|
if (newNode.isConnected) _scanTree(newNode);
|
2026-05-14 17:12:01 +08:00
|
|
|
});
|
|
|
|
|
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);
|
|
|
|
|
}
|