solely 0.5.8 → 0.6.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 (145) hide show
  1. package/README.md +7 -6
  2. package/dist/compiler/ir/buildIR.cjs +1 -1
  3. package/dist/compiler/ir/buildIR.js +1 -1
  4. package/dist/compiler/parser/parser.cjs +1 -1
  5. package/dist/compiler/parser/parser.js +1 -1
  6. package/dist/components/commands/drawer/index.cjs +1 -1
  7. package/dist/components/commands/drawer/index.js +1 -1
  8. package/dist/components/commands/drawer/style.css.cjs +1 -1
  9. package/dist/components/commands/drawer/style.css.js +1 -1
  10. package/dist/components/commands/message/index.cjs +1 -1
  11. package/dist/components/commands/message/index.js +1 -1
  12. package/dist/components/commands/modal/index.cjs +1 -1
  13. package/dist/components/commands/modal/index.js +1 -1
  14. package/dist/components/commands/modal/style.css.cjs +1 -1
  15. package/dist/components/commands/modal/style.css.js +1 -1
  16. package/dist/components/commands/popconfirm/index.cjs +1 -1
  17. package/dist/components/commands/popconfirm/index.js +1 -1
  18. package/dist/components/commands/tooltip/index.cjs +1 -1
  19. package/dist/components/commands/tooltip/index.js +1 -1
  20. package/dist/components/commands/utils.cjs +1 -1
  21. package/dist/components/commands/utils.js +1 -1
  22. package/dist/components/elements/alert/index.cjs +1 -1
  23. package/dist/components/elements/alert/index.html.cjs +1 -1
  24. package/dist/components/elements/alert/index.html.js +1 -1
  25. package/dist/components/elements/alert/index.js +1 -1
  26. package/dist/components/elements/backtop/index.cjs +1 -1
  27. package/dist/components/elements/backtop/index.html.cjs +1 -1
  28. package/dist/components/elements/backtop/index.html.js +1 -1
  29. package/dist/components/elements/backtop/index.js +1 -1
  30. package/dist/components/elements/breadcrumb/index.cjs +1 -1
  31. package/dist/components/elements/breadcrumb/index.html.cjs +1 -1
  32. package/dist/components/elements/breadcrumb/index.html.js +1 -1
  33. package/dist/components/elements/breadcrumb/index.js +1 -1
  34. package/dist/components/elements/button/index.cjs +1 -1
  35. package/dist/components/elements/button/index.html.cjs +1 -1
  36. package/dist/components/elements/button/index.html.js +1 -1
  37. package/dist/components/elements/button/index.js +1 -1
  38. package/dist/components/elements/card/index.html.cjs +1 -1
  39. package/dist/components/elements/card/index.html.js +1 -1
  40. package/dist/components/elements/checkbox/index.cjs +1 -1
  41. package/dist/components/elements/checkbox/index.html.cjs +1 -1
  42. package/dist/components/elements/checkbox/index.html.js +1 -1
  43. package/dist/components/elements/checkbox/index.js +1 -1
  44. package/dist/components/elements/coordinate-input/index.html.cjs +1 -1
  45. package/dist/components/elements/coordinate-input/index.html.js +1 -1
  46. package/dist/components/elements/coordinate-input/style.css.cjs +1 -1
  47. package/dist/components/elements/coordinate-input/style.css.js +1 -1
  48. package/dist/components/elements/fab/index.cjs +1 -1
  49. package/dist/components/elements/fab/index.html.cjs +1 -1
  50. package/dist/components/elements/fab/index.html.js +1 -1
  51. package/dist/components/elements/fab/index.js +1 -1
  52. package/dist/components/elements/icon/index.cjs +1 -1
  53. package/dist/components/elements/icon/index.d.ts +8 -0
  54. package/dist/components/elements/icon/index.html.cjs +1 -1
  55. package/dist/components/elements/icon/index.html.js +1 -1
  56. package/dist/components/elements/icon/index.js +1 -1
  57. package/dist/components/elements/input/index.cjs +1 -1
  58. package/dist/components/elements/input/index.html.cjs +1 -1
  59. package/dist/components/elements/input/index.html.js +1 -1
  60. package/dist/components/elements/input/index.js +1 -1
  61. package/dist/components/elements/not-found/index.html.cjs +1 -1
  62. package/dist/components/elements/not-found/index.html.js +1 -1
  63. package/dist/components/elements/not-found/style.css.cjs +1 -1
  64. package/dist/components/elements/not-found/style.css.js +1 -1
  65. package/dist/components/elements/pagination/index.html.cjs +1 -1
  66. package/dist/components/elements/pagination/index.html.js +1 -1
  67. package/dist/components/elements/pagination/style.css.cjs +1 -1
  68. package/dist/components/elements/pagination/style.css.js +1 -1
  69. package/dist/components/elements/radio/index.cjs +1 -1
  70. package/dist/components/elements/radio/index.html.cjs +1 -1
  71. package/dist/components/elements/radio/index.html.js +1 -1
  72. package/dist/components/elements/radio/index.js +1 -1
  73. package/dist/components/elements/rate/index.cjs +1 -1
  74. package/dist/components/elements/rate/index.html.cjs +1 -1
  75. package/dist/components/elements/rate/index.html.js +1 -1
  76. package/dist/components/elements/rate/index.js +1 -1
  77. package/dist/components/elements/select/index.cjs +1 -1
  78. package/dist/components/elements/select/index.html.cjs +1 -1
  79. package/dist/components/elements/select/index.html.js +1 -1
  80. package/dist/components/elements/select/index.js +1 -1
  81. package/dist/components/elements/slider/index.cjs +1 -1
  82. package/dist/components/elements/slider/index.html.cjs +1 -1
  83. package/dist/components/elements/slider/index.html.js +1 -1
  84. package/dist/components/elements/slider/index.js +1 -1
  85. package/dist/components/elements/steps/index.cjs +1 -1
  86. package/dist/components/elements/steps/index.html.cjs +1 -1
  87. package/dist/components/elements/steps/index.html.js +1 -1
  88. package/dist/components/elements/steps/index.js +1 -1
  89. package/dist/components/elements/switch/index.cjs +1 -1
  90. package/dist/components/elements/switch/index.html.cjs +1 -1
  91. package/dist/components/elements/switch/index.html.js +1 -1
  92. package/dist/components/elements/switch/index.js +1 -1
  93. package/dist/components/elements/table/index.html.cjs +1 -1
  94. package/dist/components/elements/table/index.html.js +1 -1
  95. package/dist/components/elements/tabs/index.html.cjs +1 -1
  96. package/dist/components/elements/tabs/index.html.js +1 -1
  97. package/dist/components/elements/tag/index.html.cjs +1 -1
  98. package/dist/components/elements/tag/index.html.js +1 -1
  99. package/dist/components/elements/timeline/index.cjs +1 -1
  100. package/dist/components/elements/timeline/index.js +1 -1
  101. package/dist/components/elements/tooltip/index.cjs +1 -1
  102. package/dist/components/elements/tooltip/index.html.cjs +1 -1
  103. package/dist/components/elements/tooltip/index.html.js +1 -1
  104. package/dist/components/elements/tooltip/index.js +1 -1
  105. package/dist/components/elements/tree/index.cjs +1 -1
  106. package/dist/components/elements/tree/index.d.ts +5 -0
  107. package/dist/components/elements/tree/index.html.cjs +1 -1
  108. package/dist/components/elements/tree/index.html.js +1 -1
  109. package/dist/components/elements/tree/index.js +1 -1
  110. package/dist/components/elements/upload/index.cjs +1 -1
  111. package/dist/components/elements/upload/index.html.cjs +1 -1
  112. package/dist/components/elements/upload/index.html.js +1 -1
  113. package/dist/components/elements/upload/index.js +1 -1
  114. package/dist/index.cjs +1 -1
  115. package/dist/index.js +1 -1
  116. package/dist/plugins/solely-vite-plugin.cjs +1 -1
  117. package/dist/plugins/solely-vite-plugin.js +1 -1
  118. package/dist/router/core.cjs +1 -1
  119. package/dist/router/core.js +1 -1
  120. package/dist/router/router-link.cjs +1 -1
  121. package/dist/router/router-link.js +1 -1
  122. package/dist/router/router-view.cjs +1 -1
  123. package/dist/router/router-view.js +1 -1
  124. package/dist/runtime/component/base-element.cjs +1 -1
  125. package/dist/runtime/component/base-element.js +1 -1
  126. package/dist/runtime/component/decorators.cjs +1 -1
  127. package/dist/runtime/component/decorators.js +1 -1
  128. package/dist/runtime/reactivity/observe.cjs +1 -1
  129. package/dist/runtime/reactivity/observe.js +1 -1
  130. package/dist/runtime/renderer/renderIR.cjs +1 -1
  131. package/dist/runtime/renderer/renderIR.js +1 -1
  132. package/dist/shared/env.cjs +1 -1
  133. package/dist/shared/env.js +1 -1
  134. package/dist/shared/functions.d.ts +2 -2
  135. package/dist/shared/gen-function.cjs +1 -1
  136. package/dist/shared/gen-function.js +1 -1
  137. package/dist/shared/index.cjs +1 -1
  138. package/dist/shared/index.d.ts +1 -0
  139. package/dist/shared/index.js +1 -1
  140. package/dist/shared/svg-sanitize.cjs +1 -0
  141. package/dist/shared/svg-sanitize.d.ts +27 -0
  142. package/dist/shared/svg-sanitize.js +1 -0
  143. package/dist/shared/templateError.cjs +1 -1
  144. package/dist/shared/templateError.js +1 -1
  145. package/package.json +14 -12
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./router/index.cjs"),r=require("./shared/templateError.cjs"),t=require("./shared/gen-function.cjs"),o=require("./shared/functions.cjs"),s=require("./shared/event-listeners.cjs"),c=require("./shared/is-object.cjs"),i=require("./shared/url.cjs"),u=require("./shared/env.cjs"),a=require("./shared/case-convert.cjs"),p=require("./types/ast.cjs"),n=require("./types/lifecycle.cjs"),l=require("./runtime/component/base-element.cjs"),d=require("./router/router-link.cjs"),x=require("./router/router-view.cjs"),m=require("./runtime/renderer/html-decode.cjs"),R=require("./runtime/component/decorators.cjs"),j=require("./runtime/renderer/renderIR.cjs"),y=require("./router/core.cjs"),q=require("./compiler/ir/buildIR.cjs"),h=require("./runtime/reactivity/computed.cjs"),b=require("./runtime/reactivity/observe.cjs"),f=require("./compiler/parser/parser.cjs"),E=require("./runtime/reactivity/watch.cjs");exports.createRouter=e.createRouter,exports.showTemplateError=r.showTemplateError,exports.genFunction=t.genFunction,exports.createFunction=o.createFunction,exports.isCSPBlocked=o.isCSPBlocked,exports.listeners=s.default,exports.isObject=c.isObject,exports.parseHashUrl=i.parseHashUrl,exports.IS_DEV=u.IS_DEV,exports.IS_PROD=u.IS_PROD,exports.SOLELY_VERSION=u.SOLELY_VERSION,exports.camelToKebab=a.camelToKebab,exports.ASTType=p.ASTType,exports.LIFECYCLE_ATTRS_MAP=n.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=n.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=n.mapAttrKeyToLifecycleKind,exports.BaseElement=l.default,Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>d.default}),Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>x.default}),exports.htmlDecode=m.default,exports.CustomElement=R.CustomElement,exports.IRRenderer=j.IRRenderer,exports.createRender=j.createRender,exports.Router=y.Router,exports.getRouter=y.getRouter,exports.routerReady=y.routerReady,exports.buildIR=q.buildIR,exports.clearIRCache=q.clearIRCache,exports.transformModel=q.transformModel,exports.computed=h.computed,exports.isProxy=b.isProxy,exports.observe=b.observe,exports.toProxy=b.toProxy,exports.toRaw=b.toRaw,exports.parseHtml=f.parseHtml,exports.watch=E.watch,exports.watchGetter=E.watchGetter;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./router/index.cjs"),r=require("./shared/templateError.cjs"),t=require("./shared/gen-function.cjs"),s=require("./shared/functions.cjs"),o=require("./shared/event-listeners.cjs"),i=require("./shared/is-object.cjs"),c=require("./shared/url.cjs"),u=require("./shared/env.cjs"),a=require("./shared/case-convert.cjs"),p=require("./shared/svg-sanitize.cjs"),n=require("./types/ast.cjs"),d=require("./types/lifecycle.cjs"),l=require("./runtime/component/base-element.cjs"),x=require("./router/router-link.cjs"),m=require("./router/router-view.cjs"),j=require("./runtime/renderer/html-decode.cjs"),R=require("./runtime/component/decorators.cjs"),q=require("./runtime/renderer/renderIR.cjs"),y=require("./router/core.cjs"),h=require("./compiler/ir/buildIR.cjs"),b=require("./runtime/reactivity/computed.cjs"),S=require("./runtime/reactivity/observe.cjs"),f=require("./compiler/parser/parser.cjs"),E=require("./runtime/reactivity/watch.cjs");exports.createRouter=e.createRouter,exports.showTemplateError=r.showTemplateError,exports.genFunction=t.genFunction,exports.createFunction=s.createFunction,exports.isCSPBlocked=s.isCSPBlocked,exports.listeners=o.default,exports.isObject=i.isObject,exports.parseHashUrl=c.parseHashUrl,exports.IS_DEV=u.IS_DEV,exports.IS_PROD=u.IS_PROD,exports.SOLELY_VERSION=u.SOLELY_VERSION,exports.camelToKebab=a.camelToKebab,exports.sanitizeSvg=p.sanitizeSvg,exports.ASTType=n.ASTType,exports.LIFECYCLE_ATTRS_MAP=d.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=d.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=d.mapAttrKeyToLifecycleKind,exports.BaseElement=l.default,Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>x.default}),Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>m.default}),exports.htmlDecode=j.default,exports.CustomElement=R.CustomElement,exports.IRRenderer=q.IRRenderer,exports.createRender=q.createRender,exports.Router=y.Router,exports.getRouter=y.getRouter,exports.routerReady=y.routerReady,exports.buildIR=h.buildIR,exports.clearIRCache=h.clearIRCache,exports.transformModel=h.transformModel,exports.computed=b.computed,exports.isProxy=S.isProxy,exports.observe=S.observe,exports.toProxy=S.toProxy,exports.toRaw=S.toRaw,exports.parseHtml=f.parseHtml,exports.watch=E.watch,exports.watchGetter=E.watchGetter;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{createRouter as r}from"./router/index.js";import{showTemplateError as e}from"./shared/templateError.js";import{genFunction as o}from"./shared/gen-function.js";import{createFunction as t,isCSPBlocked as m}from"./shared/functions.js";import{default as s}from"./shared/event-listeners.js";import{isObject as i}from"./shared/is-object.js";import{parseHashUrl as a}from"./shared/url.js";import{IS_DEV as p,IS_PROD as f,SOLELY_VERSION as n}from"./shared/env.js";import{camelToKebab as u}from"./shared/case-convert.js";import{ASTType as j}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as d,isLifecycleKind as c,mapAttrKeyToLifecycleKind as l}from"./types/lifecycle.js";import{default as h}from"./runtime/component/base-element.js";import{default as v}from"./router/router-link.js";import{default as y}from"./router/router-view.js";import{default as b}from"./runtime/renderer/html-decode.js";import{CustomElement as R}from"./runtime/component/decorators.js";import{IRRenderer as w,createRender as k}from"./runtime/renderer/renderIR.js";import{Router as x,getRouter as E,routerReady as I}from"./router/core.js";import{buildIR as g,clearIRCache as B,transformModel as D}from"./compiler/ir/buildIR.js";import{computed as L}from"./runtime/reactivity/computed.js";import{isProxy as V,observe as q,toProxy as z,toRaw as A}from"./runtime/reactivity/observe.js";import{parseHtml as C}from"./compiler/parser/parser.js";import{watch as F,watchGetter as G}from"./runtime/reactivity/watch.js";export{j as ASTType,h as BaseElement,R as CustomElement,w as IRRenderer,p as IS_DEV,f as IS_PROD,d as LIFECYCLE_ATTRS_MAP,x as Router,v as RouterLink,y as RouterView,n as SOLELY_VERSION,g as buildIR,u as camelToKebab,B as clearIRCache,L as computed,t as createFunction,k as createRender,r as createRouter,o as genFunction,E as getRouter,b as htmlDecode,m as isCSPBlocked,c as isLifecycleKind,i as isObject,V as isProxy,s as listeners,l as mapAttrKeyToLifecycleKind,q as observe,a as parseHashUrl,C as parseHtml,I as routerReady,e as showTemplateError,z as toProxy,A as toRaw,D as transformModel,F as watch,G as watchGetter};
1
+ import{createRouter as r}from"./router/index.js";import{showTemplateError as e}from"./shared/templateError.js";import{genFunction as o}from"./shared/gen-function.js";import{createFunction as t,isCSPBlocked as m}from"./shared/functions.js";import{default as s}from"./shared/event-listeners.js";import{isObject as i}from"./shared/is-object.js";import{parseHashUrl as a}from"./shared/url.js";import{IS_DEV as p,IS_PROD as f,SOLELY_VERSION as n}from"./shared/env.js";import{camelToKebab as j}from"./shared/case-convert.js";import{sanitizeSvg as u}from"./shared/svg-sanitize.js";import{ASTType as d}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as c,isLifecycleKind as l,mapAttrKeyToLifecycleKind as h}from"./types/lifecycle.js";import{default as v}from"./runtime/component/base-element.js";import{default as y}from"./router/router-link.js";import{default as b}from"./router/router-view.js";import{default as R}from"./runtime/renderer/html-decode.js";import{CustomElement as w}from"./runtime/component/decorators.js";import{IRRenderer as g,createRender as k}from"./runtime/renderer/renderIR.js";import{Router as x,getRouter as E,routerReady as I}from"./router/core.js";import{buildIR as z,clearIRCache as B,transformModel as D}from"./compiler/ir/buildIR.js";import{computed as L}from"./runtime/reactivity/computed.js";import{isProxy as V,observe as q,toProxy as A,toRaw as C}from"./runtime/reactivity/observe.js";import{parseHtml as F}from"./compiler/parser/parser.js";import{watch as G,watchGetter as H}from"./runtime/reactivity/watch.js";export{d as ASTType,v as BaseElement,w as CustomElement,g as IRRenderer,p as IS_DEV,f as IS_PROD,c as LIFECYCLE_ATTRS_MAP,x as Router,y as RouterLink,b as RouterView,n as SOLELY_VERSION,z as buildIR,j as camelToKebab,B as clearIRCache,L as computed,t as createFunction,k as createRender,r as createRouter,o as genFunction,E as getRouter,R as htmlDecode,m as isCSPBlocked,l as isLifecycleKind,i as isObject,V as isProxy,s as listeners,h as mapAttrKeyToLifecycleKind,q as observe,a as parseHashUrl,F as parseHtml,I as routerReady,u as sanitizeSvg,e as showTemplateError,A as toProxy,C as toRaw,D as transformModel,G as watch,H as watchGetter};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("magic-string"),n=require("../compiler/parser/parser.cjs"),o=require("../compiler/ir/buildIR.cjs"),r={precompile:!0,sourceMap:!0,minify:!1,include:[/\.html(?:\?|$)/],exclude:/node_modules/,debug:!1};function t(e,r="anonymous"){const t=n.parseHtml(e);return o.buildIR(t,{filename:r,source:e})}function p(e,n){return(Array.isArray(n)?n:[n]).some(n=>"string"==typeof n?e.includes(n):n.test(e))}function i(n,o,r){const t=new e.default(n),p=n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$");return t.overwrite(0,n.length,`\nconst __SOLELY_TEMPLATE__ = \`${p}\`;\n\nexport default __SOLELY_TEMPLATE__;\nexport { __SOLELY_TEMPLATE__ };\n`),{code:t.toString(),map:t.generateMap({source:o,includeContent:!r})}}function l(n={}){const o={...r,...n};return{name:"solely-vite-plugin",enforce:"pre",configResolved(e){o.debug&&console.info("[Solely] Plugin initialized with options:",o)},transform(n,r){if(!p(r,o.include)||p(r,o.exclude))return null;if(!r.includes(".html?solely"))return null;try{if(o.debug&&console.info(`[Solely] Processing: ${r}`),o.precompile){const p=t(n,r),i=function(n,o,r,t){const p=new e.default(o);p.remove(0,o.length),t||(p.append("\n// ============================================\n"),p.append("// Solely Precompiled Template\n"),p.append(`// Compiled at: ${(new Date).toISOString()}\n`),p.append("// ============================================\n\n")),p.append("const __SOLELY_IR__ = {\n"),p.append(" t: 'root',\n"),p.append(` v: '${n.v}',\n\n`),t||p.append(" // 编译后的函数数组\n"),p.append(" fns: [\n"),n.fns.forEach((e,o)=>{const r="string"==typeof e?e:e.toString(),i=o===n.fns.length-1;t||p.append(` // Function ${o+1}\n`),p.append(` ${r}${i?"":","}\n`)}),p.append(" ],\n\n");const i=e=>{const n={t:e.t,d:e.d};return void 0!==e.s&&(n.s=e.s),void 0!==e.g&&(n.g=e.g),void 0!==e.x&&(n.x=e.x),void 0!==e.f&&(n.f=e.f),void 0!==e.i&&(n.i=e.i),void 0!==e.n&&(n.n=e.n),!t&&e.__m&&(n.__m={...e.__m}),e.a&&(n.a=e.a.map(e=>({k:e.k,v:e.v,f:e.f,d:e.d,r:e.r,...!t&&e.__m&&{__m:{...e.__m}}}))),e.c&&(n.c=e.c.map(i)),e.b&&(n.b=e.b.map(e=>{var n;return{f:e.f,c:e.c.map(i),a:null==(n=e.a)?void 0:n.map(e=>({k:e.k,v:e.v,f:e.f,d:e.d,r:e.r})),...void 0!==e.ka&&{ka:e.ka},...!t&&e.__m&&{__m:{...e.__m}}}})),n},l=n.n.map(i);return t||p.append(" // IR 节点树\n"),p.append(` n: ${JSON.stringify(l,null,t?0:2)},\n\n`),t||p.append(" // 编译统计\n"),p.append(` s: ${JSON.stringify(n.s)},\n\n`),t||(p.append(" // 元数据\n"),p.append(` m: ${JSON.stringify(n.m)}\n`)),p.append("};\n\n"),t||p.append("// 导出 IR 对象\n"),p.append("export default __SOLELY_IR__;\n"),p.append("export { __SOLELY_IR__ };\n\n"),t||p.append("// 同时导出模板字符串(向后兼容)\n"),p.append("export const __SOLELY_TEMPLATE__ = '';\n"),{code:p.toString(),map:p.generateMap({source:r,includeContent:!t,hires:!t})}}(p,n,r,!!o.minify);return o.debug&&(console.info(`[Solely] Compiled IR for: ${r}`),console.info("[Solely] Stats:",p.s)),{code:i.code,map:o.sourceMap?i.map:null}}{const e=i(n,r,!!o.minify);return{code:e.code,map:o.sourceMap?e.map:null}}}catch(l){const e=`[Solely] Error processing ${r}: ${l instanceof Error?l.message:String(l)}`;console.error(e),console.warn(`[Solely] Falling back to raw template for: ${r}`);const t=i(n,r,!!o.minify);return{code:t.code,map:o.sourceMap?t.map:null}}},handleHotUpdate({file:e,server:n,modules:r}){if(p(e,o.include)&&!p(e,o.exclude))return o.debug&&console.info(`[Solely] HMR triggered for: ${e}`),n.ws.send({type:"full-reload",path:"*"}),r}}}"undefined"!=typeof window&&(window.__SOLELY_VITE_PLUGIN__=l),exports.compileTemplate=t,exports.solelyVitePlugin=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("magic-string"),n=require("../compiler/parser/parser.cjs"),o=require("../compiler/ir/buildIR.cjs"),r={precompile:!0,sourceMap:!0,minify:!1,include:[/\.html(?:\?|$)/],exclude:/node_modules/,debug:!1};function t(e,r="anonymous"){const t=n.parseHtml(e);return o.buildIR(t,{filename:r,source:e})}function p(e,n){return(Array.isArray(n)?n:[n]).some(n=>"string"==typeof n?e.includes(n):n.test(e))}function i(n,o,r){const t=new e.default(n),p=n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$");return t.overwrite(0,n.length,`\nconst __SOLELY_TEMPLATE__ = \`${p}\`;\n\nexport default __SOLELY_TEMPLATE__;\nexport { __SOLELY_TEMPLATE__ };\n`),{code:t.toString(),map:t.generateMap({source:o,includeContent:!r})}}function l(n={}){const o={...r,...n};return{name:"solely-vite-plugin",enforce:"pre",configResolved(e){o.debug&&console.info("[Solely] Plugin initialized with options:",o)},transform(n,r){if(!p(r,o.include)||p(r,o.exclude))return null;if(!r.includes(".html?solely"))return null;try{if(o.debug&&console.info(`[Solely] Processing: ${r}`),o.precompile){const p=t(n,r),i=function(n,o,r,t){const p=new e.default(o);p.remove(0,o.length),t||(p.append("\n// ============================================\n"),p.append("// Solely Precompiled Template\n"),p.append(`// Compiled at: ${(new Date).toISOString()}\n`),p.append("// ============================================\n\n")),p.append("const __SOLELY_IR__ = {\n"),p.append(" t: 'root',\n"),p.append(` v: '${n.v}',\n\n`),t||p.append(" // 编译后的函数数组\n"),p.append(" fns: [\n"),n.fns.forEach((e,o)=>{const r="string"==typeof e?e:e.toString(),i=o===n.fns.length-1;t||p.append(` // Function ${o+1}\n`),p.append(` ${r}${i?"":","}\n`)}),p.append(" ],\n\n");const i=e=>{const n={t:e.t,d:e.d};return void 0!==e.s&&(n.s=e.s),void 0!==e.g&&(n.g=e.g),void 0!==e.x&&(n.x=e.x),void 0!==e.f&&(n.f=e.f),void 0!==e.i&&(n.i=e.i),void 0!==e.n&&(n.n=e.n),!t&&e.__m&&(n.__m={...e.__m}),e.a&&(n.a=e.a.map(e=>({k:e.k,v:e.v,f:e.f,d:e.d,r:e.r,...!t&&e.__m&&{__m:{...e.__m}}}))),e.c&&(n.c=e.c.map(i)),e.b&&(n.b=e.b.map(e=>({f:e.f,c:e.c.map(i),a:e.a?.map(e=>({k:e.k,v:e.v,f:e.f,d:e.d,r:e.r})),...void 0!==e.ka&&{ka:e.ka},...!t&&e.__m&&{__m:{...e.__m}}}))),n},l=n.n.map(i);return t||p.append(" // IR 节点树\n"),p.append(` n: ${JSON.stringify(l,null,t?0:2)},\n\n`),t||p.append(" // 编译统计\n"),p.append(` s: ${JSON.stringify(n.s)},\n\n`),t||(p.append(" // 元数据\n"),p.append(` m: ${JSON.stringify(n.m)}\n`)),p.append("};\n\n"),t||p.append("// 导出 IR 对象\n"),p.append("export default __SOLELY_IR__;\n"),p.append("export { __SOLELY_IR__ };\n\n"),t||p.append("// 同时导出模板字符串(向后兼容)\n"),p.append("export const __SOLELY_TEMPLATE__ = '';\n"),{code:p.toString(),map:p.generateMap({source:r,includeContent:!t,hires:!t})}}(p,n,r,!!o.minify);return o.debug&&(console.info(`[Solely] Compiled IR for: ${r}`),console.info("[Solely] Stats:",p.s)),{code:i.code,map:o.sourceMap?i.map:null}}{const e=i(n,r,!!o.minify);return{code:e.code,map:o.sourceMap?e.map:null}}}catch(l){const e=`[Solely] Error processing ${r}: ${l instanceof Error?l.message:String(l)}`;console.error(e),console.warn(`[Solely] Falling back to raw template for: ${r}`);const t=i(n,r,!!o.minify);return{code:t.code,map:o.sourceMap?t.map:null}}},handleHotUpdate({file:e,server:n,modules:r}){if(p(e,o.include)&&!p(e,o.exclude))return o.debug&&console.info(`[Solely] HMR triggered for: ${e}`),n.ws.send({type:"full-reload",path:"*"}),r}}}"undefined"!=typeof window&&(window.__SOLELY_VITE_PLUGIN__=l),exports.compileTemplate=t,exports.solelyVitePlugin=l;
@@ -1 +1 @@
1
- import n from"magic-string";import{parseHtml as e}from"../compiler/parser/parser.js";import{buildIR as o}from"../compiler/ir/buildIR.js";const r={precompile:!0,sourceMap:!0,minify:!1,include:[/\.html(?:\?|$)/],exclude:/node_modules/,debug:!1};function p(n,r="anonymous"){const p=e(n);return o(p,{filename:r,source:n})}function t(n,e){return(Array.isArray(e)?e:[e]).some(e=>"string"==typeof e?n.includes(e):e.test(n))}function i(e,o,r){const p=new n(e),t=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$");return p.overwrite(0,e.length,`\nconst __SOLELY_TEMPLATE__ = \`${t}\`;\n\nexport default __SOLELY_TEMPLATE__;\nexport { __SOLELY_TEMPLATE__ };\n`),{code:p.toString(),map:p.generateMap({source:o,includeContent:!r})}}function a(e={}){const o={...r,...e};return{name:"solely-vite-plugin",enforce:"pre",configResolved(n){o.debug&&console.info("[Solely] Plugin initialized with options:",o)},transform(e,r){if(!t(r,o.include)||t(r,o.exclude))return null;if(!r.includes(".html?solely"))return null;try{if(o.debug&&console.info(`[Solely] Processing: ${r}`),o.precompile){const t=p(e,r),i=function(e,o,r,p){const t=new n(o);t.remove(0,o.length),p||(t.append("\n// ============================================\n"),t.append("// Solely Precompiled Template\n"),t.append(`// Compiled at: ${(new Date).toISOString()}\n`),t.append("// ============================================\n\n")),t.append("const __SOLELY_IR__ = {\n"),t.append(" t: 'root',\n"),t.append(` v: '${e.v}',\n\n`),p||t.append(" // 编译后的函数数组\n"),t.append(" fns: [\n"),e.fns.forEach((n,o)=>{const r="string"==typeof n?n:n.toString(),i=o===e.fns.length-1;p||t.append(` // Function ${o+1}\n`),t.append(` ${r}${i?"":","}\n`)}),t.append(" ],\n\n");const i=n=>{const e={t:n.t,d:n.d};return void 0!==n.s&&(e.s=n.s),void 0!==n.g&&(e.g=n.g),void 0!==n.x&&(e.x=n.x),void 0!==n.f&&(e.f=n.f),void 0!==n.i&&(e.i=n.i),void 0!==n.n&&(e.n=n.n),!p&&n.__m&&(e.__m={...n.__m}),n.a&&(e.a=n.a.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r,...!p&&n.__m&&{__m:{...n.__m}}}))),n.c&&(e.c=n.c.map(i)),n.b&&(e.b=n.b.map(n=>{var e;return{f:n.f,c:n.c.map(i),a:null==(e=n.a)?void 0:e.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r})),...void 0!==n.ka&&{ka:n.ka},...!p&&n.__m&&{__m:{...n.__m}}}})),e},a=e.n.map(i);return p||t.append(" // IR 节点树\n"),t.append(` n: ${JSON.stringify(a,null,p?0:2)},\n\n`),p||t.append(" // 编译统计\n"),t.append(` s: ${JSON.stringify(e.s)},\n\n`),p||(t.append(" // 元数据\n"),t.append(` m: ${JSON.stringify(e.m)}\n`)),t.append("};\n\n"),p||t.append("// 导出 IR 对象\n"),t.append("export default __SOLELY_IR__;\n"),t.append("export { __SOLELY_IR__ };\n\n"),p||t.append("// 同时导出模板字符串(向后兼容)\n"),t.append("export const __SOLELY_TEMPLATE__ = '';\n"),{code:t.toString(),map:t.generateMap({source:r,includeContent:!p,hires:!p})}}(t,e,r,!!o.minify);return o.debug&&(console.info(`[Solely] Compiled IR for: ${r}`),console.info("[Solely] Stats:",t.s)),{code:i.code,map:o.sourceMap?i.map:null}}{const n=i(e,r,!!o.minify);return{code:n.code,map:o.sourceMap?n.map:null}}}catch(a){const n=`[Solely] Error processing ${r}: ${a instanceof Error?a.message:String(a)}`;console.error(n),console.warn(`[Solely] Falling back to raw template for: ${r}`);const p=i(e,r,!!o.minify);return{code:p.code,map:o.sourceMap?p.map:null}}},handleHotUpdate({file:n,server:e,modules:r}){if(t(n,o.include)&&!t(n,o.exclude))return o.debug&&console.info(`[Solely] HMR triggered for: ${n}`),e.ws.send({type:"full-reload",path:"*"}),r}}}"undefined"!=typeof window&&(window.__SOLELY_VITE_PLUGIN__=a);export{p as compileTemplate,a as solelyVitePlugin};
1
+ import n from"magic-string";import{parseHtml as e}from"../compiler/parser/parser.js";import{buildIR as o}from"../compiler/ir/buildIR.js";const r={precompile:!0,sourceMap:!0,minify:!1,include:[/\.html(?:\?|$)/],exclude:/node_modules/,debug:!1};function p(n,r="anonymous"){const p=e(n);return o(p,{filename:r,source:n})}function t(n,e){return(Array.isArray(e)?e:[e]).some(e=>"string"==typeof e?n.includes(e):e.test(n))}function i(e,o,r){const p=new n(e),t=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$");return p.overwrite(0,e.length,`\nconst __SOLELY_TEMPLATE__ = \`${t}\`;\n\nexport default __SOLELY_TEMPLATE__;\nexport { __SOLELY_TEMPLATE__ };\n`),{code:p.toString(),map:p.generateMap({source:o,includeContent:!r})}}function a(e={}){const o={...r,...e};return{name:"solely-vite-plugin",enforce:"pre",configResolved(n){o.debug&&console.info("[Solely] Plugin initialized with options:",o)},transform(e,r){if(!t(r,o.include)||t(r,o.exclude))return null;if(!r.includes(".html?solely"))return null;try{if(o.debug&&console.info(`[Solely] Processing: ${r}`),o.precompile){const t=p(e,r),i=function(e,o,r,p){const t=new n(o);t.remove(0,o.length),p||(t.append("\n// ============================================\n"),t.append("// Solely Precompiled Template\n"),t.append(`// Compiled at: ${(new Date).toISOString()}\n`),t.append("// ============================================\n\n")),t.append("const __SOLELY_IR__ = {\n"),t.append(" t: 'root',\n"),t.append(` v: '${e.v}',\n\n`),p||t.append(" // 编译后的函数数组\n"),t.append(" fns: [\n"),e.fns.forEach((n,o)=>{const r="string"==typeof n?n:n.toString(),i=o===e.fns.length-1;p||t.append(` // Function ${o+1}\n`),t.append(` ${r}${i?"":","}\n`)}),t.append(" ],\n\n");const i=n=>{const e={t:n.t,d:n.d};return void 0!==n.s&&(e.s=n.s),void 0!==n.g&&(e.g=n.g),void 0!==n.x&&(e.x=n.x),void 0!==n.f&&(e.f=n.f),void 0!==n.i&&(e.i=n.i),void 0!==n.n&&(e.n=n.n),!p&&n.__m&&(e.__m={...n.__m}),n.a&&(e.a=n.a.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r,...!p&&n.__m&&{__m:{...n.__m}}}))),n.c&&(e.c=n.c.map(i)),n.b&&(e.b=n.b.map(n=>({f:n.f,c:n.c.map(i),a:n.a?.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r})),...void 0!==n.ka&&{ka:n.ka},...!p&&n.__m&&{__m:{...n.__m}}}))),e},a=e.n.map(i);return p||t.append(" // IR 节点树\n"),t.append(` n: ${JSON.stringify(a,null,p?0:2)},\n\n`),p||t.append(" // 编译统计\n"),t.append(` s: ${JSON.stringify(e.s)},\n\n`),p||(t.append(" // 元数据\n"),t.append(` m: ${JSON.stringify(e.m)}\n`)),t.append("};\n\n"),p||t.append("// 导出 IR 对象\n"),t.append("export default __SOLELY_IR__;\n"),t.append("export { __SOLELY_IR__ };\n\n"),p||t.append("// 同时导出模板字符串(向后兼容)\n"),t.append("export const __SOLELY_TEMPLATE__ = '';\n"),{code:t.toString(),map:t.generateMap({source:r,includeContent:!p,hires:!p})}}(t,e,r,!!o.minify);return o.debug&&(console.info(`[Solely] Compiled IR for: ${r}`),console.info("[Solely] Stats:",t.s)),{code:i.code,map:o.sourceMap?i.map:null}}{const n=i(e,r,!!o.minify);return{code:n.code,map:o.sourceMap?n.map:null}}}catch(a){const n=`[Solely] Error processing ${r}: ${a instanceof Error?a.message:String(a)}`;console.error(n),console.warn(`[Solely] Falling back to raw template for: ${r}`);const p=i(e,r,!!o.minify);return{code:p.code,map:o.sourceMap?p.map:null}}},handleHotUpdate({file:n,server:e,modules:r}){if(t(n,o.include)&&!t(n,o.exclude))return o.debug&&console.info(`[Solely] HMR triggered for: ${n}`),e.ws.send({type:"full-reload",path:"*"}),r}}}"undefined"!=typeof window&&(window.__SOLELY_VITE_PLUGIN__=a);export{p as compileTemplate,a as solelyVitePlugin};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,t=(t,s,i)=>((t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i)(t,"symbol"!=typeof s?s+"":s,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../shared/env.cjs");let i=null,r=null,a=null;function n(){return i?Promise.resolve(i):(a||(a=new Promise(e=>{r=e})),a)}const h=(()=>{const e=()=>n();return Object.defineProperties(e,{then:{value:(e,t)=>n().then(e,t),writable:!1,enumerable:!1,configurable:!0},catch:{value:e=>n().catch(e),writable:!1,enumerable:!1,configurable:!0},finally:{value:e=>n().finally(e),writable:!1,enumerable:!1,configurable:!0},[Symbol.toStringTag]:{value:"Promise",writable:!1,enumerable:!1,configurable:!0}}),e})(),o=class e{constructor(e){t(this,"routes"),t(this,"base"),t(this,"mode"),t(this,"beforeEachGuard"),t(this,"afterEachGuard"),t(this,"currentRoute",null),t(this,"listeners",new Set),t(this,"componentCache",new Map),t(this,"keepAliveCache",new Map),t(this,"keepAliveKeys",[]),t(this,"navigationId",0),t(this,"maxKeepAlive"),t(this,"isStarted",!1),t(this,"handleRouteChange",null),this.routes=e.routes,this.base=this.normalizeBase(e.base),this.mode=e.mode||"history",this.beforeEachGuard=e.beforeEach,this.afterEachGuard=e.afterEach,this.maxKeepAlive=e.maxKeepAlive}normalizeBase(e){let t=e||"/";return t.startsWith("/")||(t="/"+t),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}matchRoute(e="/"){return this.matchRouteInternal(e,new Set,0)}matchRouteInternal(t,i,r){if(r>=e.MAX_REDIRECTS)return s.IS_DEV&&console.error(`[Router] Too many redirects (max ${e.MAX_REDIRECTS}), last path: ${t}`),null;const a=this.normalizePath(t);if(i.has(a))return s.IS_DEV&&console.error(`[Router] Circular redirect detected: ${a}`),null;i.add(a);const[n,h]=a.split("?"),o=n.split("/").filter(Boolean),c=this.parseQuery(h),l=this.recursiveMatch(this.routes,o);if(l){const e=l.matched[l.matched.length-1];return e.config.redirect?this.matchRouteInternal(e.config.redirect,i,r+1):{matched:l.matched,params:l.params,query:c,fullPath:a,meta:l.matched.reduce((e,t)=>({...e,...t.config.meta||{}}),{})}}return null}recursiveMatch(e,t){const s=[...e].sort((e,t)=>this.calculateScore(t.path)-this.calculateScore(e.path));for(const i of s){const e=i.path.split("/").filter(Boolean),s={};let r=!0;if(0===e.length&&0===t.length)return{matched:[{config:i,params:{}}],params:{}};for(let i=0;i<e.length;i++){const a=e[i],n=t[i];if(a.startsWith(":")){if(!n){r=!1;break}Object.defineProperty(s,a.slice(1),{value:n,writable:!0,enumerable:!0,configurable:!0})}else{if("*"===a){r=!0;break}if(a!==n){r=!1;break}}}if(r){const r=e.length,a=t.slice(r),n={config:i,params:s};if(a.length>0&&i.children){const e=this.recursiveMatch(i.children,a);if(e)return{matched:[n,...e.matched],params:{...s,...e.params}}}else if(0===a.length||e.includes("*"))return{matched:[n],params:s}}}return null}calculateScore(e="/"){const t=e.split("/").filter(Boolean);return 0===t.length?1:t.reduce((e,t)=>t.startsWith(":")?e+5:"*"===t?e+0:e+10,0)}parseQuery(e){const t={};return e?(new URLSearchParams(e).forEach((e,s)=>{Object.defineProperty(t,s,{value:e,writable:!0,enumerable:!0,configurable:!0})}),t):t}normalizePath(e="/"){const t=e&&"string"==typeof e?e:"/",s=t.indexOf("?"),i=-1===s?t:t.slice(0,s),r=-1===s?"":t.slice(s+1);let a=i;return a.startsWith("/")||(a="/"+a),a.length>1&&a.endsWith("/")&&(a=a.slice(0,-1)),r?`${a}?${r}`:a}getPath(){let e;try{e="hash"===this.mode?window.location.hash.slice(1)||"/":`${window.location.pathname}${window.location.search}`}catch{e="/"}const t=this.base||"/";return"/"===t||e!==t&&!e.startsWith(t+"/")||(e=e.slice(t.length)||"/"),this.normalizePath(e)}updateBrowserHistory(e="/",t){const s=this.normalizePath(e),i=this.base||"/";if("hash"===this.mode)t?window.location.replace(`#${s}`):window.location.hash=s;else{const e=i.endsWith("/")?i.slice(0,-1):i,r="/"===e?s:e+s;t?window.history.replaceState({path:r},"",r):window.history.pushState({path:r},"",r)}}async navigate(e="/",t=!1,s=!1){const i=++this.navigationId,r=this.normalizePath(e),a=this.currentRoute,n=this.matchRoute(r);if(!n)return{success:!1,error:`No route matched: ${r}`};if(a&&a.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const e=await this.beforeEachGuard(n,a);if(i!==this.navigationId)return{success:!1,cancelled:!0};if(!1===e)return{success:!1,cancelled:!0};if("string"==typeof e)return this.navigate(e,t)}catch(h){return i!==this.navigationId?{success:!1,cancelled:!0}:{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return i!==this.navigationId?{success:!1,cancelled:!0}:(this.currentRoute=n,s||this.updateBrowserHistory(r,t),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,a),{success:!0})}resolve(e="/"){const t=this.normalizePath(e);if("hash"===this.mode)return`#${t}`;const s=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===s?t:s+t}get modeType(){return this.mode}pushWithQuery(e="/",t){const s=new URLSearchParams(t).toString(),i=e.includes("?")?"&":"?";return this.push(e+(s?i+s:""))}push(e="/"){return this.navigate(e,!1)}replace(e="/"){return this.navigate(e,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}setupListeners(){this.isStarted||(this.isStarted=!0,this.handleRouteChange=()=>{this.navigate(this.getPath(),!0,!0)},"hash"===this.mode?window.addEventListener("hashchange",this.handleRouteChange):window.addEventListener("popstate",this.handleRouteChange),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0))}destroy(){this.handleRouteChange&&("hash"===this.mode?window.removeEventListener("hashchange",this.handleRouteChange):window.removeEventListener("popstate",this.handleRouteChange),this.handleRouteChange=null),this.isStarted=!1,this.listeners.clear(),this.componentCache.clear(),this.keepAliveCache.clear(),this.keepAliveKeys=[],this.currentRoute=null,i=null}getCurrentRoute(){return this.currentRoute}getKeepAlive(e){const t=this.keepAliveCache.get(e);if(t){const t=this.keepAliveKeys.indexOf(e);-1!==t&&(this.keepAliveKeys.splice(t,1),this.keepAliveKeys.push(e))}return t}setKeepAlive(e,t){if(this.keepAliveCache.has(e)){this.keepAliveCache.set(e,t);const s=this.keepAliveKeys.indexOf(e);-1!==s&&(this.keepAliveKeys.splice(s,1),this.keepAliveKeys.push(e))}else this.keepAliveCache.set(e,t),this.keepAliveKeys.push(e),this.evictKeepAlive()}hasKeepAlive(e){return this.keepAliveCache.has(e)}evictKeepAlive(){if(this.maxKeepAlive)for(;this.keepAliveKeys.length>this.maxKeepAlive;){const e=this.keepAliveKeys.shift();e&&this.keepAliveCache.delete(e)}}cacheKey(e){return this.normalizePath(e)}prefetch(e){const t=this.matchRoute(e);if(!t)return;const s=this.cacheKey(t.fullPath),i=t.matched[t.matched.length-1];if(!(null==i?void 0:i.config.component))return;const r=i.config.component;if("function"!=typeof r)return;if(this.componentCache.has(s))return;const a=r();this.componentCache.set(s,a),a.catch(()=>{this.componentCache.delete(s)})}getComponentFromCache(e){return this.componentCache.get(this.cacheKey(e))}};t(o,"MAX_REDIRECTS",20);let c=o;exports.Router=c,exports.createRouter=function(e){return i||(i=new c(e),r&&r(i),r=null,a=null,i)},exports.getRouter=function(){return i},exports.routerReady=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../shared/env.cjs");let t=null,s=null,i=null;function r(){return t?Promise.resolve(t):(i||(i=new Promise(e=>{s=e})),i)}const a=(()=>{const e=()=>r();return Object.defineProperties(e,{then:{value:(e,t)=>r().then(e,t),writable:!1,enumerable:!1,configurable:!0},catch:{value:e=>r().catch(e),writable:!1,enumerable:!1,configurable:!0},finally:{value:e=>r().finally(e),writable:!1,enumerable:!1,configurable:!0},[Symbol.toStringTag]:{value:"Promise",writable:!1,enumerable:!1,configurable:!0}}),e})();class n{routes;base;mode;beforeEachGuard;afterEachGuard;currentRoute=null;listeners=new Set;componentCache=new Map;keepAliveCache=new Map;keepAliveKeys=[];navigationId=0;maxKeepAlive;constructor(e){this.routes=e.routes,this.base=this.normalizeBase(e.base),this.mode=e.mode||"history",this.beforeEachGuard=e.beforeEach,this.afterEachGuard=e.afterEach,this.maxKeepAlive=e.maxKeepAlive}normalizeBase(e){let t=e||"/";return t.startsWith("/")||(t="/"+t),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}static MAX_REDIRECTS=20;matchRoute(e="/"){return this.matchRouteInternal(e,new Set,0)}matchRouteInternal(t,s,i){if(i>=n.MAX_REDIRECTS)return e.IS_DEV&&console.error(`[Router] Too many redirects (max ${n.MAX_REDIRECTS}), last path: ${t}`),null;const r=this.normalizePath(t);if(s.has(r))return e.IS_DEV&&console.error(`[Router] Circular redirect detected: ${r}`),null;s.add(r);const[a,h]=r.split("?"),o=a.split("/").filter(Boolean),c=this.parseQuery(h),l=this.recursiveMatch(this.routes,o);if(l){const e=l.matched[l.matched.length-1];return e.config.redirect?this.matchRouteInternal(e.config.redirect,s,i+1):{matched:l.matched,params:l.params,query:c,fullPath:r,meta:l.matched.reduce((e,t)=>({...e,...t.config.meta||{}}),{})}}return null}recursiveMatch(e,t){const s=[...e].sort((e,t)=>this.calculateScore(t.path)-this.calculateScore(e.path));for(const i of s){const e=i.path.split("/").filter(Boolean),s={};let r=!0;if(0===e.length&&0===t.length)return{matched:[{config:i,params:{}}],params:{}};for(let i=0;i<e.length;i++){const a=e[i],n=t[i];if(a.startsWith(":")){if(!n){r=!1;break}Object.defineProperty(s,a.slice(1),{value:n,writable:!0,enumerable:!0,configurable:!0})}else{if("*"===a){r=!0;break}if(a!==n){r=!1;break}}}if(r){const r=e.length,a=t.slice(r),n={config:i,params:s};if(a.length>0&&i.children){const e=this.recursiveMatch(i.children,a);if(e)return{matched:[n,...e.matched],params:{...s,...e.params}}}else if(0===a.length||e.includes("*"))return{matched:[n],params:s}}}return null}calculateScore(e="/"){const t=e.split("/").filter(Boolean);return 0===t.length?1:t.reduce((e,t)=>t.startsWith(":")?e+5:"*"===t?e+0:e+10,0)}parseQuery(e){const t={};return e?(new URLSearchParams(e).forEach((e,s)=>{Object.defineProperty(t,s,{value:e,writable:!0,enumerable:!0,configurable:!0})}),t):t}normalizePath(e="/"){const t=e&&"string"==typeof e?e:"/",s=t.indexOf("?"),i=-1===s?t:t.slice(0,s),r=-1===s?"":t.slice(s+1);let a=i;return a.startsWith("/")||(a="/"+a),a.length>1&&a.endsWith("/")&&(a=a.slice(0,-1)),r?`${a}?${r}`:a}getPath(){let e;try{e="hash"===this.mode?window.location.hash.slice(1)||"/":`${window.location.pathname}${window.location.search}`}catch{e="/"}const t=this.base||"/";return"/"===t||e!==t&&!e.startsWith(t+"/")||(e=e.slice(t.length)||"/"),this.normalizePath(e)}updateBrowserHistory(e="/",t){const s=this.normalizePath(e),i=this.base||"/";if("hash"===this.mode)t?window.location.replace(`#${s}`):window.location.hash=s;else{const e=i.endsWith("/")?i.slice(0,-1):i,r="/"===e?s:e+s;t?window.history.replaceState({path:r},"",r):window.history.pushState({path:r},"",r)}}async navigate(e="/",t=!1,s=!1){const i=++this.navigationId,r=this.normalizePath(e),a=this.currentRoute,n=this.matchRoute(r);if(!n)return{success:!1,error:`No route matched: ${r}`};if(a&&a.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const e=await this.beforeEachGuard(n,a);if(i!==this.navigationId)return{success:!1,cancelled:!0};if(!1===e)return{success:!1,cancelled:!0};if("string"==typeof e)return this.navigate(e,t)}catch(h){return i!==this.navigationId?{success:!1,cancelled:!0}:{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return i!==this.navigationId?{success:!1,cancelled:!0}:(this.currentRoute=n,s||this.updateBrowserHistory(r,t),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,a),{success:!0})}resolve(e="/"){const t=this.normalizePath(e);if("hash"===this.mode)return`#${t}`;const s=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===s?t:s+t}get modeType(){return this.mode}pushWithQuery(e="/",t){const s=new URLSearchParams(t).toString(),i=e.includes("?")?"&":"?";return this.push(e+(s?i+s:""))}push(e="/"){return this.navigate(e,!1)}replace(e="/"){return this.navigate(e,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}isStarted=!1;handleRouteChange=null;setupListeners(){this.isStarted||(this.isStarted=!0,this.handleRouteChange=()=>{this.navigate(this.getPath(),!0,!0)},"hash"===this.mode?window.addEventListener("hashchange",this.handleRouteChange):window.addEventListener("popstate",this.handleRouteChange),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0))}destroy(){this.handleRouteChange&&("hash"===this.mode?window.removeEventListener("hashchange",this.handleRouteChange):window.removeEventListener("popstate",this.handleRouteChange),this.handleRouteChange=null),this.isStarted=!1,this.listeners.clear(),this.componentCache.clear(),this.keepAliveCache.clear(),this.keepAliveKeys=[],this.currentRoute=null,t=null}getCurrentRoute(){return this.currentRoute}getKeepAlive(e){const t=this.keepAliveCache.get(e);if(t){const t=this.keepAliveKeys.indexOf(e);-1!==t&&(this.keepAliveKeys.splice(t,1),this.keepAliveKeys.push(e))}return t}setKeepAlive(e,t){if(this.keepAliveCache.has(e)){this.keepAliveCache.set(e,t);const s=this.keepAliveKeys.indexOf(e);-1!==s&&(this.keepAliveKeys.splice(s,1),this.keepAliveKeys.push(e))}else this.keepAliveCache.set(e,t),this.keepAliveKeys.push(e),this.evictKeepAlive()}hasKeepAlive(e){return this.keepAliveCache.has(e)}evictKeepAlive(){if(this.maxKeepAlive)for(;this.keepAliveKeys.length>this.maxKeepAlive;){const e=this.keepAliveKeys.shift();e&&this.keepAliveCache.delete(e)}}cacheKey(e){return this.normalizePath(e)}prefetch(e){const t=this.matchRoute(e);if(!t)return;const s=this.cacheKey(t.fullPath),i=t.matched[t.matched.length-1];if(!i?.config.component)return;const r=i.config.component;if("function"!=typeof r)return;if(this.componentCache.has(s))return;const a=r();this.componentCache.set(s,a),a.catch(()=>{this.componentCache.delete(s)})}getComponentFromCache(e){return this.componentCache.get(this.cacheKey(e))}}exports.Router=n,exports.createRouter=function(e){return t||(t=new n(e),s&&s(t),s=null,i=null,t)},exports.getRouter=function(){return t},exports.routerReady=a;
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,s,i)=>((t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i)(t,"symbol"!=typeof s?s+"":s,i);import{IS_DEV as s}from"../shared/env.js";let i=null,a=null,r=null;function n(){return i?Promise.resolve(i):(r||(r=new Promise(e=>{a=e})),r)}const h=(()=>{const e=()=>n();return Object.defineProperties(e,{then:{value:(e,t)=>n().then(e,t),writable:!1,enumerable:!1,configurable:!0},catch:{value:e=>n().catch(e),writable:!1,enumerable:!1,configurable:!0},finally:{value:e=>n().finally(e),writable:!1,enumerable:!1,configurable:!0},[Symbol.toStringTag]:{value:"Promise",writable:!1,enumerable:!1,configurable:!0}}),e})();function o(e){return i||(i=new u(e),a&&a(i),a=null,r=null,i)}function c(){return i}const l=class e{constructor(e){t(this,"routes"),t(this,"base"),t(this,"mode"),t(this,"beforeEachGuard"),t(this,"afterEachGuard"),t(this,"currentRoute",null),t(this,"listeners",new Set),t(this,"componentCache",new Map),t(this,"keepAliveCache",new Map),t(this,"keepAliveKeys",[]),t(this,"navigationId",0),t(this,"maxKeepAlive"),t(this,"isStarted",!1),t(this,"handleRouteChange",null),this.routes=e.routes,this.base=this.normalizeBase(e.base),this.mode=e.mode||"history",this.beforeEachGuard=e.beforeEach,this.afterEachGuard=e.afterEach,this.maxKeepAlive=e.maxKeepAlive}normalizeBase(e){let t=e||"/";return t.startsWith("/")||(t="/"+t),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}matchRoute(e="/"){return this.matchRouteInternal(e,new Set,0)}matchRouteInternal(t,i,a){if(a>=e.MAX_REDIRECTS)return s&&console.error(`[Router] Too many redirects (max ${e.MAX_REDIRECTS}), last path: ${t}`),null;const r=this.normalizePath(t);if(i.has(r))return s&&console.error(`[Router] Circular redirect detected: ${r}`),null;i.add(r);const[n,h]=r.split("?"),o=n.split("/").filter(Boolean),c=this.parseQuery(h),l=this.recursiveMatch(this.routes,o);if(l){const e=l.matched[l.matched.length-1];return e.config.redirect?this.matchRouteInternal(e.config.redirect,i,a+1):{matched:l.matched,params:l.params,query:c,fullPath:r,meta:l.matched.reduce((e,t)=>({...e,...t.config.meta||{}}),{})}}return null}recursiveMatch(e,t){const s=[...e].sort((e,t)=>this.calculateScore(t.path)-this.calculateScore(e.path));for(const i of s){const e=i.path.split("/").filter(Boolean),s={};let a=!0;if(0===e.length&&0===t.length)return{matched:[{config:i,params:{}}],params:{}};for(let i=0;i<e.length;i++){const r=e[i],n=t[i];if(r.startsWith(":")){if(!n){a=!1;break}Object.defineProperty(s,r.slice(1),{value:n,writable:!0,enumerable:!0,configurable:!0})}else{if("*"===r){a=!0;break}if(r!==n){a=!1;break}}}if(a){const a=e.length,r=t.slice(a),n={config:i,params:s};if(r.length>0&&i.children){const e=this.recursiveMatch(i.children,r);if(e)return{matched:[n,...e.matched],params:{...s,...e.params}}}else if(0===r.length||e.includes("*"))return{matched:[n],params:s}}}return null}calculateScore(e="/"){const t=e.split("/").filter(Boolean);return 0===t.length?1:t.reduce((e,t)=>t.startsWith(":")?e+5:"*"===t?e+0:e+10,0)}parseQuery(e){const t={};return e?(new URLSearchParams(e).forEach((e,s)=>{Object.defineProperty(t,s,{value:e,writable:!0,enumerable:!0,configurable:!0})}),t):t}normalizePath(e="/"){const t=e&&"string"==typeof e?e:"/",s=t.indexOf("?"),i=-1===s?t:t.slice(0,s),a=-1===s?"":t.slice(s+1);let r=i;return r.startsWith("/")||(r="/"+r),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),a?`${r}?${a}`:r}getPath(){let e;try{e="hash"===this.mode?window.location.hash.slice(1)||"/":`${window.location.pathname}${window.location.search}`}catch{e="/"}const t=this.base||"/";return"/"===t||e!==t&&!e.startsWith(t+"/")||(e=e.slice(t.length)||"/"),this.normalizePath(e)}updateBrowserHistory(e="/",t){const s=this.normalizePath(e),i=this.base||"/";if("hash"===this.mode)t?window.location.replace(`#${s}`):window.location.hash=s;else{const e=i.endsWith("/")?i.slice(0,-1):i,a="/"===e?s:e+s;t?window.history.replaceState({path:a},"",a):window.history.pushState({path:a},"",a)}}async navigate(e="/",t=!1,s=!1){const i=++this.navigationId,a=this.normalizePath(e),r=this.currentRoute,n=this.matchRoute(a);if(!n)return{success:!1,error:`No route matched: ${a}`};if(r&&r.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const e=await this.beforeEachGuard(n,r);if(i!==this.navigationId)return{success:!1,cancelled:!0};if(!1===e)return{success:!1,cancelled:!0};if("string"==typeof e)return this.navigate(e,t)}catch(h){return i!==this.navigationId?{success:!1,cancelled:!0}:{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return i!==this.navigationId?{success:!1,cancelled:!0}:(this.currentRoute=n,s||this.updateBrowserHistory(a,t),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,r),{success:!0})}resolve(e="/"){const t=this.normalizePath(e);if("hash"===this.mode)return`#${t}`;const s=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===s?t:s+t}get modeType(){return this.mode}pushWithQuery(e="/",t){const s=new URLSearchParams(t).toString(),i=e.includes("?")?"&":"?";return this.push(e+(s?i+s:""))}push(e="/"){return this.navigate(e,!1)}replace(e="/"){return this.navigate(e,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}setupListeners(){this.isStarted||(this.isStarted=!0,this.handleRouteChange=()=>{this.navigate(this.getPath(),!0,!0)},"hash"===this.mode?window.addEventListener("hashchange",this.handleRouteChange):window.addEventListener("popstate",this.handleRouteChange),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0))}destroy(){this.handleRouteChange&&("hash"===this.mode?window.removeEventListener("hashchange",this.handleRouteChange):window.removeEventListener("popstate",this.handleRouteChange),this.handleRouteChange=null),this.isStarted=!1,this.listeners.clear(),this.componentCache.clear(),this.keepAliveCache.clear(),this.keepAliveKeys=[],this.currentRoute=null,i=null}getCurrentRoute(){return this.currentRoute}getKeepAlive(e){const t=this.keepAliveCache.get(e);if(t){const t=this.keepAliveKeys.indexOf(e);-1!==t&&(this.keepAliveKeys.splice(t,1),this.keepAliveKeys.push(e))}return t}setKeepAlive(e,t){if(this.keepAliveCache.has(e)){this.keepAliveCache.set(e,t);const s=this.keepAliveKeys.indexOf(e);-1!==s&&(this.keepAliveKeys.splice(s,1),this.keepAliveKeys.push(e))}else this.keepAliveCache.set(e,t),this.keepAliveKeys.push(e),this.evictKeepAlive()}hasKeepAlive(e){return this.keepAliveCache.has(e)}evictKeepAlive(){if(this.maxKeepAlive)for(;this.keepAliveKeys.length>this.maxKeepAlive;){const e=this.keepAliveKeys.shift();e&&this.keepAliveCache.delete(e)}}cacheKey(e){return this.normalizePath(e)}prefetch(e){const t=this.matchRoute(e);if(!t)return;const s=this.cacheKey(t.fullPath),i=t.matched[t.matched.length-1];if(!(null==i?void 0:i.config.component))return;const a=i.config.component;if("function"!=typeof a)return;if(this.componentCache.has(s))return;const r=a();this.componentCache.set(s,r),r.catch(()=>{this.componentCache.delete(s)})}getComponentFromCache(e){return this.componentCache.get(this.cacheKey(e))}};t(l,"MAX_REDIRECTS",20);let u=l;export{u as Router,o as createRouter,c as getRouter,h as routerReady};
1
+ import{IS_DEV as e}from"../shared/env.js";let t=null,s=null,i=null;function a(){return t?Promise.resolve(t):(i||(i=new Promise(e=>{s=e})),i)}const r=(()=>{const e=()=>a();return Object.defineProperties(e,{then:{value:(e,t)=>a().then(e,t),writable:!1,enumerable:!1,configurable:!0},catch:{value:e=>a().catch(e),writable:!1,enumerable:!1,configurable:!0},finally:{value:e=>a().finally(e),writable:!1,enumerable:!1,configurable:!0},[Symbol.toStringTag]:{value:"Promise",writable:!1,enumerable:!1,configurable:!0}}),e})();function n(e){return t||(t=new o(e),s&&s(t),s=null,i=null,t)}function h(){return t}class o{routes;base;mode;beforeEachGuard;afterEachGuard;currentRoute=null;listeners=new Set;componentCache=new Map;keepAliveCache=new Map;keepAliveKeys=[];navigationId=0;maxKeepAlive;constructor(e){this.routes=e.routes,this.base=this.normalizeBase(e.base),this.mode=e.mode||"history",this.beforeEachGuard=e.beforeEach,this.afterEachGuard=e.afterEach,this.maxKeepAlive=e.maxKeepAlive}normalizeBase(e){let t=e||"/";return t.startsWith("/")||(t="/"+t),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}static MAX_REDIRECTS=20;matchRoute(e="/"){return this.matchRouteInternal(e,new Set,0)}matchRouteInternal(t,s,i){if(i>=o.MAX_REDIRECTS)return e&&console.error(`[Router] Too many redirects (max ${o.MAX_REDIRECTS}), last path: ${t}`),null;const a=this.normalizePath(t);if(s.has(a))return e&&console.error(`[Router] Circular redirect detected: ${a}`),null;s.add(a);const[r,n]=a.split("?"),h=r.split("/").filter(Boolean),c=this.parseQuery(n),l=this.recursiveMatch(this.routes,h);if(l){const e=l.matched[l.matched.length-1];return e.config.redirect?this.matchRouteInternal(e.config.redirect,s,i+1):{matched:l.matched,params:l.params,query:c,fullPath:a,meta:l.matched.reduce((e,t)=>({...e,...t.config.meta||{}}),{})}}return null}recursiveMatch(e,t){const s=[...e].sort((e,t)=>this.calculateScore(t.path)-this.calculateScore(e.path));for(const i of s){const e=i.path.split("/").filter(Boolean),s={};let a=!0;if(0===e.length&&0===t.length)return{matched:[{config:i,params:{}}],params:{}};for(let i=0;i<e.length;i++){const r=e[i],n=t[i];if(r.startsWith(":")){if(!n){a=!1;break}Object.defineProperty(s,r.slice(1),{value:n,writable:!0,enumerable:!0,configurable:!0})}else{if("*"===r){a=!0;break}if(r!==n){a=!1;break}}}if(a){const a=e.length,r=t.slice(a),n={config:i,params:s};if(r.length>0&&i.children){const e=this.recursiveMatch(i.children,r);if(e)return{matched:[n,...e.matched],params:{...s,...e.params}}}else if(0===r.length||e.includes("*"))return{matched:[n],params:s}}}return null}calculateScore(e="/"){const t=e.split("/").filter(Boolean);return 0===t.length?1:t.reduce((e,t)=>t.startsWith(":")?e+5:"*"===t?e+0:e+10,0)}parseQuery(e){const t={};return e?(new URLSearchParams(e).forEach((e,s)=>{Object.defineProperty(t,s,{value:e,writable:!0,enumerable:!0,configurable:!0})}),t):t}normalizePath(e="/"){const t=e&&"string"==typeof e?e:"/",s=t.indexOf("?"),i=-1===s?t:t.slice(0,s),a=-1===s?"":t.slice(s+1);let r=i;return r.startsWith("/")||(r="/"+r),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),a?`${r}?${a}`:r}getPath(){let e;try{e="hash"===this.mode?window.location.hash.slice(1)||"/":`${window.location.pathname}${window.location.search}`}catch{e="/"}const t=this.base||"/";return"/"===t||e!==t&&!e.startsWith(t+"/")||(e=e.slice(t.length)||"/"),this.normalizePath(e)}updateBrowserHistory(e="/",t){const s=this.normalizePath(e),i=this.base||"/";if("hash"===this.mode)t?window.location.replace(`#${s}`):window.location.hash=s;else{const e=i.endsWith("/")?i.slice(0,-1):i,a="/"===e?s:e+s;t?window.history.replaceState({path:a},"",a):window.history.pushState({path:a},"",a)}}async navigate(e="/",t=!1,s=!1){const i=++this.navigationId,a=this.normalizePath(e),r=this.currentRoute,n=this.matchRoute(a);if(!n)return{success:!1,error:`No route matched: ${a}`};if(r&&r.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const e=await this.beforeEachGuard(n,r);if(i!==this.navigationId)return{success:!1,cancelled:!0};if(!1===e)return{success:!1,cancelled:!0};if("string"==typeof e)return this.navigate(e,t)}catch(h){return i!==this.navigationId?{success:!1,cancelled:!0}:{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return i!==this.navigationId?{success:!1,cancelled:!0}:(this.currentRoute=n,s||this.updateBrowserHistory(a,t),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,r),{success:!0})}resolve(e="/"){const t=this.normalizePath(e);if("hash"===this.mode)return`#${t}`;const s=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===s?t:s+t}get modeType(){return this.mode}pushWithQuery(e="/",t){const s=new URLSearchParams(t).toString(),i=e.includes("?")?"&":"?";return this.push(e+(s?i+s:""))}push(e="/"){return this.navigate(e,!1)}replace(e="/"){return this.navigate(e,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}isStarted=!1;handleRouteChange=null;setupListeners(){this.isStarted||(this.isStarted=!0,this.handleRouteChange=()=>{this.navigate(this.getPath(),!0,!0)},"hash"===this.mode?window.addEventListener("hashchange",this.handleRouteChange):window.addEventListener("popstate",this.handleRouteChange),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0))}destroy(){this.handleRouteChange&&("hash"===this.mode?window.removeEventListener("hashchange",this.handleRouteChange):window.removeEventListener("popstate",this.handleRouteChange),this.handleRouteChange=null),this.isStarted=!1,this.listeners.clear(),this.componentCache.clear(),this.keepAliveCache.clear(),this.keepAliveKeys=[],this.currentRoute=null,t=null}getCurrentRoute(){return this.currentRoute}getKeepAlive(e){const t=this.keepAliveCache.get(e);if(t){const t=this.keepAliveKeys.indexOf(e);-1!==t&&(this.keepAliveKeys.splice(t,1),this.keepAliveKeys.push(e))}return t}setKeepAlive(e,t){if(this.keepAliveCache.has(e)){this.keepAliveCache.set(e,t);const s=this.keepAliveKeys.indexOf(e);-1!==s&&(this.keepAliveKeys.splice(s,1),this.keepAliveKeys.push(e))}else this.keepAliveCache.set(e,t),this.keepAliveKeys.push(e),this.evictKeepAlive()}hasKeepAlive(e){return this.keepAliveCache.has(e)}evictKeepAlive(){if(this.maxKeepAlive)for(;this.keepAliveKeys.length>this.maxKeepAlive;){const e=this.keepAliveKeys.shift();e&&this.keepAliveCache.delete(e)}}cacheKey(e){return this.normalizePath(e)}prefetch(e){const t=this.matchRoute(e);if(!t)return;const s=this.cacheKey(t.fullPath),i=t.matched[t.matched.length-1];if(!i?.config.component)return;const a=i.config.component;if("function"!=typeof a)return;if(this.componentCache.has(s))return;const r=a();this.componentCache.set(s,r),r.catch(()=>{this.componentCache.delete(s)})}getComponentFromCache(e){return this.componentCache.get(this.cacheKey(e))}}export{o as Router,n as createRouter,h as getRouter,r as routerReady};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./core.cjs"),e=require("./router-link.html.cjs"),s=require("../runtime/component/base-element.cjs"),a=require("../runtime/component/decorators.cjs");var i,n=Object.defineProperty,r=(Object.getOwnPropertyDescriptor,t=>{throw TypeError(t)}),o=(t,e,s)=>((t,e,s)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),u=(t,e,s)=>e.has(t)||r("Cannot "+s);exports.default=class extends s.default{constructor(){var e,s;super(...arguments),e=this,(s=i).has(e)?r("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(e):s.set(e,false),o(this,"unsubscribe"),o(this,"mountVersion",0),o(this,"handleClick",e=>{var s,a;e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||0===e.button&&((null==(s=e.target.closest("a"))?void 0:s.getAttribute("target"))||(e.preventDefault(),null==(a=t.getRouter())||a.push(this.$data.to)))}),o(this,"handleMouseEnter",()=>{this.prefetchRoute()})}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){const e=++this.mountVersion,s=await t.routerReady();this.mountVersion===e&&(this.unsubscribe=s.listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",this.handleClick),this.addEventListener("mouseenter",this.handleMouseEnter,{once:!0}))}unmounted(){var t;this.mountVersion++,null==(t=this.unsubscribe)||t.call(this),this.unsubscribe=void 0,this.removeEventListener("click",this.handleClick),this.removeEventListener("mouseenter",this.handleMouseEnter)}updateState(){const e=t.getRouter();if(!e)return;this.$data.href=e.resolve(this.$data.to);let s=!1;if(this.$data.active)s=!0;else{const t=e.getCurrentRoute();if(t){const e=t.fullPath;if(this.hasAttribute("exact"))s=e===this.$data.to;else{const t=e.split("?")[0],a=this.$data.to.split("?")[0];s=t===a||t.startsWith(a+"/")}}}this.$data.isActive=s;const a=this.$data.activeClass||"active";this.classList.toggle(a,s)}prefetchRoute(){if(u(this,e=i,"read from private field"),e.get(this)||!this.hasAttribute("prefetch"))return;var e;const s=t.getRouter();s&&(s.prefetch(this.$data.to),((t,e)=>{u(t,e,"write to private field"),e.set(t,!0)})(this,i))}},i=new WeakMap,exports.default=((t,e)=>{for(var s,a=e,i=t.length-1;i>=0;i--)(s=t[i])&&(a=s(a)||a);return a})([a.CustomElement({tagName:"router-link",template:e.__SOLELY_IR__,styles:"\n :host {\n }\n\n a {\n text-decoration: none;\n color: inherit;\n cursor: pointer;\n }\n\n /* 内部 <a> 标签的默认高亮 */\n a.active {\n font-weight: 600;\n }\n\n /* custom 模式:消除包裹 a 标签的视觉/布局影响,由 slot 内部元素接管 */\n :host([custom]) a {\n display: contents;\n }\n ",shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],exports.default);
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./core.cjs"),e=require("./router-link.html.cjs"),s=require("../runtime/component/base-element.cjs"),r=require("../runtime/component/decorators.cjs");var i,n=Object.defineProperty,a=(Object.getOwnPropertyDescriptor,t=>{throw TypeError(t)}),o=(t,e,s)=>((t,e,s)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),u=(t,e,s)=>e.has(t)||a("Cannot "+s);exports.default=class extends s.default{constructor(){var e,s;super(...arguments),e=this,(s=i).has(e)?a("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(e):s.set(e,false),o(this,"unsubscribe"),o(this,"mountVersion",0),o(this,"handleClick",e=>{if(e.defaultPrevented)return;if(e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;if(0!==e.button)return;const s=e.target;s.closest("a")?.getAttribute("target")||(e.preventDefault(),t.getRouter()?.push(this.$data.to))}),o(this,"handleMouseEnter",()=>{this.prefetchRoute()})}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){const e=++this.mountVersion,s=await t.routerReady();this.mountVersion===e&&(this.unsubscribe=s.listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",this.handleClick),this.addEventListener("mouseenter",this.handleMouseEnter,{once:!0}))}unmounted(){this.mountVersion++,this.unsubscribe?.(),this.unsubscribe=void 0,this.removeEventListener("click",this.handleClick),this.removeEventListener("mouseenter",this.handleMouseEnter)}updateState(){const e=t.getRouter();if(!e)return;this.$data.href=e.resolve(this.$data.to);let s=!1;if(this.$data.active)s=!0;else{const t=e.getCurrentRoute();if(t){const e=t.fullPath;if(this.hasAttribute("exact"))s=e===this.$data.to;else{const t=e.split("?")[0],r=this.$data.to.split("?")[0];s=t===r||t.startsWith(r+"/")}}}this.$data.isActive=s;const r=this.$data.activeClass||"active";this.classList.toggle(r,s)}prefetchRoute(){if(u(this,e=i,"read from private field"),e.get(this)||!this.hasAttribute("prefetch"))return;var e;const s=t.getRouter();s&&(s.prefetch(this.$data.to),((t,e)=>{u(t,e,"write to private field"),e.set(t,!0)})(this,i))}},i=new WeakMap,exports.default=((t,e)=>{for(var s,r=e,i=t.length-1;i>=0;i--)(s=t[i])&&(r=s(r)||r);return r})([r.CustomElement({tagName:"router-link",template:e.__SOLELY_IR__,styles:"\n :host {\n }\n\n a {\n text-decoration: none;\n color: inherit;\n cursor: pointer;\n }\n\n /* 内部 <a> 标签的默认高亮 */\n a.active {\n font-weight: 600;\n }\n\n /* custom 模式:消除包裹 a 标签的视觉/布局影响,由 slot 内部元素接管 */\n :host([custom]) a {\n display: contents;\n }\n ",shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],exports.default);
@@ -1 +1 @@
1
- import{routerReady as t,getRouter as e}from"./core.js";import{__SOLELY_IR__ as s}from"./router-link.html.js";import i from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";var a,r=Object.defineProperty,o=(Object.getOwnPropertyDescriptor,t=>{throw TypeError(t)}),h=(t,e,s)=>((t,e,s)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),l=(t,e,s)=>e.has(t)||o("Cannot "+s);let c=class extends i{constructor(){var t,s;super(...arguments),t=this,(s=a).has(t)?o("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,false),h(this,"unsubscribe"),h(this,"mountVersion",0),h(this,"handleClick",t=>{var s,i;t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||0===t.button&&((null==(s=t.target.closest("a"))?void 0:s.getAttribute("target"))||(t.preventDefault(),null==(i=e())||i.push(this.$data.to)))}),h(this,"handleMouseEnter",()=>{this.prefetchRoute()})}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){const e=++this.mountVersion,s=await t();this.mountVersion===e&&(this.unsubscribe=s.listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",this.handleClick),this.addEventListener("mouseenter",this.handleMouseEnter,{once:!0}))}unmounted(){var t;this.mountVersion++,null==(t=this.unsubscribe)||t.call(this),this.unsubscribe=void 0,this.removeEventListener("click",this.handleClick),this.removeEventListener("mouseenter",this.handleMouseEnter)}updateState(){const t=e();if(!t)return;this.$data.href=t.resolve(this.$data.to);let s=!1;if(this.$data.active)s=!0;else{const e=t.getCurrentRoute();if(e){const t=e.fullPath;if(this.hasAttribute("exact"))s=t===this.$data.to;else{const e=t.split("?")[0],i=this.$data.to.split("?")[0];s=e===i||e.startsWith(i+"/")}}}this.$data.isActive=s;const i=this.$data.activeClass||"active";this.classList.toggle(i,s)}prefetchRoute(){if(l(this,t=a,"read from private field"),t.get(this)||!this.hasAttribute("prefetch"))return;var t;const s=e();s&&(s.prefetch(this.$data.to),((t,e)=>{l(t,e,"write to private field"),e.set(t,!0)})(this,a))}};a=new WeakMap,c=((t,e)=>{for(var s,i=e,n=t.length-1;n>=0;n--)(s=t[n])&&(i=s(i)||i);return i})([n({tagName:"router-link",template:s,styles:"\n :host {\n }\n\n a {\n text-decoration: none;\n color: inherit;\n cursor: pointer;\n }\n\n /* 内部 <a> 标签的默认高亮 */\n a.active {\n font-weight: 600;\n }\n\n /* custom 模式:消除包裹 a 标签的视觉/布局影响,由 slot 内部元素接管 */\n :host([custom]) a {\n display: contents;\n }\n ",shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],c);export{c as default};
1
+ import{routerReady as t,getRouter as e}from"./core.js";import{__SOLELY_IR__ as s}from"./router-link.html.js";import i from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";var a,r=Object.defineProperty,o=(Object.getOwnPropertyDescriptor,t=>{throw TypeError(t)}),h=(t,e,s)=>((t,e,s)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),c=(t,e,s)=>e.has(t)||o("Cannot "+s);let u=class extends i{constructor(){var t,s;super(...arguments),t=this,(s=a).has(t)?o("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,false),h(this,"unsubscribe"),h(this,"mountVersion",0),h(this,"handleClick",t=>{if(t.defaultPrevented)return;if(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)return;if(0!==t.button)return;const s=t.target;s.closest("a")?.getAttribute("target")||(t.preventDefault(),e()?.push(this.$data.to))}),h(this,"handleMouseEnter",()=>{this.prefetchRoute()})}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){const e=++this.mountVersion,s=await t();this.mountVersion===e&&(this.unsubscribe=s.listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",this.handleClick),this.addEventListener("mouseenter",this.handleMouseEnter,{once:!0}))}unmounted(){this.mountVersion++,this.unsubscribe?.(),this.unsubscribe=void 0,this.removeEventListener("click",this.handleClick),this.removeEventListener("mouseenter",this.handleMouseEnter)}updateState(){const t=e();if(!t)return;this.$data.href=t.resolve(this.$data.to);let s=!1;if(this.$data.active)s=!0;else{const e=t.getCurrentRoute();if(e){const t=e.fullPath;if(this.hasAttribute("exact"))s=t===this.$data.to;else{const e=t.split("?")[0],i=this.$data.to.split("?")[0];s=e===i||e.startsWith(i+"/")}}}this.$data.isActive=s;const i=this.$data.activeClass||"active";this.classList.toggle(i,s)}prefetchRoute(){if(c(this,t=a,"read from private field"),t.get(this)||!this.hasAttribute("prefetch"))return;var t;const s=e();s&&(s.prefetch(this.$data.to),((t,e)=>{c(t,e,"write to private field"),e.set(t,!0)})(this,a))}};a=new WeakMap,u=((t,e)=>{for(var s,i=e,n=t.length-1;n>=0;n--)(s=t[n])&&(i=s(i)||i);return i})([n({tagName:"router-link",template:s,styles:"\n :host {\n }\n\n a {\n text-decoration: none;\n color: inherit;\n cursor: pointer;\n }\n\n /* 内部 <a> 标签的默认高亮 */\n a.active {\n font-weight: 600;\n }\n\n /* custom 模式:消除包裹 a 标签的视觉/布局影响,由 slot 内部元素接管 */\n :host([custom]) a {\n display: contents;\n }\n ",shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],u);export{u as default};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,t=(t,r,o)=>((t,r,o)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o)(t,"symbol"!=typeof r?r+"":r,o);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./core.cjs"),o=require("../runtime/component/base-element.cjs"),s=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;const n=new WeakMap;exports.default=class extends o.default{constructor(){super(...arguments),t(this,"unsubscribe"),t(this,"level",0),t(this,"currentElement",null),t(this,"currentTagName",null),t(this,"managedNodes",new Set),t(this,"scheduled",!1),t(this,"latestLoadId",0),t(this,"abortController",null),t(this,"disposed",!1),t(this,"router",null)}async mounted(){this.disposed=!1,this.detectLevel(),this.router=await r.routerReady(),this.disposed||(this.unsubscribe=this.router.listen(()=>this.scheduleLoad()),this.loadRoute(this.router.getCurrentRoute()))}unmounted(){var e,t;this.disposed=!0,null==(e=this.abortController)||e.abort(),this.abortController=null,null==(t=this.unsubscribe)||t.call(this),this.clear()}scheduleLoad(){!this.router||this.scheduled||this.disposed||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,!this.disposed&&this.router&&this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let e=0,t=this.parentElement;for(;t;){const r=t.closest("router-view");if(r){if(e++,t=r.parentElement,!t){const e=r.getRootNode();t=e instanceof ShadowRoot?e.host:null}}else{const e=t.getRootNode();t=e instanceof ShadowRoot?e.host:null}}this.level=e}async loadRoute(e){var t,r;this.abortController&&(this.abortController.abort(),this.abortController=null);const o=++this.latestLoadId,s=null==e?void 0:e.matched[this.level];if(!s)return void this.handleEmptyRoute(e);const{config:n}=s;let i=n.tagName;if(!i&&"function"==typeof n.component){this.renderLoading();const s=new AbortController;this.abortController=s;try{const l=null==(r=null==(t=this.router)?void 0:t.getComponentFromCache)?void 0:r.call(t,null==e?void 0:e.fullPath),a=l?await l:await n.component();if(s.signal.aborted||o!==this.latestLoadId||this.disposed)return;i="string"==typeof a?a:a.tagName}catch(l){if(s.signal.aborted||o!==this.latestLoadId||this.disposed)return;return void this.renderError(`Load Error: ${l}`)}finally{this.abortController===s&&(this.abortController=null)}}if(o===this.latestLoadId&&!this.disposed)if(i)if(!n.forceReload&&this.currentElement&&this.currentTagName===i.toLowerCase())this.syncState(this.currentElement,(null==e?void 0:e.params)||{},(null==e?void 0:e.query)||{},n.props);else{this.clear();const t=this.getOrCreateComponent(i,n,e);this.syncState(t,(null==e?void 0:e.params)||{},(null==e?void 0:e.query)||{},n.props),this.appendManagedNode(t),this.currentElement=t,this.currentTagName=i.toLowerCase()}else this.clear()}syncState(e,t,r,o={}){const s=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=function(e){let t=n.get(e);return t||(t={routerAttrs:new Set,propKeys:new Set},n.set(e,t)),t}(e),l=new Map;Object.entries(t).forEach(([e,t])=>l.set(s(e),String(t))),Object.entries(r).forEach(([e,t])=>l.set(`query-${s(e)}`,String(t))),i.routerAttrs.forEach(t=>{l.has(t)||(e.removeAttribute(t),i.routerAttrs.delete(t))}),l.forEach((t,r)=>{e.getAttribute(r)!==t&&e.setAttribute(r,t),i.routerAttrs.add(r)});const a=new Set(Object.keys(o)),d=e;i.propKeys.forEach(e=>{a.has(e)||(d[e]=void 0)}),Object.entries(o).forEach(([e,t])=>{d[e]!==t&&(d[e]=t)}),i.propKeys=a}getOrCreateComponent(e,t,r){var o,s;if(!r)throw new Error("Route is required to create or retrieve component");const n=t.keepAliveKey?t.keepAliveKey(r,this.level):this.buildKeepAliveKey(e,r),i=t.keepAlive&&(null==(o=this.router)?void 0:o.getKeepAlive(n));if(i)return i;const l=document.createElement(e);return t.keepAlive&&(null==(s=this.router)||s.setKeepAlive(n,l)),l}buildKeepAliveKey(e,t){const r=t.matched[this.level],o=(null==r?void 0:r.config.path)??e.toLowerCase(),s=Object.values((null==r?void 0:r.params)??{});return s.length?`${this.level}:${o}:${s.join("|")}`:`${this.level}:${o}`}handleEmptyRoute(e){var t,r;if(0===this.level){this.clear();const o=null==(t=null==e?void 0:e.matched)?void 0:t[0],s=(null==(r=null==o?void 0:o.config)?void 0:r.notFoundComponent)||this.$data.notFound;if(s){const e=document.createElement(s);this.appendManagedNode(e),this.currentElement=e,this.currentTagName=s.toLowerCase()}else this.renderError("404 Not Found")}else this.clear()}appendManagedNode(e){e.parentNode!==this&&this.appendChild(e),this.managedNodes.add(e)}clear(){this.managedNodes.forEach(e=>{e.parentNode===this&&this.removeChild(e)}),this.managedNodes.clear(),this.currentElement=null,this.currentTagName=null}renderLoading(){this.clear();const e=document.createElement("div");e.style.cssText="padding:20px; color:#999;",e.textContent="Loading...",this.appendManagedNode(e)}renderError(e){this.clear();const t=document.createElement("div");t.style.cssText="padding:20px; color:#ff4d4f;",t.textContent=e,this.appendManagedNode(t)}},exports.default=((e,t)=>{for(var r,o=t,s=e.length-1;s>=0;s--)(r=e[s])&&(o=r(o)||o);return o})([s.CustomElement({tagName:"router-view",props:[{name:"notFound",type:"string",default:""}]})],exports.default);
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./core.cjs"),t=require("../runtime/component/base-element.cjs"),r=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;const o=new WeakMap;exports.default=class extends t.default{unsubscribe;level=0;currentElement=null;currentTagName=null;managedNodes=new Set;scheduled=!1;latestLoadId=0;abortController=null;disposed=!1;router=null;async mounted(){this.disposed=!1,this.detectLevel(),this.router=await e.routerReady(),this.disposed||(this.unsubscribe=this.router.listen(()=>this.scheduleLoad()),this.loadRoute(this.router.getCurrentRoute()))}unmounted(){this.disposed=!0,this.abortController?.abort(),this.abortController=null,this.unsubscribe?.(),this.clear()}scheduleLoad(){!this.router||this.scheduled||this.disposed||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,!this.disposed&&this.router&&this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let e=0,t=this.parentElement;for(;t;){const r=t.closest("router-view");if(r){if(e++,t=r.parentElement,!t){const e=r.getRootNode();t=e instanceof ShadowRoot?e.host:null}}else{const e=t.getRootNode();t=e instanceof ShadowRoot?e.host:null}}this.level=e}async loadRoute(e){this.abortController&&(this.abortController.abort(),this.abortController=null);const t=++this.latestLoadId,r=e?.matched[this.level];if(!r)return void this.handleEmptyRoute(e);const{config:o}=r;let s=o.tagName;if(!s&&"function"==typeof o.component){this.renderLoading();const r=new AbortController;this.abortController=r;try{const n=this.router?.getComponentFromCache?.(e?.fullPath),i=n?await n:await o.component();if(r.signal.aborted||t!==this.latestLoadId||this.disposed)return;s="string"==typeof i?i:i.tagName}catch(n){if(r.signal.aborted||t!==this.latestLoadId||this.disposed)return;return void this.renderError(`Load Error: ${n}`)}finally{this.abortController===r&&(this.abortController=null)}}if(t===this.latestLoadId&&!this.disposed)if(s)if(!o.forceReload&&this.currentElement&&this.currentTagName===s.toLowerCase())this.syncState(this.currentElement,e?.params||{},e?.query||{},o.props);else{this.clear();const t=this.getOrCreateComponent(s,o,e);this.syncState(t,e?.params||{},e?.query||{},o.props),this.appendManagedNode(t),this.currentElement=t,this.currentTagName=s.toLowerCase()}else this.clear()}syncState(e,t,r,s={}){const n=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=function(e){let t=o.get(e);return t||(t={routerAttrs:new Set,propKeys:new Set},o.set(e,t)),t}(e),a=new Map;Object.entries(t).forEach(([e,t])=>a.set(n(e),String(t))),Object.entries(r).forEach(([e,t])=>a.set(`query-${n(e)}`,String(t))),i.routerAttrs.forEach(t=>{a.has(t)||(e.removeAttribute(t),i.routerAttrs.delete(t))}),a.forEach((t,r)=>{e.getAttribute(r)!==t&&e.setAttribute(r,t),i.routerAttrs.add(r)});const l=new Set(Object.keys(s)),d=e;i.propKeys.forEach(e=>{l.has(e)||(d[e]=void 0)}),Object.entries(s).forEach(([e,t])=>{d[e]!==t&&(d[e]=t)}),i.propKeys=l}getOrCreateComponent(e,t,r){if(!r)throw new Error("Route is required to create or retrieve component");const o=t.keepAliveKey?t.keepAliveKey(r,this.level):this.buildKeepAliveKey(e,r),s=t.keepAlive&&this.router?.getKeepAlive(o);if(s)return s;const n=document.createElement(e);return t.keepAlive&&this.router?.setKeepAlive(o,n),n}buildKeepAliveKey(e,t){const r=t.matched[this.level],o=r?.config.path??e.toLowerCase(),s=Object.values(r?.params??{});return s.length?`${this.level}:${o}:${s.join("|")}`:`${this.level}:${o}`}handleEmptyRoute(e){if(0===this.level){this.clear();const t=e?.matched?.[0],r=t?.config?.notFoundComponent||this.$data.notFound;if(r){const e=document.createElement(r);this.appendManagedNode(e),this.currentElement=e,this.currentTagName=r.toLowerCase()}else this.renderError("404 Not Found")}else this.clear()}appendManagedNode(e){e.parentNode!==this&&this.appendChild(e),this.managedNodes.add(e)}clear(){this.managedNodes.forEach(e=>{e.parentNode===this&&this.removeChild(e)}),this.managedNodes.clear(),this.currentElement=null,this.currentTagName=null}renderLoading(){this.clear();const e=document.createElement("div");e.style.cssText="padding:20px; color:#999;",e.textContent="Loading...",this.appendManagedNode(e)}renderError(e){this.clear();const t=document.createElement("div");t.style.cssText="padding:20px; color:#ff4d4f;",t.textContent=e,this.appendManagedNode(t)}},exports.default=((e,t)=>{for(var r,o=t,s=e.length-1;s>=0;s--)(r=e[s])&&(o=r(o)||o);return o})([r.CustomElement({tagName:"router-view",props:[{name:"notFound",type:"string",default:""}]})],exports.default);
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,o,r)=>((t,o,r)=>o in t?e(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r)(t,"symbol"!=typeof o?o+"":o,r);import{routerReady as o}from"./core.js";import r from"../runtime/component/base-element.js";import{CustomElement as s}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const n=new WeakMap;let i=class extends r{constructor(){super(...arguments),t(this,"unsubscribe"),t(this,"level",0),t(this,"currentElement",null),t(this,"currentTagName",null),t(this,"managedNodes",new Set),t(this,"scheduled",!1),t(this,"latestLoadId",0),t(this,"abortController",null),t(this,"disposed",!1),t(this,"router",null)}async mounted(){this.disposed=!1,this.detectLevel(),this.router=await o(),this.disposed||(this.unsubscribe=this.router.listen(()=>this.scheduleLoad()),this.loadRoute(this.router.getCurrentRoute()))}unmounted(){var e,t;this.disposed=!0,null==(e=this.abortController)||e.abort(),this.abortController=null,null==(t=this.unsubscribe)||t.call(this),this.clear()}scheduleLoad(){!this.router||this.scheduled||this.disposed||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,!this.disposed&&this.router&&this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let e=0,t=this.parentElement;for(;t;){const o=t.closest("router-view");if(o){if(e++,t=o.parentElement,!t){const e=o.getRootNode();t=e instanceof ShadowRoot?e.host:null}}else{const e=t.getRootNode();t=e instanceof ShadowRoot?e.host:null}}this.level=e}async loadRoute(e){var t,o;this.abortController&&(this.abortController.abort(),this.abortController=null);const r=++this.latestLoadId,s=null==e?void 0:e.matched[this.level];if(!s)return void this.handleEmptyRoute(e);const{config:n}=s;let i=n.tagName;if(!i&&"function"==typeof n.component){this.renderLoading();const s=new AbortController;this.abortController=s;try{const l=null==(o=null==(t=this.router)?void 0:t.getComponentFromCache)?void 0:o.call(t,null==e?void 0:e.fullPath),a=l?await l:await n.component();if(s.signal.aborted||r!==this.latestLoadId||this.disposed)return;i="string"==typeof a?a:a.tagName}catch(l){if(s.signal.aborted||r!==this.latestLoadId||this.disposed)return;return void this.renderError(`Load Error: ${l}`)}finally{this.abortController===s&&(this.abortController=null)}}if(r===this.latestLoadId&&!this.disposed)if(i)if(!n.forceReload&&this.currentElement&&this.currentTagName===i.toLowerCase())this.syncState(this.currentElement,(null==e?void 0:e.params)||{},(null==e?void 0:e.query)||{},n.props);else{this.clear();const t=this.getOrCreateComponent(i,n,e);this.syncState(t,(null==e?void 0:e.params)||{},(null==e?void 0:e.query)||{},n.props),this.appendManagedNode(t),this.currentElement=t,this.currentTagName=i.toLowerCase()}else this.clear()}syncState(e,t,o,r={}){const s=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=function(e){let t=n.get(e);return t||(t={routerAttrs:new Set,propKeys:new Set},n.set(e,t)),t}(e),l=new Map;Object.entries(t).forEach(([e,t])=>l.set(s(e),String(t))),Object.entries(o).forEach(([e,t])=>l.set(`query-${s(e)}`,String(t))),i.routerAttrs.forEach(t=>{l.has(t)||(e.removeAttribute(t),i.routerAttrs.delete(t))}),l.forEach((t,o)=>{e.getAttribute(o)!==t&&e.setAttribute(o,t),i.routerAttrs.add(o)});const a=new Set(Object.keys(r)),d=e;i.propKeys.forEach(e=>{a.has(e)||(d[e]=void 0)}),Object.entries(r).forEach(([e,t])=>{d[e]!==t&&(d[e]=t)}),i.propKeys=a}getOrCreateComponent(e,t,o){var r,s;if(!o)throw new Error("Route is required to create or retrieve component");const n=t.keepAliveKey?t.keepAliveKey(o,this.level):this.buildKeepAliveKey(e,o),i=t.keepAlive&&(null==(r=this.router)?void 0:r.getKeepAlive(n));if(i)return i;const l=document.createElement(e);return t.keepAlive&&(null==(s=this.router)||s.setKeepAlive(n,l)),l}buildKeepAliveKey(e,t){const o=t.matched[this.level],r=(null==o?void 0:o.config.path)??e.toLowerCase(),s=Object.values((null==o?void 0:o.params)??{});return s.length?`${this.level}:${r}:${s.join("|")}`:`${this.level}:${r}`}handleEmptyRoute(e){var t,o;if(0===this.level){this.clear();const r=null==(t=null==e?void 0:e.matched)?void 0:t[0],s=(null==(o=null==r?void 0:r.config)?void 0:o.notFoundComponent)||this.$data.notFound;if(s){const e=document.createElement(s);this.appendManagedNode(e),this.currentElement=e,this.currentTagName=s.toLowerCase()}else this.renderError("404 Not Found")}else this.clear()}appendManagedNode(e){e.parentNode!==this&&this.appendChild(e),this.managedNodes.add(e)}clear(){this.managedNodes.forEach(e=>{e.parentNode===this&&this.removeChild(e)}),this.managedNodes.clear(),this.currentElement=null,this.currentTagName=null}renderLoading(){this.clear();const e=document.createElement("div");e.style.cssText="padding:20px; color:#999;",e.textContent="Loading...",this.appendManagedNode(e)}renderError(e){this.clear();const t=document.createElement("div");t.style.cssText="padding:20px; color:#ff4d4f;",t.textContent=e,this.appendManagedNode(t)}};i=((e,t)=>{for(var o,r=t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=o(r)||r);return r})([s({tagName:"router-view",props:[{name:"notFound",type:"string",default:""}]})],i);export{i as default};
1
+ import{routerReady as e}from"./core.js";import t from"../runtime/component/base-element.js";import{CustomElement as r}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const o=new WeakMap;let s=class extends t{unsubscribe;level=0;currentElement=null;currentTagName=null;managedNodes=new Set;scheduled=!1;latestLoadId=0;abortController=null;disposed=!1;router=null;async mounted(){this.disposed=!1,this.detectLevel(),this.router=await e(),this.disposed||(this.unsubscribe=this.router.listen(()=>this.scheduleLoad()),this.loadRoute(this.router.getCurrentRoute()))}unmounted(){this.disposed=!0,this.abortController?.abort(),this.abortController=null,this.unsubscribe?.(),this.clear()}scheduleLoad(){!this.router||this.scheduled||this.disposed||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,!this.disposed&&this.router&&this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let e=0,t=this.parentElement;for(;t;){const r=t.closest("router-view");if(r){if(e++,t=r.parentElement,!t){const e=r.getRootNode();t=e instanceof ShadowRoot?e.host:null}}else{const e=t.getRootNode();t=e instanceof ShadowRoot?e.host:null}}this.level=e}async loadRoute(e){this.abortController&&(this.abortController.abort(),this.abortController=null);const t=++this.latestLoadId,r=e?.matched[this.level];if(!r)return void this.handleEmptyRoute(e);const{config:o}=r;let s=o.tagName;if(!s&&"function"==typeof o.component){this.renderLoading();const r=new AbortController;this.abortController=r;try{const n=this.router?.getComponentFromCache?.(e?.fullPath),i=n?await n:await o.component();if(r.signal.aborted||t!==this.latestLoadId||this.disposed)return;s="string"==typeof i?i:i.tagName}catch(n){if(r.signal.aborted||t!==this.latestLoadId||this.disposed)return;return void this.renderError(`Load Error: ${n}`)}finally{this.abortController===r&&(this.abortController=null)}}if(t===this.latestLoadId&&!this.disposed)if(s)if(!o.forceReload&&this.currentElement&&this.currentTagName===s.toLowerCase())this.syncState(this.currentElement,e?.params||{},e?.query||{},o.props);else{this.clear();const t=this.getOrCreateComponent(s,o,e);this.syncState(t,e?.params||{},e?.query||{},o.props),this.appendManagedNode(t),this.currentElement=t,this.currentTagName=s.toLowerCase()}else this.clear()}syncState(e,t,r,s={}){const n=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=function(e){let t=o.get(e);return t||(t={routerAttrs:new Set,propKeys:new Set},o.set(e,t)),t}(e),a=new Map;Object.entries(t).forEach(([e,t])=>a.set(n(e),String(t))),Object.entries(r).forEach(([e,t])=>a.set(`query-${n(e)}`,String(t))),i.routerAttrs.forEach(t=>{a.has(t)||(e.removeAttribute(t),i.routerAttrs.delete(t))}),a.forEach((t,r)=>{e.getAttribute(r)!==t&&e.setAttribute(r,t),i.routerAttrs.add(r)});const l=new Set(Object.keys(s)),d=e;i.propKeys.forEach(e=>{l.has(e)||(d[e]=void 0)}),Object.entries(s).forEach(([e,t])=>{d[e]!==t&&(d[e]=t)}),i.propKeys=l}getOrCreateComponent(e,t,r){if(!r)throw new Error("Route is required to create or retrieve component");const o=t.keepAliveKey?t.keepAliveKey(r,this.level):this.buildKeepAliveKey(e,r),s=t.keepAlive&&this.router?.getKeepAlive(o);if(s)return s;const n=document.createElement(e);return t.keepAlive&&this.router?.setKeepAlive(o,n),n}buildKeepAliveKey(e,t){const r=t.matched[this.level],o=r?.config.path??e.toLowerCase(),s=Object.values(r?.params??{});return s.length?`${this.level}:${o}:${s.join("|")}`:`${this.level}:${o}`}handleEmptyRoute(e){if(0===this.level){this.clear();const t=e?.matched?.[0],r=t?.config?.notFoundComponent||this.$data.notFound;if(r){const e=document.createElement(r);this.appendManagedNode(e),this.currentElement=e,this.currentTagName=r.toLowerCase()}else this.renderError("404 Not Found")}else this.clear()}appendManagedNode(e){e.parentNode!==this&&this.appendChild(e),this.managedNodes.add(e)}clear(){this.managedNodes.forEach(e=>{e.parentNode===this&&this.removeChild(e)}),this.managedNodes.clear(),this.currentElement=null,this.currentTagName=null}renderLoading(){this.clear();const e=document.createElement("div");e.style.cssText="padding:20px; color:#999;",e.textContent="Loading...",this.appendManagedNode(e)}renderError(e){this.clear();const t=document.createElement("div");t.style.cssText="padding:20px; color:#ff4d4f;",t.textContent=e,this.appendManagedNode(t)}};s=((e,t)=>{for(var r,o=t,s=e.length-1;s>=0;s--)(r=e[s])&&(o=r(o)||o);return o})([r({tagName:"router-view",props:[{name:"notFound",type:"string",default:""}]})],s);export{s as default};
@@ -1 +1 @@
1
- "use strict";var t,e,s,i,a,r,n,o,h,l,c,u,d,p,f,b,m,y,v,w,S,g,M,O,$,k,j,C,W,N,A,E=Object.defineProperty,P=t=>{throw TypeError(t)},L=(t,e,s)=>e.has(t)||P("Cannot "+s),D=(t,e,s)=>(L(t,e,"read from private field"),s?s.call(t):e.get(t)),q=(t,e,s)=>e.has(t)?P("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),U=(t,e,s,i)=>(L(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),_=(t,e,s)=>(L(t,e,"access private method"),s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("../../shared/is-object.cjs"),T=require("../../shared/env.cjs"),x=require("../../shared/case-convert.cjs"),I=require("../reactivity/observe.cjs"),V=require("../renderer/renderIR.cjs"),H=Symbol.for("solely.manifest"),J=class extends HTMLElement{constructor(m={}){var y,w;super(),q(this,v),((t,e,s)=>{e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(w="$refs")?w+"":w,{}),q(this,t),q(this,e),q(this,s),q(this,i),q(this,a),q(this,r),q(this,n,!1),q(this,o,!1),q(this,h,!1),q(this,l,!1),q(this,c,!1),q(this,u,!1),q(this,d,!1),q(this,p,new Set),q(this,f,!1),q(this,b,!1);const g=this.constructor;U(this,t,g[H]||{tagName:"base-element"});const O=D(this,t);U(this,a,(null==(y=O.shadowDOM)?void 0:y.use)?this.attachShadow({mode:O.shadowDOM.mode||"open"}):this),_(this,v,S).call(this,m),_(this,v,M).call(this,O),queueMicrotask(()=>_(this,v,A).call(this))}static get observedAttributes(){const t=this[H];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return D(this,i)}set $data(t){var e;R.isObject(t)||(t={}),t!==D(this,i)&&(null==(e=D(this,r))||e.call(this),_(this,v,S).call(this,t),_(this,v,$).call(this),_(this,v,j).call(this))}refresh(){_(this,v,j).call(this)}connectedCallback(){if(D(this,f))throw this.remove(),new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);U(this,c,!0);const i=D(this,t);if(_(this,v,A).call(this),(i.className||i.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),_(this,v,W).call(this),i.attributeMap&&R.isObject(this.$data)){_(this,v,$).call(this);for(const[t,e]of i.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=_(this,v,k).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}_(this,v,w).call(this),D(this,s)&&!D(this,e)&&U(this,e,V.createRender(D(this,s),D(this,a),this)),D(this,u)&&(U(this,u,!1),_(this,v,j).call(this)),this.mounted()}disconnectedCallback(){U(this,c,!1),D(this,f)||_(this,v,N).call(this),this.unmounted()}attributeChangedCallback(e,s,i){var a;if(D(this,f)||s===i||!R.isObject(this.$data))return;if(D(this,p).has(e))return;const r=null==(a=D(this,t).attributeMap)?void 0:a.get(e);if(!r)return;const n=r.name,o=this.$data[n],l=_(this,v,k).call(this,i,r.default??o,r.type);o!==l&&(U(this,h,!0),this.$data[n]=l,this.attributeChanged(e,o,l))}emit(t,e,s){D(this,f)||this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){D(this,f)||this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(T.IS_DEV&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(T.IS_DEV&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}dispose(){var t,s;D(this,f)||(U(this,f,!0),U(this,c,!1),_(this,v,N).call(this),null==(t=D(this,e))||t.destroy(),U(this,e,void 0),null==(s=D(this,r))||s.call(this),U(this,r,void 0),this.remove())}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,r=new WeakMap,n=new WeakMap,o=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,v=new WeakSet,w=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=D(J,y),i=new Map;let a=Object.getPrototypeOf(this);for(;a&&a!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(a);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);a=Object.getPrototypeOf(a)}for(const r of t){if(s.has(r))continue;if(e.some(t=>r.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,r);if(!t||!("value"in t))continue;const a=t.value,n=i.get(r);(null==n?void 0:n.set)&&(delete this[r],this[r]=a)}},S=function(e){const{proxy:s,dispose:a}=I.observe(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,r=D(this,t),n=String(i),o=null==(s=r.propMap)?void 0:s.get(n);(null==o?void 0:o.reflect)&&_(this,v,g).call(this,o,a)}this.emit("dataChange",{...e}),_(this,v,j).call(this)});U(this,i,s),U(this,r,a)},g=function(t,e){const s=x.camelToKebab(t.name);D(this,p).add(s);try{if(null==e)return void this.removeAttribute(s);if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}}finally{D(this,p).delete(s)}},M=function(t){t.ir&&U(this,s,t.ir)},O=function(){const e=D(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;let e,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(e=Object.getOwnPropertyDescriptor(s,t.name),!e);)s=Object.getPrototypeOf(s);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},$=function(){D(this,d)||(U(this,d,!0),_(this,v,O).call(this))},k=function(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=JSON.parse(t);return Array.isArray(s)?s:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},j=function(){D(this,f)||(D(this,c)?!D(this,o)&&D(this,e)&&(U(this,o,!0),queueMicrotask(()=>{D(this,f)||(U(this,o,!1),_(this,v,C).call(this))})):U(this,u,!0))},C=function(){var t;if(!D(this,f)&&!D(this,n)&&D(this,c)){U(this,n,!0);try{D(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),null==(t=D(this,e))||t.update(),this.updated(),D(this,h)&&(this.afterAttributesUpdate(),U(this,h,!1))}finally{U(this,n,!1)}}},W=function(){var e;const s=D(this,t);if(!s.styles)return;const i=D(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i){if(!i.adoptedStyleSheets.includes(s.sheet)){const t=Array.from(i.adoptedStyleSheets);t.push(s.sheet),i.adoptedStyleSheets=t}return void U(this,b,!0)}const r=i instanceof ShadowRoot?i:document.head,n=`solely-style-${T.SOLELY_VERSION}-${s.tagName}`,o=!(null==(e=s.shadowDOM)?void 0:e.use),h="undefined"!=typeof CSS&&CSS.escape?CSS.escape(n):n.replace(/([.#:[\]()!])/g,"\\$1");if(!r.querySelector(`#${h}`)){const t=document.createElement("style");t.id=n,t.textContent=s.styles,r.appendChild(t)}if(o){const t=D(J,m).get(n)||0;D(J,m).set(n,t+1),U(this,b,!0)}},N=function(){var e,s;if(!D(this,b))return;U(this,b,!1);const i=D(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${T.SOLELY_VERSION}-${i.tagName}`,e=D(J,m).get(t)||0;if(e<=1){const e="undefined"!=typeof CSS&&CSS.escape?CSS.escape(t):t.replace(/([.#:[\]()!])/g,"\\$1");null==(s=document.head.querySelector(`#${e}`))||s.remove(),D(J,m).delete(t)}else D(J,m).set(t,e-1)}},A=function(){D(this,l)||(U(this,l,!0),this.created())},q(J,m,new Map),q(J,y,new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]));let F=J;exports.default=F;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../shared/is-object.cjs"),t=require("../../shared/env.cjs"),s=require("../../shared/case-convert.cjs"),i=require("../reactivity/observe.cjs"),r=require("../renderer/renderIR.cjs"),a=Symbol.for("solely.manifest");class o extends HTMLElement{$refs={};#e;#t;#s;#i;#r;#a;#o=!1;#n=!1;#d=!1;#h=!1;#c=!1;#l=!1;#u=!1;#p=new Set;#f=!1;#b=!1;static#y=new Map;static#m=new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]);static get observedAttributes(){const e=this[a];return e?.attributeMap?Array.from(e.attributeMap.keys()):[]}constructor(e={}){super();const t=this.constructor;this.#e=t[a]||{tagName:"base-element"};const s=this.#e;this.#r=s.shadowDOM?.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this,this.#S(e),this.#g(s),queueMicrotask(()=>this.#v())}#A(){const e=Object.getOwnPropertyNames(this),t=["#","_"],s=o.#m,i=new Map;let r=Object.getPrototypeOf(this);for(;r&&r!==HTMLElement.prototype;){const e=Object.getOwnPropertyDescriptors(r);for(const[t,s]of Object.entries(e))s.set&&!i.has(t)&&i.set(t,s);r=Object.getPrototypeOf(r)}for(const a of e){if(s.has(a))continue;if(t.some(e=>a.startsWith(e)))continue;const e=Object.getOwnPropertyDescriptor(this,a);if(!e||!("value"in e))continue;const r=e.value,o=i.get(a);o?.set&&(delete this[a],this[a]=r)}}#S(e){const{proxy:t,dispose:s}=i.observe(e,e=>{if("set"===e.type){const{key:t,newValue:s}=e,i=this.#e,r=String(t),a=i.propMap?.get(r);a?.reflect&&this.#O(a,s)}this.emit("dataChange",{...e}),this.#R()});this.#i=t,this.#a=s}#O(e,t){const i=s.camelToKebab(e.name);this.#p.add(i);try{if(null==t)return void this.removeAttribute(i);if("boolean"===e.type)t?this.setAttribute(i,""):this.removeAttribute(i);else{const e="object"==typeof t?JSON.stringify(t):String(t);this.setAttribute(i,e)}}finally{this.#p.delete(i)}}#g(e){e.ir&&(this.#s=e.ir)}#C(){const e=this.#e;if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;let e,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(e=Object.getOwnPropertyDescriptor(s,t.name),!e);)s=Object.getPrototypeOf(s);if(!e?.get&&!e?.set){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}}#$(){this.#u||(this.#u=!0,this.#C())}get $data(){return this.#i}set $data(t){e.isObject(t)||(t={}),t!==this.#i&&(this.#a?.(),this.#S(t),this.#$(),this.#R())}#w(e,t,s){if(null===e)return"boolean"!==s&&t;switch(s){case"boolean":return!0;case"number":{const s=Number(e);return isNaN(s)?t:s}case"object":try{return JSON.parse(e)}catch(i){return console.error(`[Solely] Failed to parse object value: "${e}", using default value.`,i),t}case"array":try{const s=JSON.parse(e);return Array.isArray(s)?s:t}catch(i){return console.error(`[Solely] Failed to parse array value: "${e}", using default value.`,i),t}default:return e}}#R(){this.#f||(this.#c?!this.#n&&this.#t&&(this.#n=!0,queueMicrotask(()=>{this.#f||(this.#n=!1,this.#j())})):this.#l=!0)}#j(){if(!this.#f&&!this.#o&&this.#c){this.#o=!0;try{this.#d&&this.beforeAttributesUpdate(),this.beforeUpdate(),this.#t?.update(),this.updated(),this.#d&&(this.afterAttributesUpdate(),this.#d=!1)}finally{this.#o=!1}}}refresh(){this.#R()}#M(){const e=this.#e;if(!e.styles)return;const s=this.#r;if(e.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s){if(!s.adoptedStyleSheets.includes(e.sheet)){const t=Array.from(s.adoptedStyleSheets);t.push(e.sheet),s.adoptedStyleSheets=t}return void(this.#b=!0)}const i=s instanceof ShadowRoot?s:document.head,r=`solely-style-${t.SOLELY_VERSION}-${e.tagName}`,a=!e.shadowDOM?.use,n="undefined"!=typeof CSS&&CSS.escape?CSS.escape(r):r.replace(/([.#:[\]()!])/g,"\\$1");if(!i.querySelector(`#${n}`)){const t=document.createElement("style");t.id=r,t.textContent=e.styles,i.appendChild(t)}if(a){const e=o.#y.get(r)||0;o.#y.set(r,e+1),this.#b=!0}}#N(){if(!this.#b)return;this.#b=!1;const e=this.#e;if(!e.shadowDOM?.use&&e.styles){const s=`solely-style-${t.SOLELY_VERSION}-${e.tagName}`,i=o.#y.get(s)||0;if(i<=1){const e="undefined"!=typeof CSS&&CSS.escape?CSS.escape(s):s.replace(/([.#:[\]()!])/g,"\\$1");document.head.querySelector(`#${e}`)?.remove(),o.#y.delete(s)}else o.#y.set(s,i-1)}}connectedCallback(){if(this.#f)throw this.remove(),new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);this.#c=!0;const t=this.#e;if(this.#v(),(t.className||t.tagName||"").split(" ").forEach(e=>e&&this.classList.add(e)),this.#M(),t.attributeMap&&e.isObject(this.$data)){this.#$();for(const[e,s]of t.attributeMap){const t=s.name;if(this.hasAttribute(e)){const i=this.getAttribute(e),r=this.#w(i,s.default,s.type);this.$data[t]=r}else"default"in s&&void 0===this.$data[t]&&(this.$data[t]=s.default,"boolean"===s.type&&!0===s.default&&this.setAttribute(e,""))}}this.#A(),this.#s&&!this.#t&&(this.#t=r.createRender(this.#s,this.#r,this)),this.#l&&(this.#l=!1,this.#R()),this.mounted()}disconnectedCallback(){this.#c=!1,this.#f||this.#N(),this.unmounted()}attributeChangedCallback(t,s,i){if(this.#f||s===i||!e.isObject(this.$data))return;if(this.#p.has(t))return;const r=this.#e,a=r.attributeMap?.get(t);if(!a)return;const o=a.name,n=this.$data[o],d=this.#w(i,a.default??n,a.type);n!==d&&(this.#d=!0,this.$data[o]=d,this.attributeChanged(t,n,d))}#v(){this.#h||(this.#h=!0,this.created())}emit(e,t,s){this.#f||this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t,...s}))}emitNative(e,t){this.#f||this.dispatchEvent(new Event(e,{bubbles:!0,composed:!0,...t}))}warn(e,s){if(t.IS_DEV&&e){const e=this.tagName.toLowerCase();console.warn(`[${e}] ${s}`)}}error(e,s){if(t.IS_DEV&&e){const e=this.tagName.toLowerCase();console.error(`[${e}] ${s}`)}}dispose(){this.#f||(this.#f=!0,this.#c=!1,this.#N(),this.#t?.destroy(),this.#t=void 0,this.#a?.(),this.#a=void 0,this.remove())}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(e,t,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}}exports.default=o;
@@ -1 +1 @@
1
- var t,e,s,i,a,r,o,n,h,l,c,d,u,p,f,b,m,y,v,w,g,S,M,$,O,k,C,j,W,A,N,E=Object.defineProperty,P=t=>{throw TypeError(t)},U=(t,e,s)=>e.has(t)||P("Cannot "+s),D=(t,e,s)=>(U(t,e,"read from private field"),s?s.call(t):e.get(t)),L=(t,e,s)=>e.has(t)?P("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),q=(t,e,s,i)=>(U(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),x=(t,e,s)=>(U(t,e,"access private method"),s);import{isObject as T}from"../../shared/is-object.js";import{SOLELY_VERSION as H,IS_DEV as J}from"../../shared/env.js";import{camelToKebab as R}from"../../shared/case-convert.js";import{observe as F}from"../reactivity/observe.js";import{createRender as I}from"../renderer/renderIR.js";const V=Symbol.for("solely.manifest"),_=class extends HTMLElement{constructor(m={}){var y,w;super(),L(this,v),((t,e,s)=>{e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(w="$refs")?w+"":w,{}),L(this,t),L(this,e),L(this,s),L(this,i),L(this,a),L(this,r),L(this,o,!1),L(this,n,!1),L(this,h,!1),L(this,l,!1),L(this,c,!1),L(this,d,!1),L(this,u,!1),L(this,p,new Set),L(this,f,!1),L(this,b,!1);const S=this.constructor;q(this,t,S[V]||{tagName:"base-element"});const $=D(this,t);q(this,a,(null==(y=$.shadowDOM)?void 0:y.use)?this.attachShadow({mode:$.shadowDOM.mode||"open"}):this),x(this,v,g).call(this,m),x(this,v,M).call(this,$),queueMicrotask(()=>x(this,v,N).call(this))}static get observedAttributes(){const t=this[V];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return D(this,i)}set $data(t){var e;T(t)||(t={}),t!==D(this,i)&&(null==(e=D(this,r))||e.call(this),x(this,v,g).call(this,t),x(this,v,O).call(this),x(this,v,C).call(this))}refresh(){x(this,v,C).call(this)}connectedCallback(){if(D(this,f))throw this.remove(),new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);q(this,c,!0);const i=D(this,t);if(x(this,v,N).call(this),(i.className||i.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),x(this,v,W).call(this),i.attributeMap&&T(this.$data)){x(this,v,O).call(this);for(const[t,e]of i.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=x(this,v,k).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}x(this,v,w).call(this),D(this,s)&&!D(this,e)&&q(this,e,I(D(this,s),D(this,a),this)),D(this,d)&&(q(this,d,!1),x(this,v,C).call(this)),this.mounted()}disconnectedCallback(){q(this,c,!1),D(this,f)||x(this,v,A).call(this),this.unmounted()}attributeChangedCallback(e,s,i){var a;if(D(this,f)||s===i||!T(this.$data))return;if(D(this,p).has(e))return;const r=null==(a=D(this,t).attributeMap)?void 0:a.get(e);if(!r)return;const o=r.name,n=this.$data[o],l=x(this,v,k).call(this,i,r.default??n,r.type);n!==l&&(q(this,h,!0),this.$data[o]=l,this.attributeChanged(e,n,l))}emit(t,e,s){D(this,f)||this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){D(this,f)||this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(J&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(J&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}dispose(){var t,s;D(this,f)||(q(this,f,!0),q(this,c,!1),x(this,v,A).call(this),null==(t=D(this,e))||t.destroy(),q(this,e,void 0),null==(s=D(this,r))||s.call(this),q(this,r,void 0),this.remove())}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,r=new WeakMap,o=new WeakMap,n=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,p=new WeakMap,f=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,v=new WeakSet,w=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=D(_,y),i=new Map;let a=Object.getPrototypeOf(this);for(;a&&a!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(a);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);a=Object.getPrototypeOf(a)}for(const r of t){if(s.has(r))continue;if(e.some(t=>r.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,r);if(!t||!("value"in t))continue;const a=t.value,o=i.get(r);(null==o?void 0:o.set)&&(delete this[r],this[r]=a)}},g=function(e){const{proxy:s,dispose:a}=F(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,r=D(this,t),o=String(i),n=null==(s=r.propMap)?void 0:s.get(o);(null==n?void 0:n.reflect)&&x(this,v,S).call(this,n,a)}this.emit("dataChange",{...e}),x(this,v,C).call(this)});q(this,i,s),q(this,r,a)},S=function(t,e){const s=R(t.name);D(this,p).add(s);try{if(null==e)return void this.removeAttribute(s);if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}}finally{D(this,p).delete(s)}},M=function(t){t.ir&&q(this,s,t.ir)},$=function(){const e=D(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;let e,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(e=Object.getOwnPropertyDescriptor(s,t.name),!e);)s=Object.getPrototypeOf(s);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},O=function(){D(this,u)||(q(this,u,!0),x(this,v,$).call(this))},k=function(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=JSON.parse(t);return Array.isArray(s)?s:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},C=function(){D(this,f)||(D(this,c)?!D(this,n)&&D(this,e)&&(q(this,n,!0),queueMicrotask(()=>{D(this,f)||(q(this,n,!1),x(this,v,j).call(this))})):q(this,d,!0))},j=function(){var t;if(!D(this,f)&&!D(this,o)&&D(this,c)){q(this,o,!0);try{D(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),null==(t=D(this,e))||t.update(),this.updated(),D(this,h)&&(this.afterAttributesUpdate(),q(this,h,!1))}finally{q(this,o,!1)}}},W=function(){var e;const s=D(this,t);if(!s.styles)return;const i=D(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i){if(!i.adoptedStyleSheets.includes(s.sheet)){const t=Array.from(i.adoptedStyleSheets);t.push(s.sheet),i.adoptedStyleSheets=t}return void q(this,b,!0)}const r=i instanceof ShadowRoot?i:document.head,o=`solely-style-${H}-${s.tagName}`,n=!(null==(e=s.shadowDOM)?void 0:e.use),h="undefined"!=typeof CSS&&CSS.escape?CSS.escape(o):o.replace(/([.#:[\]()!])/g,"\\$1");if(!r.querySelector(`#${h}`)){const t=document.createElement("style");t.id=o,t.textContent=s.styles,r.appendChild(t)}if(n){const t=D(_,m).get(o)||0;D(_,m).set(o,t+1),q(this,b,!0)}},A=function(){var e,s;if(!D(this,b))return;q(this,b,!1);const i=D(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${H}-${i.tagName}`,e=D(_,m).get(t)||0;if(e<=1){const e="undefined"!=typeof CSS&&CSS.escape?CSS.escape(t):t.replace(/([.#:[\]()!])/g,"\\$1");null==(s=document.head.querySelector(`#${e}`))||s.remove(),D(_,m).delete(t)}else D(_,m).set(t,e-1)}},N=function(){D(this,l)||(q(this,l,!0),this.created())},L(_,m,new Map),L(_,y,new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]));let z=_;export{z as default};
1
+ import{isObject as t}from"../../shared/is-object.js";import{SOLELY_VERSION as e,IS_DEV as s}from"../../shared/env.js";import{camelToKebab as i}from"../../shared/case-convert.js";import{observe as r}from"../reactivity/observe.js";import{createRender as a}from"../renderer/renderIR.js";const o=Symbol.for("solely.manifest");class n extends HTMLElement{$refs={};#t;#e;#s;#i;#r;#a;#o=!1;#n=!1;#d=!1;#h=!1;#c=!1;#l=!1;#u=!1;#p=new Set;#f=!1;#m=!1;static#b=new Map;static#y=new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]);static get observedAttributes(){const t=this[o];return t?.attributeMap?Array.from(t.attributeMap.keys()):[]}constructor(t={}){super();const e=this.constructor;this.#t=e[o]||{tagName:"base-element"};const s=this.#t;this.#r=s.shadowDOM?.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this,this.#g(t),this.#v(s),queueMicrotask(()=>this.#S())}#A(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=n.#y,i=new Map;let r=Object.getPrototypeOf(this);for(;r&&r!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(r);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);r=Object.getPrototypeOf(r)}for(const a of t){if(s.has(a))continue;if(e.some(t=>a.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,a);if(!t||!("value"in t))continue;const r=t.value,o=i.get(a);o?.set&&(delete this[a],this[a]=r)}}#g(t){const{proxy:e,dispose:s}=r(t,t=>{if("set"===t.type){const{key:e,newValue:s}=t,i=this.#t,r=String(e),a=i.propMap?.get(r);a?.reflect&&this.#O(a,s)}this.emit("dataChange",{...t}),this.#C()});this.#i=e,this.#a=s}#O(t,e){const s=i(t.name);this.#p.add(s);try{if(null==e)return void this.removeAttribute(s);if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}}finally{this.#p.delete(s)}}#v(t){t.ir&&(this.#s=t.ir)}#R(){const t=this.#t;if(t.attributeMap)for(const[,e]of t.attributeMap){if(!1===e.reactive)continue;let t,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(t=Object.getOwnPropertyDescriptor(s,e.name),!t);)s=Object.getPrototypeOf(s);if(!t?.get&&!t?.set){const t=Object.getOwnPropertyDescriptor(this,e.name);t&&"value"in t&&(this.$data[e.name]=t.value,delete this[e.name]),Object.defineProperty(this,e.name,{get:()=>this.$data[e.name],set:t=>{this.$data[e.name]=t},configurable:!0,enumerable:!0})}}}#$(){this.#u||(this.#u=!0,this.#R())}get $data(){return this.#i}set $data(e){t(e)||(e={}),e!==this.#i&&(this.#a?.(),this.#g(e),this.#$(),this.#C())}#w(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=JSON.parse(t);return Array.isArray(s)?s:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}}#C(){this.#f||(this.#c?!this.#n&&this.#e&&(this.#n=!0,queueMicrotask(()=>{this.#f||(this.#n=!1,this.#j())})):this.#l=!0)}#j(){if(!this.#f&&!this.#o&&this.#c){this.#o=!0;try{this.#d&&this.beforeAttributesUpdate(),this.beforeUpdate(),this.#e?.update(),this.updated(),this.#d&&(this.afterAttributesUpdate(),this.#d=!1)}finally{this.#o=!1}}}refresh(){this.#C()}#M(){const t=this.#t;if(!t.styles)return;const s=this.#r;if(t.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s){if(!s.adoptedStyleSheets.includes(t.sheet)){const e=Array.from(s.adoptedStyleSheets);e.push(t.sheet),s.adoptedStyleSheets=e}return void(this.#m=!0)}const i=s instanceof ShadowRoot?s:document.head,r=`solely-style-${e}-${t.tagName}`,a=!t.shadowDOM?.use,o="undefined"!=typeof CSS&&CSS.escape?CSS.escape(r):r.replace(/([.#:[\]()!])/g,"\\$1");if(!i.querySelector(`#${o}`)){const e=document.createElement("style");e.id=r,e.textContent=t.styles,i.appendChild(e)}if(a){const t=n.#b.get(r)||0;n.#b.set(r,t+1),this.#m=!0}}#N(){if(!this.#m)return;this.#m=!1;const t=this.#t;if(!t.shadowDOM?.use&&t.styles){const s=`solely-style-${e}-${t.tagName}`,i=n.#b.get(s)||0;if(i<=1){const t="undefined"!=typeof CSS&&CSS.escape?CSS.escape(s):s.replace(/([.#:[\]()!])/g,"\\$1");document.head.querySelector(`#${t}`)?.remove(),n.#b.delete(s)}else n.#b.set(s,i-1)}}connectedCallback(){if(this.#f)throw this.remove(),new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);this.#c=!0;const e=this.#t;if(this.#S(),(e.className||e.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),this.#M(),e.attributeMap&&t(this.$data)){this.#$();for(const[t,s]of e.attributeMap){const e=s.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),r=this.#w(i,s.default,s.type);this.$data[e]=r}else"default"in s&&void 0===this.$data[e]&&(this.$data[e]=s.default,"boolean"===s.type&&!0===s.default&&this.setAttribute(t,""))}}this.#A(),this.#s&&!this.#e&&(this.#e=a(this.#s,this.#r,this)),this.#l&&(this.#l=!1,this.#C()),this.mounted()}disconnectedCallback(){this.#c=!1,this.#f||this.#N(),this.unmounted()}attributeChangedCallback(e,s,i){if(this.#f||s===i||!t(this.$data))return;if(this.#p.has(e))return;const r=this.#t,a=r.attributeMap?.get(e);if(!a)return;const o=a.name,n=this.$data[o],d=this.#w(i,a.default??n,a.type);n!==d&&(this.#d=!0,this.$data[o]=d,this.attributeChanged(e,n,d))}#S(){this.#h||(this.#h=!0,this.created())}emit(t,e,s){this.#f||this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){this.#f||this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(s&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(s&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}dispose(){this.#f||(this.#f=!0,this.#c=!1,this.#N(),this.#e?.destroy(),this.#e=void 0,this.#a?.(),this.#a=void 0,this.remove())}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}}export{n as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../shared/case-convert.cjs"),o=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const{tagName:c}=l;if(a&&!(s.prototype instanceof HTMLElement)&&s!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${s.name||"anonymous class"}`);if(a&&customElements.get(c))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${c}" 已经被注册,跳过重复定义。`),s[n]=l,s;if("string"!=typeof l.template||l.ir){if(l.template&&!l.ir)if("object"==typeof l.template&&null!==l.template){const t=l.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(l.ir=t,e.IS_DEV&&console.info(`[Solely] Using precompiled IR for <${c}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${c}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${c}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof l.template}`)}else if(l.template.trim())try{const e=o.parseHtml(l.template);l.ir=r.buildIR(e,{source:l.template,filename:c})}catch(p){const t=p instanceof Error?p:new Error(String(p));console.error(`[Compiler Error] <${c}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${l.template.length} 字符`,e.IS_DEV?t.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${c}>: 模板为空字符串`);if(a&&l.styles&&!l.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(l.styles),l.sheet=e)}catch{e.IS_DEV&&console.warn(`[Solely] <${c}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(l.props&&!l.attributeMap){const e=new Map,o=new Map;l.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,s=t.camelToKebab(n.name),l=n.name,a={...n,name:l};e.set(s,a),o.set(l,a)}),l.attributeMap=e,l.propMap=o}class i extends s{}if(i[n]=l,a){if(e.IS_DEV){const e=s.prototype,t=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&console.error(`[${c}] 禁止重写 ${o}(),请使用框架钩子`)}customElements.define(c,i)}return i}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../shared/case-convert.cjs"),o=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const c=s,{tagName:i}=l,p="undefined"!=typeof HTMLElement&&!(s.prototype instanceof HTMLElement)&&s!==HTMLElement;if(a&&p)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${s.name||"anonymous class"}`);if(a&&customElements.get(i))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${i}" 已经被注册,跳过重复定义。`),s[n]=l,s;if("string"!=typeof l.template||l.ir){if(l.template&&!l.ir)if("object"==typeof l.template&&null!==l.template){const t=l.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(l.ir=t,e.IS_DEV&&console.info(`[Solely] Using precompiled IR for <${i}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${i}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${i}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof l.template}`)}else if(l.template.trim())try{const e=o.parseHtml(l.template);l.ir=r.buildIR(e,{source:l.template,filename:i})}catch(f){const t=f instanceof Error?f:new Error(String(f));console.error(`[Compiler Error] <${i}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${l.template.length} 字符`,e.IS_DEV?t.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${i}>: 模板为空字符串`);if(a&&l.styles&&!l.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(l.styles),l.sheet=e)}catch{e.IS_DEV&&console.warn(`[Solely] <${i}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(l.props&&!l.attributeMap){const e=new Map,o=new Map;l.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,s=t.camelToKebab(n.name),l=n.name,a={...n,name:l};e.set(s,a),o.set(l,a)}),l.attributeMap=e,l.propMap=o}class m extends c{}if(m[n]=l,a){if(e.IS_DEV){const e=s.prototype,t=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&console.error(`[${i}] 禁止重写 ${o}(),请使用框架钩子`)}customElements.define(i,m)}return m}};
@@ -1 +1 @@
1
- import{IS_DEV as e}from"../../shared/env.js";import{camelToKebab as t}from"../../shared/case-convert.js";import{parseHtml as o}from"../../compiler/parser/parser.js";import{buildIR as r}from"../../compiler/ir/buildIR.js";const n=Symbol.for("solely.manifest"),s=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const{tagName:c}=l;if(a&&!(s.prototype instanceof HTMLElement)&&s!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${s.name||"anonymous class"}`);if(a&&customElements.get(c))return e&&console.warn(`[Solely] 标签名称 "${c}" 已经被注册,跳过重复定义。`),s[n]=l,s;if("string"!=typeof l.template||l.ir){if(l.template&&!l.ir)if("object"==typeof l.template&&null!==l.template){const t=l.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(l.ir=t,e&&console.info(`[Solely] Using precompiled IR for <${c}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${c}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${c}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof l.template}`)}else if(l.template.trim())try{const e=o(l.template);l.ir=r(e,{source:l.template,filename:c})}catch(p){const t=p instanceof Error?p:new Error(String(p));console.error(`[Compiler Error] <${c}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${l.template.length} 字符`,e?t.stack:"")}else e&&console.warn(`[Solely] <${c}>: 模板为空字符串`);if(a&&l.styles&&!l.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(l.styles),l.sheet=e)}catch{e&&console.warn(`[Solely] <${c}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(l.props&&!l.attributeMap){const e=new Map,o=new Map;l.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,s=t(n.name),l=n.name,a={...n,name:l};e.set(s,a),o.set(l,a)}),l.attributeMap=e,l.propMap=o}class i extends s{}if(i[n]=l,a){if(e){const e=s.prototype,t=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&console.error(`[${c}] 禁止重写 ${o}(),请使用框架钩子`)}customElements.define(c,i)}return i}};export{s as CustomElement};
1
+ import{IS_DEV as e}from"../../shared/env.js";import{camelToKebab as t}from"../../shared/case-convert.js";import{parseHtml as o}from"../../compiler/parser/parser.js";import{buildIR as n}from"../../compiler/ir/buildIR.js";const r=Symbol.for("solely.manifest"),s=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const c=s,{tagName:i}=l,p="undefined"!=typeof HTMLElement&&!(s.prototype instanceof HTMLElement)&&s!==HTMLElement;if(a&&p)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${s.name||"anonymous class"}`);if(a&&customElements.get(i))return e&&console.warn(`[Solely] 标签名称 "${i}" 已经被注册,跳过重复定义。`),s[r]=l,s;if("string"!=typeof l.template||l.ir){if(l.template&&!l.ir)if("object"==typeof l.template&&null!==l.template){const t=l.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(l.ir=t,e&&console.info(`[Solely] Using precompiled IR for <${i}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${i}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${i}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof l.template}`)}else if(l.template.trim())try{const e=o(l.template);l.ir=n(e,{source:l.template,filename:i})}catch(f){const t=f instanceof Error?f:new Error(String(f));console.error(`[Compiler Error] <${i}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${l.template.length} 字符`,e?t.stack:"")}else e&&console.warn(`[Solely] <${i}>: 模板为空字符串`);if(a&&l.styles&&!l.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(l.styles),l.sheet=e)}catch{e&&console.warn(`[Solely] <${i}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(l.props&&!l.attributeMap){const e=new Map,o=new Map;l.props.forEach(n=>{const r="string"==typeof n?{name:n}:n,s=t(r.name),l=r.name,a={...r,name:l};e.set(s,a),o.set(l,a)}),l.attributeMap=e,l.propMap=o}class m extends c{}if(m[r]=l,a){if(e){const e=s.prototype,t=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&console.error(`[${i}] 禁止重写 ${o}(),请使用框架钩子`)}customElements.define(i,m)}return m}};export{s as CustomElement};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/is-object.cjs"),t=Symbol("solely.raw"),n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap;function c(e,t,n){l(e,t);let r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,n);let o=s.get(n);o||(o=[],s.set(n,o)),o.some(n=>n.parentRef.deref()===e&&n.key===t)||o.push({parentRef:new WeakRef(e),key:t})}function l(e,t){const n=i.get(e);if(!n)return;const r=n.get(t);if(!r)return;n.delete(t);const o=s.get(r);if(o){const n=o.filter(n=>{const r=n.parentRef.deref();return void 0!==r&&!(r===e&&n.key===t)});0===n.length?s.delete(r):s.set(r,n)}}function a(t,n){const r=i.get(n);if(r)for(const e of r.keys())l(n,e);for(let o=0;o<t.length;o++){const r=t[o];e.isObject(r)&&!p(r)&&c(n,String(o),m(r))}}function f(e){if(e&&"object"==typeof e){const n=e[t];if(n)return n}return e}const u=Object.prototype.toString,p=e=>{if(!e||"object"!=typeof e)return!1;const t=u.call(e);return"[object Date]"===t||"[object RegExp]"===t||"[object Map]"===t||"[object Set]"===t||"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Response&&e instanceof Response||"undefined"!=typeof Request&&e instanceof Request};function y(e){return!(!e||!e[t])}const h=new Map,d=(e,t)=>{if(0===t.length)return!0;const n=e.map(String);for(let r=n.length;r>0;r--){const e=n.slice(0,r).join(".");if(t.some(t=>t.test(e)))return!0}return!1},g=(e,t)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!g(e[n],t[n]))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Reflect.ownKeys(e),r=Reflect.ownKeys(t);if(n.length!==r.length)return!1;for(const o of n){if(!Reflect.has(t,o))return!1;if(!g(e[o],t[o]))return!1}return!0},b=(e,t)=>{e.active&&(e.deepCompare&&"set"===t.type&&g(t.oldValue,t.newValue)||(e.throttle>0?(e.pending.push(t),e.timer||(e.timer=setTimeout(()=>{if(!e.active)return;const t=[...e.pending];e.pending=[],e.timer=null,t.length>0&&(e.onBatch?e.onBatch(t):e.callback(t[t.length-1]))},e.throttle))):e.onBatch?e.onBatch([t]):e.callback(t)))},v=(e,t)=>{const n=[{node:e,relativePath:[],visited:new Set([e])}];let o=0;for(;o<n.length;){const{node:e,relativePath:i,visited:c}=n[o++],l=r.get(e);l&&l.forEach(e=>{if(!e.active)return;let n=i;if("set"===t.type||"delete"===t.type?n=[...i,t.key]:"array-push"!==t.type&&"array-splice"!==t.type||(n=[...i,String(t.index)]),!d(n,e.filterRegexes))return;const r={...t,path:n};b(e,r)});const a=s.get(e);if(a)for(let t=a.length-1;t>=0;t--){const e=a[t],r=e.parentRef.deref();if(!r){a.splice(t,1);continue}if(c.has(r))continue;const o=new Set(c);o.add(r),n.push({node:r,relativePath:[e.key,...i],visited:o})}}},R={};["push","pop","shift","unshift","splice"].forEach(t=>{R[t]=function(...n){const r=this,i=f(r),s=o.get(r)||0;o.set(r,s+1);try{const o=i.length,s=i[t].apply(i,n);if("push"===t){const t=i.length-n.length;for(let o=0;o<n.length;o++){const n=i[t+o];e.isObject(n)&&!p(n)&&c(r,String(t+o),m(n))}v(r,{type:"array-push",index:t,values:n})}else if("pop"===t)l(r,String(o-1)),v(r,{type:"array-splice",index:o-1,deleteCount:1,insert:[]});else if(a(i,r),"unshift"===t)v(r,{type:"array-push",index:0,values:n});else if("shift"===t)v(r,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if("splice"===t){const[e,t,...o]=n;v(r,{type:"array-splice",index:e,deleteCount:t,insert:o})}return s}finally{o.set(r,s)}}}),["sort","reverse","fill","copyWithin"].forEach(e=>{R[e]=function(...t){const n=this,r=f(n),i=o.get(n)||0;o.set(n,i+1);try{const o=r[e].apply(r,t);return a(r,n),v(n,{type:"array-reset",method:e}),o}finally{o.set(n,i)}}}),["indexOf","lastIndexOf","includes"].forEach(e=>{R[e]=function(t,...n){const r=f(this);let o=r[e].apply(r,[t,...n]);return-1!==o&&!1!==o||!y(t)||(o=r[e].apply(r,[f(t),...n])),o}});const j={get(n,r,o){var s;if(r===t)return n;if(Array.isArray(n)&&Object.prototype.hasOwnProperty.call(R,r))return Reflect.get(R,r,o);const l=Reflect.get(n,r,o);if("symbol"==typeof r)return l;if(e.isObject(l)&&!p(l)){const e=m(l);return(null==(s=i.get(o))?void 0:s.get(r))!==e&&c(o,r,e),e}return l},set(t,n,r,i){const s=Reflect.get(t,n,i),a=f(r);if(Object.is(s,a))return!0;const u=Reflect.set(t,n,a,i);return!!u&&(e.isObject(a)&&!p(a)?c(i,n,m(a)):l(i,n),0===(o.get(i)||0)&&(!Array.isArray(t)&&Array.isArray(s)&&Array.isArray(a)?v(i,{type:"array-replace",oldValue:s,newValue:a}):v(i,{type:"set",key:n,newValue:a,oldValue:s})),u)},deleteProperty(e,t){if(!Reflect.has(e,t))return!1;const r=Reflect.get(e,t),i=Reflect.deleteProperty(e,t);if(i){const i=n.get(e);i&&(l(i,t),0===(o.get(i)||0)&&v(i,{type:"delete",key:t,oldValue:r}))}return i}};function m(e){if(!Object.isExtensible(e))return e;if(p(e))return e;if(e[t])return e;const r=n.get(e);if(r)return r;const o=new Proxy(e,j);return n.set(e,o),o}exports.isProxy=y,exports.observe=function(t,n,o={}){const{throttle:i=0,onBatch:s,immediate:c=!1,deepCompare:l}=o,a={callback:n,onBatch:s,throttle:i,filterRegexes:(Array.isArray(o.filter)?o.filter:o.filter?[o.filter]:[]).map(e=>{if(""===e)return/^.*$/;const t=h.get(e);if(t)return t;let n="";for(let c=0;c<e.length;c++){const t=e[c];"*"===t&&"*"===e[c+1]?(n+="**",c++):"*"===t?n+="*":"."===t?n+=".":/[.*+?^${}()|[\]\\]/.test(t)?n+="\\"+t:n+=t}const r=n.split("."),o=[];for(let c=0;c<r.length;c++){const e=r[c];"**"===e?1===r.length?o.push(".*"):0===c?o.push("(?:[^.]+\\.)*"):o.push("(?:\\.[^.]+)*"):"*"===e?o.push("[^.]+"):o.push(e)}let i="^";for(let c=0;c<o.length;c++)if(i+=o[c],c<o.length-1){const e=o[c],t=o[c+1];if(e.endsWith("\\.)*"))continue;if(t.startsWith("(?:\\."))continue;i+="\\."}i+="$";const s=new RegExp(i);return h.set(e,s),s}),pending:[],timer:null,active:!0,deepCompare:l},u=m(t);let y=r.get(u);if(y||(y=new Set,r.set(u,y)),y.add(a),c){const n=[...y],r=(t,o,i=[],s=new WeakSet)=>{e.isObject(t)&&!s.has(t)&&(s.add(t),Reflect.ownKeys(t).forEach(c=>{const l=Reflect.get(t,c);if(e.isObject(l)&&s.has(l))return;const a=Reflect.get(o,c),f=[...i,c];n.forEach(e=>{d(f,e.filterRegexes)&&b(e,{type:"set",key:c,newValue:l,oldValue:void 0,path:f})}),e.isObject(l)&&!p(l)&&r(l,a,f,s)}))};r(f(t),u)}const g=()=>{const e=r.get(u);e&&(e.delete(a),0===e.size&&r.delete(u)),a.pending=[],a.timer&&(clearTimeout(a.timer),a.timer=null)};return{proxy:u,unobserve:()=>{a.active&&(a.active=!1,g())},resume:()=>{a.active||(a.active=!0,(()=>{let e=r.get(u);e||(e=new Set,r.set(u,e)),e.add(a)})())},dispose:()=>{if(!a.active)return a.callback=()=>{},void(a.onBatch=void 0);a.active=!1,g(),a.callback=()=>{},a.onBatch=void 0}}},exports.toProxy=function(e){return e&&"object"==typeof e&&"proxy"in e?e.proxy:e},exports.toRaw=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/is-object.cjs"),t=Symbol("solely.raw"),n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap;function c(e,t,n){l(e,t);let r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,n);let o=s.get(n);o||(o=[],s.set(n,o)),o.some(n=>n.parentRef.deref()===e&&n.key===t)||o.push({parentRef:new WeakRef(e),key:t})}function l(e,t){const n=i.get(e);if(!n)return;const r=n.get(t);if(!r)return;n.delete(t);const o=s.get(r);if(o){const n=o.filter(n=>{const r=n.parentRef.deref();return void 0!==r&&!(r===e&&n.key===t)});0===n.length?s.delete(r):s.set(r,n)}}function a(t,n){const r=i.get(n);if(r)for(const e of r.keys())l(n,e);for(let o=0;o<t.length;o++){const r=t[o];e.isObject(r)&&!p(r)&&c(n,String(o),w(r))}}function f(e){if(e&&"object"==typeof e){const n=e[t];if(n)return n}return e}const u=Object.prototype.toString,p=e=>{if(!e||"object"!=typeof e)return!1;const t=u.call(e);return"[object Date]"===t||"[object RegExp]"===t||"[object Map]"===t||"[object Set]"===t||"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Response&&e instanceof Response||"undefined"!=typeof Request&&e instanceof Request};function y(e){return!(!e||!e[t])}const h=new Map,d=(e,t)=>{if(0===t.length)return!0;const n=e.map(String);for(let r=n.length;r>0;r--){const e=n.slice(0,r).join(".");if(t.some(t=>t.test(e)))return!0}return!1},g=(e,t)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!g(e[n],t[n]))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Reflect.ownKeys(e),r=Reflect.ownKeys(t);if(n.length!==r.length)return!1;for(const o of n){if(!Reflect.has(t,o))return!1;const n=e[o],r=t[o];if(!g(n,r))return!1}return!0},b=(e,t)=>{e.active&&(e.deepCompare&&"set"===t.type&&g(t.oldValue,t.newValue)||(e.throttle>0?(e.pending.push(t),e.timer||(e.timer=setTimeout(()=>{if(!e.active)return;const t=[...e.pending];e.pending=[],e.timer=null,t.length>0&&(e.onBatch?e.onBatch(t):e.callback(t[t.length-1]))},e.throttle))):e.onBatch?e.onBatch([t]):e.callback(t)))},R=(e,t)=>{const n=[{node:e,relativePath:[],visited:new Set([e])}];let o=0;for(;o<n.length;){const{node:e,relativePath:i,visited:c}=n[o++],l=r.get(e);l&&l.forEach(e=>{if(!e.active)return;let n=i;if("set"===t.type||"delete"===t.type?n=[...i,t.key]:"array-push"!==t.type&&"array-splice"!==t.type||(n=[...i,String(t.index)]),!d(n,e.filterRegexes))return;const r={...t,path:n};b(e,r)});const a=s.get(e);if(a)for(let t=a.length-1;t>=0;t--){const e=a[t],r=e.parentRef.deref();if(!r){a.splice(t,1);continue}if(c.has(r))continue;const o=new Set(c);o.add(r),n.push({node:r,relativePath:[e.key,...i],visited:o})}}},v={},j=(e,t)=>e[t];["push","pop","shift","unshift","splice"].forEach(t=>{v[t]=function(...n){const r=this,i=f(r),s=o.get(r)||0;o.set(r,s+1);try{const o=i.length,s=j(i,t).apply(i,n);if("push"===t){const t=i.length-n.length;for(let o=0;o<n.length;o++){const n=i[t+o];e.isObject(n)&&!p(n)&&c(r,String(t+o),w(n))}R(r,{type:"array-push",index:t,values:n})}else if("pop"===t)l(r,String(o-1)),R(r,{type:"array-splice",index:o-1,deleteCount:1,insert:[]});else if(a(i,r),"unshift"===t)R(r,{type:"array-push",index:0,values:n});else if("shift"===t)R(r,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if("splice"===t){const[e,t,...o]=n;R(r,{type:"array-splice",index:e,deleteCount:t,insert:o})}return s}finally{o.set(r,s)}}}),["sort","reverse","fill","copyWithin"].forEach(e=>{v[e]=function(...t){const n=this,r=f(n),i=o.get(n)||0;o.set(n,i+1);try{const o=j(r,e).apply(r,t);return a(r,n),R(n,{type:"array-reset",method:e}),o}finally{o.set(n,i)}}}),["indexOf","lastIndexOf","includes"].forEach(e=>{v[e]=function(t,...n){const r=f(this),o=j(r,e);let i=o.apply(r,[t,...n]);return-1!==i&&!1!==i||!y(t)||(i=o.apply(r,[f(t),...n])),i}});const m={get(n,r,o){if(r===t)return n;if(Array.isArray(n)&&Object.prototype.hasOwnProperty.call(v,r))return Reflect.get(v,r,o);const s=Reflect.get(n,r,o);if("symbol"==typeof r)return s;if(e.isObject(s)&&!p(s)){const e=w(s),t=i.get(o)?.get(r);return t!==e&&c(o,r,e),e}return s},set(t,n,r,i){const s=Reflect.get(t,n,i),a=f(r);if(Object.is(s,a))return!0;const u=Reflect.set(t,n,a,i);return!!u&&(e.isObject(a)&&!p(a)?c(i,n,w(a)):l(i,n),0===(o.get(i)||0)&&(!Array.isArray(t)&&Array.isArray(s)&&Array.isArray(a)?R(i,{type:"array-replace",oldValue:s,newValue:a}):R(i,{type:"set",key:n,newValue:a,oldValue:s})),u)},deleteProperty(e,t){if(!Reflect.has(e,t))return!1;const r=Reflect.get(e,t),i=Reflect.deleteProperty(e,t);if(i){const i=n.get(e);i&&(l(i,t),0===(o.get(i)||0)&&R(i,{type:"delete",key:t,oldValue:r}))}return i}};function w(e){if(!Object.isExtensible(e))return e;if(p(e))return e;if(e[t])return e;const r=n.get(e);if(r)return r;const o=new Proxy(e,m);return n.set(e,o),o}exports.isProxy=y,exports.observe=function(t,n,o={}){const{throttle:i=0,onBatch:s,immediate:c=!1,deepCompare:l}=o,a={callback:n,onBatch:s,throttle:i,filterRegexes:(Array.isArray(o.filter)?o.filter:o.filter?[o.filter]:[]).map(e=>{if(""===e)return/^.*$/;const t=h.get(e);if(t)return t;let n="";for(let c=0;c<e.length;c++){const t=e[c];"*"===t&&"*"===e[c+1]?(n+="**",c++):"*"===t?n+="*":"."===t?n+=".":/[.*+?^${}()|[\]\\]/.test(t)?n+="\\"+t:n+=t}const r=n.split("."),o=[];for(let c=0;c<r.length;c++){const e=r[c];"**"===e?1===r.length?o.push(".*"):0===c?o.push("(?:[^.]+\\.)*"):o.push("(?:\\.[^.]+)*"):"*"===e?o.push("[^.]+"):o.push(e)}let i="^";for(let c=0;c<o.length;c++)if(i+=o[c],c<o.length-1){const e=o[c],t=o[c+1];if(e.endsWith("\\.)*"))continue;if(t.startsWith("(?:\\."))continue;i+="\\."}i+="$";const s=new RegExp(i);return h.set(e,s),s}),pending:[],timer:null,active:!0,deepCompare:l},u=w(t);let y=r.get(u);if(y||(y=new Set,r.set(u,y)),y.add(a),c){const n=[...y],r=(t,o,i=[],s=new WeakSet)=>{e.isObject(t)&&!s.has(t)&&(s.add(t),Reflect.ownKeys(t).forEach(c=>{const l=Reflect.get(t,c);if(e.isObject(l)&&s.has(l))return;const a=Reflect.get(o,c),f=[...i,c];n.forEach(e=>{d(f,e.filterRegexes)&&b(e,{type:"set",key:c,newValue:l,oldValue:void 0,path:f})}),e.isObject(l)&&!p(l)&&r(l,a,f,s)}))};r(f(t),u)}const g=()=>{const e=r.get(u);e&&(e.delete(a),0===e.size&&r.delete(u)),a.pending=[],a.timer&&(clearTimeout(a.timer),a.timer=null)};return{proxy:u,unobserve:()=>{a.active&&(a.active=!1,g())},resume:()=>{a.active||(a.active=!0,(()=>{let e=r.get(u);e||(e=new Set,r.set(u,e)),e.add(a)})())},dispose:()=>{if(!a.active)return a.callback=()=>{},void(a.onBatch=void 0);a.active=!1,g(),a.callback=()=>{},a.onBatch=void 0}}},exports.toProxy=function(e){return e&&"object"==typeof e&&"proxy"in e?e.proxy:e},exports.toRaw=f;
@@ -1 +1 @@
1
- import{isObject as e}from"../../shared/is-object.js";const t=Symbol("solely.raw"),n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap;function l(e,t,n){a(e,t);let r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,n);let o=s.get(n);o||(o=[],s.set(n,o)),o.some(n=>n.parentRef.deref()===e&&n.key===t)||o.push({parentRef:new WeakRef(e),key:t})}function a(e,t){const n=i.get(e);if(!n)return;const r=n.get(t);if(!r)return;n.delete(t);const o=s.get(r);if(o){const n=o.filter(n=>{const r=n.parentRef.deref();return void 0!==r&&!(r===e&&n.key===t)});0===n.length?s.delete(r):s.set(r,n)}}function c(t,n){const r=i.get(n);if(r)for(const e of r.keys())a(n,e);for(let o=0;o<t.length;o++){const r=t[o];e(r)&&!p(r)&&l(n,String(o),k(r))}}function f(e){if(e&&"object"==typeof e){const n=e[t];if(n)return n}return e}const u=Object.prototype.toString,p=e=>{if(!e||"object"!=typeof e)return!1;const t=u.call(e);return"[object Date]"===t||"[object RegExp]"===t||"[object Map]"===t||"[object Set]"===t||"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Response&&e instanceof Response||"undefined"!=typeof Request&&e instanceof Request};function y(e){return!(!e||!e[t])}function h(e){return e&&"object"==typeof e&&"proxy"in e?e.proxy:e}const d=new Map,g=(e,t)=>{if(0===t.length)return!0;const n=e.map(String);for(let r=n.length;r>0;r--){const e=n.slice(0,r).join(".");if(t.some(t=>t.test(e)))return!0}return!1},v=(e,t)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!v(e[n],t[n]))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Reflect.ownKeys(e),r=Reflect.ownKeys(t);if(n.length!==r.length)return!1;for(const o of n){if(!Reflect.has(t,o))return!1;if(!v(e[o],t[o]))return!1}return!0},R=(e,t)=>{e.active&&(e.deepCompare&&"set"===t.type&&v(t.oldValue,t.newValue)||(e.throttle>0?(e.pending.push(t),e.timer||(e.timer=setTimeout(()=>{if(!e.active)return;const t=[...e.pending];e.pending=[],e.timer=null,t.length>0&&(e.onBatch?e.onBatch(t):e.callback(t[t.length-1]))},e.throttle))):e.onBatch?e.onBatch([t]):e.callback(t)))},b=(e,t)=>{const n=[{node:e,relativePath:[],visited:new Set([e])}];let o=0;for(;o<n.length;){const{node:e,relativePath:i,visited:l}=n[o++],a=r.get(e);a&&a.forEach(e=>{if(!e.active)return;let n=i;if("set"===t.type||"delete"===t.type?n=[...i,t.key]:"array-push"!==t.type&&"array-splice"!==t.type||(n=[...i,String(t.index)]),!g(n,e.filterRegexes))return;const r={...t,path:n};R(e,r)});const c=s.get(e);if(c)for(let t=c.length-1;t>=0;t--){const e=c[t],r=e.parentRef.deref();if(!r){c.splice(t,1);continue}if(l.has(r))continue;const o=new Set(l);o.add(r),n.push({node:r,relativePath:[e.key,...i],visited:o})}}},m={};["push","pop","shift","unshift","splice"].forEach(t=>{m[t]=function(...n){const r=this,i=f(r),s=o.get(r)||0;o.set(r,s+1);try{const o=i.length,s=i[t].apply(i,n);if("push"===t){const t=i.length-n.length;for(let o=0;o<n.length;o++){const n=i[t+o];e(n)&&!p(n)&&l(r,String(t+o),k(n))}b(r,{type:"array-push",index:t,values:n})}else if("pop"===t)a(r,String(o-1)),b(r,{type:"array-splice",index:o-1,deleteCount:1,insert:[]});else if(c(i,r),"unshift"===t)b(r,{type:"array-push",index:0,values:n});else if("shift"===t)b(r,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if("splice"===t){const[e,t,...o]=n;b(r,{type:"array-splice",index:e,deleteCount:t,insert:o})}return s}finally{o.set(r,s)}}}),["sort","reverse","fill","copyWithin"].forEach(e=>{m[e]=function(...t){const n=this,r=f(n),i=o.get(n)||0;o.set(n,i+1);try{const o=r[e].apply(r,t);return c(r,n),b(n,{type:"array-reset",method:e}),o}finally{o.set(n,i)}}}),["indexOf","lastIndexOf","includes"].forEach(e=>{m[e]=function(t,...n){const r=f(this);let o=r[e].apply(r,[t,...n]);return-1!==o&&!1!==o||!y(t)||(o=r[e].apply(r,[f(t),...n])),o}});const w={get(n,r,o){var s;if(r===t)return n;if(Array.isArray(n)&&Object.prototype.hasOwnProperty.call(m,r))return Reflect.get(m,r,o);const a=Reflect.get(n,r,o);if("symbol"==typeof r)return a;if(e(a)&&!p(a)){const e=k(a);return(null==(s=i.get(o))?void 0:s.get(r))!==e&&l(o,r,e),e}return a},set(t,n,r,i){const s=Reflect.get(t,n,i),c=f(r);if(Object.is(s,c))return!0;const u=Reflect.set(t,n,c,i);return!!u&&(e(c)&&!p(c)?l(i,n,k(c)):a(i,n),0===(o.get(i)||0)&&(!Array.isArray(t)&&Array.isArray(s)&&Array.isArray(c)?b(i,{type:"array-replace",oldValue:s,newValue:c}):b(i,{type:"set",key:n,newValue:c,oldValue:s})),u)},deleteProperty(e,t){if(!Reflect.has(e,t))return!1;const r=Reflect.get(e,t),i=Reflect.deleteProperty(e,t);if(i){const i=n.get(e);i&&(a(i,t),0===(o.get(i)||0)&&b(i,{type:"delete",key:t,oldValue:r}))}return i}};function k(e){if(!Object.isExtensible(e))return e;if(p(e))return e;if(e[t])return e;const r=n.get(e);if(r)return r;const o=new Proxy(e,w);return n.set(e,o),o}function A(t,n,o={}){const{throttle:i=0,onBatch:s,immediate:l=!1,deepCompare:a}=o,c={callback:n,onBatch:s,throttle:i,filterRegexes:(Array.isArray(o.filter)?o.filter:o.filter?[o.filter]:[]).map(e=>{if(""===e)return/^.*$/;const t=d.get(e);if(t)return t;let n="";for(let l=0;l<e.length;l++){const t=e[l];"*"===t&&"*"===e[l+1]?(n+="**",l++):"*"===t?n+="*":"."===t?n+=".":/[.*+?^${}()|[\]\\]/.test(t)?n+="\\"+t:n+=t}const r=n.split("."),o=[];for(let l=0;l<r.length;l++){const e=r[l];"**"===e?1===r.length?o.push(".*"):0===l?o.push("(?:[^.]+\\.)*"):o.push("(?:\\.[^.]+)*"):"*"===e?o.push("[^.]+"):o.push(e)}let i="^";for(let l=0;l<o.length;l++)if(i+=o[l],l<o.length-1){const e=o[l],t=o[l+1];if(e.endsWith("\\.)*"))continue;if(t.startsWith("(?:\\."))continue;i+="\\."}i+="$";const s=new RegExp(i);return d.set(e,s),s}),pending:[],timer:null,active:!0,deepCompare:a},u=k(t);let y=r.get(u);if(y||(y=new Set,r.set(u,y)),y.add(c),l){const n=[...y],r=(t,o,i=[],s=new WeakSet)=>{e(t)&&!s.has(t)&&(s.add(t),Reflect.ownKeys(t).forEach(l=>{const a=Reflect.get(t,l);if(e(a)&&s.has(a))return;const c=Reflect.get(o,l),f=[...i,l];n.forEach(e=>{g(f,e.filterRegexes)&&R(e,{type:"set",key:l,newValue:a,oldValue:void 0,path:f})}),e(a)&&!p(a)&&r(a,c,f,s)}))};r(f(t),u)}const h=()=>{const e=r.get(u);e&&(e.delete(c),0===e.size&&r.delete(u)),c.pending=[],c.timer&&(clearTimeout(c.timer),c.timer=null)};return{proxy:u,unobserve:()=>{c.active&&(c.active=!1,h())},resume:()=>{c.active||(c.active=!0,(()=>{let e=r.get(u);e||(e=new Set,r.set(u,e)),e.add(c)})())},dispose:()=>{if(!c.active)return c.callback=()=>{},void(c.onBatch=void 0);c.active=!1,h(),c.callback=()=>{},c.onBatch=void 0}}}export{y as isProxy,A as observe,h as toProxy,f as toRaw};
1
+ import{isObject as e}from"../../shared/is-object.js";const t=Symbol("solely.raw"),n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap;function l(e,t,n){a(e,t);let r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,n);let o=s.get(n);o||(o=[],s.set(n,o)),o.some(n=>n.parentRef.deref()===e&&n.key===t)||o.push({parentRef:new WeakRef(e),key:t})}function a(e,t){const n=i.get(e);if(!n)return;const r=n.get(t);if(!r)return;n.delete(t);const o=s.get(r);if(o){const n=o.filter(n=>{const r=n.parentRef.deref();return void 0!==r&&!(r===e&&n.key===t)});0===n.length?s.delete(r):s.set(r,n)}}function c(t,n){const r=i.get(n);if(r)for(const e of r.keys())a(n,e);for(let o=0;o<t.length;o++){const r=t[o];e(r)&&!p(r)&&l(n,String(o),A(r))}}function f(e){if(e&&"object"==typeof e){const n=e[t];if(n)return n}return e}const u=Object.prototype.toString,p=e=>{if(!e||"object"!=typeof e)return!1;const t=u.call(e);return"[object Date]"===t||"[object RegExp]"===t||"[object Map]"===t||"[object Set]"===t||"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Response&&e instanceof Response||"undefined"!=typeof Request&&e instanceof Request};function y(e){return!(!e||!e[t])}function h(e){return e&&"object"==typeof e&&"proxy"in e?e.proxy:e}const d=new Map,g=(e,t)=>{if(0===t.length)return!0;const n=e.map(String);for(let r=n.length;r>0;r--){const e=n.slice(0,r).join(".");if(t.some(t=>t.test(e)))return!0}return!1},R=(e,t)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!R(e[n],t[n]))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Reflect.ownKeys(e),r=Reflect.ownKeys(t);if(n.length!==r.length)return!1;for(const o of n){if(!Reflect.has(t,o))return!1;const n=e[o],r=t[o];if(!R(n,r))return!1}return!0},b=(e,t)=>{e.active&&(e.deepCompare&&"set"===t.type&&R(t.oldValue,t.newValue)||(e.throttle>0?(e.pending.push(t),e.timer||(e.timer=setTimeout(()=>{if(!e.active)return;const t=[...e.pending];e.pending=[],e.timer=null,t.length>0&&(e.onBatch?e.onBatch(t):e.callback(t[t.length-1]))},e.throttle))):e.onBatch?e.onBatch([t]):e.callback(t)))},m=(e,t)=>{const n=[{node:e,relativePath:[],visited:new Set([e])}];let o=0;for(;o<n.length;){const{node:e,relativePath:i,visited:l}=n[o++],a=r.get(e);a&&a.forEach(e=>{if(!e.active)return;let n=i;if("set"===t.type||"delete"===t.type?n=[...i,t.key]:"array-push"!==t.type&&"array-splice"!==t.type||(n=[...i,String(t.index)]),!g(n,e.filterRegexes))return;const r={...t,path:n};b(e,r)});const c=s.get(e);if(c)for(let t=c.length-1;t>=0;t--){const e=c[t],r=e.parentRef.deref();if(!r){c.splice(t,1);continue}if(l.has(r))continue;const o=new Set(l);o.add(r),n.push({node:r,relativePath:[e.key,...i],visited:o})}}},v={},w=(e,t)=>e[t];["push","pop","shift","unshift","splice"].forEach(t=>{v[t]=function(...n){const r=this,i=f(r),s=o.get(r)||0;o.set(r,s+1);try{const o=i.length,s=w(i,t).apply(i,n);if("push"===t){const t=i.length-n.length;for(let o=0;o<n.length;o++){const n=i[t+o];e(n)&&!p(n)&&l(r,String(t+o),A(n))}m(r,{type:"array-push",index:t,values:n})}else if("pop"===t)a(r,String(o-1)),m(r,{type:"array-splice",index:o-1,deleteCount:1,insert:[]});else if(c(i,r),"unshift"===t)m(r,{type:"array-push",index:0,values:n});else if("shift"===t)m(r,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if("splice"===t){const[e,t,...o]=n;m(r,{type:"array-splice",index:e,deleteCount:t,insert:o})}return s}finally{o.set(r,s)}}}),["sort","reverse","fill","copyWithin"].forEach(e=>{v[e]=function(...t){const n=this,r=f(n),i=o.get(n)||0;o.set(n,i+1);try{const o=w(r,e).apply(r,t);return c(r,n),m(n,{type:"array-reset",method:e}),o}finally{o.set(n,i)}}}),["indexOf","lastIndexOf","includes"].forEach(e=>{v[e]=function(t,...n){const r=f(this),o=w(r,e);let i=o.apply(r,[t,...n]);return-1!==i&&!1!==i||!y(t)||(i=o.apply(r,[f(t),...n])),i}});const k={get(n,r,o){if(r===t)return n;if(Array.isArray(n)&&Object.prototype.hasOwnProperty.call(v,r))return Reflect.get(v,r,o);const s=Reflect.get(n,r,o);if("symbol"==typeof r)return s;if(e(s)&&!p(s)){const e=A(s),t=i.get(o)?.get(r);return t!==e&&l(o,r,e),e}return s},set(t,n,r,i){const s=Reflect.get(t,n,i),c=f(r);if(Object.is(s,c))return!0;const u=Reflect.set(t,n,c,i);return!!u&&(e(c)&&!p(c)?l(i,n,A(c)):a(i,n),0===(o.get(i)||0)&&(!Array.isArray(t)&&Array.isArray(s)&&Array.isArray(c)?m(i,{type:"array-replace",oldValue:s,newValue:c}):m(i,{type:"set",key:n,newValue:c,oldValue:s})),u)},deleteProperty(e,t){if(!Reflect.has(e,t))return!1;const r=Reflect.get(e,t),i=Reflect.deleteProperty(e,t);if(i){const i=n.get(e);i&&(a(i,t),0===(o.get(i)||0)&&m(i,{type:"delete",key:t,oldValue:r}))}return i}};function A(e){if(!Object.isExtensible(e))return e;if(p(e))return e;if(e[t])return e;const r=n.get(e);if(r)return r;const o=new Proxy(e,k);return n.set(e,o),o}function x(t,n,o={}){const{throttle:i=0,onBatch:s,immediate:l=!1,deepCompare:a}=o,c={callback:n,onBatch:s,throttle:i,filterRegexes:(Array.isArray(o.filter)?o.filter:o.filter?[o.filter]:[]).map(e=>{if(""===e)return/^.*$/;const t=d.get(e);if(t)return t;let n="";for(let l=0;l<e.length;l++){const t=e[l];"*"===t&&"*"===e[l+1]?(n+="**",l++):"*"===t?n+="*":"."===t?n+=".":/[.*+?^${}()|[\]\\]/.test(t)?n+="\\"+t:n+=t}const r=n.split("."),o=[];for(let l=0;l<r.length;l++){const e=r[l];"**"===e?1===r.length?o.push(".*"):0===l?o.push("(?:[^.]+\\.)*"):o.push("(?:\\.[^.]+)*"):"*"===e?o.push("[^.]+"):o.push(e)}let i="^";for(let l=0;l<o.length;l++)if(i+=o[l],l<o.length-1){const e=o[l],t=o[l+1];if(e.endsWith("\\.)*"))continue;if(t.startsWith("(?:\\."))continue;i+="\\."}i+="$";const s=new RegExp(i);return d.set(e,s),s}),pending:[],timer:null,active:!0,deepCompare:a},u=A(t);let y=r.get(u);if(y||(y=new Set,r.set(u,y)),y.add(c),l){const n=[...y],r=(t,o,i=[],s=new WeakSet)=>{e(t)&&!s.has(t)&&(s.add(t),Reflect.ownKeys(t).forEach(l=>{const a=Reflect.get(t,l);if(e(a)&&s.has(a))return;const c=Reflect.get(o,l),f=[...i,l];n.forEach(e=>{g(f,e.filterRegexes)&&b(e,{type:"set",key:l,newValue:a,oldValue:void 0,path:f})}),e(a)&&!p(a)&&r(a,c,f,s)}))};r(f(t),u)}const h=()=>{const e=r.get(u);e&&(e.delete(c),0===e.size&&r.delete(u)),c.pending=[],c.timer&&(clearTimeout(c.timer),c.timer=null)};return{proxy:u,unobserve:()=>{c.active&&(c.active=!1,h())},resume:()=>{c.active||(c.active=!0,(()=>{let e=r.get(u);e||(e=new Set,r.set(u,e)),e.add(c)})())},dispose:()=>{if(!c.active)return c.callback=()=>{},void(c.onBatch=void 0);c.active=!1,h(),c.callback=()=>{},c.onBatch=void 0}}}export{y as isProxy,x as observe,h as toProxy,f as toRaw};