solely 0.4.12 → 0.4.14

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 (149) hide show
  1. package/dist/compiler/ir/buildIR.cjs +1 -1
  2. package/dist/compiler/ir/buildIR.js +1 -1
  3. package/dist/components/commands/modal/index.cjs +1 -1
  4. package/dist/components/commands/modal/index.js +1 -1
  5. package/dist/components/commands/modal/types.d.ts +4 -2
  6. package/dist/components/elements/alert/index.cjs +1 -1
  7. package/dist/components/elements/alert/index.d.ts +2 -0
  8. package/dist/components/elements/alert/index.html.cjs +1 -1
  9. package/dist/components/elements/alert/index.html.js +1 -1
  10. package/dist/components/elements/alert/index.js +1 -1
  11. package/dist/components/elements/backtop/index.cjs +1 -1
  12. package/dist/components/elements/backtop/index.html.cjs +1 -1
  13. package/dist/components/elements/backtop/index.html.js +1 -1
  14. package/dist/components/elements/backtop/index.js +1 -1
  15. package/dist/components/elements/badge/index.cjs +1 -1
  16. package/dist/components/elements/badge/index.html.cjs +1 -1
  17. package/dist/components/elements/badge/index.html.js +1 -1
  18. package/dist/components/elements/badge/index.js +1 -1
  19. package/dist/components/elements/breadcrumb/index.cjs +1 -1
  20. package/dist/components/elements/breadcrumb/index.html.cjs +1 -1
  21. package/dist/components/elements/breadcrumb/index.html.js +1 -1
  22. package/dist/components/elements/breadcrumb/index.js +1 -1
  23. package/dist/components/elements/button/index.cjs +1 -1
  24. package/dist/components/elements/button/index.html.cjs +1 -1
  25. package/dist/components/elements/button/index.html.js +1 -1
  26. package/dist/components/elements/button/index.js +1 -1
  27. package/dist/components/elements/card/index.cjs +1 -1
  28. package/dist/components/elements/card/index.html.cjs +1 -1
  29. package/dist/components/elements/card/index.html.js +1 -1
  30. package/dist/components/elements/card/index.js +1 -1
  31. package/dist/components/elements/checkbox/index.cjs +1 -1
  32. package/dist/components/elements/checkbox/index.html.cjs +1 -1
  33. package/dist/components/elements/checkbox/index.html.js +1 -1
  34. package/dist/components/elements/checkbox/index.js +1 -1
  35. package/dist/components/elements/coordinate-input/index.cjs +1 -1
  36. package/dist/components/elements/coordinate-input/index.d.ts +2 -2
  37. package/dist/components/elements/coordinate-input/index.html.cjs +1 -1
  38. package/dist/components/elements/coordinate-input/index.html.js +1 -1
  39. package/dist/components/elements/coordinate-input/index.js +1 -1
  40. package/dist/components/elements/divider/index.cjs +1 -1
  41. package/dist/components/elements/divider/index.html.cjs +1 -1
  42. package/dist/components/elements/divider/index.html.js +1 -1
  43. package/dist/components/elements/divider/index.js +1 -1
  44. package/dist/components/elements/empty/index.cjs +1 -1
  45. package/dist/components/elements/empty/index.html.cjs +1 -1
  46. package/dist/components/elements/empty/index.html.js +1 -1
  47. package/dist/components/elements/empty/index.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.html.cjs +1 -1
  54. package/dist/components/elements/icon/index.html.js +1 -1
  55. package/dist/components/elements/icon/index.js +1 -1
  56. package/dist/components/elements/input/index.cjs +1 -1
  57. package/dist/components/elements/input/index.d.ts +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.cjs +1 -1
  62. package/dist/components/elements/not-found/index.html.cjs +1 -1
  63. package/dist/components/elements/not-found/index.html.js +1 -1
  64. package/dist/components/elements/not-found/index.js +1 -1
  65. package/dist/components/elements/pagination/index.cjs +1 -1
  66. package/dist/components/elements/pagination/index.html.cjs +1 -1
  67. package/dist/components/elements/pagination/index.html.js +1 -1
  68. package/dist/components/elements/pagination/index.js +1 -1
  69. package/dist/components/elements/progress/index.cjs +1 -1
  70. package/dist/components/elements/progress/index.html.cjs +1 -1
  71. package/dist/components/elements/progress/index.html.js +1 -1
  72. package/dist/components/elements/progress/index.js +1 -1
  73. package/dist/components/elements/radio/index.cjs +1 -1
  74. package/dist/components/elements/radio/index.d.ts +3 -0
  75. package/dist/components/elements/radio/index.html.cjs +1 -1
  76. package/dist/components/elements/radio/index.html.js +1 -1
  77. package/dist/components/elements/radio/index.js +1 -1
  78. package/dist/components/elements/rate/index.cjs +1 -1
  79. package/dist/components/elements/rate/index.d.ts +4 -0
  80. package/dist/components/elements/rate/index.html.cjs +1 -1
  81. package/dist/components/elements/rate/index.html.js +1 -1
  82. package/dist/components/elements/rate/index.js +1 -1
  83. package/dist/components/elements/select/index.cjs +1 -1
  84. package/dist/components/elements/select/index.d.ts +2 -0
  85. package/dist/components/elements/select/index.html.cjs +1 -1
  86. package/dist/components/elements/select/index.html.js +1 -1
  87. package/dist/components/elements/select/index.js +1 -1
  88. package/dist/components/elements/skeleton/index.cjs +1 -1
  89. package/dist/components/elements/skeleton/index.html.cjs +1 -1
  90. package/dist/components/elements/skeleton/index.html.js +1 -1
  91. package/dist/components/elements/skeleton/index.js +1 -1
  92. package/dist/components/elements/slider/index.cjs +1 -1
  93. package/dist/components/elements/slider/index.d.ts +8 -1
  94. package/dist/components/elements/slider/index.html.cjs +1 -1
  95. package/dist/components/elements/slider/index.html.js +1 -1
  96. package/dist/components/elements/slider/index.js +1 -1
  97. package/dist/components/elements/steps/index.cjs +1 -1
  98. package/dist/components/elements/steps/index.d.ts +1 -0
  99. package/dist/components/elements/steps/index.html.cjs +1 -1
  100. package/dist/components/elements/steps/index.html.js +1 -1
  101. package/dist/components/elements/steps/index.js +1 -1
  102. package/dist/components/elements/switch/index.cjs +1 -1
  103. package/dist/components/elements/switch/index.html.cjs +1 -1
  104. package/dist/components/elements/switch/index.html.js +1 -1
  105. package/dist/components/elements/switch/index.js +1 -1
  106. package/dist/components/elements/table/index.cjs +1 -1
  107. package/dist/components/elements/table/index.html.cjs +1 -1
  108. package/dist/components/elements/table/index.html.js +1 -1
  109. package/dist/components/elements/table/index.js +1 -1
  110. package/dist/components/elements/tabs/index.cjs +1 -1
  111. package/dist/components/elements/tabs/index.html.cjs +1 -1
  112. package/dist/components/elements/tabs/index.html.js +1 -1
  113. package/dist/components/elements/tabs/index.js +1 -1
  114. package/dist/components/elements/tag/index.cjs +1 -1
  115. package/dist/components/elements/tag/index.html.cjs +1 -1
  116. package/dist/components/elements/tag/index.html.js +1 -1
  117. package/dist/components/elements/tag/index.js +1 -1
  118. package/dist/components/elements/timeline/index.cjs +1 -1
  119. package/dist/components/elements/timeline/index.html.cjs +1 -1
  120. package/dist/components/elements/timeline/index.html.js +1 -1
  121. package/dist/components/elements/timeline/index.js +1 -1
  122. package/dist/components/elements/tooltip/index.d.ts +4 -0
  123. package/dist/components/elements/tree/index.cjs +1 -1
  124. package/dist/components/elements/tree/index.html.cjs +1 -1
  125. package/dist/components/elements/tree/index.html.js +1 -1
  126. package/dist/components/elements/tree/index.js +1 -1
  127. package/dist/components/elements/upload/index.cjs +1 -1
  128. package/dist/components/elements/upload/index.d.ts +3 -0
  129. package/dist/components/elements/upload/index.html.cjs +1 -1
  130. package/dist/components/elements/upload/index.html.js +1 -1
  131. package/dist/components/elements/upload/index.js +1 -1
  132. package/dist/index.cjs +1 -1
  133. package/dist/index.js +1 -1
  134. package/dist/router/router-link.cjs +1 -1
  135. package/dist/router/router-link.html.cjs +1 -0
  136. package/dist/router/router-link.html.js +1 -0
  137. package/dist/router/router-link.js +1 -1
  138. package/dist/runtime/component/decorators.cjs +1 -1
  139. package/dist/runtime/component/decorators.js +1 -1
  140. package/dist/shared/functions.cjs +1 -1
  141. package/dist/shared/functions.d.ts +1 -0
  142. package/dist/shared/functions.js +1 -1
  143. package/dist/shared/index.cjs +1 -1
  144. package/dist/shared/index.js +1 -1
  145. package/dist/shared/templateError.cjs +1 -1
  146. package/dist/shared/templateError.js +1 -1
  147. package/package.json +2 -1
  148. package/dist/icons/LICENSE.txt +0 -14
  149. package/dist/icons/bootstrap-icons.svg +0 -1
@@ -1 +1 @@
1
- const a='<div\n part="base"\n class="upload"\n :class="this.getUploadClasses()"\n>\n \x3c!-- 拖拽上传 --\x3e\n <If condition="$data.drag">\n <div\n part="drag"\n class="upload__drag"\n :class="this.getDragClasses()"\n @click="this.triggerUpload(event)"\n @dragover="this.handleDragOver(event)"\n @dragleave="this.handleDragLeave(event)"\n @drop="this.handleDrop(event)"\n >\n <div part="drag-icon" class="upload__drag-icon">☁️</div>\n <div part="drag-text" class="upload__drag-text">{{$data.buttonText || \'点击或拖拽文件到此区域上传\'}}</div>\n <div part="drag-hint" class="upload__drag-hint">支持单个或批量上传</div>\n </div>\n </If>\n\n \x3c!-- 普通上传按钮 --\x3e\n <If condition="!$data.drag">\n <div\n part="button"\n class="upload__button"\n @click="this.triggerUpload(event)"\n >\n <span>+</span>\n <span>{{$data.buttonText || \'上传文件\'}}</span>\n </div>\n </If>\n\n \x3c!-- 隐藏的文件输入 --\x3e\n <input\n ref="fileInput"\n type="file"\n class="upload__input"\n :accept="$data.accept"\n :multiple="$data.multiple"\n @change="this.handleFileChange(event)"\n />\n\n \x3c!-- 文件列表 --\x3e\n <If condition="$data.showUploadList && $data.parsedFileList?.length > 0">\n <ul part="list" class="upload__list">\n <For each="$data.parsedFileList" item="file">\n <li\n part="list-item"\n class="upload__list-item"\n :class="{ \'upload__list-item--error\': file.status === \'error\' }"\n >\n <If condition="file.url && ($data.listType === \'picture\' || $data.listType === \'picture-card\')">\n <img\n part="thumb"\n class="upload__list-thumb"\n :src="file.url"\n :alt="file.name"\n />\n </If>\n <div part="info" class="upload__list-info">\n <div part="name" class="upload__list-name">{{file.name}}</div>\n <If condition="file.size">\n <div part="size" class="upload__list-size">{{this.formatSize(file.size)}}</div>\n </If>\n <If condition="file.status === \'uploading\'">\n <div part="progress" class="upload__progress">\n <div part="progress-bar" class="upload__progress-bar" :style="\'width: \' + (file.percent || 0) + \'%\'"></div>\n </div>\n </If>\n </div>\n <span\n part="status"\n class="upload__list-status"\n :class="\'upload__list-status--\' + file.status"\n >\n {{this.getStatusText(file.status)}}\n </span>\n <span part="remove" class="upload__list-remove" @click="this.handleRemove(file)">×</span>\n </li>\n </For>\n </ul>\n </If>\n</div>\n';export{a as default};
1
+ const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:a}=this;return this.getUploadClasses()},function(t){const{$data:a}=this;return a.drag},function(t){const{$data:a}=this;return this.getDragClasses()},function(t,a){const{$data:d}=this,{value:s,checked:i}=(null==t?void 0:t.target)||{};this.triggerUpload(t)},function(t,a){const{$data:d}=this,{value:s,checked:i}=(null==t?void 0:t.target)||{};this.handleDragOver(t)},function(t,a){const{$data:d}=this,{value:s,checked:i}=(null==t?void 0:t.target)||{};this.handleDragLeave(t)},function(t,a){const{$data:d}=this,{value:s,checked:i}=(null==t?void 0:t.target)||{};this.handleDrop(t)},function(t){const{$data:a}=this;return`${a.buttonText||"点击或拖拽文件到此区域上传"}`},function(t){const{$data:a}=this;return!a.drag},function(t){const{$data:a}=this;return`${a.buttonText||"上传文件"}`},function(t){const{$data:a}=this;return a.accept},function(t){const{$data:a}=this;return a.multiple},function(t,a){const{$data:d}=this,{value:s,checked:i}=(null==t?void 0:t.target)||{};this.handleFileChange(t)},function(t){var a;const{$data:d}=this;return d.showUploadList&&(null==(a=d.parsedFileList)?void 0:a.length)>0},function(t){const{$data:a}=this;return a.parsedFileList},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return{"upload__list-item--error":"error"===d.status}},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return d.url&&("picture"===a.listType||"picture-card"===a.listType)},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return d.url},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return d.name},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${d.name}`},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return d.size},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${this.formatSize(d.size)}`},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return"uploading"===d.status},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return"width: "+(d.percent||0)+"%"},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return"upload__list-status--"+d.status},function(t){const{$data:a}=this;var[d]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${this.getStatusText(d.status)}`},function(t,a){const{$data:d}=this,{value:s,checked:i}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[c]=a.map(t=>t.idxVal);this.handleRemove(n)}],n:[{t:0,d:1,g:"div",a:[{k:"part",v:"base",d:0},{k:"class",v:"upload",d:0},{k:":class",f:1,d:1}],c:[{t:2,d:0,x:" 拖拽上传 "},{t:7,d:1,b:[{f:2,c:[{t:0,d:1,g:"div",a:[{k:"part",v:"drag",d:0},{k:"class",v:"upload__drag",d:0},{k:":class",f:3,d:1},{k:"@click",f:4,d:1},{k:"@dragover",f:5,d:1},{k:"@dragleave",f:6,d:1},{k:"@drop",f:7,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"drag-icon",d:0},{k:"class",v:"upload__drag-icon",d:0}],c:[{t:1,d:0,s:1,x:"☁️"}]},{t:0,d:0,g:"div",a:[{k:"part",v:"drag-text",d:0},{k:"class",v:"upload__drag-text",d:0}],c:[{t:1,d:1,f:8}]},{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"drag-hint",d:0},{k:"class",v:"upload__drag-hint",d:0}],c:[{t:1,d:0,s:1,x:"支持单个或批量上传"}]}]}]}]},{t:2,d:0,x:" 普通上传按钮 "},{t:7,d:1,b:[{f:9,c:[{t:0,d:1,g:"div",a:[{k:"part",v:"button",d:0},{k:"class",v:"upload__button",d:0},{k:"@click",f:4,d:1}],c:[{t:0,d:0,s:1,g:"span",a:[],c:[{t:1,d:0,s:1,x:"+"}]},{t:0,d:0,g:"span",a:[],c:[{t:1,d:1,f:10}]}]}]}]},{t:2,d:0,x:" 隐藏的文件输入 "},{t:0,d:1,g:"input",a:[{k:"ref",v:"fileInput",d:0},{k:"type",v:"file",d:0},{k:"class",v:"upload__input",d:0},{k:":accept",f:11,d:1},{k:":multiple",f:12,d:1},{k:"@change",f:13,d:1}],c:[]},{t:2,d:0,x:" 文件列表 "},{t:7,d:1,b:[{f:14,c:[{t:0,d:0,g:"ul",a:[{k:"part",v:"list",d:0},{k:"class",v:"upload__list",d:0}],c:[{t:6,d:1,f:15,i:"file",n:"index",a:[],c:[{t:0,d:1,g:"li",a:[{k:"part",v:"list-item",d:0},{k:"class",v:"upload__list-item",d:0},{k:":class",f:16,d:1}],c:[{t:7,d:1,b:[{f:17,c:[{t:0,d:1,g:"img",a:[{k:"part",v:"thumb",d:0},{k:"class",v:"upload__list-thumb",d:0},{k:":src",f:18,d:1},{k:":alt",f:19,d:1}],c:[]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"info",d:0},{k:"class",v:"upload__list-info",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"name",d:0},{k:"class",v:"upload__list-name",d:0}],c:[{t:1,d:1,f:20}]},{t:7,d:1,b:[{f:21,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"size",d:0},{k:"class",v:"upload__list-size",d:0}],c:[{t:1,d:1,f:22}]}]}]},{t:7,d:1,b:[{f:23,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"progress",d:0},{k:"class",v:"upload__progress",d:0}],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"progress-bar",d:0},{k:"class",v:"upload__progress-bar",d:0},{k:":style",f:24,d:1}],c:[]}]}]}]}]},{t:0,d:1,g:"span",a:[{k:"part",v:"status",d:0},{k:"class",v:"upload__list-status",d:0},{k:":class",f:25,d:1}],c:[{t:1,d:1,f:26}]},{t:0,d:1,g:"span",a:[{k:"part",v:"remove",d:0},{k:"class",v:"upload__list-remove",d:0},{k:"@click",f:27,d:1}],c:[{t:1,d:0,s:1,x:"×"}]}]}]}]}]}]}]}],s:{tf:27,cf:27,dn:1,tn:1,sn:0}};export{t as __SOLELY_IR__,t as default};
@@ -1 +1 @@
1
- import e from"./style.css.js";import t from"./index.html.js";import{safeJsonParse as s}from"../utils/helpers.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends a{getUploadClasses(){const e={};return this.$data.listType&&(e[`upload--${this.$data.listType}`]=!0),e["is-disabled"]=!!this.$data.disabled,e}get fileList(){return this.$data.parsedFileList}set fileList(e){this.$data.parsedFileList=e,this.$data.fileList=JSON.stringify(e)}getDragClasses(){return{"upload__drag--active":!!this.$data.isDragging}}mounted(){this.refresh(),this.parseFileList(),this.$data.isDragging=!1}parseFileList(){this.$data.parsedFileList=s(this.$data.fileList,[])}triggerUpload(){var e;if(this.$data.disabled)return;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('input[type="file"]');t&&t.click()}handleFileChange(e){const t=e.target,s=t.files;s&&s.length>0&&this.handleFiles(s),t.value=""}handleFiles(e){const t=this.$data.maxCount||1/0,s=this.$data.maxSize||1/0;Array.from(e).forEach(e=>{if(this.$data.parsedFileList.length>=t)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件数量超过限制 (最多 ${t} 个)`});if(e.size>s)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件大小超过限制 (${this.formatSize(s)})`});const a={uid:Date.now()+Math.random().toString(36).substr(2,9),name:e.name,size:e.size,type:e.type,status:"uploading",percent:0};this.$data.parsedFileList.push(a),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.uploadFile(a,e)})}uploadFile(e,t){if(!this.$data.action)return e.status="done",e.percent=100,e.url=URL.createObjectURL(t),this.refresh(),this.emit("success",{file:e,fileList:this.$data.parsedFileList}),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));const s=new XMLHttpRequest,a=new FormData;a.append("file",t),s.upload.addEventListener("progress",t=>{t.lengthComputable&&(e.percent=Math.round(t.loaded/t.total*100),this.$data.parsedFileList=[...this.$data.parsedFileList])}),s.addEventListener("load",()=>{if(s.status>=200&&s.status<300){e.status="done",e.percent=100;try{const t=JSON.parse(s.responseText);t.url&&(e.url=t.url)}catch{}this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("success",{file:e,fileList:this.$data.parsedFileList})}else e.status="error",e.error=s.statusText,this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:s.statusText});this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.addEventListener("error",()=>{e.status="error",e.error="网络错误",this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:"网络错误"}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.open("POST",this.$data.action,!0),s.send(a)}handleDragOver(e){e.preventDefault(),this.$data.isDragging=!0}handleDragLeave(e){e.preventDefault(),this.$data.isDragging=!1}handleDrop(e){var t;e.preventDefault(),this.$data.isDragging=!1;const s=null==(t=e.dataTransfer)?void 0:t.files;s&&s.length>0&&this.handleFiles(s)}handleRemove(e){const t=this.$data.parsedFileList.findIndex(t=>t.uid===e.uid);t>-1&&(this.$data.parsedFileList.splice(t,1),this.emit("remove",{file:e,fileList:this.$data.parsedFileList}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}getStatusText(e){return{uploading:"上传中",done:"完成",error:"失败",removed:"已删除"}[e||""]||""}getFileList(){return this.$data.parsedFileList}clear(){this.$data.parsedFileList=[]}};r=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([i({tagName:"solely-upload",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"action",type:"string"},{name:"accept",type:"string"},{name:"multiple",type:"boolean",default:!1},{name:"fileList",type:"string"},{name:"listType",type:"string"},{name:"disabled",type:"boolean",default:!1},{name:"showUploadList",type:"boolean",default:!0},{name:"buttonText",type:"string"},{name:"drag",type:"boolean",default:!1},{name:"maxCount",type:"number"},{name:"maxSize",type:"number"},{name:"block",type:"boolean",default:!1}]})],r);export{r as SolelyUpload};
1
+ var e=Object.defineProperty,t=(t,s,a)=>((t,s,a)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a)(t,"symbol"!=typeof s?s+"":s,a);import s from"./style.css.js";import{__SOLELY_IR__ as a}from"./index.html.js";import{safeJsonParse as i}from"../utils/helpers.js";import r from"../../../runtime/component/base-element.js";import{CustomElement as n}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let o=class extends r{constructor(){super(...arguments),t(this,"activeXhrs",[]),t(this,"objectURLs",[])}getUploadClasses(){const e={};return this.$data.listType&&(e[`upload--${this.$data.listType}`]=!0),e["is-disabled"]=!!this.$data.disabled,e}get fileList(){return this.$data.parsedFileList}set fileList(e){this.$data.parsedFileList=e,this.$data.fileList=JSON.stringify(e)}getDragClasses(){return{"upload__drag--active":!!this.$data.isDragging}}mounted(){this.refresh(),this.parseFileList(),this.$data.isDragging=!1}unmounted(){for(const e of this.activeXhrs)e.abort();this.activeXhrs=[];for(const e of this.objectURLs)URL.revokeObjectURL(e);this.objectURLs=[]}parseFileList(){this.$data.parsedFileList=i(this.$data.fileList,[])}triggerUpload(){var e;if(this.$data.disabled)return;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('input[type="file"]');t&&t.click()}handleFileChange(e){const t=e.target,s=t.files;s&&s.length>0&&this.handleFiles(s),t.value=""}handleFiles(e){const t=this.$data.maxCount||1/0,s=this.$data.maxSize||1/0;Array.from(e).forEach(e=>{if(this.$data.parsedFileList.length>=t)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件数量超过限制 (最多 ${t} 个)`});if(e.size>s)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件大小超过限制 (${this.formatSize(s)})`});const a={uid:Date.now()+Math.random().toString(36).substr(2,9),name:e.name,size:e.size,type:e.type,status:"uploading",percent:0};this.$data.parsedFileList.push(a),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.uploadFile(a,e)})}uploadFile(e,t){if(!this.$data.action)return e.status="done",e.percent=100,e.url=URL.createObjectURL(t),this.objectURLs.push(e.url),this.refresh(),this.emit("success",{file:e,fileList:this.$data.parsedFileList}),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));const s=new XMLHttpRequest;this.activeXhrs.push(s);const a=new FormData;a.append("file",t),s.upload.addEventListener("progress",t=>{t.lengthComputable&&(e.percent=Math.round(t.loaded/t.total*100),this.$data.parsedFileList=[...this.$data.parsedFileList])}),s.addEventListener("load",()=>{if(this.activeXhrs=this.activeXhrs.filter(e=>e!==s),s.status>=200&&s.status<300){e.status="done",e.percent=100;try{const t=JSON.parse(s.responseText);t.url&&(e.url=t.url)}catch{}this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("success",{file:e,fileList:this.$data.parsedFileList})}else e.status="error",e.error=s.statusText,this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:s.statusText});this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.addEventListener("error",()=>{this.activeXhrs=this.activeXhrs.filter(e=>e!==s),e.status="error",e.error="网络错误",this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:"网络错误"}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.open("POST",this.$data.action,!0),s.send(a)}handleDragOver(e){e.preventDefault(),this.$data.isDragging=!0}handleDragLeave(e){e.preventDefault(),this.$data.isDragging=!1}handleDrop(e){var t;e.preventDefault(),this.$data.isDragging=!1;const s=null==(t=e.dataTransfer)?void 0:t.files;s&&s.length>0&&this.handleFiles(s)}handleRemove(e){const t=this.$data.parsedFileList.findIndex(t=>t.uid===e.uid);t>-1&&(this.$data.parsedFileList.splice(t,1),this.emit("remove",{file:e,fileList:this.$data.parsedFileList}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}getStatusText(e){return{uploading:"上传中",done:"完成",error:"失败",removed:"已删除"}[e||""]||""}getFileList(){return this.$data.parsedFileList}clear(){this.$data.parsedFileList=[]}};o=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([n({tagName:"solely-upload",template:a,styles:s,shadowDOM:{use:!0,mode:"open"},props:[{name:"action",type:"string"},{name:"accept",type:"string"},{name:"multiple",type:"boolean",default:!1},{name:"fileList",type:"string"},{name:"listType",type:"string"},{name:"disabled",type:"boolean",default:!1},{name:"showUploadList",type:"boolean",default:!0},{name:"buttonText",type:"string"},{name:"drag",type:"boolean",default:!1},{name:"maxCount",type:"number"},{name:"maxSize",type:"number"},{name:"block",type:"boolean",default:!1}]})],o);export{o as SolelyUpload};
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"),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"),n=require("./types/ast.cjs"),p=require("./types/lifecycle.cjs"),a=require("./runtime/component/base-element.cjs"),l=require("./router/router-link.cjs"),d=require("./router/router-view.cjs"),x=require("./runtime/renderer/html-decode.cjs"),m=require("./runtime/component/decorators.cjs"),R=require("./runtime/renderer/renderIR.cjs"),j=require("./router/core.cjs"),q=require("./compiler/ir/buildIR.cjs"),y=require("./runtime/reactivity/observe.cjs"),f=require("./compiler/parser/parser.cjs");exports.createRouter=e.createRouter,exports.showTemplateError=r.showTemplateError,exports.genFunction=t.genFunction,exports.createFunction=s.createFunction,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.ASTType=n.ASTType,exports.LIFECYCLE_ATTRS_MAP=p.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=p.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=p.mapAttrKeyToLifecycleKind,exports.BaseElement=a.default,Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>l.default}),Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>d.default}),exports.htmlDecode=x.default,exports.CustomElement=m.CustomElement,exports.IRRenderer=R.IRRenderer,exports.createRender=R.createRender,exports.Router=j.Router,exports.getRouter=j.getRouter,exports.routerReady=j.routerReady,exports.buildIR=q.buildIR,exports.clearIRCache=q.clearIRCache,exports.transformModel=q.transformModel,exports.isProxy=y.isProxy,exports.observe=y.observe,exports.toRaw=y.toRaw,exports.parseHtml=f.parseHtml;
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"),n=require("./types/ast.cjs"),p=require("./types/lifecycle.cjs"),a=require("./runtime/component/base-element.cjs"),l=require("./router/router-link.cjs"),d=require("./router/router-view.cjs"),x=require("./runtime/renderer/html-decode.cjs"),m=require("./runtime/component/decorators.cjs"),R=require("./runtime/renderer/renderIR.cjs"),j=require("./router/core.cjs"),q=require("./compiler/ir/buildIR.cjs"),y=require("./runtime/reactivity/observe.cjs"),f=require("./compiler/parser/parser.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.ASTType=n.ASTType,exports.LIFECYCLE_ATTRS_MAP=p.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=p.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=p.mapAttrKeyToLifecycleKind,exports.BaseElement=a.default,Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>l.default}),Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>d.default}),exports.htmlDecode=x.default,exports.CustomElement=m.CustomElement,exports.IRRenderer=R.IRRenderer,exports.createRender=R.createRender,exports.Router=j.Router,exports.getRouter=j.getRouter,exports.routerReady=j.routerReady,exports.buildIR=q.buildIR,exports.clearIRCache=q.clearIRCache,exports.transformModel=q.transformModel,exports.isProxy=y.isProxy,exports.observe=y.observe,exports.toRaw=y.toRaw,exports.parseHtml=f.parseHtml;
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}from"./shared/functions.js";import{default as m}from"./shared/event-listeners.js";import{isObject as s}from"./shared/is-object.js";import{parseHashUrl as i}from"./shared/url.js";import{IS_DEV as a,IS_PROD as p}from"./shared/env.js";import{ASTType as f}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as n,isLifecycleKind as u,mapAttrKeyToLifecycleKind as d}from"./types/lifecycle.js";import{default as j}from"./runtime/component/base-element.js";import{default as l}from"./router/router-link.js";import{default as c}from"./router/router-view.js";import{default as h}from"./runtime/renderer/html-decode.js";import{CustomElement as v}from"./runtime/component/decorators.js";import{IRRenderer as b,createRender as y}from"./runtime/renderer/renderIR.js";import{Router as R,getRouter as k,routerReady as w}from"./router/core.js";import{buildIR as x,clearIRCache as E,transformModel as I}from"./compiler/ir/buildIR.js";import{isProxy as g,observe as B,toRaw as D}from"./runtime/reactivity/observe.js";import{parseHtml as L}from"./compiler/parser/parser.js";export{f as ASTType,j as BaseElement,v as CustomElement,b as IRRenderer,a as IS_DEV,p as IS_PROD,n as LIFECYCLE_ATTRS_MAP,R as Router,l as RouterLink,c as RouterView,x as buildIR,E as clearIRCache,t as createFunction,y as createRender,r as createRouter,o as genFunction,k as getRouter,h as htmlDecode,u as isLifecycleKind,s as isObject,g as isProxy,m as listeners,d as mapAttrKeyToLifecycleKind,B as observe,i as parseHashUrl,L as parseHtml,w as routerReady,e as showTemplateError,D as toRaw,I as transformModel};
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}from"./shared/env.js";import{ASTType as n}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as u,isLifecycleKind as d,mapAttrKeyToLifecycleKind as j}from"./types/lifecycle.js";import{default as l}from"./runtime/component/base-element.js";import{default as c}from"./router/router-link.js";import{default as h}from"./router/router-view.js";import{default as v}from"./runtime/renderer/html-decode.js";import{CustomElement as b}from"./runtime/component/decorators.js";import{IRRenderer as y,createRender as R}from"./runtime/renderer/renderIR.js";import{Router as k,getRouter as w,routerReady as x}from"./router/core.js";import{buildIR as E,clearIRCache as I,transformModel as g}from"./compiler/ir/buildIR.js";import{isProxy as B,observe as D,toRaw as L}from"./runtime/reactivity/observe.js";import{parseHtml as V}from"./compiler/parser/parser.js";export{n as ASTType,l as BaseElement,b as CustomElement,y as IRRenderer,p as IS_DEV,f as IS_PROD,u as LIFECYCLE_ATTRS_MAP,k as Router,c as RouterLink,h as RouterView,E as buildIR,I as clearIRCache,t as createFunction,R as createRender,r as createRouter,o as genFunction,w as getRouter,v as htmlDecode,m as isCSPBlocked,d as isLifecycleKind,i as isObject,B as isProxy,s as listeners,j as mapAttrKeyToLifecycleKind,D as observe,a as parseHashUrl,V as parseHtml,x as routerReady,e as showTemplateError,L as toRaw,g as transformModel};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./core.cjs"),e=require("../runtime/component/base-element.cjs"),a=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;var s,r=t=>{throw TypeError(t)},o=(t,e,a)=>e.has(t)||r("Cannot "+a);exports.default=class extends e.default{constructor(){var t,e;super(...arguments),t=this,(e=s).has(t)?r("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,false)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await t.routerReady).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",e=>{var a,s;e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||0===e.button&&((null==(a=e.target.closest("a"))?void 0:a.getAttribute("target"))||(e.preventDefault(),null==(s=t.getRouter())||s.push(this.$data.to)))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const e=t.getRouter();if(!e)return;this.$data.href=e.resolve(this.$data.to);let a=!1;if(this.$data.active)a=!0;else{const t=e.getCurrentRoute();if(t){const e=t.fullPath;a=this.hasAttribute("exact")?e===this.$data.to:e===this.$data.to||e.startsWith(this.$data.to+"/")}}this.$data.isActive=a;const s=this.$data.activeClass||"active";this.classList.toggle(s,a)}prefetchRoute(){if(o(this,e=s,"read from private field"),e.get(this)||!this.hasAttribute("prefetch"))return;var e;const a=t.getRouter();a&&(a.prefetch(this.$data.to),((t,e)=>{o(t,e,"write to private field"),e.set(t,!0)})(this,s))}},s=new WeakMap,exports.default=((t,e)=>{for(var a,s=e,r=t.length-1;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s})([a.CustomElement({tagName:"router-link",template:'\n <a part="link" :href="$data.href" :class="{active: $data.isActive}">\n <slot>{{$data.label || \'\'}}</slot>\n </a>\n ',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"),a=require("../runtime/component/base-element.cjs"),s=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;var r,o=t=>{throw TypeError(t)},n=(t,e,a)=>e.has(t)||o("Cannot "+a);exports.default=class extends a.default{constructor(){var t,e;super(...arguments),t=this,(e=r).has(t)?o("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,false)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await t.routerReady).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",e=>{var a,s;e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||0===e.button&&((null==(a=e.target.closest("a"))?void 0:a.getAttribute("target"))||(e.preventDefault(),null==(s=t.getRouter())||s.push(this.$data.to)))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const e=t.getRouter();if(!e)return;this.$data.href=e.resolve(this.$data.to);let a=!1;if(this.$data.active)a=!0;else{const t=e.getCurrentRoute();if(t){const e=t.fullPath;a=this.hasAttribute("exact")?e===this.$data.to:e===this.$data.to||e.startsWith(this.$data.to+"/")}}this.$data.isActive=a;const s=this.$data.activeClass||"active";this.classList.toggle(s,a)}prefetchRoute(){if(n(this,e=r,"read from private field"),e.get(this)||!this.hasAttribute("prefetch"))return;var e;const a=t.getRouter();a&&(a.prefetch(this.$data.to),((t,e)=>{n(t,e,"write to private field"),e.set(t,!0)})(this,r))}},r=new WeakMap,exports.default=((t,e)=>{for(var a,s=e,r=t.length-1;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s})([s.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);
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:e}=this;return e.href},function(t){const{$data:e}=this;return{active:e.isActive}},function(t){const{$data:e}=this;return`${e.label||""}`}],n:[{t:0,d:1,g:"a",a:[{k:"part",v:"link",d:0},{k:":href",f:1,d:1},{k:":class",f:2,d:1}],c:[{t:0,d:0,g:"slot",a:[],c:[{t:1,d:1,f:3}]}]}],s:{tf:3,cf:3,dn:1,tn:1,sn:0}};exports.__SOLELY_IR__=t,exports.default=t;
@@ -0,0 +1 @@
1
+ const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:n}=this;return n.href},function(t){const{$data:n}=this;return{active:n.isActive}},function(t){const{$data:n}=this;return`${n.label||""}`}],n:[{t:0,d:1,g:"a",a:[{k:"part",v:"link",d:0},{k:":href",f:1,d:1},{k:":class",f:2,d:1}],c:[{t:0,d:0,g:"slot",a:[],c:[{t:1,d:1,f:3}]}]}],s:{tf:3,cf:3,dn:1,tn:1,sn:0}};export{t as __SOLELY_IR__,t as default};
@@ -1 +1 @@
1
- import{routerReady as t,getRouter as e}from"./core.js";import a from"../runtime/component/base-element.js";import{CustomElement as s}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;var n,r=t=>{throw TypeError(t)},o=(t,e,a)=>e.has(t)||r("Cannot "+a);let i=class extends a{constructor(){var t,e;super(...arguments),t=this,(e=n).has(t)?r("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,false)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await t).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",t=>{var a,s;t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||0===t.button&&((null==(a=t.target.closest("a"))?void 0:a.getAttribute("target"))||(t.preventDefault(),null==(s=e())||s.push(this.$data.to)))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const t=e();if(!t)return;this.$data.href=t.resolve(this.$data.to);let a=!1;if(this.$data.active)a=!0;else{const e=t.getCurrentRoute();if(e){const t=e.fullPath;a=this.hasAttribute("exact")?t===this.$data.to:t===this.$data.to||t.startsWith(this.$data.to+"/")}}this.$data.isActive=a;const s=this.$data.activeClass||"active";this.classList.toggle(s,a)}prefetchRoute(){if(o(this,t=n,"read from private field"),t.get(this)||!this.hasAttribute("prefetch"))return;var t;const a=e();a&&(a.prefetch(this.$data.to),((t,e)=>{o(t,e,"write to private field"),e.set(t,!0)})(this,n))}};n=new WeakMap,i=((t,e)=>{for(var a,s=e,n=t.length-1;n>=0;n--)(a=t[n])&&(s=a(s)||s);return s})([s({tagName:"router-link",template:'\n <a part="link" :href="$data.href" :class="{active: $data.isActive}">\n <slot>{{$data.label || \'\'}}</slot>\n </a>\n ',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"]})],i);export{i as default};
1
+ import{routerReady as t,getRouter as e}from"./core.js";import{__SOLELY_IR__ as a}from"./router-link.html.js";import s from"../runtime/component/base-element.js";import{CustomElement as r}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;var o,n=t=>{throw TypeError(t)},i=(t,e,a)=>e.has(t)||n("Cannot "+a);let h=class extends s{constructor(){var t,e;super(...arguments),t=this,(e=o).has(t)?n("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,false)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await t).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",t=>{var a,s;t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||0===t.button&&((null==(a=t.target.closest("a"))?void 0:a.getAttribute("target"))||(t.preventDefault(),null==(s=e())||s.push(this.$data.to)))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const t=e();if(!t)return;this.$data.href=t.resolve(this.$data.to);let a=!1;if(this.$data.active)a=!0;else{const e=t.getCurrentRoute();if(e){const t=e.fullPath;a=this.hasAttribute("exact")?t===this.$data.to:t===this.$data.to||t.startsWith(this.$data.to+"/")}}this.$data.isActive=a;const s=this.$data.activeClass||"active";this.classList.toggle(s,a)}prefetchRoute(){if(i(this,t=o,"read from private field"),t.get(this)||!this.hasAttribute("prefetch"))return;var t;const a=e();a&&(a.prefetch(this.$data.to),((t,e)=>{i(t,e,"write to private field"),e.set(t,!0)})(this,o))}};o=new WeakMap,h=((t,e)=>{for(var a,s=e,r=t.length-1;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s})([r({tagName:"router-link",template:a,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"]})],h);export{h as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=o=>{const s=o,l="undefined"!=typeof window&&"undefined"!=typeof customElements;return o=>{const{tagName:a}=s;if(l&&!(o.prototype instanceof HTMLElement)&&o!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${o.name||"anonymous class"}`);if(l&&customElements.get(a))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${a}" 已经被注册,跳过重复定义。`),o[n]=s,o;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const t=s.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(s.ir=t,e.IS_DEV&&console.info(`[Solely] Using precompiled IR for <${a}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${a}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${a}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=t.parseHtml(s.template);s.ir=r.buildIR(e,{source:s.template,filename:a})}catch(c){const t=c instanceof Error?c:new Error(String(c));console.error(`[Compiler Error] <${a}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${s.template.length} 字符`,e.IS_DEV?t.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${a}>: 模板为空字符串`);if(l&&s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch{e.IS_DEV&&console.warn(`[Style Warning] <${a}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.attributeMap){const e=new Map,t=new Map;s.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,o=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase(),s=n.name,l={...n,name:s};e.set(o,l),t.set(s,l)}),s.attributeMap=e,s.propMap=t}class i extends o{}return i[n]=s,l&&customElements.define(a,i),i}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=o=>{const s=o,l="undefined"!=typeof window&&"undefined"!=typeof customElements;return o=>{const{tagName:a}=s;if(l&&!(o.prototype instanceof HTMLElement)&&o!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${o.name||"anonymous class"}`);if(l&&customElements.get(a))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${a}" 已经被注册,跳过重复定义。`),o[n]=s,o;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const t=s.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(s.ir=t,e.IS_DEV&&console.info(`[Solely] Using precompiled IR for <${a}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${a}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${a}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=t.parseHtml(s.template);s.ir=r.buildIR(e,{source:s.template,filename:a})}catch(c){const t=c instanceof Error?c:new Error(String(c));console.error(`[Compiler Error] <${a}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${s.template.length} 字符`,e.IS_DEV?t.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${a}>: 模板为空字符串`);if(l&&s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch{e.IS_DEV&&console.warn(`[Solely] <${a}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.attributeMap){const e=new Map,t=new Map;s.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,o=n.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase(),s=n.name,l={...n,name:s};e.set(o,l),t.set(s,l)}),s.attributeMap=e,s.propMap=t}class i extends o{}return i[n]=s,l&&customElements.define(a,i),i}};
@@ -1 +1 @@
1
- import{IS_DEV as e}from"../../shared/env.js";import{parseHtml as t}from"../../compiler/parser/parser.js";import{buildIR as n}from"../../compiler/ir/buildIR.js";const o=Symbol.for("solely.manifest"),r=r=>{const s=r,l="undefined"!=typeof window&&"undefined"!=typeof customElements;return r=>{const{tagName:a}=s;if(l&&!(r.prototype instanceof HTMLElement)&&r!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${r.name||"anonymous class"}`);if(l&&customElements.get(a))return e&&console.warn(`[Solely] 标签名称 "${a}" 已经被注册,跳过重复定义。`),r[o]=s,r;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const t=s.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(s.ir=t,e&&console.info(`[Solely] Using precompiled IR for <${a}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${a}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${a}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=t(s.template);s.ir=n(e,{source:s.template,filename:a})}catch(p){const t=p instanceof Error?p:new Error(String(p));console.error(`[Compiler Error] <${a}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${s.template.length} 字符`,e?t.stack:"")}else e&&console.warn(`[Solely] <${a}>: 模板为空字符串`);if(l&&s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch{e&&console.warn(`[Style Warning] <${a}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.attributeMap){const e=new Map,t=new Map;s.props.forEach(n=>{const o="string"==typeof n?{name:n}:n,r=o.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase(),s=o.name,l={...o,name:s};e.set(r,l),t.set(s,l)}),s.attributeMap=e,s.propMap=t}class i extends r{}return i[o]=s,l&&customElements.define(a,i),i}};export{r as CustomElement};
1
+ import{IS_DEV as e}from"../../shared/env.js";import{parseHtml as t}from"../../compiler/parser/parser.js";import{buildIR as o}from"../../compiler/ir/buildIR.js";const r=Symbol.for("solely.manifest"),n=n=>{const s=n,l="undefined"!=typeof window&&"undefined"!=typeof customElements;return n=>{const{tagName:a}=s;if(l&&!(n.prototype instanceof HTMLElement)&&n!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${n.name||"anonymous class"}`);if(l&&customElements.get(a))return e&&console.warn(`[Solely] 标签名称 "${a}" 已经被注册,跳过重复定义。`),n[r]=s,n;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const t=s.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(s.ir=t,e&&console.info(`[Solely] Using precompiled IR for <${a}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${a}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${a}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=t(s.template);s.ir=o(e,{source:s.template,filename:a})}catch(p){const t=p instanceof Error?p:new Error(String(p));console.error(`[Compiler Error] <${a}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${s.template.length} 字符`,e?t.stack:"")}else e&&console.warn(`[Solely] <${a}>: 模板为空字符串`);if(l&&s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch{e&&console.warn(`[Solely] <${a}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.attributeMap){const e=new Map,t=new Map;s.props.forEach(o=>{const r="string"==typeof o?{name:o}:o,n=r.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase(),s=r.name,l={...r,name:s};e.set(n,l),t.set(s,l)}),s.attributeMap=e,s.propMap=t}class i extends n{}return i[r]=s,l&&customElements.define(a,i),i}};export{n as CustomElement};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.createFunction=function(t){if(""===t[t.length-1].trim())throw new Error("Function body cannot be empty");return new Function(...t)};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let t=null;function n(){if(null!==t)return t;try{new Function("return 1"),t=!1}catch{t=!0}return t}exports.createFunction=function(t){const e=t[t.length-1];if(""===e.trim())throw new Error("Function body cannot be empty");try{return new Function(...t)}catch(r){throw n()&&console.error(`[Solely] CSP 阻止了 new Function() 执行。请使用 ?solely 预编译模式(构建时编译,运行时无需 eval),或在 CSP 中添加 'unsafe-eval'。表达式: ${e.substring(0,80)}`),r}},exports.isCSPBlocked=n;
@@ -1,5 +1,6 @@
1
1
  /** 函数创建器类型 */
2
2
  export type FunctionCreator<TArgs extends any[], TReturn> = (...args: TArgs) => TReturn;
3
+ export declare function isCSPBlocked(): boolean;
3
4
  /**
4
5
  * 创建函数
5
6
  * 注意:安全检查由调用方根据场景决定,此函数仅做基础验证
@@ -1 +1 @@
1
- function n(n){if(""===n[n.length-1].trim())throw new Error("Function body cannot be empty");return new Function(...n)}export{n as createFunction};
1
+ let n=null;function t(){if(null!==n)return n;try{new Function("return 1"),n=!1}catch{n=!0}return n}function r(n){const r=n[n.length-1];if(""===r.trim())throw new Error("Function body cannot be empty");try{return new Function(...n)}catch(e){throw t()&&console.error(`[Solely] CSP 阻止了 new Function() 执行。请使用 ?solely 预编译模式(构建时编译,运行时无需 eval),或在 CSP 中添加 'unsafe-eval'。表达式: ${r.substring(0,80)}`),e}}export{r as createFunction,t as isCSPBlocked};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./templateError.cjs"),r=require("./gen-function.cjs"),t=require("./functions.cjs"),s=require("./event-listeners.cjs"),o=require("./is-object.cjs"),n=require("./url.cjs"),c=require("./env.cjs");exports.showTemplateError=e.showTemplateError,exports.genFunction=r.genFunction,exports.createFunction=t.createFunction,exports.listeners=s.default,exports.isObject=o.isObject,exports.parseHashUrl=n.parseHashUrl,exports.IS_DEV=c.IS_DEV,exports.IS_PROD=c.IS_PROD;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./templateError.cjs"),r=require("./gen-function.cjs"),s=require("./functions.cjs"),t=require("./event-listeners.cjs"),o=require("./is-object.cjs"),c=require("./url.cjs"),i=require("./env.cjs");exports.showTemplateError=e.showTemplateError,exports.genFunction=r.genFunction,exports.createFunction=s.createFunction,exports.isCSPBlocked=s.isCSPBlocked,exports.listeners=t.default,exports.isObject=o.isObject,exports.parseHashUrl=c.parseHashUrl,exports.IS_DEV=i.IS_DEV,exports.IS_PROD=i.IS_PROD;
@@ -1 +1 @@
1
- import{showTemplateError as r}from"./templateError.js";import{genFunction as o}from"./gen-function.js";import{createFunction as t}from"./functions.js";import{default as m}from"./event-listeners.js";import{isObject as s}from"./is-object.js";import{parseHashUrl as e}from"./url.js";import{IS_DEV as i,IS_PROD as f}from"./env.js";export{i as IS_DEV,f as IS_PROD,t as createFunction,o as genFunction,s as isObject,m as listeners,e as parseHashUrl,r as showTemplateError};
1
+ import{showTemplateError as r}from"./templateError.js";import{genFunction as o}from"./gen-function.js";import{createFunction as t,isCSPBlocked as m}from"./functions.js";import{default as s}from"./event-listeners.js";import{isObject as e}from"./is-object.js";import{parseHashUrl as i}from"./url.js";import{IS_DEV as f,IS_PROD as n}from"./env.js";export{f as IS_DEV,n as IS_PROD,t as createFunction,o as genFunction,m as isCSPBlocked,e as isObject,s as listeners,i as parseHashUrl,r as showTemplateError};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="#858585",n="#3c1e1e",e="#f8f8f2",t="#ff6b6b",l="#ff6b6b",c="#ffffff",r="#a0a0a0",i="#5ddcff";function s(o){let n=0;for(let e=0;e<o.length;){const t=o.codePointAt(e)??0;"\t"!==o[e]?(n+=t>=9472&&t<=9599||t>255?2:1,e+=t>65535?2:1):(n+=4,e++)}return n}function f(o,n={}){const{lineIndex:e=0,totalLines:t=1}=n,l=Math.max(1,Math.floor(o));return(t<=1||0===e?"^":"~").repeat(l)}exports.showTemplateError=function(a,d="",p,$="component"){var g;const h=`%cTemplate Error%c in <${$}> → ${(null==a?void 0:a.message)??String(a)}`,u=[`color:${c};background:${l};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${t};font-weight:bold;`];if(!d||!(null==p?void 0:p.loc)||p.loc.length<2)return console.error(h,...u),void((null==p?void 0:p.expr)&&console.info(`Expression: ${p.expr.trim()}`));const m=p.loc;let x=m[0]||0,b=m[1]||0;x|=0,b|=0,x<1&&(x=1),b<1&&(b=1);const v=d.split("\n");if(x>v.length)return void console.error(`[Template Error] 行号 ${x} 超出范围`);const E=x-1,M=Math.max(0,E-3),S=Math.min(v.length-1,E+3),w=String(S+1).length,T=(null==(g=p.expr)?void 0:g.trim())??"",y=T?T.split("\n"):[],L=T?Math.max(...y.map(s)):0,k=y.length>1,C=`color:${o};`,I=`color:${t};font-weight:bold;`,P=`color:${o};`,j=`color:${e};background:${n};padding:0 4px;`,A=`color:${o};`,O=`color:${t};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${h} %c(Line:${x}, Col:${b})`,...u,`color:${o};font-weight:normal;`);for(let o=M;o<=S;o++){const n=v[o],e=String(o+1).padStart(w," ");if(o!==E){console.info(`%c${e} │%c ${n}`,C,P);continue}const t=s(n.slice(0,Math.max(0,b-1))),l=" ".repeat(w+3),c=e.padEnd(w," ");if(console.info(`%c${c} │%c ${n}`,I,j),k)for(let o=0;o<y.length;o++){const n=y[o],e=E+o;let c=0;if(0===o)c=t;else if(e<v.length){const o=v[e],n=o.search(/\S/);c=s(-1===n?o:o.slice(0,n))}const r=f(Math.max(1,s(n.trim())),{lineIndex:o,totalLines:y.length}),i=l+" ".repeat(c);if(0===o)console.info(`%c${i}%c${r}`,A,O);else if(e<v.length){const o=String(e+1).padEnd(w," "),n=v[e];console.info(`%c${o} │%c ${n}`,I,j),console.info(`%c${i}%c${r}`,A,O)}}else{const o=l+" ".repeat(t),n=f(L||1);console.info(`%c${o}%c${n}`,A,O)}}T&&console.info(`%cExpression:%c ${T}`,`color:${r};font-weight:bold;`,`color:${i};font-family:monospace;`),console.groupEnd()};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="#858585",n="#3c1e1e",e="#f8f8f2",t="#ff6b6b",l="#ff6b6b",c="#ffffff",r="#a0a0a0",i="#5ddcff";function s(o){let n=0;for(let e=0;e<o.length;){const t=o.codePointAt(e)??0;"\t"!==o[e]?(n+=t>=9472&&t<=9599||t>255?2:1,e+=t>65535?2:1):(n+=4,e++)}return n}function f(o,n={}){const{lineIndex:e=0,totalLines:t=1}=n,l=Math.max(1,Math.floor(o));return(t<=1||0===e?"^":"~").repeat(l)}exports.showTemplateError=function(a,d="",p,$="component"){var g;const h=`%c[Solely]%c Template Error in <${$}> → ${(null==a?void 0:a.message)??String(a)}`,u=[`color:${c};background:${l};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${t};font-weight:bold;`];if(!d||!(null==p?void 0:p.loc)||p.loc.length<2)return console.error(h,...u),void((null==p?void 0:p.expr)&&console.info(`Expression: ${p.expr.trim()}`));const x=p.loc;let m=x[0]||0,b=x[1]||0;m|=0,b|=0,m<1&&(m=1),b<1&&(b=1);const S=d.split("\n");if(m>S.length)return void console.error(`[Solely] 行号 ${m} 超出范围`);const v=m-1,M=Math.max(0,v-3),w=Math.min(S.length-1,v+3),E=String(w+1).length,y=(null==(g=p.expr)?void 0:g.trim())??"",L=y?y.split("\n"):[],T=y?Math.max(...L.map(s)):0,k=L.length>1,C=`color:${o};`,I=`color:${t};font-weight:bold;`,P=`color:${o};`,j=`color:${e};background:${n};padding:0 4px;`,A=`color:${o};`,O=`color:${t};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${h} %c(Line:${m}, Col:${b})`,...u,`color:${o};font-weight:normal;`);for(let o=M;o<=w;o++){const n=S[o],e=String(o+1).padStart(E," ");if(o!==v){console.info(`%c${e} │%c ${n}`,C,P);continue}const t=s(n.slice(0,Math.max(0,b-1))),l=" ".repeat(E+3),c=e.padEnd(E," ");if(console.info(`%c${c} │%c ${n}`,I,j),k)for(let o=0;o<L.length;o++){const n=L[o],e=v+o;let c=0;if(0===o)c=t;else if(e<S.length){const o=S[e],n=o.search(/\S/);c=s(-1===n?o:o.slice(0,n))}const r=f(Math.max(1,s(n.trim())),{lineIndex:o,totalLines:L.length}),i=l+" ".repeat(c);if(0===o)console.info(`%c${i}%c${r}`,A,O);else if(e<S.length){const o=String(e+1).padEnd(E," "),n=S[e];console.info(`%c${o} │%c ${n}`,I,j),console.info(`%c${i}%c${r}`,A,O)}}else{const o=l+" ".repeat(t),n=f(T||1);console.info(`%c${o}%c${n}`,A,O)}}y&&console.info(`%cExpression:%c ${y}`,`color:${r};font-weight:bold;`,`color:${i};font-family:monospace;`),console.groupEnd()};
@@ -1 +1 @@
1
- const o="#858585",n="#3c1e1e",e="#f8f8f2",t="#ff6b6b",l="#ff6b6b",c="#ffffff",r="#a0a0a0",i="#5ddcff";function f(o){let n=0;for(let e=0;e<o.length;){const t=o.codePointAt(e)??0;"\t"!==o[e]?(n+=t>=9472&&t<=9599||t>255?2:1,e+=t>65535?2:1):(n+=4,e++)}return n}function s(o,n={}){const{lineIndex:e=0,totalLines:t=1}=n,l=Math.max(1,Math.floor(o));return(t<=1||0===e?"^":"~").repeat(l)}function a(a,d="",$,p="component"){var g;const h=`%cTemplate Error%c in <${p}> → ${(null==a?void 0:a.message)??String(a)}`,x=[`color:${c};background:${l};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${t};font-weight:bold;`];if(!d||!(null==$?void 0:$.loc)||$.loc.length<2)return console.error(h,...x),void((null==$?void 0:$.expr)&&console.info(`Expression: ${$.expr.trim()}`));const m=$.loc;let u=m[0]||0,b=m[1]||0;u|=0,b|=0,u<1&&(u=1),b<1&&(b=1);const v=d.split("\n");if(u>v.length)return void console.error(`[Template Error] 行号 ${u} 超出范围`);const E=u-1,M=Math.max(0,E-3),w=Math.min(v.length-1,E+3),S=String(w+1).length,L=(null==(g=$.expr)?void 0:g.trim())??"",k=L?L.split("\n"):[],C=L?Math.max(...k.map(f)):0,I=k.length>1,T=`color:${o};`,y=`color:${t};font-weight:bold;`,A=`color:${o};`,P=`color:${e};background:${n};padding:0 4px;`,j=`color:${o};`,q=`color:${t};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${h} %c(Line:${u}, Col:${b})`,...x,`color:${o};font-weight:normal;`);for(let o=M;o<=w;o++){const n=v[o],e=String(o+1).padStart(S," ");if(o!==E){console.info(`%c${e} │%c ${n}`,T,A);continue}const t=f(n.slice(0,Math.max(0,b-1))),l=" ".repeat(S+3),c=e.padEnd(S," ");if(console.info(`%c${c} │%c ${n}`,y,P),I)for(let o=0;o<k.length;o++){const n=k[o],e=E+o;let c=0;if(0===o)c=t;else if(e<v.length){const o=v[e],n=o.search(/\S/);c=f(-1===n?o:o.slice(0,n))}const r=s(Math.max(1,f(n.trim())),{lineIndex:o,totalLines:k.length}),i=l+" ".repeat(c);if(0===o)console.info(`%c${i}%c${r}`,j,q);else if(e<v.length){const o=String(e+1).padEnd(S," "),n=v[e];console.info(`%c${o} │%c ${n}`,y,P),console.info(`%c${i}%c${r}`,j,q)}}else{const o=l+" ".repeat(t),n=s(C||1);console.info(`%c${o}%c${n}`,j,q)}}L&&console.info(`%cExpression:%c ${L}`,`color:${r};font-weight:bold;`,`color:${i};font-family:monospace;`),console.groupEnd()}export{a as showTemplateError};
1
+ const o="#858585",n="#3c1e1e",e="#f8f8f2",t="#ff6b6b",l="#ff6b6b",c="#ffffff",r="#a0a0a0",i="#5ddcff";function f(o){let n=0;for(let e=0;e<o.length;){const t=o.codePointAt(e)??0;"\t"!==o[e]?(n+=t>=9472&&t<=9599||t>255?2:1,e+=t>65535?2:1):(n+=4,e++)}return n}function s(o,n={}){const{lineIndex:e=0,totalLines:t=1}=n,l=Math.max(1,Math.floor(o));return(t<=1||0===e?"^":"~").repeat(l)}function a(a,d="",$,p="component"){var g;const h=`%c[Solely]%c Template Error in <${p}> → ${(null==a?void 0:a.message)??String(a)}`,x=[`color:${c};background:${l};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${t};font-weight:bold;`];if(!d||!(null==$?void 0:$.loc)||$.loc.length<2)return console.error(h,...x),void((null==$?void 0:$.expr)&&console.info(`Expression: ${$.expr.trim()}`));const u=$.loc;let m=u[0]||0,b=u[1]||0;m|=0,b|=0,m<1&&(m=1),b<1&&(b=1);const S=d.split("\n");if(m>S.length)return void console.error(`[Solely] 行号 ${m} 超出范围`);const v=m-1,M=Math.max(0,v-3),w=Math.min(S.length-1,v+3),E=String(w+1).length,y=(null==(g=$.expr)?void 0:g.trim())??"",L=y?y.split("\n"):[],k=y?Math.max(...L.map(f)):0,C=L.length>1,I=`color:${o};`,A=`color:${t};font-weight:bold;`,P=`color:${o};`,T=`color:${e};background:${n};padding:0 4px;`,j=`color:${o};`,q=`color:${t};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${h} %c(Line:${m}, Col:${b})`,...x,`color:${o};font-weight:normal;`);for(let o=M;o<=w;o++){const n=S[o],e=String(o+1).padStart(E," ");if(o!==v){console.info(`%c${e} │%c ${n}`,I,P);continue}const t=f(n.slice(0,Math.max(0,b-1))),l=" ".repeat(E+3),c=e.padEnd(E," ");if(console.info(`%c${c} │%c ${n}`,A,T),C)for(let o=0;o<L.length;o++){const n=L[o],e=v+o;let c=0;if(0===o)c=t;else if(e<S.length){const o=S[e],n=o.search(/\S/);c=f(-1===n?o:o.slice(0,n))}const r=s(Math.max(1,f(n.trim())),{lineIndex:o,totalLines:L.length}),i=l+" ".repeat(c);if(0===o)console.info(`%c${i}%c${r}`,j,q);else if(e<S.length){const o=String(e+1).padEnd(E," "),n=S[e];console.info(`%c${o} │%c ${n}`,A,T),console.info(`%c${i}%c${r}`,j,q)}}else{const o=l+" ".repeat(t),n=s(k||1);console.info(`%c${o}%c${n}`,j,q)}}y&&console.info(`%cExpression:%c ${y}`,`color:${r};font-weight:bold;`,`color:${i};font-family:monospace;`),console.groupEnd()}export{a as showTemplateError};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.4.12",
4
+ "version": "0.4.14",
5
5
  "description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -131,6 +131,7 @@
131
131
  },
132
132
  "files": [
133
133
  "dist",
134
+ "!dist/icons",
134
135
  "README.md",
135
136
  "LICENSE"
136
137
  ],
@@ -1,14 +0,0 @@
1
- Bootstrap Icons License
2
- =======================
3
-
4
- The file bootstrap-icons.svg in this directory is from Bootstrap Icons:
5
- https://github.com/twbs/icons
6
-
7
- License: MIT License
8
- Copyright (c) 2019-2024 The Bootstrap Authors
9
-
10
- See the project's NOTICE file or https://github.com/twbs/icons/blob/main/LICENSE
11
- for the full license text.
12
-
13
- This file is used for demonstration purposes only and is not bundled with
14
- the published npm package.