transone 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/core/app.d.ts +114 -0
- package/dist/core/component/base.d.ts +79 -0
- package/dist/core/component/index.d.ts +4 -0
- package/dist/core/component.d.ts +1 -0
- package/dist/core/document.d.ts +32 -0
- package/dist/core/form.d.ts +24 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/model.d.ts +18 -0
- package/dist/core/reactive/scheduler.d.ts +32 -0
- package/dist/core/reactive/types.d.ts +24 -0
- package/dist/core/reactive.d.ts +77 -0
- package/dist/core/renderer/element-strategy.d.ts +32 -0
- package/dist/core/renderer/props.d.ts +9 -0
- package/dist/core/renderer/types.d.ts +37 -0
- package/dist/core/renderer.d.ts +43 -0
- package/dist/core/template.d.ts +50 -0
- package/dist/core/vnode.d.ts +104 -0
- package/dist/dom/index.d.ts +612 -0
- package/dist/dom/index.js +4 -0
- package/dist/dom/index.js.map +10 -0
- package/dist/index-3t506ckz.js +12 -0
- package/dist/index-3t506ckz.js.map +25 -0
- package/dist/index-mbmajrpr.js +26 -0
- package/dist/index-mbmajrpr.js.map +11 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +11 -0
- package/dist/router/history.d.ts +5 -0
- package/dist/router/index.d.ts +112 -0
- package/dist/router/index.js +4 -0
- package/dist/router/index.js.map +9 -0
- package/dist/router/instance.d.ts +26 -0
- package/dist/router/matcher.d.ts +7 -0
- package/dist/style/StyleManager.d.ts +18 -0
- package/dist/style/class-style.d.ts +0 -0
- package/dist/style/id-style.d.ts +0 -0
- package/dist/style/index.d.ts +2 -0
- package/dist/style/index.js +4 -0
- package/dist/style/index.js.map +9 -0
- package/dist/style/sheet.d.ts +13 -0
- package/dist/style/style.d.ts +0 -0
- package/package.json +59 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var ge;((s)=>{s[s.ELEMENT_NODE=1]="ELEMENT_NODE";s[s.TEXT_NODE=3]="TEXT_NODE";s[s.COMMENT_NODE=8]="COMMENT_NODE";s[s.DOCUMENT_NODE=9]="DOCUMENT_NODE";s[s.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"})(ge||={});class q extends Error{code;constructor(e,t="Error"){super(e);this.name=t,this.code=0}}class S{listenerMap=new Map;addEventListener(e,t,n){if(!t)return;let i=typeof n==="boolean"?n:n?.capture??!1,r=typeof n==="object"?n.once??!1:!1,s=typeof n==="object"?n.passive??!1:!1,l=this.listenerMap.get(e);if(!l)l=[],this.listenerMap.set(e,l);if(l.some((c)=>c.listener===t&&c.capture===i))return;l.push({listener:t,capture:i,once:r,passive:s})}removeEventListener(e,t,n){if(!t)return;let i=typeof n==="boolean"?n:n?.capture??!1,r=this.listenerMap.get(e);if(!r)return;let s=r.findIndex((l)=>l.listener===t&&l.capture===i);if(s>=0)r.splice(s,1);if(r.length===0)this.listenerMap.delete(e)}dispatchEvent(e){if(!(e instanceof a))throw TypeError("dispatchEvent requires an Event instance");if(e.dispatched)throw Error("Event has already been dispatched");return fe(this,e)}getListeners(e){return this.listenerMap.get(e)??[]}}class a{static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;type;bubbles;cancelable;composed;target=null;currentTarget=null;eventPhase=a.NONE;defaultPrevented=!1;isTrusted=!1;timeStamp;cancelBubble=!1;dispatched=!1;propagationStopped=!1;immediateStopped=!1;canceled=!1;constructor(e,t){this.type=e,this.bubbles=t?.bubbles??!1,this.cancelable=t?.cancelable??!1,this.composed=t?.composed??!1,this.timeStamp=Date.now()}preventDefault(){if(this.cancelable)this.canceled=!0,this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0,this.cancelBubble=!0}stopImmediatePropagation(){this.propagationStopped=!0,this.immediateStopped=!0,this.cancelBubble=!0}propagationPrevented(){return this.propagationStopped}immediatePrevented(){return this.immediateStopped}wasCanceled(){return this.canceled}}class V extends a{detail;constructor(e,t){super(e,t);this.detail=t?.detail}}class O extends a{clientX;clientY;button;buttons;relatedTarget;constructor(e,t){super(e,t);this.clientX=t?.clientX??0,this.clientY=t?.clientY??0,this.button=t?.button??0,this.buttons=t?.buttons??0,this.relatedTarget=t?.relatedTarget??null}}class H extends a{key;code;shiftKey;ctrlKey;altKey;metaKey;constructor(e,t){super(e,t);this.key=t?.key??"",this.code=t?.code??"",this.shiftKey=t?.shiftKey??!1,this.ctrlKey=t?.ctrlKey??!1,this.altKey=t?.altKey??!1,this.metaKey=t?.metaKey??!1}}function me(e,t){let n=e.listener;if(typeof n==="function")n.call(t.currentTarget,t);else n.handleEvent(t)}function fe(e,t){t.dispatched=!0,t.target=e;let i=[...ye(e)].reverse(),r=i.length-1;t.eventPhase=a.CAPTURING_PHASE;for(let s=0;s<r;s+=1){let l=i[s];if(t.propagationPrevented())break;t.currentTarget=l,D(l,t,!0)}if(!t.propagationPrevented()){if(t.eventPhase=a.AT_TARGET,t.currentTarget=e,D(e,t,!0),!t.immediatePrevented())D(e,t,!1)}if(t.bubbles&&!t.propagationPrevented()){t.eventPhase=a.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s-=1){let l=i[s];if(t.propagationPrevented())break;t.currentTarget=l,D(l,t,!1)}}return t.eventPhase=a.NONE,t.currentTarget=null,!t.wasCanceled()}function D(e,t,n){let i=e.getListeners(t.type);for(let r of[...i]){if(r.capture!==n)continue;if(t.immediatePrevented())break;if(r.once)e.removeEventListener(t.type,r.listener,{capture:r.capture});me(r,t)}}function ye(e){let t=[],n=e;while(n){t.push(n);let i=n;if(i.nodeType===9){let s=i.defaultView;if(s)t.push(s);break}let r=i.parentNode;if(r){n=r;continue}break}return t}class X{element;attributeName;constructor(e,t="class"){this.element=e,this.attributeName=t}get length(){return this.tokens().length}get value(){return this.element.getAttribute(this.attributeName)??""}set value(e){this.setTokens(G(e))}item(e){return this.tokens()[e]??null}contains(e){return this.tokens().includes(e)}add(...e){let t=new Set(this.tokens());for(let n of e)if(n)t.add(n);this.setTokens([...t])}remove(...e){let t=new Set(this.tokens());for(let n of e)t.delete(n);this.setTokens([...t])}toggle(e,t){let n=new Set(this.tokens()),i=t??!n.has(e);if(i)n.add(e);else n.delete(e);return this.setTokens([...n]),i}replace(e,t){let n=this.tokens(),i=n.indexOf(e);if(i<0)return!1;return n[i]=t,this.setTokens(n),!0}[Symbol.iterator](){return this.tokens()[Symbol.iterator]()}forEach(e){this.tokens().forEach((t,n)=>e(t,n,this))}toString(){return this.value}tokens(){return G(this.element.getAttribute(this.attributeName)??"")}setTokens(e){let t=e.filter(Boolean).join(" ");if(t)this.element.setAttribute(this.attributeName,t);else this.element.removeAttribute(this.attributeName)}}function G(e){return e.trim().split(/\s+/).filter(Boolean)}function L(e){return e.replace(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function _(){let e=new Map,t={properties:e,setProperty(i,r,s=""){let l=L(i);if(r==="")e.delete(l);else e.set(l,{value:r,priority:s})},getPropertyValue(i){return e.get(L(i))?.value??""},getPropertyPriority(i){return e.get(L(i))?.priority??""},removeProperty(i){let r=L(i),s=e.get(r)?.value??"";return e.delete(r),s},item(i){return[...e.keys()][i]??""},get length(){return e.size},get cssText(){return[...e.entries()].map(([i,r])=>`${i}: ${r.value}${r.priority?` ${r.priority}`:""};`).join(" ")},set cssText(i){e.clear();for(let r of i.split(";")){let s=r.trim();if(!s)continue;let l=s.indexOf(":");if(l<0)continue;let c=s.slice(0,l).trim(),o=s.slice(l+1).trim();if(c)t.setProperty(c,o)}}};return new Proxy(t,{get(i,r,s){if(typeof r==="symbol")return Reflect.get(i,r,s);if(r in i){let l=Reflect.get(i,r,s);return typeof l==="function"?l.bind(i):l}return i.getPropertyValue(r)},set(i,r,s,l){if(typeof r==="symbol")return Reflect.set(i,r,s,l);if(r in i)return Reflect.set(i,r,s,l);return i.setProperty(r,String(s)),!0},has(i,r){if(typeof r==="symbol")return Reflect.has(i,r);if(r in i)return!0;return i.getPropertyValue(r)!==""},ownKeys(){return[...Reflect.ownKeys(t),...[...e.keys()].map((i)=>Ee(i))]},getOwnPropertyDescriptor(i,r){if(typeof r==="symbol")return Reflect.getOwnPropertyDescriptor(i,r);if(r in i)return Reflect.getOwnPropertyDescriptor(i,r);let s=i.getPropertyValue(r);if(s!=="")return{configurable:!0,enumerable:!0,writable:!0,value:s};return}})}function Ee(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}class f{items;constructor(e=[]){this.items=e;for(let t=0;t<e.length;t+=1)Object.defineProperty(this,String(t),{configurable:!0,enumerable:!0,get:()=>this.items[t]})}get length(){return this.items.length}item(e){return this.items[e]??null}[Symbol.iterator](){return this.items[Symbol.iterator]()}forEach(e){this.items.forEach((t,n)=>e(t,n,this))}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}toArray(){return[...this.items]}}class b extends S{static ELEMENT_NODE=1;static TEXT_NODE=3;static COMMENT_NODE=8;static DOCUMENT_NODE=9;static DOCUMENT_FRAGMENT_NODE=11;nodeType;nodeName;parentNode=null;ownerDocument=null;childList=[];constructor(e,t){super();this.nodeType=e,this.nodeName=t}get parentElement(){let e=this.parentNode;return e instanceof M?e:null}get childNodes(){return new f([...this.childList])}get firstChild(){return this.childList[0]??null}get lastChild(){return this.childList[this.childList.length-1]??null}get nextSibling(){let e=this.parentNode;if(!e)return null;let t=e.childList.indexOf(this);return t>=0?e.childList[t+1]??null:null}get previousSibling(){let e=this.parentNode;if(!e)return null;let t=e.childList.indexOf(this);return t>0?e.childList[t-1]:null}get textContent(){let e="";for(let t of this.childList)if(t.nodeType===3)e+=t.data;else if(t.nodeType===1)e+=t.textContent;return e}set textContent(e){if(this.childList=[],e){let t=new u(e);t.ownerDocument=this.ownerDocument,t.parentNode=this,this.childList.push(t)}}hasChildNodes(){return this.childList.length>0}appendChild(e){if(e===this)throw Error("Cannot append a node to itself");return this.insertBefore(e,null),e}insertBefore(e,t){if(e===this)throw Error("Cannot insert a node before itself");if(e.parentNode)e.parentNode.removeChild(e);if(e.parentNode=this,e.ownerDocument===null)e.ownerDocument=this.ownerDocument;if(t===null)return this.childList.push(e),e;let n=this.childList.indexOf(t);if(n<0)throw Error("Reference node is not a child of this node");return this.childList.splice(n,0,e),e}removeChild(e){let t=this.childList.indexOf(e);if(t<0)throw Error("Node is not a child of this node");return this.childList.splice(t,1),e.parentNode=null,e}replaceChild(e,t){let n=this.childList.indexOf(t);if(n<0)throw Error("Old child is not a child of this node");if(e.parentNode)e.parentNode.removeChild(e);if(e.parentNode=this,e.ownerDocument===null)e.ownerDocument=this.ownerDocument;return this.childList[n]=e,t.parentNode=null,e}replaceChildren(...e){for(let t of[...this.childList])this.removeChild(t);for(let t of e)this.appendChild(t)}contains(e){if(!e)return!1;let t=e;while(t){if(t===this)return!0;t=t.parentNode}return!1}remove(){this.parentNode?.removeChild(this)}cloneNode(e=!1){let t=this.createClone();if(e)for(let n of this.childList)t.appendChild(n.cloneNode(!0));return t}createClone(){let e=new b(this.nodeType,this.nodeName);return e.ownerDocument=this.ownerDocument,e}getRootNode(){if(!this.parentNode)return this;let e=this.parentNode;while(e.parentNode)e=e.parentNode;return e}get isConnected(){return this.getRootNode().nodeType===9}}class M extends b{namespaceURI;attributeList=[];styleValue;classListValue;datasetProxy;constructor(e,t=null){super(1,e.toUpperCase());this.namespaceURI=t}get tagName(){return this.nodeName}get localName(){return this.nodeName.toLowerCase()}get id(){return this.getAttribute("id")??""}set id(e){this.setAttribute("id",e)}get className(){return this.getAttribute("class")??""}set className(e){this.setAttribute("class",e)}get classList(){if(!this.classListValue)this.classListValue=new X(this,"class");return this.classListValue}get style(){if(!this.styleValue)this.styleValue=_();return this.styleValue}get dataset(){if(!this.datasetProxy)this.datasetProxy=Re(this);return this.datasetProxy}get children(){return new f(this.childList.filter((e)=>e.nodeType===1))}get firstElementChild(){return this.children.item(0)}get lastElementChild(){return this.children.item(this.children.length-1)}get childElementCount(){return this.children.length}get attributes(){return new Z(this)}getAttribute(e){let t=this.findAttribute(e);return t?t.value:null}getAttributeNames(){return this.attributeList.map((e)=>e.name)}setAttribute(e,t){let n=String(t);if(e==="style")this.styleValue=_(),this.styleValue.cssText=n;let i=this.findAttribute(e);if(i)i.value=n;else this.attributeList.push({name:e,value:n})}removeAttribute(e){if(e==="style")this.styleValue=_();let t=this.attributeList.findIndex((n)=>n.name===e);if(t>=0)this.attributeList.splice(t,1)}hasAttribute(e){return this.findAttribute(e)!==void 0}toggleAttribute(e,t){let n=t??!this.hasAttribute(e);if(n)this.setAttribute(e,"");else this.removeAttribute(e);return n}hasAttributes(){return this.attributeList.length>0}get innerHTML(){return pe(this)}set innerHTML(e){this.replaceChildren(...Te(e,this.ownerDocument))}get outerHTML(){return ce(this)}get value(){return this.getAttribute("value")??""}set value(e){this.setAttribute("value",e)}querySelector(e){return C(this,e).item(0)}querySelectorAll(e){return C(this,e)}getElementsByTagName(e){let t=e.toLowerCase(),n=[];return x(this,(i)=>{if(i.localName===t)n.push(i)}),new f(n)}matches(e){return he(this,e)}closest(e){if(this.matches(e))return this;let t=this.parentElement;while(t){if(t.matches(e))return t;t=t.parentElement}return null}getBoundingClientRect(){let e=this.ownerDocument?.defaultView,t=e?.innerWidth??1024,n=e?.innerHeight??768,i=this,r=i===this.ownerDocument?.body||i===this.ownerDocument?.documentElement;return{x:0,y:0,top:0,left:0,right:r?t:0,bottom:r?n:0,width:r?t:0,height:r?n:0,toJSON(){return{x:0,y:0,top:0,left:0,right:r?t:0,bottom:r?n:0,width:r?t:0,height:r?n:0}}}}scrollIntoView(){}focus(){this.ownerDocument?.setActiveElement(this)}blur(){if(this.ownerDocument?.activeElement===this)this.ownerDocument.setActiveElement(null)}click(){if(this.disabled===!0)return;if(this.dispatchEvent(new O("click",{bubbles:!0,cancelable:!0})),this.tagName==="BUTTON"&&this.getAttribute("type")==="reset"&&this.isConnected)this.closest("form")?.dispatchEvent(new a("reset",{bubbles:!0,cancelable:!0}))}append(...e){for(let t of e)if(typeof t==="string"){let n=new u(t);n.ownerDocument=this.ownerDocument,this.appendChild(n)}else this.appendChild(t)}prepend(...e){let t=this.firstChild;for(let n of e)if(typeof n==="string"){let i=new u(n);i.ownerDocument=this.ownerDocument,this.insertBefore(i,t)}else this.insertBefore(n,t)}before(...e){let t=this.parentNode;if(!t)return;for(let n of e)if(typeof n==="string"){let i=new u(n);i.ownerDocument=this.ownerDocument,t.insertBefore(i,this)}else t.insertBefore(n,this)}after(...e){let t=this.parentNode;if(!t)return;let n=this.nextSibling;for(let i of e)if(typeof i==="string"){let r=new u(i);r.ownerDocument=this.ownerDocument,t.insertBefore(r,n)}else t.insertBefore(i,n)}replaceWith(...e){let t=this.parentNode;if(!t)return;let n=this.nextSibling;t.removeChild(this);for(let i of e)if(typeof i==="string"){let r=new u(i);r.ownerDocument=this.ownerDocument,t.insertBefore(r,n)}else t.insertBefore(i,n)}setAttributeNS(e,t,n){this.setAttribute(t,n)}removeAttributeNS(e,t){this.removeAttribute(t)}hasAttributeNS(e,t){return this.hasAttribute(t)}getAttributeNS(e,t){return this.getAttribute(t)}findAttribute(e){return this.attributeList.find((t)=>t.name===e)}attributeEntries(){return[...this.attributeList]}inlineStyleText(){return this.styleValue?.cssText??""}createClone(){let e=m(this.localName,this.ownerDocument);for(let t of this.attributeList)e.setAttribute(t.name,t.value);return e}}class p extends M{constructor(e){super(e)}get lang(){return this.getAttribute("lang")??""}set lang(e){this.setAttribute("lang",e)}get hidden(){return this.hasAttribute("hidden")}set hidden(e){if(e)this.setAttribute("hidden","");else this.removeAttribute("hidden")}get tabIndex(){let e=this.getAttribute("tabindex");return e===null?0:Number(e)}set tabIndex(e){if(e===0)this.removeAttribute("tabindex");else this.setAttribute("tabindex",String(e))}get offsetWidth(){return 0}get offsetHeight(){return 0}get offsetLeft(){return 0}get offsetTop(){return 0}}class Z{element;constructor(e){this.element=e;for(let t=0;t<e.attributeEntries().length;t+=1)Object.defineProperty(this,String(t),{configurable:!0,enumerable:!0,get:()=>this.element.attributeEntries()[t]??null})}get length(){return this.element.attributeEntries().length}item(e){return this.element.attributeEntries()[e]??null}getNamedItem(e){return this.element.findAttribute(e)??null}setNamedItem(e){this.element.setAttribute(e.name,e.value)}removeNamedItem(e){this.element.removeAttribute(e)}[Symbol.iterator](){return this.element.attributeEntries()[Symbol.iterator]()}}class k extends p{selectedValue;constructor(e="option"){super(e)}get value(){return this.getAttribute("value")??this.textContent}set value(e){this.setAttribute("value",e)}get text(){return this.textContent}get label(){return this.getAttribute("label")??this.textContent}get selected(){return this.hasSelectedValue()}set selected(e){if(this.setSelectedRaw(e),e){let t=this.parentElement;if(t instanceof R&&!t.multiple){for(let n of t.options.toArray())if(n!==this)n.setSelectedRaw(!1)}}}setSelectedRaw(e){if(this.selectedValue=e,e)this.setAttribute("selected","");else this.removeAttribute("selected")}hasSelectedValue(){if(this.selectedValue!==void 0)return this.selectedValue;return this.hasAttribute("selected")}}class R extends p{constructor(e="select"){super(e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){if(e)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get multiple(){return this.hasAttribute("multiple")}set multiple(e){if(e)this.setAttribute("multiple","");else this.removeAttribute("multiple")}get options(){let e=[];return x(this,(t)=>{if(t instanceof k)e.push(t)}),new Q(e)}get selectedOptions(){return new f(this.options.toArray().filter((e)=>e.hasSelectedValue()))}get selectedIndex(){return this.options.toArray().findIndex((e)=>e.hasSelectedValue())}set selectedIndex(e){this.options.toArray().forEach((n,i)=>n.setSelectedRaw(i===e))}get value(){let e=this.options.toArray(),t=e.find((n)=>n.hasSelectedValue());if(t)return t.value;if(!this.multiple&&e.length>0)return e[0].value;return""}set value(e){let t=this.options.toArray();for(let n of t)if(n.value===e)if(this.multiple)n.setSelectedRaw(!0);else{for(let r of t)r.setSelectedRaw(r===n);return}}add(e){this.appendChild(e)}removeOption(e){let n=this.options.toArray()[e];if(n)n.remove()}}class Q{items;constructor(e){this.items=e;for(let t=0;t<e.length;t+=1)Object.defineProperty(this,String(t),{configurable:!0,enumerable:!0,get:()=>this.items[t]})}get length(){return this.items.length}item(e){return this.items[e]??null}get value(){return this.items.find((e)=>e.hasSelectedValue())?.value??""}get selectedIndex(){return this.items.findIndex((e)=>e.hasSelectedValue())}toArray(){return[...this.items]}[Symbol.iterator](){return this.items[Symbol.iterator]()}}class U extends p{inputValue;checkedValue;constructor(e="input"){super(e)}get type(){return this.getAttribute("type")??"text"}set type(e){this.setAttribute("type",e)}get name(){return this.getAttribute("name")??""}set name(e){this.setAttribute("name",e)}get value(){return this.inputValue??this.getAttribute("value")??""}set value(e){this.inputValue=e}get defaultValue(){return this.getAttribute("value")??""}get checked(){return this.checkedValue??this.hasAttribute("checked")}set checked(e){this.checkedValue=e}get disabled(){return this.hasAttribute("disabled")}set disabled(e){if(e)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get placeholder(){return this.getAttribute("placeholder")??""}set placeholder(e){this.setAttribute("placeholder",e)}get accept(){return this.getAttribute("accept")??""}get multiple(){return this.hasAttribute("multiple")}set multiple(e){if(e)this.setAttribute("multiple","");else this.removeAttribute("multiple")}set accept(e){this.setAttribute("accept",e)}get min(){return this.getAttribute("min")??""}set min(e){this.setAttribute("min",e)}get max(){return this.getAttribute("max")??""}set max(e){this.setAttribute("max",e)}get step(){return this.getAttribute("step")??""}set step(e){this.setAttribute("step",e)}createClone(){let e=super.createClone();return e.inputValue=this.inputValue,e.checkedValue=this.checkedValue,e}}class B extends p{textareaValue;constructor(e="textarea"){super(e)}get value(){return this.textareaValue??this.textContent}set value(e){this.textareaValue=e}get name(){return this.getAttribute("name")??""}set name(e){this.setAttribute("name",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){if(e)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get placeholder(){return this.getAttribute("placeholder")??""}set placeholder(e){this.setAttribute("placeholder",e)}}class W extends p{constructor(e="button"){super(e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){if(e)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get type(){return this.getAttribute("type")??"submit"}}class Y extends p{constructor(e="td"){super(e)}get colSpan(){let e=this.getAttribute("colspan");return e===null?1:Number(e)}set colSpan(e){this.setAttribute("colspan",String(e))}}class J extends p{constructor(e="label"){super(e)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(e){this.setAttribute("for",e)}}class ee extends p{constructor(e="img"){super(e)}get src(){return this.getAttribute("src")??""}set src(e){this.setAttribute("src",e)}get alt(){return this.getAttribute("alt")??""}set alt(e){this.setAttribute("alt",e)}}class K extends p{constructor(e="style"){super(e)}}class z extends p{constructor(e="a"){super(e)}get href(){return this.getAttribute("href")??""}set href(e){this.setAttribute("href",e)}}class u extends b{data;constructor(e=""){super(3,"#text");this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}get wholeText(){return this.data}createClone(){let e=new u(this.data);return e.ownerDocument=this.ownerDocument,e}}class T extends b{data;constructor(e=""){super(8,"#comment");this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e}createClone(){let e=new T(this.data);return e.ownerDocument=this.ownerDocument,e}}class P extends b{constructor(){super(11,"#document-fragment")}}class te{createDocument(){return new v}createDocumentType(){throw Error("createDocumentType is not supported in tsone DOM")}hasFeature(){return!1}createHTMLDocument(e){let t=new v,n=t.createElement("html"),i=t.createElement("head"),r=t.createElement("body");if(e){let s=t.createElement("title");s.textContent=e,i.appendChild(s)}return n.appendChild(i),n.appendChild(r),t.appendChild(n),t}}class v extends b{defaultView=null;implementation;activeElementRef=null;constructor(){super(9,"#document");this.implementation=new te}get activeElement(){return this.activeElementRef}setActiveElement(e){this.activeElementRef=e}createElement(e){return m(e,this)}createElementNS(e,t){let n=m(t,this);return n.namespaceURI=e,n}createTextNode(e){let t=new u(e);return t.ownerDocument=this,t}createComment(e){let t=new T(e);return t.ownerDocument=this,t}createDocumentFragment(){let e=new P;return e.ownerDocument=this,e}createEvent(e){if(e==="MouseEvent"||e==="mouseevent")return new O("");if(e==="KeyboardEvent"||e==="keyboardevent")return new H("");if(e==="CustomEvent"||e==="customevent")return new V("");return new a("")}get documentElement(){let e=this.childList.find((n)=>n.nodeType===1);if(e)return e;let t=m("html",this);return this.appendChild(t),t}get head(){return this.ensureDocumentChild("head")}get body(){return this.ensureDocumentChild("body")}get title(){return this.querySelector("title")?.textContent??""}set title(e){let t=this.querySelector("title");if(!t)t=m("title",this),this.head.appendChild(t);t.textContent=e}querySelector(e){return C(this,e).item(0)}querySelectorAll(e){return C(this,e)}getElementById(e){let t=null;return x(this,(n)=>{if(!t&&n.id===e)t=n}),t}getElementsByTagName(e){return this.documentElement.getElementsByTagName(e)}createClone(){return new v}ensureDocumentChild(e){let t=this.documentElement,n=t.childList.find((i)=>i.nodeType===1&&i.localName===e);if(!n)n=m(e,this),t.appendChild(n);return n}}class ne{url;constructor(e){this.url=new URL(e)}get href(){return this.url.href}set href(e){this.url=new URL(e,this.url.href)}get origin(){return this.url.origin}get protocol(){return this.url.protocol}get host(){return this.url.host}get hostname(){return this.url.hostname}get port(){return this.url.port}get pathname(){return this.url.pathname}set pathname(e){let t=this.url,n=new URL(e,t.href);t.pathname=n.pathname}get search(){return this.url.search}set search(e){this.url.search=e.startsWith("?")?e:`?${e}`}get hash(){return this.url.hash}set hash(e){let t=e.startsWith("#")?e:`#${e}`;this.url.hash=t}get username(){return this.url.username}get password(){return this.url.password}assign(e){this.url=new URL(e,this.url.href)}replace(e){this.url=new URL(e,this.url.href)}reload(){}toString(){return this.url.href}getHashPath(){return this.url.hash.slice(1)}getHrefWithoutHash(){let e=this.url;return`${e.origin}${e.pathname}${e.search}`}}class ie{windowRef;entries=[];index=0;scrollRestoration="auto";constructor(e){this.windowRef=e,this.entries=[{state:null,url:e.location.href}]}get length(){return this.entries.length}get state(){return this.entries[this.index]?.state??null}pushState(e,t,n){let i=n?new URL(n,this.windowRef.location.href).href:this.windowRef.location.href;this.entries=this.entries.slice(0,this.index+1),this.entries.push({state:e,url:i}),this.index=this.entries.length-1,this.windowRef.setLocationUrl(i)}replaceState(e,t,n){let i=n?new URL(n,this.windowRef.location.href).href:this.windowRef.location.href;this.entries[this.index]={state:e,url:i},this.windowRef.setLocationUrl(i)}back(){this.go(-1)}forward(){this.go(1)}go(e=0){let t=this.index+e;if(t<0||t>=this.entries.length)return;this.index=t,this.windowRef.setLocationUrl(this.entries[t].url),this.windowRef.dispatchEvent(new a("popstate",{bubbles:!1,cancelable:!1}))}}class re{store=new Map;get length(){return this.store.size}key(e){return[...this.store.keys()][e]??null}getItem(e){return this.store.has(e)?this.store.get(e):null}setItem(e,t){this.store.set(e,String(t))}removeItem(e){this.store.delete(e)}clear(){this.store.clear()}}class se{userAgent="TSone/0.5.1";platform="TSone";language="zh-CN";languages=["zh-CN"];onLine=!0;maxTouchPoints=0}function ve(e,t){let n=new Set,i=!1,r={media:t,matches:!1,onchange:null,addEventListener(s,l){if(s==="change")n.add(l)},removeEventListener(s,l){if(s==="change")n.delete(l)},addListener(s){n.add(s)},removeListener(s){n.delete(s)},dispatchEvent(s){for(let l of[...n])if(typeof l==="function")l.call(r,s);else l.handleEvent(s);return!0}};return r}class we{observe(){}unobserve(){}disconnect(){}}var Ne=["window","document","Node","Text","Comment","Element","HTMLElement","HTMLInputElement","HTMLTextAreaElement","HTMLSelectElement","HTMLButtonElement","HTMLOptionElement","HTMLStyleElement","HTMLAnchorElement","HTMLImageElement","HTMLTableCellElement","HTMLLabelElement","DocumentFragment","Document","Event","MouseEvent","KeyboardEvent","CustomEvent","EventTarget","DOMException","history","location","navigator","localStorage","matchMedia","getComputedStyle","requestAnimationFrame","cancelAnimationFrame","ResizeObserver"];class le extends S{innerWidth=1024;innerHeight=768;setTimeout(e,t){return setTimeout(e,t)}clearTimeout(e){clearTimeout(e)}window=this;document;location;history;localStorage=new re;navigator=new se;Node=b;Text=u;Comment=T;Element=M;HTMLElement=p;HTMLInputElement=U;HTMLTextAreaElement=B;HTMLSelectElement=R;HTMLButtonElement=W;HTMLOptionElement=k;HTMLStyleElement=K;HTMLAnchorElement=z;DocumentFragment=P;Document=v;Event=a;MouseEvent=O;KeyboardEvent=H;CustomEvent=V;EventTarget=S;DOMException=q;NodeList=f;constructor(e={}){super();let t=e.url??"http://localhost/";this.location=new ne(t),this.history=new ie(this),this.document=new v,this.document.defaultView=this,ke(this.document)}matchMedia(e){return ve(this,e)}getComputedStyle(e){return e.style}requestAnimationFrame(e){return setTimeout(()=>e(Date.now()),0)}cancelAnimationFrame(e){clearTimeout(e)}setLocationUrl(e){this.location.href=e}installKeys(){return[...Ne]}}function Ie(e={}){return new le(e)}function Ve(e,t=globalThis){let n=new Map,i=e.installKeys();for(let r of i)n.set(r,Object.getOwnPropertyDescriptor(t,r));for(let r of i)Object.defineProperty(t,r,{configurable:!0,enumerable:!0,writable:!0,value:e[r]});return Object.defineProperty(t,"window",{configurable:!0,enumerable:!0,writable:!0,value:e}),()=>{for(let r of i){let s=n.get(r);if(s)Object.defineProperty(t,r,s);else Reflect.deleteProperty(t,r)}}}function Te(e,t){let n=new P;if(t)n.ownerDocument=t;return xe(n,e,t),[...n.childList]}function xe(e,t,n){let i=[],r=e,s=0,l=t.length,c=(o)=>{if(o.ownerDocument===null)o.ownerDocument=n;r.appendChild(o)};while(s<l){let o=t.indexOf("<",s);if(o<0){c(new u(t.slice(s)));break}if(o>s)c(new u(t.slice(s,o)));if(t.startsWith("<!--",o)){let d=t.indexOf("-->",o+4),E=d<0?l:d;c(new T(t.slice(o+4,E))),s=d<0?l:d+3;continue}let h=Ae(t,o);if(h<0){c(new u(t.slice(o)));break}let A=t.slice(o+1,h).trim();if(A.startsWith("/")){let d=A.slice(1).trim().toLowerCase();if(i.length>0&&i[i.length-1].localName===d)i.pop(),r=i[i.length-1]??e;s=h+1;continue}let be=A.endsWith("/"),y=De(A.replace(/\/$/,"").trim());if(!y){s=h+1;continue}let w=m(y.name,n);for(let d of y.attributes)w.setAttribute(d.name,d.value);if(c(w),oe.has(y.name)||be){s=h+1;continue}if(ue.has(y.name)){let d=`</${y.name}>`,E=t.toLowerCase().indexOf(d,h+1),F=t.slice(h+1,E<0?l:E);w.appendChild(n?.createTextNode(F)??new u(F)),s=E<0?l:E+d.length;continue}i.push(w),r=w,s=h+1}}var oe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ue=new Set(["script","style","textarea","title"]);function Ae(e,t){let n=null;for(let i=t+1;i<e.length;i+=1){let r=e[i];if(n){if(r===n)n=null;continue}if(r==='"'||r==="'"){n=r;continue}if(r===">")return i}return-1}function De(e){let t=e.match(/^([a-zA-Z][a-zA-Z0-9-]*)\s*(.*)$/);if(!t)return null;let n=t[1].toLowerCase(),i=[],r=t[2],s=/([a-zA-Z_:][a-zA-Z0-9_:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g,l;while((l=s.exec(r))!==null){let c=l[1],o=l[2]??l[3]??l[4]??"";i.push({name:c,value:Le(o)})}return{name:n,attributes:i}}function Le(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/ /g," ")}function ae(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function j(e){return ae(e).replace(/"/g,""")}function ce(e){switch(e.nodeType){case 3:return ae(e.data);case 8:return`<!--${e.data}-->`;case 1:return Se(e);default:return""}}function Se(e){let t=e.localName,n=[];for(let s of e.attributeEntries()){if(s.name==="style")continue;n.push(`${s.name}="${j(s.value)}"`)}let i=e.inlineStyleText();if(i)n.push(`style="${j(i)}"`);let r=n.length>0?` ${n.join(" ")}`:"";if(oe.has(t))return`<${t}${r}>`;if(ue.has(t))return`<${t}${r}>${e.textContent}</${t}>`;return`<${t}${r}>${pe(e)}</${t}>`}function pe(e){return e.childList.map((t)=>ce(t)).join("")}function Ce(e){return e.split(",").map((t)=>{let n=[],i=0;while(i<t.length){while(i<t.length&&t[i]===" ")i+=1;if(i>=t.length)break;if(t[i]===">"){n.push({type:"child"}),i+=1;continue}let r=i;while(i<t.length&&t[i]!==" "&&t[i]!==">")i+=1;n.push(de(t.slice(r,i)))}return n})}function de(e){let t=[],n=0;while(n<e.length){let i=e[n];if(i==="*")t.push({type:"universal"}),n+=1;else if(i==="#"){let r=I(e,n+1);t.push({type:"id",id:e.slice(n+1,r)}),n=r}else if(i==="."){let r=I(e,n+1);t.push({type:"class",className:e.slice(n+1,r)}),n=r}else if(i==="["){let r=e.indexOf("]",n),s=e.slice(n+1,r<0?e.length:r).trim(),l=s.match(/^([a-zA-Z_:][a-zA-Z0-9_:.-]*)(?:([~|^$*]?=)(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?$/);if(l)t.push({type:"attribute",name:l[1],operator:l[2],value:l[3]??l[4]??l[5]});else t.push({type:"attribute",name:s});n=r<0?e.length:r+1}else if(i===":"&&e.startsWith(":not(",n)){let r=e.indexOf(")",n),s=e.slice(n+5,r<0?e.length:r);t.push({type:"not",selector:de(s.trim())}),n=r<0?e.length:r+1}else if(i===":"&&e.startsWith(":disabled",n))t.push({type:"attribute",name:"disabled"}),n+=9;else if(/[a-zA-Z_]/.test(i)){let r=I(e,n);t.push({type:"tag",name:e.slice(n,r).toLowerCase()}),n=r}else n+=1}if(t.length===1)return t[0];return{type:"compound",parts:t}}function I(e,t){let n=t;while(n<e.length&&/[a-zA-Z0-9_-]/.test(e[n]))n+=1;return n}function he(e,t){return Ce(t).some((i)=>Oe(e,i))}function Oe(e,t){let n=t.length-1;if(n<0)return!0;if(!N(e,t[n]))return!1;if(n===0)return!0;let i=e.parentElement;n-=1;while(i){let r=t[n];if(!r)return!0;if(r.type==="child"){let s=t[n-1];if(!s||!N(i,s))return!1;if(n-=2,n<0)return!0;i=i.parentElement;continue}if(N(i,r)){if(n-=1,n<0)return!0}i=i.parentElement}return!1}function N(e,t){switch(t.type){case"universal":return!0;case"tag":return e.localName===t.name;case"id":return e.id===t.id;case"class":return e.classList.contains(t.className);case"attribute":return Me(e,t);case"compound":return t.parts.every((n)=>N(e,n));case"not":return!N(e,t.selector);case"child":return!1;default:return!1}}function Me(e,t){let n=e.getAttribute(t.name);if(!t.operator)return n!==null;if(n===null)return!1;let i=t.value??"";switch(t.operator){case"=":return n===i;case"~=":return n.split(/\s+/).includes(i);case"|=":return n===i||n.startsWith(`${i}-`);case"^=":return n.startsWith(i);case"$=":return n.endsWith(i);case"*=":return n.includes(i);default:return!1}}function C(e,t){let n=[];return x(e,(i)=>{if(i!==e&&he(i,t))n.push(i)}),new f(n)}function x(e,t){for(let n of e.childList)if(n.nodeType===1)t(n),x(n,t)}function m(e,t){let n=e.toLowerCase(),i;if(n==="input")i=new U(n);else if(n==="textarea")i=new B(n);else if(n==="select")i=new R(n);else if(n==="option")i=new k(n);else if(n==="button")i=new W(n);else if(n==="style")i=new K(n);else if(n==="a")i=new z(n);else if(n==="img")i=new ee(n);else if(n==="label")i=new J(n);else if(n==="td"||n==="th")i=new Y(n);else i=new p(n);return i.ownerDocument=t,i}function ke(e){let t=e.createElement("html");e.appendChild(t);let n=e.createElement("head"),i=e.createElement("body");t.appendChild(n),t.appendChild(i)}function Re(e){return new Proxy({},{get(n,i){if(typeof i==="symbol")return;return e.getAttribute(`data-${g(i)}`)??void 0},set(n,i,r){if(typeof i==="symbol")return!0;if(r===null||r===void 0)e.removeAttribute(`data-${g(i)}`);else e.setAttribute(`data-${g(i)}`,String(r));return!0},deleteProperty(n,i){if(typeof i!=="symbol")e.removeAttribute(`data-${g(i)}`);return!0},has(n,i){if(typeof i==="symbol")return!1;return e.hasAttribute(`data-${g(i)}`)},ownKeys(){let n=[];for(let i of e.attributeEntries())if(i.name.startsWith("data-"))n.push(Pe(i.name.slice(5)));return n},getOwnPropertyDescriptor(n,i){if(typeof i==="symbol")return;if(e.hasAttribute(`data-${g(i)}`))return{configurable:!0,enumerable:!0,writable:!0,value:e.getAttribute(`data-${g(i)}`)};return}})}function g(e){return e.replace(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function Pe(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}export{T as Comment,V as CustomEvent,q as DOMException,X as DOMTokenList,Ne as DOM_GLOBAL_KEYS,v as Document,P as DocumentFragment,te as DomDOMImplementation,ge as DomNodeType,le as DomWindow,M as Element,a as Event,S as EventTarget,z as HTMLAnchorElement,W as HTMLButtonElement,p as HTMLElement,ee as HTMLImageElement,U as HTMLInputElement,J as HTMLLabelElement,k as HTMLOptionElement,Q as HTMLOptionsCollection,R as HTMLSelectElement,K as HTMLStyleElement,Y as HTMLTableCellElement,B as HTMLTextAreaElement,ie as History,H as KeyboardEvent,ne as Location,O as MouseEvent,Z as NamedNodeMap,se as Navigator,b as Node,f as NodeList,we as ResizeObserver,re as Storage,u as Text,Ie as createDomWindow,ve as createMatchMedia,_ as createStyleDeclaration,Ve as installDomGlobals,Te as parseHtmlFragment};
|
|
2
|
+
|
|
3
|
+
//# debugId=6DCFF74335B6DF6464756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/dom/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * 零依赖最小 DOM 实现。\n *\n * 供 SSR(CLI 项目渲染、docs 静态构建)与测试环境使用,\n * 覆盖 TSone 框架与测试实际依赖的 DOM 面(节点树、事件、CSS 选择器、\n * innerHTML 序列化/解析、history/location/localStorage 等)。\n * 仅面向本项目所需场景,不追求完整浏览器兼容。\n */\n\nexport const enum DomNodeType {\n ELEMENT_NODE = 1,\n TEXT_NODE = 3,\n COMMENT_NODE = 8,\n DOCUMENT_NODE = 9,\n DOCUMENT_FRAGMENT_NODE = 11,\n}\n\nexport class DOMException extends Error {\n public readonly code: number;\n\n constructor(message: string, name = 'Error') {\n super(message);\n this.name = name;\n this.code = 0;\n }\n}\n\ntype EventListenerRecord =\n | ((event: Event) => void)\n | { handleEvent(event: Event): void };\n\ninterface ListenerEntry {\n listener: EventListenerRecord;\n capture: boolean;\n once: boolean;\n passive: boolean;\n}\n\n/**\n * EventTarget 基类:addEventListener / removeEventListener / dispatchEvent。\n */\nexport class EventTarget {\n private readonly listenerMap = new Map<string, ListenerEntry[]>();\n\n public addEventListener(\n type: string,\n listener: EventListenerRecord | null,\n options?: boolean | AddEventListenerOptions\n ): void {\n if (!listener) {\n return;\n }\n const capture =\n typeof options === 'boolean' ? options : (options?.capture ?? false);\n const once = typeof options === 'object' ? (options.once ?? false) : false;\n const passive =\n typeof options === 'object' ? (options.passive ?? false) : false;\n let entries = this.listenerMap.get(type);\n if (!entries) {\n entries = [];\n this.listenerMap.set(type, entries);\n }\n if (\n entries.some(\n (entry) => entry.listener === listener && entry.capture === capture\n )\n ) {\n return;\n }\n entries.push({ listener, capture, once, passive });\n }\n\n public removeEventListener(\n type: string,\n listener: EventListenerRecord | null,\n options?: boolean | EventListenerOptions\n ): void {\n if (!listener) {\n return;\n }\n const capture =\n typeof options === 'boolean' ? options : (options?.capture ?? false);\n const entries = this.listenerMap.get(type);\n if (!entries) {\n return;\n }\n const index = entries.findIndex(\n (entry) => entry.listener === listener && entry.capture === capture\n );\n if (index >= 0) {\n entries.splice(index, 1);\n }\n if (entries.length === 0) {\n this.listenerMap.delete(type);\n }\n }\n\n public dispatchEvent(event: Event): boolean {\n if (!(event instanceof Event)) {\n throw new TypeError('dispatchEvent requires an Event instance');\n }\n if (event.dispatched) {\n throw new Error('Event has already been dispatched');\n }\n return dispatchOnTarget(this, event);\n }\n\n /** @internal 返回本节点的监听器。 */\n public getListeners(type: string): ListenerEntry[] {\n return this.listenerMap.get(type) ?? [];\n }\n}\n\nexport class Event {\n public static readonly NONE = 0;\n public static readonly CAPTURING_PHASE = 1;\n public static readonly AT_TARGET = 2;\n public static readonly BUBBLING_PHASE = 3;\n\n public readonly type: string;\n public readonly bubbles: boolean;\n public readonly cancelable: boolean;\n public readonly composed: boolean;\n public target: EventTarget | null = null;\n public currentTarget: EventTarget | null = null;\n public eventPhase = Event.NONE;\n public defaultPrevented = false;\n public readonly isTrusted = false;\n public readonly timeStamp: number;\n public cancelBubble = false;\n\n /** @internal */\n public dispatched = false;\n /** @internal */\n private propagationStopped = false;\n /** @internal */\n private immediateStopped = false;\n /** @internal */\n private canceled = false;\n\n constructor(type: string, init?: EventInit) {\n this.type = type;\n this.bubbles = init?.bubbles ?? false;\n this.cancelable = init?.cancelable ?? false;\n this.composed = init?.composed ?? false;\n this.timeStamp = Date.now();\n }\n\n public preventDefault(): void {\n if (this.cancelable) {\n this.canceled = true;\n this.defaultPrevented = true;\n }\n }\n\n public stopPropagation(): void {\n this.propagationStopped = true;\n this.cancelBubble = true;\n }\n\n public stopImmediatePropagation(): void {\n this.propagationStopped = true;\n this.immediateStopped = true;\n this.cancelBubble = true;\n }\n\n /** @internal */\n public propagationPrevented(): boolean {\n return this.propagationStopped;\n }\n\n /** @internal */\n public immediatePrevented(): boolean {\n return this.immediateStopped;\n }\n\n /** @internal */\n public wasCanceled(): boolean {\n return this.canceled;\n }\n}\n\nexport class CustomEvent<T = unknown> extends Event {\n public readonly detail: T;\n\n constructor(type: string, init?: CustomEventInit<T>) {\n super(type, init);\n this.detail = init?.detail as T;\n }\n}\n\nexport class MouseEvent extends Event {\n public readonly clientX: number;\n public readonly clientY: number;\n public readonly button: number;\n public readonly buttons: number;\n public readonly relatedTarget: unknown;\n\n constructor(type: string, init?: MouseEventInit) {\n super(type, init);\n this.clientX = init?.clientX ?? 0;\n this.clientY = init?.clientY ?? 0;\n this.button = init?.button ?? 0;\n this.buttons = init?.buttons ?? 0;\n this.relatedTarget = init?.relatedTarget ?? null;\n }\n}\n\nexport class KeyboardEvent extends Event {\n public readonly key: string;\n public readonly code: string;\n public readonly shiftKey: boolean;\n public readonly ctrlKey: boolean;\n public readonly altKey: boolean;\n public readonly metaKey: boolean;\n\n constructor(type: string, init?: KeyboardEventInit) {\n super(type, init);\n this.key = init?.key ?? '';\n this.code = init?.code ?? '';\n this.shiftKey = init?.shiftKey ?? false;\n this.ctrlKey = init?.ctrlKey ?? false;\n this.altKey = init?.altKey ?? false;\n this.metaKey = init?.metaKey ?? false;\n }\n}\n\nfunction invokeListener(listener: ListenerEntry, event: Event): void {\n const record = listener.listener;\n if (typeof record === 'function') {\n record.call(event.currentTarget, event);\n } else {\n record.handleEvent(event);\n }\n}\n\nfunction dispatchOnTarget(target: EventTarget, event: Event): boolean {\n event.dispatched = true;\n event.target = target;\n\n const chain = buildEventPath(target);\n const capturePath = [...chain].reverse();\n const targetIndex = capturePath.length - 1;\n\n event.eventPhase = Event.CAPTURING_PHASE;\n for (let index = 0; index < targetIndex; index += 1) {\n const current = capturePath[index];\n if (event.propagationPrevented()) {\n break;\n }\n event.currentTarget = current;\n runListeners(current, event, true);\n }\n\n if (!event.propagationPrevented()) {\n event.eventPhase = Event.AT_TARGET;\n event.currentTarget = target;\n runListeners(target, event, true);\n if (!event.immediatePrevented()) {\n runListeners(target, event, false);\n }\n }\n\n if (event.bubbles && !event.propagationPrevented()) {\n event.eventPhase = Event.BUBBLING_PHASE;\n for (let index = capturePath.length - 2; index >= 0; index -= 1) {\n const current = capturePath[index];\n if (event.propagationPrevented()) {\n break;\n }\n event.currentTarget = current;\n runListeners(current, event, false);\n }\n }\n\n event.eventPhase = Event.NONE;\n event.currentTarget = null;\n return !event.wasCanceled();\n}\n\nfunction runListeners(\n target: EventTarget,\n event: Event,\n capture: boolean\n): void {\n const listeners = target.getListeners(event.type);\n for (const entry of [...listeners]) {\n if (entry.capture !== capture) {\n continue;\n }\n if (event.immediatePrevented()) {\n break;\n }\n if (entry.once) {\n target.removeEventListener(event.type, entry.listener, {\n capture: entry.capture,\n });\n }\n invokeListener(entry, event);\n }\n}\n\nfunction buildEventPath(target: EventTarget): EventTarget[] {\n const path: EventTarget[] = [];\n let current: EventTarget | null = target;\n while (current) {\n path.push(current);\n const node = current as unknown as Node;\n if (node.nodeType === DomNodeType.DOCUMENT_NODE) {\n const view = (node as Document).defaultView;\n if (view) {\n path.push(view);\n }\n break;\n }\n const parent = node.parentNode;\n if (parent) {\n current = parent;\n continue;\n }\n break;\n }\n return path;\n}\n\nexport class DOMTokenList implements Iterable<string> {\n private readonly element: Element;\n private readonly attributeName: string;\n\n constructor(element: Element, attributeName = 'class') {\n this.element = element;\n this.attributeName = attributeName;\n }\n\n public get length(): number {\n return this.tokens().length;\n }\n\n public get value(): string {\n return this.element.getAttribute(this.attributeName) ?? '';\n }\n\n public set value(value: string) {\n this.setTokens(splitTokens(value));\n }\n\n public item(index: number): string | null {\n return this.tokens()[index] ?? null;\n }\n\n public contains(token: string): boolean {\n return this.tokens().includes(token);\n }\n\n public add(...tokens: string[]): void {\n const current = new Set(this.tokens());\n for (const token of tokens) {\n if (token) {\n current.add(token);\n }\n }\n this.setTokens([...current]);\n }\n\n public remove(...tokens: string[]): void {\n const current = new Set(this.tokens());\n for (const token of tokens) {\n current.delete(token);\n }\n this.setTokens([...current]);\n }\n\n public toggle(token: string, force?: boolean): boolean {\n const current = new Set(this.tokens());\n const shouldAdd = force ?? !current.has(token);\n if (shouldAdd) {\n current.add(token);\n } else {\n current.delete(token);\n }\n this.setTokens([...current]);\n return shouldAdd;\n }\n\n public replace(oldToken: string, newToken: string): boolean {\n const current = this.tokens();\n const index = current.indexOf(oldToken);\n if (index < 0) {\n return false;\n }\n current[index] = newToken;\n this.setTokens(current);\n return true;\n }\n\n public [Symbol.iterator](): Iterator<string> {\n return this.tokens()[Symbol.iterator]();\n }\n\n public forEach(\n callback: (value: string, index: number, list: DOMTokenList) => void\n ): void {\n this.tokens().forEach((value, index) => callback(value, index, this));\n }\n\n public toString(): string {\n return this.value;\n }\n\n private tokens(): string[] {\n return splitTokens(this.element.getAttribute(this.attributeName) ?? '');\n }\n\n private setTokens(tokens: string[]): void {\n const value = tokens.filter(Boolean).join(' ');\n if (value) {\n this.element.setAttribute(this.attributeName, value);\n } else {\n this.element.removeAttribute(this.attributeName);\n }\n }\n}\n\nfunction splitTokens(value: string): string[] {\n return value.trim().split(/\\s+/).filter(Boolean);\n}\n\nfunction normalizeCssProperty(property: string): string {\n return property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\n}\n\ninterface StyleTarget {\n properties: Map<string, { value: string; priority: string }>;\n setProperty(property: string, value: string, priority?: string): void;\n getPropertyValue(property: string): string;\n getPropertyPriority(property: string): string;\n removeProperty(property: string): string;\n item(index: number): string;\n readonly length: number;\n cssText: string;\n}\n\n/**\n * 创建 CSSStyleDeclaration 代理,支持任意 camelCase 属性访问与赋值。\n */\nexport function createStyleDeclaration(): CSSStyleDeclaration {\n const properties = new Map<string, { value: string; priority: string }>();\n\n const target: StyleTarget = {\n properties,\n\n setProperty(property: string, value: string, priority = ''): void {\n const name = normalizeCssProperty(property);\n if (value === '') {\n properties.delete(name);\n } else {\n properties.set(name, { value, priority });\n }\n },\n\n getPropertyValue(property: string): string {\n return properties.get(normalizeCssProperty(property))?.value ?? '';\n },\n\n getPropertyPriority(property: string): string {\n return properties.get(normalizeCssProperty(property))?.priority ?? '';\n },\n\n removeProperty(property: string): string {\n const name = normalizeCssProperty(property);\n const previous = properties.get(name)?.value ?? '';\n properties.delete(name);\n return previous;\n },\n\n item(index: number): string {\n return [...properties.keys()][index] ?? '';\n },\n\n get length(): number {\n return properties.size;\n },\n\n get cssText(): string {\n return [...properties.entries()]\n .map(\n ([name, entry]) =>\n `${name}: ${entry.value}${entry.priority ? ` ${entry.priority}` : ''};`\n )\n .join(' ');\n },\n\n set cssText(value: string) {\n properties.clear();\n for (const declaration of value.split(';')) {\n const trimmed = declaration.trim();\n if (!trimmed) {\n continue;\n }\n const separator = trimmed.indexOf(':');\n if (separator < 0) {\n continue;\n }\n const name = trimmed.slice(0, separator).trim();\n const propertyValue = trimmed.slice(separator + 1).trim();\n if (name) {\n target.setProperty(name, propertyValue);\n }\n }\n },\n };\n\n const handler: ProxyHandler<StyleTarget> = {\n get(t, property, receiver) {\n if (typeof property === 'symbol') {\n return Reflect.get(t, property, receiver);\n }\n if (property in t) {\n const value = Reflect.get(t, property, receiver);\n return typeof value === 'function' ? value.bind(t) : value;\n }\n return t.getPropertyValue(property);\n },\n set(t, property, value, receiver) {\n if (typeof property === 'symbol') {\n return Reflect.set(t, property, value, receiver);\n }\n if (property in t) {\n return Reflect.set(t, property, value, receiver);\n }\n t.setProperty(property, String(value));\n return true;\n },\n has(t, property) {\n if (typeof property === 'symbol') {\n return Reflect.has(t, property);\n }\n if (property in t) {\n return true;\n }\n return t.getPropertyValue(property) !== '';\n },\n ownKeys() {\n return [\n ...Reflect.ownKeys(target),\n ...[...properties.keys()].map((name) => camelCaseProperty(name)),\n ];\n },\n getOwnPropertyDescriptor(t, property) {\n if (typeof property === 'symbol') {\n return Reflect.getOwnPropertyDescriptor(t, property);\n }\n if (property in t) {\n return Reflect.getOwnPropertyDescriptor(t, property);\n }\n const value = t.getPropertyValue(property);\n if (value !== '') {\n return { configurable: true, enumerable: true, writable: true, value };\n }\n return undefined;\n },\n };\n\n return new Proxy(target, handler) as unknown as CSSStyleDeclaration;\n}\n\nfunction camelCaseProperty(property: string): string {\n return property.replace(/-([a-z])/g, (_match, char: string) =>\n char.toUpperCase()\n );\n}\n\n/**\n * 类数组节点列表:支持 .length、.item()、数值索引与迭代。\n */\nexport class NodeList<T extends Node = Node> implements Iterable<T> {\n /** @internal */\n private readonly items: T[];\n\n constructor(items: T[] = []) {\n this.items = items;\n for (let index = 0; index < items.length; index += 1) {\n Object.defineProperty(this, String(index), {\n configurable: true,\n enumerable: true,\n get: () => this.items[index],\n });\n }\n }\n\n public get length(): number {\n return this.items.length;\n }\n\n public item(index: number): T | null {\n return this.items[index] ?? null;\n }\n\n public [Symbol.iterator](): Iterator<T> {\n return this.items[Symbol.iterator]();\n }\n\n public forEach(\n callback: (value: T, index: number, list: NodeList<T>) => void\n ): void {\n this.items.forEach((value, index) => callback(value, index, this));\n }\n\n public entries(): IterableIterator<[number, T]> {\n return this.items.entries();\n }\n\n public keys(): IterableIterator<number> {\n return this.items.keys();\n }\n\n public values(): IterableIterator<T> {\n return this.items.values();\n }\n\n public toArray(): T[] {\n return [...this.items];\n }\n}\n\n/**\n * Node 基类:节点树、父子关系、文本内容。\n */\nexport class Node extends EventTarget {\n public static readonly ELEMENT_NODE = DomNodeType.ELEMENT_NODE;\n public static readonly TEXT_NODE = DomNodeType.TEXT_NODE;\n public static readonly COMMENT_NODE = DomNodeType.COMMENT_NODE;\n public static readonly DOCUMENT_NODE = DomNodeType.DOCUMENT_NODE;\n public static readonly DOCUMENT_FRAGMENT_NODE =\n DomNodeType.DOCUMENT_FRAGMENT_NODE;\n\n public readonly nodeType: number;\n public readonly nodeName: string;\n public parentNode: Node | null = null;\n public ownerDocument: Document | null = null;\n\n /** @internal */\n public childList: Node[] = [];\n\n constructor(nodeType: number, nodeName: string) {\n super();\n this.nodeType = nodeType;\n this.nodeName = nodeName;\n }\n\n public get parentElement(): Element | null {\n const parent = this.parentNode;\n return parent instanceof Element ? parent : null;\n }\n\n public get childNodes(): NodeList<Node> {\n return new NodeList([...this.childList]);\n }\n\n public get firstChild(): Node | null {\n return this.childList[0] ?? null;\n }\n\n public get lastChild(): Node | null {\n return this.childList[this.childList.length - 1] ?? null;\n }\n\n public get nextSibling(): Node | null {\n const parent = this.parentNode;\n if (!parent) {\n return null;\n }\n const index = parent.childList.indexOf(this);\n return index >= 0 ? (parent.childList[index + 1] ?? null) : null;\n }\n\n public get previousSibling(): Node | null {\n const parent = this.parentNode;\n if (!parent) {\n return null;\n }\n const index = parent.childList.indexOf(this);\n return index > 0 ? parent.childList[index - 1] : null;\n }\n\n public get textContent(): string {\n let text = '';\n for (const child of this.childList) {\n if (child.nodeType === DomNodeType.TEXT_NODE) {\n text += (child as Text).data;\n } else if (child.nodeType === DomNodeType.ELEMENT_NODE) {\n text += child.textContent;\n }\n }\n return text;\n }\n\n public set textContent(value: string) {\n this.childList = [];\n if (value) {\n const textNode = new Text(value);\n textNode.ownerDocument = this.ownerDocument;\n textNode.parentNode = this;\n this.childList.push(textNode);\n }\n }\n\n public hasChildNodes(): boolean {\n return this.childList.length > 0;\n }\n\n public appendChild<T extends Node>(node: T): T {\n if (node === (this as Node)) {\n throw new Error('Cannot append a node to itself');\n }\n this.insertBefore(node, null);\n return node;\n }\n\n public insertBefore<T extends Node>(node: T, reference: Node | null): T {\n if (node === (this as Node)) {\n throw new Error('Cannot insert a node before itself');\n }\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n node.parentNode = this;\n if (node.ownerDocument === null) {\n node.ownerDocument = this.ownerDocument;\n }\n if (reference === null) {\n this.childList.push(node);\n return node;\n }\n const index = this.childList.indexOf(reference);\n if (index < 0) {\n throw new Error('Reference node is not a child of this node');\n }\n this.childList.splice(index, 0, node);\n return node;\n }\n\n public removeChild<T extends Node>(node: T): T {\n const index = this.childList.indexOf(node);\n if (index < 0) {\n throw new Error('Node is not a child of this node');\n }\n this.childList.splice(index, 1);\n node.parentNode = null;\n return node;\n }\n\n public replaceChild<T extends Node>(newChild: T, oldChild: Node): T {\n const index = this.childList.indexOf(oldChild);\n if (index < 0) {\n throw new Error('Old child is not a child of this node');\n }\n if (newChild.parentNode) {\n newChild.parentNode.removeChild(newChild);\n }\n newChild.parentNode = this;\n if (newChild.ownerDocument === null) {\n newChild.ownerDocument = this.ownerDocument;\n }\n this.childList[index] = newChild;\n oldChild.parentNode = null;\n return newChild;\n }\n\n public replaceChildren(...nodes: Node[]): void {\n for (const child of [...this.childList]) {\n this.removeChild(child);\n }\n for (const node of nodes) {\n this.appendChild(node);\n }\n }\n\n public contains(node: Node | null): boolean {\n if (!node) {\n return false;\n }\n let current: Node | null = node;\n while (current) {\n if (current === this) {\n return true;\n }\n current = current.parentNode;\n }\n return false;\n }\n\n public remove(): void {\n this.parentNode?.removeChild(this);\n }\n\n public cloneNode(deep = false): Node {\n const clone = this.createClone();\n if (deep) {\n for (const child of this.childList) {\n clone.appendChild(child.cloneNode(true) as Node);\n }\n }\n return clone;\n }\n\n /** @internal */\n protected createClone(): Node {\n const clone = new Node(this.nodeType, this.nodeName);\n clone.ownerDocument = this.ownerDocument;\n return clone;\n }\n\n public getRootNode(): Node {\n if (!this.parentNode) {\n return this;\n }\n let parent = this.parentNode;\n while (parent.parentNode) {\n parent = parent.parentNode;\n }\n return parent;\n }\n\n public get isConnected(): boolean {\n return this.getRootNode().nodeType === DomNodeType.DOCUMENT_NODE;\n }\n}\n\n/**\n * Element:标签节点。\n */\nexport class Element extends Node {\n public readonly namespaceURI: string | null;\n\n /** @internal */\n private readonly attributeList: Array<{ name: string; value: string }> = [];\n /** @internal */\n private styleValue: CSSStyleDeclaration | undefined;\n /** @internal */\n private classListValue: DOMTokenList | undefined;\n /** @internal */\n private datasetProxy: Record<string, string> | undefined;\n\n constructor(tagName: string, namespaceURI: string | null = null) {\n super(DomNodeType.ELEMENT_NODE, tagName.toUpperCase());\n this.namespaceURI = namespaceURI;\n }\n\n public get tagName(): string {\n return this.nodeName;\n }\n\n public get localName(): string {\n return this.nodeName.toLowerCase();\n }\n\n public get id(): string {\n return this.getAttribute('id') ?? '';\n }\n\n public set id(value: string) {\n this.setAttribute('id', value);\n }\n\n public get className(): string {\n return this.getAttribute('class') ?? '';\n }\n\n public set className(value: string) {\n this.setAttribute('class', value);\n }\n\n public get classList(): DOMTokenList {\n if (!this.classListValue) {\n this.classListValue = new DOMTokenList(this, 'class');\n }\n return this.classListValue;\n }\n\n public get style(): CSSStyleDeclaration {\n if (!this.styleValue) {\n this.styleValue = createStyleDeclaration();\n }\n return this.styleValue;\n }\n\n public get dataset(): Record<string, string> {\n if (!this.datasetProxy) {\n this.datasetProxy = createDatasetProxy(this);\n }\n return this.datasetProxy;\n }\n\n public get children(): NodeList<Element> {\n return new NodeList(\n this.childList.filter(\n (child): child is Element => child.nodeType === DomNodeType.ELEMENT_NODE\n )\n );\n }\n\n public get firstElementChild(): Element | null {\n return this.children.item(0);\n }\n\n public get lastElementChild(): Element | null {\n return this.children.item(this.children.length - 1);\n }\n\n public get childElementCount(): number {\n return this.children.length;\n }\n\n public get attributes(): NamedNodeMap {\n return new NamedNodeMap(this);\n }\n\n public getAttribute(name: string): string | null {\n const entry = this.findAttribute(name);\n return entry ? entry.value : null;\n }\n\n public getAttributeNames(): string[] {\n return this.attributeList.map((entry) => entry.name);\n }\n\n public setAttribute(name: string, value: unknown): void {\n const stringValue = String(value);\n if (name === 'style') {\n this.styleValue = createStyleDeclaration();\n this.styleValue.cssText = stringValue;\n }\n const entry = this.findAttribute(name);\n if (entry) {\n entry.value = stringValue;\n } else {\n this.attributeList.push({ name, value: stringValue });\n }\n }\n\n public removeAttribute(name: string): void {\n if (name === 'style') {\n this.styleValue = createStyleDeclaration();\n }\n const index = this.attributeList.findIndex((entry) => entry.name === name);\n if (index >= 0) {\n this.attributeList.splice(index, 1);\n }\n }\n\n public hasAttribute(name: string): boolean {\n return this.findAttribute(name) !== undefined;\n }\n\n public toggleAttribute(name: string, force?: boolean): boolean {\n const shouldAdd = force ?? !this.hasAttribute(name);\n if (shouldAdd) {\n this.setAttribute(name, '');\n } else {\n this.removeAttribute(name);\n }\n return shouldAdd;\n }\n\n public hasAttributes(): boolean {\n return this.attributeList.length > 0;\n }\n\n public get innerHTML(): string {\n return serializeChildren(this);\n }\n\n public set innerHTML(value: string) {\n this.replaceChildren(...parseHtmlFragment(value, this.ownerDocument));\n }\n\n public get outerHTML(): string {\n return serializeNode(this);\n }\n\n public get value(): string {\n return this.getAttribute('value') ?? '';\n }\n\n public set value(value: string) {\n this.setAttribute('value', value);\n }\n\n public querySelector(selector: string): Element | null {\n return querySelectorAll(this, selector).item(0);\n }\n\n public querySelectorAll(selector: string): NodeList<Element> {\n return querySelectorAll(this, selector);\n }\n\n public getElementsByTagName(tagName: string): NodeList<Element> {\n const lowered = tagName.toLowerCase();\n const results: Element[] = [];\n collectElements(this, (element) => {\n if (element.localName === lowered) {\n results.push(element);\n }\n });\n return new NodeList(results);\n }\n\n public matches(selector: string): boolean {\n return matchSelector(this, selector);\n }\n\n public closest(selector: string): Element | null {\n if (this.matches(selector)) {\n return this;\n }\n let parent = this.parentElement;\n while (parent) {\n if (parent.matches(selector)) {\n return parent;\n }\n parent = parent.parentElement;\n }\n return null;\n }\n\n public getBoundingClientRect(): DOMRect {\n const view = this.ownerDocument?.defaultView;\n // 无排版引擎时 body/documentElement 的边界即视口,给默认视口尺寸\n const width = view?.innerWidth ?? 1024;\n const height = view?.innerHeight ?? 768;\n const current = this as unknown as HTMLElement;\n const viewport =\n current === this.ownerDocument?.body ||\n current === this.ownerDocument?.documentElement;\n return {\n x: 0,\n y: 0,\n top: 0,\n left: 0,\n right: viewport ? width : 0,\n bottom: viewport ? height : 0,\n width: viewport ? width : 0,\n height: viewport ? height : 0,\n toJSON(): Record<string, number> {\n return {\n x: 0,\n y: 0,\n top: 0,\n left: 0,\n right: viewport ? width : 0,\n bottom: viewport ? height : 0,\n width: viewport ? width : 0,\n height: viewport ? height : 0,\n };\n },\n };\n }\n\n public scrollIntoView(): void {}\n\n public focus(): void {\n this.ownerDocument?.setActiveElement(this);\n }\n\n public blur(): void {\n if (this.ownerDocument?.activeElement === this) {\n this.ownerDocument.setActiveElement(null);\n }\n }\n\n public click(): void {\n // 禁用态表单控件不派发 click(真实浏览器行为)\n const candidate = this as unknown as { disabled?: boolean };\n if (candidate.disabled === true) {\n return;\n }\n this.dispatchEvent(\n new MouseEvent('click', { bubbles: true, cancelable: true })\n );\n // 表单按钮默认行为:type=reset 的按钮点击触发表单 reset 事件\n if (\n this.tagName === 'BUTTON' &&\n this.getAttribute('type') === 'reset' &&\n this.isConnected\n ) {\n this.closest('form')?.dispatchEvent(\n new Event('reset', { bubbles: true, cancelable: true })\n );\n }\n }\n\n public append(...nodes: (Node | string)[]): void {\n for (const node of nodes) {\n if (typeof node === 'string') {\n const textNode = new Text(node);\n textNode.ownerDocument = this.ownerDocument;\n this.appendChild(textNode);\n } else {\n this.appendChild(node);\n }\n }\n }\n\n public prepend(...nodes: (Node | string)[]): void {\n const reference = this.firstChild;\n for (const node of nodes) {\n if (typeof node === 'string') {\n const textNode = new Text(node);\n textNode.ownerDocument = this.ownerDocument;\n this.insertBefore(textNode, reference);\n } else {\n this.insertBefore(node, reference);\n }\n }\n }\n\n public before(...nodes: (Node | string)[]): void {\n const parent = this.parentNode;\n if (!parent) {\n return;\n }\n for (const node of nodes) {\n if (typeof node === 'string') {\n const textNode = new Text(node);\n textNode.ownerDocument = this.ownerDocument;\n parent.insertBefore(textNode, this);\n } else {\n parent.insertBefore(node, this);\n }\n }\n }\n\n public after(...nodes: (Node | string)[]): void {\n const parent = this.parentNode;\n if (!parent) {\n return;\n }\n const reference = this.nextSibling;\n for (const node of nodes) {\n if (typeof node === 'string') {\n const textNode = new Text(node);\n textNode.ownerDocument = this.ownerDocument;\n parent.insertBefore(textNode, reference);\n } else {\n parent.insertBefore(node, reference);\n }\n }\n }\n\n public replaceWith(...nodes: (Node | string)[]): void {\n const parent = this.parentNode;\n if (!parent) {\n return;\n }\n const reference = this.nextSibling;\n parent.removeChild(this);\n for (const node of nodes) {\n if (typeof node === 'string') {\n const textNode = new Text(node);\n textNode.ownerDocument = this.ownerDocument;\n parent.insertBefore(textNode, reference);\n } else {\n parent.insertBefore(node, reference);\n }\n }\n }\n\n public setAttributeNS(\n _namespace: string,\n name: string,\n value: unknown\n ): void {\n this.setAttribute(name, value);\n }\n\n public removeAttributeNS(_namespace: string, name: string): void {\n this.removeAttribute(name);\n }\n\n public hasAttributeNS(_namespace: string, name: string): boolean {\n return this.hasAttribute(name);\n }\n\n public getAttributeNS(_namespace: string, name: string): string | null {\n return this.getAttribute(name);\n }\n\n /** @internal */\n public findAttribute(\n name: string\n ): { name: string; value: string } | undefined {\n return this.attributeList.find((entry) => entry.name === name);\n }\n\n /** @internal */\n public attributeEntries(): Array<{ name: string; value: string }> {\n return [...this.attributeList];\n }\n\n /** @internal 供序列化读取内联样式。 */\n public inlineStyleText(): string {\n return this.styleValue?.cssText ?? '';\n }\n\n /** @internal */\n protected createClone(): Node {\n const clone = createElementForTag(this.localName, this.ownerDocument);\n for (const entry of this.attributeList) {\n clone.setAttribute(entry.name, entry.value);\n }\n return clone;\n }\n}\n\nexport class HTMLElement extends Element {\n constructor(tagName: string) {\n super(tagName);\n }\n\n /** 页面语言(属性反射,无值回退空串)。 */\n public get lang(): string {\n return this.getAttribute('lang') ?? '';\n }\n\n public set lang(value: string) {\n this.setAttribute('lang', value);\n }\n\n /** 是否隐藏(布尔属性反射)。 */\n public get hidden(): boolean {\n return this.hasAttribute('hidden');\n }\n\n public set hidden(value: boolean) {\n if (value) {\n this.setAttribute('hidden', '');\n } else {\n this.removeAttribute('hidden');\n }\n }\n\n /** 键盘焦点顺序(数字属性反射;0 表示按文档顺序)。 */\n public get tabIndex(): number {\n const raw = this.getAttribute('tabindex');\n return raw === null ? 0 : Number(raw);\n }\n\n public set tabIndex(value: number) {\n if (value === 0) {\n this.removeAttribute('tabindex');\n } else {\n this.setAttribute('tabindex', String(value));\n }\n }\n\n /** 布局尺寸与偏移;无排版引擎时恒为 0,测试可覆盖 getBoundingClientRect。 */\n public get offsetWidth(): number {\n return 0;\n }\n\n public get offsetHeight(): number {\n return 0;\n }\n\n public get offsetLeft(): number {\n return 0;\n }\n\n public get offsetTop(): number {\n return 0;\n }\n}\n\nexport class NamedNodeMap implements Iterable<{ name: string; value: string }> {\n private readonly element: Element;\n\n constructor(element: Element) {\n this.element = element;\n for (let index = 0; index < element.attributeEntries().length; index += 1) {\n Object.defineProperty(this, String(index), {\n configurable: true,\n enumerable: true,\n get: () => this.element.attributeEntries()[index] ?? null,\n });\n }\n }\n\n public get length(): number {\n return this.element.attributeEntries().length;\n }\n\n public item(index: number): { name: string; value: string } | null {\n return this.element.attributeEntries()[index] ?? null;\n }\n\n public getNamedItem(name: string): { name: string; value: string } | null {\n return this.element.findAttribute(name) ?? null;\n }\n\n public setNamedItem(attr: { name: string; value: string }): void {\n this.element.setAttribute(attr.name, attr.value);\n }\n\n public removeNamedItem(name: string): void {\n this.element.removeAttribute(name);\n }\n\n public [Symbol.iterator](): Iterator<{ name: string; value: string }> {\n return this.element.attributeEntries()[Symbol.iterator]();\n }\n}\n\nexport class HTMLOptionElement extends HTMLElement {\n /** @internal */\n private selectedValue: boolean | undefined;\n\n constructor(tagName = 'option') {\n super(tagName);\n }\n\n public get value(): string {\n return this.getAttribute('value') ?? this.textContent;\n }\n\n public set value(value: string) {\n this.setAttribute('value', value);\n }\n\n public get text(): string {\n return this.textContent;\n }\n\n public get label(): string {\n return this.getAttribute('label') ?? this.textContent;\n }\n\n public get selected(): boolean {\n return this.hasSelectedValue();\n }\n\n public set selected(value: boolean) {\n this.setSelectedRaw(value);\n if (value) {\n const select = this.parentElement;\n if (select instanceof HTMLSelectElement && !select.multiple) {\n for (const option of select.options.toArray()) {\n if (option !== this) {\n option.setSelectedRaw(false);\n }\n }\n }\n }\n }\n\n /** @internal */\n public setSelectedRaw(value: boolean): void {\n this.selectedValue = value;\n if (value) {\n this.setAttribute('selected', '');\n } else {\n this.removeAttribute('selected');\n }\n }\n\n /** @internal */\n public hasSelectedValue(): boolean {\n if (this.selectedValue !== undefined) {\n return this.selectedValue;\n }\n return this.hasAttribute('selected');\n }\n}\n\nexport class HTMLSelectElement extends HTMLElement {\n constructor(tagName = 'select') {\n super(tagName);\n }\n\n public get disabled(): boolean {\n return this.hasAttribute('disabled');\n }\n\n public set disabled(value: boolean) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n public get multiple(): boolean {\n return this.hasAttribute('multiple');\n }\n\n public set multiple(value: boolean) {\n if (value) {\n this.setAttribute('multiple', '');\n } else {\n this.removeAttribute('multiple');\n }\n }\n\n public get options(): HTMLOptionsCollection {\n const options: HTMLOptionElement[] = [];\n collectElements(this, (element) => {\n if (element instanceof HTMLOptionElement) {\n options.push(element);\n }\n });\n return new HTMLOptionsCollection(options);\n }\n\n public get selectedOptions(): NodeList<HTMLOptionElement> {\n return new NodeList(\n this.options.toArray().filter((option) => option.hasSelectedValue())\n );\n }\n\n public get selectedIndex(): number {\n return this.options\n .toArray()\n .findIndex((option) => option.hasSelectedValue());\n }\n\n public set selectedIndex(index: number) {\n const options = this.options.toArray();\n options.forEach((option, optionIndex) =>\n option.setSelectedRaw(optionIndex === index)\n );\n }\n\n public get value(): string {\n const options = this.options.toArray();\n const selected = options.find((option) => option.hasSelectedValue());\n if (selected) {\n return selected.value;\n }\n if (!this.multiple && options.length > 0) {\n return options[0].value;\n }\n return '';\n }\n\n public set value(value: string) {\n const options = this.options.toArray();\n for (const option of options) {\n const shouldSelect = option.value === value;\n if (shouldSelect) {\n if (this.multiple) {\n option.setSelectedRaw(true);\n } else {\n for (const other of options) {\n other.setSelectedRaw(other === option);\n }\n return;\n }\n }\n }\n }\n\n public add(option: HTMLOptionElement): void {\n this.appendChild(option);\n }\n\n public removeOption(index: number): void {\n const options = this.options.toArray();\n const option = options[index];\n if (option) {\n option.remove();\n }\n }\n}\n\nexport class HTMLOptionsCollection implements Iterable<HTMLOptionElement> {\n private readonly items: HTMLOptionElement[];\n\n constructor(items: HTMLOptionElement[]) {\n this.items = items;\n for (let index = 0; index < items.length; index += 1) {\n Object.defineProperty(this, String(index), {\n configurable: true,\n enumerable: true,\n get: () => this.items[index],\n });\n }\n }\n\n public get length(): number {\n return this.items.length;\n }\n\n public item(index: number): HTMLOptionElement | null {\n return this.items[index] ?? null;\n }\n\n public get value(): string {\n return this.items.find((option) => option.hasSelectedValue())?.value ?? '';\n }\n\n public get selectedIndex(): number {\n return this.items.findIndex((option) => option.hasSelectedValue());\n }\n\n public toArray(): HTMLOptionElement[] {\n return [...this.items];\n }\n\n public [Symbol.iterator](): Iterator<HTMLOptionElement> {\n return this.items[Symbol.iterator]();\n }\n}\n\nexport class HTMLInputElement extends HTMLElement {\n /** @internal */\n private inputValue: string | undefined;\n /** @internal */\n private checkedValue: boolean | undefined;\n\n constructor(tagName = 'input') {\n super(tagName);\n }\n\n public get type(): string {\n return this.getAttribute('type') ?? 'text';\n }\n\n public set type(value: string) {\n this.setAttribute('type', value);\n }\n\n public get name(): string {\n return this.getAttribute('name') ?? '';\n }\n\n public set name(value: string) {\n this.setAttribute('name', value);\n }\n\n public get value(): string {\n return this.inputValue ?? this.getAttribute('value') ?? '';\n }\n\n public set value(value: string) {\n this.inputValue = value;\n }\n\n public get defaultValue(): string {\n return this.getAttribute('value') ?? '';\n }\n\n public get checked(): boolean {\n return this.checkedValue ?? this.hasAttribute('checked');\n }\n\n public set checked(value: boolean) {\n this.checkedValue = value;\n }\n\n public get disabled(): boolean {\n return this.hasAttribute('disabled');\n }\n\n public set disabled(value: boolean) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n public get placeholder(): string {\n return this.getAttribute('placeholder') ?? '';\n }\n\n public set placeholder(value: string) {\n this.setAttribute('placeholder', value);\n }\n\n public get accept(): string {\n return this.getAttribute('accept') ?? '';\n }\n\n public get multiple(): boolean {\n return this.hasAttribute('multiple');\n }\n\n public set multiple(value: boolean) {\n if (value) {\n this.setAttribute('multiple', '');\n } else {\n this.removeAttribute('multiple');\n }\n }\n\n public set accept(value: string) {\n this.setAttribute('accept', value);\n }\n\n public get min(): string {\n return this.getAttribute('min') ?? '';\n }\n\n public set min(value: string) {\n this.setAttribute('min', value);\n }\n\n public get max(): string {\n return this.getAttribute('max') ?? '';\n }\n\n public set max(value: string) {\n this.setAttribute('max', value);\n }\n\n public get step(): string {\n return this.getAttribute('step') ?? '';\n }\n\n public set step(value: string) {\n this.setAttribute('step', value);\n }\n\n /** @internal */\n protected createClone(): Node {\n const clone = super.createClone() as HTMLInputElement;\n clone.inputValue = this.inputValue;\n clone.checkedValue = this.checkedValue;\n return clone;\n }\n}\n\nexport class HTMLTextAreaElement extends HTMLElement {\n /** @internal */\n private textareaValue: string | undefined;\n\n constructor(tagName = 'textarea') {\n super(tagName);\n }\n\n public get value(): string {\n return this.textareaValue ?? this.textContent;\n }\n\n public set value(value: string) {\n this.textareaValue = value;\n }\n\n public get name(): string {\n return this.getAttribute('name') ?? '';\n }\n\n public set name(value: string) {\n this.setAttribute('name', value);\n }\n\n public get disabled(): boolean {\n return this.hasAttribute('disabled');\n }\n\n public set disabled(value: boolean) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n public get placeholder(): string {\n return this.getAttribute('placeholder') ?? '';\n }\n\n public set placeholder(value: string) {\n this.setAttribute('placeholder', value);\n }\n}\n\nexport class HTMLButtonElement extends HTMLElement {\n constructor(tagName = 'button') {\n super(tagName);\n }\n\n public get disabled(): boolean {\n return this.hasAttribute('disabled');\n }\n\n public set disabled(value: boolean) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n public get type(): string {\n return this.getAttribute('type') ?? 'submit';\n }\n}\n\nexport class HTMLTableCellElement extends HTMLElement {\n constructor(tagName = 'td') {\n super(tagName);\n }\n\n public get colSpan(): number {\n const raw = this.getAttribute('colspan');\n return raw === null ? 1 : Number(raw);\n }\n\n public set colSpan(value: number) {\n this.setAttribute('colspan', String(value));\n }\n}\n\nexport class HTMLLabelElement extends HTMLElement {\n constructor(tagName = 'label') {\n super(tagName);\n }\n\n public get htmlFor(): string {\n return this.getAttribute('for') ?? '';\n }\n\n public set htmlFor(value: string) {\n this.setAttribute('for', value);\n }\n}\n\nexport class HTMLImageElement extends HTMLElement {\n constructor(tagName = 'img') {\n super(tagName);\n }\n\n public get src(): string {\n return this.getAttribute('src') ?? '';\n }\n\n public set src(value: string) {\n this.setAttribute('src', value);\n }\n\n public get alt(): string {\n return this.getAttribute('alt') ?? '';\n }\n\n public set alt(value: string) {\n this.setAttribute('alt', value);\n }\n}\n\nexport class HTMLStyleElement extends HTMLElement {\n constructor(tagName = 'style') {\n super(tagName);\n }\n}\n\nexport class HTMLAnchorElement extends HTMLElement {\n constructor(tagName = 'a') {\n super(tagName);\n }\n\n public get href(): string {\n return this.getAttribute('href') ?? '';\n }\n\n public set href(value: string) {\n this.setAttribute('href', value);\n }\n}\n\nexport class Text extends Node {\n public data: string;\n\n constructor(data = '') {\n super(DomNodeType.TEXT_NODE, '#text');\n this.data = data;\n }\n\n public get nodeValue(): string {\n return this.data;\n }\n\n public set nodeValue(value: string) {\n this.data = value;\n }\n\n public get textContent(): string {\n return this.data;\n }\n\n public set textContent(value: string) {\n this.data = value;\n }\n\n public get wholeText(): string {\n return this.data;\n }\n\n /** @internal */\n protected createClone(): Node {\n const clone = new Text(this.data);\n clone.ownerDocument = this.ownerDocument;\n return clone;\n }\n}\n\nexport class Comment extends Node {\n public data: string;\n\n constructor(data = '') {\n super(DomNodeType.COMMENT_NODE, '#comment');\n this.data = data;\n }\n\n public get nodeValue(): string {\n return this.data;\n }\n\n public set nodeValue(value: string) {\n this.data = value;\n }\n\n /** @internal */\n protected createClone(): Node {\n const clone = new Comment(this.data);\n clone.ownerDocument = this.ownerDocument;\n return clone;\n }\n}\n\nexport class DocumentFragment extends Node {\n constructor() {\n super(DomNodeType.DOCUMENT_FRAGMENT_NODE, '#document-fragment');\n }\n}\n\nexport interface DomDocumentImplementation {\n createHTMLDocument(title?: string): Document;\n createDocument(): Document;\n createDocumentType(): never;\n hasFeature(): boolean;\n}\n\nexport class DomDOMImplementation implements DomDocumentImplementation {\n public createDocument(): Document {\n return new Document();\n }\n\n public createDocumentType(): never {\n throw new Error('createDocumentType is not supported in tsone DOM');\n }\n\n public hasFeature(): boolean {\n return false;\n }\n\n public createHTMLDocument(title?: string): Document {\n const document = new Document();\n const html = document.createElement('html');\n const head = document.createElement('head');\n const body = document.createElement('body');\n if (title) {\n const titleElement = document.createElement('title');\n titleElement.textContent = title;\n head.appendChild(titleElement);\n }\n html.appendChild(head);\n html.appendChild(body);\n document.appendChild(html);\n return document;\n }\n}\n\nexport class Document extends Node {\n public readonly defaultView: DomWindow | null = null;\n\n public readonly implementation: DomDocumentImplementation;\n\n private activeElementRef: Element | null = null;\n\n constructor() {\n super(DomNodeType.DOCUMENT_NODE, '#document');\n this.implementation = new DomDOMImplementation();\n }\n\n public get activeElement(): Element | null {\n return this.activeElementRef;\n }\n\n /** @internal 由 Element.focus()/blur() 维护。 */\n public setActiveElement(element: Element | null): void {\n this.activeElementRef = element;\n }\n\n public createElement(tagName: string): HTMLElement {\n return createElementForTag(tagName, this);\n }\n\n public createElementNS(namespaceURI: string, tagName: string): HTMLElement {\n const element = createElementForTag(tagName, this);\n (element as { namespaceURI: string | null }).namespaceURI = namespaceURI;\n return element;\n }\n\n public createTextNode(data: string): Text {\n const text = new Text(data);\n text.ownerDocument = this;\n return text;\n }\n\n public createComment(data: string): Comment {\n const comment = new Comment(data);\n comment.ownerDocument = this;\n return comment;\n }\n\n public createDocumentFragment(): DocumentFragment {\n const fragment = new DocumentFragment();\n fragment.ownerDocument = this;\n return fragment;\n }\n\n public createEvent(type: string): Event {\n if (type === 'MouseEvent' || type === 'mouseevent') {\n return new MouseEvent('');\n }\n if (type === 'KeyboardEvent' || type === 'keyboardevent') {\n return new KeyboardEvent('');\n }\n if (type === 'CustomEvent' || type === 'customevent') {\n return new CustomEvent('');\n }\n return new Event('');\n }\n\n public get documentElement(): HTMLElement {\n const html = this.childList.find(\n (child) => child.nodeType === DomNodeType.ELEMENT_NODE\n ) as HTMLElement | undefined;\n if (html) {\n return html;\n }\n const created = createElementForTag('html', this);\n this.appendChild(created);\n return created;\n }\n\n public get head(): HTMLElement {\n return this.ensureDocumentChild('head');\n }\n\n public get body(): HTMLElement {\n return this.ensureDocumentChild('body');\n }\n\n public get title(): string {\n const titleElement = this.querySelector('title');\n return titleElement?.textContent ?? '';\n }\n\n public set title(value: string) {\n let titleElement = this.querySelector('title');\n if (!titleElement) {\n titleElement = createElementForTag('title', this);\n this.head.appendChild(titleElement);\n }\n titleElement.textContent = value;\n }\n\n public querySelector(selector: string): Element | null {\n return querySelectorAll(this, selector).item(0);\n }\n\n public querySelectorAll(selector: string): NodeList<Element> {\n return querySelectorAll(this, selector);\n }\n\n public getElementById(id: string): Element | null {\n let result: Element | null = null;\n collectElements(this, (element) => {\n if (!result && element.id === id) {\n result = element;\n }\n });\n return result;\n }\n\n public getElementsByTagName(tagName: string): NodeList<Element> {\n return this.documentElement.getElementsByTagName(tagName);\n }\n\n /** @internal */\n protected createClone(): Node {\n return new Document();\n }\n\n private ensureDocumentChild(tagName: 'head' | 'body'): HTMLElement {\n const documentElement = this.documentElement;\n let child = documentElement.childList.find(\n (node) =>\n node.nodeType === DomNodeType.ELEMENT_NODE &&\n (node as Element).localName === tagName\n ) as HTMLElement | undefined;\n if (!child) {\n child = createElementForTag(tagName, this);\n documentElement.appendChild(child);\n }\n return child;\n }\n}\n\n/**\n * History / Location / Storage 等浏览器环境对象。\n */\nexport class Location {\n /** @internal */\n private url: URL;\n\n constructor(url: string) {\n this.url = new URL(url);\n }\n\n public get href(): string {\n return this.url.href;\n }\n\n public set href(value: string) {\n this.url = new URL(value, this.url.href);\n }\n\n public get origin(): string {\n return this.url.origin;\n }\n\n public get protocol(): string {\n return this.url.protocol;\n }\n\n public get host(): string {\n return this.url.host;\n }\n\n public get hostname(): string {\n return this.url.hostname;\n }\n\n public get port(): string {\n return this.url.port;\n }\n\n public get pathname(): string {\n return this.url.pathname;\n }\n\n public set pathname(value: string) {\n const url = this.url;\n const next = new URL(value, url.href);\n url.pathname = next.pathname;\n }\n\n public get search(): string {\n return this.url.search;\n }\n\n public set search(value: string) {\n this.url.search = value.startsWith('?') ? value : `?${value}`;\n }\n\n public get hash(): string {\n return this.url.hash;\n }\n\n public set hash(value: string) {\n const nextHash = value.startsWith('#') ? value : `#${value}`;\n this.url.hash = nextHash;\n }\n\n public get username(): string {\n return this.url.username;\n }\n\n public get password(): string {\n return this.url.password;\n }\n\n public assign(value: string): void {\n this.url = new URL(value, this.url.href);\n }\n\n public replace(value: string): void {\n this.url = new URL(value, this.url.href);\n }\n\n public reload(): void {}\n\n public toString(): string {\n return this.url.href;\n }\n\n /** @internal */\n public getHashPath(): string {\n return this.url.hash.slice(1);\n }\n\n /** @internal */\n public getHrefWithoutHash(): string {\n const url = this.url;\n return `${url.origin}${url.pathname}${url.search}`;\n }\n}\n\ninterface HistoryEntry {\n state: unknown;\n url: string;\n}\n\nexport class History {\n /** @internal */\n private readonly windowRef: DomWindow;\n /** @internal */\n private entries: HistoryEntry[] = [];\n /** @internal */\n private index = 0;\n /** @internal */\n public scrollRestoration: 'auto' | 'manual' = 'auto';\n\n constructor(windowRef: DomWindow) {\n this.windowRef = windowRef;\n this.entries = [{ state: null, url: windowRef.location.href }];\n }\n\n public get length(): number {\n return this.entries.length;\n }\n\n public get state(): unknown {\n return this.entries[this.index]?.state ?? null;\n }\n\n public pushState(state: unknown, _unusedTitle: string, url?: string): void {\n const nextUrl = url\n ? new URL(url, this.windowRef.location.href).href\n : this.windowRef.location.href;\n this.entries = this.entries.slice(0, this.index + 1);\n this.entries.push({ state, url: nextUrl });\n this.index = this.entries.length - 1;\n this.windowRef.setLocationUrl(nextUrl);\n }\n\n public replaceState(\n state: unknown,\n _unusedTitle: string,\n url?: string\n ): void {\n const nextUrl = url\n ? new URL(url, this.windowRef.location.href).href\n : this.windowRef.location.href;\n this.entries[this.index] = { state, url: nextUrl };\n this.windowRef.setLocationUrl(nextUrl);\n }\n\n public back(): void {\n this.go(-1);\n }\n\n public forward(): void {\n this.go(1);\n }\n\n public go(delta = 0): void {\n const nextIndex = this.index + delta;\n if (nextIndex < 0 || nextIndex >= this.entries.length) {\n return;\n }\n this.index = nextIndex;\n this.windowRef.setLocationUrl(this.entries[nextIndex].url);\n this.windowRef.dispatchEvent(\n new Event('popstate', { bubbles: false, cancelable: false })\n );\n }\n}\n\nexport class Storage {\n private readonly store = new Map<string, string>();\n\n public get length(): number {\n return this.store.size;\n }\n\n public key(index: number): string | null {\n return [...this.store.keys()][index] ?? null;\n }\n\n public getItem(key: string): string | null {\n return this.store.has(key) ? (this.store.get(key) as string) : null;\n }\n\n public setItem(key: string, value: string): void {\n this.store.set(key, String(value));\n }\n\n public removeItem(key: string): void {\n this.store.delete(key);\n }\n\n public clear(): void {\n this.store.clear();\n }\n}\n\nexport class Navigator {\n public readonly userAgent = 'TSone/0.5.1';\n public readonly platform = 'TSone';\n public readonly language = 'zh-CN';\n public readonly languages = ['zh-CN'];\n public readonly onLine = true;\n public readonly maxTouchPoints = 0;\n}\n\nexport interface MediaQueryList {\n readonly media: string;\n readonly matches: boolean;\n onchange: ((event: Event) => void) | null;\n addEventListener(type: string, listener: EventListenerRecord): void;\n removeEventListener(type: string, listener: EventListenerRecord): void;\n addListener(listener: EventListenerRecord): void;\n removeListener(listener: EventListenerRecord): void;\n dispatchEvent(event: Event): boolean;\n}\n\nexport function createMatchMedia(\n _windowRef: DomWindow,\n query: string\n): MediaQueryList {\n const listeners = new Set<EventListenerRecord>();\n const matches = false;\n const list: MediaQueryList = {\n media: query,\n matches,\n onchange: null,\n addEventListener(type, listener) {\n if (type === 'change') {\n listeners.add(listener);\n }\n },\n removeEventListener(type, listener) {\n if (type === 'change') {\n listeners.delete(listener);\n }\n },\n addListener(listener) {\n listeners.add(listener);\n },\n removeListener(listener) {\n listeners.delete(listener);\n },\n dispatchEvent(event) {\n for (const listener of [...listeners]) {\n if (typeof listener === 'function') {\n listener.call(list, event);\n } else {\n listener.handleEvent(event);\n }\n }\n return true;\n },\n };\n return list;\n}\n\nexport class ResizeObserver {\n public observe(): void {}\n public unobserve(): void {}\n public disconnect(): void {}\n}\n\nexport const DOM_GLOBAL_KEYS: readonly string[] = [\n 'window',\n 'document',\n 'Node',\n 'Text',\n 'Comment',\n 'Element',\n 'HTMLElement',\n 'HTMLInputElement',\n 'HTMLTextAreaElement',\n 'HTMLSelectElement',\n 'HTMLButtonElement',\n 'HTMLOptionElement',\n 'HTMLStyleElement',\n 'HTMLAnchorElement',\n 'HTMLImageElement',\n 'HTMLTableCellElement',\n 'HTMLLabelElement',\n 'DocumentFragment',\n 'Document',\n 'Event',\n 'MouseEvent',\n 'KeyboardEvent',\n 'CustomEvent',\n 'EventTarget',\n 'DOMException',\n 'history',\n 'location',\n 'navigator',\n 'localStorage',\n 'matchMedia',\n 'getComputedStyle',\n 'requestAnimationFrame',\n 'cancelAnimationFrame',\n 'ResizeObserver',\n];\n\n/**\n * DomWindow:模拟的浏览器 window 环境。\n */\nexport class DomWindow extends EventTarget {\n public readonly innerWidth = 1024;\n public readonly innerHeight = 768;\n\n public setTimeout(\n handler: () => void,\n timeout?: number\n ): ReturnType<typeof setTimeout> {\n return setTimeout(handler, timeout);\n }\n\n public clearTimeout(id: ReturnType<typeof setTimeout>): void {\n clearTimeout(id);\n }\n public readonly window: DomWindow = this;\n public readonly document: Document;\n public readonly location: Location;\n public readonly history: History;\n public readonly localStorage = new Storage();\n public readonly navigator = new Navigator();\n public readonly Node = Node;\n public readonly Text = Text;\n public readonly Comment = Comment;\n public readonly Element = Element;\n public readonly HTMLElement = HTMLElement;\n public readonly HTMLInputElement = HTMLInputElement;\n public readonly HTMLTextAreaElement = HTMLTextAreaElement;\n public readonly HTMLSelectElement = HTMLSelectElement;\n public readonly HTMLButtonElement = HTMLButtonElement;\n public readonly HTMLOptionElement = HTMLOptionElement;\n public readonly HTMLStyleElement = HTMLStyleElement;\n public readonly HTMLAnchorElement = HTMLAnchorElement;\n public readonly DocumentFragment = DocumentFragment;\n public readonly Document = Document;\n public readonly Event = Event;\n public readonly MouseEvent = MouseEvent;\n public readonly KeyboardEvent = KeyboardEvent;\n public readonly CustomEvent = CustomEvent;\n public readonly EventTarget = EventTarget;\n public readonly DOMException = DOMException;\n public readonly NodeList = NodeList;\n\n constructor(options: { url?: string } = {}) {\n super();\n const url = options.url ?? 'http://localhost/';\n this.location = new Location(url);\n this.history = new History(this);\n this.document = new Document();\n (this.document as { defaultView: DomWindow | null }).defaultView = this;\n setupDocumentTree(this.document);\n }\n\n public matchMedia(query: string): MediaQueryList {\n return createMatchMedia(this, query);\n }\n\n public getComputedStyle(element: Element): CSSStyleDeclaration {\n return element.style;\n }\n\n public requestAnimationFrame(callback: FrameRequestCallback): number {\n return setTimeout(() => callback(Date.now()), 0) as unknown as number;\n }\n\n public cancelAnimationFrame(handle: number): void {\n clearTimeout(handle as unknown as ReturnType<typeof setTimeout>);\n }\n\n /** @internal */\n public setLocationUrl(url: string): void {\n this.location.href = url;\n }\n\n /** @internal 安装到目标对象上的全局属性名。 */\n public installKeys(): string[] {\n return [...DOM_GLOBAL_KEYS];\n }\n}\n\nexport interface DomWindowOptions {\n url?: string;\n}\n\n/**\n * 创建隔离的 DOM window 环境。\n */\nexport function createDomWindow(options: DomWindowOptions = {}): DomWindow {\n return new DomWindow(options);\n}\n\n/**\n * 将 DOM window 的全局属性安装到目标对象(默认 globalThis),\n * 返回可恢复旧值的函数。\n */\nexport function installDomGlobals(\n windowRef: DomWindow,\n target: Record<string, unknown> = globalThis as Record<string, unknown>\n): () => void {\n const previous = new Map<string, PropertyDescriptor | undefined>();\n const keys = windowRef.installKeys();\n for (const key of keys) {\n previous.set(key, Object.getOwnPropertyDescriptor(target, key));\n }\n for (const key of keys) {\n Object.defineProperty(target, key, {\n configurable: true,\n enumerable: true,\n writable: true,\n value: (windowRef as unknown as Record<string, unknown>)[key],\n });\n }\n Object.defineProperty(target, 'window', {\n configurable: true,\n enumerable: true,\n writable: true,\n value: windowRef,\n });\n\n return () => {\n for (const key of keys) {\n const descriptor = previous.get(key);\n if (descriptor) {\n Object.defineProperty(target, key, descriptor);\n } else {\n Reflect.deleteProperty(target, key);\n }\n }\n };\n}\n\n/**\n * 解析 HTML 片段为节点列表(innerHTML setter 用)。\n */\nexport function parseHtmlFragment(\n source: string,\n documentRef: Document | null\n): Node[] {\n const root = new DocumentFragment();\n if (documentRef) {\n root.ownerDocument = documentRef;\n }\n parseInto(root, source, documentRef);\n return [...root.childList];\n}\n\nfunction parseInto(\n parent: Node,\n source: string,\n documentRef: Document | null\n): void {\n const stack: Element[] = [];\n let current: Node = parent;\n let index = 0;\n const length = source.length;\n\n const append = (node: Node): void => {\n if (node.ownerDocument === null) {\n node.ownerDocument = documentRef;\n }\n current.appendChild(node);\n };\n\n while (index < length) {\n const openIndex = source.indexOf('<', index);\n if (openIndex < 0) {\n append(new Text(source.slice(index)));\n break;\n }\n if (openIndex > index) {\n append(new Text(source.slice(index, openIndex)));\n }\n if (source.startsWith('<!--', openIndex)) {\n const closeIndex = source.indexOf('-->', openIndex + 4);\n const commentEnd = closeIndex < 0 ? length : closeIndex;\n append(new Comment(source.slice(openIndex + 4, commentEnd)));\n index = closeIndex < 0 ? length : closeIndex + 3;\n continue;\n }\n const tagEnd = findTagEnd(source, openIndex);\n if (tagEnd < 0) {\n append(new Text(source.slice(openIndex)));\n break;\n }\n const tagSource = source.slice(openIndex + 1, tagEnd);\n const trimmed = tagSource.trim();\n if (trimmed.startsWith('/')) {\n const tagName = trimmed.slice(1).trim().toLowerCase();\n if (stack.length > 0 && stack[stack.length - 1].localName === tagName) {\n stack.pop();\n current = stack[stack.length - 1] ?? parent;\n }\n index = tagEnd + 1;\n continue;\n }\n const selfClosing = trimmed.endsWith('/');\n const parsed = parseTag(trimmed.replace(/\\/$/, '').trim());\n if (!parsed) {\n index = tagEnd + 1;\n continue;\n }\n const element = createElementForTag(parsed.name, documentRef);\n for (const attr of parsed.attributes) {\n element.setAttribute(attr.name, attr.value);\n }\n append(element);\n if (VOID_TAGS.has(parsed.name) || selfClosing) {\n index = tagEnd + 1;\n continue;\n }\n if (RAW_TEXT_TAGS.has(parsed.name)) {\n const closeTag = `</${parsed.name}>`;\n const rawEnd = source.toLowerCase().indexOf(closeTag, tagEnd + 1);\n const rawText = source.slice(tagEnd + 1, rawEnd < 0 ? length : rawEnd);\n element.appendChild(\n documentRef?.createTextNode(rawText) ?? new Text(rawText)\n );\n index = rawEnd < 0 ? length : rawEnd + closeTag.length;\n continue;\n }\n stack.push(element);\n current = element;\n index = tagEnd + 1;\n }\n}\n\nconst VOID_TAGS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\nconst RAW_TEXT_TAGS = new Set(['script', 'style', 'textarea', 'title']);\n\nfunction findTagEnd(source: string, openIndex: number): number {\n let inQuote: string | null = null;\n for (let index = openIndex + 1; index < source.length; index += 1) {\n const char = source[index];\n if (inQuote) {\n if (char === inQuote) {\n inQuote = null;\n }\n continue;\n }\n if (char === '\"' || char === \"'\") {\n inQuote = char;\n continue;\n }\n if (char === '>') {\n return index;\n }\n }\n return -1;\n}\n\nfunction parseTag(\n source: string\n): { name: string; attributes: Array<{ name: string; value: string }> } | null {\n const match = source.match(/^([a-zA-Z][a-zA-Z0-9-]*)\\s*(.*)$/);\n if (!match) {\n return null;\n }\n const name = match[1].toLowerCase();\n const attributes: Array<{ name: string; value: string }> = [];\n const attributeSource = match[2];\n const pattern =\n /([a-zA-Z_:][a-zA-Z0-9_:.-]*)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g;\n let attributeMatch: RegExpExecArray | null;\n while ((attributeMatch = pattern.exec(attributeSource)) !== null) {\n const attrName = attributeMatch[1];\n const value =\n attributeMatch[2] ?? attributeMatch[3] ?? attributeMatch[4] ?? '';\n attributes.push({ name: attrName, value: decodeEntities(value) });\n }\n return { name, attributes };\n}\n\nfunction decodeEntities(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/ /g, '\\u00a0');\n}\n\nfunction encodeText(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\nfunction encodeAttribute(value: string): string {\n return encodeText(value).replace(/\"/g, '"');\n}\n\nfunction serializeNode(node: Node): string {\n switch (node.nodeType) {\n case DomNodeType.TEXT_NODE:\n return encodeText((node as Text).data);\n case DomNodeType.COMMENT_NODE:\n return `<!--${(node as Comment).data}-->`;\n case DomNodeType.ELEMENT_NODE:\n return serializeElement(node as Element);\n default:\n return '';\n }\n}\n\nfunction serializeElement(element: Element): string {\n const tag = element.localName;\n const attributes: string[] = [];\n for (const entry of element.attributeEntries()) {\n if (entry.name === 'style') {\n continue;\n }\n attributes.push(`${entry.name}=\"${encodeAttribute(entry.value)}\"`);\n }\n const inlineStyle = element.inlineStyleText();\n if (inlineStyle) {\n attributes.push(`style=\"${encodeAttribute(inlineStyle)}\"`);\n }\n const attributeText = attributes.length > 0 ? ` ${attributes.join(' ')}` : '';\n if (VOID_TAGS.has(tag)) {\n return `<${tag}${attributeText}>`;\n }\n if (RAW_TEXT_TAGS.has(tag)) {\n return `<${tag}${attributeText}>${element.textContent}</${tag}>`;\n }\n return `<${tag}${attributeText}>${serializeChildren(element)}</${tag}>`;\n}\n\nfunction serializeChildren(element: Element): string {\n return element.childList.map((child) => serializeNode(child)).join('');\n}\n\n/**\n * CSS 选择器引擎:支持 tag、#id、.class、[attr]、[attr=value]、复合与后代选择器。\n */\nfunction parseSelector(selector: string): SimpleSelector[][] {\n return selector.split(',').map((group) => {\n const segments: SimpleSelector[] = [];\n let index = 0;\n while (index < group.length) {\n while (index < group.length && group[index] === ' ') {\n index += 1;\n }\n if (index >= group.length) {\n break;\n }\n if (group[index] === '>') {\n segments.push({ type: 'child' });\n index += 1;\n continue;\n }\n const start = index;\n while (\n index < group.length &&\n group[index] !== ' ' &&\n group[index] !== '>'\n ) {\n index += 1;\n }\n segments.push(parseCompound(group.slice(start, index)));\n }\n return segments;\n });\n}\n\ntype SimpleSelector =\n | { type: 'universal' }\n | { type: 'tag'; name: string }\n | { type: 'id'; id: string }\n | { type: 'class'; className: string }\n | { type: 'attribute'; name: string; operator?: string; value?: string }\n | { type: 'compound'; parts: SimpleSelector[] }\n | { type: 'not'; selector: SimpleSelector }\n | { type: 'child' };\n\nfunction parseCompound(source: string): SimpleSelector {\n const selectors: SimpleSelector[] = [];\n let index = 0;\n while (index < source.length) {\n const char = source[index];\n if (char === '*') {\n selectors.push({ type: 'universal' });\n index += 1;\n } else if (char === '#') {\n const end = scanIdentifier(source, index + 1);\n selectors.push({ type: 'id', id: source.slice(index + 1, end) });\n index = end;\n } else if (char === '.') {\n const end = scanIdentifier(source, index + 1);\n selectors.push({\n type: 'class',\n className: source.slice(index + 1, end),\n });\n index = end;\n } else if (char === '[') {\n const end = source.indexOf(']', index);\n const inner = source\n .slice(index + 1, end < 0 ? source.length : end)\n .trim();\n const attrMatch = inner.match(\n /^([a-zA-Z_:][a-zA-Z0-9_:.-]*)(?:([~|^$*]?=)(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?$/\n );\n if (attrMatch) {\n selectors.push({\n type: 'attribute',\n name: attrMatch[1],\n operator: attrMatch[2],\n value: attrMatch[3] ?? attrMatch[4] ?? attrMatch[5],\n });\n } else {\n selectors.push({ type: 'attribute', name: inner });\n }\n index = end < 0 ? source.length : end + 1;\n } else if (char === ':' && source.startsWith(':not(', index)) {\n const close = source.indexOf(')', index);\n const inner = source.slice(index + 5, close < 0 ? source.length : close);\n selectors.push({ type: 'not', selector: parseCompound(inner.trim()) });\n index = close < 0 ? source.length : close + 1;\n } else if (char === ':' && source.startsWith(':disabled', index)) {\n selectors.push({ type: 'attribute', name: 'disabled' });\n index += ':disabled'.length;\n } else if (/[a-zA-Z_]/.test(char)) {\n const end = scanIdentifier(source, index);\n selectors.push({\n type: 'tag',\n name: source.slice(index, end).toLowerCase(),\n });\n index = end;\n } else {\n index += 1;\n }\n }\n if (selectors.length === 1) {\n return selectors[0];\n }\n return { type: 'compound', parts: selectors };\n}\n\nfunction scanIdentifier(source: string, start: number): number {\n let index = start;\n // ':' 是伪类(:not)起始,不属于标识符\n while (index < source.length && /[a-zA-Z0-9_-]/.test(source[index])) {\n index += 1;\n }\n return index;\n}\n\nfunction matchSelector(element: Element, selector: string): boolean {\n const groups = parseSelector(selector);\n return groups.some((group) => matchGroup(element, group));\n}\n\nfunction matchGroup(element: Element, group: SimpleSelector[]): boolean {\n let index = group.length - 1;\n if (index < 0) {\n return true;\n }\n\n // The rightmost compound must match the queried element itself.\n if (!matchSegment(element, group[index])) {\n return false;\n }\n if (index === 0) {\n return true;\n }\n\n // Remaining compounds must match ancestors, right to left.\n let current: Element | null = element.parentElement;\n index -= 1;\n while (current) {\n const selector = group[index];\n if (!selector) {\n return true;\n }\n if (selector.type === 'child') {\n // The previously matched element must be the immediate child of this parent.\n const parentSelector = group[index - 1];\n if (!parentSelector || !matchSegment(current, parentSelector)) {\n return false;\n }\n index -= 2;\n if (index < 0) {\n return true;\n }\n current = current.parentElement;\n continue;\n }\n if (matchSegment(current, selector)) {\n index -= 1;\n if (index < 0) {\n return true;\n }\n }\n current = current.parentElement;\n }\n return false;\n}\n\nfunction matchSegment(element: Element, selector: SimpleSelector): boolean {\n switch (selector.type) {\n case 'universal':\n return true;\n case 'tag':\n return element.localName === selector.name;\n case 'id':\n return element.id === selector.id;\n case 'class':\n return element.classList.contains(selector.className);\n case 'attribute':\n return matchAttribute(element, selector);\n case 'compound':\n return selector.parts.every((part) => matchSegment(element, part));\n case 'not':\n return !matchSegment(element, selector.selector);\n case 'child':\n return false;\n default:\n return false;\n }\n}\n\nfunction matchAttribute(\n element: Element,\n selector: { name: string; operator?: string; value?: string }\n): boolean {\n const attributeValue = element.getAttribute(selector.name);\n if (!selector.operator) {\n return attributeValue !== null;\n }\n if (attributeValue === null) {\n return false;\n }\n const expected = selector.value ?? '';\n switch (selector.operator) {\n case '=':\n return attributeValue === expected;\n case '~=':\n return attributeValue.split(/\\s+/).includes(expected);\n case '|=':\n return (\n attributeValue === expected || attributeValue.startsWith(`${expected}-`)\n );\n case '^=':\n return attributeValue.startsWith(expected);\n case '$=':\n return attributeValue.endsWith(expected);\n case '*=':\n return attributeValue.includes(expected);\n default:\n return false;\n }\n}\n\nfunction querySelectorAll(root: Node, selector: string): NodeList<Element> {\n const results: Element[] = [];\n collectElements(root, (element) => {\n if (element !== root && matchSelector(element, selector)) {\n results.push(element);\n }\n });\n return new NodeList(results);\n}\n\nfunction collectElements(root: Node, visit: (element: Element) => void): void {\n for (const child of root.childList) {\n if (child.nodeType === DomNodeType.ELEMENT_NODE) {\n visit(child as Element);\n collectElements(child, visit);\n }\n }\n}\n\nfunction createElementForTag(\n tagName: string,\n documentRef: Document | null\n): HTMLElement {\n const tag = tagName.toLowerCase();\n let element: HTMLElement;\n if (tag === 'input') {\n element = new HTMLInputElement(tag);\n } else if (tag === 'textarea') {\n element = new HTMLTextAreaElement(tag);\n } else if (tag === 'select') {\n element = new HTMLSelectElement(tag);\n } else if (tag === 'option') {\n element = new HTMLOptionElement(tag);\n } else if (tag === 'button') {\n element = new HTMLButtonElement(tag);\n } else if (tag === 'style') {\n element = new HTMLStyleElement(tag);\n } else if (tag === 'a') {\n element = new HTMLAnchorElement(tag);\n } else if (tag === 'img') {\n element = new HTMLImageElement(tag);\n } else if (tag === 'label') {\n element = new HTMLLabelElement(tag);\n } else if (tag === 'td' || tag === 'th') {\n element = new HTMLTableCellElement(tag);\n } else {\n element = new HTMLElement(tag);\n }\n element.ownerDocument = documentRef;\n return element;\n}\n\nfunction setupDocumentTree(documentRef: Document): void {\n const html = documentRef.createElement('html');\n documentRef.appendChild(html);\n const head = documentRef.createElement('head');\n const body = documentRef.createElement('body');\n html.appendChild(head);\n html.appendChild(body);\n}\n\nfunction createDatasetProxy(element: Element): Record<string, string> {\n const handler: ProxyHandler<Record<string, string>> = {\n get(_target, property: string) {\n if (typeof property === 'symbol') {\n return undefined;\n }\n return (\n element.getAttribute(`data-${toKebabCase(property)}`) ?? undefined\n );\n },\n set(_target, property: string, value: string): boolean {\n if (typeof property === 'symbol') {\n return true;\n }\n if (value === null || value === undefined) {\n element.removeAttribute(`data-${toKebabCase(property)}`);\n } else {\n element.setAttribute(`data-${toKebabCase(property)}`, String(value));\n }\n return true;\n },\n deleteProperty(_target, property: string): boolean {\n if (typeof property !== 'symbol') {\n element.removeAttribute(`data-${toKebabCase(property)}`);\n }\n return true;\n },\n has(_target, property: string): boolean {\n if (typeof property === 'symbol') {\n return false;\n }\n return element.hasAttribute(`data-${toKebabCase(property)}`);\n },\n ownKeys() {\n const keys: string[] = [];\n for (const entry of element.attributeEntries()) {\n if (entry.name.startsWith('data-')) {\n keys.push(toCamelCase(entry.name.slice(5)));\n }\n }\n return keys;\n },\n getOwnPropertyDescriptor(_target, property: string) {\n if (typeof property === 'symbol') {\n return undefined;\n }\n if (element.hasAttribute(`data-${toKebabCase(property)}`)) {\n return {\n configurable: true,\n enumerable: true,\n writable: true,\n value: element.getAttribute(`data-${toKebabCase(property)}`),\n };\n }\n return undefined;\n },\n };\n return new Proxy({}, handler);\n}\n\nfunction toKebabCase(value: string): string {\n return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\n}\n\nfunction toCamelCase(value: string): string {\n return value.replace(/-([a-z])/g, (_match, char: string) =>\n char.toUpperCase()\n );\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "AASO,IAAW,IAAX,CAAW,IAAX,CACL,iBAAe,GAAf,eACA,cAAY,GAAZ,YACA,iBAAe,GAAf,eACA,kBAAgB,GAAhB,gBACA,2BAAyB,IAAzB,2BALgB,SAQX,MAAM,UAAqB,KAAM,CACtB,KAEhB,WAAW,CAAC,EAAiB,EAAO,QAAS,CAC3C,MAAM,CAAO,EACb,KAAK,KAAO,EACZ,KAAK,KAAO,EAEhB,CAgBO,MAAM,CAAY,CACN,YAAc,IAAI,IAE5B,gBAAgB,CACrB,EACA,EACA,EACM,CACN,GAAI,CAAC,EACH,OAEF,IAAM,EACJ,OAAO,IAAY,UAAY,EAAW,GAAS,SAAW,GAC1D,EAAO,OAAO,IAAY,SAAY,EAAQ,MAAQ,GAAS,GAC/D,EACJ,OAAO,IAAY,SAAY,EAAQ,SAAW,GAAS,GACzD,EAAU,KAAK,YAAY,IAAI,CAAI,EACvC,GAAI,CAAC,EACH,EAAU,CAAC,EACX,KAAK,YAAY,IAAI,EAAM,CAAO,EAEpC,GACE,EAAQ,KACN,CAAC,I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
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{Ba as ae,Ca as K}from"./index-mbmajrpr.js";var y=Symbol("is_reactive"),l=Symbol("is_readonly"),H=Symbol("is_ref"),F=["push","pop","shift","unshift","splice","sort","reverse"];function d(e,t){return Boolean(Reflect.get(e,t))}function h(e){return e!==null&&typeof e==="object"}class k{pending=new Set;flushing=!1;flushPromise=null;flushResolve=null;enqueue(e){if(this.pending.has(e))return;if(this.pending.add(e),!this.flushing)queueMicrotask(()=>this.flush())}flush(){if(this.flushing)return;this.flushing=!0;try{while(this.pending.size>0){let e=Array.from(this.pending);this.pending.clear();for(let t of e)if(t.active)t()}}finally{this.flushing=!1;let e=this.flushResolve;this.flushResolve=null,this.flushPromise=null,e?.()}}nextTick(){if(!this.flushing&&this.pending.size===0)return Promise.resolve();if(this.flushPromise)return this.flushPromise;return this.flushPromise=new Promise((e)=>{this.flushResolve=e}),this.flushPromise}}var fe=0,b=new k;function Ue(){return b.nextTick()}function Ke(){b.flush()}class f{static instance;activeEffect=null;effectStack=[];targetMap=new WeakMap;reactiveMap=new WeakMap;readonlyMap=new WeakMap;proxyMap=new WeakMap;constructor(){}static getInstance(){if(!f.instance)f.instance=new f;return f.instance}reactive(e){if(!h(e))return console.warn("reactive: target must be an object"),e;if(me(e))return e;if(this.reactiveMap.has(e))return this.reactiveMap.get(e);if(Array.isArray(e))return this.createReactiveArray(e);let t=new Proxy(e,{get:(n,r)=>{if(r===y)return!0;if(r===l)return!1;this.track(n,r);let o=Reflect.get(n,r);if(h(o)&&!d(o,l))return this.reactive(o);return o},set:(n,r,o)=>{if(d(n,l))return console.warn(`Cannot set property ${String(r)} on readonly object`),!1;let i=Reflect.get(n,r);if(h(o)&&!d(o,y)&&!d(o,l))o=this.reactive(o);let s=Reflect.set(n,r,o);if(i!==o)this.trigger(n,r);return s},deleteProperty:(n,r)=>{if(d(n,l))return console.warn(`Cannot delete property ${String(r)} on readonly object`),!1;let o=r in n,i=Reflect.deleteProperty(n,r);if(o)this.trigger(n,r);return i}});return this.reactiveMap.set(e,t),this.proxyMap.set(t,e),t}toRawValue(e){if(h(e)&&this.proxyMap.has(e))return this.proxyMap.get(e);return e}createReactiveArray(e){if(this.reactiveMap.has(e))return this.reactiveMap.get(e);let t=new Proxy(e,{get:(n,r)=>{if(r===y)return!0;if(r===l)return!1;this.track(n,r);let o=Reflect.get(n,r);if(typeof r==="string"&&(r==="includes"||r==="indexOf"||r==="lastIndexOf")){this.track(n,"length");for(let s=0;s<n.length;s++)this.track(n,String(s));let i=o;return(...s)=>{let a=i.apply(n,s);if(a===!1||a===-1){let c=n.map((u)=>this.toRawValue(u));return c[r].apply(c,s.map((u)=>this.toRawValue(u)))}return a}}if(typeof r==="string"&&F.includes(r))return(...i)=>{let a=o.apply(n,i);return this.trigger(n,"length"),this.trigger(n,r),a};if(h(o)&&!d(o,l))return this.reactive(o);return o},set:(n,r,o)=>{if(d(n,l))return console.warn(`Cannot set property ${String(r)} on readonly object`),!1;let i=Reflect.get(n,r);if(h(o)&&!d(o,y)&&!d(o,l))o=this.reactive(o);let s=Reflect.set(n,r,o);if(i!==o){if(this.trigger(n,r),typeof r==="string"&&!isNaN(Number(r)))this.trigger(n,"length")}return s},deleteProperty:(n,r)=>{if(d(n,l))return console.warn(`Cannot delete property ${String(r)} on readonly object`),!1;let o=r in n,i=Reflect.deleteProperty(n,r);if(o)this.trigger(n,r),this.trigger(n,"length");return i}});return this.reactiveMap.set(e,t),this.proxyMap.set(t,e),t}readonly(e){if(!h(e))return console.warn("readonly: target must be an object"),e;if(d(e,l))return e;if(this.readonlyMap.has(e))return this.readonlyMap.get(e);let t=new Proxy(e,{get:(n,r)=>{if(r===y)return!1;if(r===l)return!0;let o=Reflect.get(n,r);if(h(o))return this.readonly(o);return o},set:()=>(console.warn("Cannot set property on readonly object"),!1),deleteProperty:()=>(console.warn("Cannot delete property on readonly object"),!1)});return this.readonlyMap.set(e,t),t}effect(e,t){let{lazy:n=!1,scheduler:r,throwOnError:o=!1}=t||{},i=()=>{if(!i.active)return e();try{return this.cleanup(i),this.effectStack.push(i),this.activeEffect=i,e()}catch(s){if(o)throw s;console.error("Effect error:",s);return}finally{this.effectStack.pop(),this.activeEffect=this.effectStack[this.effectStack.length-1]??null}};if(i.id=fe++,i.deps=[],i.active=!0,i.scheduler=r,!n)i();return i}runWithEffect(e,t){this.effectStack.push(e),this.activeEffect=e;try{return t()}finally{this.effectStack.pop(),this.activeEffect=this.effectStack[this.effectStack.length-1]??null}}computed(e){let t=!0,n,r={},o=()=>{this.track(r,"value")},i=this.effect(()=>{n=e(),t=!1},{lazy:!0,scheduler:()=>{if(!t)t=!0,this.trigger(r,"value")}});return{get value(){if(t)i();return o(),n}}}cleanup(e){e.deps.forEach((t)=>{t.delete(e)}),e.deps.length=0}track(e,t){if(!this.activeEffect||!this.activeEffect.active)return;let n=this.targetMap.get(e);if(!n)n=new Map,this.targetMap.set(e,n);let r=n.get(t);if(!r)r=new Set,n.set(t,r);if(!r.has(this.activeEffect))r.add(this.activeEffect),this.activeEffect.deps.push(r)}trigger(e,t){let n=this.targetMap.get(e);if(!n)return;let r=n.get(t);if(!r)return;new Set(r).forEach((i)=>{if(i.active)if(i.scheduler)i.scheduler(i);else i()})}stop(e){if(e.active)this.cleanup(e),e.active=!1}}function O(e){return f.getInstance().reactive(e)}function We(e){return f.getInstance().readonly(e)}function g(e,t){return f.getInstance().effect(e,t)}function Fe(e){return f.getInstance().computed(e)}function Ge(e){let t={value:e};return Object.defineProperty(t,H,{configurable:!1,enumerable:!1,value:!0}),O(t)}function G(e){return h(e)&&Boolean(Reflect.get(e,H))}function qe(e){return G(e)?e.value:e}function v(e){f.getInstance().stop(e)}function j(e,t){if(!h(e)||t.has(e))return;if(t.add(e),Array.isArray(e)){e.forEach((n)=>j(n,t));return}Object.keys(e).forEach((n)=>{j(e[n],t)})}function ze(e,t,n={}){let r=f.getInstance(),o=G(e)?()=>e.value:e,i,s=null,a=()=>{if(!m.active)return;s?.(),s=null;let u=c();t(u,i,(C)=>{s=C}),i=u},c=g(()=>{let u=o();if(n.deep&&h(u))j(u,new Set);return u},{lazy:!0,scheduler:()=>{if(n.sync)a();else b.enqueue(m)}}),m=g(()=>{a()},{lazy:!0});if(n.immediate)a();else i=c();return()=>{r.stop(c),r.stop(m)}}function me(e){return h(e)&&d(e,y)}function Ye(e){return h(e)&&d(e,l)}function q(e){return typeof e==="object"&&e!==null&&"component"in e}function z(e){return typeof e==="object"&&e!==null&&"tag"in e&&e.tag!=="slot"}function Y(e){return typeof e==="object"&&e!==null&&"tag"in e&&e.tag==="slot"}function Ze(e,t,n,r,o,i){return{tag:e,props:t,children:n,listeners:r,key:o,directions:i}}function ge(e,t={}){return{tag:e,...t}}function p(e){return(t={})=>ge(e,t)}var T=p("div"),Je=p("span"),Xe=p("p"),et=p("button"),tt=p("input"),nt=p("section"),rt=p("main"),ot=p("header"),it=p("footer"),st=p("nav"),at=p("article"),pt=p("aside"),ct=p("h1"),ut=p("h2"),lt=p("h3"),dt=p("h4"),ht=p("h5"),ft=p("h6"),mt=p("strong"),gt=p("em"),vt=p("small"),yt=p("pre"),Rt=p("code"),Ct=p("blockquote"),bt=p("ul"),Et=p("ol"),xt=p("li"),Tt=p("a"),wt=p("img"),St=p("form"),Mt=p("label"),Lt=p("textarea"),Nt=p("select"),Pt=p("option"),At=p("table"),It=p("thead"),Ht=p("tbody"),kt=p("tr"),jt=p("th"),Ot=p("td");function Vt(e,t,n,r,o){return{component:e,props:t,children:n,key:r,directions:o}}function Bt(e,t,n){return{tag:"slot",props:{name:e},key:t,directions:n}}function _t(e,t,n){return e.map((r,o)=>{let i=t(r,o);if(typeof i==="string")throw Error("each render callback must return a VNode");return{...i,key:n(r,o)}})}function Z(e){let t=e.split(".");if(e.length===0||t.some((n)=>n.length===0||n==="__proto__"||n==="prototype"||n==="constructor"))throw Error(`Invalid model path "${e}"`);return t}function B(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function J(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ve(e){return typeof e==="string"?e:e.path}function Q(e,t){let n=e;for(let r of Z(t)){if(!B(n))throw Error(`Invalid model path "${t}"`);if(!J(n,r)){if(r in n)throw Error(`Invalid model path "${t}"`);return}n=n[r]}return n}function ye(e,t,n){let r=Z(t),o=e;for(let s of r.slice(0,-1)){if(!J(o,s)){if(s in o)throw Error(`Invalid model path "${t}"`);o[s]={}}else if(!B(o[s]))throw Error(`Invalid model path "${t}"`);let a=o[s];if(!B(a))throw Error(`Invalid model path "${t}"`);o=a}let i=r[r.length-1];o[i]=n}function V(e,t){if(typeof e!=="string"&&e.format)return e.format(t);return t===void 0||t===null?"":String(t)}function Re(e,t){if(typeof e!=="string"&&e.parse)return e.parse(t);return t}function Ce(e,t,n){if(e instanceof HTMLInputElement){if(e.type==="checkbox"){e.checked=Array.isArray(n)?n.some((r)=>String(r)===e.value):Boolean(n);return}if(e.type==="radio"){e.checked=n===e.value;return}e.value=V(t,n);return}if(e instanceof HTMLTextAreaElement){e.value=V(t,n);return}if(e instanceof HTMLSelectElement){if(e.multiple){let r=Array.isArray(n)?new Set(n.map(String)):new Set;for(let o=0;o<e.options.length;o+=1){let i=e.options.item(o);if(!i)continue;i.selected=r.has(i.value)}return}e.value=V(t,n)}}function be(e,t){if(e instanceof HTMLInputElement){if(e.type==="checkbox"){if(Array.isArray(t)){let n=t.filter((r)=>String(r)!==e.value);return e.checked?[...n,e.value]:n}return e.checked}if(e.type==="radio")return e.checked?e.value:t;return e.value}if(e instanceof HTMLTextAreaElement)return e.value;if(e instanceof HTMLSelectElement){if(!e.multiple)return e.value;let n=[];for(let r=0;r<e.selectedOptions.length;r+=1){let o=e.selectedOptions.item(r);if(o)n.push(o.value)}return n}return}class _{bindings=new WeakMap;bind(e,t,n){if(!this.isSupportedControl(e))return;let r=this.bindings.get(e);if(r&&this.sameBinding(r,t))return;this.cleanup(e);let o=ve(t),i=()=>Ce(e,t,Q(n,o)),s=e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["checkbox","radio"].includes(e.type)?"input":"change",a=()=>{let m=Q(n,o);ye(n,o,Re(t,be(e,m)))};e.addEventListener(s,a);let c=g(i);this.bindings.set(e,{binding:t,path:o,parse:typeof t==="string"?void 0:t.parse,format:typeof t==="string"?void 0:t.format,eventName:s,listener:a,effect:c})}cleanup(e){let t=this.bindings.get(e);if(!t)return;e.removeEventListener(t.eventName,t.listener),v(t.effect),this.bindings.delete(e)}isSupportedControl(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement}sameBinding(e,t){if(typeof e.binding==="string"||typeof t==="string")return e.binding===t;return e.path===t.path&&e.parse===t.parse&&e.format===t.format}}function M(e){return/^on[A-Z]/.test(e)||/^on[a-z]/.test(e)}function X(e){return e.slice(2).toLowerCase()}function ee(e){let[t,...n]=e.split(".");return{eventName:t,modifiers:new Set(n)}}function te(e,t){let n=(r)=>{if(t.has("stop"))r.stopPropagation();if(t.has("prevent"))r.preventDefault();if(t.has("self")&&r.currentTarget!==r.target)return;if(t.has("once"))r.currentTarget.removeEventListener(r.type,n);e(r)};return n}function ne(e,t,n){let r=t.includes("-")?t:t.replace(/[A-Z]/g,(o)=>`-${o.toLowerCase()}`);e.setProperty(r,String(n))}var re="http://www.w3.org/2000/svg",Ee=new Set(["svg","g","defs","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","textPath","use","symbol","marker","linearGradient","radialGradient","stop","pattern","mask","clipPath","foreignObject"]);class N{listeners=new WeakMap;effects=new WeakMap;modelBindings=new _;matches(e){return typeof e==="object"&&e!==null&&z(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let n=Ee.has(e.tag)?document.createElementNS(re,e.tag):document.createElement(e.tag);return this.applyProps(n,{},e.props??{},t),this.updateListeners(n,{},this.collectListeners(e)),this.mountChildren(n,e,t),this.applyDirections(n,void 0,e.directions,t),n}patch(e,t,n,r){if(e.tag!==t.tag||n.nodeType===Node.COMMENT_NODE){let o=this.mount(t,r);return n.parentNode?.replaceChild(o,n),this.unmount(e,n,r),o}if(!(n instanceof Element))return n;if(t.directions?.if===!1){let o=document.createComment("if");return n.parentNode?.replaceChild(o,n),this.unmount(e,n,r),o}return this.applyProps(n,e.props??{},t.props??{},r),this.updateListeners(n,this.collectListeners(e),this.collectListeners(t)),this.updateChildren(n,e,t,r),this.applyDirections(n,e.directions,t.directions,r),n}unmount(e,t,n){if(!(t instanceof Element))return;this.effects.get(t)?.forEach((r)=>v(r)),this.effects.delete(t),this.listeners.get(t)?.forEach(({eventName:r,listener:o})=>{t.removeEventListener(r,o)}),this.listeners.delete(t),this.modelBindings.cleanup(t),this.unmountChildren(t,e,n)}mountChildren(e,t,n){(t.children??[]).forEach((r)=>{e.appendChild(n.renderer.mount(r,n))})}updateChildren(e,t,n,r){this.updateOrdinaryChildren(e,t.children??[],n.children??[],r)}unmountChildren(e,t,n){(t.children??[]).forEach((r,o)=>{let i=e.childNodes[o];if(i)n.renderer.unmount(r,i,n)})}applyProps(e,t,n,r){Object.keys(t).forEach((o)=>{if(M(o)||o in n)return;if(o==="className"||o==="class")e.removeAttribute("class");else if(o==="style")e.removeAttribute("style");else if(o==="value"&&typeof e==="object"&&e!==null&&"value"in e)e.value="";else e.removeAttribute(L(o))}),Object.entries(n).forEach(([o,i])=>{if(M(o))return;if(t[o]===i)return;if(o==="className"||o==="class"){if(e.namespaceURI===re)e.setAttribute("class",String(i??""));else e.className=String(i??"");return}if(o==="value"&&typeof e==="object"&&e!==null&&"value"in e){e.value=String(i??"");return}if(o==="style"&&typeof i==="object"&&i!==null){e.removeAttribute("style");let s=e.style;Object.entries(i).forEach(([a,c])=>{ne(s,a,c)});return}if(i===!1||i===void 0||i===null){e.removeAttribute(L(o));return}if(i===!0){e.setAttribute(L(o),"");return}if(typeof i==="string"&&r.templateEngine.hasExpressions(i)){this.setupReactiveAttribute(e,o,i,r);return}e.setAttribute(L(o),String(i))})}applyDirections(e,t,n,r){if(n&&"show"in n)e.style.display=n.show?"":"none";else if(t&&"show"in t)e.style.display="";if(!n?.model){this.modelBindings.cleanup(e);return}this.modelBindings.bind(e,n.model,r.templateEngine.state)}updateOrdinaryChildren(e,t,n,r){if(this.assertNoDuplicateKeys(t),this.assertNoDuplicateKeys(n),this.hasOnlyKeyedChildren(t,n)){this.updateKeyedChildren(e,t,n,r);return}let o=Math.min(t.length,n.length);for(let i=0;i<o;i+=1){let s=e.childNodes[i];if(!s){e.appendChild(r.renderer.mount(n[i],r));continue}r.renderer.patch(t[i],n[i],s,r)}for(let i=o;i<n.length;i+=1)e.appendChild(r.renderer.mount(n[i],r));for(let i=t.length-1;i>=n.length;i-=1){let s=e.childNodes[i];if(s){if(r.renderer.unmount(t[i],s,r),s.parentNode===e)e.removeChild(s)}}}updateKeyedChildren(e,t,n,r){let o=t.map((a,c)=>({vnode:a,node:e.childNodes[c],index:c})),i=new Map,s=new Set;o.forEach((a)=>{let c=this.getVNodeKey(a.vnode);if(c!==void 0&&a.node)i.set(c,{vnode:a.vnode,node:a.node,index:a.index})}),n.forEach((a,c)=>{let m=this.getVNodeKey(a),u=m===void 0?void 0:i.get(m),C;if(u)C=r.renderer.patch(u.vnode,a,u.node,r),s.add(u.index);else C=r.renderer.mount(a,r);let W=e.childNodes[c]??null;if(C!==W)e.insertBefore(C,W)}),o.forEach((a)=>{if(!a.node||s.has(a.index))return;if(r.renderer.unmount(a.vnode,a.node,r),a.node.parentNode===e)e.removeChild(a.node)})}hasOnlyKeyedChildren(e,t){return[...e,...t].every((n)=>this.getVNodeKey(n)!==void 0)}assertNoDuplicateKeys(e){let t=new Set;e.forEach((n)=>{let r=this.getVNodeKey(n);if(r===void 0)return;if(t.has(r))throw Error(`Duplicate key "${r}"`);t.add(r)})}getVNodeKey(e){if(typeof e==="string")return;return e.key}collectListeners(e){let t={};return Object.entries(e.props??{}).forEach(([n,r])=>{if(M(n)&&typeof r==="function")t[X(n)]=r}),{...t,...e.listeners??{}}}updateListeners(e,t,n){let r=this.listeners.get(e)??new Map,o=new Set(Object.keys(t)),i=new Set(Object.keys(n));o.forEach((s)=>{if(!i.has(s)||t[s]!==n[s]){let a=r.get(s);if(a)e.removeEventListener(a.eventName,a.listener),r.delete(s)}}),i.forEach((s)=>{if(!o.has(s)||t[s]!==n[s]){let{eventName:a,modifiers:c}=ee(s),m=te(n[s],c);e.addEventListener(a,m),r.set(s,{eventName:a,listener:m})}}),this.listeners.set(e,r)}setupReactiveAttribute(e,t,n,r){let o=g(()=>{e.setAttribute(t,r.templateEngine.evaluateTemplateValue(n))});this.trackEffect(e,o)}trackEffect(e,t){let n=this.effects.get(e)??new Set;n.add(t),this.effects.set(e,n)}}function L(e){if(e.startsWith("data")&&e.length>4)return`data${e.slice(4).replace(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}`;if(e==="tabIndex"||e==="colSpan"||e==="htmlFor")return e.toLowerCase();return e}class w{strategies;constructor(){this.strategies=[new oe,new ie,new se,new N]}mount(e,t){return this.findStrategy(e).mount(e,t)}patch(e,t,n,r){let o=this.findStrategy(e),i=this.findStrategy(t);if(o!==i){let s=i.mount(t,r);return n.parentNode?.replaceChild(s,n),o.unmount(e,n,r),s}return o.patch(e,t,n,r)}unmount(e,t,n){this.findStrategy(e).unmount(e,t,n)}findStrategy(e){let t=this.strategies.find((n)=>n.matches(e));if(!t)throw Error("No render strategy found for vnode");return t}}class oe{matches(e){return typeof e==="string"}mount(e,t){return t.templateEngine.parseTemplate(e)}patch(e,t,n,r){if(e===t)return n;let o=this.mount(t,r);return n.parentNode?.replaceChild(o,n),o}unmount(){}}class ie{instances=new WeakMap;instanceNodes=new Map;emitterUnsubscribers=new WeakMap;matches(e){return typeof e==="object"&&e!==null&&q(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let r=new e.component(this.createProps(e));if(t.appContext&&r.setAppContext)r.setAppContext(t.appContext);this.syncEmitters(r,e.emitters??{}),t.registerChild(r);let o=r.mountToNode();return this.trackInstanceNode(r,o),r.setElementChangeListener?.((i,s)=>{this.trackInstanceNode(r,i),this.trackInstanceNode(r,s)}),o}patch(e,t,n,r){if(n.nodeType===Node.COMMENT_NODE){let s=this.mount(t,r);return n.parentNode?.replaceChild(s,n),s}if(t.directions?.if===!1){let s=document.createComment("if");return n.parentNode?.replaceChild(s,n),this.unmount(e,n,r),s}let o=this.instances.get(n);if(o&&e.component===t.component){this.syncEmitters(o,t.emitters??{}),o.setProps(this.createProps(t));let s=o.getElement()??n;return this.trackInstanceNode(o,s),s}let i=this.mount(t,r);return n.parentNode?.replaceChild(i,n),this.unmount(e,n,r),i}unmount(e,t,n){let r=this.instances.get(t);if(r)this.clearEmitters(r),r.unmount(),this.clearInstanceNodes(r),n.unregisterChild(r)}createProps(e){return{...e.props??{},children:e.children??[]}}syncEmitters(e,t){let n=this.emitterUnsubscribers.get(e)??new Map;n.forEach(({listener:r,unsubscribe:o},i)=>{let s=t[i];if(!s||s!==r)o(),n.delete(i)}),Object.entries(t).forEach(([r,o])=>{if(n.get(r)?.listener===o)return;n.set(r,{listener:o,unsubscribe:e.on(r,o)})}),this.emitterUnsubscribers.set(e,n)}clearEmitters(e){this.emitterUnsubscribers.get(e)?.forEach(({unsubscribe:t})=>{t()}),this.emitterUnsubscribers.delete(e)}trackInstanceNode(e,t){this.instances.set(t,e);let n=this.instanceNodes.get(e)??new Set;n.add(t),this.instanceNodes.set(e,n)}clearInstanceNodes(e){this.instanceNodes.get(e)?.forEach((t)=>{this.instances.delete(t)}),this.instanceNodes.delete(e)}}class se{renderedChildren=new WeakMap;matches(e){return typeof e==="object"&&e!==null&&Y(e)}mount(e,t){if(e.directions?.if===!1)return document.createComment("if");let n=document.createElement("div");return n.setAttribute("data-slot",e.props.name),this.mountSlotChildren(n,this.resolveChildren(e,t),t),n}patch(e,t,n,r){if(n.nodeType===Node.COMMENT_NODE){let o=this.mount(t,r);return n.parentNode?.replaceChild(o,n),o}if(t.directions?.if===!1){let o=document.createComment("if");return n.parentNode?.replaceChild(o,n),this.unmount(e,n,r),o}if(n instanceof HTMLElement)n.setAttribute("data-slot",t.props.name),this.replaceSlotChildren(n,e,t,r);return n}unmount(e,t,n){if(!(t instanceof HTMLElement))return;this.unmountSlotChildren(t,n),this.renderedChildren.delete(t)}resolveChildren(e,t){return t.slots[e.props.name]??e.children??[]}replaceSlotChildren(e,t,n,r){let o=this.renderedChildren.get(e)??[],i=this.resolveChildren(n,r),s=Math.min(o.length,i.length);for(let a=0;a<s;a+=1){let c=e.childNodes[a];if(!c){e.appendChild(r.renderer.mount(i[a],r));continue}r.renderer.patch(o[a],i[a],c,r)}for(let a=s;a<i.length;a+=1)e.appendChild(r.renderer.mount(i[a],r));for(let a=o.length-1;a>=i.length;a-=1){let c=e.childNodes[a];if(c){if(r.renderer.unmount(o[a],c,r),c.parentNode===e)e.removeChild(c)}}this.renderedChildren.set(e,i)}mountSlotChildren(e,t,n){t.forEach((r)=>{e.appendChild(n.renderer.mount(r,n))}),this.renderedChildren.set(e,t)}unmountSlotChildren(e,t){(this.renderedChildren.get(e)??[]).forEach((r,o)=>{let i=e.childNodes[o];if(i)t.renderer.unmount(r,i,t)})}}class R{state;bindings=[];templateRegex=/{{(.*?)}}/g;constructor(e){this.state=e;if(!e||typeof e!=="object")throw Error("TemplateEngine requires a valid state object")}parseTemplate(e){if(typeof e!=="string")e=String(e);let t=document.createTextNode("");this.templateRegex.lastIndex=0;let n=Array.from(e.matchAll(this.templateRegex));if(n&&n.length>0)this.setupReactiveBindings(t,e,n);else t.textContent=e;return t}setupReactiveBindings(e,t,n){let r=new Set,o=this.evaluateTemplate(t,n,r);e.textContent=o;let i=g(()=>{try{let s=this.evaluateTemplate(t,n,r);if(e.textContent!==s)e.textContent=s}catch(s){console.error("Template update error:",s),e.textContent=`Error: ${s instanceof Error?s.message:"Unknown error"}`}});this.bindings.push({node:e,originalText:t,effect:i})}evaluateTemplate(e,t,n){let r=e;return t.forEach((o)=>{let i=o[1]?.trim();if(i){n.add(i);let s=this.getValueFromState(i),a=s===void 0||s===null?"":String(s);r=r.replace(o[0],a)}}),r}getValueFromState(e){if(!e)return;let t=e.split("."),n=this.state;for(let r of t){if(!n||typeof n!=="object")return;n=n[r]}return n}clearBindings(){this.bindings.forEach((e)=>{v(e.effect)}),this.bindings=[]}getBindingCount(){return this.bindings.length}hasExpressions(e){return this.templateRegex.lastIndex=0,this.templateRegex.test(e)}extractKeys(e){let t=[],n,r=new RegExp(this.templateRegex,"g");while((n=r.exec(e))!==null){let o=n[1]?.trim();if(o)t.push(o)}return t}evaluateTemplateValue(e){this.templateRegex.lastIndex=0;let t=Array.from(e.matchAll(this.templateRegex));if(!t||t.length===0)return e;let n=new Set;return this.evaluateTemplate(e,t,n)}}class S{props;vnode=null;el=null;renderer=new w;templateEngine;childComponents=new Set;eventListeners={};providers=new Map;updateEffect;appContext=null;parentComponent=null;elementChangeListener=null;styleManager;state;mounted=!1;constructor(e={}){this.props=e;this.styleManager=new ae,this.state=O(this.initState()??{}),this.templateEngine=new R(this.state),this.initStyles(),this.updateEffect=g(()=>{if(this.mounted)try{this.update()}catch(t){if(!this.dispatchError(t))throw t}},{throwOnError:!0,scheduler:(t)=>{b.enqueue(t)}})}mount(e){if(!e||!(e instanceof HTMLElement))throw Error("Invalid container element");try{e.appendChild(this.mountToNode())}catch(t){throw console.error("组件渲染错误:",t),t}}mountToNode(){if(this.mounted&&this.el)return this.el;return this.beforeMount(),this.el=f.getInstance().runWithEffect(this.updateEffect,()=>{try{return this.vnode=this.render(),this.renderer.mount(this.vnode,this.createRenderContext())}catch(e){if(this.dispatchError(e))return document.createComment("error-boundary");throw e}}),this.mounted=!0,this.onMounted(),this.el}update(){if(!this.el||!this.vnode)return;this.beforeUpdate();let e=this.vnode,t=this.el;if(this.el=f.getInstance().runWithEffect(this.updateEffect,()=>{let n=this.render(),r=this.renderer.patch(e,n,t,this.createRenderContext());return this.vnode=n,r}),t!==this.el)this.elementChangeListener?.(t,this.el);this.onUpdated()}unmount(){if(!this.mounted)return;if(this.beforeUnmount(),this.vnode&&this.el)this.renderer.unmount(this.vnode,this.el,this.createRenderContext());if(this.childComponents.clear(),Object.keys(this.eventListeners).forEach((e)=>{this.eventListeners[e].clear(),delete this.eventListeners[e]}),this.providers.clear(),this.parentComponent=null,this.elementChangeListener=null,this.templateEngine.clearBindings(),this.styleManager.destroy(),v(this.updateEffect),this.el?.parentNode)this.el.parentNode.removeChild(this.el);this.el=null,this.vnode=null,this.mounted=!1,this.onUnmounted()}setProps(e){if(this.props={...this.props,...e},this.mounted)b.enqueue(this.updateEffect)}setState(e){Object.assign(this.state,e)}setAppContext(e){this.appContext=e,this.childComponents.forEach((t)=>{t.setAppContext?.(e)})}setParentComponent(e){this.parentComponent=e}getParentComponent(){return this.parentComponent}setElementChangeListener(e){this.elementChangeListener=e}provide(e,t){this.providers.set(e,t)}inject(e,t){let n=this.resolveInjection(e);return n.found?n.value:t}resolveInjection(e){if(this.providers.has(e))return{found:!0,value:this.providers.get(e)};if(this.parentComponent?.resolveInjection)return this.parentComponent.resolveInjection(e);return this.resolveAppInjection(e)}getElement(){return this.el}beforeMount(){}onMounted(){}beforeUpdate(){}onUpdated(){}beforeUnmount(){}onUnmounted(){}dispatchError(e){let t=this.getParentComponent();while(t){let n=t;if(typeof n.onErrorCaptured==="function"){if(n.onErrorCaptured(e,this)===!1)return!0}t=t.getParentComponent?.()??null}return!1}getContext(){return this.appContext}get router(){return this.getRouterFrom(this.appContext)??this.getRouterFromGlobalApp()}emit(e,...t){this.eventListeners[e]?.forEach((n)=>{n(...t)})}on(e,t){if(!this.eventListeners[e])this.eventListeners[e]=new Set;return this.eventListeners[e].add(t),()=>this.off(e,t)}off(e,t){this.eventListeners[e]?.delete(t)}createRenderContext(){return{appContext:this.appContext,templateEngine:this.templateEngine,renderer:this.renderer,slots:this.collectSlots(),registerChild:(e)=>{this.childComponents.add(e),e.setParentComponent?.(this),e.setAppContext?.(this.appContext)},unregisterChild:(e)=>{this.childComponents.delete(e),e.setParentComponent?.(null)}}}collectSlots(){let e={default:[]};return(this.props.children??[]).forEach((n)=>{let r=this.getSlotName(n);if(!e[r])e[r]=[];e[r].push(this.normalizeSlotChild(n))}),e}getSlotName(e){if(typeof e==="string")return"default";return"slot"in e&&typeof e.slot==="string"?e.slot:"default"}normalizeSlotChild(e){if(typeof e==="string"||!("slot"in e))return e;let t={...e};return delete t.slot,t}getRouterFrom(e){if(!e||typeof e!=="object"||!("router"in e))return;return e.router}getRouterFromGlobalApp(){let e=globalThis.__APP__;return this.getRouterFrom(e)}resolveAppInjection(e){if(!this.appContext||typeof this.appContext!=="object")return{found:!1,value:void 0};return this.appContext.app?.resolveInjection?.(e)??{found:!1,value:void 0}}}var D=null;function pe(e){if(!e||!(e instanceof P))throw Error("Invalid router instance");D=e}function xe(){if(!D)throw Error("Router is not initialized. Please make sure you have installed the router plugin.");return D}function E(e){if(!e.startsWith("/"))return`/${e}`;return e||"/"}function A(e,t){let n=E(t.split("?")[0]);for(let i of e){if(i.path==="*")continue;let s=Te(i.path,n);if(s)return{route:i,params:s}}let r=e.find((i)=>i.path==="*");if(r)return{route:r,params:{pathMatch:n}};let o=e.find((i)=>i.path==="/");return o?{route:o,params:{}}:null}function Te(e,t){let n=ce(e),r=ce(t);if(n.length!==r.length)return null;let o={};for(let i=0;i<n.length;i+=1){let s=n[i],a=r[i];if(s.startsWith(":")){let c=s.slice(1);if(!c)return null;o[decodeURIComponent(c)]=decodeURIComponent(a);continue}if(s!==a)return null}return o}function ce(e){let t=E(e);if(t==="/")return[];return t.split("/").filter(Boolean)}function ue(e,t,n){let r=E(e),o=n==="/"?r:n+r;return t==="hash"?`#${o}`:o}function le(e,t){let n,r,o;if(e==="history")r=window.location.pathname+window.location.search,n=window.location.pathname,o=window.location.search;else{r=window.location.hash||"#/",n=r.startsWith("#")?r.slice(1):r;let s=n.indexOf("?");o=s>=0?n.slice(s+1):"",n=s>=0?n.slice(0,s):n}if(n.startsWith(t)&&t!=="/"&&n!=="/")n=n.slice(t.length);return n=E(n),{path:n,fullPath:r,query:we(o),params:{}}}function U(e,t,n,r){let o=E(e),i=r==="/"?o:r+o;if(n==="history"){if(t)window.history.replaceState({},"",i);else window.history.pushState({},"",i);return}if(t){let s=window.location.href.split("#")[0];window.location.replace(`${s}#${i}`);return}window.location.hash=i}function we(e){let t={},n=e.startsWith("?")?e.slice(1):e;if(!n)return t;return n.split("&").forEach((r)=>{let[o,i]=r.split("=");if(o)t[decodeURIComponent(o)]=i?decodeURIComponent(i):""}),t}function Se(e){let t=e.indexOf("?");if(t<0)return{};let n=e.slice(t+1),r={};if(!n)return r;return n.split("&").forEach((o)=>{let[i,s]=o.split("=");if(i)r[decodeURIComponent(i)]=s?decodeURIComponent(s):""}),r}class P{currentRoute=null;currentLocation=null;routes=[];app=null;mode;base;routeChangeListeners=[];beforeGuards=[];afterHooks=[];removeWindowListener;constructor(e){let t=Array.isArray(e)?{routes:e}:e;this.routes=t.routes||[],this.mode=t.mode||"history",this.base=t.base||"/",this.validateRoutes(),this.initEvents(),this.resolveCurrentRoute()}install(e){this.app=e,e.router=this,pe(this);let t=e.getContext();t.router=this,this.resolveCurrentRoute()}push(e){this.navigate(e,!1)}replace(e){this.navigate(e,!0)}forward(){window.history.forward()}back(){window.history.back()}go(e){window.history.go(e)}getCurrentRoute(){if(!this.currentLocation)this.resolveCurrentRoute();return this.currentLocation}getCurrentRouteRecord(){if(!this.currentRoute)this.resolveCurrentRoute();return this.currentRoute}onRouteChange(e){return this.routeChangeListeners.push(e),()=>{let t=this.routeChangeListeners.indexOf(e);if(t>-1)this.routeChangeListeners.splice(t,1)}}beforeEach(e){return this.beforeGuards.push(e),()=>{let t=this.beforeGuards.indexOf(e);if(t>-1)this.beforeGuards.splice(t,1)}}afterEach(e){return this.afterHooks.push(e),()=>{let t=this.afterHooks.indexOf(e);if(t>-1)this.afterHooks.splice(t,1)}}getRoutes(){return[...this.routes]}addRoute(e){if(this.routes.some((n)=>n.path===e.path))throw Error(`Route already exists: ${e.path}`);if(this.routes.push(e),this.getCurrentLocation().path===e.path)this.handleRouteChange()}createHref(e){return ue(e,this.mode,this.base)}destroy(){if(this.removeWindowListener?.(),this.removeWindowListener=void 0,this.app?.router===this)this.app.router=void 0;this.app=null}navigate(e,t){if(!e||typeof e!=="string")throw Error("Path must be a non-empty string");let n=this.currentLocation,r=this.resolveTarget(e);if(!r)return;let o=r.location;for(let i of this.beforeGuards){let s=i(o,n);if(s===!1)return;if(typeof s==="string"&&s!==e){this.navigate(s,t);return}}if(n&&this.isSameLocation(n,o))return;U(r.path,t,this.mode,this.base),this.currentRoute=r.route,this.currentLocation=o,this.triggerRouteChangeListeners(o,n),this.afterHooks.forEach((i)=>{try{i(o,n)}catch(s){console.error("Route afterEach error:",s)}})}resolveTarget(e){let t=A(this.routes,e.split("?")[0]);if(!t)return null;let n=this.applyRedirect(t),r=n?.path??e,o=n?.route??t.route;return{path:r,route:o,location:{path:r.split("?")[0],query:Se(r),params:n?.params??t.params,fullPath:r,name:o?.name,meta:o?.meta}}}applyRedirect(e){let t=new Set,n=e,r="";while(n.route.redirect){if(t.has(n.route.path))throw Error(`Redirect loop detected for route: ${n.route.path}`);t.add(n.route.path),r=n.route.redirect;let o=A(this.routes,r.split("?")[0]);if(!o)return null;n=o}return r?{route:n.route,params:n.params,path:r}:null}validateRoutes(){if(!Array.isArray(this.routes))throw Error("Router routes must be an array");let e=new Set;this.routes.forEach((t)=>{if(!t.component&&!t.redirect)throw Error(`Route ${t.path} must define a component or redirect`);if(e.has(t.path))throw Error(`Duplicate route path: ${t.path}`);e.add(t.path)})}initEvents(){if(typeof window>"u")return;let e=this.mode==="history"?"popstate":"hashchange",t=()=>{this.handleRouteChange()};window.addEventListener(e,t),this.removeWindowListener=()=>{window.removeEventListener(e,t)}}handleRouteChange(){let e=this.currentLocation,t=this.resolveCurrentRoute();if(!this.isSameLocation(e,t))this.triggerRouteChangeListeners(t,e)}resolveCurrentRoute(){let e=this.getCurrentLocation(),t=A(this.routes,e.path),n=t?this.applyRedirect(t):null,r=n?.route??t?.route??null;if(n&&n.path!==e.path)U(n.path,!0,this.mode,this.base);return this.currentRoute=r,this.currentLocation={...e,params:n?.params??t?.params??{},name:r?.name,meta:r?.meta},this.currentLocation}getCurrentLocation(){return le(this.mode,this.base)}isSameLocation(e,t){return e?.fullPath===t?.fullPath&&e?.name===t?.name}triggerRouteChangeListeners(e,t){this.routeChangeListeners.forEach((n)=>{try{n(e,t)}catch(r){console.error("Route change listener error:",r)}})}}class Me extends S{unsubscribe;initState(){return{currentPath:this.router?.getCurrentRoute()?.path??window.location.pathname}}initStyles(){}onMounted(){let e=this.router;this.unsubscribe=e?.onRouteChange((t)=>{this.state.currentPath=t.path})}onUnmounted(){this.unsubscribe?.()}render(){let e=this.router,t=this.props.activeClass??"active",n=this.state.currentPath===this.props.to,r=[this.props.className,n?t:void 0].filter(Boolean).join(" ");return{tag:"a",props:{href:e?.createHref(this.props.to)??this.props.to,className:r},listeners:{click:(o)=>{if(o.preventDefault(),this.props.replace)e?.replace(this.props.to);else e?.push(this.props.to)}},children:this.props.children&&this.props.children.length>0?this.props.children:[this.props.to]}}}class Le extends S{unsubscribe;initState(){let e=this.router;return{route:e?.getCurrentRoute()??null,record:e?.getCurrentRouteRecord()??null}}initStyles(){}onMounted(){let e=this.router;this.unsubscribe=e?.onRouteChange((t)=>{this.state.route=t,this.state.record=e.getCurrentRouteRecord()})}onUnmounted(){this.unsubscribe?.()}render(){let e=this.state.record??this.router?.getCurrentRouteRecord();return{tag:"div",props:{"data-router-view":""},children:e?.component?[{component:e.component}]:[]}}}function kn(e){return new P(e)}var Ne=new Set(["base","link","meta"]);function de(e){let t=e.lang??"en",n=e.charset??"utf-8",r=e.viewport??"width=device-width, initial-scale=1",o=I({lang:t,...e.htmlAttributes??{}}),i=I(e.bodyAttributes),s=Pe(e.body);return["<!doctype html>",`<html${o}>`,"<head>",` <meta charset="${x(n)}">`,` <meta name="viewport" content="${x(r)}">`,` <title>${x(e.title)}</title>`,e.description?` <meta name="description" content="${x(e.description)}">`:"",...(e.head??[]).map((a)=>` ${Ae(a)}`),e.styles&&e.styles.length>0?` <style>${K(e.styles)}</style>`:"","</head>",`<body${i}>`,s,...(e.scripts??[]).map((a)=>` ${Ie(a)}`),"</body>","</html>"].filter((a)=>a!=="").join(`
|
|
2
|
+
`)}function Pe(e){if(typeof document>"u")throw Error("renderHtmlDocument requires a DOM-like document");let t=document.createElement("div"),n=new w,r=new Set,o=Array.isArray(e)?e:[e],i={templateEngine:new R({}),renderer:n,slots:{default:[]},registerChild:(a)=>{r.add(a)},unregisterChild:(a)=>{r.delete(a)}};o.forEach((a)=>{t.appendChild(n.mount(a,i))});let s=t.innerHTML;return r.forEach((a)=>{a.unmount()}),s}function Ae(e){let t=I(e.attributes);if(Ne.has(e.tag)&&!e.text)return`<${e.tag}${t}>`;return`<${e.tag}${t}>${x(e.text??"")}</${e.tag}>`}function Ie(e){return`<script${I({type:e.type,src:e.src,async:e.async,defer:e.defer,...e.attributes??{}})}></script>`}function I(e={}){let t=Object.entries(e).flatMap(([n,r])=>{if(r===!1||r===null||r===void 0)return[];return r===!0?[n]:[`${n}="${x(String(r))}"`]}).join(" ");return t?` ${t}`:""}function x(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var he="#app";class He{options;container=null;rootInstance=null;mounted=!1;templateEngine=null;appContext;providers=new Map;plugins=[];unmountedCallback;router;constructor(e={}){this.options=e;this.appContext={app:this,version:"0.1.0",config:e.config||{}}}handleError(e){console.error("应用错误:",e),this.renderErrorUI(e)}renderErrorUI(e){if(!this.container)return;this.container.innerHTML=`
|
|
3
|
+
<div style="padding: 20px; background-color: #ffebee; color: #c62828; font-family: Arial, sans-serif;">
|
|
4
|
+
<h3>应用错误</h3>
|
|
5
|
+
<p>${e.message}</p>
|
|
6
|
+
<pre style="background-color: #fff; padding: 10px; border-radius: 4px; overflow: auto;">${e.stack}</pre>
|
|
7
|
+
</div>
|
|
8
|
+
`}use(e,...t){if(typeof e.install!=="function")throw Error("插件必须提供 install 方法");return e.install(this,...t),this.plugins.push({plugin:e,args:t}),this}mount(){if(this.mounted){console.warn("应用已经处于运行状态");return}let e=this.resolveMountContainer();if(!e)return;try{if(this.container=e,globalThis.__APP__=this,this.options.root){if(this.rootInstance=new this.options.root(this.options.rootProps),"setAppContext"in this.rootInstance)this.rootInstance.setAppContext(this.appContext);if(this.options.state&&"setState"in this.rootInstance)this.rootInstance.setState(this.options.state);this.rootInstance.mount(this.container),this.templateEngine=new R(this.options.state||{})}this.mounted=!0,this.onMounted()}catch(t){this.handleError(t)}}unmount(){if(!this.mounted){console.warn("应用未处于运行状态");return}try{if(this.onBeforeUnmount(),this.rootInstance){if("unmount"in this.rootInstance)this.rootInstance.unmount();this.rootInstance=null,this.mounted=!1,delete globalThis.__APP__}if(this.templateEngine)this.templateEngine.clearBindings(),this.templateEngine=null;if(this.container)this.container.innerHTML="";if(this.unmountedCallback)this.unmountedCallback()}catch(e){console.error("Failed to unmount app:",e)}}isRunning(){return this.mounted}updateRootComponent(e){if(this.mounted)this.unmount();this.options.root=e,this.mount()}update(e){if(!this.mounted)return console.warn("Cannot update unmounted app"),this;try{if(e&&this.options.state){if(this.options.state={...this.options.state,...e},this.rootInstance&&"setState"in this.rootInstance)this.rootInstance.setState(e);if(this.templateEngine)this.templateEngine.state=this.options.state}this.onUpdated()}catch(t){console.error("Failed to update app:",t)}return this}getContext(){return this.appContext}provide(e,t){return this.providers.set(e,t),this}inject(e,t){let n=this.resolveInjection(e);return n.found?n.value:t}resolveInjection(e){if(!this.providers.has(e))return{found:!1,value:void 0};return{found:!0,value:this.providers.get(e)}}getState(){return this.options.state}setState(e){if(this.options.state=e,this.mounted)this.update();return this}onUnmounted(e){return this.unmountedCallback=e,this}renderHtmlDocument(e={}){let t=this.options.document??{},n=this.mergeDocumentScripts(t.scripts,e.scripts);return de({...t,...e,title:e.title??t.title??"TransOne App",body:e.body??t.body??this.createMountDocumentBody(),scripts:n})}resolveRootElement(e){if(!e)return null;if(typeof e==="string"){if(typeof document>"u")return null;return document.querySelector(e)}return typeof Element<"u"&&e instanceof Element?e:null}resolveMountContainer(){if(typeof document>"u")return null;let e=this.resolveRootElement(this.options.rootElement??he);return e instanceof HTMLElement?e:null}createMountDocumentBody(){let e=this.options.rootElement??he;if(typeof e==="string")return this.createMountElementFromSelector(e);if(typeof Element<"u"&&e instanceof Element){let t={};if(e.id)t.id=e.id;if(e.className)t.className=e.className;return{tag:e.tagName.toLowerCase(),props:t}}return T({props:{id:"app"}})}createMountElementFromSelector(e){if(e.startsWith("#")&&e.length>1)return T({props:{id:e.slice(1)}});if(e.startsWith(".")&&e.length>1)return T({props:{className:e.slice(1)}});return T({props:{"data-transone-root":e}})}mergeDocumentScripts(e,t){if(!e&&!t)return;return[...e??[],...t??[]]}onMounted(){this.plugins.forEach(({plugin:e})=>{if(e&&typeof e.onMounted==="function")e.onMounted(this)})}onUpdated(){this.plugins.forEach(({plugin:e})=>{if(e&&typeof e.onUpdated==="function")e.onUpdated(this)})}onBeforeUnmount(){this.plugins.forEach(({plugin:e})=>{if(e&&typeof e.onBeforeUnmount==="function")e.onBeforeUnmount(this)})}}
|
|
9
|
+
export{b as a,Ue as b,Ke as c,f as d,O as e,We as f,g,Fe as h,Ge as i,G as j,qe as k,v as l,ze as m,me as n,Ye as o,q as p,z as q,Y as r,Ze as s,ge as t,T as u,Je as v,Xe as w,et as x,tt as y,nt as z,rt as A,ot as B,it as C,st as D,at as E,pt as F,ct as G,ut as H,lt as I,dt as J,ht as K,ft as L,mt as M,gt as N,vt as O,yt as P,Rt as Q,Ct as R,bt as S,Et as T,xt as U,Tt as V,wt as W,St as X,Mt as Y,Lt as Z,Nt as _,Pt as $,At as aa,It as ba,Ht as ca,kt as da,jt as ea,Ot as fa,Vt as ga,Bt as ha,_t as ia,ve as ja,Q as ka,ye as la,_ as ma,N as na,w as oa,oe as pa,ie as qa,se as ra,R as sa,S as ta,de as ua,He as va,xe as wa,P as xa,Me as ya,Le as za,kn as Aa};
|
|
10
|
+
|
|
11
|
+
//# debugId=8A550B29FEBC7E8B64756E2164756E21
|
|
12
|
+
//# sourceMappingURL=index-3t506ckz.js.map
|