@lytjs/core 4.0.4 → 4.0.5

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.
@@ -1 +1 @@
1
- var I=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(r,o)=>{for(var t in o)I(r,t,{get:o[t],enumerable:!0})},M=(r,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of m(o))!h.call(r,s)&&s!==t&&I(r,s,{get:()=>o[s],enumerable:!(i=P(o,s))||i.enumerable});return r};var y=r=>M(I({},"__esModule",{value:!0}),r);var V={};d(V,{ErrorBoundary:()=>R,ErrorCategory:()=>n.ErrorCategory,LytError:()=>a,LytErrorCodes:()=>N,NewLytError:()=>E.LytError,NewLytErrorCodes:()=>n.LytErrorCodes,callWithErrorHandling:()=>L,createCompilerError:()=>E.createCompilerError,createComponentError:()=>E.createComponentError,createMessage:()=>C,createRendererError:()=>E.createRendererError,getCategory:()=>n.getCategory,getDevMode:()=>f,getErrorMessage:()=>n.getErrorMessage,handleError:()=>D,resetWarnedMessages:()=>u,setDevMode:()=>g,warn:()=>A,warnOnce:()=>l,warnOnceUtil:()=>l,warnUtil:()=>A});module.exports=y(V);var N=(e=>(e[e.INVALID_ARGUMENT=1001]="INVALID_ARGUMENT",e[e.NOT_FOUND=1002]="NOT_FOUND",e[e.ALREADY_EXISTS=1003]="ALREADY_EXISTS",e[e.OPERATION_FAILED=1004]="OPERATION_FAILED",e[e.REACTIVE_READONLY=2001]="REACTIVE_READONLY",e[e.REACTIVE_EFFECT_DISPOSED=2002]="REACTIVE_EFFECT_DISPOSED",e[e.COMPUTED_CYCLE=2003]="COMPUTED_CYCLE",e[e.PARSE_ERROR=3001]="PARSE_ERROR",e[e.INVALID_EXPRESSION=3002]="INVALID_EXPRESSION",e[e.INVALID_DIRECTIVE=3003]="INVALID_DIRECTIVE",e[e.INVALID_TEMPLATE=3004]="INVALID_TEMPLATE",e[e.RENDER_ERROR=4001]="RENDER_ERROR",e[e.HYDRATION_MISMATCH=4002]="HYDRATION_MISMATCH",e[e.INVALID_VNODE=4003]="INVALID_VNODE",e[e.COMPONENT_INVALID_PROPS=5001]="COMPONENT_INVALID_PROPS",e[e.COMPONENT_MISSING_TEMPLATE=5002]="COMPONENT_MISSING_TEMPLATE",e[e.COMPONENT_LIFECYCLE_ERROR=5003]="COMPONENT_LIFECYCLE_ERROR",e[e.ROUTE_NOT_FOUND=6001]="ROUTE_NOT_FOUND",e[e.ROUTE_DUPLICATE=6002]="ROUTE_DUPLICATE",e[e.NAVIGATION_ABORTED=6003]="NAVIGATION_ABORTED",e[e.NAVIGATION_FAILED=6004]="NAVIGATION_FAILED",e[e.STORE_NOT_FOUND=7001]="STORE_NOT_FOUND",e[e.STORE_DUPLICATE=7002]="STORE_DUPLICATE",e))(N||{});var a=class extends Error{constructor(o,t,i){let s=`[Lyt ${o}] ${t}`;super(s),this.name="LytError",this.code=o,this.details=i}};var _=class _{constructor(o){this.errors=[],this.options=o||{},this._hasError=!1}get hasError(){return this._hasError}static setGlobalHandler(o){_.globalHandler=o}capture(o,t,i){var p;let s={error:o,vm:t,info:i||"",timestamp:Date.now()};this.errors.push(s),this._hasError=!0;let c=(p=this.options.maxErrors)!=null?p:100;this.errors.length>c&&this.errors.splice(0,this.errors.length-c),!(this.options.onErrorCaptured&&this.options.onErrorCaptured(o instanceof a?o:new a(1004,o.message),t,s.info)===!0)&&this.options.onError&&this.options.onError(o instanceof a?o:new a(1004,o.message),t)}getFallback(o){if(!this.options.fallback||this.errors.length===0)return null;let t=this.errors[this.errors.length-1];return this.options.fallback(t.error,t.vm,t.info)}getErrors(){return this.errors.slice()}getErrorCount(){return this.errors.length}getLastErrors(){return this.errors.length===0?null:{...this.errors[this.errors.length-1]}}clear(){this.errors=[],this._hasError=!1}};_.globalHandler=null;var R=_,O=!0,T=new Set;function g(r){O=r}function f(){return O}function A(r){}function l(r){O&&(T.has(r)||T.add(r))}function u(){T.clear()}var S={1001:r=>`\u53C2\u6570 "${r}" \u65E0\u6548\u3002\u8BF7\u68C0\u67E5\u4F20\u5165\u7684\u503C\u7C7B\u578B\u548C\u8303\u56F4\u3002`,1002:r=>`"${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8D44\u6E90\u540D\u79F0\u6216\u8DEF\u5F84\u662F\u5426\u6B63\u786E\u3002`,1003:r=>`"${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u4F7F\u7528\u4E0D\u540C\u7684\u540D\u79F0\u3002`,1004:r=>`\u64CD\u4F5C "${r}" \u6267\u884C\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u76F8\u5173\u914D\u7F6E\u548C\u72B6\u6001\u3002`,2001:r=>`\u65E0\u6CD5\u4FEE\u6539\u53EA\u8BFB\u54CD\u5E94\u5F0F\u5C5E\u6027 "${r}"\u3002\u53EA\u8BFB\u5BF9\u8C61\u4E0D\u5141\u8BB8\u76F4\u63A5\u8D4B\u503C\u3002`,2002:()=>"\u526F\u4F5C\u7528\u51FD\u6570\u5DF2\u88AB\u9500\u6BC1\uFF0C\u65E0\u6CD5\u518D\u6B21\u6267\u884C\u3002\u8BF7\u521B\u5EFA\u65B0\u7684\u526F\u4F5C\u7528\u3002",2003:()=>"\u8BA1\u7B97\u5C5E\u6027\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56\u3002\u8BF7\u68C0\u67E5 computed \u51FD\u6570\u662F\u5426\u5F15\u7528\u4E86\u81EA\u8EAB\u3002",3001:r=>`\u6A21\u677F\u89E3\u6790\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u6A21\u677F\u8BED\u6CD5\u662F\u5426\u6B63\u786E\u3002`,3002:r=>`\u65E0\u6548\u7684\u8868\u8FBE\u5F0F "${r}"\u3002\u8BF7\u68C0\u67E5\u8868\u8FBE\u5F0F\u8BED\u6CD5\u3002`,3003:r=>`\u65E0\u6548\u7684\u6307\u4EE4 "${r}"\u3002\u8BF7\u786E\u8BA4\u6307\u4EE4\u540D\u79F0\u662F\u5426\u6B63\u786E\u3002`,3004:r=>`\u65E0\u6548\u7684\u6A21\u677F\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u6A21\u677F\u5185\u5BB9\u3002`,4001:r=>`\u6E32\u67D3\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u7EC4\u4EF6\u7684 render \u51FD\u6570\u6216\u6A21\u677F\u3002`,4002:r=>`\u6C34\u5408\u4E0D\u5339\u914D\uFF1A${r}\u3002\u670D\u52A1\u7AEF\u6E32\u67D3\u4E0E\u5BA2\u6237\u7AEF\u6E32\u67D3\u7ED3\u679C\u4E0D\u4E00\u81F4\u3002`,4003:r=>`\u65E0\u6548\u7684\u865A\u62DF\u8282\u70B9\uFF1A${r}\u3002VNode \u7F3A\u5C11\u5FC5\u8981\u7684 type \u6216\u5176\u4ED6\u5C5E\u6027\u3002`,5001:r=>`\u7EC4\u4EF6\u5C5E\u6027\u65E0\u6548\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u4F20\u5165\u7684 props \u662F\u5426\u7B26\u5408\u7EC4\u4EF6\u5B9A\u4E49\u3002`,5002:r=>`\u7EC4\u4EF6 "${r}" \u7F3A\u5C11 template \u6216 render \u51FD\u6570\u3002\u8BF7\u786E\u4FDD\u7EC4\u4EF6\u5B9A\u4E49\u4E2D\u5305\u542B template \u5B57\u7B26\u4E32\u6216 render \u65B9\u6CD5\u3002`,5003:r=>`\u7EC4\u4EF6\u751F\u547D\u5468\u671F\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u751F\u547D\u5468\u671F\u94A9\u5B50\u51FD\u6570\u3002`,6001:r=>`\u8DEF\u7531 "${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8DEF\u7531\u8DEF\u5F84\u662F\u5426\u5DF2\u6CE8\u518C\u3002`,6002:r=>`\u8DEF\u7531 "${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u907F\u514D\u91CD\u590D\u6CE8\u518C\u76F8\u540C\u7684\u8DEF\u7531\u8DEF\u5F84\u3002`,6003:r=>`\u5BFC\u822A\u88AB\u4E2D\u6B62\uFF1A${r}\u3002\u53EF\u80FD\u88AB\u5BFC\u822A\u5B88\u536B\u62E6\u622A\u3002`,6004:r=>`\u5BFC\u822A\u5931\u8D25\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u76EE\u6807\u8DEF\u7531\u662F\u5426\u6709\u6548\u3002`,7001:r=>`Store "${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4 store \u662F\u5426\u5DF2\u6CE8\u518C\u3002`,7002:r=>`Store "${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u907F\u514D\u91CD\u590D\u521B\u5EFA\u76F8\u540C ID \u7684 store\u3002`};function C(r,...o){let t=S[r];if(t){let i=t(...o);return`[Lyt ${r}] ${i}`}return`[Lyt ${r}] \u672A\u77E5\u9519\u8BEF\u3002`}function D(r,o,t){R.globalHandler&&R.globalHandler(r,o,t||""),O&&r instanceof a&&r.details}function L(r,o){try{return r()}catch(t){D(t instanceof Error?t:new Error(String(t)),o);return}}var n=require("@lytjs/common");var E=require("@lytjs/common");
1
+ var I=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var d=(r,o)=>{for(var t in o)I(r,t,{get:o[t],enumerable:!0})},M=(r,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of h(o))!y.call(r,s)&&s!==t&&I(r,s,{get:()=>o[s],enumerable:!(i=P(o,s))||i.enumerable});return r};var m=r=>M(I({},"__esModule",{value:!0}),r);var V={};d(V,{ErrorBoundary:()=>R,ErrorCategory:()=>n.ErrorCategory,LytError:()=>a,LytErrorCodes:()=>N,NewLytError:()=>E.LytError,NewLytErrorCodes:()=>n.LytErrorCodes,callWithErrorHandling:()=>C,createCompilerError:()=>E.createCompilerError,createComponentError:()=>E.createComponentError,createMessage:()=>L,createRendererError:()=>E.createRendererError,getCategory:()=>n.getCategory,getDevMode:()=>u,getErrorMessage:()=>n.getErrorMessage,handleError:()=>c,resetWarnedMessages:()=>g,setDevMode:()=>f,warn:()=>l,warnOnce:()=>A,warnOnceUtil:()=>A,warnUtil:()=>l});module.exports=m(V);var N=(e=>(e[e.INVALID_ARGUMENT=1001]="INVALID_ARGUMENT",e[e.NOT_FOUND=1002]="NOT_FOUND",e[e.ALREADY_EXISTS=1003]="ALREADY_EXISTS",e[e.OPERATION_FAILED=1004]="OPERATION_FAILED",e[e.REACTIVE_READONLY=2001]="REACTIVE_READONLY",e[e.REACTIVE_EFFECT_DISPOSED=2002]="REACTIVE_EFFECT_DISPOSED",e[e.COMPUTED_CYCLE=2003]="COMPUTED_CYCLE",e[e.PARSE_ERROR=3001]="PARSE_ERROR",e[e.INVALID_EXPRESSION=3002]="INVALID_EXPRESSION",e[e.INVALID_DIRECTIVE=3003]="INVALID_DIRECTIVE",e[e.INVALID_TEMPLATE=3004]="INVALID_TEMPLATE",e[e.RENDER_ERROR=4001]="RENDER_ERROR",e[e.HYDRATION_MISMATCH=4002]="HYDRATION_MISMATCH",e[e.INVALID_VNODE=4003]="INVALID_VNODE",e[e.COMPONENT_INVALID_PROPS=5001]="COMPONENT_INVALID_PROPS",e[e.COMPONENT_MISSING_TEMPLATE=5002]="COMPONENT_MISSING_TEMPLATE",e[e.COMPONENT_LIFECYCLE_ERROR=5003]="COMPONENT_LIFECYCLE_ERROR",e[e.ROUTE_NOT_FOUND=6001]="ROUTE_NOT_FOUND",e[e.ROUTE_DUPLICATE=6002]="ROUTE_DUPLICATE",e[e.NAVIGATION_ABORTED=6003]="NAVIGATION_ABORTED",e[e.NAVIGATION_FAILED=6004]="NAVIGATION_FAILED",e[e.STORE_NOT_FOUND=7001]="STORE_NOT_FOUND",e[e.STORE_DUPLICATE=7002]="STORE_DUPLICATE",e))(N||{});var a=class extends Error{constructor(o,t,i){let s=`[Lyt ${o}] ${t}`;super(s),this.name="LytError",this.code=o,this.details=i}};var _=class _{constructor(o){this.errors=[],this.options=o||{},this._hasError=!1}get hasError(){return this._hasError}static setGlobalHandler(o){_.globalHandler=o}capture(o,t,i){var p;let s={error:o,vm:t,info:i||"",timestamp:Date.now()};this.errors.push(s),this._hasError=!0;let D=(p=this.options.maxErrors)!=null?p:100;this.errors.length>D&&this.errors.splice(0,this.errors.length-D),!(this.options.onErrorCaptured&&this.options.onErrorCaptured(o instanceof a?o:new a(1004,o.message),t,s.info)===!0)&&this.options.onError&&this.options.onError(o instanceof a?o:new a(1004,o.message),t)}getFallback(o){if(!this.options.fallback||this.errors.length===0)return null;let t=this.errors[this.errors.length-1];return this.options.fallback(t.error,t.vm,t.info)}getErrors(){return this.errors.slice()}getErrorCount(){return this.errors.length}getLastErrors(){return this.errors.length===0?null:{...this.errors[this.errors.length-1]}}clear(){this.errors=[],this._hasError=!1}};_.globalHandler=null;var R=_,O=!0,T=new Set;function f(r){O=r}function u(){return O}function l(r){if(!O)return;let o=console.warn;typeof o=="function"&&o(`[Lyt warn] ${r}`)}function A(r){if(!O||T.has(r))return;T.add(r);let o=console.warn;typeof o=="function"&&o(`[Lyt warn] ${r}`)}function g(){T.clear()}var S={1001:r=>`\u53C2\u6570 "${r}" \u65E0\u6548\u3002\u8BF7\u68C0\u67E5\u4F20\u5165\u7684\u503C\u7C7B\u578B\u548C\u8303\u56F4\u3002`,1002:r=>`"${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8D44\u6E90\u540D\u79F0\u6216\u8DEF\u5F84\u662F\u5426\u6B63\u786E\u3002`,1003:r=>`"${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u4F7F\u7528\u4E0D\u540C\u7684\u540D\u79F0\u3002`,1004:r=>`\u64CD\u4F5C "${r}" \u6267\u884C\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u76F8\u5173\u914D\u7F6E\u548C\u72B6\u6001\u3002`,2001:r=>`\u65E0\u6CD5\u4FEE\u6539\u53EA\u8BFB\u54CD\u5E94\u5F0F\u5C5E\u6027 "${r}"\u3002\u53EA\u8BFB\u5BF9\u8C61\u4E0D\u5141\u8BB8\u76F4\u63A5\u8D4B\u503C\u3002`,2002:()=>"\u526F\u4F5C\u7528\u51FD\u6570\u5DF2\u88AB\u9500\u6BC1\uFF0C\u65E0\u6CD5\u518D\u6B21\u6267\u884C\u3002\u8BF7\u521B\u5EFA\u65B0\u7684\u526F\u4F5C\u7528\u3002",2003:()=>"\u8BA1\u7B97\u5C5E\u6027\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56\u3002\u8BF7\u68C0\u67E5 computed \u51FD\u6570\u662F\u5426\u5F15\u7528\u4E86\u81EA\u8EAB\u3002",3001:r=>`\u6A21\u677F\u89E3\u6790\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u6A21\u677F\u8BED\u6CD5\u662F\u5426\u6B63\u786E\u3002`,3002:r=>`\u65E0\u6548\u7684\u8868\u8FBE\u5F0F "${r}"\u3002\u8BF7\u68C0\u67E5\u8868\u8FBE\u5F0F\u8BED\u6CD5\u3002`,3003:r=>`\u65E0\u6548\u7684\u6307\u4EE4 "${r}"\u3002\u8BF7\u786E\u8BA4\u6307\u4EE4\u540D\u79F0\u662F\u5426\u6B63\u786E\u3002`,3004:r=>`\u65E0\u6548\u7684\u6A21\u677F\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u6A21\u677F\u5185\u5BB9\u3002`,4001:r=>`\u6E32\u67D3\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u7EC4\u4EF6\u7684 render \u51FD\u6570\u6216\u6A21\u677F\u3002`,4002:r=>`\u6C34\u5408\u4E0D\u5339\u914D\uFF1A${r}\u3002\u670D\u52A1\u7AEF\u6E32\u67D3\u4E0E\u5BA2\u6237\u7AEF\u6E32\u67D3\u7ED3\u679C\u4E0D\u4E00\u81F4\u3002`,4003:r=>`\u65E0\u6548\u7684\u865A\u62DF\u8282\u70B9\uFF1A${r}\u3002VNode \u7F3A\u5C11\u5FC5\u8981\u7684 type \u6216\u5176\u4ED6\u5C5E\u6027\u3002`,5001:r=>`\u7EC4\u4EF6\u5C5E\u6027\u65E0\u6548\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u4F20\u5165\u7684 props \u662F\u5426\u7B26\u5408\u7EC4\u4EF6\u5B9A\u4E49\u3002`,5002:r=>`\u7EC4\u4EF6 "${r}" \u7F3A\u5C11 template \u6216 render \u51FD\u6570\u3002\u8BF7\u786E\u4FDD\u7EC4\u4EF6\u5B9A\u4E49\u4E2D\u5305\u542B template \u5B57\u7B26\u4E32\u6216 render \u65B9\u6CD5\u3002`,5003:r=>`\u7EC4\u4EF6\u751F\u547D\u5468\u671F\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u751F\u547D\u5468\u671F\u94A9\u5B50\u51FD\u6570\u3002`,6001:r=>`\u8DEF\u7531 "${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8DEF\u7531\u8DEF\u5F84\u662F\u5426\u5DF2\u6CE8\u518C\u3002`,6002:r=>`\u8DEF\u7531 "${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u907F\u514D\u91CD\u590D\u6CE8\u518C\u76F8\u540C\u7684\u8DEF\u7531\u8DEF\u5F84\u3002`,6003:r=>`\u5BFC\u822A\u88AB\u4E2D\u6B62\uFF1A${r}\u3002\u53EF\u80FD\u88AB\u5BFC\u822A\u5B88\u536B\u62E6\u622A\u3002`,6004:r=>`\u5BFC\u822A\u5931\u8D25\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u76EE\u6807\u8DEF\u7531\u662F\u5426\u6709\u6548\u3002`,7001:r=>`Store "${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4 store \u662F\u5426\u5DF2\u6CE8\u518C\u3002`,7002:r=>`Store "${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u907F\u514D\u91CD\u590D\u521B\u5EFA\u76F8\u540C ID \u7684 store\u3002`};function L(r,...o){let t=S[r];if(t){let i=t(...o);return`[Lyt ${r}] ${i}`}return`[Lyt ${r}] \u672A\u77E5\u9519\u8BEF\u3002`}function c(r,o,t){R.globalHandler&&R.globalHandler(r,o,t||""),O&&r instanceof a&&r.details}function C(r,o){try{return r()}catch(t){c(t instanceof Error?t:new Error(String(t)),o);return}}var n=require("@lytjs/common");var E=require("@lytjs/common");
@@ -1 +1 @@
1
- var T=(e=>(e[e.INVALID_ARGUMENT=1001]="INVALID_ARGUMENT",e[e.NOT_FOUND=1002]="NOT_FOUND",e[e.ALREADY_EXISTS=1003]="ALREADY_EXISTS",e[e.OPERATION_FAILED=1004]="OPERATION_FAILED",e[e.REACTIVE_READONLY=2001]="REACTIVE_READONLY",e[e.REACTIVE_EFFECT_DISPOSED=2002]="REACTIVE_EFFECT_DISPOSED",e[e.COMPUTED_CYCLE=2003]="COMPUTED_CYCLE",e[e.PARSE_ERROR=3001]="PARSE_ERROR",e[e.INVALID_EXPRESSION=3002]="INVALID_EXPRESSION",e[e.INVALID_DIRECTIVE=3003]="INVALID_DIRECTIVE",e[e.INVALID_TEMPLATE=3004]="INVALID_TEMPLATE",e[e.RENDER_ERROR=4001]="RENDER_ERROR",e[e.HYDRATION_MISMATCH=4002]="HYDRATION_MISMATCH",e[e.INVALID_VNODE=4003]="INVALID_VNODE",e[e.COMPONENT_INVALID_PROPS=5001]="COMPONENT_INVALID_PROPS",e[e.COMPONENT_MISSING_TEMPLATE=5002]="COMPONENT_MISSING_TEMPLATE",e[e.COMPONENT_LIFECYCLE_ERROR=5003]="COMPONENT_LIFECYCLE_ERROR",e[e.ROUTE_NOT_FOUND=6001]="ROUTE_NOT_FOUND",e[e.ROUTE_DUPLICATE=6002]="ROUTE_DUPLICATE",e[e.NAVIGATION_ABORTED=6003]="NAVIGATION_ABORTED",e[e.NAVIGATION_FAILED=6004]="NAVIGATION_FAILED",e[e.STORE_NOT_FOUND=7001]="STORE_NOT_FOUND",e[e.STORE_DUPLICATE=7002]="STORE_DUPLICATE",e))(T||{});var n=class extends Error{constructor(o,t,E){let i=`[Lyt ${o}] ${t}`;super(i),this.name="LytError",this.code=o,this.details=E}};var R=class R{constructor(o){this.errors=[],this.options=o||{},this._hasError=!1}get hasError(){return this._hasError}static setGlobalHandler(o){R.globalHandler=o}capture(o,t,E){var I;let i={error:o,vm:t,info:E||"",timestamp:Date.now()};this.errors.push(i),this._hasError=!0;let _=(I=this.options.maxErrors)!=null?I:100;this.errors.length>_&&this.errors.splice(0,this.errors.length-_),!(this.options.onErrorCaptured&&this.options.onErrorCaptured(o instanceof n?o:new n(1004,o.message),t,i.info)===!0)&&this.options.onError&&this.options.onError(o instanceof n?o:new n(1004,o.message),t)}getFallback(o){if(!this.options.fallback||this.errors.length===0)return null;let t=this.errors[this.errors.length-1];return this.options.fallback(t.error,t.vm,t.info)}getErrors(){return this.errors.slice()}getErrorCount(){return this.errors.length}getLastErrors(){return this.errors.length===0?null:{...this.errors[this.errors.length-1]}}clear(){this.errors=[],this._hasError=!1}};R.globalHandler=null;var s=R,a=!0,O=new Set;function D(r){a=r}function c(){return a}function N(r){}function A(r){a&&(O.has(r)||O.add(r))}function p(){O.clear()}var g={1001:r=>`\u53C2\u6570 "${r}" \u65E0\u6548\u3002\u8BF7\u68C0\u67E5\u4F20\u5165\u7684\u503C\u7C7B\u578B\u548C\u8303\u56F4\u3002`,1002:r=>`"${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8D44\u6E90\u540D\u79F0\u6216\u8DEF\u5F84\u662F\u5426\u6B63\u786E\u3002`,1003:r=>`"${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u4F7F\u7528\u4E0D\u540C\u7684\u540D\u79F0\u3002`,1004:r=>`\u64CD\u4F5C "${r}" \u6267\u884C\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u76F8\u5173\u914D\u7F6E\u548C\u72B6\u6001\u3002`,2001:r=>`\u65E0\u6CD5\u4FEE\u6539\u53EA\u8BFB\u54CD\u5E94\u5F0F\u5C5E\u6027 "${r}"\u3002\u53EA\u8BFB\u5BF9\u8C61\u4E0D\u5141\u8BB8\u76F4\u63A5\u8D4B\u503C\u3002`,2002:()=>"\u526F\u4F5C\u7528\u51FD\u6570\u5DF2\u88AB\u9500\u6BC1\uFF0C\u65E0\u6CD5\u518D\u6B21\u6267\u884C\u3002\u8BF7\u521B\u5EFA\u65B0\u7684\u526F\u4F5C\u7528\u3002",2003:()=>"\u8BA1\u7B97\u5C5E\u6027\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56\u3002\u8BF7\u68C0\u67E5 computed \u51FD\u6570\u662F\u5426\u5F15\u7528\u4E86\u81EA\u8EAB\u3002",3001:r=>`\u6A21\u677F\u89E3\u6790\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u6A21\u677F\u8BED\u6CD5\u662F\u5426\u6B63\u786E\u3002`,3002:r=>`\u65E0\u6548\u7684\u8868\u8FBE\u5F0F "${r}"\u3002\u8BF7\u68C0\u67E5\u8868\u8FBE\u5F0F\u8BED\u6CD5\u3002`,3003:r=>`\u65E0\u6548\u7684\u6307\u4EE4 "${r}"\u3002\u8BF7\u786E\u8BA4\u6307\u4EE4\u540D\u79F0\u662F\u5426\u6B63\u786E\u3002`,3004:r=>`\u65E0\u6548\u7684\u6A21\u677F\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u6A21\u677F\u5185\u5BB9\u3002`,4001:r=>`\u6E32\u67D3\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u7EC4\u4EF6\u7684 render \u51FD\u6570\u6216\u6A21\u677F\u3002`,4002:r=>`\u6C34\u5408\u4E0D\u5339\u914D\uFF1A${r}\u3002\u670D\u52A1\u7AEF\u6E32\u67D3\u4E0E\u5BA2\u6237\u7AEF\u6E32\u67D3\u7ED3\u679C\u4E0D\u4E00\u81F4\u3002`,4003:r=>`\u65E0\u6548\u7684\u865A\u62DF\u8282\u70B9\uFF1A${r}\u3002VNode \u7F3A\u5C11\u5FC5\u8981\u7684 type \u6216\u5176\u4ED6\u5C5E\u6027\u3002`,5001:r=>`\u7EC4\u4EF6\u5C5E\u6027\u65E0\u6548\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u4F20\u5165\u7684 props \u662F\u5426\u7B26\u5408\u7EC4\u4EF6\u5B9A\u4E49\u3002`,5002:r=>`\u7EC4\u4EF6 "${r}" \u7F3A\u5C11 template \u6216 render \u51FD\u6570\u3002\u8BF7\u786E\u4FDD\u7EC4\u4EF6\u5B9A\u4E49\u4E2D\u5305\u542B template \u5B57\u7B26\u4E32\u6216 render \u65B9\u6CD5\u3002`,5003:r=>`\u7EC4\u4EF6\u751F\u547D\u5468\u671F\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u751F\u547D\u5468\u671F\u94A9\u5B50\u51FD\u6570\u3002`,6001:r=>`\u8DEF\u7531 "${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8DEF\u7531\u8DEF\u5F84\u662F\u5426\u5DF2\u6CE8\u518C\u3002`,6002:r=>`\u8DEF\u7531 "${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u907F\u514D\u91CD\u590D\u6CE8\u518C\u76F8\u540C\u7684\u8DEF\u7531\u8DEF\u5F84\u3002`,6003:r=>`\u5BFC\u822A\u88AB\u4E2D\u6B62\uFF1A${r}\u3002\u53EF\u80FD\u88AB\u5BFC\u822A\u5B88\u536B\u62E6\u622A\u3002`,6004:r=>`\u5BFC\u822A\u5931\u8D25\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u76EE\u6807\u8DEF\u7531\u662F\u5426\u6709\u6548\u3002`,7001:r=>`Store "${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4 store \u662F\u5426\u5DF2\u6CE8\u518C\u3002`,7002:r=>`Store "${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u907F\u514D\u91CD\u590D\u521B\u5EFA\u76F8\u540C ID \u7684 store\u3002`};function f(r,...o){let t=g[r];if(t){let E=t(...o);return`[Lyt ${r}] ${E}`}return`[Lyt ${r}] \u672A\u77E5\u9519\u8BEF\u3002`}function l(r,o,t){s.globalHandler&&s.globalHandler(r,o,t||""),a&&r instanceof n&&r.details}function u(r,o){try{return r()}catch(t){l(t instanceof Error?t:new Error(String(t)),o);return}}import{LytErrorCodes as C,ErrorCategory as L,getErrorMessage as P,getCategory as m}from"@lytjs/common";import{LytError as h,createCompilerError as d,createRendererError as M,createComponentError as y}from"@lytjs/common";export{s as ErrorBoundary,L as ErrorCategory,n as LytError,T as LytErrorCodes,h as NewLytError,C as NewLytErrorCodes,u as callWithErrorHandling,d as createCompilerError,y as createComponentError,f as createMessage,M as createRendererError,m as getCategory,c as getDevMode,P as getErrorMessage,l as handleError,p as resetWarnedMessages,D as setDevMode,N as warn,A as warnOnce,A as warnOnceUtil,N as warnUtil};
1
+ var T=(e=>(e[e.INVALID_ARGUMENT=1001]="INVALID_ARGUMENT",e[e.NOT_FOUND=1002]="NOT_FOUND",e[e.ALREADY_EXISTS=1003]="ALREADY_EXISTS",e[e.OPERATION_FAILED=1004]="OPERATION_FAILED",e[e.REACTIVE_READONLY=2001]="REACTIVE_READONLY",e[e.REACTIVE_EFFECT_DISPOSED=2002]="REACTIVE_EFFECT_DISPOSED",e[e.COMPUTED_CYCLE=2003]="COMPUTED_CYCLE",e[e.PARSE_ERROR=3001]="PARSE_ERROR",e[e.INVALID_EXPRESSION=3002]="INVALID_EXPRESSION",e[e.INVALID_DIRECTIVE=3003]="INVALID_DIRECTIVE",e[e.INVALID_TEMPLATE=3004]="INVALID_TEMPLATE",e[e.RENDER_ERROR=4001]="RENDER_ERROR",e[e.HYDRATION_MISMATCH=4002]="HYDRATION_MISMATCH",e[e.INVALID_VNODE=4003]="INVALID_VNODE",e[e.COMPONENT_INVALID_PROPS=5001]="COMPONENT_INVALID_PROPS",e[e.COMPONENT_MISSING_TEMPLATE=5002]="COMPONENT_MISSING_TEMPLATE",e[e.COMPONENT_LIFECYCLE_ERROR=5003]="COMPONENT_LIFECYCLE_ERROR",e[e.ROUTE_NOT_FOUND=6001]="ROUTE_NOT_FOUND",e[e.ROUTE_DUPLICATE=6002]="ROUTE_DUPLICATE",e[e.NAVIGATION_ABORTED=6003]="NAVIGATION_ABORTED",e[e.NAVIGATION_FAILED=6004]="NAVIGATION_FAILED",e[e.STORE_NOT_FOUND=7001]="STORE_NOT_FOUND",e[e.STORE_DUPLICATE=7002]="STORE_DUPLICATE",e))(T||{});var n=class extends Error{constructor(o,t,E){let i=`[Lyt ${o}] ${t}`;super(i),this.name="LytError",this.code=o,this.details=E}};var R=class R{constructor(o){this.errors=[],this.options=o||{},this._hasError=!1}get hasError(){return this._hasError}static setGlobalHandler(o){R.globalHandler=o}capture(o,t,E){var I;let i={error:o,vm:t,info:E||"",timestamp:Date.now()};this.errors.push(i),this._hasError=!0;let _=(I=this.options.maxErrors)!=null?I:100;this.errors.length>_&&this.errors.splice(0,this.errors.length-_),!(this.options.onErrorCaptured&&this.options.onErrorCaptured(o instanceof n?o:new n(1004,o.message),t,i.info)===!0)&&this.options.onError&&this.options.onError(o instanceof n?o:new n(1004,o.message),t)}getFallback(o){if(!this.options.fallback||this.errors.length===0)return null;let t=this.errors[this.errors.length-1];return this.options.fallback(t.error,t.vm,t.info)}getErrors(){return this.errors.slice()}getErrorCount(){return this.errors.length}getLastErrors(){return this.errors.length===0?null:{...this.errors[this.errors.length-1]}}clear(){this.errors=[],this._hasError=!1}};R.globalHandler=null;var s=R,a=!0,O=new Set;function c(r){a=r}function D(){return a}function N(r){if(!a)return;let o=console.warn;typeof o=="function"&&o(`[Lyt warn] ${r}`)}function l(r){if(!a||O.has(r))return;O.add(r);let o=console.warn;typeof o=="function"&&o(`[Lyt warn] ${r}`)}function p(){O.clear()}var f={1001:r=>`\u53C2\u6570 "${r}" \u65E0\u6548\u3002\u8BF7\u68C0\u67E5\u4F20\u5165\u7684\u503C\u7C7B\u578B\u548C\u8303\u56F4\u3002`,1002:r=>`"${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8D44\u6E90\u540D\u79F0\u6216\u8DEF\u5F84\u662F\u5426\u6B63\u786E\u3002`,1003:r=>`"${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u4F7F\u7528\u4E0D\u540C\u7684\u540D\u79F0\u3002`,1004:r=>`\u64CD\u4F5C "${r}" \u6267\u884C\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u76F8\u5173\u914D\u7F6E\u548C\u72B6\u6001\u3002`,2001:r=>`\u65E0\u6CD5\u4FEE\u6539\u53EA\u8BFB\u54CD\u5E94\u5F0F\u5C5E\u6027 "${r}"\u3002\u53EA\u8BFB\u5BF9\u8C61\u4E0D\u5141\u8BB8\u76F4\u63A5\u8D4B\u503C\u3002`,2002:()=>"\u526F\u4F5C\u7528\u51FD\u6570\u5DF2\u88AB\u9500\u6BC1\uFF0C\u65E0\u6CD5\u518D\u6B21\u6267\u884C\u3002\u8BF7\u521B\u5EFA\u65B0\u7684\u526F\u4F5C\u7528\u3002",2003:()=>"\u8BA1\u7B97\u5C5E\u6027\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56\u3002\u8BF7\u68C0\u67E5 computed \u51FD\u6570\u662F\u5426\u5F15\u7528\u4E86\u81EA\u8EAB\u3002",3001:r=>`\u6A21\u677F\u89E3\u6790\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u6A21\u677F\u8BED\u6CD5\u662F\u5426\u6B63\u786E\u3002`,3002:r=>`\u65E0\u6548\u7684\u8868\u8FBE\u5F0F "${r}"\u3002\u8BF7\u68C0\u67E5\u8868\u8FBE\u5F0F\u8BED\u6CD5\u3002`,3003:r=>`\u65E0\u6548\u7684\u6307\u4EE4 "${r}"\u3002\u8BF7\u786E\u8BA4\u6307\u4EE4\u540D\u79F0\u662F\u5426\u6B63\u786E\u3002`,3004:r=>`\u65E0\u6548\u7684\u6A21\u677F\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u6A21\u677F\u5185\u5BB9\u3002`,4001:r=>`\u6E32\u67D3\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u7EC4\u4EF6\u7684 render \u51FD\u6570\u6216\u6A21\u677F\u3002`,4002:r=>`\u6C34\u5408\u4E0D\u5339\u914D\uFF1A${r}\u3002\u670D\u52A1\u7AEF\u6E32\u67D3\u4E0E\u5BA2\u6237\u7AEF\u6E32\u67D3\u7ED3\u679C\u4E0D\u4E00\u81F4\u3002`,4003:r=>`\u65E0\u6548\u7684\u865A\u62DF\u8282\u70B9\uFF1A${r}\u3002VNode \u7F3A\u5C11\u5FC5\u8981\u7684 type \u6216\u5176\u4ED6\u5C5E\u6027\u3002`,5001:r=>`\u7EC4\u4EF6\u5C5E\u6027\u65E0\u6548\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u4F20\u5165\u7684 props \u662F\u5426\u7B26\u5408\u7EC4\u4EF6\u5B9A\u4E49\u3002`,5002:r=>`\u7EC4\u4EF6 "${r}" \u7F3A\u5C11 template \u6216 render \u51FD\u6570\u3002\u8BF7\u786E\u4FDD\u7EC4\u4EF6\u5B9A\u4E49\u4E2D\u5305\u542B template \u5B57\u7B26\u4E32\u6216 render \u65B9\u6CD5\u3002`,5003:r=>`\u7EC4\u4EF6\u751F\u547D\u5468\u671F\u9519\u8BEF\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u751F\u547D\u5468\u671F\u94A9\u5B50\u51FD\u6570\u3002`,6001:r=>`\u8DEF\u7531 "${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4\u8DEF\u7531\u8DEF\u5F84\u662F\u5426\u5DF2\u6CE8\u518C\u3002`,6002:r=>`\u8DEF\u7531 "${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u907F\u514D\u91CD\u590D\u6CE8\u518C\u76F8\u540C\u7684\u8DEF\u7531\u8DEF\u5F84\u3002`,6003:r=>`\u5BFC\u822A\u88AB\u4E2D\u6B62\uFF1A${r}\u3002\u53EF\u80FD\u88AB\u5BFC\u822A\u5B88\u536B\u62E6\u622A\u3002`,6004:r=>`\u5BFC\u822A\u5931\u8D25\uFF1A${r}\u3002\u8BF7\u68C0\u67E5\u76EE\u6807\u8DEF\u7531\u662F\u5426\u6709\u6548\u3002`,7001:r=>`Store "${r}" \u672A\u627E\u5230\u3002\u8BF7\u786E\u8BA4 store \u662F\u5426\u5DF2\u6CE8\u518C\u3002`,7002:r=>`Store "${r}" \u5DF2\u5B58\u5728\u3002\u8BF7\u907F\u514D\u91CD\u590D\u521B\u5EFA\u76F8\u540C ID \u7684 store\u3002`};function u(r,...o){let t=f[r];if(t){let E=t(...o);return`[Lyt ${r}] ${E}`}return`[Lyt ${r}] \u672A\u77E5\u9519\u8BEF\u3002`}function A(r,o,t){s.globalHandler&&s.globalHandler(r,o,t||""),a&&r instanceof n&&r.details}function g(r,o){try{return r()}catch(t){A(t instanceof Error?t:new Error(String(t)),o);return}}import{LytErrorCodes as L,ErrorCategory as C,getErrorMessage as P,getCategory as h}from"@lytjs/common";import{LytError as y,createCompilerError as d,createRendererError as M,createComponentError as m}from"@lytjs/common";export{s as ErrorBoundary,C as ErrorCategory,n as LytError,T as LytErrorCodes,y as NewLytError,L as NewLytErrorCodes,g as callWithErrorHandling,d as createCompilerError,m as createComponentError,u as createMessage,M as createRendererError,h as getCategory,D as getDevMode,P as getErrorMessage,A as handleError,p as resetWarnedMessages,c as setDevMode,N as warn,l as warnOnce,l as warnOnceUtil,N as warnUtil};
package/dist/index.cjs CHANGED
@@ -1,2 +1 @@
1
- var k=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var re=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},w=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of te(t))!ne.call(e,l)&&l!==n&&k(e,l,{get:()=>t[l],enumerable:!(a=ee(t,l))||a.enumerable});return e},b=(e,t,n)=>(w(e,t,"default"),n&&w(n,t,"default"));var oe=e=>w(k({},"__esModule",{value:!0}),e);var C={};re(C,{ErrorBoundary:()=>I,Fragment:()=>H,LytError:()=>N,ShapeFlags:()=>$,createApp:()=>z,defineCustomElement:()=>V,defineCustomElementFromSFC:()=>J,h:()=>A,handleError:()=>X,installPlugin:()=>D,isBrowser:()=>M,registerComponents:()=>K,uninstallPlugin:()=>L,unregisterElement:()=>Z});module.exports=oe(C);var T=require("@lytjs/common"),$=(d=>(d[d.ELEMENT=1]="ELEMENT",d[d.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",d[d.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",d[d.TEXT_CHILDREN=8]="TEXT_CHILDREN",d[d.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",d[d.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",d))($||{}),H=Symbol("Fragment");function ie(e,t){if(t!=null)if((0,T.isStringOrNumber)(t))e.children=String(t),e.shapeFlag|=8;else if((0,T.isArray)(t)){let n=[];for(let a=0;a<t.length;a++){let l=t[a];if(!(l==null||typeof l=="boolean"))if((0,T.isArray)(l))for(let y=0;y<l.length;y++){let d=l[y];d!=null&&typeof d!="boolean"&&n.push((0,T.isVNode)(d)?d:U(String(d)))}else(0,T.isVNode)(l)?n.push(l):n.push(U(String(l)))}e.children=n,e.shapeFlag|=16}else typeof t=="object"&&(e.children=t,e.shapeFlag|=32)}function U(e,t=null,n=null){var m,E;let a=0;typeof e=="string"?a=1:e===H?a=0:typeof e=="function"?a=2:typeof e=="object"&&e!==null&&(e.setup||e.__vccOpts||e.render)&&(a=4);let l=(m=t==null?void 0:t.key)!=null?m:null,y=(E=t==null?void 0:t.ref)!=null?E:null,d=t;if(t){let{key:h,ref:r,...i}=t;d=i}let g={type:e,props:d,children:null,key:l,ref:y,shapeFlag:a,el:null,component:null};return n!=null&&ie(g,n),g}function A(e,t,n){return U(e,t||null,n||null)}var P=require("@lytjs/common");function B(e){return Object.create(e||null)}function Y(e){return e!==null&&typeof e=="object"&&typeof e.install=="function"}function W(e){return typeof e=="function"}function D(e,t,...n){if(Y(t)){let a=t.onBeforeInstall?t.onBeforeInstall(e,...n):void 0;if((0,P.isPromise)(a))return a.then(()=>{let l=t.install(e,...n);if((0,P.isPromise)(l))return l.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)});{let l=t.install(e,...n);if((0,P.isPromise)(l))return l.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)}}else if(W(t))return t(e,...n)}function L(e,t){if(Y(t)){if(typeof t.uninstall=="function")return t.uninstall(e)}else W(t)}var x=require("@lytjs/reactivity"),G=require("@lytjs/compiler"),R=require("@lytjs/component"),q=require("@lytjs/renderer"),se=100,v=new Map;function ae(e){let t=v.get(e);if(t)return v.delete(e),v.set(e,t),t;let{code:n}=(0,G.compile)(e);if(t=new Function("h","_ctx",`return ${n}`),v.size>=se){let a=v.keys().next().value;v.delete(a)}return v.set(e,t),t}function le(e){let t={...e};if(e.state&&typeof e.state!="function"){let n=e.state;t.state=()=>({...n})}if(typeof e.render=="function"){let n=e.render;t.render=(a,l)=>n(a)}if(e.computed){let n={};for(let a of Object.keys(e.computed)){let l=e.computed[a];typeof l=="function"?n[a]={get:l}:n[a]=l}t.computed=n}if(typeof e.init=="function"){let n=e.init;t.init=function(a,l){return n.call(this,a)}}return t}function ce(){return{createElement(e){return document.createElement(e)},createText(e){return document.createTextNode(e)},createComment(e){return document.createComment(e)},setAttribute(e,t,n){e.setAttribute(t,String(n))},removeAttribute(e,t){e.removeAttribute(t)},setStyle(e,t){if(typeof t=="string")e.style.cssText=t;else if(t&&typeof t=="object")for(let n in t)e.style[n]=t[n]},setClass(e,t){if(typeof t=="string")e.className=t;else if(t&&typeof t=="object"){let n=[];for(let[a,l]of Object.entries(t))l&&n.push(a);e.className=n.join(" ")}else e.className=""},insert(e,t,n){n!=null?e.insertBefore(t,n):e.appendChild(t)},remove(e){e.parentNode&&e.parentNode.removeChild(e)},replace(e,t,n){e.replaceChild(n,t)},addEventListener(e,t,n,a){e.addEventListener(t,n,a)},removeEventListener(e,t,n){e.removeEventListener(t,n)},nextTick(e){Promise.resolve().then(e)},parentNode(e){return e.parentNode},nextSibling(e){return e.nextSibling},querySelector(e){return document.querySelector(e)}}}function z(e,t){let n=new Set,a={},l={},y=B(),d={},g={},m=null,E=null,h=null,r=null,i=!1,o=le(typeof e=="function"?{render:e}:e),u=(0,R.defineComponent)(o),s={config:d,globalProperties:g,get _instance(){return m},mount(f){if(i)return s;let p;if(typeof f=="string"){if(p=document.querySelector(f),!p)throw new Error(`[Lyt] \u627E\u4E0D\u5230\u6302\u8F7D\u76EE\u6807: "${f}"`)}else p=f;r=p;let _=ce();E=(0,q.createRenderer)(_),m=(0,R.createComponentInstance)(u),(0,R.setupComponent)(m,t||{},null);let O=m.type;if(!O.render&&O.template){let F=ae(O.template);O.render=(j,Q)=>F(j,Q.renderProxy)}return(0,R.mountComponent)(m,A),m.subTree&&E.mount(m.subTree,p),h=(0,x.effect)(()=>{if(!(!m||!m.isMounted||!E)&&((0,R.updateComponent)(m,A),m.subTree&&r)){let F=r.firstChild,j=m.subTree;r.innerHTML="",E.mount(j,r)}},{lazy:!0}),i=!0,s},unmount(){i&&(h&&((0,x.stop)(h),h=null),m&&(0,R.unmountComponent)(m),r&&(r.innerHTML=""),m=null,E=null,r=null,i=!1)},use(f,...p){if(n.has(f))return s;n.add(f);let _=D({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:d,globalProperties:g},f,...p);return _ instanceof Promise?_.then(()=>s):s},unuse(f){if(!n.has(f))return s;n.delete(f);let p=L({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:d,globalProperties:g},f);return p instanceof Promise?p.then(()=>s):s},isInstalled(f){return n.has(f)},provide(f,p){return y[f]=p,s},inject(f,p){let _=y[f];return _!==void 0?_:p},component(f,p){return p?(a[f]=p,s):a[f]},directive(f,p){return p?(l[f]=p,s):l[f]}};return s}var N=class extends Error{constructor(t,n,a){let l=`[Lyt ${t}] ${n}`;super(l),this.name="LytError",this.code=t,this.details=a}};var S=class S{constructor(t){this.errors=[],this.options=t||{},this._hasError=!1}get hasError(){return this._hasError}static setGlobalHandler(t){S.globalHandler=t}capture(t,n,a){var d;let l={error:t,vm:n,info:a||"",timestamp:Date.now()};this.errors.push(l),this._hasError=!0;let y=(d=this.options.maxErrors)!=null?d:100;this.errors.length>y&&this.errors.splice(0,this.errors.length-y),!(this.options.onErrorCaptured&&this.options.onErrorCaptured(t instanceof N?t:new N(1004,t.message),n,l.info)===!0)&&this.options.onError&&this.options.onError(t instanceof N?t:new N(1004,t.message),n)}getFallback(t){if(!this.options.fallback||this.errors.length===0)return null;let n=this.errors[this.errors.length-1];return this.options.fallback(n.error,n.vm,n.info)}getErrors(){return this.errors.slice()}getErrorCount(){return this.errors.length}getLastErrors(){return this.errors.length===0?null:{...this.errors[this.errors.length-1]}}clear(){this.errors=[],this._hasError=!1}};S.globalHandler=null;var I=S,ue=!0;function X(e,t,n){I.globalHandler&&I.globalHandler(e,t,n||""),ue&&e instanceof N&&e.details}function M(){return typeof window!="undefined"&&typeof document!="undefined"&&typeof HTMLElement!="undefined"&&typeof customElements!="undefined"}function de(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function fe(e){if(e===""||e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e==="undefined")return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(n){}return e}function pe(e,t){return t&&t[e]?t[e]:de(e)}function me(e){let t=[],n=e;if(n.emits&&(Array.isArray(n.emits)?t.push(...n.emits):typeof n.emits=="object"&&t.push(...Object.keys(n.emits))),n.methods){for(let a of Object.keys(n.methods))if(a.startsWith("on")&&a.length>2){let l=a.charAt(2).toLowerCase()+a.slice(3);t.push(l)}}return t}function ye(e,t={}){let{shadowMode:n="open",styles:a="",propMappings:l,eventMappings:y={},attributeConverters:d={}}=t,g=t.observedAttributes||[],m=me(e);return class extends HTMLElement{constructor(){super();this._shadowRoot=null;this._instance=null;this._props={};this._container=null;this._connected=!1;this._eventCleanups=[];this._effectCleanup=null;this._updateScheduled=!1}static get observedAttributes(){return g}connectedCallback(){if(!this._connected){if(this._connected=!0,this._shadowRoot=this.attachShadow({mode:n}),a){let r=document.createElement("style");r.textContent=a,this._shadowRoot.appendChild(r)}this._container=document.createElement("div"),this._shadowRoot.appendChild(this._container),this._syncAttributesToProps(),this._mountComponent(),this._forwardSlots()}}disconnectedCallback(){if(this._connected){this._connected=!1;for(let r of this._eventCleanups)r();this._eventCleanups=[],this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=null),this._instance=null,this._container&&(this._container.innerHTML="")}}attributeChangedCallback(r,i,c){i!==c&&this._connected&&(this._syncAttributesToProps(),this._updateComponent())}_syncAttributesToProps(){let r={};for(let i of g)if(this.hasAttribute(i)){let c=this.getAttribute(i),o=pe(i,l);d[i]?r[o]=d[i](c):r[o]=fe(c)}if(e.props){for(let[i,c]of Object.entries(e.props))if(r[i]===void 0){let o=c;o&&typeof o=="object"&&"default"in o?r[i]=typeof o.default=="function"?o.default():o.default:o==null}}this._props=r}_mountComponent(){let r=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!r)return;let i=this._createComponentContext(),c=r.call(i,A,i);c&&this._container&&this._renderVNode(c,this._container),this._setupReactiveUpdates(i,r)}_compileTemplate(r){try{let i=Function("return require")(),{compile:c}=i("../../compiler/src/index.ts"),{code:o}=c(r);return new Function("h","_ctx",`return ${o}`)}catch(i){return null}}_createComponentContext(){let r=e.state?typeof e.state=="function"?e.state():{...e.state}:{},i=e.computed||{},c=e.methods||{},o={...this._props,...r};for(let[u,s]of Object.entries(i))typeof s=="function"?Object.defineProperty(o,u,{get:s.bind(o),enumerable:!0}):s&&typeof s=="object"&&"get"in s&&Object.defineProperty(o,u,{get:s.get.bind(o),enumerable:!0});for(let[u,s]of Object.entries(c))typeof s=="function"&&(o[u]=s.bind(o));return o.emit=(u,...s)=>{let f=y[u]||u,p=new CustomEvent(f,{detail:s.length===1?s[0]:s,bubbles:!0,composed:!0});this.dispatchEvent(p)},o.$el=this._container,o.$attrs={...this._props},o.$slots=this._getSlotContent(),o}_setupReactiveUpdates(r,i){try{let c=Function("return require")(),{effect:o,stop:u}=c("../../reactivity/src/index.ts"),s=o(()=>{if(!this._connected||!this._container)return;let p=i.call(r,A,r);p&&(this._container.innerHTML="",this._renderVNode(p,this._container))},{lazy:!0}),f=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let p of f){let _=r[p];Object.defineProperty(r,p,{get(){return _},set(O){_=O;try{s()}catch(F){}},enumerable:!0})}this._effectCleanup=()=>{try{u(s)}catch(p){}}}catch(c){let o=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let u of o){let f=r[u],p=this;Object.defineProperty(r,u,{get(){return f},set(_){f=_,p._scheduleUpdate(r,i)},enumerable:!0})}}}_scheduleUpdate(r,i){this._updateScheduled||(this._updateScheduled=!0,Promise.resolve().then(()=>{if(this._updateScheduled=!1,!this._connected||!this._container)return;let c=i.call(r,A,r);c&&(this._container.innerHTML="",this._renderVNode(c,this._container))}))}_updateComponent(){if(!this._container)return;let r=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!r)return;let i=this._createComponentContext(),c=r.call(i,A,i);this._container.innerHTML="",c&&this._renderVNode(c,this._container)}_renderVNode(r,i){let c=this._vNodeToElement(r);c&&i.appendChild(c)}_vNodeToElement(r){if(!r)return null;if(typeof r.type=="symbol"){let i=document.createDocumentFragment();if(Array.isArray(r.children))for(let c of r.children){let o=this._vNodeToElement(c);o&&i.appendChild(o)}return i}if(typeof r.children=="string")return document.createTextNode(r.children);if(typeof r.type=="string"){let i=document.createElement(r.type);if(r.props)for(let[c,o]of Object.entries(r.props))if(c==="style"&&typeof o=="object")for(let[u,s]of Object.entries(o))i.style[u]=s;else if(c==="class"){if(typeof o=="string")i.className=o;else if(typeof o=="object"){let u=[];for(let[s,f]of Object.entries(o))f&&u.push(s);i.className=u.join(" ")}}else if(c.startsWith("on")&&typeof o=="function"){let u=c.slice(2).toLowerCase();i.addEventListener(u,o),this._eventCleanups.push(()=>{i.removeEventListener(u,o)})}else c==="ref"&&typeof o=="function"?o(i):i.setAttribute(c,String(o));if(Array.isArray(r.children))for(let c of r.children){let o=this._vNodeToElement(c);o&&i.appendChild(o)}else typeof r.children=="string"&&(i.textContent=r.children);return i}return typeof r.type=="object"||typeof r.type=="function"?r.component?this._vNodeToElement(r.component.subTree||r):document.createComment("component"):null}_forwardSlots(){if(!this._shadowRoot||!this._container)return;let r=this.querySelectorAll("[slot]");for(let c of r){let o=c.getAttribute("slot")||"default",u=document.createElement("slot");o!=="default"&&u.setAttribute("name",o),this._container.appendChild(u)}let i=document.createElement("slot");this._container.appendChild(i)}_getSlotContent(){var o;let r={},i=this.querySelectorAll("[slot]");for(let u of i){let s=u.getAttribute("slot")||"default";r[s]||(r[s]=[]),r[s].push(u.cloneNode(!0))}let c=[];for(let u of Array.from(this.childNodes))(o=u.hasAttribute)!=null&&o.call(u,"slot")||c.push(u.cloneNode(!0));return c.length>0&&(r.default=c),r}get _lytInstance(){return this._instance}get _lytProps(){return{...this._props}}}}function V(e,t,n){if(!e.includes("-"))throw new Error(`[Lyt Web Component] \u6807\u7B7E\u540D "${e}" \u5FC5\u987B\u5305\u542B\u8FDE\u5B57\u7B26 (-)\u3002\u8FD9\u662F Custom Element \u89C4\u8303\u7684\u8981\u6C42\u3002`);if(!M())return;let a=ye(t,n);customElements.define(e,a)}function K(e){for(let{tagName:t,component:n,options:a}of e)V(t,n,a)}function Z(e){if(M())try{let t=customElements;t.__unregister&&t.__unregister(e)}catch(t){}}async function J(e,t,n){let a=t.match(/<template>([\s\S]*?)<\/template>/),l=t.match(/<script[^>]*>([\s\S]*?)<\/script>/),y=/<style[^>]*>([\s\S]*?)<\/style>/g,d=[],g;for(;(g=y.exec(t))!==null;)d.push(g);let m=(n==null?void 0:n.styles)||"";for(let i of d)m+=i[1]+`
2
- `;let E=a?a[1].trim():void 0,h={};if(l){let i=l[1].trim();if(i.match(/export\s+default\s*(\{[\s\S]*\}|\([\s\S]*\)[\s\S]*?\))/))try{let o={},u={exports:o};new Function("module","exports",`"use strict"; ${i.replace(/export\s+default\s*/,"module.exports =")}`)(u,o),h=u.exports||o}catch(o){}}let r={...n,styles:m};E&&!h.template&&!h.render&&(h.template=E),V(e,h,r)}b(C,require("@lytjs/common"),module.exports);
1
+ var O=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var Y=(n,e)=>{for(var t in e)O(n,t,{get:e[t],enumerable:!0})},h=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of q(e))!X.call(n,o)&&o!==t&&O(n,o,{get:()=>e[o],enumerable:!(i=$(e,o))||i.enumerable});return n},A=(n,e,t)=>(h(n,e,"default"),t&&h(t,e,"default"));var K=n=>h(O({},"__esModule",{value:!0}),n);var v={};Y(v,{Fragment:()=>j,ShapeFlags:()=>L,createApp:()=>B,h:()=>I});module.exports=K(v);var y=require("@lytjs/common"),L=(s=>(s[s.ELEMENT=1]="ELEMENT",s[s.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",s[s.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",s[s.TEXT_CHILDREN=8]="TEXT_CHILDREN",s[s.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",s[s.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",s))(L||{}),j=Symbol("Fragment");function Z(n,e){if(e!=null)if((0,y.isStringOrNumber)(e))n.children=String(e),n.shapeFlag|=8;else if((0,y.isArray)(e)){let t=[];for(let i=0;i<e.length;i++){let o=e[i];if(!(o==null||typeof o=="boolean"))if((0,y.isArray)(o))for(let d=0;d<o.length;d++){let s=o[d];s!=null&&typeof s!="boolean"&&t.push((0,y.isVNode)(s)?s:E(String(s)))}else(0,y.isVNode)(o)?t.push(o):t.push(E(String(o)))}n.children=t,n.shapeFlag|=16}else typeof e=="object"&&(n.children=e,n.shapeFlag|=32)}function E(n,e=null,t=null){var u,f;let i=0;typeof n=="string"?i=1:n===j?i=0:typeof n=="function"?i=2:typeof n=="object"&&n!==null&&(n.setup||n.__vccOpts||n.render)&&(i=4);let o=(u=e==null?void 0:e.key)!=null?u:null,d=(f=e==null?void 0:e.ref)!=null?f:null,s=e;if(e){let{key:C,ref:p,...P}=e;s=P}let b={type:n,props:s,children:null,key:o,ref:d,shapeFlag:i,el:null,component:null};return t!=null&&Z(b,t),b}function I(n,e,t){return E(n,e||null,t||null)}var N=require("@lytjs/common");function D(n){return Object.create(n||null)}function V(n){return n!==null&&typeof n=="object"&&typeof n.install=="function"}function _(n){return typeof n=="function"}function F(n,e,...t){if(V(e)){let i=e.onBeforeInstall?e.onBeforeInstall(n,...t):void 0;if((0,N.isPromise)(i))return i.then(()=>{let o=e.install(n,...t);if((0,N.isPromise)(o))return o.then(()=>{if(e.onInstalled)return e.onInstalled(n,...t)});if(e.onInstalled)return e.onInstalled(n,...t)});{let o=e.install(n,...t);if((0,N.isPromise)(o))return o.then(()=>{if(e.onInstalled)return e.onInstalled(n,...t)});if(e.onInstalled)return e.onInstalled(n,...t)}}else if(_(e))return e(n,...t)}function S(n,e){if(V(e)){if(typeof e.uninstall=="function")return e.uninstall(n)}else _(e)}var T=require("@lytjs/reactivity"),H=require("@lytjs/compiler"),c=require("@lytjs/component"),M=require("@lytjs/renderer"),G=100,g=new Map;function J(n){let e=g.get(n);if(e)return g.delete(n),g.set(n,e),e;let{code:t}=(0,H.compile)(n);if(e=new Function("h","_ctx",`return ${t}`),g.size>=G){let i=g.keys().next().value;g.delete(i)}return g.set(n,e),e}function Q(n){let e={...n};if(n.state&&typeof n.state!="function"){let t=n.state;e.state=()=>({...t})}if(typeof n.render=="function"){let t=n.render;e.render=(i,o)=>t(i)}if(n.computed){let t={};for(let i of Object.keys(n.computed)){let o=n.computed[i];typeof o=="function"?t[i]={get:o}:t[i]=o}e.computed=t}if(typeof n.init=="function"){let t=n.init;e.init=function(i,o){return t.call(this,i)}}return e}function W(){return{createElement(n){return document.createElement(n)},createText(n){return document.createTextNode(n)},createComment(n){return document.createComment(n)},setAttribute(n,e,t){n.setAttribute(e,String(t))},removeAttribute(n,e){n.removeAttribute(e)},setStyle(n,e){if(typeof e=="string")n.style.cssText=e;else if(e&&typeof e=="object")for(let t in e)n.style[t]=e[t]},setClass(n,e){if(typeof e=="string")n.className=e;else if(e&&typeof e=="object"){let t=[];for(let[i,o]of Object.entries(e))o&&t.push(i);n.className=t.join(" ")}else n.className=""},insert(n,e,t){t!=null?n.insertBefore(e,t):n.appendChild(e)},remove(n){n.parentNode&&n.parentNode.removeChild(n)},replace(n,e,t){n.replaceChild(t,e)},addEventListener(n,e,t,i){n.addEventListener(e,t,i)},removeEventListener(n,e,t){n.removeEventListener(e,t)},nextTick(n){Promise.resolve().then(n)},parentNode(n){return n.parentNode},nextSibling(n){return n.nextSibling},querySelector(n){return document.querySelector(n)}}}function B(n,e){let t=new Set,i={},o={},d=D(),s={},b={},u=null,f=null,C=null,p=null,P=!1,w=Q(typeof n=="function"?{render:n}:n),U=(0,c.defineComponent)(w),r={config:s,globalProperties:b,get _instance(){return u},mount(a){if(P)return r;let l;if(typeof a=="string"){if(l=document.querySelector(a),!l)throw new Error(`[Lyt] \u627E\u4E0D\u5230\u6302\u8F7D\u76EE\u6807: "${a}"`)}else l=a;p=l;let m=W();f=(0,M.createRenderer)(m),u=(0,c.createComponentInstance)(U),(0,c.setupComponent)(u,e||{},null);let R=u.type;if(!R.render&&R.template){let k=J(R.template);R.render=(x,z)=>k(x,z.renderProxy)}return(0,c.mountComponent)(u,I),u.subTree&&f.mount(u.subTree,l),C=(0,T.effect)(()=>{if(!(!u||!u.isMounted||!f)&&((0,c.updateComponent)(u,I),u.subTree&&p)){let k=p.firstChild,x=u.subTree;p.innerHTML="",f.mount(x,p)}},{lazy:!0}),P=!0,r},unmount(){P&&(C&&((0,T.stop)(C),C=null),u&&(0,c.unmountComponent)(u),p&&(p.innerHTML=""),u=null,f=null,p=null,P=!1)},use(a,...l){if(t.has(a))return r;t.add(a);let m=F({use:r.use.bind(r),unuse:r.unuse.bind(r),isInstalled:r.isInstalled.bind(r),provide:r.provide.bind(r),inject:r.inject.bind(r),config:s,globalProperties:b},a,...l);return m instanceof Promise?m.then(()=>r):r},unuse(a){if(!t.has(a))return r;t.delete(a);let l=S({use:r.use.bind(r),unuse:r.unuse.bind(r),isInstalled:r.isInstalled.bind(r),provide:r.provide.bind(r),inject:r.inject.bind(r),config:s,globalProperties:b},a);return l instanceof Promise?l.then(()=>r):r},isInstalled(a){return t.has(a)},provide(a,l){return d[a]=l,r},inject(a,l){let m=d[a];return m!==void 0?m:l},component(a,l){return l?(i[a]=l,r):i[a]},directive(a,l){return l?(o[a]=l,r):o[a]}};return r}A(v,require("@lytjs/common"),module.exports);
package/dist/index.mjs CHANGED
@@ -1,2 +1 @@
1
- import{isStringOrNumber as H,isArray as M,isVNode as V}from"@lytjs/common";var F=(d=>(d[d.ELEMENT=1]="ELEMENT",d[d.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",d[d.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",d[d.TEXT_CHILDREN=8]="TEXT_CHILDREN",d[d.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",d[d.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",d))(F||{}),j=Symbol("Fragment");function B(e,t){if(t!=null)if(H(t))e.children=String(t),e.shapeFlag|=8;else if(M(t)){let n=[];for(let a=0;a<t.length;a++){let c=t[a];if(!(c==null||typeof c=="boolean"))if(M(c))for(let y=0;y<c.length;y++){let d=c[y];d!=null&&typeof d!="boolean"&&n.push(V(d)?d:I(String(d)))}else V(c)?n.push(c):n.push(I(String(c)))}e.children=n,e.shapeFlag|=16}else typeof t=="object"&&(e.children=t,e.shapeFlag|=32)}function I(e,t=null,n=null){var m,E;let a=0;typeof e=="string"?a=1:e===j?a=0:typeof e=="function"?a=2:typeof e=="object"&&e!==null&&(e.setup||e.__vccOpts||e.render)&&(a=4);let c=(m=t==null?void 0:t.key)!=null?m:null,y=(E=t==null?void 0:t.ref)!=null?E:null,d=t;if(t){let{key:h,ref:r,...i}=t;d=i}let g={type:e,props:d,children:null,key:c,ref:y,shapeFlag:a,el:null,component:null};return n!=null&&B(g,n),g}function R(e,t,n){return I(e,t||null,n||null)}import{isPromise as P}from"@lytjs/common";function w(e){return Object.create(e||null)}function k(e){return e!==null&&typeof e=="object"&&typeof e.install=="function"}function U(e){return typeof e=="function"}function D(e,t,...n){if(k(t)){let a=t.onBeforeInstall?t.onBeforeInstall(e,...n):void 0;if(P(a))return a.then(()=>{let c=t.install(e,...n);if(P(c))return c.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)});{let c=t.install(e,...n);if(P(c))return c.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)}}else if(U(t))return t(e,...n)}function L(e,t){if(k(t)){if(typeof t.uninstall=="function")return t.uninstall(e)}else U(t)}import{effect as Y,stop as W}from"@lytjs/reactivity";import{compile as G}from"@lytjs/compiler";import{defineComponent as q,createComponentInstance as z,setupComponent as X,mountComponent as K,updateComponent as Z,unmountComponent as J}from"@lytjs/component";import{createRenderer as Q}from"@lytjs/renderer";var ee=100,A=new Map;function te(e){let t=A.get(e);if(t)return A.delete(e),A.set(e,t),t;let{code:n}=G(e);if(t=new Function("h","_ctx",`return ${n}`),A.size>=ee){let a=A.keys().next().value;A.delete(a)}return A.set(e,t),t}function ne(e){let t={...e};if(e.state&&typeof e.state!="function"){let n=e.state;t.state=()=>({...n})}if(typeof e.render=="function"){let n=e.render;t.render=(a,c)=>n(a)}if(e.computed){let n={};for(let a of Object.keys(e.computed)){let c=e.computed[a];typeof c=="function"?n[a]={get:c}:n[a]=c}t.computed=n}if(typeof e.init=="function"){let n=e.init;t.init=function(a,c){return n.call(this,a)}}return t}function re(){return{createElement(e){return document.createElement(e)},createText(e){return document.createTextNode(e)},createComment(e){return document.createComment(e)},setAttribute(e,t,n){e.setAttribute(t,String(n))},removeAttribute(e,t){e.removeAttribute(t)},setStyle(e,t){if(typeof t=="string")e.style.cssText=t;else if(t&&typeof t=="object")for(let n in t)e.style[n]=t[n]},setClass(e,t){if(typeof t=="string")e.className=t;else if(t&&typeof t=="object"){let n=[];for(let[a,c]of Object.entries(t))c&&n.push(a);e.className=n.join(" ")}else e.className=""},insert(e,t,n){n!=null?e.insertBefore(t,n):e.appendChild(t)},remove(e){e.parentNode&&e.parentNode.removeChild(e)},replace(e,t,n){e.replaceChild(n,t)},addEventListener(e,t,n,a){e.addEventListener(t,n,a)},removeEventListener(e,t,n){e.removeEventListener(t,n)},nextTick(e){Promise.resolve().then(e)},parentNode(e){return e.parentNode},nextSibling(e){return e.nextSibling},querySelector(e){return document.querySelector(e)}}}function oe(e,t){let n=new Set,a={},c={},y=w(),d={},g={},m=null,E=null,h=null,r=null,i=!1,o=ne(typeof e=="function"?{render:e}:e),u=q(o),s={config:d,globalProperties:g,get _instance(){return m},mount(f){if(i)return s;let p;if(typeof f=="string"){if(p=document.querySelector(f),!p)throw new Error(`[Lyt] \u627E\u4E0D\u5230\u6302\u8F7D\u76EE\u6807: "${f}"`)}else p=f;r=p;let _=re();E=Q(_),m=z(u),X(m,t||{},null);let b=m.type;if(!b.render&&b.template){let v=te(b.template);b.render=(O,$)=>v(O,$.renderProxy)}return K(m,R),m.subTree&&E.mount(m.subTree,p),h=Y(()=>{if(!(!m||!m.isMounted||!E)&&(Z(m,R),m.subTree&&r)){let v=r.firstChild,O=m.subTree;r.innerHTML="",E.mount(O,r)}},{lazy:!0}),i=!0,s},unmount(){i&&(h&&(W(h),h=null),m&&J(m),r&&(r.innerHTML=""),m=null,E=null,r=null,i=!1)},use(f,...p){if(n.has(f))return s;n.add(f);let _=D({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:d,globalProperties:g},f,...p);return _ instanceof Promise?_.then(()=>s):s},unuse(f){if(!n.has(f))return s;n.delete(f);let p=L({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:d,globalProperties:g},f);return p instanceof Promise?p.then(()=>s):s},isInstalled(f){return n.has(f)},provide(f,p){return y[f]=p,s},inject(f,p){let _=y[f];return _!==void 0?_:p},component(f,p){return p?(a[f]=p,s):a[f]},directive(f,p){return p?(c[f]=p,s):c[f]}};return s}var C=class extends Error{constructor(t,n,a){let c=`[Lyt ${t}] ${n}`;super(c),this.name="LytError",this.code=t,this.details=a}};var T=class T{constructor(t){this.errors=[],this.options=t||{},this._hasError=!1}get hasError(){return this._hasError}static setGlobalHandler(t){T.globalHandler=t}capture(t,n,a){var d;let c={error:t,vm:n,info:a||"",timestamp:Date.now()};this.errors.push(c),this._hasError=!0;let y=(d=this.options.maxErrors)!=null?d:100;this.errors.length>y&&this.errors.splice(0,this.errors.length-y),!(this.options.onErrorCaptured&&this.options.onErrorCaptured(t instanceof C?t:new C(1004,t.message),n,c.info)===!0)&&this.options.onError&&this.options.onError(t instanceof C?t:new C(1004,t.message),n)}getFallback(t){if(!this.options.fallback||this.errors.length===0)return null;let n=this.errors[this.errors.length-1];return this.options.fallback(n.error,n.vm,n.info)}getErrors(){return this.errors.slice()}getErrorCount(){return this.errors.length}getLastErrors(){return this.errors.length===0?null:{...this.errors[this.errors.length-1]}}clear(){this.errors=[],this._hasError=!1}};T.globalHandler=null;var N=T,ie=!0;function se(e,t,n){N.globalHandler&&N.globalHandler(e,t,n||""),ie&&e instanceof C&&e.details}function x(){return typeof window!="undefined"&&typeof document!="undefined"&&typeof HTMLElement!="undefined"&&typeof customElements!="undefined"}function ae(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function le(e){if(e===""||e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e==="undefined")return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(n){}return e}function ce(e,t){return t&&t[e]?t[e]:ae(e)}function ue(e){let t=[],n=e;if(n.emits&&(Array.isArray(n.emits)?t.push(...n.emits):typeof n.emits=="object"&&t.push(...Object.keys(n.emits))),n.methods){for(let a of Object.keys(n.methods))if(a.startsWith("on")&&a.length>2){let c=a.charAt(2).toLowerCase()+a.slice(3);t.push(c)}}return t}function de(e,t={}){let{shadowMode:n="open",styles:a="",propMappings:c,eventMappings:y={},attributeConverters:d={}}=t,g=t.observedAttributes||[],m=ue(e);return class extends HTMLElement{constructor(){super();this._shadowRoot=null;this._instance=null;this._props={};this._container=null;this._connected=!1;this._eventCleanups=[];this._effectCleanup=null;this._updateScheduled=!1}static get observedAttributes(){return g}connectedCallback(){if(!this._connected){if(this._connected=!0,this._shadowRoot=this.attachShadow({mode:n}),a){let r=document.createElement("style");r.textContent=a,this._shadowRoot.appendChild(r)}this._container=document.createElement("div"),this._shadowRoot.appendChild(this._container),this._syncAttributesToProps(),this._mountComponent(),this._forwardSlots()}}disconnectedCallback(){if(this._connected){this._connected=!1;for(let r of this._eventCleanups)r();this._eventCleanups=[],this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=null),this._instance=null,this._container&&(this._container.innerHTML="")}}attributeChangedCallback(r,i,l){i!==l&&this._connected&&(this._syncAttributesToProps(),this._updateComponent())}_syncAttributesToProps(){let r={};for(let i of g)if(this.hasAttribute(i)){let l=this.getAttribute(i),o=ce(i,c);d[i]?r[o]=d[i](l):r[o]=le(l)}if(e.props){for(let[i,l]of Object.entries(e.props))if(r[i]===void 0){let o=l;o&&typeof o=="object"&&"default"in o?r[i]=typeof o.default=="function"?o.default():o.default:o==null}}this._props=r}_mountComponent(){let r=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!r)return;let i=this._createComponentContext(),l=r.call(i,R,i);l&&this._container&&this._renderVNode(l,this._container),this._setupReactiveUpdates(i,r)}_compileTemplate(r){try{let i=Function("return require")(),{compile:l}=i("../../compiler/src/index.ts"),{code:o}=l(r);return new Function("h","_ctx",`return ${o}`)}catch(i){return null}}_createComponentContext(){let r=e.state?typeof e.state=="function"?e.state():{...e.state}:{},i=e.computed||{},l=e.methods||{},o={...this._props,...r};for(let[u,s]of Object.entries(i))typeof s=="function"?Object.defineProperty(o,u,{get:s.bind(o),enumerable:!0}):s&&typeof s=="object"&&"get"in s&&Object.defineProperty(o,u,{get:s.get.bind(o),enumerable:!0});for(let[u,s]of Object.entries(l))typeof s=="function"&&(o[u]=s.bind(o));return o.emit=(u,...s)=>{let f=y[u]||u,p=new CustomEvent(f,{detail:s.length===1?s[0]:s,bubbles:!0,composed:!0});this.dispatchEvent(p)},o.$el=this._container,o.$attrs={...this._props},o.$slots=this._getSlotContent(),o}_setupReactiveUpdates(r,i){try{let l=Function("return require")(),{effect:o,stop:u}=l("../../reactivity/src/index.ts"),s=o(()=>{if(!this._connected||!this._container)return;let p=i.call(r,R,r);p&&(this._container.innerHTML="",this._renderVNode(p,this._container))},{lazy:!0}),f=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let p of f){let _=r[p];Object.defineProperty(r,p,{get(){return _},set(b){_=b;try{s()}catch(v){}},enumerable:!0})}this._effectCleanup=()=>{try{u(s)}catch(p){}}}catch(l){let o=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let u of o){let f=r[u],p=this;Object.defineProperty(r,u,{get(){return f},set(_){f=_,p._scheduleUpdate(r,i)},enumerable:!0})}}}_scheduleUpdate(r,i){this._updateScheduled||(this._updateScheduled=!0,Promise.resolve().then(()=>{if(this._updateScheduled=!1,!this._connected||!this._container)return;let l=i.call(r,R,r);l&&(this._container.innerHTML="",this._renderVNode(l,this._container))}))}_updateComponent(){if(!this._container)return;let r=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!r)return;let i=this._createComponentContext(),l=r.call(i,R,i);this._container.innerHTML="",l&&this._renderVNode(l,this._container)}_renderVNode(r,i){let l=this._vNodeToElement(r);l&&i.appendChild(l)}_vNodeToElement(r){if(!r)return null;if(typeof r.type=="symbol"){let i=document.createDocumentFragment();if(Array.isArray(r.children))for(let l of r.children){let o=this._vNodeToElement(l);o&&i.appendChild(o)}return i}if(typeof r.children=="string")return document.createTextNode(r.children);if(typeof r.type=="string"){let i=document.createElement(r.type);if(r.props)for(let[l,o]of Object.entries(r.props))if(l==="style"&&typeof o=="object")for(let[u,s]of Object.entries(o))i.style[u]=s;else if(l==="class"){if(typeof o=="string")i.className=o;else if(typeof o=="object"){let u=[];for(let[s,f]of Object.entries(o))f&&u.push(s);i.className=u.join(" ")}}else if(l.startsWith("on")&&typeof o=="function"){let u=l.slice(2).toLowerCase();i.addEventListener(u,o),this._eventCleanups.push(()=>{i.removeEventListener(u,o)})}else l==="ref"&&typeof o=="function"?o(i):i.setAttribute(l,String(o));if(Array.isArray(r.children))for(let l of r.children){let o=this._vNodeToElement(l);o&&i.appendChild(o)}else typeof r.children=="string"&&(i.textContent=r.children);return i}return typeof r.type=="object"||typeof r.type=="function"?r.component?this._vNodeToElement(r.component.subTree||r):document.createComment("component"):null}_forwardSlots(){if(!this._shadowRoot||!this._container)return;let r=this.querySelectorAll("[slot]");for(let l of r){let o=l.getAttribute("slot")||"default",u=document.createElement("slot");o!=="default"&&u.setAttribute("name",o),this._container.appendChild(u)}let i=document.createElement("slot");this._container.appendChild(i)}_getSlotContent(){var o;let r={},i=this.querySelectorAll("[slot]");for(let u of i){let s=u.getAttribute("slot")||"default";r[s]||(r[s]=[]),r[s].push(u.cloneNode(!0))}let l=[];for(let u of Array.from(this.childNodes))(o=u.hasAttribute)!=null&&o.call(u,"slot")||l.push(u.cloneNode(!0));return l.length>0&&(r.default=l),r}get _lytInstance(){return this._instance}get _lytProps(){return{...this._props}}}}function S(e,t,n){if(!e.includes("-"))throw new Error(`[Lyt Web Component] \u6807\u7B7E\u540D "${e}" \u5FC5\u987B\u5305\u542B\u8FDE\u5B57\u7B26 (-)\u3002\u8FD9\u662F Custom Element \u89C4\u8303\u7684\u8981\u6C42\u3002`);if(!x())return;let a=de(t,n);customElements.define(e,a)}function fe(e){for(let{tagName:t,component:n,options:a}of e)S(t,n,a)}function pe(e){if(x())try{let t=customElements;t.__unregister&&t.__unregister(e)}catch(t){}}async function me(e,t,n){let a=t.match(/<template>([\s\S]*?)<\/template>/),c=t.match(/<script[^>]*>([\s\S]*?)<\/script>/),y=/<style[^>]*>([\s\S]*?)<\/style>/g,d=[],g;for(;(g=y.exec(t))!==null;)d.push(g);let m=(n==null?void 0:n.styles)||"";for(let i of d)m+=i[1]+`
2
- `;let E=a?a[1].trim():void 0,h={};if(c){let i=c[1].trim();if(i.match(/export\s+default\s*(\{[\s\S]*\}|\([\s\S]*\)[\s\S]*?\))/))try{let o={},u={exports:o};new Function("module","exports",`"use strict"; ${i.replace(/export\s+default\s*/,"module.exports =")}`)(u,o),h=u.exports||o}catch(o){}}let r={...n,styles:m};E&&!h.template&&!h.render&&(h.template=E),S(e,h,r)}export*from"@lytjs/common";export{N as ErrorBoundary,j as Fragment,C as LytError,F as ShapeFlags,oe as createApp,S as defineCustomElement,me as defineCustomElementFromSFC,R as h,se as handleError,D as installPlugin,x as isBrowser,fe as registerComponents,L as uninstallPlugin,pe as unregisterElement};
1
+ import{isStringOrNumber as F,isArray as N,isVNode as T}from"@lytjs/common";var x=(s=>(s[s.ELEMENT=1]="ELEMENT",s[s.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",s[s.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",s[s.TEXT_CHILDREN=8]="TEXT_CHILDREN",s[s.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",s[s.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",s))(x||{}),h=Symbol("Fragment");function S(n,e){if(e!=null)if(F(e))n.children=String(e),n.shapeFlag|=8;else if(N(e)){let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(!(r==null||typeof r=="boolean"))if(N(r))for(let c=0;c<r.length;c++){let s=r[c];s!=null&&typeof s!="boolean"&&t.push(T(s)?s:C(String(s)))}else T(r)?t.push(r):t.push(C(String(r)))}n.children=t,n.shapeFlag|=16}else typeof e=="object"&&(n.children=e,n.shapeFlag|=32)}function C(n,e=null,t=null){var u,p;let i=0;typeof n=="string"?i=1:n===h?i=0:typeof n=="function"?i=2:typeof n=="object"&&n!==null&&(n.setup||n.__vccOpts||n.render)&&(i=4);let r=(u=e==null?void 0:e.key)!=null?u:null,c=(p=e==null?void 0:e.ref)!=null?p:null,s=e;if(e){let{key:v,ref:d,...g}=e;s=g}let m={type:n,props:s,children:null,key:r,ref:c,shapeFlag:i,el:null,component:null};return t!=null&&S(m,t),m}function P(n,e,t){return C(n,e||null,t||null)}import{isPromise as I}from"@lytjs/common";function O(n){return Object.create(n||null)}function E(n){return n!==null&&typeof n=="object"&&typeof n.install=="function"}function L(n){return typeof n=="function"}function j(n,e,...t){if(E(e)){let i=e.onBeforeInstall?e.onBeforeInstall(n,...t):void 0;if(I(i))return i.then(()=>{let r=e.install(n,...t);if(I(r))return r.then(()=>{if(e.onInstalled)return e.onInstalled(n,...t)});if(e.onInstalled)return e.onInstalled(n,...t)});{let r=e.install(n,...t);if(I(r))return r.then(()=>{if(e.onInstalled)return e.onInstalled(n,...t)});if(e.onInstalled)return e.onInstalled(n,...t)}}else if(L(e))return e(n,...t)}function k(n,e){if(E(e)){if(typeof e.uninstall=="function")return e.uninstall(n)}else L(e)}import{effect as H,stop as M}from"@lytjs/reactivity";import{compile as B}from"@lytjs/compiler";import{defineComponent as w,createComponentInstance as U,setupComponent as z,mountComponent as $,updateComponent as q,unmountComponent as X}from"@lytjs/component";import{createRenderer as Y}from"@lytjs/renderer";var K=100,y=new Map;function Z(n){let e=y.get(n);if(e)return y.delete(n),y.set(n,e),e;let{code:t}=B(n);if(e=new Function("h","_ctx",`return ${t}`),y.size>=K){let i=y.keys().next().value;y.delete(i)}return y.set(n,e),e}function G(n){let e={...n};if(n.state&&typeof n.state!="function"){let t=n.state;e.state=()=>({...t})}if(typeof n.render=="function"){let t=n.render;e.render=(i,r)=>t(i)}if(n.computed){let t={};for(let i of Object.keys(n.computed)){let r=n.computed[i];typeof r=="function"?t[i]={get:r}:t[i]=r}e.computed=t}if(typeof n.init=="function"){let t=n.init;e.init=function(i,r){return t.call(this,i)}}return e}function J(){return{createElement(n){return document.createElement(n)},createText(n){return document.createTextNode(n)},createComment(n){return document.createComment(n)},setAttribute(n,e,t){n.setAttribute(e,String(t))},removeAttribute(n,e){n.removeAttribute(e)},setStyle(n,e){if(typeof e=="string")n.style.cssText=e;else if(e&&typeof e=="object")for(let t in e)n.style[t]=e[t]},setClass(n,e){if(typeof e=="string")n.className=e;else if(e&&typeof e=="object"){let t=[];for(let[i,r]of Object.entries(e))r&&t.push(i);n.className=t.join(" ")}else n.className=""},insert(n,e,t){t!=null?n.insertBefore(e,t):n.appendChild(e)},remove(n){n.parentNode&&n.parentNode.removeChild(n)},replace(n,e,t){n.replaceChild(t,e)},addEventListener(n,e,t,i){n.addEventListener(e,t,i)},removeEventListener(n,e,t){n.removeEventListener(e,t)},nextTick(n){Promise.resolve().then(n)},parentNode(n){return n.parentNode},nextSibling(n){return n.nextSibling},querySelector(n){return document.querySelector(n)}}}function Q(n,e){let t=new Set,i={},r={},c=O(),s={},m={},u=null,p=null,v=null,d=null,g=!1,D=G(typeof n=="function"?{render:n}:n),V=w(D),o={config:s,globalProperties:m,get _instance(){return u},mount(a){if(g)return o;let l;if(typeof a=="string"){if(l=document.querySelector(a),!l)throw new Error(`[Lyt] \u627E\u4E0D\u5230\u6302\u8F7D\u76EE\u6807: "${a}"`)}else l=a;d=l;let f=J();p=Y(f),u=U(V),z(u,e||{},null);let b=u.type;if(!b.render&&b.template){let R=Z(b.template);b.render=(A,_)=>R(A,_.renderProxy)}return $(u,P),u.subTree&&p.mount(u.subTree,l),v=H(()=>{if(!(!u||!u.isMounted||!p)&&(q(u,P),u.subTree&&d)){let R=d.firstChild,A=u.subTree;d.innerHTML="",p.mount(A,d)}},{lazy:!0}),g=!0,o},unmount(){g&&(v&&(M(v),v=null),u&&X(u),d&&(d.innerHTML=""),u=null,p=null,d=null,g=!1)},use(a,...l){if(t.has(a))return o;t.add(a);let f=j({use:o.use.bind(o),unuse:o.unuse.bind(o),isInstalled:o.isInstalled.bind(o),provide:o.provide.bind(o),inject:o.inject.bind(o),config:s,globalProperties:m},a,...l);return f instanceof Promise?f.then(()=>o):o},unuse(a){if(!t.has(a))return o;t.delete(a);let l=k({use:o.use.bind(o),unuse:o.unuse.bind(o),isInstalled:o.isInstalled.bind(o),provide:o.provide.bind(o),inject:o.inject.bind(o),config:s,globalProperties:m},a);return l instanceof Promise?l.then(()=>o):o},isInstalled(a){return t.has(a)},provide(a,l){return c[a]=l,o},inject(a,l){let f=c[a];return f!==void 0?f:l},component(a,l){return l?(i[a]=l,o):i[a]},directive(a,l){return l?(r[a]=l,o):r[a]}};return o}export*from"@lytjs/common";export{h as Fragment,x as ShapeFlags,Q as createApp,P as h};
@@ -154,6 +154,10 @@ export declare function warnOnce(msg: string): void;
154
154
  * 重置已警告消息集合(仅用于测试)
155
155
  */
156
156
  export declare function resetWarnedMessages(): void;
157
+ /**
158
+ * 始终输出错误信息(不受开发/生产模式限制)
159
+ */
160
+ export declare function error(msg: string): void;
157
161
  /**
158
162
  * 根据错误码生成友好的中文提示信息
159
163
  *
@@ -1 +1 @@
1
- {"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/error-handling.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/error-handling.ts"],"names":[],"mappings":"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"}
@@ -9,9 +9,5 @@ export type { App, ComponentOptions, DirectiveHooks, DirectiveBinding, } from '.
9
9
  export { h, Fragment } from './h';
10
10
  export type { VNode, Children, Props, } from './h';
11
11
  export { ShapeFlags } from './h';
12
- export { installPlugin, uninstallPlugin } from './plugin';
13
- export { LytError, ErrorBoundary, handleError } from './error-handling';
14
- export { defineCustomElement, registerComponents, unregisterElement, isBrowser, defineCustomElementFromSFC, } from './web-component';
15
- export type { CustomElementOptions, ComponentRegistration, } from './web-component';
16
12
  export * from '@lytjs/common';
17
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,YAAY,EACV,GAAG,EACH,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAElC,YAAY,EACV,KAAK,EACL,QAAQ,EACR,KAAK,GACN,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAKjC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKvE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,0BAA0B,GAC3B,MAAM,iBAAiB,CAAA;AAExB,YAAY,EACV,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,iBAAiB,CAAA;AAOxB,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,YAAY,EACV,GAAG,EACH,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAElC,YAAY,EACV,KAAK,EACL,QAAQ,EACR,KAAK,GACN,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AA8CjC,cAAc,eAAe,CAAC"}
@@ -1,8 +1,32 @@
1
1
  /**
2
2
  * Lyt.js 警告与错误输出工具
3
3
  *
4
- * 已移至 @lytjs/common
5
- * 保持向后兼容性 - 重新导出自 @lytjs/common
4
+ * 提供 warn、warnOnce、error 等工具函数。
5
+ * 开发模式下输出详细信息,生产模式下静默。
6
+ * 纯原生零依赖 TypeScript 实现。
6
7
  */
7
- export { warn, warnOnce, error, setDevMode, getDevMode, resetWarnedMessages, } from '@lytjs/common';
8
+ /**
9
+ * 设置开发/生产模式
10
+ */
11
+ export declare function setDevMode(mode: boolean): void;
12
+ /**
13
+ * 获取当前是否为开发模式
14
+ */
15
+ export declare function getDevMode(): boolean;
16
+ /**
17
+ * 仅开发模式输出警告
18
+ */
19
+ export declare function warn(msg: string): void;
20
+ /**
21
+ * 每条消息只警告一次
22
+ */
23
+ export declare function warnOnce(msg: string): void;
24
+ /**
25
+ * 始终输出错误信息(不受开发/生产模式限制)
26
+ */
27
+ export declare function error(msg: string): void;
28
+ /**
29
+ * 重置已警告消息集合(仅用于测试)
30
+ */
31
+ export declare function resetWarnedMessages(): void;
8
32
  //# sourceMappingURL=warn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../../src/warn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,UAAU,EACV,UAAU,EACV,mBAAmB,GACpB,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../../src/warn.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAQH;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAE9C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AASD;;GAEG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGtC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAK1C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEvC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
@@ -1,2 +1,2 @@
1
- var H=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var n in t)H(e,n,{get:t[n],enumerable:!0})},$=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of ne(t))!re.call(e,l)&&l!==n&&H(e,l,{get:()=>t[l],enumerable:!(a=te(t,l))||a.enumerable});return e},N=(e,t,n)=>($(e,t,"default"),n&&$(n,t,"default"));var oe=e=>$(H({},"__esModule",{value:!0}),e);var ge={};G(ge,{defineCustomElement:()=>D,defineCustomElementFromSFC:()=>w,isBrowser:()=>P,registerComponents:()=>F,unregisterElement:()=>j});module.exports=oe(ge);var A={};G(A,{ErrorBoundary:()=>I,Fragment:()=>W,LytError:()=>b,ShapeFlags:()=>Y,createApp:()=>J,defineCustomElement:()=>D,defineCustomElementFromSFC:()=>w,h:()=>C,handleError:()=>Q,installPlugin:()=>x,isBrowser:()=>P,registerComponents:()=>F,uninstallPlugin:()=>S,unregisterElement:()=>j});var T=require("@lytjs/common"),Y=(d=>(d[d.ELEMENT=1]="ELEMENT",d[d.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",d[d.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",d[d.TEXT_CHILDREN=8]="TEXT_CHILDREN",d[d.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",d[d.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",d))(Y||{}),W=Symbol("Fragment");function ie(e,t){if(t!=null)if((0,T.isStringOrNumber)(t))e.children=String(t),e.shapeFlag|=8;else if((0,T.isArray)(t)){let n=[];for(let a=0;a<t.length;a++){let l=t[a];if(!(l==null||typeof l=="boolean"))if((0,T.isArray)(l))for(let y=0;y<l.length;y++){let d=l[y];d!=null&&typeof d!="boolean"&&n.push((0,T.isVNode)(d)?d:B(String(d)))}else(0,T.isVNode)(l)?n.push(l):n.push(B(String(l)))}e.children=n,e.shapeFlag|=16}else typeof t=="object"&&(e.children=t,e.shapeFlag|=32)}function B(e,t=null,n=null){var m,E;let a=0;typeof e=="string"?a=1:e===W?a=0:typeof e=="function"?a=2:typeof e=="object"&&e!==null&&(e.setup||e.__vccOpts||e.render)&&(a=4);let l=(m=t==null?void 0:t.key)!=null?m:null,y=(E=t==null?void 0:t.ref)!=null?E:null,d=t;if(t){let{key:h,ref:r,...i}=t;d=i}let g={type:e,props:d,children:null,key:l,ref:y,shapeFlag:a,el:null,component:null};return n!=null&&ie(g,n),g}function C(e,t,n){return B(e,t||null,n||null)}var L=require("@lytjs/common");function q(e){return Object.create(e||null)}function z(e){return e!==null&&typeof e=="object"&&typeof e.install=="function"}function X(e){return typeof e=="function"}function x(e,t,...n){if(z(t)){let a=t.onBeforeInstall?t.onBeforeInstall(e,...n):void 0;if((0,L.isPromise)(a))return a.then(()=>{let l=t.install(e,...n);if((0,L.isPromise)(l))return l.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)});{let l=t.install(e,...n);if((0,L.isPromise)(l))return l.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)}}else if(X(t))return t(e,...n)}function S(e,t){if(z(t)){if(typeof t.uninstall=="function")return t.uninstall(e)}else X(t)}var M=require("@lytjs/reactivity"),K=require("@lytjs/compiler"),R=require("@lytjs/component"),Z=require("@lytjs/renderer"),se=100,v=new Map;function ae(e){let t=v.get(e);if(t)return v.delete(e),v.set(e,t),t;let{code:n}=(0,K.compile)(e);if(t=new Function("h","_ctx",`return ${n}`),v.size>=se){let a=v.keys().next().value;v.delete(a)}return v.set(e,t),t}function le(e){let t={...e};if(e.state&&typeof e.state!="function"){let n=e.state;t.state=()=>({...n})}if(typeof e.render=="function"){let n=e.render;t.render=(a,l)=>n(a)}if(e.computed){let n={};for(let a of Object.keys(e.computed)){let l=e.computed[a];typeof l=="function"?n[a]={get:l}:n[a]=l}t.computed=n}if(typeof e.init=="function"){let n=e.init;t.init=function(a,l){return n.call(this,a)}}return t}function ce(){return{createElement(e){return document.createElement(e)},createText(e){return document.createTextNode(e)},createComment(e){return document.createComment(e)},setAttribute(e,t,n){e.setAttribute(t,String(n))},removeAttribute(e,t){e.removeAttribute(t)},setStyle(e,t){if(typeof t=="string")e.style.cssText=t;else if(t&&typeof t=="object")for(let n in t)e.style[n]=t[n]},setClass(e,t){if(typeof t=="string")e.className=t;else if(t&&typeof t=="object"){let n=[];for(let[a,l]of Object.entries(t))l&&n.push(a);e.className=n.join(" ")}else e.className=""},insert(e,t,n){n!=null?e.insertBefore(t,n):e.appendChild(t)},remove(e){e.parentNode&&e.parentNode.removeChild(e)},replace(e,t,n){e.replaceChild(n,t)},addEventListener(e,t,n,a){e.addEventListener(t,n,a)},removeEventListener(e,t,n){e.removeEventListener(t,n)},nextTick(e){Promise.resolve().then(e)},parentNode(e){return e.parentNode},nextSibling(e){return e.nextSibling},querySelector(e){return document.querySelector(e)}}}function J(e,t){let n=new Set,a={},l={},y=q(),d={},g={},m=null,E=null,h=null,r=null,i=!1,o=le(typeof e=="function"?{render:e}:e),u=(0,R.defineComponent)(o),s={config:d,globalProperties:g,get _instance(){return m},mount(f){if(i)return s;let p;if(typeof f=="string"){if(p=document.querySelector(f),!p)throw new Error(`[Lyt] \u627E\u4E0D\u5230\u6302\u8F7D\u76EE\u6807: "${f}"`)}else p=f;r=p;let _=ce();E=(0,Z.createRenderer)(_),m=(0,R.createComponentInstance)(u),(0,R.setupComponent)(m,t||{},null);let O=m.type;if(!O.render&&O.template){let k=ae(O.template);O.render=(U,ee)=>k(U,ee.renderProxy)}return(0,R.mountComponent)(m,C),m.subTree&&E.mount(m.subTree,p),h=(0,M.effect)(()=>{if(!(!m||!m.isMounted||!E)&&((0,R.updateComponent)(m,C),m.subTree&&r)){let k=r.firstChild,U=m.subTree;r.innerHTML="",E.mount(U,r)}},{lazy:!0}),i=!0,s},unmount(){i&&(h&&((0,M.stop)(h),h=null),m&&(0,R.unmountComponent)(m),r&&(r.innerHTML=""),m=null,E=null,r=null,i=!1)},use(f,...p){if(n.has(f))return s;n.add(f);let _=x({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:d,globalProperties:g},f,...p);return _ instanceof Promise?_.then(()=>s):s},unuse(f){if(!n.has(f))return s;n.delete(f);let p=S({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:d,globalProperties:g},f);return p instanceof Promise?p.then(()=>s):s},isInstalled(f){return n.has(f)},provide(f,p){return y[f]=p,s},inject(f,p){let _=y[f];return _!==void 0?_:p},component(f,p){return p?(a[f]=p,s):a[f]},directive(f,p){return p?(l[f]=p,s):l[f]}};return s}var b=class extends Error{constructor(t,n,a){let l=`[Lyt ${t}] ${n}`;super(l),this.name="LytError",this.code=t,this.details=a}};var V=class V{constructor(t){this.errors=[],this.options=t||{},this._hasError=!1}get hasError(){return this._hasError}static setGlobalHandler(t){V.globalHandler=t}capture(t,n,a){var d;let l={error:t,vm:n,info:a||"",timestamp:Date.now()};this.errors.push(l),this._hasError=!0;let y=(d=this.options.maxErrors)!=null?d:100;this.errors.length>y&&this.errors.splice(0,this.errors.length-y),!(this.options.onErrorCaptured&&this.options.onErrorCaptured(t instanceof b?t:new b(1004,t.message),n,l.info)===!0)&&this.options.onError&&this.options.onError(t instanceof b?t:new b(1004,t.message),n)}getFallback(t){if(!this.options.fallback||this.errors.length===0)return null;let n=this.errors[this.errors.length-1];return this.options.fallback(n.error,n.vm,n.info)}getErrors(){return this.errors.slice()}getErrorCount(){return this.errors.length}getLastErrors(){return this.errors.length===0?null:{...this.errors[this.errors.length-1]}}clear(){this.errors=[],this._hasError=!1}};V.globalHandler=null;var I=V,ue=!0;function Q(e,t,n){I.globalHandler&&I.globalHandler(e,t,n||""),ue&&e instanceof b&&e.details}N(A,require("@lytjs/common"));function P(){return typeof window!="undefined"&&typeof document!="undefined"&&typeof HTMLElement!="undefined"&&typeof customElements!="undefined"}function de(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function fe(e){if(e===""||e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e==="undefined")return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(n){}return e}function pe(e,t){return t&&t[e]?t[e]:de(e)}function me(e){let t=[],n=e;if(n.emits&&(Array.isArray(n.emits)?t.push(...n.emits):typeof n.emits=="object"&&t.push(...Object.keys(n.emits))),n.methods){for(let a of Object.keys(n.methods))if(a.startsWith("on")&&a.length>2){let l=a.charAt(2).toLowerCase()+a.slice(3);t.push(l)}}return t}function ye(e,t={}){let{shadowMode:n="open",styles:a="",propMappings:l,eventMappings:y={},attributeConverters:d={}}=t,g=t.observedAttributes||[],m=me(e);return class extends HTMLElement{constructor(){super();this._shadowRoot=null;this._instance=null;this._props={};this._container=null;this._connected=!1;this._eventCleanups=[];this._effectCleanup=null;this._updateScheduled=!1}static get observedAttributes(){return g}connectedCallback(){if(!this._connected){if(this._connected=!0,this._shadowRoot=this.attachShadow({mode:n}),a){let r=document.createElement("style");r.textContent=a,this._shadowRoot.appendChild(r)}this._container=document.createElement("div"),this._shadowRoot.appendChild(this._container),this._syncAttributesToProps(),this._mountComponent(),this._forwardSlots()}}disconnectedCallback(){if(this._connected){this._connected=!1;for(let r of this._eventCleanups)r();this._eventCleanups=[],this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=null),this._instance=null,this._container&&(this._container.innerHTML="")}}attributeChangedCallback(r,i,c){i!==c&&this._connected&&(this._syncAttributesToProps(),this._updateComponent())}_syncAttributesToProps(){let r={};for(let i of g)if(this.hasAttribute(i)){let c=this.getAttribute(i),o=pe(i,l);d[i]?r[o]=d[i](c):r[o]=fe(c)}if(e.props){for(let[i,c]of Object.entries(e.props))if(r[i]===void 0){let o=c;o&&typeof o=="object"&&"default"in o?r[i]=typeof o.default=="function"?o.default():o.default:o==null}}this._props=r}_mountComponent(){let r=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!r)return;let i=this._createComponentContext(),c=r.call(i,C,i);c&&this._container&&this._renderVNode(c,this._container),this._setupReactiveUpdates(i,r)}_compileTemplate(r){try{let i=Function("return require")(),{compile:c}=i("../../compiler/src/index.ts"),{code:o}=c(r);return new Function("h","_ctx",`return ${o}`)}catch(i){return null}}_createComponentContext(){let r=e.state?typeof e.state=="function"?e.state():{...e.state}:{},i=e.computed||{},c=e.methods||{},o={...this._props,...r};for(let[u,s]of Object.entries(i))typeof s=="function"?Object.defineProperty(o,u,{get:s.bind(o),enumerable:!0}):s&&typeof s=="object"&&"get"in s&&Object.defineProperty(o,u,{get:s.get.bind(o),enumerable:!0});for(let[u,s]of Object.entries(c))typeof s=="function"&&(o[u]=s.bind(o));return o.emit=(u,...s)=>{let f=y[u]||u,p=new CustomEvent(f,{detail:s.length===1?s[0]:s,bubbles:!0,composed:!0});this.dispatchEvent(p)},o.$el=this._container,o.$attrs={...this._props},o.$slots=this._getSlotContent(),o}_setupReactiveUpdates(r,i){try{let c=Function("return require")(),{effect:o,stop:u}=c("../../reactivity/src/index.ts"),s=o(()=>{if(!this._connected||!this._container)return;let p=i.call(r,C,r);p&&(this._container.innerHTML="",this._renderVNode(p,this._container))},{lazy:!0}),f=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let p of f){let _=r[p];Object.defineProperty(r,p,{get(){return _},set(O){_=O;try{s()}catch(k){}},enumerable:!0})}this._effectCleanup=()=>{try{u(s)}catch(p){}}}catch(c){let o=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let u of o){let f=r[u],p=this;Object.defineProperty(r,u,{get(){return f},set(_){f=_,p._scheduleUpdate(r,i)},enumerable:!0})}}}_scheduleUpdate(r,i){this._updateScheduled||(this._updateScheduled=!0,Promise.resolve().then(()=>{if(this._updateScheduled=!1,!this._connected||!this._container)return;let c=i.call(r,C,r);c&&(this._container.innerHTML="",this._renderVNode(c,this._container))}))}_updateComponent(){if(!this._container)return;let r=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!r)return;let i=this._createComponentContext(),c=r.call(i,C,i);this._container.innerHTML="",c&&this._renderVNode(c,this._container)}_renderVNode(r,i){let c=this._vNodeToElement(r);c&&i.appendChild(c)}_vNodeToElement(r){if(!r)return null;if(typeof r.type=="symbol"){let i=document.createDocumentFragment();if(Array.isArray(r.children))for(let c of r.children){let o=this._vNodeToElement(c);o&&i.appendChild(o)}return i}if(typeof r.children=="string")return document.createTextNode(r.children);if(typeof r.type=="string"){let i=document.createElement(r.type);if(r.props)for(let[c,o]of Object.entries(r.props))if(c==="style"&&typeof o=="object")for(let[u,s]of Object.entries(o))i.style[u]=s;else if(c==="class"){if(typeof o=="string")i.className=o;else if(typeof o=="object"){let u=[];for(let[s,f]of Object.entries(o))f&&u.push(s);i.className=u.join(" ")}}else if(c.startsWith("on")&&typeof o=="function"){let u=c.slice(2).toLowerCase();i.addEventListener(u,o),this._eventCleanups.push(()=>{i.removeEventListener(u,o)})}else c==="ref"&&typeof o=="function"?o(i):i.setAttribute(c,String(o));if(Array.isArray(r.children))for(let c of r.children){let o=this._vNodeToElement(c);o&&i.appendChild(o)}else typeof r.children=="string"&&(i.textContent=r.children);return i}return typeof r.type=="object"||typeof r.type=="function"?r.component?this._vNodeToElement(r.component.subTree||r):document.createComment("component"):null}_forwardSlots(){if(!this._shadowRoot||!this._container)return;let r=this.querySelectorAll("[slot]");for(let c of r){let o=c.getAttribute("slot")||"default",u=document.createElement("slot");o!=="default"&&u.setAttribute("name",o),this._container.appendChild(u)}let i=document.createElement("slot");this._container.appendChild(i)}_getSlotContent(){var o;let r={},i=this.querySelectorAll("[slot]");for(let u of i){let s=u.getAttribute("slot")||"default";r[s]||(r[s]=[]),r[s].push(u.cloneNode(!0))}let c=[];for(let u of Array.from(this.childNodes))(o=u.hasAttribute)!=null&&o.call(u,"slot")||c.push(u.cloneNode(!0));return c.length>0&&(r.default=c),r}get _lytInstance(){return this._instance}get _lytProps(){return{...this._props}}}}function D(e,t,n){if(!e.includes("-"))throw new Error(`[Lyt Web Component] \u6807\u7B7E\u540D "${e}" \u5FC5\u987B\u5305\u542B\u8FDE\u5B57\u7B26 (-)\u3002\u8FD9\u662F Custom Element \u89C4\u8303\u7684\u8981\u6C42\u3002`);if(!P())return;let a=ye(t,n);customElements.define(e,a)}function F(e){for(let{tagName:t,component:n,options:a}of e)D(t,n,a)}function j(e){if(P())try{let t=customElements;t.__unregister&&t.__unregister(e)}catch(t){}}async function w(e,t,n){let a=t.match(/<template>([\s\S]*?)<\/template>/),l=t.match(/<script[^>]*>([\s\S]*?)<\/script>/),y=/<style[^>]*>([\s\S]*?)<\/style>/g,d=[],g;for(;(g=y.exec(t))!==null;)d.push(g);let m=(n==null?void 0:n.styles)||"";for(let i of d)m+=i[1]+`
2
- `;let E=a?a[1].trim():void 0,h={};if(l){let i=l[1].trim();if(i.match(/export\s+default\s*(\{[\s\S]*\}|\([\s\S]*\)[\s\S]*?\))/))try{let o={},u={exports:o};new Function("module","exports",`"use strict"; ${i.replace(/export\s+default\s*/,"module.exports =")}`)(u,o),h=u.exports||o}catch(o){}}let r={...n,styles:m};E&&!h.template&&!h.render&&(h.template=E),D(e,h,r)}
1
+ var S=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var F=(e,t)=>{for(var n in t)S(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of G(t))!Q.call(e,c)&&c!==n&&S(e,c,{get:()=>t[c],enumerable:!(a=J(t,c))||a.enumerable});return e},R=(e,t,n)=>(k(e,t,"default"),n&&k(n,t,"default"));var ee=e=>k(S({},"__esModule",{value:!0}),e);var de={};F(de,{defineCustomElement:()=>j,defineCustomElementFromSFC:()=>Y,isBrowser:()=>I,registerComponents:()=>K,unregisterElement:()=>X});module.exports=ee(de);var E={};F(E,{Fragment:()=>M,ShapeFlags:()=>V,createApp:()=>z,h:()=>_});var A=require("@lytjs/common"),V=(f=>(f[f.ELEMENT=1]="ELEMENT",f[f.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",f[f.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",f[f.TEXT_CHILDREN=8]="TEXT_CHILDREN",f[f.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",f[f.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",f))(V||{}),M=Symbol("Fragment");function te(e,t){if(t!=null)if((0,A.isStringOrNumber)(t))e.children=String(t),e.shapeFlag|=8;else if((0,A.isArray)(t)){let n=[];for(let a=0;a<t.length;a++){let c=t[a];if(!(c==null||typeof c=="boolean"))if((0,A.isArray)(c))for(let m=0;m<c.length;m++){let f=c[m];f!=null&&typeof f!="boolean"&&n.push((0,A.isVNode)(f)?f:w(String(f)))}else(0,A.isVNode)(c)?n.push(c):n.push(w(String(c)))}e.children=n,e.shapeFlag|=16}else typeof t=="object"&&(e.children=t,e.shapeFlag|=32)}function w(e,t=null,n=null){var y,h;let a=0;typeof e=="string"?a=1:e===M?a=0:typeof e=="function"?a=2:typeof e=="object"&&e!==null&&(e.setup||e.__vccOpts||e.render)&&(a=4);let c=(y=t==null?void 0:t.key)!=null?y:null,m=(h=t==null?void 0:t.ref)!=null?h:null,f=t;if(t){let{key:b,ref:o,...i}=t;f=i}let g={type:e,props:f,children:null,key:c,ref:m,shapeFlag:a,el:null,component:null};return n!=null&&te(g,n),g}function _(e,t,n){return w(e,t||null,n||null)}var T=require("@lytjs/common");function D(e){return Object.create(e||null)}function H(e){return e!==null&&typeof e=="object"&&typeof e.install=="function"}function B(e){return typeof e=="function"}function U(e,t,...n){if(H(t)){let a=t.onBeforeInstall?t.onBeforeInstall(e,...n):void 0;if((0,T.isPromise)(a))return a.then(()=>{let c=t.install(e,...n);if((0,T.isPromise)(c))return c.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)});{let c=t.install(e,...n);if((0,T.isPromise)(c))return c.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)}}else if(B(t))return t(e,...n)}function $(e,t){if(H(t)){if(typeof t.uninstall=="function")return t.uninstall(e)}else B(t)}var x=require("@lytjs/reactivity"),W=require("@lytjs/compiler"),v=require("@lytjs/component"),q=require("@lytjs/renderer"),ne=100,P=new Map;function oe(e){let t=P.get(e);if(t)return P.delete(e),P.set(e,t),t;let{code:n}=(0,W.compile)(e);if(t=new Function("h","_ctx",`return ${n}`),P.size>=ne){let a=P.keys().next().value;P.delete(a)}return P.set(e,t),t}function re(e){let t={...e};if(e.state&&typeof e.state!="function"){let n=e.state;t.state=()=>({...n})}if(typeof e.render=="function"){let n=e.render;t.render=(a,c)=>n(a)}if(e.computed){let n={};for(let a of Object.keys(e.computed)){let c=e.computed[a];typeof c=="function"?n[a]={get:c}:n[a]=c}t.computed=n}if(typeof e.init=="function"){let n=e.init;t.init=function(a,c){return n.call(this,a)}}return t}function ie(){return{createElement(e){return document.createElement(e)},createText(e){return document.createTextNode(e)},createComment(e){return document.createComment(e)},setAttribute(e,t,n){e.setAttribute(t,String(n))},removeAttribute(e,t){e.removeAttribute(t)},setStyle(e,t){if(typeof t=="string")e.style.cssText=t;else if(t&&typeof t=="object")for(let n in t)e.style[n]=t[n]},setClass(e,t){if(typeof t=="string")e.className=t;else if(t&&typeof t=="object"){let n=[];for(let[a,c]of Object.entries(t))c&&n.push(a);e.className=n.join(" ")}else e.className=""},insert(e,t,n){n!=null?e.insertBefore(t,n):e.appendChild(t)},remove(e){e.parentNode&&e.parentNode.removeChild(e)},replace(e,t,n){e.replaceChild(n,t)},addEventListener(e,t,n,a){e.addEventListener(t,n,a)},removeEventListener(e,t,n){e.removeEventListener(t,n)},nextTick(e){Promise.resolve().then(e)},parentNode(e){return e.parentNode},nextSibling(e){return e.nextSibling},querySelector(e){return document.querySelector(e)}}}function z(e,t){let n=new Set,a={},c={},m=D(),f={},g={},y=null,h=null,b=null,o=null,i=!1,r=re(typeof e=="function"?{render:e}:e),u=(0,v.defineComponent)(r),s={config:f,globalProperties:g,get _instance(){return y},mount(d){if(i)return s;let p;if(typeof d=="string"){if(p=document.querySelector(d),!p)throw new Error(`[Lyt] \u627E\u4E0D\u5230\u6302\u8F7D\u76EE\u6807: "${d}"`)}else p=d;o=p;let C=ie();h=(0,q.createRenderer)(C),y=(0,v.createComponentInstance)(u),(0,v.setupComponent)(y,t||{},null);let N=y.type;if(!N.render&&N.template){let L=oe(N.template);N.render=(O,Z)=>L(O,Z.renderProxy)}return(0,v.mountComponent)(y,_),y.subTree&&h.mount(y.subTree,p),b=(0,x.effect)(()=>{if(!(!y||!y.isMounted||!h)&&((0,v.updateComponent)(y,_),y.subTree&&o)){let L=o.firstChild,O=y.subTree;o.innerHTML="",h.mount(O,o)}},{lazy:!0}),i=!0,s},unmount(){i&&(b&&((0,x.stop)(b),b=null),y&&(0,v.unmountComponent)(y),o&&(o.innerHTML=""),y=null,h=null,o=null,i=!1)},use(d,...p){if(n.has(d))return s;n.add(d);let C=U({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:f,globalProperties:g},d,...p);return C instanceof Promise?C.then(()=>s):s},unuse(d){if(!n.has(d))return s;n.delete(d);let p=$({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:f,globalProperties:g},d);return p instanceof Promise?p.then(()=>s):s},isInstalled(d){return n.has(d)},provide(d,p){return m[d]=p,s},inject(d,p){let C=m[d];return C!==void 0?C:p},component(d,p){return p?(a[d]=p,s):a[d]},directive(d,p){return p?(c[d]=p,s):c[d]}};return s}R(E,require("@lytjs/common"));function I(){return typeof globalThis.window!="undefined"&&typeof globalThis.document!="undefined"&&typeof globalThis.HTMLElement!="undefined"&&typeof globalThis.customElements!="undefined"}function se(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function ae(e){if(e===""||e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e==="undefined")return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(n){}return e}function le(e,t){return t&&t[e]?t[e]:se(e)}function ce(e){let t=[],n=e;if(n.emits&&(Array.isArray(n.emits)?t.push(...n.emits):typeof n.emits=="object"&&t.push(...Object.keys(n.emits))),n.methods){for(let a of Object.keys(n.methods))if(a.startsWith("on")&&a.length>2){let c=a.charAt(2).toLowerCase()+a.slice(3);t.push(c)}}return t}function ue(e,t={}){let{shadowMode:n="open",styles:a="",propMappings:c,eventMappings:m={},attributeConverters:f={}}=t,g=t.observedAttributes||[],y=ce(e);return class extends HTMLElement{constructor(){super();this._shadowRoot=null;this._instance=null;this._props={};this._container=null;this._connected=!1;this._eventCleanups=[];this._effectCleanup=null;this._updateScheduled=!1}static get observedAttributes(){return g}connectedCallback(){if(!this._connected){if(this._connected=!0,this._shadowRoot=this.attachShadow({mode:n}),a){let o=document.createElement("style");o.textContent=a,this._shadowRoot.appendChild(o)}this._container=document.createElement("div"),this._shadowRoot.appendChild(this._container),this._syncAttributesToProps(),this._mountComponent(),this._forwardSlots()}}disconnectedCallback(){if(this._connected){this._connected=!1;for(let o of this._eventCleanups)o();this._eventCleanups=[],this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=null),this._instance=null,this._container&&(this._container.innerHTML="")}}attributeChangedCallback(o,i,l){i!==l&&this._connected&&(this._syncAttributesToProps(),this._updateComponent())}_syncAttributesToProps(){let o={};for(let i of g)if(this.hasAttribute(i)){let l=this.getAttribute(i),r=le(i,c);f[i]?o[r]=f[i](l):o[r]=ae(l)}if(e.props){for(let[i,l]of Object.entries(e.props))if(o[i]===void 0){let r=l;r&&typeof r=="object"&&"default"in r?o[i]=typeof r.default=="function"?r.default():r.default:r==null}}this._props=o}_mountComponent(){let o=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!o)return;let i=this._createComponentContext(),l=o.call(i,_,i);l&&this._container&&this._renderVNode(l,this._container),this._setupReactiveUpdates(i,o)}_compileTemplate(o){try{let i=Function("return require")(),{compile:l}=i("../../compiler/src/index.ts"),{code:r}=l(o);return new Function("h","_ctx",`return ${r}`)}catch(i){return null}}_createComponentContext(){let o=e.state?typeof e.state=="function"?e.state():{...e.state}:{},i=e.computed||{},l=e.methods||{},r={...this._props,...o};for(let[u,s]of Object.entries(i))typeof s=="function"?Object.defineProperty(r,u,{get:s.bind(r),enumerable:!0}):s&&typeof s=="object"&&"get"in s&&Object.defineProperty(r,u,{get:s.get.bind(r),enumerable:!0});for(let[u,s]of Object.entries(l))typeof s=="function"&&(r[u]=s.bind(r));return r.emit=(u,...s)=>{let d=m[u]||u,p=new CustomEvent(d,{detail:s.length===1?s[0]:s,bubbles:!0,composed:!0});this.dispatchEvent(p)},r.$el=this._container,r.$attrs={...this._props},r.$slots=this._getSlotContent(),r}_setupReactiveUpdates(o,i){try{let l=Function("return require")(),{effect:r,stop:u}=l("../../reactivity/src/index.ts"),s=r(()=>{if(!this._connected||!this._container)return;let p=i.call(o,_,o);p&&(this._container.innerHTML="",this._renderVNode(p,this._container))},{lazy:!0}),d=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let p of d){let C=o[p];Object.defineProperty(o,p,{get(){return C},set(N){C=N;try{s()}catch(L){}},enumerable:!0})}this._effectCleanup=()=>{try{u(s)}catch(p){}}}catch(l){let r=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let u of r){let d=o[u],p=this;Object.defineProperty(o,u,{get(){return d},set(C){d=C,p._scheduleUpdate(o,i)},enumerable:!0})}}}_scheduleUpdate(o,i){this._updateScheduled||(this._updateScheduled=!0,Promise.resolve().then(()=>{if(this._updateScheduled=!1,!this._connected||!this._container)return;let l=i.call(o,_,o);l&&(this._container.innerHTML="",this._renderVNode(l,this._container))}))}_updateComponent(){if(!this._container)return;let o=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!o)return;let i=this._createComponentContext(),l=o.call(i,_,i);this._container.innerHTML="",l&&this._renderVNode(l,this._container)}_renderVNode(o,i){let l=this._vNodeToElement(o);l&&i.appendChild(l)}_vNodeToElement(o){if(!o)return null;if(typeof o.type=="symbol"){let i=document.createDocumentFragment();if(Array.isArray(o.children))for(let l of o.children){let r=this._vNodeToElement(l);r&&i.appendChild(r)}return i}if(typeof o.children=="string")return document.createTextNode(o.children);if(typeof o.type=="string"){let i=document.createElement(o.type);if(o.props)for(let[l,r]of Object.entries(o.props))if(l==="style"&&typeof r=="object")for(let[u,s]of Object.entries(r))i.style[u]=s;else if(l==="class"){if(typeof r=="string")i.className=r;else if(typeof r=="object"){let u=[];for(let[s,d]of Object.entries(r))d&&u.push(s);i.className=u.join(" ")}}else if(l.startsWith("on")&&typeof r=="function"){let u=l.slice(2).toLowerCase();i.addEventListener(u,r),this._eventCleanups.push(()=>{i.removeEventListener(u,r)})}else l==="ref"&&typeof r=="function"?r(i):i.setAttribute(l,String(r));if(Array.isArray(o.children))for(let l of o.children){let r=this._vNodeToElement(l);r&&i.appendChild(r)}else typeof o.children=="string"&&(i.textContent=o.children);return i}return typeof o.type=="object"||typeof o.type=="function"?o.component?this._vNodeToElement(o.component.subTree||o):document.createComment("component"):null}_forwardSlots(){if(!this._shadowRoot||!this._container)return;let o=this.querySelectorAll("[slot]");for(let l of o){let r=l.getAttribute("slot")||"default",u=document.createElement("slot");r!=="default"&&u.setAttribute("name",r),this._container.appendChild(u)}let i=document.createElement("slot");this._container.appendChild(i)}_getSlotContent(){var r;let o={},i=this.querySelectorAll("[slot]");for(let u of i){let s=u.getAttribute("slot")||"default";o[s]||(o[s]=[]),o[s].push(u.cloneNode(!0))}let l=[];for(let u of Array.from(this.childNodes))(r=u.hasAttribute)!=null&&r.call(u,"slot")||l.push(u.cloneNode(!0));return l.length>0&&(o.default=l),o}get _lytInstance(){return this._instance}get _lytProps(){return{...this._props}}}}function j(e,t,n){if(!e.includes("-"))throw new Error(`[Lyt Web Component] \u6807\u7B7E\u540D "${e}" \u5FC5\u987B\u5305\u542B\u8FDE\u5B57\u7B26 (-)\u3002\u8FD9\u662F Custom Element \u89C4\u8303\u7684\u8981\u6C42\u3002`);if(!I())return;let a=ue(t,n);customElements.define(e,a)}function K(e){for(let{tagName:t,component:n,options:a}of e)j(t,n,a)}function X(e){if(I())try{let t=customElements;t.__unregister&&t.__unregister(e)}catch(t){}}async function Y(e,t,n){let a=t.match(/<template>([\s\S]*?)<\/template>/),c=t.match(/<script[^>]*>([\s\S]*?)<\/script>/),m=/<style[^>]*>([\s\S]*?)<\/style>/g,f=[],g;for(;(g=m.exec(t))!==null;)f.push(g);let y=(n==null?void 0:n.styles)||"";for(let i of f)y+=i[1]+`
2
+ `;let h=a?a[1].trim():void 0,b={};if(c){let i=c[1].trim();if(i.match(/export\s+default\s*(\{[\s\S]*\}|\([\s\S]*\)[\s\S]*?\))/))try{let r={},u={exports:r};new Function("module","exports",`"use strict"; ${i.replace(/export\s+default\s*/,"module.exports =")}`)(u,r),b=u.exports||r}catch(r){}}let o={...n,styles:y};h&&!b.template&&!b.render&&(b.template=h),j(e,b,o)}
@@ -1,2 +1,2 @@
1
- var H=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var ee=(e,t)=>{for(var n in t)H(e,n,{get:t[n],enumerable:!0})},$=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of J(t))!Q.call(e,l)&&l!==n&&H(e,l,{get:()=>t[l],enumerable:!(a=Z(t,l))||a.enumerable});return e},b=(e,t,n)=>($(e,t,"default"),n&&$(n,t,"default"));var C={};ee(C,{ErrorBoundary:()=>v,Fragment:()=>F,LytError:()=>A,ShapeFlags:()=>V,createApp:()=>z,defineCustomElement:()=>I,defineCustomElementFromSFC:()=>U,h:()=>R,handleError:()=>X,installPlugin:()=>P,isBrowser:()=>O,registerComponents:()=>w,uninstallPlugin:()=>D,unregisterElement:()=>k});import{isStringOrNumber as te,isArray as B,isVNode as Y}from"@lytjs/common";var V=(d=>(d[d.ELEMENT=1]="ELEMENT",d[d.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",d[d.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",d[d.TEXT_CHILDREN=8]="TEXT_CHILDREN",d[d.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",d[d.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",d))(V||{}),F=Symbol("Fragment");function ne(e,t){if(t!=null)if(te(t))e.children=String(t),e.shapeFlag|=8;else if(B(t)){let n=[];for(let a=0;a<t.length;a++){let l=t[a];if(!(l==null||typeof l=="boolean"))if(B(l))for(let y=0;y<l.length;y++){let d=l[y];d!=null&&typeof d!="boolean"&&n.push(Y(d)?d:M(String(d)))}else Y(l)?n.push(l):n.push(M(String(l)))}e.children=n,e.shapeFlag|=16}else typeof t=="object"&&(e.children=t,e.shapeFlag|=32)}function M(e,t=null,n=null){var m,E;let a=0;typeof e=="string"?a=1:e===F?a=0:typeof e=="function"?a=2:typeof e=="object"&&e!==null&&(e.setup||e.__vccOpts||e.render)&&(a=4);let l=(m=t==null?void 0:t.key)!=null?m:null,y=(E=t==null?void 0:t.ref)!=null?E:null,d=t;if(t){let{key:h,ref:r,...i}=t;d=i}let g={type:e,props:d,children:null,key:l,ref:y,shapeFlag:a,el:null,component:null};return n!=null&&ne(g,n),g}function R(e,t,n){return M(e,t||null,n||null)}import{isPromise as j}from"@lytjs/common";function W(e){return Object.create(e||null)}function G(e){return e!==null&&typeof e=="object"&&typeof e.install=="function"}function q(e){return typeof e=="function"}function P(e,t,...n){if(G(t)){let a=t.onBeforeInstall?t.onBeforeInstall(e,...n):void 0;if(j(a))return a.then(()=>{let l=t.install(e,...n);if(j(l))return l.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)});{let l=t.install(e,...n);if(j(l))return l.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)}}else if(q(t))return t(e,...n)}function D(e,t){if(G(t)){if(typeof t.uninstall=="function")return t.uninstall(e)}else q(t)}import{effect as re,stop as oe}from"@lytjs/reactivity";import{compile as ie}from"@lytjs/compiler";import{defineComponent as se,createComponentInstance as ae,setupComponent as le,mountComponent as ce,updateComponent as ue,unmountComponent as de}from"@lytjs/component";import{createRenderer as fe}from"@lytjs/renderer";var pe=100,N=new Map;function me(e){let t=N.get(e);if(t)return N.delete(e),N.set(e,t),t;let{code:n}=ie(e);if(t=new Function("h","_ctx",`return ${n}`),N.size>=pe){let a=N.keys().next().value;N.delete(a)}return N.set(e,t),t}function ye(e){let t={...e};if(e.state&&typeof e.state!="function"){let n=e.state;t.state=()=>({...n})}if(typeof e.render=="function"){let n=e.render;t.render=(a,l)=>n(a)}if(e.computed){let n={};for(let a of Object.keys(e.computed)){let l=e.computed[a];typeof l=="function"?n[a]={get:l}:n[a]=l}t.computed=n}if(typeof e.init=="function"){let n=e.init;t.init=function(a,l){return n.call(this,a)}}return t}function ge(){return{createElement(e){return document.createElement(e)},createText(e){return document.createTextNode(e)},createComment(e){return document.createComment(e)},setAttribute(e,t,n){e.setAttribute(t,String(n))},removeAttribute(e,t){e.removeAttribute(t)},setStyle(e,t){if(typeof t=="string")e.style.cssText=t;else if(t&&typeof t=="object")for(let n in t)e.style[n]=t[n]},setClass(e,t){if(typeof t=="string")e.className=t;else if(t&&typeof t=="object"){let n=[];for(let[a,l]of Object.entries(t))l&&n.push(a);e.className=n.join(" ")}else e.className=""},insert(e,t,n){n!=null?e.insertBefore(t,n):e.appendChild(t)},remove(e){e.parentNode&&e.parentNode.removeChild(e)},replace(e,t,n){e.replaceChild(n,t)},addEventListener(e,t,n,a){e.addEventListener(t,n,a)},removeEventListener(e,t,n){e.removeEventListener(t,n)},nextTick(e){Promise.resolve().then(e)},parentNode(e){return e.parentNode},nextSibling(e){return e.nextSibling},querySelector(e){return document.querySelector(e)}}}function z(e,t){let n=new Set,a={},l={},y=W(),d={},g={},m=null,E=null,h=null,r=null,i=!1,o=ye(typeof e=="function"?{render:e}:e),u=se(o),s={config:d,globalProperties:g,get _instance(){return m},mount(f){if(i)return s;let p;if(typeof f=="string"){if(p=document.querySelector(f),!p)throw new Error(`[Lyt] \u627E\u4E0D\u5230\u6302\u8F7D\u76EE\u6807: "${f}"`)}else p=f;r=p;let _=ge();E=fe(_),m=ae(u),le(m,t||{},null);let T=m.type;if(!T.render&&T.template){let x=me(T.template);T.render=(S,K)=>x(S,K.renderProxy)}return ce(m,R),m.subTree&&E.mount(m.subTree,p),h=re(()=>{if(!(!m||!m.isMounted||!E)&&(ue(m,R),m.subTree&&r)){let x=r.firstChild,S=m.subTree;r.innerHTML="",E.mount(S,r)}},{lazy:!0}),i=!0,s},unmount(){i&&(h&&(oe(h),h=null),m&&de(m),r&&(r.innerHTML=""),m=null,E=null,r=null,i=!1)},use(f,...p){if(n.has(f))return s;n.add(f);let _=P({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:d,globalProperties:g},f,...p);return _ instanceof Promise?_.then(()=>s):s},unuse(f){if(!n.has(f))return s;n.delete(f);let p=D({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:d,globalProperties:g},f);return p instanceof Promise?p.then(()=>s):s},isInstalled(f){return n.has(f)},provide(f,p){return y[f]=p,s},inject(f,p){let _=y[f];return _!==void 0?_:p},component(f,p){return p?(a[f]=p,s):a[f]},directive(f,p){return p?(l[f]=p,s):l[f]}};return s}var A=class extends Error{constructor(t,n,a){let l=`[Lyt ${t}] ${n}`;super(l),this.name="LytError",this.code=t,this.details=a}};var L=class L{constructor(t){this.errors=[],this.options=t||{},this._hasError=!1}get hasError(){return this._hasError}static setGlobalHandler(t){L.globalHandler=t}capture(t,n,a){var d;let l={error:t,vm:n,info:a||"",timestamp:Date.now()};this.errors.push(l),this._hasError=!0;let y=(d=this.options.maxErrors)!=null?d:100;this.errors.length>y&&this.errors.splice(0,this.errors.length-y),!(this.options.onErrorCaptured&&this.options.onErrorCaptured(t instanceof A?t:new A(1004,t.message),n,l.info)===!0)&&this.options.onError&&this.options.onError(t instanceof A?t:new A(1004,t.message),n)}getFallback(t){if(!this.options.fallback||this.errors.length===0)return null;let n=this.errors[this.errors.length-1];return this.options.fallback(n.error,n.vm,n.info)}getErrors(){return this.errors.slice()}getErrorCount(){return this.errors.length}getLastErrors(){return this.errors.length===0?null:{...this.errors[this.errors.length-1]}}clear(){this.errors=[],this._hasError=!1}};L.globalHandler=null;var v=L,Ee=!0;function X(e,t,n){v.globalHandler&&v.globalHandler(e,t,n||""),Ee&&e instanceof A&&e.details}b(C,qe);import*as qe from"@lytjs/common";function O(){return typeof window!="undefined"&&typeof document!="undefined"&&typeof HTMLElement!="undefined"&&typeof customElements!="undefined"}function he(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function _e(e){if(e===""||e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e==="undefined")return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(n){}return e}function Re(e,t){return t&&t[e]?t[e]:he(e)}function Ce(e){let t=[],n=e;if(n.emits&&(Array.isArray(n.emits)?t.push(...n.emits):typeof n.emits=="object"&&t.push(...Object.keys(n.emits))),n.methods){for(let a of Object.keys(n.methods))if(a.startsWith("on")&&a.length>2){let l=a.charAt(2).toLowerCase()+a.slice(3);t.push(l)}}return t}function Ae(e,t={}){let{shadowMode:n="open",styles:a="",propMappings:l,eventMappings:y={},attributeConverters:d={}}=t,g=t.observedAttributes||[],m=Ce(e);return class extends HTMLElement{constructor(){super();this._shadowRoot=null;this._instance=null;this._props={};this._container=null;this._connected=!1;this._eventCleanups=[];this._effectCleanup=null;this._updateScheduled=!1}static get observedAttributes(){return g}connectedCallback(){if(!this._connected){if(this._connected=!0,this._shadowRoot=this.attachShadow({mode:n}),a){let r=document.createElement("style");r.textContent=a,this._shadowRoot.appendChild(r)}this._container=document.createElement("div"),this._shadowRoot.appendChild(this._container),this._syncAttributesToProps(),this._mountComponent(),this._forwardSlots()}}disconnectedCallback(){if(this._connected){this._connected=!1;for(let r of this._eventCleanups)r();this._eventCleanups=[],this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=null),this._instance=null,this._container&&(this._container.innerHTML="")}}attributeChangedCallback(r,i,c){i!==c&&this._connected&&(this._syncAttributesToProps(),this._updateComponent())}_syncAttributesToProps(){let r={};for(let i of g)if(this.hasAttribute(i)){let c=this.getAttribute(i),o=Re(i,l);d[i]?r[o]=d[i](c):r[o]=_e(c)}if(e.props){for(let[i,c]of Object.entries(e.props))if(r[i]===void 0){let o=c;o&&typeof o=="object"&&"default"in o?r[i]=typeof o.default=="function"?o.default():o.default:o==null}}this._props=r}_mountComponent(){let r=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!r)return;let i=this._createComponentContext(),c=r.call(i,R,i);c&&this._container&&this._renderVNode(c,this._container),this._setupReactiveUpdates(i,r)}_compileTemplate(r){try{let i=Function("return require")(),{compile:c}=i("../../compiler/src/index.ts"),{code:o}=c(r);return new Function("h","_ctx",`return ${o}`)}catch(i){return null}}_createComponentContext(){let r=e.state?typeof e.state=="function"?e.state():{...e.state}:{},i=e.computed||{},c=e.methods||{},o={...this._props,...r};for(let[u,s]of Object.entries(i))typeof s=="function"?Object.defineProperty(o,u,{get:s.bind(o),enumerable:!0}):s&&typeof s=="object"&&"get"in s&&Object.defineProperty(o,u,{get:s.get.bind(o),enumerable:!0});for(let[u,s]of Object.entries(c))typeof s=="function"&&(o[u]=s.bind(o));return o.emit=(u,...s)=>{let f=y[u]||u,p=new CustomEvent(f,{detail:s.length===1?s[0]:s,bubbles:!0,composed:!0});this.dispatchEvent(p)},o.$el=this._container,o.$attrs={...this._props},o.$slots=this._getSlotContent(),o}_setupReactiveUpdates(r,i){try{let c=Function("return require")(),{effect:o,stop:u}=c("../../reactivity/src/index.ts"),s=o(()=>{if(!this._connected||!this._container)return;let p=i.call(r,R,r);p&&(this._container.innerHTML="",this._renderVNode(p,this._container))},{lazy:!0}),f=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let p of f){let _=r[p];Object.defineProperty(r,p,{get(){return _},set(T){_=T;try{s()}catch(x){}},enumerable:!0})}this._effectCleanup=()=>{try{u(s)}catch(p){}}}catch(c){let o=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let u of o){let f=r[u],p=this;Object.defineProperty(r,u,{get(){return f},set(_){f=_,p._scheduleUpdate(r,i)},enumerable:!0})}}}_scheduleUpdate(r,i){this._updateScheduled||(this._updateScheduled=!0,Promise.resolve().then(()=>{if(this._updateScheduled=!1,!this._connected||!this._container)return;let c=i.call(r,R,r);c&&(this._container.innerHTML="",this._renderVNode(c,this._container))}))}_updateComponent(){if(!this._container)return;let r=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!r)return;let i=this._createComponentContext(),c=r.call(i,R,i);this._container.innerHTML="",c&&this._renderVNode(c,this._container)}_renderVNode(r,i){let c=this._vNodeToElement(r);c&&i.appendChild(c)}_vNodeToElement(r){if(!r)return null;if(typeof r.type=="symbol"){let i=document.createDocumentFragment();if(Array.isArray(r.children))for(let c of r.children){let o=this._vNodeToElement(c);o&&i.appendChild(o)}return i}if(typeof r.children=="string")return document.createTextNode(r.children);if(typeof r.type=="string"){let i=document.createElement(r.type);if(r.props)for(let[c,o]of Object.entries(r.props))if(c==="style"&&typeof o=="object")for(let[u,s]of Object.entries(o))i.style[u]=s;else if(c==="class"){if(typeof o=="string")i.className=o;else if(typeof o=="object"){let u=[];for(let[s,f]of Object.entries(o))f&&u.push(s);i.className=u.join(" ")}}else if(c.startsWith("on")&&typeof o=="function"){let u=c.slice(2).toLowerCase();i.addEventListener(u,o),this._eventCleanups.push(()=>{i.removeEventListener(u,o)})}else c==="ref"&&typeof o=="function"?o(i):i.setAttribute(c,String(o));if(Array.isArray(r.children))for(let c of r.children){let o=this._vNodeToElement(c);o&&i.appendChild(o)}else typeof r.children=="string"&&(i.textContent=r.children);return i}return typeof r.type=="object"||typeof r.type=="function"?r.component?this._vNodeToElement(r.component.subTree||r):document.createComment("component"):null}_forwardSlots(){if(!this._shadowRoot||!this._container)return;let r=this.querySelectorAll("[slot]");for(let c of r){let o=c.getAttribute("slot")||"default",u=document.createElement("slot");o!=="default"&&u.setAttribute("name",o),this._container.appendChild(u)}let i=document.createElement("slot");this._container.appendChild(i)}_getSlotContent(){var o;let r={},i=this.querySelectorAll("[slot]");for(let u of i){let s=u.getAttribute("slot")||"default";r[s]||(r[s]=[]),r[s].push(u.cloneNode(!0))}let c=[];for(let u of Array.from(this.childNodes))(o=u.hasAttribute)!=null&&o.call(u,"slot")||c.push(u.cloneNode(!0));return c.length>0&&(r.default=c),r}get _lytInstance(){return this._instance}get _lytProps(){return{...this._props}}}}function I(e,t,n){if(!e.includes("-"))throw new Error(`[Lyt Web Component] \u6807\u7B7E\u540D "${e}" \u5FC5\u987B\u5305\u542B\u8FDE\u5B57\u7B26 (-)\u3002\u8FD9\u662F Custom Element \u89C4\u8303\u7684\u8981\u6C42\u3002`);if(!O())return;let a=Ae(t,n);customElements.define(e,a)}function w(e){for(let{tagName:t,component:n,options:a}of e)I(t,n,a)}function k(e){if(O())try{let t=customElements;t.__unregister&&t.__unregister(e)}catch(t){}}async function U(e,t,n){let a=t.match(/<template>([\s\S]*?)<\/template>/),l=t.match(/<script[^>]*>([\s\S]*?)<\/script>/),y=/<style[^>]*>([\s\S]*?)<\/style>/g,d=[],g;for(;(g=y.exec(t))!==null;)d.push(g);let m=(n==null?void 0:n.styles)||"";for(let i of d)m+=i[1]+`
2
- `;let E=a?a[1].trim():void 0,h={};if(l){let i=l[1].trim();if(i.match(/export\s+default\s*(\{[\s\S]*\}|\([\s\S]*\)[\s\S]*?\))/))try{let o={},u={exports:o};new Function("module","exports",`"use strict"; ${i.replace(/export\s+default\s*/,"module.exports =")}`)(u,o),h=u.exports||o}catch(o){}}let r={...n,styles:m};E&&!h.template&&!h.render&&(h.template=E),I(e,h,r)}export{I as defineCustomElement,U as defineCustomElementFromSFC,O as isBrowser,w as registerComponents,k as unregisterElement};
1
+ var S=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var K=(e,t)=>{for(var n in t)S(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of q(t))!z.call(e,c)&&c!==n&&S(e,c,{get:()=>t[c],enumerable:!(a=W(t,c))||a.enumerable});return e},E=(e,t,n)=>(k(e,t,"default"),n&&k(n,t,"default"));var A={};K(A,{Fragment:()=>I,ShapeFlags:()=>x,createApp:()=>U,h:()=>v});import{isStringOrNumber as X,isArray as w,isVNode as V}from"@lytjs/common";var x=(f=>(f[f.ELEMENT=1]="ELEMENT",f[f.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",f[f.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",f[f.TEXT_CHILDREN=8]="TEXT_CHILDREN",f[f.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",f[f.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",f))(x||{}),I=Symbol("Fragment");function Y(e,t){if(t!=null)if(X(t))e.children=String(t),e.shapeFlag|=8;else if(w(t)){let n=[];for(let a=0;a<t.length;a++){let c=t[a];if(!(c==null||typeof c=="boolean"))if(w(c))for(let m=0;m<c.length;m++){let f=c[m];f!=null&&typeof f!="boolean"&&n.push(V(f)?f:T(String(f)))}else V(c)?n.push(c):n.push(T(String(c)))}e.children=n,e.shapeFlag|=16}else typeof t=="object"&&(e.children=t,e.shapeFlag|=32)}function T(e,t=null,n=null){var y,h;let a=0;typeof e=="string"?a=1:e===I?a=0:typeof e=="function"?a=2:typeof e=="object"&&e!==null&&(e.setup||e.__vccOpts||e.render)&&(a=4);let c=(y=t==null?void 0:t.key)!=null?y:null,m=(h=t==null?void 0:t.ref)!=null?h:null,f=t;if(t){let{key:b,ref:o,...i}=t;f=i}let g={type:e,props:f,children:null,key:c,ref:m,shapeFlag:a,el:null,component:null};return n!=null&&Y(g,n),g}function v(e,t,n){return T(e,t||null,n||null)}import{isPromise as j}from"@lytjs/common";function M(e){return Object.create(e||null)}function F(e){return e!==null&&typeof e=="object"&&typeof e.install=="function"}function D(e){return typeof e=="function"}function H(e,t,...n){if(F(t)){let a=t.onBeforeInstall?t.onBeforeInstall(e,...n):void 0;if(j(a))return a.then(()=>{let c=t.install(e,...n);if(j(c))return c.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)});{let c=t.install(e,...n);if(j(c))return c.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)}}else if(D(t))return t(e,...n)}function B(e,t){if(F(t)){if(typeof t.uninstall=="function")return t.uninstall(e)}else D(t)}import{effect as Z,stop as J}from"@lytjs/reactivity";import{compile as G}from"@lytjs/compiler";import{defineComponent as Q,createComponentInstance as ee,setupComponent as te,mountComponent as ne,updateComponent as oe,unmountComponent as re}from"@lytjs/component";import{createRenderer as ie}from"@lytjs/renderer";var se=100,_=new Map;function ae(e){let t=_.get(e);if(t)return _.delete(e),_.set(e,t),t;let{code:n}=G(e);if(t=new Function("h","_ctx",`return ${n}`),_.size>=se){let a=_.keys().next().value;_.delete(a)}return _.set(e,t),t}function le(e){let t={...e};if(e.state&&typeof e.state!="function"){let n=e.state;t.state=()=>({...n})}if(typeof e.render=="function"){let n=e.render;t.render=(a,c)=>n(a)}if(e.computed){let n={};for(let a of Object.keys(e.computed)){let c=e.computed[a];typeof c=="function"?n[a]={get:c}:n[a]=c}t.computed=n}if(typeof e.init=="function"){let n=e.init;t.init=function(a,c){return n.call(this,a)}}return t}function ce(){return{createElement(e){return document.createElement(e)},createText(e){return document.createTextNode(e)},createComment(e){return document.createComment(e)},setAttribute(e,t,n){e.setAttribute(t,String(n))},removeAttribute(e,t){e.removeAttribute(t)},setStyle(e,t){if(typeof t=="string")e.style.cssText=t;else if(t&&typeof t=="object")for(let n in t)e.style[n]=t[n]},setClass(e,t){if(typeof t=="string")e.className=t;else if(t&&typeof t=="object"){let n=[];for(let[a,c]of Object.entries(t))c&&n.push(a);e.className=n.join(" ")}else e.className=""},insert(e,t,n){n!=null?e.insertBefore(t,n):e.appendChild(t)},remove(e){e.parentNode&&e.parentNode.removeChild(e)},replace(e,t,n){e.replaceChild(n,t)},addEventListener(e,t,n,a){e.addEventListener(t,n,a)},removeEventListener(e,t,n){e.removeEventListener(t,n)},nextTick(e){Promise.resolve().then(e)},parentNode(e){return e.parentNode},nextSibling(e){return e.nextSibling},querySelector(e){return document.querySelector(e)}}}function U(e,t){let n=new Set,a={},c={},m=M(),f={},g={},y=null,h=null,b=null,o=null,i=!1,r=le(typeof e=="function"?{render:e}:e),u=Q(r),s={config:f,globalProperties:g,get _instance(){return y},mount(d){if(i)return s;let p;if(typeof d=="string"){if(p=document.querySelector(d),!p)throw new Error(`[Lyt] \u627E\u4E0D\u5230\u6302\u8F7D\u76EE\u6807: "${d}"`)}else p=d;o=p;let C=ce();h=ie(C),y=ee(u),te(y,t||{},null);let P=y.type;if(!P.render&&P.template){let N=ae(P.template);P.render=(R,$)=>N(R,$.renderProxy)}return ne(y,v),y.subTree&&h.mount(y.subTree,p),b=Z(()=>{if(!(!y||!y.isMounted||!h)&&(oe(y,v),y.subTree&&o)){let N=o.firstChild,R=y.subTree;o.innerHTML="",h.mount(R,o)}},{lazy:!0}),i=!0,s},unmount(){i&&(b&&(J(b),b=null),y&&re(y),o&&(o.innerHTML=""),y=null,h=null,o=null,i=!1)},use(d,...p){if(n.has(d))return s;n.add(d);let C=H({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:f,globalProperties:g},d,...p);return C instanceof Promise?C.then(()=>s):s},unuse(d){if(!n.has(d))return s;n.delete(d);let p=B({use:s.use.bind(s),unuse:s.unuse.bind(s),isInstalled:s.isInstalled.bind(s),provide:s.provide.bind(s),inject:s.inject.bind(s),config:f,globalProperties:g},d);return p instanceof Promise?p.then(()=>s):s},isInstalled(d){return n.has(d)},provide(d,p){return m[d]=p,s},inject(d,p){let C=m[d];return C!==void 0?C:p},component(d,p){return p?(a[d]=p,s):a[d]},directive(d,p){return p?(c[d]=p,s):c[d]}};return s}E(A,Fe);import*as Fe from"@lytjs/common";function L(){return typeof globalThis.window!="undefined"&&typeof globalThis.document!="undefined"&&typeof globalThis.HTMLElement!="undefined"&&typeof globalThis.customElements!="undefined"}function ue(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function de(e){if(e===""||e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e==="undefined")return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(n){}return e}function fe(e,t){return t&&t[e]?t[e]:ue(e)}function pe(e){let t=[],n=e;if(n.emits&&(Array.isArray(n.emits)?t.push(...n.emits):typeof n.emits=="object"&&t.push(...Object.keys(n.emits))),n.methods){for(let a of Object.keys(n.methods))if(a.startsWith("on")&&a.length>2){let c=a.charAt(2).toLowerCase()+a.slice(3);t.push(c)}}return t}function ye(e,t={}){let{shadowMode:n="open",styles:a="",propMappings:c,eventMappings:m={},attributeConverters:f={}}=t,g=t.observedAttributes||[],y=pe(e);return class extends HTMLElement{constructor(){super();this._shadowRoot=null;this._instance=null;this._props={};this._container=null;this._connected=!1;this._eventCleanups=[];this._effectCleanup=null;this._updateScheduled=!1}static get observedAttributes(){return g}connectedCallback(){if(!this._connected){if(this._connected=!0,this._shadowRoot=this.attachShadow({mode:n}),a){let o=document.createElement("style");o.textContent=a,this._shadowRoot.appendChild(o)}this._container=document.createElement("div"),this._shadowRoot.appendChild(this._container),this._syncAttributesToProps(),this._mountComponent(),this._forwardSlots()}}disconnectedCallback(){if(this._connected){this._connected=!1;for(let o of this._eventCleanups)o();this._eventCleanups=[],this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=null),this._instance=null,this._container&&(this._container.innerHTML="")}}attributeChangedCallback(o,i,l){i!==l&&this._connected&&(this._syncAttributesToProps(),this._updateComponent())}_syncAttributesToProps(){let o={};for(let i of g)if(this.hasAttribute(i)){let l=this.getAttribute(i),r=fe(i,c);f[i]?o[r]=f[i](l):o[r]=de(l)}if(e.props){for(let[i,l]of Object.entries(e.props))if(o[i]===void 0){let r=l;r&&typeof r=="object"&&"default"in r?o[i]=typeof r.default=="function"?r.default():r.default:r==null}}this._props=o}_mountComponent(){let o=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!o)return;let i=this._createComponentContext(),l=o.call(i,v,i);l&&this._container&&this._renderVNode(l,this._container),this._setupReactiveUpdates(i,o)}_compileTemplate(o){try{let i=Function("return require")(),{compile:l}=i("../../compiler/src/index.ts"),{code:r}=l(o);return new Function("h","_ctx",`return ${r}`)}catch(i){return null}}_createComponentContext(){let o=e.state?typeof e.state=="function"?e.state():{...e.state}:{},i=e.computed||{},l=e.methods||{},r={...this._props,...o};for(let[u,s]of Object.entries(i))typeof s=="function"?Object.defineProperty(r,u,{get:s.bind(r),enumerable:!0}):s&&typeof s=="object"&&"get"in s&&Object.defineProperty(r,u,{get:s.get.bind(r),enumerable:!0});for(let[u,s]of Object.entries(l))typeof s=="function"&&(r[u]=s.bind(r));return r.emit=(u,...s)=>{let d=m[u]||u,p=new CustomEvent(d,{detail:s.length===1?s[0]:s,bubbles:!0,composed:!0});this.dispatchEvent(p)},r.$el=this._container,r.$attrs={...this._props},r.$slots=this._getSlotContent(),r}_setupReactiveUpdates(o,i){try{let l=Function("return require")(),{effect:r,stop:u}=l("../../reactivity/src/index.ts"),s=r(()=>{if(!this._connected||!this._container)return;let p=i.call(o,v,o);p&&(this._container.innerHTML="",this._renderVNode(p,this._container))},{lazy:!0}),d=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let p of d){let C=o[p];Object.defineProperty(o,p,{get(){return C},set(P){C=P;try{s()}catch(N){}},enumerable:!0})}this._effectCleanup=()=>{try{u(s)}catch(p){}}}catch(l){let r=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let u of r){let d=o[u],p=this;Object.defineProperty(o,u,{get(){return d},set(C){d=C,p._scheduleUpdate(o,i)},enumerable:!0})}}}_scheduleUpdate(o,i){this._updateScheduled||(this._updateScheduled=!0,Promise.resolve().then(()=>{if(this._updateScheduled=!1,!this._connected||!this._container)return;let l=i.call(o,v,o);l&&(this._container.innerHTML="",this._renderVNode(l,this._container))}))}_updateComponent(){if(!this._container)return;let o=e.render?e.render:e.template?this._compileTemplate(e.template):null;if(!o)return;let i=this._createComponentContext(),l=o.call(i,v,i);this._container.innerHTML="",l&&this._renderVNode(l,this._container)}_renderVNode(o,i){let l=this._vNodeToElement(o);l&&i.appendChild(l)}_vNodeToElement(o){if(!o)return null;if(typeof o.type=="symbol"){let i=document.createDocumentFragment();if(Array.isArray(o.children))for(let l of o.children){let r=this._vNodeToElement(l);r&&i.appendChild(r)}return i}if(typeof o.children=="string")return document.createTextNode(o.children);if(typeof o.type=="string"){let i=document.createElement(o.type);if(o.props)for(let[l,r]of Object.entries(o.props))if(l==="style"&&typeof r=="object")for(let[u,s]of Object.entries(r))i.style[u]=s;else if(l==="class"){if(typeof r=="string")i.className=r;else if(typeof r=="object"){let u=[];for(let[s,d]of Object.entries(r))d&&u.push(s);i.className=u.join(" ")}}else if(l.startsWith("on")&&typeof r=="function"){let u=l.slice(2).toLowerCase();i.addEventListener(u,r),this._eventCleanups.push(()=>{i.removeEventListener(u,r)})}else l==="ref"&&typeof r=="function"?r(i):i.setAttribute(l,String(r));if(Array.isArray(o.children))for(let l of o.children){let r=this._vNodeToElement(l);r&&i.appendChild(r)}else typeof o.children=="string"&&(i.textContent=o.children);return i}return typeof o.type=="object"||typeof o.type=="function"?o.component?this._vNodeToElement(o.component.subTree||o):document.createComment("component"):null}_forwardSlots(){if(!this._shadowRoot||!this._container)return;let o=this.querySelectorAll("[slot]");for(let l of o){let r=l.getAttribute("slot")||"default",u=document.createElement("slot");r!=="default"&&u.setAttribute("name",r),this._container.appendChild(u)}let i=document.createElement("slot");this._container.appendChild(i)}_getSlotContent(){var r;let o={},i=this.querySelectorAll("[slot]");for(let u of i){let s=u.getAttribute("slot")||"default";o[s]||(o[s]=[]),o[s].push(u.cloneNode(!0))}let l=[];for(let u of Array.from(this.childNodes))(r=u.hasAttribute)!=null&&r.call(u,"slot")||l.push(u.cloneNode(!0));return l.length>0&&(o.default=l),o}get _lytInstance(){return this._instance}get _lytProps(){return{...this._props}}}}function O(e,t,n){if(!e.includes("-"))throw new Error(`[Lyt Web Component] \u6807\u7B7E\u540D "${e}" \u5FC5\u987B\u5305\u542B\u8FDE\u5B57\u7B26 (-)\u3002\u8FD9\u662F Custom Element \u89C4\u8303\u7684\u8981\u6C42\u3002`);if(!L())return;let a=ye(t,n);customElements.define(e,a)}function me(e){for(let{tagName:t,component:n,options:a}of e)O(t,n,a)}function ge(e){if(L())try{let t=customElements;t.__unregister&&t.__unregister(e)}catch(t){}}async function he(e,t,n){let a=t.match(/<template>([\s\S]*?)<\/template>/),c=t.match(/<script[^>]*>([\s\S]*?)<\/script>/),m=/<style[^>]*>([\s\S]*?)<\/style>/g,f=[],g;for(;(g=m.exec(t))!==null;)f.push(g);let y=(n==null?void 0:n.styles)||"";for(let i of f)y+=i[1]+`
2
+ `;let h=a?a[1].trim():void 0,b={};if(c){let i=c[1].trim();if(i.match(/export\s+default\s*(\{[\s\S]*\}|\([\s\S]*\)[\s\S]*?\))/))try{let r={},u={exports:r};new Function("module","exports",`"use strict"; ${i.replace(/export\s+default\s*/,"module.exports =")}`)(u,r),b=u.exports||r}catch(r){}}let o={...n,styles:y};h&&!b.template&&!b.render&&(b.template=h),O(e,b,o)}export{O as defineCustomElement,he as defineCustomElementFromSFC,L as isBrowser,me as registerComponents,ge as unregisterElement};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lytjs/core",
3
- "version": "4.0.4",
3
+ "version": "4.0.5",
4
4
  "description": "Lyt.js 核心入口 - 整合响应式、编译器、虚拟 DOM、渲染器和组件系统",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -61,12 +61,12 @@
61
61
  "createApp"
62
62
  ],
63
63
  "dependencies": {
64
- "@lytjs/common": "^4.0.4",
65
- "@lytjs/reactivity": "^4.0.4",
66
- "@lytjs/compiler": "^4.0.4",
67
- "@lytjs/vdom": "^4.0.4",
68
- "@lytjs/renderer": "^4.0.4",
69
- "@lytjs/component": "^4.0.4"
64
+ "@lytjs/common": "^4.0.5",
65
+ "@lytjs/reactivity": "^4.0.5",
66
+ "@lytjs/compiler": "^4.0.5",
67
+ "@lytjs/vdom": "^4.0.5",
68
+ "@lytjs/renderer": "^4.0.5",
69
+ "@lytjs/component": "^4.0.5"
70
70
  },
71
71
  "engines": {
72
72
  "node": ">=18.0.0"