@lytjs/component 5.0.1 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +509 -288
  2. package/dist/index.cjs +1945 -1
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +812 -0
  5. package/dist/index.d.ts +812 -0
  6. package/dist/index.mjs +1865 -1
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +27 -38
  9. package/dist/builtins-entry.cjs +0 -1
  10. package/dist/builtins-entry.mjs +0 -1
  11. package/dist/types/builtins/async-component.d.ts +0 -61
  12. package/dist/types/builtins/async-component.d.ts.map +0 -1
  13. package/dist/types/builtins/error-boundary.d.ts +0 -28
  14. package/dist/types/builtins/error-boundary.d.ts.map +0 -1
  15. package/dist/types/builtins/index.d.ts +0 -19
  16. package/dist/types/builtins/index.d.ts.map +0 -1
  17. package/dist/types/builtins/keep-alive.d.ts +0 -118
  18. package/dist/types/builtins/keep-alive.d.ts.map +0 -1
  19. package/dist/types/builtins/suspense.d.ts +0 -51
  20. package/dist/types/builtins/suspense.d.ts.map +0 -1
  21. package/dist/types/builtins/transition-group.d.ts +0 -40
  22. package/dist/types/builtins/transition-group.d.ts.map +0 -1
  23. package/dist/types/builtins/transition.d.ts +0 -136
  24. package/dist/types/builtins/transition.d.ts.map +0 -1
  25. package/dist/types/builtins-entry.d.ts +0 -9
  26. package/dist/types/builtins-entry.d.ts.map +0 -1
  27. package/dist/types/composition-api.d.ts +0 -116
  28. package/dist/types/composition-api.d.ts.map +0 -1
  29. package/dist/types/define-component.d.ts +0 -281
  30. package/dist/types/define-component.d.ts.map +0 -1
  31. package/dist/types/emit.d.ts +0 -92
  32. package/dist/types/emit.d.ts.map +0 -1
  33. package/dist/types/index.d.ts +0 -21
  34. package/dist/types/index.d.ts.map +0 -1
  35. package/dist/types/lifecycle.d.ts +0 -92
  36. package/dist/types/lifecycle.d.ts.map +0 -1
  37. package/dist/types/props.d.ts +0 -85
  38. package/dist/types/props.d.ts.map +0 -1
  39. package/dist/types/signal-state.d.ts +0 -58
  40. package/dist/types/signal-state.d.ts.map +0 -1
  41. package/dist/types/slots.d.ts +0 -80
  42. package/dist/types/slots.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -1 +1,1945 @@
1
- "use strict";var $=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Oe=Object.prototype.hasOwnProperty;var Ce=(e,t)=>{for(var o in t)$(e,o,{get:t[o],enumerable:!0})},Pe=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ke(t))!Oe.call(e,r)&&r!==o&&$(e,r,{get:()=>t[r],enumerable:!(n=be(t,r))||n.enumerable});return e};var he=e=>Pe($({},"__esModule",{value:!0}),e);var Ue={};Ce(Ue,{LifecycleHook:()=>M,callLifecycleHook:()=>g,camelizeToHyphen:()=>E,compositionOnBeforeMount:()=>pe,compositionOnBeforeUnmount:()=>ae,compositionOnMounted:()=>se,compositionOnUnmounted:()=>ie,compositionOnUpdated:()=>le,createComponentInstance:()=>me,createLifecycleHook:()=>S,createSignalState:()=>T,createSignalStateProxy:()=>H,currentInstance:()=>I,defineComponent:()=>ye,defineEmits:()=>G,defineFunctionalComponent:()=>de,disposeSignalState:()=>Z,emit:()=>v,getCurrentInstance:()=>fe,getPropDefaultValue:()=>B,getSignalStateSnapshot:()=>q,hasSlot:()=>re,hyphenToCamel:()=>J,initProps:()=>h,initSlots:()=>w,inject:()=>ue,mountComponent:()=>Se,normalizeEmits:()=>F,normalizePropsOptions:()=>L,normalizeSlotValue:()=>O,onBeforeUnmount:()=>te,onBeforeUpdate:()=>Y,onInit:()=>Q,onMounted:()=>X,onUnmounted:()=>oe,onUpdated:()=>ee,patchSignalState:()=>R,provide:()=>ce,renderSlot:()=>ne,runSetup:()=>D,setCurrentInstance:()=>N,setupComponent:()=>ge,setupFunctionComponent:()=>V,setupStatefulComponent:()=>A,unmountComponent:()=>K,updateComponent:()=>xe,validateProp:()=>z});module.exports=he(Ue);var x=require("@lytjs/reactivity"),_=require("@lytjs/reactivity/signal");var W=require("@lytjs/reactivity/signal");function T(e){let t={},o=Object.keys(e);for(let n=0;n<o.length;n++){let r=o[n];t[r]=(0,W.signal)(e[r])}return t}function b(e){return typeof e=="function"&&e!==null&&"set"in e}function H(e){return new Proxy(e,{get(t,o){if(typeof o=="symbol")return t[o];let n=t[o];return b(n)?n():t[o]},set(t,o,n){if(typeof o=="symbol")return t[o]=n,!0;let r=t[o];return b(r)?r.set(n):t[o]=n,!0},has(t,o){return o in t},ownKeys(t){return Object.keys(t)},getOwnPropertyDescriptor(t,o){if(typeof o=="string"&&o in t)return{configurable:!0,enumerable:!0,get:()=>{let n=t[o];return b(n)?n():n},set:n=>{let r=t[o];b(r)?r.set(n):t[o]=n}}}})}function q(e){let t={},o=Object.keys(e);for(let n=0;n<o.length;n++){let r=o[n],l=e[r];t[r]=b(l)?l():l}return t}function R(e,t){let o=Object.keys(t);for(let n=0;n<o.length;n++){let r=o[n],l=e[r];b(l)&&l.set(t[r])}}function Z(e){if(!e)return;let t=Object.keys(e);for(let o=0;o<t.length;o++){let n=t[o],r=e[n];if(r&&typeof r=="function"&&"dispose"in r)try{r.dispose()}catch(l){}delete e[n]}}var f=require("@lytjs/common");function Ee(e){return e===String?"String":e===Number?"Number":e===Boolean?"Boolean":e===Array?"Array":e===Object?"Object":e===Function?"Function":"unknown"}function L(e){if(!e)return{options:{},keys:[]};if((0,f.isArray)(e)){let r={},l=[];for(let s=0;s<e.length;s++){let i=e[s];r[i]={type:null},l.push(i)}return{options:r,keys:l}}let t={},o=[],n=Object.keys(e);for(let r=0;r<n.length;r++){let l=n[r],s=e[l];s==null?t[l]={type:null}:s===String||s===Number||s===Boolean||s===Array||s===Object||s===Function?t[l]={type:s}:(0,f.isPlainObject)(s)?t[l]={...s}:(0,f.isArray)(s)?t[l]={type:s}:t[l]={type:null},o.push(l)}return{options:t,keys:o}}function z(e,t,o){let{type:n,required:r,validator:l}=t;if(o==null)return!r;if(n!=null){let s=(0,f.isArray)(n)?n:[n],i=!1;for(let p=0;p<s.length;p++){let a=s[p],c=!1;if(a===String?c=(0,f.isString)(o):a===Number?c=(0,f.isNumber)(o):a===Boolean?c=(0,f.isBoolean)(o):a===Function?c=(0,f.isFunction)(o):a===Array?c=(0,f.isArray)(o):a===Object&&(c=(0,f.isObject)(o)),c){i=!0;break}}if(!i){let p=s.map(Ee).join(" | ");return!1}}if(l&&(0,f.isFunction)(l))try{if(!l(o))return!1}catch(s){return!1}return!0}function B(e,t){let{default:o}=e;if(o!==void 0){if((0,f.isFunction)(o)){let n=e.type;if(!(n===Function||(0,f.isArray)(n)&&n.indexOf(Function)!==-1))return o()}return o}}function h(e,t){let{options:o,keys:n}=e.propsOptions,r={};for(let l=0;l<n.length;l++){let s=n[l],i=o[s],p=t?t[s]:void 0;p===void 0&&(p=B(i,s)),i.type!==null&&i.type!==void 0&&((0,f.isArray)(i.type)?i.type:[i.type]).indexOf(Boolean)!==-1&&p===void 0&&(p=!1),z(s,i,p),r[s]=p}return e.props=r,r}var k=require("@lytjs/common");function G(e){return e}function E(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function J(e){return e.replace(/-(\w)/g,(t,o)=>o.toUpperCase())}function F(e){if(!e)return{keys:[],validators:{}};let t=[],o={};if((0,k.isArray)(e)){for(let r=0;r<e.length;r++){let l=E(e[r]);t.push(l),o[l]=null}return{keys:t,validators:o}}let n=Object.keys(e);for(let r=0;r<n.length;r++){let l=n[r],s=E(l),i=e[l];t.push(s),(0,k.isFunction)(i)?o[s]=i:o[s]=null}return{keys:t,validators:o}}function v(e,t,...o){let n=E(t),r=e.emitsOptions;if(r&&r.keys.length>0){let a=r.keys.indexOf(n)!==-1,c=r.validators[n];if((0,k.isFunction)(c))try{if(!c(...o))return!1}catch(d){return!1}}let l="on"+n.charAt(0).toUpperCase()+n.slice(1),s=l.replace(/-([a-z])/g,(a,c)=>c.toUpperCase()),i=e.props||{},p=i[s]||i[l];return(0,k.isFunction)(p)?(p(...o),!0):!1}var M=(s=>(s.INIT="init",s.MOUNTED="mounted",s.BEFORE_UPDATE="beforeUpdate",s.UPDATED="updated",s.BEFORE_UNMOUNT="beforeUnmount",s.UNMOUNTED="unmounted",s))(M||{}),I=null;function Ie(e){return typeof e=="function"}function N(e){let t=I;return I=e,t}function S(e){return function(o,n){if(!Ie(o))return;let r=n||I;r&&(r[e]||(r[e]=[]),r[e].push(o))}}function g(e,t,...o){let n=e[t];if(!(!n||n.length===0))for(let r=0;r<n.length;r++)try{n[r](...o)}catch(l){}}var Q=S("init"),X=S("mounted"),Y=S("beforeUpdate"),ee=S("updated"),te=S("beforeUnmount"),oe=S("unmounted");var C=require("@lytjs/common");function O(e){return e==null?null:(0,C.isFunction)(e)?e:Array.isArray(e)?e.length>0?e:null:e}function w(e,t){let o={};if(t==null)return e.slots=o,o;if((0,C.isFunction)(t)||Array.isArray(t))return o.default=O(t),e.slots=o,o;if((0,C.isPlainObject)(t)){let n=Object.keys(t);for(let r=0;r<n.length;r++){let l=n[r],s=t[l];s!==void 0&&(o[l]=O(s))}return e.slots=o,o}return o.default=O(t),e.slots=o,o}function ne(e,t="default",o){let n=e[t];return n==null?null:(0,C.isFunction)(n)?n(o):n}function re(e,t="default"){let o=e[t];return o!=null}var u=null;function se(e){if(u){let t=u._lifecycleHooks||(u._lifecycleHooks={});(t.mounted||(t.mounted=[])).push(e)}}function ie(e){if(u){let t=u._lifecycleHooks||(u._lifecycleHooks={});(t.unmounted||(t.unmounted=[])).push(e)}}function le(e){if(u){let t=u._lifecycleHooks||(u._lifecycleHooks={});(t.updated||(t.updated=[])).push(e)}}function pe(e){if(u){let t=u._lifecycleHooks||(u._lifecycleHooks={});(t.beforeMount||(t.beforeMount=[])).push(e)}}function ae(e){if(u){let t=u._lifecycleHooks||(u._lifecycleHooks={});(t.beforeUnmount||(t.beforeUnmount=[])).push(e)}}var j=new WeakMap;function ce(e,t){if(u){let o=j.get(u);o||(o=new Map,j.set(u,o)),o.set(e,t)}}function ue(e,t){if(u){let o=u;for(;o;){let n=j.get(o);if(n&&n.has(e))return n.get(e);o=o._parent}}return t}function D(e,t,o,n){u=t;try{return e(o,n)}finally{let r=t._lifecycleHooks||(t._lifecycleHooks={});(r.unmounted||(r.unmounted=[])).push(()=>{j.delete(t)}),u=null}}function fe(){return u}var y=require("@lytjs/common");function ye(e){return{name:e.name,options:e,_isComponentDefine:!0}}function de(e){return{options:e,_isComponentDefine:!0}}function me(e){let t=e.options,o=L(t.props),n=F(t.emits),r={_isComponent:!0,type:t,name:e.name||t.name,propsOptions:o,emitsOptions:n,props:{},state:{},setupState:{},computedRefs:{},subTree:null,isMounted:!1,isUnmounted:!1,slots:{},watchStopHandles:[],renderProxy:null,emit:null};return r.emit=(l,...s)=>v(r,l,...s),r.renderProxy=Ne(r),r}function Ne(e){return{get $name(){return e.name},get $props(){return e.props},get $state(){return e.state},get $slots(){return e.slots},get $isMounted(){return e.isMounted},$emit:e.emit,$forceUpdate(){e.update&&e.update()},$unmount(){K(e)},$setState(o){e._signalState?R(e._signalState,o):(0,y.mergeObjects)(e.state,o),e.update&&e.update()}}}function ge(e,t,o){h(e,t||null),w(e,o||null);let n=e.type;(0,y.isFunction)(n)&&!n._isComponentDefine?V(e):A(e)}function A(e){let{type:t}=e,o=t.reactivityMode==="signal",n=N(e);try{if((0,y.isFunction)(t.setup)){let s={attrs:e.props,slots:e.slots,emit:e.emit},i=D(t.setup,e,e.props,s);if((0,y.isFunction)(i))t.render=i;else if((0,y.isPlainObject)(i)){e.setupState={...i};let p=Object.keys(i);for(let a=0;a<p.length;a++)Object.defineProperty(e.renderProxy,p[a],{get(){return e.setupState[p[a]]},set(c){e.setupState[p[a]]=c},enumerable:!0})}}if((0,y.isFunction)(t.state)){let s=t.state();if((0,y.isPlainObject)(s))if(o){let i=T(s);e._signalState=i,e.state=H(i)}else e.state=(0,x.shallowReactive)({...s})}if(t.computed){let s=Object.keys(t.computed);for(let i=0;i<s.length;i++){let p=s[i],a=t.computed[p],c=typeof a=="function"?()=>a.call(e.renderProxy):()=>a.get.call(e.renderProxy),d=typeof a=="function"?void 0:P=>a.set.call(e.renderProxy,P),m;o?m=(0,_.computed)(c):d?m=(0,x.computed)({get:c,set:d}):m=(0,x.computed)(c),e.computedRefs[p]=m}}let r=t.methods;if((0,y.isPlainObject)(r)){let s=Object.keys(r);for(let i=0;i<s.length;i++){let p=s[i],a=r[p];(0,y.isFunction)(a)&&(e.renderProxy[p]=a.bind(e.renderProxy))}}if((0,y.isFunction)(t.init)){let s=t.init.call(e.renderProxy,e.props,e.state);if((0,y.isPlainObject)(s)){e.setupState={...e.setupState,...s};let i=Object.keys(s);for(let p=0;p<i.length;p++)Object.defineProperty(e.renderProxy,i[p],{get(){return e.setupState[i[p]]},set(a){e.setupState[i[p]]=a},enumerable:!0})}}let l=Object.keys(e.state);for(let s=0;s<l.length;s++){let i=l[s];Object.defineProperty(e.renderProxy,i,{get(){return e.state[i]},set(p){e.state[i]=p},enumerable:!0})}if(t.computed){let s=Object.keys(t.computed);for(let i=0;i<s.length;i++){let p=s[i],a=e.computedRefs[p];o?Object.defineProperty(e.renderProxy,p,{get(){return a()},enumerable:!0}):Object.defineProperty(e.renderProxy,p,{get(){return a.value},set(c){a.value=c},enumerable:!0})}}if(t.watch){let s=Object.keys(t.watch);for(let i=0;i<s.length;i++){let p=s[i],a=t.watch[p],c=()=>{let d=e.state[p];if(d!==void 0)return d;let m=e.props[p];return m!==void 0?m:e.renderProxy[p]};if(o){let d=(0,_.effect)(m=>{let P=c();a.handler.call(e.renderProxy,P,void 0)});e.watchStopHandles.push(d)}else{let d=(0,x.watch)(c,(m,P)=>{a.handler.call(e.renderProxy,m,P)},{immediate:!!a.immediate,deep:!!a.deep});e.watchStopHandles.push(d)}}}g(e,"init")}finally{N(n)}}function V(e){let t=e.type,o={slots:e.slots,emit:e.emit},n=t(e.props,o);e.subTree=n}function U(e,t){let o=e._lifecycleHooks;if(!o||!o[t])return;let n=o[t];for(let r=0;r<n.length;r++)try{n[r]()}catch(l){}}function Se(e,t){if(e.isMounted)return;U(e,"beforeMount");let{type:o}=e;(0,y.isFunction)(o.render)&&t&&(e.subTree=o.render.call(e.renderProxy,t,e)),e.isMounted=!0,g(e,"mounted"),U(e,"mounted")}function xe(e,t,o){if(e.isUnmounted)return;o&&h(e,o),g(e,"beforeUpdate");let{type:n}=e;(0,y.isFunction)(n.render)&&t&&(e.subTree=n.render.call(e.renderProxy,t,e)),g(e,"updated"),U(e,"updated")}function K(e){if(e.isUnmounted)return;g(e,"beforeUnmount"),U(e,"beforeUnmount"),e.isUnmounted=!0,e.isMounted=!1,e.subTree=null;for(let o of e.watchStopHandles)o();e.watchStopHandles=[],g(e,"unmounted"),U(e,"unmounted");let t=["init","mounted","beforeUpdate","updated","beforeUnmount","unmounted"];for(let o=0;o<t.length;o++)e[t[o]]=void 0;e._lifecycleHooks=void 0}
1
+ 'use strict';
2
+
3
+ var commonIs = require('@lytjs/common-is');
4
+ var commonError = require('@lytjs/common-error');
5
+ var commonString = require('@lytjs/common-string');
6
+ var reactivity = require('@lytjs/reactivity');
7
+ var commonScheduler = require('@lytjs/common-scheduler');
8
+ var vdom = require('@lytjs/vdom');
9
+ var commonVnode = require('@lytjs/common-vnode');
10
+
11
+ // src/component-setup.ts
12
+ function normalizePropsOptions(rawProps) {
13
+ if (!rawProps) return commonIs.EMPTY_OBJ;
14
+ if (commonIs.isArray(rawProps)) {
15
+ const result2 = {};
16
+ for (let i = 0; i < rawProps.length; i++) {
17
+ const key = rawProps[i];
18
+ result2[key] = {};
19
+ }
20
+ return result2;
21
+ }
22
+ const result = {};
23
+ for (const key in rawProps) {
24
+ if (commonIs.hasOwn(rawProps, key)) {
25
+ const value = rawProps[key];
26
+ result[key] = commonIs.isFunction(value) || commonIs.isArray(value) ? { type: value } : value;
27
+ }
28
+ }
29
+ return result;
30
+ }
31
+ function resolvePropValue(propOptions, value, _instance, key) {
32
+ const { type, default: defaultValue, required, validator } = propOptions;
33
+ if (value === void 0) {
34
+ if (defaultValue !== void 0) {
35
+ let def;
36
+ if (commonIs.isFunction(defaultValue)) {
37
+ try {
38
+ def = defaultValue();
39
+ } catch (e) {
40
+ def = void 0;
41
+ }
42
+ } else {
43
+ def = defaultValue;
44
+ }
45
+ return def;
46
+ }
47
+ if (type === Boolean || commonIs.isArray(type) && type.includes(Boolean)) {
48
+ return false;
49
+ }
50
+ return void 0;
51
+ }
52
+ return value;
53
+ }
54
+ function validateType(value, type, key) {
55
+ if (type === null || type === void 0) return true;
56
+ getTypeName(value);
57
+ if (commonIs.isArray(type)) {
58
+ for (let i = 0; i < type.length; i++) {
59
+ if (checkType(value, type[i])) return true;
60
+ }
61
+ type.map((t) => getTypeName(t)).join(" | ");
62
+ } else {
63
+ if (checkType(value, type)) return true;
64
+ getTypeName(type);
65
+ }
66
+ return false;
67
+ }
68
+ function checkType(value, type) {
69
+ if (type === String) return commonIs.isString(value);
70
+ if (type === Number) return commonIs.isNumber(value);
71
+ if (type === Boolean) return commonIs.isBoolean(value);
72
+ if (type === Object) return commonIs.isObject(value) && !commonIs.isArray(value);
73
+ if (type === Array) return commonIs.isArray(value);
74
+ if (type === Function) return commonIs.isFunction(value);
75
+ return false;
76
+ }
77
+ function getTypeName(value) {
78
+ if (value === null) return "null";
79
+ if (value === void 0) return "undefined";
80
+ if (commonIs.isArray(value)) return "Array";
81
+ if (commonIs.isString(value)) return "String";
82
+ if (commonIs.isNumber(value)) return "Number";
83
+ if (commonIs.isBoolean(value)) return "Boolean";
84
+ if (commonIs.isFunction(value)) return "Function";
85
+ if (commonIs.isObject(value)) return "Object";
86
+ return String(value);
87
+ }
88
+ var currentInstance = null;
89
+ function setCurrentInstance(instance) {
90
+ currentInstance = instance;
91
+ }
92
+ function getCurrentInstance() {
93
+ return currentInstance;
94
+ }
95
+ function registerLifecycleHook(instance, hookName, fn) {
96
+ if (instance) {
97
+ instance.lifecycle[hookName].add(fn);
98
+ }
99
+ }
100
+ function onMounted(fn) {
101
+ if (currentInstance) {
102
+ registerLifecycleHook(currentInstance, "mounted", fn);
103
+ }
104
+ }
105
+ function onUpdated(fn) {
106
+ if (currentInstance) {
107
+ registerLifecycleHook(currentInstance, "updated", fn);
108
+ }
109
+ }
110
+ function onUnmounted(fn) {
111
+ if (currentInstance) {
112
+ registerLifecycleHook(currentInstance, "unmounted", fn);
113
+ }
114
+ }
115
+ function onBeforeMount(fn) {
116
+ if (currentInstance) {
117
+ registerLifecycleHook(currentInstance, "beforeMount", fn);
118
+ }
119
+ }
120
+ function onBeforeUpdate(fn) {
121
+ if (currentInstance) {
122
+ registerLifecycleHook(currentInstance, "beforeUpdate", fn);
123
+ }
124
+ }
125
+ function onBeforeUnmount(fn) {
126
+ if (currentInstance) {
127
+ registerLifecycleHook(currentInstance, "beforeUnmount", fn);
128
+ }
129
+ }
130
+ function onErrorCaptured(fn) {
131
+ if (currentInstance) {
132
+ if (!currentInstance.errorCapturedHooks) {
133
+ currentInstance.errorCapturedHooks = [];
134
+ }
135
+ currentInstance.errorCapturedHooks.push(fn);
136
+ }
137
+ }
138
+ function onActivated(fn) {
139
+ if (currentInstance) {
140
+ if (!currentInstance.activatedHooks) {
141
+ currentInstance.activatedHooks = [];
142
+ }
143
+ currentInstance.activatedHooks.push(fn);
144
+ }
145
+ }
146
+ function onDeactivated(fn) {
147
+ if (currentInstance) {
148
+ if (!currentInstance.deactivatedHooks) {
149
+ currentInstance.deactivatedHooks = [];
150
+ }
151
+ currentInstance.deactivatedHooks.push(fn);
152
+ }
153
+ }
154
+ function onRenderTracked(fn) {
155
+ }
156
+ function onRenderTriggered(fn) {
157
+ }
158
+ function callOptionsHook(instance, hook, name) {
159
+ if (hook) {
160
+ try {
161
+ hook.call(instance.ctx);
162
+ } catch (err) {
163
+ handleError(err, instance, `${name} hook`);
164
+ }
165
+ }
166
+ }
167
+ function callLifecycleHook(instance, hookName) {
168
+ const hooks = instance.lifecycle[hookName];
169
+ if (hooks.size > 0) {
170
+ for (const hook of hooks) {
171
+ try {
172
+ hook();
173
+ } catch (err) {
174
+ handleError(err, instance, hookName);
175
+ }
176
+ }
177
+ }
178
+ }
179
+ function callCreatedHook(instance) {
180
+ const { beforeCreate, created } = instance.type;
181
+ callOptionsHook(instance, beforeCreate, "beforeCreate");
182
+ callOptionsHook(instance, created, "created");
183
+ }
184
+ function callMountedHook(instance) {
185
+ const { beforeMount, mounted } = instance.type;
186
+ callLifecycleHook(instance, "beforeMount");
187
+ callOptionsHook(instance, beforeMount, "beforeMount");
188
+ callLifecycleHook(instance, "mounted");
189
+ callOptionsHook(instance, mounted, "mounted");
190
+ instance.isMounted = true;
191
+ }
192
+ function callUpdatedHook(instance) {
193
+ const { beforeUpdate, updated } = instance.type;
194
+ callLifecycleHook(instance, "beforeUpdate");
195
+ callOptionsHook(instance, beforeUpdate, "beforeUpdate");
196
+ callLifecycleHook(instance, "updated");
197
+ callOptionsHook(instance, updated, "updated");
198
+ }
199
+ function callUnmountedHook(instance) {
200
+ const { beforeUnmount, unmounted } = instance.type;
201
+ callLifecycleHook(instance, "beforeUnmount");
202
+ callOptionsHook(instance, beforeUnmount, "beforeUnmount");
203
+ callLifecycleHook(instance, "unmounted");
204
+ callOptionsHook(instance, unmounted, "unmounted");
205
+ instance.isUnmounted = true;
206
+ }
207
+ function handleError(err, instance, info) {
208
+ let current = instance;
209
+ while (current) {
210
+ const hooks = current.errorCapturedHooks;
211
+ if (hooks && hooks.length > 0) {
212
+ for (const hook of hooks) {
213
+ const result = hook(err, current, info);
214
+ if (result === false) return true;
215
+ }
216
+ }
217
+ const errorHandler = current.type.errorCaptured;
218
+ if (errorHandler) {
219
+ const result = errorHandler.call(
220
+ current.ctx,
221
+ err,
222
+ current,
223
+ info
224
+ );
225
+ if (result === false) return true;
226
+ }
227
+ current = current.parent;
228
+ }
229
+ if (instance) {
230
+ const appErrorHandler = instance.root.appContext?.config?.errorHandler;
231
+ if (typeof appErrorHandler === "function") {
232
+ const publicInstance = instance.ctx ? instance.ctx : null;
233
+ appErrorHandler(err, publicInstance, info);
234
+ return true;
235
+ }
236
+ }
237
+ return false;
238
+ }
239
+
240
+ // src/emit.ts
241
+ function normalizeEmitsOptions(emits) {
242
+ if (!emits) return null;
243
+ if (commonIs.isArray(emits)) {
244
+ const result = {};
245
+ for (let i = 0; i < emits.length; i++) {
246
+ const key = emits[i];
247
+ result[key] = null;
248
+ }
249
+ return result;
250
+ }
251
+ return emits;
252
+ }
253
+ function normalizeEventName(event) {
254
+ return commonString.kebabToCamel(event);
255
+ }
256
+ function toHandlerKey(event) {
257
+ if (!event) return "";
258
+ const camelized = normalizeEventName(event);
259
+ return `on${camelized[0].toUpperCase()}${camelized.slice(1)}`;
260
+ }
261
+ function emit(instance, event, ...args) {
262
+ if (instance.isUnmounted) return;
263
+ const handlerName = toHandlerKey(event);
264
+ const handler = instance.props[handlerName] ?? instance.attrs[handlerName];
265
+ if (commonIs.isFunction(handler)) {
266
+ try {
267
+ handler(...args);
268
+ } catch (err) {
269
+ handleError(err, instance, `event handler for "${event}"`);
270
+ }
271
+ }
272
+ }
273
+ function isEmitValid(instance, event) {
274
+ if (!instance.emitsOptions) return true;
275
+ const normalized = normalizeEventName(event);
276
+ return commonIs.hasOwn(instance.emitsOptions, normalized) || commonIs.hasOwn(instance.emitsOptions, event);
277
+ }
278
+ function initSlots(instance, children) {
279
+ if (commonIs.isNullish(children)) {
280
+ instance.slots = {};
281
+ return;
282
+ }
283
+ const slots = {};
284
+ if (commonIs.isFunction(children)) {
285
+ slots.default = children;
286
+ } else if (commonIs.isObject(children) && !commonIs.isArray(children)) {
287
+ const slotObj = children;
288
+ for (const key in slotObj) {
289
+ if (commonIs.isFunction(slotObj[key])) {
290
+ slots[key] = slotObj[key];
291
+ }
292
+ }
293
+ }
294
+ instance.slots = slots;
295
+ }
296
+ function normalizeSlotValue(value) {
297
+ if (commonIs.isNullish(value)) return [];
298
+ if (commonIs.isArray(value)) return value;
299
+ if (value.__v_isVNode === true) {
300
+ return [value];
301
+ }
302
+ return [value];
303
+ }
304
+ function defineComponent(options) {
305
+ return options;
306
+ }
307
+ function defineFunctionalComponent(render, props) {
308
+ return {
309
+ name: "FunctionalComponent",
310
+ props: props ?? {},
311
+ setup(_props) {
312
+ return render;
313
+ },
314
+ // 标记为函数式组件
315
+ __isFunctional: true
316
+ };
317
+ }
318
+ function mergeOptions(options, seen = /* @__PURE__ */ new WeakSet(), path = [], pathLength = 0) {
319
+ if (seen.has(options)) {
320
+ return { ...options };
321
+ }
322
+ seen.add(options);
323
+ path[pathLength] = options;
324
+ let merged = { ...options };
325
+ if (options.extends) {
326
+ merged = mergeOptionsPair(mergeOptions(options.extends, seen, path, pathLength + 1), merged);
327
+ }
328
+ if (options.mixins) {
329
+ for (const mixin of options.mixins) {
330
+ merged = mergeOptionsPair(merged, mergeOptions(mixin, seen, path, pathLength + 1));
331
+ }
332
+ }
333
+ return merged;
334
+ }
335
+ function mergeOptionsPair(parent, child) {
336
+ const merged = { ...parent };
337
+ for (const key in child) {
338
+ if (key === "props" || key === "emits" || key === "inject") {
339
+ const parentVal = parent[key];
340
+ const childVal = child[key];
341
+ if (parentVal && childVal) {
342
+ merged[key] = { ...parentVal, ...childVal };
343
+ } else if (childVal) {
344
+ merged[key] = childVal;
345
+ }
346
+ } else if (key === "data" || key === "provide") {
347
+ const parentVal = parent[key];
348
+ const childVal = child[key];
349
+ if (parentVal && childVal) {
350
+ merged[key] = function() {
351
+ const parentData = commonIs.isFunction(parentVal) ? parentVal.call(this) : parentVal;
352
+ const childData = commonIs.isFunction(childVal) ? childVal.call(this) : childVal;
353
+ return {
354
+ ...parentData,
355
+ ...childData
356
+ };
357
+ };
358
+ } else if (childVal) {
359
+ merged[key] = childVal;
360
+ }
361
+ } else if (key === "computed" || key === "methods" || key === "watch") {
362
+ const parentVal = parent[key];
363
+ const childVal = child[key];
364
+ if (parentVal && childVal) {
365
+ merged[key] = { ...parentVal, ...childVal };
366
+ } else if (childVal) {
367
+ merged[key] = childVal;
368
+ }
369
+ } else if (key === "beforeCreate" || key === "created" || key === "beforeMount" || key === "mounted" || key === "beforeUpdate" || key === "updated" || key === "beforeUnmount" || key === "unmounted") {
370
+ const parentVal = parent[key];
371
+ const childVal = child[key];
372
+ if (parentVal && childVal) {
373
+ merged[key] = function() {
374
+ parentVal.call(this);
375
+ childVal.call(this);
376
+ };
377
+ } else if (childVal) {
378
+ merged[key] = childVal;
379
+ }
380
+ } else if (key === "mixins" || key === "extends") ; else if (commonIs.hasOwn(child, key)) {
381
+ merged[key] = child[key];
382
+ }
383
+ }
384
+ return merged;
385
+ }
386
+ function createAppContext() {
387
+ return {
388
+ config: {},
389
+ components: {},
390
+ directives: {},
391
+ mixins: [],
392
+ provides: /* @__PURE__ */ Object.create(null)
393
+ };
394
+ }
395
+ var PUBLIC_PROPERTIES_MAP = {
396
+ $: 1,
397
+ $el: 2,
398
+ $data: 4,
399
+ $props: 8,
400
+ $attrs: 16,
401
+ $slots: 32,
402
+ $refs: 64,
403
+ $parent: 128,
404
+ $root: 256,
405
+ $emit: 512,
406
+ $options: 1024,
407
+ $forceUpdate: 2048,
408
+ $nextTick: 4096,
409
+ $watch: 8192
410
+ };
411
+ function createComponentPublicInstance(instance) {
412
+ if (!instance.accessCache) {
413
+ instance.accessCache = /* @__PURE__ */ Object.create(null);
414
+ }
415
+ const PublicInstanceProxyHandlers = {
416
+ get(target, key) {
417
+ if (typeof key === "symbol") {
418
+ if (key in target) {
419
+ const res = target[key];
420
+ if (typeof res === "function" && key !== Symbol.toPrimitive && key !== Symbol.iterator) {
421
+ return res.bind(target);
422
+ }
423
+ return res;
424
+ }
425
+ return void 0;
426
+ }
427
+ const cachedValue = instance.accessCache[key];
428
+ if (cachedValue !== void 0) {
429
+ switch (cachedValue) {
430
+ case 32 /* CONTEXT */: {
431
+ const res = target[key];
432
+ if (typeof res === "function" && key !== "$emit") {
433
+ return res.bind(target);
434
+ }
435
+ return res;
436
+ }
437
+ case 1 /* OTHER */:
438
+ return void 0;
439
+ case 2 /* SETUP_STATE */:
440
+ return instance.setupState[key];
441
+ case 4 /* DATA */:
442
+ return instance.data[key];
443
+ case 8 /* PROPS */:
444
+ return instance.props[key];
445
+ case 16 /* GLOBAL_PROPERTIES */: {
446
+ const globalProperties2 = instance.appContext?.config?.globalProperties;
447
+ return globalProperties2 ? globalProperties2[key] : void 0;
448
+ }
449
+ }
450
+ }
451
+ if (key in target) {
452
+ const res = target[key];
453
+ if (typeof res === "function" && key !== "$emit") {
454
+ return res.bind(target);
455
+ }
456
+ instance.accessCache[key] = 32 /* CONTEXT */;
457
+ return res;
458
+ }
459
+ const globalProperties = instance.appContext?.config?.globalProperties;
460
+ if (globalProperties && commonIs.hasOwn(globalProperties, key)) {
461
+ instance.accessCache[key] = 16 /* GLOBAL_PROPERTIES */;
462
+ return globalProperties[key];
463
+ }
464
+ if (commonIs.hasOwn(instance.setupState, key)) {
465
+ instance.accessCache[key] = 2 /* SETUP_STATE */;
466
+ return instance.setupState[key];
467
+ }
468
+ if (commonIs.hasOwn(instance.data, key)) {
469
+ instance.accessCache[key] = 4 /* DATA */;
470
+ return instance.data[key];
471
+ }
472
+ if (commonIs.hasOwn(instance.props, key)) {
473
+ instance.accessCache[key] = 8 /* PROPS */;
474
+ return instance.props[key];
475
+ }
476
+ instance.accessCache[key] = 1 /* OTHER */;
477
+ return void 0;
478
+ },
479
+ set(_target, key, value) {
480
+ if (typeof key === "symbol") {
481
+ if (key === Symbol.toPrimitive || key === Symbol.iterator) {
482
+ return false;
483
+ }
484
+ _target[key] = value;
485
+ return true;
486
+ }
487
+ if (commonIs.hasOwn(instance.setupState, key)) {
488
+ instance.setupState[key] = value;
489
+ return true;
490
+ }
491
+ if (commonIs.hasOwn(instance.data, key)) {
492
+ instance.data[key] = value;
493
+ return true;
494
+ }
495
+ return false;
496
+ },
497
+ has(_target, key) {
498
+ if (typeof key === "symbol") {
499
+ return key in instance.setupState || key in instance.data || key in instance.props || key in _target;
500
+ }
501
+ const cachedValue = instance.accessCache[key];
502
+ if (cachedValue !== void 0) {
503
+ return cachedValue !== 1 /* OTHER */;
504
+ }
505
+ const globalProperties = instance.appContext?.config?.globalProperties;
506
+ const found = key in instance.setupState || key in instance.data || key in instance.props || (globalProperties ? key in globalProperties : false) || key in _target;
507
+ instance.accessCache[key] = found ? 32 /* CONTEXT */ : 1 /* OTHER */;
508
+ return found;
509
+ }
510
+ };
511
+ const ctx = {
512
+ get $data() {
513
+ return instance.data;
514
+ },
515
+ get $props() {
516
+ return instance.props;
517
+ },
518
+ get $el() {
519
+ return instance.vnode?.el ?? null;
520
+ },
521
+ get $options() {
522
+ return instance.type;
523
+ },
524
+ get $refs() {
525
+ return instance.refs;
526
+ },
527
+ get $slots() {
528
+ return instance.slots;
529
+ },
530
+ $emit: instance.emit,
531
+ $forceUpdate: () => {
532
+ if (instance.update) {
533
+ instance.update();
534
+ } else if (instance.isMounted && instance.render && !instance.isUnmounted) {
535
+ commonScheduler.nextTick(() => {
536
+ if (instance.isUnmounted) return;
537
+ const prevTree = instance.subTree;
538
+ const nextTree = instance.render(instance.ctx);
539
+ if (nextTree) {
540
+ instance.subTree = nextTree;
541
+ nextTree.el = prevTree?.el ?? null;
542
+ if (prevTree && "anchor" in prevTree) {
543
+ nextTree.anchor = prevTree.anchor;
544
+ }
545
+ if (prevTree && "ref" in prevTree) {
546
+ nextTree.ref = prevTree.ref;
547
+ }
548
+ }
549
+ });
550
+ }
551
+ },
552
+ $nextTick: () => commonScheduler.nextTick()
553
+ };
554
+ return new Proxy(ctx, PublicInstanceProxyHandlers);
555
+ }
556
+
557
+ // src/component-init.ts
558
+ function normalizeWatchHandler(raw, methods, proxy) {
559
+ if (typeof raw === "function") {
560
+ return raw.bind(proxy);
561
+ }
562
+ if (typeof raw === "string") {
563
+ if (methods && commonIs.hasOwn(methods, raw)) {
564
+ return methods[raw].bind(proxy);
565
+ }
566
+ return null;
567
+ }
568
+ if (raw !== null && typeof raw === "object" && typeof raw.handler !== "undefined") {
569
+ return normalizeWatchHandler(raw.handler, methods, proxy);
570
+ }
571
+ return null;
572
+ }
573
+ function finishComponentSetup(instance) {
574
+ const { type } = instance;
575
+ try {
576
+ instance.ctx = createComponentPublicInstance(instance);
577
+ } catch (err) {
578
+ handleError(err, instance, "finishComponentSetup (createComponentPublicInstance)");
579
+ instance.render = () => null;
580
+ return;
581
+ }
582
+ try {
583
+ if (type.data) {
584
+ const data = type.data.call(instance.ctx) ?? {};
585
+ instance.data = reactivity.reactive(data);
586
+ }
587
+ } catch (err) {
588
+ handleError(err, instance, "finishComponentSetup (data initialization)");
589
+ instance.render = () => null;
590
+ return;
591
+ }
592
+ const devPropsKeys = null;
593
+ const proxy = instance.ctx;
594
+ try {
595
+ if (type.methods) {
596
+ for (const key in type.methods) {
597
+ if (commonIs.hasOwn(type.methods, key)) {
598
+ const method = type.methods[key];
599
+ if (false) ;
600
+ instance.ctx[key] = method.bind(proxy);
601
+ }
602
+ }
603
+ if (devPropsKeys) ;
604
+ }
605
+ } catch (err) {
606
+ handleError(err, instance, "finishComponentSetup (methods initialization)");
607
+ instance.render = () => null;
608
+ return;
609
+ }
610
+ try {
611
+ if (type.computed) {
612
+ for (const key in type.computed) {
613
+ if (commonIs.hasOwn(type.computed, key)) {
614
+ const opt = type.computed[key];
615
+ let c;
616
+ if (typeof opt === "function") {
617
+ c = reactivity.computed(() => opt.call(proxy));
618
+ } else if (opt && typeof opt === "object") {
619
+ const { get, set } = opt;
620
+ if (false) ;
621
+ c = reactivity.computed({
622
+ get: get ? () => get.call(proxy) : () => void 0,
623
+ set: set ? (v) => set.call(proxy, v) : void 0
624
+ });
625
+ } else if (false) ;
626
+ if (false) ;
627
+ instance.ctx[key] = c;
628
+ }
629
+ }
630
+ if (devPropsKeys) ;
631
+ }
632
+ } catch (err) {
633
+ handleError(err, instance, "finishComponentSetup (computed initialization)");
634
+ instance.render = () => null;
635
+ return;
636
+ }
637
+ try {
638
+ if (type.watch) {
639
+ for (const key in type.watch) {
640
+ if (commonIs.hasOwn(type.watch, key)) {
641
+ const raw = type.watch[key];
642
+ const handlers = [];
643
+ if (Array.isArray(raw)) {
644
+ for (const h of raw) {
645
+ const normalized = normalizeWatchHandler(h, type.methods, proxy);
646
+ if (normalized) handlers.push(normalized);
647
+ }
648
+ } else {
649
+ const h = normalizeWatchHandler(raw, type.methods, proxy);
650
+ if (h) handlers.push(h);
651
+ }
652
+ const options = {};
653
+ if (!Array.isArray(raw) && raw !== null && typeof raw === "object" && typeof raw.handler !== "undefined") {
654
+ const watchObj = raw;
655
+ if (typeof watchObj.immediate === "boolean") options.immediate = watchObj.immediate;
656
+ if (typeof watchObj.deep === "boolean") options.deep = watchObj.deep;
657
+ if (typeof watchObj.flush === "string")
658
+ options.flush = watchObj.flush;
659
+ }
660
+ for (const handler of handlers) {
661
+ reactivity.watch(
662
+ () => proxy[key],
663
+ handler,
664
+ options
665
+ );
666
+ }
667
+ }
668
+ }
669
+ }
670
+ } catch (err) {
671
+ handleError(err, instance, "finishComponentSetup (watch initialization)");
672
+ instance.render = () => null;
673
+ return;
674
+ }
675
+ try {
676
+ callCreatedHook(instance);
677
+ if (type.renderTracked) {
678
+ if (!instance.renderTrackedHooks) {
679
+ instance.renderTrackedHooks = [];
680
+ }
681
+ instance.renderTrackedHooks.push(type.renderTracked.bind(proxy));
682
+ }
683
+ if (type.renderTriggered) {
684
+ if (!instance.renderTriggeredHooks) {
685
+ instance.renderTriggeredHooks = [];
686
+ }
687
+ instance.renderTriggeredHooks.push(type.renderTriggered.bind(proxy));
688
+ }
689
+ } catch (err) {
690
+ handleError(err, instance, "finishComponentSetup (lifecycle hooks)");
691
+ instance.render = () => null;
692
+ return;
693
+ }
694
+ try {
695
+ if (!instance.render) {
696
+ if (type.render) {
697
+ instance.render = type.render.bind(instance.ctx);
698
+ }
699
+ }
700
+ } catch (err) {
701
+ handleError(err, instance, "finishComponentSetup (render setup)");
702
+ instance.render = () => null;
703
+ }
704
+ }
705
+
706
+ // src/component-setup.ts
707
+ var ASYNC_SETUP_TIMEOUT = 3e4;
708
+ var uid = 0;
709
+ var setupContextCache = /* @__PURE__ */ new WeakMap();
710
+ function createComponentInstance(vnode, parent) {
711
+ const rawType = vnode.type;
712
+ if (rawType === null || rawType === void 0 || typeof rawType === "string" || typeof rawType === "number" || typeof rawType === "boolean" || typeof rawType === "symbol") {
713
+ throw new Error(
714
+ `[lytjs/component] createComponentInstance: invalid vnode.type "${String(rawType)}". Expected a component options object or function.`
715
+ );
716
+ }
717
+ const type = vnode.type;
718
+ try {
719
+ const mergedOptions = mergeOptions(type);
720
+ const appContext = parent ? parent.appContext : createAppContext();
721
+ const instance = {
722
+ uid: uid++,
723
+ type: mergedOptions,
724
+ vnode,
725
+ subTree: null,
726
+ props: commonIs.EMPTY_OBJ,
727
+ slots: {},
728
+ ctx: {},
729
+ setupState: {},
730
+ data: {},
731
+ propsOptions: normalizePropsOptions(mergedOptions.props),
732
+ emitsOptions: normalizeEmitsOptions(mergedOptions.emits),
733
+ emit: commonIs.NOOP,
734
+ isMounted: false,
735
+ isUnmounted: false,
736
+ isDeactivated: false,
737
+ isKeepingAlive: false,
738
+ refs: {},
739
+ lifecycle: {
740
+ beforeMount: /* @__PURE__ */ new Set(),
741
+ mounted: /* @__PURE__ */ new Set(),
742
+ beforeUpdate: /* @__PURE__ */ new Set(),
743
+ updated: /* @__PURE__ */ new Set(),
744
+ beforeUnmount: /* @__PURE__ */ new Set(),
745
+ unmounted: /* @__PURE__ */ new Set()
746
+ },
747
+ provides: parent ? parent.provides : /* @__PURE__ */ Object.create(null),
748
+ parent,
749
+ root: null,
750
+ appContext,
751
+ attrs: {},
752
+ accessCache: null
753
+ };
754
+ instance.emit = (event, ...args) => emit(instance, event, ...args);
755
+ instance.root = parent ? parent.root : instance;
756
+ return instance;
757
+ } catch (err) {
758
+ handleError(err, parent, "createComponentInstance");
759
+ throw err;
760
+ }
761
+ }
762
+ function setupComponent(instance) {
763
+ const vnode = instance.vnode;
764
+ if (!vnode) return;
765
+ const { children } = vnode;
766
+ const props = vnode.props ?? null;
767
+ initProps(instance, props);
768
+ initSlots(instance, children);
769
+ const setupResult = runSetup(instance);
770
+ if (commonIs.isPromise(setupResult)) {
771
+ vnode.isAsyncPlaceholder = true;
772
+ let timeoutId;
773
+ const timedSetupResult = Promise.race([
774
+ setupResult,
775
+ new Promise((_, reject) => {
776
+ timeoutId = setTimeout(
777
+ () => reject(new Error("Async component setup timed out")),
778
+ ASYNC_SETUP_TIMEOUT
779
+ );
780
+ })
781
+ ]);
782
+ timedSetupResult.then((resolvedResult) => {
783
+ if (timeoutId !== void 0) {
784
+ clearTimeout(timeoutId);
785
+ timeoutId = void 0;
786
+ }
787
+ if (instance.isUnmounted) return;
788
+ handleSetupResult(instance, resolvedResult);
789
+ vnode.isAsyncPlaceholder = false;
790
+ }).catch((err) => {
791
+ if (timeoutId !== void 0) {
792
+ clearTimeout(timeoutId);
793
+ timeoutId = void 0;
794
+ }
795
+ vnode.isAsyncPlaceholder = false;
796
+ handleError(err, instance, "setup function");
797
+ });
798
+ } else {
799
+ handleSetupResult(instance, setupResult);
800
+ }
801
+ }
802
+ function runSetup(instance) {
803
+ const { setup } = instance.type;
804
+ if (!setup) return void 0;
805
+ setCurrentInstance(instance);
806
+ try {
807
+ const setupContext = createSetupContext(instance);
808
+ const result = setup(instance.props, setupContext);
809
+ return result;
810
+ } catch (err) {
811
+ handleError(err, instance, "setup function");
812
+ instance.render = () => null;
813
+ return void 0;
814
+ } finally {
815
+ setCurrentInstance(null);
816
+ }
817
+ }
818
+ function handleSetupResult(instance, setupResult) {
819
+ if (commonIs.isFunction(setupResult)) {
820
+ instance.render = setupResult;
821
+ } else if (commonIs.isObject(setupResult) && setupResult !== null) {
822
+ instance.setupState = setupResult;
823
+ }
824
+ finishComponentSetup(instance);
825
+ }
826
+ function initProps(instance, rawProps) {
827
+ const propsOptions = instance.propsOptions;
828
+ const props = {};
829
+ if (!rawProps) {
830
+ instance.props = props;
831
+ return;
832
+ }
833
+ for (const key in propsOptions) {
834
+ if (commonIs.hasOwn(propsOptions, key)) {
835
+ const value = rawProps[key];
836
+ props[key] = resolvePropValue(propsOptions[key], value);
837
+ }
838
+ }
839
+ const attrs = {};
840
+ for (const key in rawProps) {
841
+ if (commonIs.hasOwn(rawProps, key) && !commonIs.hasOwn(propsOptions, key)) {
842
+ attrs[key] = rawProps[key];
843
+ }
844
+ }
845
+ instance.props = props;
846
+ instance.attrs = attrs;
847
+ }
848
+ function createSetupContext(instance) {
849
+ const cached = setupContextCache.get(instance);
850
+ if (cached) {
851
+ return cached;
852
+ }
853
+ const context = {
854
+ attrs: instance.attrs,
855
+ slots: instance.slots,
856
+ emit: instance.emit,
857
+ expose(exposed) {
858
+ if (!exposed) {
859
+ instance.exposed = null;
860
+ return;
861
+ }
862
+ const publicApiKeys = /* @__PURE__ */ new Set([
863
+ "$data",
864
+ "$props",
865
+ "$el",
866
+ "$emit",
867
+ "$forceUpdate",
868
+ "$nextTick",
869
+ "$slots",
870
+ "$refs",
871
+ "$options"
872
+ ]);
873
+ const safeExposed = {};
874
+ for (const key of Object.keys(exposed)) {
875
+ if (key !== "__proto__" && key !== "constructor" && !publicApiKeys.has(key)) {
876
+ safeExposed[key] = exposed[key];
877
+ }
878
+ }
879
+ instance.exposed = safeExposed;
880
+ }
881
+ };
882
+ setupContextCache.set(instance, context);
883
+ return context;
884
+ }
885
+ function provide(key, value) {
886
+ const instance = getCurrentInstance();
887
+ if (instance) {
888
+ if (instance.provides === (instance.parent?.provides ?? null)) {
889
+ instance.provides = Object.create(
890
+ instance.provides
891
+ );
892
+ }
893
+ instance.provides[key] = value;
894
+ }
895
+ }
896
+ function inject(key, defaultValue, options) {
897
+ const instance = getCurrentInstance();
898
+ if (!instance) {
899
+ return resolveDefault(defaultValue, options);
900
+ }
901
+ const lookupKey = options?.from ?? key;
902
+ if (options?.local) {
903
+ const provides = instance.provides;
904
+ const hasOwnProvides = instance.parent ? provides !== instance.parent.provides : true;
905
+ if (hasOwnProvides && commonIs.hasOwn(provides, lookupKey)) {
906
+ return provides[lookupKey];
907
+ }
908
+ return resolveDefault(defaultValue, options);
909
+ }
910
+ let current = instance.parent;
911
+ while (current) {
912
+ const provides = current.provides;
913
+ if (lookupKey in provides) {
914
+ return provides[lookupKey];
915
+ }
916
+ current = current.parent;
917
+ }
918
+ return resolveDefault(defaultValue, options);
919
+ }
920
+ function resolveDefault(defaultValue, options) {
921
+ if (defaultValue === void 0) return void 0;
922
+ if (options?.factory && typeof defaultValue === "function") {
923
+ return defaultValue();
924
+ }
925
+ return defaultValue;
926
+ }
927
+ var LRUCache = class {
928
+ constructor(maxSize = 10) {
929
+ this.cache = /* @__PURE__ */ new Map();
930
+ this.maxSize = maxSize;
931
+ }
932
+ get(key) {
933
+ const instance = this.cache.get(key);
934
+ if (instance !== void 0) {
935
+ this.cache.delete(key);
936
+ this.cache.set(key, instance);
937
+ }
938
+ return instance;
939
+ }
940
+ set(key, instance) {
941
+ if (this.cache.has(key)) {
942
+ this.cache.delete(key);
943
+ }
944
+ if (this.cache.size >= this.maxSize) {
945
+ const oldestKey = this.cache.keys().next().value;
946
+ if (oldestKey !== void 0) {
947
+ const oldestInstance = this.cache.get(oldestKey);
948
+ if (oldestInstance) {
949
+ deactivateInstance(oldestInstance);
950
+ oldestInstance.effects?.forEach((effect) => {
951
+ effect.stop();
952
+ });
953
+ }
954
+ this.cache.delete(oldestKey);
955
+ }
956
+ }
957
+ this.cache.set(key, instance);
958
+ }
959
+ delete(key) {
960
+ return this.cache.delete(key);
961
+ }
962
+ has(key) {
963
+ return this.cache.has(key);
964
+ }
965
+ forEach(callback) {
966
+ this.cache.forEach(callback);
967
+ }
968
+ get size() {
969
+ return this.cache.size;
970
+ }
971
+ keys() {
972
+ return this.cache.keys();
973
+ }
974
+ /**
975
+ * 更新缓存的最大容量
976
+ */
977
+ setMaxSize(newMaxSize) {
978
+ this.maxSize = newMaxSize;
979
+ while (this.cache.size > this.maxSize) {
980
+ const oldestKey = this.cache.keys().next().value;
981
+ if (oldestKey !== void 0) {
982
+ const oldestInstance = this.cache.get(oldestKey);
983
+ if (oldestInstance) {
984
+ deactivateInstance(oldestInstance);
985
+ oldestInstance.effects?.forEach((effect) => {
986
+ effect.stop();
987
+ });
988
+ }
989
+ this.cache.delete(oldestKey);
990
+ }
991
+ }
992
+ }
993
+ };
994
+ var KeepAlive = {
995
+ name: "KeepAlive",
996
+ props: {
997
+ include: {},
998
+ exclude: {},
999
+ max: { type: Number },
1000
+ onCacheKey: { type: Function }
1001
+ },
1002
+ setup(_props, _ctx) {
1003
+ const props = _props;
1004
+ const maxCacheSize = props.max ?? 10;
1005
+ const cache = new LRUCache(maxCacheSize);
1006
+ const _currentVNode = null;
1007
+ reactivity.watch(
1008
+ () => _props.max,
1009
+ (newMax) => {
1010
+ if (newMax !== void 0 && typeof newMax === "number" && newMax > 0) {
1011
+ cache.setMaxSize(newMax);
1012
+ }
1013
+ }
1014
+ );
1015
+ return {
1016
+ cache,
1017
+ _currentVNode
1018
+ };
1019
+ },
1020
+ render(ctx) {
1021
+ const instance = ctx;
1022
+ const props = instance.props;
1023
+ const defaultSlot = instance.slots?.default;
1024
+ if (!defaultSlot) return vdom.createCommentVNode("keep-alive");
1025
+ const children = defaultSlot();
1026
+ if (!children || children.length === 0) return vdom.createCommentVNode("keep-alive");
1027
+ const rawVNode = children[0];
1028
+ if (rawVNode == null) return vdom.createCommentVNode("keep-alive");
1029
+ if (typeof rawVNode.type === "string" || rawVNode.type === globalThis.__LYTJS_FRAGMENT__ || rawVNode.type === globalThis.__LYTJS_TEXT__ || rawVNode.type === globalThis.__LYTJS_COMMENT__) {
1030
+ return rawVNode;
1031
+ }
1032
+ const compType = rawVNode.type;
1033
+ const compName = typeof compType === "object" && compType !== null && "name" in compType ? compType.name : typeof compType === "function" ? compType.name : void 0;
1034
+ const isIncluded = props.include === void 0 || matchesPattern(compName, props.include);
1035
+ const isExcluded = props.exclude !== void 0 && matchesPattern(compName, props.exclude);
1036
+ if (!isIncluded || isExcluded) {
1037
+ return rawVNode;
1038
+ }
1039
+ const cacheKey = getCacheKey(instance, rawVNode);
1040
+ const cachedInstance = getCachedInstance(instance, cacheKey);
1041
+ if (cachedInstance) {
1042
+ cacheInstance(instance, cacheKey, cachedInstance);
1043
+ rawVNode.component = cachedInstance;
1044
+ rawVNode.shapeFlag |= vdom.ShapeFlags.COMPONENT_KEPT_ALIVE;
1045
+ activateInstance(cachedInstance);
1046
+ return rawVNode;
1047
+ }
1048
+ instance.setupState._currentVNode = rawVNode;
1049
+ return rawVNode;
1050
+ },
1051
+ created() {
1052
+ }
1053
+ };
1054
+ function createKeepAliveInstance(props = {}, parent = null) {
1055
+ const vnode = vdom.createVNode(
1056
+ KeepAlive,
1057
+ {
1058
+ ...props,
1059
+ include: props.include,
1060
+ exclude: props.exclude,
1061
+ max: props.max,
1062
+ onCacheKey: props.onCacheKey
1063
+ },
1064
+ null,
1065
+ vdom.ShapeFlags.STATEFUL_COMPONENT
1066
+ );
1067
+ const instance = createComponentInstance(vnode, parent);
1068
+ setupComponent(instance);
1069
+ return instance;
1070
+ }
1071
+ function matchesPattern(name, pattern) {
1072
+ if (!pattern) return true;
1073
+ if (name === void 0) return false;
1074
+ if (commonIs.isString(pattern)) {
1075
+ return name === pattern;
1076
+ }
1077
+ if (pattern instanceof RegExp) {
1078
+ return pattern.test(name);
1079
+ }
1080
+ if (commonIs.isArray(pattern)) {
1081
+ return pattern.some((p) => matchesPattern(name, p));
1082
+ }
1083
+ return true;
1084
+ }
1085
+ function getCacheKey(keepAlive, vnode) {
1086
+ const onCacheKey = keepAlive.props.onCacheKey;
1087
+ if (commonIs.isFunction(onCacheKey)) {
1088
+ try {
1089
+ return String(onCacheKey(vnode));
1090
+ } catch (e) {
1091
+ handleError(e, keepAlive, "onCacheKey");
1092
+ }
1093
+ }
1094
+ const type = vnode.type;
1095
+ if (typeof type === "string") {
1096
+ return type;
1097
+ }
1098
+ if (type && typeof type === "object" && "name" in type) {
1099
+ return String(type.name) || String(type);
1100
+ }
1101
+ if (typeof type === "function" && "name" in type) {
1102
+ return type.name || String(type);
1103
+ }
1104
+ return String(type);
1105
+ }
1106
+ function cacheInstance(keepAlive, key, instance) {
1107
+ const cache = keepAlive.setupState.cache;
1108
+ if (cache.has(key)) {
1109
+ cache.delete(key);
1110
+ }
1111
+ cache.set(key, instance);
1112
+ }
1113
+ function getCachedInstance(keepAlive, key) {
1114
+ const cache = keepAlive.setupState.cache;
1115
+ return cache.get(key);
1116
+ }
1117
+ function removeCachedInstance(keepAlive, key) {
1118
+ const cache = keepAlive.setupState.cache;
1119
+ return cache.delete(key);
1120
+ }
1121
+ function activateInstance(instance) {
1122
+ instance.isDeactivated = false;
1123
+ if (instance.type.activated) {
1124
+ instance.type.activated.call(instance.ctx);
1125
+ }
1126
+ if (instance.activatedHooks) {
1127
+ for (const hook of instance.activatedHooks) {
1128
+ try {
1129
+ hook();
1130
+ } catch (e) {
1131
+ handleError(e, instance, "activated hook");
1132
+ }
1133
+ }
1134
+ }
1135
+ }
1136
+ function deactivateInstance(instance) {
1137
+ instance.isDeactivated = true;
1138
+ if (instance.type.deactivated) {
1139
+ instance.type.deactivated.call(instance.ctx);
1140
+ }
1141
+ if (instance.deactivatedHooks) {
1142
+ for (const hook of instance.deactivatedHooks) {
1143
+ try {
1144
+ hook();
1145
+ } catch (e) {
1146
+ handleError(e, instance, "deactivated hook");
1147
+ }
1148
+ }
1149
+ }
1150
+ }
1151
+ var _linkerRegistered = false;
1152
+ function ensureLinkerRegistered() {
1153
+ if (_linkerRegistered) return;
1154
+ _linkerRegistered = true;
1155
+ vdom.registerSuspenseLinker(((asyncState, vnodeBoundary, domSwitch) => {
1156
+ linkSuspenseBoundary(asyncState, vnodeBoundary, domSwitch);
1157
+ }));
1158
+ }
1159
+ var SuspenseAbortedError = class extends Error {
1160
+ constructor(pendingId) {
1161
+ super(`Suspense boundary (id: ${pendingId}) was aborted`);
1162
+ this.pendingId = pendingId;
1163
+ this.name = "SuspenseAbortedError";
1164
+ }
1165
+ };
1166
+ var Suspense = {
1167
+ name: "Suspense",
1168
+ props: {
1169
+ timeout: { type: Number, default: void 0 }
1170
+ },
1171
+ setup(_props, _ctx) {
1172
+ ensureLinkerRegistered();
1173
+ const boundary = {
1174
+ isPending: false,
1175
+ error: null,
1176
+ promise: null,
1177
+ pendingPromises: /* @__PURE__ */ new Set(),
1178
+ onResolve: [],
1179
+ onPending: [],
1180
+ onError: [],
1181
+ aborted: false
1182
+ };
1183
+ const props = _props;
1184
+ if (props.onResolve) boundary.onResolve.push(props.onResolve);
1185
+ if (props.onPending) boundary.onPending.push(props.onPending);
1186
+ if (props.onError) boundary.onError.push(props.onError);
1187
+ return {
1188
+ boundary
1189
+ };
1190
+ }
1191
+ };
1192
+ function createSuspenseInstance(props = {}, parent = null) {
1193
+ const vnode = commonVnode.createBaseVNode({
1194
+ type: Suspense,
1195
+ props: {
1196
+ timeout: props.timeout,
1197
+ onResolve: props.onResolve,
1198
+ onPending: props.onPending,
1199
+ onError: props.onError
1200
+ },
1201
+ shapeFlag: commonVnode.ShapeFlags.SUSPENSE | commonVnode.ShapeFlags.STATEFUL_COMPONENT
1202
+ });
1203
+ const instance = createComponentInstance(vnode, parent);
1204
+ setupComponent(instance);
1205
+ return instance;
1206
+ }
1207
+ function createSuspenseBoundary() {
1208
+ return {
1209
+ isPending: false,
1210
+ error: null,
1211
+ promise: null,
1212
+ pendingPromises: /* @__PURE__ */ new Set(),
1213
+ onResolve: [],
1214
+ onPending: [],
1215
+ onError: [],
1216
+ aborted: false
1217
+ };
1218
+ }
1219
+ function registerAsyncChild(boundary, promise) {
1220
+ if (boundary.aborted) return false;
1221
+ const wasPending = boundary.isPending;
1222
+ boundary.isPending = true;
1223
+ boundary.error = null;
1224
+ boundary.pendingPromises.add(promise);
1225
+ if (!wasPending) {
1226
+ for (const cb of boundary.onPending) {
1227
+ cb();
1228
+ }
1229
+ if (boundary.domSwitch) {
1230
+ const switchFn = boundary.domSwitch;
1231
+ commonScheduler.nextTick(() => {
1232
+ if (!boundary.aborted) {
1233
+ switchFn(boundary, true);
1234
+ }
1235
+ });
1236
+ }
1237
+ }
1238
+ promise.then((result) => {
1239
+ if (boundary.aborted) return;
1240
+ boundary.pendingPromises.delete(promise);
1241
+ if (boundary.pendingPromises.size === 0) {
1242
+ boundary.isPending = false;
1243
+ boundary.promise = null;
1244
+ for (const cb of boundary.onResolve) {
1245
+ try {
1246
+ cb();
1247
+ } catch (e) {
1248
+ commonError.error(`Error in suspense resolve callback: ${String(e)}`);
1249
+ }
1250
+ }
1251
+ if (boundary.domSwitch) {
1252
+ const switchFn = boundary.domSwitch;
1253
+ commonScheduler.nextTick(() => {
1254
+ if (!boundary.aborted) {
1255
+ switchFn(boundary, false);
1256
+ }
1257
+ });
1258
+ }
1259
+ }
1260
+ return result;
1261
+ }).catch((err) => {
1262
+ if (boundary.aborted) return;
1263
+ boundary.pendingPromises.delete(promise);
1264
+ const caughtError = err instanceof Error ? err : new Error(String(err));
1265
+ boundary.error = caughtError;
1266
+ if (boundary.pendingPromises.size === 0) {
1267
+ boundary.isPending = false;
1268
+ boundary.promise = null;
1269
+ for (const cb of boundary.onError) {
1270
+ try {
1271
+ cb(caughtError);
1272
+ } catch (e) {
1273
+ commonError.error(`Error in suspense error callback: ${String(e)}`);
1274
+ }
1275
+ }
1276
+ }
1277
+ });
1278
+ return !wasPending;
1279
+ }
1280
+ function isSuspensePending(boundary) {
1281
+ return boundary.isPending;
1282
+ }
1283
+ function getSuspenseError(boundary) {
1284
+ return boundary.error;
1285
+ }
1286
+ function linkSuspenseBoundary(asyncState, vnodeBoundary, domSwitch) {
1287
+ asyncState.vnodeBoundary = vnodeBoundary;
1288
+ asyncState.domSwitch = domSwitch;
1289
+ }
1290
+ function resolveSuspense(boundary) {
1291
+ boundary.isPending = false;
1292
+ boundary.aborted = true;
1293
+ boundary.promise = null;
1294
+ boundary.error = null;
1295
+ boundary.pendingPromises.clear();
1296
+ for (const cb of boundary.onResolve) {
1297
+ try {
1298
+ cb();
1299
+ } catch (e) {
1300
+ commonError.error(`Error in suspense resolve callback: ${String(e)}`);
1301
+ }
1302
+ }
1303
+ }
1304
+ function abortSuspense(boundary) {
1305
+ boundary.aborted = true;
1306
+ boundary.isPending = false;
1307
+ boundary.promise = null;
1308
+ if (boundary.pendingPromises.size > 0) {
1309
+ const abortError = new SuspenseAbortedError(boundary.pendingPromises.size);
1310
+ boundary.pendingPromises.forEach((promise) => {
1311
+ try {
1312
+ const p = promise;
1313
+ if (typeof p.abort === "function") {
1314
+ p.abort(abortError);
1315
+ }
1316
+ } catch {
1317
+ }
1318
+ });
1319
+ boundary.pendingPromises.clear();
1320
+ }
1321
+ boundary.onResolve.length = 0;
1322
+ boundary.onPending.length = 0;
1323
+ boundary.onError.length = 0;
1324
+ }
1325
+
1326
+ // src/transition.ts
1327
+ var Transition = {
1328
+ name: "Transition",
1329
+ props: {
1330
+ name: { type: String },
1331
+ appear: { type: Boolean, default: false },
1332
+ mode: { type: String, default: "default" },
1333
+ enterFromClass: { type: String },
1334
+ enterActiveClass: { type: String },
1335
+ enterToClass: { type: String },
1336
+ leaveFromClass: { type: String },
1337
+ leaveActiveClass: { type: String },
1338
+ leaveToClass: { type: String },
1339
+ onBeforeEnter: { type: Function },
1340
+ onEnter: { type: Function },
1341
+ onAfterEnter: { type: Function },
1342
+ onEnterCancelled: { type: Function },
1343
+ onBeforeLeave: { type: Function },
1344
+ onLeave: { type: Function },
1345
+ onAfterLeave: { type: Function },
1346
+ onLeaveCancelled: { type: Function }
1347
+ },
1348
+ // FIX: P0-06 移除多余的 IIFE 包装和 as unknown as void 类型欺骗,
1349
+ // 直接返回渲染函数,让组件系统正确识别 setup 返回的渲染函数
1350
+ // FIX: DTS build error - 添加类型断言
1351
+ setup(_props, { slots }) {
1352
+ return (() => slots.default?.());
1353
+ }
1354
+ };
1355
+
1356
+ // src/transition-group.ts
1357
+ var TransitionGroup = {
1358
+ name: "TransitionGroup",
1359
+ props: {
1360
+ name: { type: String },
1361
+ appear: { type: Boolean, default: false },
1362
+ tag: { type: [String, Boolean] },
1363
+ moveClass: { type: String },
1364
+ enterFromClass: { type: String },
1365
+ enterActiveClass: { type: String },
1366
+ enterToClass: { type: String },
1367
+ leaveFromClass: { type: String },
1368
+ leaveActiveClass: { type: String },
1369
+ leaveToClass: { type: String },
1370
+ onBeforeEnter: { type: Function },
1371
+ onEnter: { type: Function },
1372
+ onAfterEnter: { type: Function },
1373
+ onEnterCancelled: { type: Function },
1374
+ onBeforeLeave: { type: Function },
1375
+ onLeave: { type: Function },
1376
+ onAfterLeave: { type: Function },
1377
+ onLeaveCancelled: { type: Function }
1378
+ },
1379
+ // FIX: DTS build error - 添加类型断言
1380
+ setup(_props, { slots }) {
1381
+ return (() => slots.default?.());
1382
+ }
1383
+ };
1384
+
1385
+ // src/teleport.ts
1386
+ var Teleport = {
1387
+ name: "Teleport",
1388
+ // FIX: P1-21 定义正确的 props 类型替代 as any
1389
+ // FIX: DTS build error - 使用 any 避免 PropConstructor 类型不兼容
1390
+ // FIX: DTS build error - props 使用 any 类型
1391
+ props: {
1392
+ to: { type: [String, Object], required: true },
1393
+ disabled: { type: Boolean, default: false }
1394
+ },
1395
+ setup() {
1396
+ }
1397
+ };
1398
+ var activeErrorBoundaries = /* @__PURE__ */ new Set();
1399
+ var globalHandlerInstalled = false;
1400
+ function globalUnhandledRejectionHandler(event) {
1401
+ for (const eb of activeErrorBoundaries) {
1402
+ eb.handler(event);
1403
+ }
1404
+ }
1405
+ function isErrorBoundaryProps(props) {
1406
+ return props !== null && typeof props === "object";
1407
+ }
1408
+ var ErrorBoundary = {
1409
+ name: "ErrorBoundary",
1410
+ props: {
1411
+ onError: { type: Function },
1412
+ fallback: { type: Object },
1413
+ /** 是否捕获异步 Promise 错误 */
1414
+ capturePromiseRejections: { type: Boolean, default: false }
1415
+ },
1416
+ setup(props) {
1417
+ const error2 = reactivity.ref(null);
1418
+ const hasError = reactivity.ref(false);
1419
+ const typedProps = isErrorBoundaryProps(props) ? props : {};
1420
+ onErrorCaptured((err, _instance, info) => {
1421
+ error2.value = err;
1422
+ hasError.value = true;
1423
+ typedProps.onError?.(err, info);
1424
+ return false;
1425
+ });
1426
+ let currentBoundary = null;
1427
+ onMounted(() => {
1428
+ if (typedProps.capturePromiseRejections && typeof window !== "undefined") {
1429
+ currentBoundary = {
1430
+ handler: (event) => {
1431
+ const err = event.reason instanceof Error ? event.reason : new Error(String(event.reason));
1432
+ error2.value = err;
1433
+ hasError.value = true;
1434
+ typedProps.onError?.(
1435
+ err,
1436
+ "unhandledrejection"
1437
+ );
1438
+ }
1439
+ };
1440
+ activeErrorBoundaries.add(currentBoundary);
1441
+ if (!globalHandlerInstalled) {
1442
+ globalHandlerInstalled = true;
1443
+ window.addEventListener("unhandledrejection", globalUnhandledRejectionHandler);
1444
+ }
1445
+ }
1446
+ });
1447
+ onUnmounted(() => {
1448
+ if (currentBoundary) {
1449
+ activeErrorBoundaries.delete(currentBoundary);
1450
+ currentBoundary = null;
1451
+ if (activeErrorBoundaries.size === 0 && globalHandlerInstalled) {
1452
+ globalHandlerInstalled = false;
1453
+ window.removeEventListener("unhandledrejection", globalUnhandledRejectionHandler);
1454
+ }
1455
+ }
1456
+ });
1457
+ const render = (ctx) => {
1458
+ if (hasError.value) {
1459
+ const fallbackSlot = ctx.$slots.fallback;
1460
+ if (fallbackSlot) {
1461
+ const result = fallbackSlot({ error: error2.value });
1462
+ if (!Array.isArray(result)) {
1463
+ return result;
1464
+ }
1465
+ if (result.length > 0) {
1466
+ if (result.length === 1) {
1467
+ return result[0];
1468
+ }
1469
+ return vdom.createVNode(commonVnode.Fragment, null, result);
1470
+ }
1471
+ }
1472
+ return vdom.createVNode(
1473
+ commonVnode.Text,
1474
+ null,
1475
+ error2.value ? `Error: ${error2.value.message}` : "An error occurred"
1476
+ );
1477
+ }
1478
+ const defaultSlot = ctx.$slots.default;
1479
+ if (defaultSlot) {
1480
+ const result = defaultSlot();
1481
+ if (Array.isArray(result) && result.length > 0) {
1482
+ if (result.length === 1) {
1483
+ return result[0];
1484
+ }
1485
+ return vdom.createVNode(commonVnode.Fragment, null, result);
1486
+ }
1487
+ }
1488
+ return vdom.createVNode(commonVnode.Text, null, "");
1489
+ };
1490
+ return { error: error2, hasError, render };
1491
+ }
1492
+ };
1493
+ function createSignalState(initialValue) {
1494
+ return reactivity.signal(initialValue);
1495
+ }
1496
+ function createComputedState(getter) {
1497
+ return reactivity.computedSignal(getter);
1498
+ }
1499
+ var preloadedComponents = /* @__PURE__ */ new WeakMap();
1500
+ var asyncComponentStates = /* @__PURE__ */ new WeakMap();
1501
+ function defineAsyncComponent(options) {
1502
+ const normalizedOptions = commonIs.isFunction(options) ? { loader: options } : options;
1503
+ const {
1504
+ loader,
1505
+ loadingComponent,
1506
+ errorComponent,
1507
+ delay = 200,
1508
+ timeout,
1509
+ // FIX: DTS build error - suspensible 未使�
1510
+ // suspensible = false,
1511
+ onError
1512
+ } = normalizedOptions;
1513
+ let loadPromise = null;
1514
+ function load() {
1515
+ if (preloadedComponents.has(loader)) {
1516
+ return preloadedComponents.get(loader);
1517
+ }
1518
+ if (loadPromise) {
1519
+ return loadPromise;
1520
+ }
1521
+ loadPromise = loader().then((comp) => {
1522
+ const resolvedComponent = comp.default || comp;
1523
+ preloadedComponents.set(loader, Promise.resolve(resolvedComponent));
1524
+ return resolvedComponent;
1525
+ }).catch((err) => {
1526
+ loadPromise = null;
1527
+ const error2 = err instanceof Error ? err : new Error(String(err));
1528
+ if (onError) {
1529
+ onError(error2);
1530
+ }
1531
+ throw error2;
1532
+ });
1533
+ return loadPromise;
1534
+ }
1535
+ function preload() {
1536
+ if (preloadedComponents.has(loader)) {
1537
+ return Promise.resolve();
1538
+ }
1539
+ return load().then(() => {
1540
+ }).catch(() => {
1541
+ });
1542
+ }
1543
+ const AsyncComponentWrapper = {
1544
+ name: "AsyncComponentWrapper",
1545
+ setup(_props, { slots }) {
1546
+ const instance = getCurrentInstance();
1547
+ let state;
1548
+ if (instance && asyncComponentStates.has(instance)) {
1549
+ state = asyncComponentStates.get(instance);
1550
+ } else {
1551
+ state = {
1552
+ loadedComponent: null,
1553
+ error: null,
1554
+ isLoading: false,
1555
+ isLoaded: false,
1556
+ isError: false,
1557
+ loadingPromise: null
1558
+ };
1559
+ if (instance) {
1560
+ asyncComponentStates.set(instance, state);
1561
+ }
1562
+ }
1563
+ if (state.isLoaded && state.loadedComponent) {
1564
+ return () => renderLoadedComponent(state.loadedComponent, slots);
1565
+ }
1566
+ if (state.isError) {
1567
+ return () => errorComponent ? createComponentVNode(errorComponent, { error: state.error }) : createAsyncCommentVNode(" Async component error ");
1568
+ }
1569
+ if (!state.isLoading) {
1570
+ state.isLoading = true;
1571
+ state.loadingPromise = load().then((comp) => {
1572
+ state.loadedComponent = comp;
1573
+ state.isLoaded = true;
1574
+ state.isLoading = false;
1575
+ if (instance) {
1576
+ triggerComponentUpdate(instance);
1577
+ }
1578
+ }).catch((err) => {
1579
+ state.error = err instanceof Error ? err : new Error(String(err));
1580
+ state.isError = true;
1581
+ state.isLoading = false;
1582
+ if (instance) {
1583
+ triggerComponentUpdate(instance);
1584
+ }
1585
+ });
1586
+ if (timeout !== void 0 && timeout > 0) {
1587
+ const timeoutId = setTimeout(() => {
1588
+ if (!state.isLoaded && !state.isError) {
1589
+ state.error = new Error(`Async component loading timed out after ${timeout}ms`);
1590
+ state.isError = true;
1591
+ state.isLoading = false;
1592
+ if (instance) {
1593
+ triggerComponentUpdate(instance);
1594
+ }
1595
+ }
1596
+ }, timeout);
1597
+ onBeforeUnmount(() => {
1598
+ clearTimeout(timeoutId);
1599
+ });
1600
+ }
1601
+ }
1602
+ return () => {
1603
+ if (delay === 0 && state.isLoading && !state.loadedComponent) {
1604
+ return createAsyncCommentVNode(" Async component loading ");
1605
+ }
1606
+ if (loadingComponent) {
1607
+ return createComponentVNode(loadingComponent, {});
1608
+ }
1609
+ return createAsyncCommentVNode(" Async component loading ");
1610
+ };
1611
+ }
1612
+ };
1613
+ return Object.assign(AsyncComponentWrapper, { preload });
1614
+ }
1615
+ function triggerComponentUpdate(instance) {
1616
+ if (instance.update) {
1617
+ instance.update();
1618
+ }
1619
+ }
1620
+ function createComponentVNode(component, props) {
1621
+ return vdom.createVNode(component, props, null, vdom.ShapeFlags.STATEFUL_COMPONENT);
1622
+ }
1623
+ function createAsyncCommentVNode(text) {
1624
+ return vdom.createCommentVNode(text);
1625
+ }
1626
+ function renderLoadedComponent(component, slots) {
1627
+ return vdom.createVNode(component, {}, slots, vdom.ShapeFlags.STATEFUL_COMPONENT);
1628
+ }
1629
+ function preloadComponents(loaders) {
1630
+ return Promise.all(loaders.map((loader) => preloadComponent(loader))).then(() => {
1631
+ });
1632
+ }
1633
+ function preloadComponent(loader) {
1634
+ if (preloadedComponents.has(loader)) {
1635
+ return Promise.resolve();
1636
+ }
1637
+ return loader().then((comp) => {
1638
+ const resolvedComponent = comp.default || comp;
1639
+ preloadedComponents.set(loader, Promise.resolve(resolvedComponent));
1640
+ }).catch(() => {
1641
+ });
1642
+ }
1643
+ function isComponentPreloaded(loader) {
1644
+ return preloadedComponents.has(loader);
1645
+ }
1646
+ function clearPreloadCache(loader) {
1647
+ if (loader) {
1648
+ preloadedComponents.delete(loader);
1649
+ }
1650
+ }
1651
+ var InjectionToken = class {
1652
+ constructor(description, options) {
1653
+ this.description = description;
1654
+ this.__token = Symbol(description);
1655
+ this.factory = options?.factory;
1656
+ this.lifecycle = options?.lifecycle;
1657
+ }
1658
+ toString() {
1659
+ return `InjectionToken(${this.description})`;
1660
+ }
1661
+ };
1662
+ function isInjectionToken(value) {
1663
+ return value instanceof InjectionToken;
1664
+ }
1665
+ var globalProviderRoot = null;
1666
+ var currentProviderNode = null;
1667
+ function createProviderNode(parent = null) {
1668
+ const node = {
1669
+ id: /* @__PURE__ */ Symbol("provider-node"),
1670
+ parent,
1671
+ children: /* @__PURE__ */ new Set(),
1672
+ providers: /* @__PURE__ */ new Map(),
1673
+ scope: reactivity.effectScope()
1674
+ };
1675
+ if (parent) {
1676
+ parent.children.add(node);
1677
+ }
1678
+ return node;
1679
+ }
1680
+ function getProviderRoot() {
1681
+ if (!globalProviderRoot) {
1682
+ globalProviderRoot = createProviderNode();
1683
+ }
1684
+ return globalProviderRoot;
1685
+ }
1686
+ function enterProviderScope() {
1687
+ const parent = currentProviderNode || getProviderRoot();
1688
+ currentProviderNode = createProviderNode(parent);
1689
+ return currentProviderNode;
1690
+ }
1691
+ function exitProviderScope() {
1692
+ if (currentProviderNode && currentProviderNode.parent) {
1693
+ currentProviderNode.scope.stop();
1694
+ currentProviderNode.parent.children.delete(currentProviderNode);
1695
+ currentProviderNode = currentProviderNode.parent;
1696
+ }
1697
+ }
1698
+ function getCurrentProviderNode() {
1699
+ return currentProviderNode;
1700
+ }
1701
+ var InjectionError = class extends Error {
1702
+ constructor(token, message) {
1703
+ super(`Injection error for token "${String(token)}": ${message}`);
1704
+ this.token = token;
1705
+ this.name = "InjectionError";
1706
+ }
1707
+ };
1708
+ function provide2(key, valueOrConfig) {
1709
+ const instance = getCurrentInstance();
1710
+ const providerNode = currentProviderNode || (instance ? null : getProviderRoot());
1711
+ const actualKey = isInjectionToken(key) ? key.__token : key;
1712
+ let record;
1713
+ if (isProviderConfig(valueOrConfig)) {
1714
+ const config = valueOrConfig;
1715
+ const lifecycle = config.lifecycle || "singleton";
1716
+ if (config.provide !== void 0) {
1717
+ record = {
1718
+ value: config.provide,
1719
+ lifecycle
1720
+ };
1721
+ } else if (config.useFactory) {
1722
+ record = {
1723
+ value: config.useFactory(),
1724
+ lifecycle
1725
+ };
1726
+ } else if (config.useExisting) {
1727
+ record = {
1728
+ value: () => inject2(config.useExisting),
1729
+ lifecycle
1730
+ };
1731
+ } else {
1732
+ throw new InjectionError(
1733
+ actualKey,
1734
+ "ProviderConfig must have provide, useFactory, or useExisting"
1735
+ );
1736
+ }
1737
+ } else {
1738
+ record = {
1739
+ value: valueOrConfig,
1740
+ lifecycle: "singleton"
1741
+ };
1742
+ }
1743
+ if (instance) {
1744
+ if (instance.provides === (instance.parent?.provides ?? null)) {
1745
+ instance.provides = Object.create(
1746
+ instance.provides
1747
+ );
1748
+ }
1749
+ instance.provides[actualKey] = record.value;
1750
+ } else if (providerNode) {
1751
+ providerNode.providers.set(actualKey, record);
1752
+ }
1753
+ }
1754
+ function inject2(key, options) {
1755
+ const instance = getCurrentInstance();
1756
+ const providerNode = currentProviderNode;
1757
+ const actualKey = isInjectionToken(key) ? key.__token : key;
1758
+ const lookupKey = actualKey;
1759
+ if (instance) {
1760
+ const result = injectFromInstance(instance, lookupKey, options);
1761
+ if (result !== void 0) {
1762
+ return result;
1763
+ }
1764
+ }
1765
+ if (providerNode) {
1766
+ const result = injectFromProviderNode(providerNode, lookupKey);
1767
+ if (result !== void 0) {
1768
+ return result;
1769
+ }
1770
+ }
1771
+ if (globalProviderRoot) {
1772
+ const result = injectFromProviderNode(globalProviderRoot, lookupKey);
1773
+ if (result !== void 0) {
1774
+ return result;
1775
+ }
1776
+ }
1777
+ if (isInjectionToken(key) && key.factory) {
1778
+ return key.factory();
1779
+ }
1780
+ {
1781
+ throw new InjectionError(actualKey, "No provider found");
1782
+ }
1783
+ }
1784
+ function injectFromInstance(instance, key, options) {
1785
+ {
1786
+ const provides = instance.provides;
1787
+ if (key in provides) {
1788
+ return provides[key];
1789
+ }
1790
+ }
1791
+ let current = options?.skipSelf ? instance.parent : instance.parent;
1792
+ while (current) {
1793
+ const provides = current.provides;
1794
+ if (key in provides) {
1795
+ return provides[key];
1796
+ }
1797
+ current = current.parent;
1798
+ }
1799
+ return void 0;
1800
+ }
1801
+ function injectFromProviderNode(node, key, options) {
1802
+ {
1803
+ const record = node.providers.get(key);
1804
+ if (record) {
1805
+ if (typeof record.value === "function" && record.lifecycle === "transient") {
1806
+ return record.value();
1807
+ }
1808
+ return record.value;
1809
+ }
1810
+ }
1811
+ let current = node.parent;
1812
+ while (current) {
1813
+ const record = current.providers.get(key);
1814
+ if (record) {
1815
+ if (typeof record.value === "function" && record.lifecycle === "transient") {
1816
+ return record.value();
1817
+ }
1818
+ return record.value;
1819
+ }
1820
+ current = current.parent;
1821
+ }
1822
+ return void 0;
1823
+ }
1824
+ function isProviderConfig(value) {
1825
+ return typeof value === "object" && value !== null && ("provide" in value || "useFactory" in value || "useExisting" in value || "lifecycle" in value);
1826
+ }
1827
+ function provideSingleton(key, factory) {
1828
+ provide2(key, {
1829
+ useFactory: factory,
1830
+ lifecycle: "singleton"
1831
+ });
1832
+ }
1833
+ function provideScoped(key, factory) {
1834
+ provide2(key, {
1835
+ useFactory: factory,
1836
+ lifecycle: "scoped"
1837
+ });
1838
+ }
1839
+ function provideTransient(key, factory) {
1840
+ provide2(key, {
1841
+ useFactory: factory,
1842
+ lifecycle: "transient"
1843
+ });
1844
+ }
1845
+ function provideAll(providers) {
1846
+ for (const provider of providers) {
1847
+ const { provide: key, useValue, useFactory, useExisting, lifecycle } = provider;
1848
+ provide2(key, {
1849
+ provide: useValue,
1850
+ useFactory,
1851
+ useExisting,
1852
+ lifecycle
1853
+ });
1854
+ }
1855
+ }
1856
+ function withProviderScope(fn) {
1857
+ const node = enterProviderScope();
1858
+ try {
1859
+ return node.scope.run(fn);
1860
+ } finally {
1861
+ exitProviderScope();
1862
+ }
1863
+ }
1864
+
1865
+ exports.ErrorBoundary = ErrorBoundary;
1866
+ exports.InjectionError = InjectionError;
1867
+ exports.InjectionToken = InjectionToken;
1868
+ exports.KeepAlive = KeepAlive;
1869
+ exports.PUBLIC_PROPERTIES_MAP = PUBLIC_PROPERTIES_MAP;
1870
+ exports.Suspense = Suspense;
1871
+ exports.Teleport = Teleport;
1872
+ exports.Transition = Transition;
1873
+ exports.TransitionGroup = TransitionGroup;
1874
+ exports.abortSuspense = abortSuspense;
1875
+ exports.activateInstance = activateInstance;
1876
+ exports.cacheInstance = cacheInstance;
1877
+ exports.callCreatedHook = callCreatedHook;
1878
+ exports.callLifecycleHook = callLifecycleHook;
1879
+ exports.callMountedHook = callMountedHook;
1880
+ exports.callUnmountedHook = callUnmountedHook;
1881
+ exports.callUpdatedHook = callUpdatedHook;
1882
+ exports.clearPreloadCache = clearPreloadCache;
1883
+ exports.createAppContext = createAppContext;
1884
+ exports.createComponentInstance = createComponentInstance;
1885
+ exports.createComponentPublicInstance = createComponentPublicInstance;
1886
+ exports.createComputedState = createComputedState;
1887
+ exports.createKeepAliveInstance = createKeepAliveInstance;
1888
+ exports.createSignalState = createSignalState;
1889
+ exports.createSuspenseBoundary = createSuspenseBoundary;
1890
+ exports.createSuspenseInstance = createSuspenseInstance;
1891
+ exports.deactivateInstance = deactivateInstance;
1892
+ exports.defineAsyncComponent = defineAsyncComponent;
1893
+ exports.defineComponent = defineComponent;
1894
+ exports.defineFunctionalComponent = defineFunctionalComponent;
1895
+ exports.emit = emit;
1896
+ exports.enterProviderScope = enterProviderScope;
1897
+ exports.exitProviderScope = exitProviderScope;
1898
+ exports.finishComponentSetup = finishComponentSetup;
1899
+ exports.getCacheKey = getCacheKey;
1900
+ exports.getCachedInstance = getCachedInstance;
1901
+ exports.getCurrentInstance = getCurrentInstance;
1902
+ exports.getCurrentProviderNode = getCurrentProviderNode;
1903
+ exports.getProviderRoot = getProviderRoot;
1904
+ exports.getSuspenseError = getSuspenseError;
1905
+ exports.handleError = handleError;
1906
+ exports.initProps = initProps;
1907
+ exports.initSlots = initSlots;
1908
+ exports.inject = inject;
1909
+ exports.isComponentPreloaded = isComponentPreloaded;
1910
+ exports.isEmitValid = isEmitValid;
1911
+ exports.isInjectionToken = isInjectionToken;
1912
+ exports.isSuspensePending = isSuspensePending;
1913
+ exports.linkSuspenseBoundary = linkSuspenseBoundary;
1914
+ exports.matchesPattern = matchesPattern;
1915
+ exports.normalizeEmitsOptions = normalizeEmitsOptions;
1916
+ exports.normalizePropsOptions = normalizePropsOptions;
1917
+ exports.normalizeSlotValue = normalizeSlotValue;
1918
+ exports.onActivated = onActivated;
1919
+ exports.onBeforeMount = onBeforeMount;
1920
+ exports.onBeforeUnmount = onBeforeUnmount;
1921
+ exports.onBeforeUpdate = onBeforeUpdate;
1922
+ exports.onDeactivated = onDeactivated;
1923
+ exports.onErrorCaptured = onErrorCaptured;
1924
+ exports.onMounted = onMounted;
1925
+ exports.onRenderTracked = onRenderTracked;
1926
+ exports.onRenderTriggered = onRenderTriggered;
1927
+ exports.onUnmounted = onUnmounted;
1928
+ exports.onUpdated = onUpdated;
1929
+ exports.preloadComponent = preloadComponent;
1930
+ exports.preloadComponents = preloadComponents;
1931
+ exports.provide = provide;
1932
+ exports.provideAll = provideAll;
1933
+ exports.provideScoped = provideScoped;
1934
+ exports.provideSingleton = provideSingleton;
1935
+ exports.provideTransient = provideTransient;
1936
+ exports.registerAsyncChild = registerAsyncChild;
1937
+ exports.removeCachedInstance = removeCachedInstance;
1938
+ exports.resolvePropValue = resolvePropValue;
1939
+ exports.resolveSuspense = resolveSuspense;
1940
+ exports.setCurrentInstance = setCurrentInstance;
1941
+ exports.setupComponent = setupComponent;
1942
+ exports.validateType = validateType;
1943
+ exports.withProviderScope = withProviderScope;
1944
+ //# sourceMappingURL=index.cjs.map
1945
+ //# sourceMappingURL=index.cjs.map