@lytjs/core 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 (44) hide show
  1. package/README.md +328 -288
  2. package/dist/index.cjs +3585 -1
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +1556 -0
  5. package/dist/index.d.ts +1556 -0
  6. package/dist/index.mjs +3440 -1
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +43 -57
  9. package/dist/error-entry.cjs +0 -1
  10. package/dist/error-entry.mjs +0 -1
  11. package/dist/plugin-entry.cjs +0 -1
  12. package/dist/plugin-entry.mjs +0 -1
  13. package/dist/shared-entry.cjs +0 -1
  14. package/dist/shared-entry.mjs +0 -1
  15. package/dist/types/create-app.d.ts +0 -161
  16. package/dist/types/create-app.d.ts.map +0 -1
  17. package/dist/types/dev-error.d.ts +0 -32
  18. package/dist/types/dev-error.d.ts.map +0 -1
  19. package/dist/types/error-codes.d.ts +0 -8
  20. package/dist/types/error-codes.d.ts.map +0 -1
  21. package/dist/types/error-entry.d.ts +0 -14
  22. package/dist/types/error-entry.d.ts.map +0 -1
  23. package/dist/types/error-handling.d.ts +0 -264
  24. package/dist/types/error-handling.d.ts.map +0 -1
  25. package/dist/types/h.d.ts +0 -96
  26. package/dist/types/h.d.ts.map +0 -1
  27. package/dist/types/index.d.ts +0 -13
  28. package/dist/types/index.d.ts.map +0 -1
  29. package/dist/types/lyt-error.d.ts +0 -8
  30. package/dist/types/lyt-error.d.ts.map +0 -1
  31. package/dist/types/plugin-entry.d.ts +0 -9
  32. package/dist/types/plugin-entry.d.ts.map +0 -1
  33. package/dist/types/plugin.d.ts +0 -119
  34. package/dist/types/plugin.d.ts.map +0 -1
  35. package/dist/types/shared-entry.d.ts +0 -8
  36. package/dist/types/shared-entry.d.ts.map +0 -1
  37. package/dist/types/warn.d.ts +0 -8
  38. package/dist/types/warn.d.ts.map +0 -1
  39. package/dist/types/web-component-entry.d.ts +0 -9
  40. package/dist/types/web-component-entry.d.ts.map +0 -1
  41. package/dist/types/web-component.d.ts +0 -251
  42. package/dist/types/web-component.d.ts.map +0 -1
  43. package/dist/web-component-entry.cjs +0 -2
  44. package/dist/web-component-entry.mjs +0 -2
@@ -1,251 +0,0 @@
1
- /**
2
- * Lyt.js Web Component 适配器
3
- *
4
- * 将 Lyt.js 组件转换为标准 Web Component(Custom Element),
5
- * 使其可以在 React、Vue、Angular 或任何其他框架中使用。
6
- *
7
- * 核心功能:
8
- * - defineCustomElement: 将 Lyt.js 组件注册为 Custom Element
9
- * - registerComponents: 批量注册多个组件
10
- * - unregisterElement: 注销 Custom Element
11
- * - isBrowser: 检测浏览器环境
12
- * - defineCustomElementFromSFC: 从 SFC 源码创建 Web Component
13
- *
14
- * 纯原生零依赖实现。
15
- */
16
- import { type ComponentOptions } from './index';
17
- /**
18
- * Custom Element 配置选项
19
- */
20
- export interface CustomElementOptions {
21
- /** 需要观察的属性列表(这些属性变化时触发 attributeChangedCallback) */
22
- observedAttributes?: string[];
23
- /** Shadow DOM 模式,默认 'open' */
24
- shadowMode?: 'open' | 'closed';
25
- /** 注入到 Shadow Root 的 CSS 样式 */
26
- styles?: string;
27
- /** 属性名映射(HTML 属性名 → 组件 prop 名) */
28
- propMappings?: Record<string, string>;
29
- /** 事件名映射(Lyt 事件名 → CustomEvent 事件名) */
30
- eventMappings?: Record<string, string>;
31
- /** 属性值转换器(属性名 → 转换函数) */
32
- attributeConverters?: Record<string, (value: string) => any>;
33
- }
34
- /**
35
- * 批量注册的组件描述
36
- */
37
- export interface ComponentRegistration {
38
- /** Custom Element 标签名(必须包含 '-') */
39
- tagName: string;
40
- /** Lyt.js 组件选项 */
41
- component: ComponentOptions;
42
- /** Custom Element 配置 */
43
- options?: CustomElementOptions;
44
- }
45
- /**
46
- * 检测是否在浏览器环境运行
47
- */
48
- export declare function isBrowser(): boolean;
49
- /**
50
- * 将 Lyt.js 组件定义为 Web Component(Custom Element)
51
- *
52
- * @param tagName - Custom Element 标签名(必须包含 '-')
53
- * @param componentOptions - Lyt.js 组件选项
54
- * @param options - Custom Element 配置选项
55
- *
56
- * @example
57
- * ```ts
58
- * import { defineCustomElement } from 'lyt'
59
- * import { MyCounter } from './MyCounter'
60
- *
61
- * defineCustomElement('lyt-counter', MyCounter, {
62
- * observedAttributes: ['initial-count', 'theme'],
63
- * shadowMode: 'open',
64
- * styles: ':host { display: block; padding: 16px; }'
65
- * })
66
- *
67
- * // 在任何框架中使用
68
- * // <lyt-counter initial-count="10" theme="dark"></lyt-counter>
69
- * ```
70
- */
71
- export declare function defineCustomElement(tagName: string, componentOptions: ComponentOptions, options?: CustomElementOptions): void;
72
- /**
73
- * 批量注册多个 Lyt.js 组件为 Web Component
74
- *
75
- * @param components - 组件注册描述数组
76
- *
77
- * @example
78
- * ```ts
79
- * registerComponents([
80
- * { tagName: 'lyt-counter', component: CounterComponent },
81
- * { tagName: 'lyt-button', component: ButtonComponent },
82
- * { tagName: 'lyt-input', component: InputComponent },
83
- * ])
84
- * ```
85
- */
86
- export declare function registerComponents(components: ComponentRegistration[]): void;
87
- /**
88
- * 注销 Custom Element
89
- *
90
- * 注意:Custom Elements 规范不支持直接注销已注册的元素。
91
- * 此函数将标签名加入黑名单,并尝试清理。
92
- * 实际效果取决于浏览器实现。
93
- *
94
- * @param tagName - 要注销的标签名
95
- */
96
- export declare function unregisterElement(tagName: string): void;
97
- /**
98
- * 从 SFC 源码创建 Web Component
99
- *
100
- * 解析 SFC 源码,提取 template、script、style 部分,
101
- * 然后创建并注册为 Custom Element。
102
- *
103
- * @param tagName - Custom Element 标签名
104
- * @param sfcSource - SFC 源码字符串
105
- * @param options - Custom Element 配置选项
106
- * @returns Promise<void>
107
- *
108
- * @example
109
- * ```ts
110
- * await defineCustomElementFromSFC('my-counter', `
111
- * <template>
112
- * <div>{{ count }}</div>
113
- * <button @click="count++">+</button>
114
- * </template>
115
- * <script>
116
- * export default {
117
- * state: () => ({ count: 0 })
118
- * }
119
- * </script>
120
- * <style>
121
- * :host { display: block; }
122
- * </style>
123
- * `)
124
- * ```
125
- */
126
- export declare function defineCustomElementFromSFC(tagName: string, sfcSource: string, options?: CustomElementOptions): Promise<void>;
127
- /**
128
- * 将 Props 定义转换为 observedAttributes 列表
129
- *
130
- * 自动将 camelCase prop 名转换为 kebab-case attribute 名,
131
- * 用于 Custom Element 的 static get observedAttributes()。
132
- *
133
- * @param props - Props 定义对象
134
- * @param exclude - 需要排除的 prop 名列表
135
- * @returns kebab-case attribute 名数组
136
- *
137
- * @example
138
- * ```ts
139
- * const props = {
140
- * initialCount: { type: Number, default: 0 },
141
- * theme: { type: String, default: 'light' },
142
- * isVisible: { type: Boolean },
143
- * }
144
- *
145
- * const attrs = propsToAttributes(props)
146
- * // ['initial-count', 'theme', 'is-visible']
147
- * ```
148
- */
149
- export declare function propsToAttributes(props: Record<string, unknown>, exclude?: string[]): string[];
150
- /**
151
- * 将 HTML attributes 转换为组件 Props
152
- *
153
- * 从 DOM 元素上读取 attribute 值,进行类型推断和转换,
154
- * 生成可直接传递给组件的 props 对象。
155
- *
156
- * @param attributes - NamedNodeMap(element.attributes)
157
- * @param propMappings - 属性名映射(attribute name -> prop name)
158
- * @param converters - 自定义属性值转换器
159
- * @returns Props 对象
160
- *
161
- * @example
162
- * ```ts
163
- * const el = document.querySelector('lyt-counter')
164
- * const props = attributesToProps(el.attributes, {
165
- * 'initial-count': 'initialCount',
166
- * })
167
- * // { initialCount: 10, theme: 'dark' }
168
- * ```
169
- */
170
- export declare function attributesToProps(attributes: NamedNodeMap, propMappings?: Record<string, string>, converters?: Record<string, (value: string) => any>): Record<string, unknown>;
171
- /**
172
- * 将 emits 定义转换为 Custom Event 配置
173
- *
174
- * 生成事件名映射和事件选项,用于 Custom Element 的事件转发。
175
- *
176
- * @param emits - emits 定义(数组或对象)
177
- * @returns 事件配置映射
178
- *
179
- * @example
180
- * ```ts
181
- * const events = eventsToCustomEvents(['click', 'change', 'update:modelValue'])
182
- * // {
183
- * // click: { name: 'click', options: { bubbles: true, composed: true } },
184
- * // change: { name: 'change', options: { bubbles: true, composed: true } },
185
- * // 'update:modelValue': { name: 'update:modelValue', options: { bubbles: true, composed: true } },
186
- * // }
187
- * ```
188
- */
189
- export declare function eventsToCustomEvents(emits: string[] | Record<string, unknown>): Record<string, {
190
- name: string;
191
- options: {
192
- bubbles: boolean;
193
- composed: boolean;
194
- cancelable: boolean;
195
- detail?: any;
196
- };
197
- }>;
198
- /**
199
- * 注入样式到 Shadow DOM
200
- *
201
- * 创建 <style> 元素并添加到 Shadow Root 中。
202
- * 支持追加模式和替换模式。
203
- *
204
- * @param styles - CSS 样式字符串
205
- * @param shadowRoot - Shadow Root 引用
206
- * @param options - 注入选项
207
- *
208
- * @example
209
- * ```ts
210
- * injectStyles(':host { display: block; }', element.shadowRoot)
211
- * injectStyles('.new-style { color: red; }', element.shadowRoot, { append: true })
212
- * ```
213
- */
214
- export declare function injectStyles(styles: string, shadowRoot: ShadowRoot, options?: {
215
- append?: boolean;
216
- id?: string;
217
- }): HTMLStyleElement | null;
218
- /**
219
- * 添加 scoped 标识到 CSS
220
- *
221
- * 为所有选择器添加 scopeId 属性选择器前缀,
222
- * 实现类似 Vue scoped CSS 的效果。
223
- *
224
- * @param css - 原始 CSS 字符串
225
- * @param scopeId - scope 标识符(不含方括号)
226
- * @returns 添加了 scoped 标识的 CSS
227
- *
228
- * @example
229
- * ```ts
230
- * const scoped = scopedCSS(
231
- * '.container { color: red; } .container .title { font-size: 16px; }',
232
- * 'data-v-abc123'
233
- * )
234
- * // '.container[data-v-abc123] { color: red; } .container[data-v-abc123] .title[data-v-abc123] { font-size: 16px; }'
235
- * ```
236
- */
237
- export declare function scopedCSS(css: string, scopeId: string): string;
238
- /**
239
- * 生成唯一的 scope ID
240
- *
241
- * @param prefix - 前缀(默认 'data-v')
242
- * @returns scope ID 字符串
243
- *
244
- * @example
245
- * ```ts
246
- * const scopeId = generateScopeId()
247
- * // 'data-v-a1b2c3d4'
248
- * ```
249
- */
250
- export declare function generateScopeId(prefix?: string): string;
251
- //# sourceMappingURL=web-component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-component.d.ts","sourceRoot":"","sources":["../../src/web-component.ts"],"names":[],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- "use strict";var se=Object.create;var T=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)T(e,n,{get:t[n],enumerable:!0})},w=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ae(t))!ue.call(e,a)&&a!==n&&T(e,a,{get:()=>t[a],enumerable:!(l=le(t,a))||l.enumerable});return e},x=(e,t,n)=>(w(e,t,"default"),n&&w(n,t,"default")),F=(e,t,n)=>(n=e!=null?se(ce(e)):{},w(t||!e||!e.__esModule?T(n,"default",{value:e,enumerable:!0}):n,e)),de=e=>w(T({},"__esModule",{value:!0}),e);var _e={};M(_e,{attributesToProps:()=>ee,defineCustomElement:()=>S,defineCustomElementFromSFC:()=>G,eventsToCustomEvents:()=>te,generateScopeId:()=>re,injectStyles:()=>ne,isBrowser:()=>O,propsToAttributes:()=>Q,registerComponents:()=>Z,scopedCSS:()=>oe,unregisterElement:()=>J});module.exports=de(_e);var N={};M(N,{Fragment:()=>j.Fragment,ShapeFlags:()=>D,createApp:()=>K,h:()=>_});var E=require("@lytjs/common"),j=require("@lytjs/vdom");var D=(u=>(u[u.ELEMENT=1]="ELEMENT",u[u.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",u[u.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",u[u.TEXT_CHILDREN=8]="TEXT_CHILDREN",u[u.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",u[u.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",u))(D||{});function pe(e,t){if(t!=null)if((0,E.isStringOrNumber)(t))e.children=String(t),e.shapeFlag|=8;else if((0,E.isArray)(t)){let n=[];for(let l=0;l<t.length;l++){let a=t[l];if(!(a==null||typeof a=="boolean"))if((0,E.isArray)(a))for(let y=0;y<a.length;y++){let u=a[y];u!=null&&typeof u!="boolean"&&n.push((0,E.isVNode)(u)?u:V(String(u)))}else(0,E.isVNode)(a)?n.push(a):n.push(V(String(a)))}e.children=n,e.shapeFlag|=16}else typeof t=="object"&&(e.children=t,e.shapeFlag|=32)}function V(e,t=null,n=null){var p,h;let l=0;typeof e=="string"?l=1:e===j.Fragment?l=0:typeof e=="function"?l=2:typeof e=="object"&&e!==null&&(e.setup||e.__vccOpts||e.render)&&(l=4);let a=(p=t==null?void 0:t.key)!=null?p:null,y=(h=t==null?void 0:t.ref)!=null?h:null,u=t;if(t){let{key:b,ref:o,...r}=t;u=r}let g={type:e,props:u,children:null,key:a,ref:y,shapeFlag:l,el:null,component:null};return n!=null&&pe(g,n),g}function _(e,t,n){return V(e,t||null,n||null)}var I=require("@lytjs/common");function H(e){return Object.create(e||null)}function B(e){return e!==null&&typeof e=="object"&&typeof e.install=="function"}function W(e){return typeof e=="function"}function U(e,t,...n){if(B(t)){let l=t.onBeforeInstall?t.onBeforeInstall(e,...n):void 0;if((0,I.isPromise)(l))return l.then(()=>{let a=t.install(e,...n);if((0,I.isPromise)(a))return a.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)});{let a=t.install(e,...n);if((0,I.isPromise)(a))return a.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 $(e,t){if(B(t)){if(typeof t.uninstall=="function")return t.uninstall(e)}else W(t)}var L=require("@lytjs/reactivity"),z=require("@lytjs/compiler"),v=require("@lytjs/component"),q=require("@lytjs/renderer"),fe=100,P=new Map;function me(e){let t=P.get(e);if(t)return P.delete(e),P.set(e,t),t;let{code:n}=(0,z.compile)(e);if(t=new Function("h","_ctx",`return ${n}`),P.size>=fe){let l=P.keys().next().value;l!==void 0&&P.delete(l)}return P.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=(l,a)=>n(l)}if(e.computed){let n={};for(let l of Object.keys(e.computed)){let a=e.computed[l];typeof a=="function"?n[l]={get:a}:n[l]=a}t.computed=n}if(typeof e.init=="function"){let n=e.init;t.init=function(l,a){return n.call(this,l)}}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[l,a]of Object.entries(t))a&&n.push(l);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,l){e.addEventListener(t,n,l)},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 K(e,t){let n=new Set,l={},a={},y=H(),u={},g={},p=null,h=null,b=null,o=null,r=!1,i=ye(typeof e=="function"?{render:e}:e),d=(0,v.defineComponent)(i),s={config:u,globalProperties:g,get _instance(){return p},mount(f){if(r)return s;let m;if(typeof f=="string"){let A=document.querySelector(f);if(!A)throw new Error(`[Lyt] \u6302\u8F7D\u76EE\u6807 "${f}" \u672A\u627E\u5230`);m=A}else m=f;o=m;let C=ge();h=(0,q.createRenderer)(C),p=(0,v.createComponentInstance)(d),(0,v.setupComponent)(p,t||{},null);let k=p.type;if(!k.render&&k.template){let A=me(k.template);k.render=(R,ie)=>A(R,ie.renderProxy)}return(0,v.mountComponent)(p,_),p.subTree&&h.mount(p.subTree,m),b=(0,L.effect)(()=>{if(!(!p||!p.isMounted||!h)&&((0,v.updateComponent)(p,_),p.subTree&&o)){let A=o.firstChild,R=p.subTree;for(;o.firstChild;)o.removeChild(o.firstChild);h.mount(R,o)}},{lazy:!0}),r=!0,s},unmount(){if(r){if(b&&((0,L.stop)(b),b=null),p&&(0,v.unmountComponent)(p),o)for(;o.firstChild;)o.removeChild(o.firstChild);p=null,h=null,o=null,r=!1}},use(f,...m){if(n.has(f))return s;n.add(f);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:u,globalProperties:g},f,...m);return C instanceof Promise?C.then(()=>s):s},unuse(f){if(!n.has(f))return s;n.delete(f);let m=$({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:u,globalProperties:g},f);return m instanceof Promise?m.then(()=>s):s},isInstalled(f){return n.has(f)},provide(f,m){return y[f]=m,s},inject(f,m){let C=y[f];return C!==void 0?C:m},component(f,m){return m?(l[f]=m,s):l[f]},directive(f,m){return m?(a[f]=m,s):a[f]}};return s}x(N,require("@lytjs/common"));function O(){return typeof globalThis.window!="undefined"&&typeof globalThis.document!="undefined"&&typeof globalThis.HTMLElement!="undefined"&&typeof globalThis.customElements!="undefined"}function X(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function he(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Y(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 be(e,t){return t&&t[e]?t[e]:X(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 l of Object.keys(n.methods))if(l.startsWith("on")&&l.length>2){let a=l.charAt(2).toLowerCase()+l.slice(3);t.push(a)}}return t}function ve(e,t={}){let{shadowMode:n="open",styles:l="",propMappings:a,eventMappings:y={},attributeConverters:u={}}=t,g=t.observedAttributes||[],p=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._originalDescriptors=new Map;this._compiledTemplate=null;this._updateScheduled=!1}static get observedAttributes(){return g}connectedCallback(){if(!this._connected){if(this._connected=!0,this._shadowRoot=this.attachShadow({mode:n}),l){let o=document.createElement("style");o.textContent=l,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._originalDescriptors.clear(),this._compiledTemplate=null,this._instance=null,this._container&&(this._container.innerHTML="")}}attributeChangedCallback(o,r,c){r!==c&&this._connected&&(this._syncAttributesToProps(),this._updateComponent())}_syncAttributesToProps(){let o={};for(let r of g)if(this.hasAttribute(r)){let c=this.getAttribute(r),i=be(r,a);u[r]?o[i]=u[r](c):o[i]=Y(c)}if(e.props){for(let[r,c]of Object.entries(e.props))if(o[r]===void 0){let i=c;i&&typeof i=="object"&&"default"in i?o[r]=typeof i.default=="function"?i.default():i.default:i==null}}this._props=o}async _mountComponent(){let o=e.render?e.render:e.template?await this._compileTemplate(e.template):null;if(!o)return;let r=this._createComponentContext(),c=o?o.call(r,_,r):null;c&&this._container&&this._renderVNode(c,this._container),this._setupReactiveUpdates(r,o)}async _compileTemplate(o){try{let r=await import("@lytjs/compiler"),{compile:c}=r,{code:i}=c(o);return new Function("h","_ctx",`return ${i}`)}catch(r){return null}}_createComponentContext(){let o=e.state?typeof e.state=="function"?e.state():{...e.state}:{},r=e.computed||{},c=e.methods||{},i={...this._props,...o};for(let[d,s]of Object.entries(r))typeof s=="function"?Object.defineProperty(i,d,{get:s.bind(i),enumerable:!0}):s&&typeof s=="object"&&"get"in s&&Object.defineProperty(i,d,{get:s.get.bind(i),enumerable:!0});for(let[d,s]of Object.entries(c))typeof s=="function"&&(i[d]=s.bind(i));return i.emit=(d,...s)=>{let f=y[d]||d,m=new CustomEvent(f,{detail:s.length===1?s[0]:s,bubbles:!0,composed:!0});this.dispatchEvent(m)},i.$el=this._container,i.$attrs={...this._props},i.$slots=this._getSlotContent(),i}_setupReactiveUpdates(o,r){try{import("@lytjs/reactivity").then(c=>{let{effect:i,stop:d}=c,s=i(()=>{if(!this._connected||!this._container||!r)return;let m=r.call(o,_,o);m&&(this._container.innerHTML="",this._renderVNode(m,this._container))},{lazy:!0}),f=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let m of f){let C=o[m],k=Object.getOwnPropertyDescriptor(o,m);this._originalDescriptors.set(m,k),Object.defineProperty(o,m,{get(){return C},set(A){C=A;try{s()}catch(R){}},enumerable:!0})}this._effectCleanup=()=>{try{d(s)}catch(m){}}}).catch(()=>{this._setupReactiveUpdatesFallback(o,r)})}catch(c){this._setupReactiveUpdatesFallback(o,r)}}_setupReactiveUpdatesFallback(o,r){let c=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let i of c){let s=o[i],f=Object.getOwnPropertyDescriptor(o,i);this._originalDescriptors.set(i,f);let m=this;Object.defineProperty(o,i,{get(){return s},set(C){s=C,m._scheduleUpdate(o,r)},enumerable:!0})}}_scheduleUpdate(o,r){this._updateScheduled||(this._updateScheduled=!0,Promise.resolve().then(()=>{if(this._updateScheduled=!1,!this._connected||!this._container||!r)return;let c=r.call(o,_,o);c&&(this._container.innerHTML="",this._renderVNode(c,this._container))}))}async _updateComponent(){if(!this._container)return;let o=e.render||null;if(!o&&e.template&&(this._compiledTemplate&&this._compiledTemplate.template===e.template?o=this._compiledTemplate.render:(o=await this._compileTemplate(e.template),o&&(this._compiledTemplate={template:e.template,render:o}))),!o)return;let r=this._createComponentContext(),c=o?o.call(r,_,r):null;this._container.innerHTML="",c&&this._renderVNode(c,this._container)}_renderVNode(o,r){let c=this._vNodeToElement(o);c&&r.appendChild(c)}_vNodeToElement(o){if(!o)return null;if(typeof o.type=="symbol"){let r=document.createDocumentFragment();if(Array.isArray(o.children))for(let c of o.children){let i=this._vNodeToElement(c);i&&r.appendChild(i)}return r}if(typeof o.children=="string")return document.createTextNode(o.children);if(typeof o.type=="string"){let r=document.createElement(o.type);if(o.props)for(let[c,i]of Object.entries(o.props))if(c==="style"&&typeof i=="object")for(let[d,s]of Object.entries(i))r.style[d]=s;else if(c==="class"){if(typeof i=="string")r.className=i;else if(typeof i=="object"){let d=[];for(let[s,f]of Object.entries(i))f&&d.push(s);r.className=d.join(" ")}}else if(c.startsWith("on")&&typeof i=="function"){let d=c.slice(2).toLowerCase();r.addEventListener(d,i),this._eventCleanups.push(()=>{r.removeEventListener(d,i)})}else c==="ref"&&typeof i=="function"?i(r):r.setAttribute(c,String(i));if(Array.isArray(o.children))for(let c of o.children){let i=this._vNodeToElement(c);i&&r.appendChild(i)}else typeof o.children=="string"&&(r.textContent=o.children);return r}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 c of o){let i=c.getAttribute("slot")||"default",d=document.createElement("slot");i!=="default"&&d.setAttribute("name",i),this._container.appendChild(d)}let r=document.createElement("slot");this._container.appendChild(r)}_getSlotContent(){var i;let o={},r=this.querySelectorAll("[slot]");for(let d of r){let s=d.getAttribute("slot")||"default";o[s]||(o[s]=[]),o[s].push(d.cloneNode(!0))}let c=[];for(let d of Array.from(this.childNodes))(i=d.hasAttribute)!=null&&i.call(d,"slot")||c.push(d.cloneNode(!0));return c.length>0&&(o.default=c),o}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(!O())return;let l=ve(t,n);customElements.define(e,l)}function Z(e){for(let{tagName:t,component:n,options:l}of e)S(t,n,l)}function J(e){if(O())try{let t=customElements;t.__unregister&&t.__unregister(e)}catch(t){}}async function G(e,t,n){let l=t.match(/<template>([\s\S]*?)<\/template>/),a=t.match(/<script[^>]*>([\s\S]*?)<\/script>/),y=/<style[^>]*>([\s\S]*?)<\/style>/g,u=[],g;for(;(g=y.exec(t))!==null;)u.push(g);let p=(n==null?void 0:n.styles)||"";for(let r of u)p+=r[1]+`
2
- `;let h=l?l[1].trim():void 0,b={};if(a){let r=a[1].trim();if(r.match(/export\s+default\s*(\{[\s\S]*\}|\([\s\S]*\)[\s\S]*?\))/))try{let i={},d={exports:i};new Function("module","exports",`"use strict"; ${r.replace(/export\s+default\s*/,"module.exports =")}`)(d,i),b=d.exports||i}catch(i){}}let o={...n,styles:p};h&&!b.template&&!b.render&&(b.template=h),S(e,b,o)}function Q(e,t=[]){return Object.keys(e).filter(n=>!t.includes(n)).map(he)}function ee(e,t,n){let l={};for(let a=0;a<e.length;a++){let y=e[a],u=y.name,g=y.value;if(u.startsWith("on"))continue;let p=(t==null?void 0:t[u])||X(u);n!=null&&n[u]?l[p]=n[u](g):l[p]=Y(g)}return l}function te(e){let t=Array.isArray(e)?e:Object.keys(e),n={};for(let l of t)n[l]={name:l,options:{bubbles:!0,composed:!0,cancelable:!0}};return n}function ne(e,t,n={}){if(!e||!t)return null;let{append:l=!1,id:a}=n;if(a){let u=t.getElementById(a);if(u)return u.textContent=e,u}let y=document.createElement("style");if(a&&(y.id=a),y.textContent=e,l)t.appendChild(y);else{let u=t.querySelector("div");u?t.insertBefore(y,u):t.insertBefore(y,t.firstChild)}return y}function oe(e,t){let n=`[${t}]`;return e.replace(/([^{}@/][^{}]*?)(\s*\{[^{}]*\})/g,(l,a,y)=>a.trim().startsWith("@")||a.includes(":host")?l:a.split(",").map(g=>{let p=g.trim();if(!p||p.startsWith("@"))return g;let h=p.indexOf("::"),b=h!==-1?p.slice(h):"",o=h!==-1?p.slice(0,h):p,r=o.indexOf(":"),c=r!==-1?o.slice(r):"",d=(r!==-1?o.slice(0,r):o).split(/\s+/).filter(Boolean),s=d[d.length-1];return s&&(d[d.length-1]=s+n),d.join(" ")+c+b}).join(", ")+y)}function re(e="data-v"){let t="abcdef0123456789",n="";for(let l=0;l<8;l++)n+=t[Math.floor(Math.random()*t.length)];return`${e}-${n}`}
@@ -1,2 +0,0 @@
1
- var O=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var Y=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},L=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of K(t))!X.call(e,a)&&a!==n&&O(e,a,{get:()=>t[a],enumerable:!(l=q(t,a))||l.enumerable});return e},N=(e,t,n)=>(L(e,t,"default"),n&&L(n,t,"default"));var A={};Y(A,{Fragment:()=>R,ShapeFlags:()=>w,createApp:()=>W,h:()=>v});import{isStringOrNumber as Z,isArray as S,isVNode as V}from"@lytjs/common";import{Fragment as R}from"@lytjs/vdom";var w=(u=>(u[u.ELEMENT=1]="ELEMENT",u[u.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",u[u.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",u[u.TEXT_CHILDREN=8]="TEXT_CHILDREN",u[u.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",u[u.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",u))(w||{});function J(e,t){if(t!=null)if(Z(t))e.children=String(t),e.shapeFlag|=8;else if(S(t)){let n=[];for(let l=0;l<t.length;l++){let a=t[l];if(!(a==null||typeof a=="boolean"))if(S(a))for(let y=0;y<a.length;y++){let u=a[y];u!=null&&typeof u!="boolean"&&n.push(V(u)?u:x(String(u)))}else V(a)?n.push(a):n.push(x(String(a)))}e.children=n,e.shapeFlag|=16}else typeof t=="object"&&(e.children=t,e.shapeFlag|=32)}function x(e,t=null,n=null){var p,h;let l=0;typeof e=="string"?l=1:e===R?l=0:typeof e=="function"?l=2:typeof e=="object"&&e!==null&&(e.setup||e.__vccOpts||e.render)&&(l=4);let a=(p=t==null?void 0:t.key)!=null?p:null,y=(h=t==null?void 0:t.ref)!=null?h:null,u=t;if(t){let{key:b,ref:o,...r}=t;u=r}let g={type:e,props:u,children:null,key:a,ref:y,shapeFlag:l,el:null,component:null};return n!=null&&J(g,n),g}function v(e,t,n){return x(e,t||null,n||null)}import{isPromise as T}from"@lytjs/common";function D(e){return Object.create(e||null)}function M(e){return e!==null&&typeof e=="object"&&typeof e.install=="function"}function F(e){return typeof e=="function"}function H(e,t,...n){if(M(t)){let l=t.onBeforeInstall?t.onBeforeInstall(e,...n):void 0;if(T(l))return l.then(()=>{let a=t.install(e,...n);if(T(a))return a.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)});{let a=t.install(e,...n);if(T(a))return a.then(()=>{if(t.onInstalled)return t.onInstalled(e,...n)});if(t.onInstalled)return t.onInstalled(e,...n)}}else if(F(t))return t(e,...n)}function B(e,t){if(M(t)){if(typeof t.uninstall=="function")return t.uninstall(e)}else F(t)}import{effect as G,stop as Q}from"@lytjs/reactivity";import{compile as ee}from"@lytjs/compiler";import{defineComponent as te,createComponentInstance as ne,setupComponent as oe,mountComponent as re,updateComponent as ie,unmountComponent as se}from"@lytjs/component";import{createRenderer as le}from"@lytjs/renderer";var ae=100,E=new Map;function ce(e){let t=E.get(e);if(t)return E.delete(e),E.set(e,t),t;let{code:n}=ee(e);if(t=new Function("h","_ctx",`return ${n}`),E.size>=ae){let l=E.keys().next().value;l!==void 0&&E.delete(l)}return E.set(e,t),t}function ue(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=(l,a)=>n(l)}if(e.computed){let n={};for(let l of Object.keys(e.computed)){let a=e.computed[l];typeof a=="function"?n[l]={get:a}:n[l]=a}t.computed=n}if(typeof e.init=="function"){let n=e.init;t.init=function(l,a){return n.call(this,l)}}return t}function de(){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[l,a]of Object.entries(t))a&&n.push(l);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,l){e.addEventListener(t,n,l)},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 W(e,t){let n=new Set,l={},a={},y=D(),u={},g={},p=null,h=null,b=null,o=null,r=!1,i=ue(typeof e=="function"?{render:e}:e),d=te(i),s={config:u,globalProperties:g,get _instance(){return p},mount(f){if(r)return s;let m;if(typeof f=="string"){let _=document.querySelector(f);if(!_)throw new Error(`[Lyt] \u6302\u8F7D\u76EE\u6807 "${f}" \u672A\u627E\u5230`);m=_}else m=f;o=m;let C=de();h=le(C),p=ne(d),oe(p,t||{},null);let P=p.type;if(!P.render&&P.template){let _=ce(P.template);P.render=(k,z)=>_(k,z.renderProxy)}return re(p,v),p.subTree&&h.mount(p.subTree,m),b=G(()=>{if(!(!p||!p.isMounted||!h)&&(ie(p,v),p.subTree&&o)){let _=o.firstChild,k=p.subTree;for(;o.firstChild;)o.removeChild(o.firstChild);h.mount(k,o)}},{lazy:!0}),r=!0,s},unmount(){if(r){if(b&&(Q(b),b=null),p&&se(p),o)for(;o.firstChild;)o.removeChild(o.firstChild);p=null,h=null,o=null,r=!1}},use(f,...m){if(n.has(f))return s;n.add(f);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:u,globalProperties:g},f,...m);return C instanceof Promise?C.then(()=>s):s},unuse(f){if(!n.has(f))return s;n.delete(f);let m=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:u,globalProperties:g},f);return m instanceof Promise?m.then(()=>s):s},isInstalled(f){return n.has(f)},provide(f,m){return y[f]=m,s},inject(f,m){let C=y[f];return C!==void 0?C:m},component(f,m){return m?(l[f]=m,s):l[f]},directive(f,m){return m?(a[f]=m,s):a[f]}};return s}N(A,qe);import*as qe from"@lytjs/common";function j(){return typeof globalThis.window!="undefined"&&typeof globalThis.document!="undefined"&&typeof globalThis.HTMLElement!="undefined"&&typeof globalThis.customElements!="undefined"}function U(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function pe(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function $(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]:U(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 l of Object.keys(n.methods))if(l.startsWith("on")&&l.length>2){let a=l.charAt(2).toLowerCase()+l.slice(3);t.push(a)}}return t}function ye(e,t={}){let{shadowMode:n="open",styles:l="",propMappings:a,eventMappings:y={},attributeConverters:u={}}=t,g=t.observedAttributes||[],p=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._originalDescriptors=new Map;this._compiledTemplate=null;this._updateScheduled=!1}static get observedAttributes(){return g}connectedCallback(){if(!this._connected){if(this._connected=!0,this._shadowRoot=this.attachShadow({mode:n}),l){let o=document.createElement("style");o.textContent=l,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._originalDescriptors.clear(),this._compiledTemplate=null,this._instance=null,this._container&&(this._container.innerHTML="")}}attributeChangedCallback(o,r,c){r!==c&&this._connected&&(this._syncAttributesToProps(),this._updateComponent())}_syncAttributesToProps(){let o={};for(let r of g)if(this.hasAttribute(r)){let c=this.getAttribute(r),i=fe(r,a);u[r]?o[i]=u[r](c):o[i]=$(c)}if(e.props){for(let[r,c]of Object.entries(e.props))if(o[r]===void 0){let i=c;i&&typeof i=="object"&&"default"in i?o[r]=typeof i.default=="function"?i.default():i.default:i==null}}this._props=o}async _mountComponent(){let o=e.render?e.render:e.template?await this._compileTemplate(e.template):null;if(!o)return;let r=this._createComponentContext(),c=o?o.call(r,v,r):null;c&&this._container&&this._renderVNode(c,this._container),this._setupReactiveUpdates(r,o)}async _compileTemplate(o){try{let r=await import("@lytjs/compiler"),{compile:c}=r,{code:i}=c(o);return new Function("h","_ctx",`return ${i}`)}catch(r){return null}}_createComponentContext(){let o=e.state?typeof e.state=="function"?e.state():{...e.state}:{},r=e.computed||{},c=e.methods||{},i={...this._props,...o};for(let[d,s]of Object.entries(r))typeof s=="function"?Object.defineProperty(i,d,{get:s.bind(i),enumerable:!0}):s&&typeof s=="object"&&"get"in s&&Object.defineProperty(i,d,{get:s.get.bind(i),enumerable:!0});for(let[d,s]of Object.entries(c))typeof s=="function"&&(i[d]=s.bind(i));return i.emit=(d,...s)=>{let f=y[d]||d,m=new CustomEvent(f,{detail:s.length===1?s[0]:s,bubbles:!0,composed:!0});this.dispatchEvent(m)},i.$el=this._container,i.$attrs={...this._props},i.$slots=this._getSlotContent(),i}_setupReactiveUpdates(o,r){try{import("@lytjs/reactivity").then(c=>{let{effect:i,stop:d}=c,s=i(()=>{if(!this._connected||!this._container||!r)return;let m=r.call(o,v,o);m&&(this._container.innerHTML="",this._renderVNode(m,this._container))},{lazy:!0}),f=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let m of f){let C=o[m],P=Object.getOwnPropertyDescriptor(o,m);this._originalDescriptors.set(m,P),Object.defineProperty(o,m,{get(){return C},set(_){C=_;try{s()}catch(k){}},enumerable:!0})}this._effectCleanup=()=>{try{d(s)}catch(m){}}}).catch(()=>{this._setupReactiveUpdatesFallback(o,r)})}catch(c){this._setupReactiveUpdatesFallback(o,r)}}_setupReactiveUpdatesFallback(o,r){let c=e.state?typeof e.state=="function"?Object.keys(e.state()):Object.keys(e.state):[];for(let i of c){let s=o[i],f=Object.getOwnPropertyDescriptor(o,i);this._originalDescriptors.set(i,f);let m=this;Object.defineProperty(o,i,{get(){return s},set(C){s=C,m._scheduleUpdate(o,r)},enumerable:!0})}}_scheduleUpdate(o,r){this._updateScheduled||(this._updateScheduled=!0,Promise.resolve().then(()=>{if(this._updateScheduled=!1,!this._connected||!this._container||!r)return;let c=r.call(o,v,o);c&&(this._container.innerHTML="",this._renderVNode(c,this._container))}))}async _updateComponent(){if(!this._container)return;let o=e.render||null;if(!o&&e.template&&(this._compiledTemplate&&this._compiledTemplate.template===e.template?o=this._compiledTemplate.render:(o=await this._compileTemplate(e.template),o&&(this._compiledTemplate={template:e.template,render:o}))),!o)return;let r=this._createComponentContext(),c=o?o.call(r,v,r):null;this._container.innerHTML="",c&&this._renderVNode(c,this._container)}_renderVNode(o,r){let c=this._vNodeToElement(o);c&&r.appendChild(c)}_vNodeToElement(o){if(!o)return null;if(typeof o.type=="symbol"){let r=document.createDocumentFragment();if(Array.isArray(o.children))for(let c of o.children){let i=this._vNodeToElement(c);i&&r.appendChild(i)}return r}if(typeof o.children=="string")return document.createTextNode(o.children);if(typeof o.type=="string"){let r=document.createElement(o.type);if(o.props)for(let[c,i]of Object.entries(o.props))if(c==="style"&&typeof i=="object")for(let[d,s]of Object.entries(i))r.style[d]=s;else if(c==="class"){if(typeof i=="string")r.className=i;else if(typeof i=="object"){let d=[];for(let[s,f]of Object.entries(i))f&&d.push(s);r.className=d.join(" ")}}else if(c.startsWith("on")&&typeof i=="function"){let d=c.slice(2).toLowerCase();r.addEventListener(d,i),this._eventCleanups.push(()=>{r.removeEventListener(d,i)})}else c==="ref"&&typeof i=="function"?i(r):r.setAttribute(c,String(i));if(Array.isArray(o.children))for(let c of o.children){let i=this._vNodeToElement(c);i&&r.appendChild(i)}else typeof o.children=="string"&&(r.textContent=o.children);return r}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 c of o){let i=c.getAttribute("slot")||"default",d=document.createElement("slot");i!=="default"&&d.setAttribute("name",i),this._container.appendChild(d)}let r=document.createElement("slot");this._container.appendChild(r)}_getSlotContent(){var i;let o={},r=this.querySelectorAll("[slot]");for(let d of r){let s=d.getAttribute("slot")||"default";o[s]||(o[s]=[]),o[s].push(d.cloneNode(!0))}let c=[];for(let d of Array.from(this.childNodes))(i=d.hasAttribute)!=null&&i.call(d,"slot")||c.push(d.cloneNode(!0));return c.length>0&&(o.default=c),o}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(!j())return;let l=ye(t,n);customElements.define(e,l)}function ge(e){for(let{tagName:t,component:n,options:l}of e)I(t,n,l)}function he(e){if(j())try{let t=customElements;t.__unregister&&t.__unregister(e)}catch(t){}}async function be(e,t,n){let l=t.match(/<template>([\s\S]*?)<\/template>/),a=t.match(/<script[^>]*>([\s\S]*?)<\/script>/),y=/<style[^>]*>([\s\S]*?)<\/style>/g,u=[],g;for(;(g=y.exec(t))!==null;)u.push(g);let p=(n==null?void 0:n.styles)||"";for(let r of u)p+=r[1]+`
2
- `;let h=l?l[1].trim():void 0,b={};if(a){let r=a[1].trim();if(r.match(/export\s+default\s*(\{[\s\S]*\}|\([\s\S]*\)[\s\S]*?\))/))try{let i={},d={exports:i};new Function("module","exports",`"use strict"; ${r.replace(/export\s+default\s*/,"module.exports =")}`)(d,i),b=d.exports||i}catch(i){}}let o={...n,styles:p};h&&!b.template&&!b.render&&(b.template=h),I(e,b,o)}function Ce(e,t=[]){return Object.keys(e).filter(n=>!t.includes(n)).map(pe)}function ve(e,t,n){let l={};for(let a=0;a<e.length;a++){let y=e[a],u=y.name,g=y.value;if(u.startsWith("on"))continue;let p=(t==null?void 0:t[u])||U(u);n!=null&&n[u]?l[p]=n[u](g):l[p]=$(g)}return l}function _e(e){let t=Array.isArray(e)?e:Object.keys(e),n={};for(let l of t)n[l]={name:l,options:{bubbles:!0,composed:!0,cancelable:!0}};return n}function Ee(e,t,n={}){if(!e||!t)return null;let{append:l=!1,id:a}=n;if(a){let u=t.getElementById(a);if(u)return u.textContent=e,u}let y=document.createElement("style");if(a&&(y.id=a),y.textContent=e,l)t.appendChild(y);else{let u=t.querySelector("div");u?t.insertBefore(y,u):t.insertBefore(y,t.firstChild)}return y}function Ae(e,t){let n=`[${t}]`;return e.replace(/([^{}@/][^{}]*?)(\s*\{[^{}]*\})/g,(l,a,y)=>a.trim().startsWith("@")||a.includes(":host")?l:a.split(",").map(g=>{let p=g.trim();if(!p||p.startsWith("@"))return g;let h=p.indexOf("::"),b=h!==-1?p.slice(h):"",o=h!==-1?p.slice(0,h):p,r=o.indexOf(":"),c=r!==-1?o.slice(r):"",d=(r!==-1?o.slice(0,r):o).split(/\s+/).filter(Boolean),s=d[d.length-1];return s&&(d[d.length-1]=s+n),d.join(" ")+c+b}).join(", ")+y)}function Pe(e="data-v"){let t="abcdef0123456789",n="";for(let l=0;l<8;l++)n+=t[Math.floor(Math.random()*t.length)];return`${e}-${n}`}export{ve as attributesToProps,I as defineCustomElement,be as defineCustomElementFromSFC,_e as eventsToCustomEvents,Pe as generateScopeId,Ee as injectStyles,j as isBrowser,Ce as propsToAttributes,ge as registerComponents,Ae as scopedCSS,he as unregisterElement};