@weapp-vite/web 1.3.28 → 1.3.30

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 (240) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +0 -8
  2. package/dist/compiler/wxml/attributes.mjs +0 -8
  3. package/dist/compiler/wxml/attributes.mjs.map +1 -1
  4. package/dist/compiler/wxml/compile.mjs +0 -8
  5. package/dist/compiler/wxml/compile.mjs.map +1 -1
  6. package/dist/compiler/wxml/dependency.mjs +0 -8
  7. package/dist/compiler/wxml/dependency.mjs.map +1 -1
  8. package/dist/compiler/wxml/interpolation.mjs +0 -8
  9. package/dist/compiler/wxml/interpolation.mjs.map +1 -1
  10. package/dist/compiler/wxml/navigation.mjs +0 -8
  11. package/dist/compiler/wxml/navigation.mjs.map +1 -1
  12. package/dist/compiler/wxml/parser.mjs +0 -8
  13. package/dist/compiler/wxml/parser.mjs.map +1 -1
  14. package/dist/compiler/wxml/renderer.mjs +0 -8
  15. package/dist/compiler/wxml/renderer.mjs.map +1 -1
  16. package/dist/compiler/wxml/specialNodes.mjs +0 -8
  17. package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
  18. package/dist/compiler/wxs.mjs +0 -8
  19. package/dist/compiler/wxs.mjs.map +1 -1
  20. package/dist/css/wxss.d.mts +0 -2
  21. package/dist/css/wxss.mjs +0 -8
  22. package/dist/css/wxss.mjs.map +1 -1
  23. package/dist/index.d.mts +0 -2
  24. package/dist/index.mjs +0 -8
  25. package/dist/plugin/constants.mjs +0 -8
  26. package/dist/plugin/constants.mjs.map +1 -1
  27. package/dist/plugin/entry.mjs +0 -8
  28. package/dist/plugin/entry.mjs.map +1 -1
  29. package/dist/plugin/files.mjs +0 -8
  30. package/dist/plugin/files.mjs.map +1 -1
  31. package/dist/plugin/index.d.mts +0 -2
  32. package/dist/plugin/index.mjs +0 -8
  33. package/dist/plugin/index.mjs.map +1 -1
  34. package/dist/plugin/navigation.mjs +0 -8
  35. package/dist/plugin/navigation.mjs.map +1 -1
  36. package/dist/plugin/path.mjs +0 -8
  37. package/dist/plugin/path.mjs.map +1 -1
  38. package/dist/plugin/register.mjs +0 -8
  39. package/dist/plugin/register.mjs.map +1 -1
  40. package/dist/plugin/scan.mjs +0 -8
  41. package/dist/plugin/scan.mjs.map +1 -1
  42. package/dist/plugin/scanConfig.mjs +0 -8
  43. package/dist/plugin/scanConfig.mjs.map +1 -1
  44. package/dist/plugin/state.mjs +0 -8
  45. package/dist/plugin/state.mjs.map +1 -1
  46. package/dist/plugin/types.d.mts +0 -2
  47. package/dist/plugin.d.mts +0 -2
  48. package/dist/plugin.mjs +0 -8
  49. package/dist/runtime/button/helpers.mjs +0 -8
  50. package/dist/runtime/button/helpers.mjs.map +1 -1
  51. package/dist/runtime/button/index.d.mts +0 -2
  52. package/dist/runtime/button/index.mjs +0 -8
  53. package/dist/runtime/button/index.mjs.map +1 -1
  54. package/dist/runtime/button/style.mjs +0 -8
  55. package/dist/runtime/button/style.mjs.map +1 -1
  56. package/dist/runtime/component/behavior.mjs +0 -8
  57. package/dist/runtime/component/behavior.mjs.map +1 -1
  58. package/dist/runtime/component/constants.mjs +0 -8
  59. package/dist/runtime/component/constants.mjs.map +1 -1
  60. package/dist/runtime/component/dom.mjs +0 -8
  61. package/dist/runtime/component/dom.mjs.map +1 -1
  62. package/dist/runtime/component/element.mjs +0 -8
  63. package/dist/runtime/component/element.mjs.map +1 -1
  64. package/dist/runtime/component/events.mjs +0 -8
  65. package/dist/runtime/component/events.mjs.map +1 -1
  66. package/dist/runtime/component/index.d.mts +0 -2
  67. package/dist/runtime/component/index.mjs +0 -8
  68. package/dist/runtime/component/index.mjs.map +1 -1
  69. package/dist/runtime/component/state.mjs +0 -8
  70. package/dist/runtime/component/state.mjs.map +1 -1
  71. package/dist/runtime/component/types.d.mts +0 -2
  72. package/dist/runtime/component/utils.mjs +0 -8
  73. package/dist/runtime/component/utils.mjs.map +1 -1
  74. package/dist/runtime/execution.d.mts +0 -2
  75. package/dist/runtime/execution.mjs +0 -8
  76. package/dist/runtime/execution.mjs.map +1 -1
  77. package/dist/runtime/index.d.mts +0 -2
  78. package/dist/runtime/index.mjs +0 -8
  79. package/dist/runtime/legacyTemplate/dom.mjs +0 -8
  80. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  81. package/dist/runtime/legacyTemplate/expression.mjs +0 -8
  82. package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
  83. package/dist/runtime/legacyTemplate/index.d.mts +0 -2
  84. package/dist/runtime/legacyTemplate/index.mjs +0 -8
  85. package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
  86. package/dist/runtime/legacyTemplate/types.d.mts +0 -2
  87. package/dist/runtime/navigationBar/index.d.mts +0 -2
  88. package/dist/runtime/navigationBar/index.mjs +0 -8
  89. package/dist/runtime/navigationBar/index.mjs.map +1 -1
  90. package/dist/runtime/navigationBar/style.mjs +0 -8
  91. package/dist/runtime/navigationBar/style.mjs.map +1 -1
  92. package/dist/runtime/polyfill/ad.mjs +0 -8
  93. package/dist/runtime/polyfill/ad.mjs.map +1 -1
  94. package/dist/runtime/polyfill/appState.mjs +0 -8
  95. package/dist/runtime/polyfill/appState.mjs.map +1 -1
  96. package/dist/runtime/polyfill/async.mjs +0 -8
  97. package/dist/runtime/polyfill/async.mjs.map +1 -1
  98. package/dist/runtime/polyfill/auth.mjs +0 -8
  99. package/dist/runtime/polyfill/auth.mjs.map +1 -1
  100. package/dist/runtime/polyfill/authApi.mjs +0 -8
  101. package/dist/runtime/polyfill/authApi.mjs.map +1 -1
  102. package/dist/runtime/polyfill/background.mjs +0 -8
  103. package/dist/runtime/polyfill/background.mjs.map +1 -1
  104. package/dist/runtime/polyfill/canvasContext.mjs +0 -8
  105. package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
  106. package/dist/runtime/polyfill/capability.mjs +0 -8
  107. package/dist/runtime/polyfill/capability.mjs.map +1 -1
  108. package/dist/runtime/polyfill/cloud.mjs +0 -8
  109. package/dist/runtime/polyfill/cloud.mjs.map +1 -1
  110. package/dist/runtime/polyfill/device.mjs +0 -8
  111. package/dist/runtime/polyfill/device.mjs.map +1 -1
  112. package/dist/runtime/polyfill/deviceApi.mjs +0 -8
  113. package/dist/runtime/polyfill/deviceApi.mjs.map +1 -1
  114. package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +0 -2
  115. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +0 -8
  116. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
  117. package/dist/runtime/polyfill/filePicker.mjs +0 -8
  118. package/dist/runtime/polyfill/filePicker.mjs.map +1 -1
  119. package/dist/runtime/polyfill/fileSystemManager.mjs +0 -8
  120. package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
  121. package/dist/runtime/polyfill/files.mjs +0 -8
  122. package/dist/runtime/polyfill/files.mjs.map +1 -1
  123. package/dist/runtime/polyfill/index.d.mts +0 -2
  124. package/dist/runtime/polyfill/index.mjs +0 -8
  125. package/dist/runtime/polyfill/index.mjs.map +1 -1
  126. package/dist/runtime/polyfill/interaction.mjs +0 -8
  127. package/dist/runtime/polyfill/interaction.mjs.map +1 -1
  128. package/dist/runtime/polyfill/interactionApi.mjs +0 -8
  129. package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
  130. package/dist/runtime/polyfill/location.mjs +0 -8
  131. package/dist/runtime/polyfill/location.mjs.map +1 -1
  132. package/dist/runtime/polyfill/locationApi.mjs +0 -8
  133. package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
  134. package/dist/runtime/polyfill/mediaActions.mjs +0 -8
  135. package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
  136. package/dist/runtime/polyfill/mediaApi/file.mjs +0 -8
  137. package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -1
  138. package/dist/runtime/polyfill/mediaApi/info.mjs +0 -8
  139. package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
  140. package/dist/runtime/polyfill/mediaApi/picker.mjs +0 -8
  141. package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
  142. package/dist/runtime/polyfill/mediaApi/preview.mjs +0 -8
  143. package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
  144. package/dist/runtime/polyfill/mediaApi/process.mjs +0 -8
  145. package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
  146. package/dist/runtime/polyfill/mediaInfo.mjs +0 -8
  147. package/dist/runtime/polyfill/mediaInfo.mjs.map +1 -1
  148. package/dist/runtime/polyfill/mediaPicker.mjs +0 -8
  149. package/dist/runtime/polyfill/mediaPicker.mjs.map +1 -1
  150. package/dist/runtime/polyfill/mediaProcess.mjs +0 -8
  151. package/dist/runtime/polyfill/mediaProcess.mjs.map +1 -1
  152. package/dist/runtime/polyfill/menuApi.mjs +0 -8
  153. package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
  154. package/dist/runtime/polyfill/navigationBarRuntime.mjs +0 -8
  155. package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
  156. package/dist/runtime/polyfill/network/request.mjs +0 -8
  157. package/dist/runtime/polyfill/network/request.mjs.map +1 -1
  158. package/dist/runtime/polyfill/network/requestBridge.mjs +0 -8
  159. package/dist/runtime/polyfill/network/requestBridge.mjs.map +1 -1
  160. package/dist/runtime/polyfill/network/status.mjs +0 -8
  161. package/dist/runtime/polyfill/network/status.mjs.map +1 -1
  162. package/dist/runtime/polyfill/platformApi.mjs +0 -8
  163. package/dist/runtime/polyfill/platformApi.mjs.map +1 -1
  164. package/dist/runtime/polyfill/platformRuntime.mjs +0 -8
  165. package/dist/runtime/polyfill/platformRuntime.mjs.map +1 -1
  166. package/dist/runtime/polyfill/routeRuntime/dom.mjs +0 -8
  167. package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
  168. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +0 -8
  169. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
  170. package/dist/runtime/polyfill/routeRuntime/options.d.mts +0 -2
  171. package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -8
  172. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
  173. package/dist/runtime/polyfill/routeRuntime/url.mjs +0 -8
  174. package/dist/runtime/polyfill/routeRuntime/url.mjs.map +1 -1
  175. package/dist/runtime/polyfill/routeRuntime.d.mts +0 -2
  176. package/dist/runtime/polyfill/routeRuntime.mjs +0 -8
  177. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  178. package/dist/runtime/polyfill/runtimeCapabilityApi.mjs +0 -8
  179. package/dist/runtime/polyfill/runtimeCapabilityApi.mjs.map +1 -1
  180. package/dist/runtime/polyfill/runtimeDataApi.d.mts +0 -2
  181. package/dist/runtime/polyfill/runtimeDataApi.mjs +0 -8
  182. package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
  183. package/dist/runtime/polyfill/runtimeInfra.mjs +0 -8
  184. package/dist/runtime/polyfill/runtimeInfra.mjs.map +1 -1
  185. package/dist/runtime/polyfill/runtimeOps.mjs +0 -8
  186. package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
  187. package/dist/runtime/polyfill/selectorQuery.mjs +0 -8
  188. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
  189. package/dist/runtime/polyfill/storage.mjs +0 -8
  190. package/dist/runtime/polyfill/storage.mjs.map +1 -1
  191. package/dist/runtime/polyfill/storageAsync.mjs +0 -8
  192. package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
  193. package/dist/runtime/polyfill/subscribe.mjs +0 -8
  194. package/dist/runtime/polyfill/subscribe.mjs.map +1 -1
  195. package/dist/runtime/polyfill/system.mjs +0 -8
  196. package/dist/runtime/polyfill/system.mjs.map +1 -1
  197. package/dist/runtime/polyfill/systemApi.mjs +0 -8
  198. package/dist/runtime/polyfill/systemApi.mjs.map +1 -1
  199. package/dist/runtime/polyfill/types/base.d.mts +0 -2
  200. package/dist/runtime/polyfill/types/common.d.mts +0 -2
  201. package/dist/runtime/polyfill/types/locationRuntime.d.mts +0 -2
  202. package/dist/runtime/polyfill/types/mediaAuth.d.mts +0 -2
  203. package/dist/runtime/polyfill/types/platformRuntime.d.mts +0 -2
  204. package/dist/runtime/polyfill/types/systemAuth.d.mts +0 -2
  205. package/dist/runtime/polyfill/ui.mjs +0 -8
  206. package/dist/runtime/polyfill/ui.mjs.map +1 -1
  207. package/dist/runtime/polyfill/uiFeedback.mjs +0 -8
  208. package/dist/runtime/polyfill/uiFeedback.mjs.map +1 -1
  209. package/dist/runtime/polyfill/uiMediaApi.d.mts +0 -2
  210. package/dist/runtime/polyfill/uiMediaApi.mjs +0 -8
  211. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
  212. package/dist/runtime/polyfill/videoContext.mjs +0 -8
  213. package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
  214. package/dist/runtime/polyfill/vkSession.mjs +0 -8
  215. package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
  216. package/dist/runtime/polyfill/windowResize.mjs +0 -8
  217. package/dist/runtime/polyfill/windowResize.mjs.map +1 -1
  218. package/dist/runtime/polyfill/worker.mjs +0 -8
  219. package/dist/runtime/polyfill/worker.mjs.map +1 -1
  220. package/dist/runtime/polyfill.d.mts +0 -2
  221. package/dist/runtime/renderContext.d.mts +0 -2
  222. package/dist/runtime/renderContext.mjs +0 -8
  223. package/dist/runtime/renderContext.mjs.map +1 -1
  224. package/dist/runtime/rpx.d.mts +0 -2
  225. package/dist/runtime/rpx.mjs +0 -8
  226. package/dist/runtime/rpx.mjs.map +1 -1
  227. package/dist/runtime/style.d.mts +0 -2
  228. package/dist/runtime/style.mjs +0 -8
  229. package/dist/runtime/style.mjs.map +1 -1
  230. package/dist/runtime/template.d.mts +0 -2
  231. package/dist/runtime/utils/object.mjs +0 -8
  232. package/dist/runtime/utils/object.mjs.map +1 -1
  233. package/dist/runtime/warning.d.mts +0 -2
  234. package/dist/runtime/warning.mjs +0 -8
  235. package/dist/runtime/warning.mjs.map +1 -1
  236. package/dist/shared/slugify.mjs +0 -8
  237. package/dist/shared/slugify.mjs.map +1 -1
  238. package/dist/shared/wxml.mjs +0 -8
  239. package/dist/shared/wxml.mjs.map +1 -1
  240. package/package.json +3 -2
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  //#region \0rolldown/runtime.js
10
2
  var __defProp = Object.defineProperty;
11
3
  var __exportAll = (all, no_symbols) => {
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { CONTROL_ATTRS, EVENT_KIND_ALIAS, EVENT_PREFIX_RE, hasControlAttribute, normalizeAttributeName, resolveControlAttributeValue } from "../../shared/wxml.mjs";
10
2
  import { buildExpression, parseInterpolations } from "./interpolation.mjs";
11
3
 
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.mjs","names":[],"sources":["../../../src/compiler/wxml/attributes.ts"],"sourcesContent":["import type { RenderElementNode, RenderNode } from './types'\nimport {\n CONTROL_ATTRS,\n EVENT_KIND_ALIAS,\n EVENT_PREFIX_RE,\n hasControlAttribute,\n normalizeAttributeName,\n resolveControlAttributeValue,\n} from '../../shared/wxml'\nimport { buildExpression, parseInterpolations } from './interpolation'\n\nexport function extractFor(attribs: Record<string, string>) {\n const expr = resolveControlAttributeValue(attribs, 'for')\n const itemName = resolveControlAttributeValue(attribs, 'for-item')?.trim() || 'item'\n let indexName = resolveControlAttributeValue(attribs, 'for-index')?.trim() || 'index'\n const key = resolveControlAttributeValue(attribs, 'key')\n const restAttribs: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(name)) {\n continue\n }\n restAttribs[name] = value\n }\n if (itemName === indexName) {\n indexName = `${indexName}Index`\n }\n return { expr, itemName, indexName, key, restAttribs }\n}\n\nexport function isConditionalElement(node: RenderNode): node is RenderElementNode {\n if (node.type !== 'element') {\n return false\n }\n const attribs = node.attribs ?? {}\n return hasControlAttribute(attribs, 'if')\n || hasControlAttribute(attribs, 'elif')\n || hasControlAttribute(attribs, 'else')\n}\n\nexport function stripControlAttributes(attribs: Record<string, string>) {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (!CONTROL_ATTRS.has(name)) {\n result[name] = value\n }\n }\n return result\n}\n\nfunction parseEventAttribute(name: string) {\n if (name.includes(':')) {\n const [prefix, rawEvent] = name.split(':', 2)\n return { prefix, rawEvent }\n }\n const match = EVENT_PREFIX_RE.exec(name)\n if (!match) {\n return undefined\n }\n return { prefix: name.slice(0, name.length - match[1].length), rawEvent: match[1] }\n}\n\nexport function resolveComponentTagName(name: string, componentTags?: Record<string, string>) {\n if (!componentTags) {\n return undefined\n }\n return componentTags[name] ?? componentTags[name.toLowerCase()]\n}\n\nconst PROPERTY_BIND_EXCLUSIONS = new Set(['class', 'style', 'id', 'slot'])\n\nfunction shouldBindAsProperty(name: string) {\n if (PROPERTY_BIND_EXCLUSIONS.has(name)) {\n return false\n }\n if (name.startsWith('data-') || name.startsWith('aria-')) {\n return false\n }\n return true\n}\n\nfunction normalizePropertyName(name: string) {\n return name.replace(/-([a-z])/g, (_, char: string) => char.toUpperCase())\n}\n\nexport function renderAttributes(\n attribs: Record<string, string>,\n scopeVar: string,\n wxsVar: string,\n options?: { skipControl?: boolean, preferProperty?: boolean },\n) {\n let buffer = ''\n for (const [rawName, rawValue] of Object.entries(attribs)) {\n if (options?.skipControl && CONTROL_ATTRS.has(rawName)) {\n continue\n }\n const eventInfo = parseEventAttribute(rawName)\n if (eventInfo) {\n const event = eventInfo.rawEvent.toLowerCase()\n const handlerExpr = buildExpression(parseInterpolations(rawValue ?? ''), scopeVar, wxsVar)\n const domEvent = EVENT_KIND_ALIAS[event] ?? event\n const flags = {\n catch: eventInfo.prefix.includes('catch'),\n capture: eventInfo.prefix.includes('capture'),\n }\n buffer += ` @${domEvent}=\\${ctx.event(${JSON.stringify(event)}, ${handlerExpr}, ${scopeVar}, ${wxsVar}, ${JSON.stringify(flags)})}`\n continue\n }\n const useProperty = options?.preferProperty && shouldBindAsProperty(rawName)\n const name = useProperty ? normalizePropertyName(rawName) : normalizeAttributeName(rawName)\n const expr = buildExpression(parseInterpolations(rawValue ?? ''), scopeVar, wxsVar)\n buffer += ` ${useProperty ? '.' : ''}${name}=\\${${expr}}`\n }\n return buffer\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,WAAW,SAAiC;CAC1D,MAAM,OAAO,6BAA6B,SAAS,KAAK;CACxD,MAAM,WAAW,6BAA6B,SAAS,UAAU,GAAG,KAAK,KAAK;CAC9E,IAAI,YAAY,6BAA6B,SAAS,WAAW,GAAG,KAAK,KAAK;CAC9E,MAAM,MAAM,6BAA6B,SAAS,KAAK;CACvD,MAAM,cAAsC,CAAC;CAC7C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAAG;EACnD,IAAI,cAAc,IAAI,IAAI,GACxB;EAEF,YAAY,QAAQ;CACtB;CACA,IAAI,aAAa,WACf,YAAY,GAAG,UAAU;CAE3B,OAAO;EAAE;EAAM;EAAU;EAAW;EAAK;CAAY;AACvD;AAEA,SAAgB,qBAAqB,MAA6C;CAChF,IAAI,KAAK,SAAS,WAChB,OAAO;CAET,MAAM,UAAU,KAAK,WA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EAC7C,IAAI,WAAW;GACb,MAAM,QAAQ,UAAU,SAAS,YAAY;GAC7C,MAAM,cAAc,gBAAgB,oBAAoB,YAAY,EAAE,GAAG,UAAU,MAAM;GACzF,MAAM,WAAW,iBAAiB,UAAU;GAC5C,MAAM,QAAQ;IACZ,OAAO,UAAU,OAAO,SAAS,OAAO;IACxC,SAAS,UAAU,OAAO,SAAS,SAAS;GAC9C;GACA,UAAU,KAAK,SAAS,gBAAgB,KAAK,UAAU,KAAK,EAAE,IAAI,YAAY,IAAI,SAAS,IAAI,OAAO,IAAI,KAAK,UAAU,KAAK,EAAE;GAChI;EACF;EACA,MAAM,cAAc,SAAS,kBAAkB,qBAAqB,OAAO;EAC3E,MAAM,OAAO,cAAc,sBAAsB,OAAO,IAAI,uBAAuB,OAAO;EAC1F,MAAM,OAAO,gBAAgB,oBAAoB,YAAY,EAAE,GAAG,UAAU,MAAM;EAClF,UAAU,IAAI,cAAc,MAAM,KAAK,KAAK,MAAM,KAAK;CACzD;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"attributes.mjs","names":[],"sources":["../../../src/compiler/wxml/attributes.ts"],"sourcesContent":["import type { RenderElementNode, RenderNode } from './types'\nimport {\n CONTROL_ATTRS,\n EVENT_KIND_ALIAS,\n EVENT_PREFIX_RE,\n hasControlAttribute,\n normalizeAttributeName,\n resolveControlAttributeValue,\n} from '../../shared/wxml'\nimport { buildExpression, parseInterpolations } from './interpolation'\n\nexport function extractFor(attribs: Record<string, string>) {\n const expr = resolveControlAttributeValue(attribs, 'for')\n const itemName = resolveControlAttributeValue(attribs, 'for-item')?.trim() || 'item'\n let indexName = resolveControlAttributeValue(attribs, 'for-index')?.trim() || 'index'\n const key = resolveControlAttributeValue(attribs, 'key')\n const restAttribs: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(name)) {\n continue\n }\n restAttribs[name] = value\n }\n if (itemName === indexName) {\n indexName = `${indexName}Index`\n }\n return { expr, itemName, indexName, key, restAttribs }\n}\n\nexport function isConditionalElement(node: RenderNode): node is RenderElementNode {\n if (node.type !== 'element') {\n return false\n }\n const attribs = node.attribs ?? {}\n return hasControlAttribute(attribs, 'if')\n || hasControlAttribute(attribs, 'elif')\n || hasControlAttribute(attribs, 'else')\n}\n\nexport function stripControlAttributes(attribs: Record<string, string>) {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (!CONTROL_ATTRS.has(name)) {\n result[name] = value\n }\n }\n return result\n}\n\nfunction parseEventAttribute(name: string) {\n if (name.includes(':')) {\n const [prefix, rawEvent] = name.split(':', 2)\n return { prefix, rawEvent }\n }\n const match = EVENT_PREFIX_RE.exec(name)\n if (!match) {\n return undefined\n }\n return { prefix: name.slice(0, name.length - match[1].length), rawEvent: match[1] }\n}\n\nexport function resolveComponentTagName(name: string, componentTags?: Record<string, string>) {\n if (!componentTags) {\n return undefined\n }\n return componentTags[name] ?? componentTags[name.toLowerCase()]\n}\n\nconst PROPERTY_BIND_EXCLUSIONS = new Set(['class', 'style', 'id', 'slot'])\n\nfunction shouldBindAsProperty(name: string) {\n if (PROPERTY_BIND_EXCLUSIONS.has(name)) {\n return false\n }\n if (name.startsWith('data-') || name.startsWith('aria-')) {\n return false\n }\n return true\n}\n\nfunction normalizePropertyName(name: string) {\n return name.replace(/-([a-z])/g, (_, char: string) => char.toUpperCase())\n}\n\nexport function renderAttributes(\n attribs: Record<string, string>,\n scopeVar: string,\n wxsVar: string,\n options?: { skipControl?: boolean, preferProperty?: boolean },\n) {\n let buffer = ''\n for (const [rawName, rawValue] of Object.entries(attribs)) {\n if (options?.skipControl && CONTROL_ATTRS.has(rawName)) {\n continue\n }\n const eventInfo = parseEventAttribute(rawName)\n if (eventInfo) {\n const event = eventInfo.rawEvent.toLowerCase()\n const handlerExpr = buildExpression(parseInterpolations(rawValue ?? ''), scopeVar, wxsVar)\n const domEvent = EVENT_KIND_ALIAS[event] ?? event\n const flags = {\n catch: eventInfo.prefix.includes('catch'),\n capture: eventInfo.prefix.includes('capture'),\n }\n buffer += ` @${domEvent}=\\${ctx.event(${JSON.stringify(event)}, ${handlerExpr}, ${scopeVar}, ${wxsVar}, ${JSON.stringify(flags)})}`\n continue\n }\n const useProperty = options?.preferProperty && shouldBindAsProperty(rawName)\n const name = useProperty ? normalizePropertyName(rawName) : normalizeAttributeName(rawName)\n const expr = buildExpression(parseInterpolations(rawValue ?? ''), scopeVar, wxsVar)\n buffer += ` ${useProperty ? '.' : ''}${name}=\\${${expr}}`\n }\n return buffer\n}\n"],"mappings":";;;;AAWA,SAAgB,WAAW,SAAiC;CAC1D,MAAM,OAAO,6BAA6B,SAAS,KAAK;CACxD,MAAM,WAAW,6BAA6B,SAAS,UAAU,GAAG,KAAK,KAAK;CAC9E,IAAI,YAAY,6BAA6B,SAAS,WAAW,GAAG,KAAK,KAAK;CAC9E,MAAM,MAAM,6BAA6B,SAAS,KAAK;CACvD,MAAM,cAAsC,CAAC;CAC7C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAAG;EACnD,IAAI,cAAc,IAAI,IAAI,GACxB;EAEF,YAAY,QAAQ;CACtB;CACA,IAAI,aAAa,WACf,YAAY,GAAG,UAAU;CAE3B,OAAO;EAAE;EAAM;EAAU;EAAW;EAAK;CAAY;AACvD;AAEA,SAAgB,qBAAqB,MAA6C;CAChF,IAAI,KAAK,SAAS,WAChB,OAAO;CAET,MAAM,UAAU,KAAK,WAAW,CAAC;CACjC,OAAO,oBAAoB,SAAS,IAAI,KACnC,oBAAoB,SAAS,MAAM,KACnC,oBAAoB,SAAS,MAAM;AAC1C;AAEA,SAAgB,uBAAuB,SAAiC;CACtE,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,CAAC,cAAc,IAAI,IAAI,GACzB,OAAO,QAAQ;CAGnB,OAAO;AACT;AAEA,SAAS,oBAAoB,MAAc;CACzC,IAAI,KAA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SAAS,IAAI,OAAO,IAAI,KAAK,UAAU,KAAK,EAAE;GAChI;EACF;EACA,MAAM,cAAc,SAAS,kBAAkB,qBAAqB,OAAO;EAC3E,MAAM,OAAO,cAAc,sBAAsB,OAAO,IAAI,uBAAuB,OAAO;EAC1F,MAAM,OAAO,gBAAgB,oBAAoB,YAAY,EAAE,GAAG,UAAU,MAAM;EAClF,UAAU,IAAI,cAAc,MAAM,KAAK,KAAK,MAAM,KAAK;CACzD;CACA,OAAO;AACT"}
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { addDependency, createDependencyContext, warnCircularTemplate, warnReadTemplate } from "./dependency.mjs";
10
2
  import { buildNavigationBarAttrs, extractNavigationBarFromPageMeta } from "./navigation.mjs";
11
3
  import { parseWxml } from "./parser.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"compile.mjs","names":[],"sources":["../../../src/compiler/wxml/compile.ts"],"sourcesContent":["import type {\n ImportEntry,\n IncludeEntry,\n TemplateDefinition,\n WxmlCompileOptions,\n WxmlCompileResult,\n WxsEntry,\n} from './types'\n\nimport { readFileSync } from 'node:fs'\nimport { addDependency, createDependencyContext, warnCircularTemplate, warnReadTemplate } from './dependency'\nimport { buildNavigationBarAttrs, extractNavigationBarFromPageMeta } from './navigation'\nimport { parseWxml } from './parser'\nimport { renderer } from './renderer'\nimport { collectSpecialNodes, normalizeTemplatePath, shouldMarkWxsImport, toRelativeImport } from './specialNodes'\n\nexport function compileWxml(options: WxmlCompileOptions): WxmlCompileResult {\n const dependencyContext = options.dependencyContext ?? createDependencyContext()\n const expandDependencies = options.expandDependencies ?? !options.dependencyContext\n const warnings = dependencyContext.warnings\n\n const expandDependencyTree = (dependencies: string[], importer: string) => {\n for (const target of dependencies) {\n if (!target) {\n continue\n }\n if (dependencyContext.active.has(target)) {\n warnCircularTemplate(dependencyContext, importer, target)\n continue\n }\n if (dependencyContext.visited.has(target)) {\n continue\n }\n dependencyContext.visited.add(target)\n dependencyContext.active.add(target)\n let source: string\n try {\n source = readFileSync(target, 'utf8')\n }\n catch {\n warnReadTemplate(dependencyContext, target)\n dependencyContext.active.delete(target)\n continue\n }\n try {\n const result = compileWxml({\n id: target,\n source,\n resolveTemplatePath: options.resolveTemplatePath,\n resolveWxsPath: options.resolveWxsPath,\n dependencyContext,\n expandDependencies: false,\n })\n expandDependencyTree(result.dependencies, target)\n }\n catch (error) {\n if (error instanceof Error && error.message) {\n warnings.push(`[web] 无法解析模板依赖: ${target} ${error.message}`)\n }\n }\n dependencyContext.active.delete(target)\n }\n }\n\n let nodes = parseWxml(options.source)\n let navigationBarAttrs: Record<string, string> | undefined\n if (options.navigationBar) {\n const extracted = extractNavigationBarFromPageMeta(nodes)\n nodes = extracted.nodes\n if (extracted.warnings.length > 0) {\n warnings.push(...extracted.warnings)\n }\n navigationBarAttrs = extracted.attrs\n }\n\n const templates: TemplateDefinition[] = []\n const includes: IncludeEntry[] = []\n const imports: ImportEntry[] = []\n const wxs: WxsEntry[] = []\n const wxsModules = new Map<string, string>()\n\n const renderNodesList = collectSpecialNodes(nodes, {\n templates,\n includes,\n imports,\n wxs,\n wxsModules,\n warnings,\n sourceId: options.id,\n resolveTemplate: (raw: string) => options.resolveTemplatePath(raw, options.id),\n resolveWxs: (raw: string) => options.resolveWxsPath(raw, options.id),\n })\n\n if (options.navigationBar && options.navigationBar.config.navigationStyle !== 'custom') {\n const attrs = buildNavigationBarAttrs(options.navigationBar.config, navigationBarAttrs)\n renderNodesList.unshift({\n type: 'element',\n name: 'weapp-navigation-bar',\n attribs: attrs,\n })\n }\n\n const importLines: string[] = [\n `import { html } from 'lit'`,\n `import { repeat } from 'lit/directives/repeat.js'`,\n ]\n const bodyLines: string[] = []\n const directDependencies: string[] = []\n\n for (const entry of imports) {\n const importPath = normalizeTemplatePath(toRelativeImport(options.id, entry.id))\n importLines.push(`import { templates as ${entry.importName} } from '${importPath}'`)\n addDependency(entry.id, dependencyContext, directDependencies)\n }\n\n for (const entry of includes) {\n const importPath = normalizeTemplatePath(toRelativeImport(options.id, entry.id))\n importLines.push(`import { render as ${entry.importName} } from '${importPath}'`)\n addDependency(entry.id, dependencyContext, directDependencies)\n }\n\n for (const entry of wxs) {\n if (entry.kind === 'src') {\n const baseImport = normalizeTemplatePath(toRelativeImport(options.id, entry.value))\n const importPath = shouldMarkWxsImport(entry.value)\n ? `${baseImport}?wxs`\n : baseImport\n importLines.push(`import ${entry.importName} from '${importPath}'`)\n addDependency(entry.value, dependencyContext, directDependencies)\n }\n }\n\n if (templates.length > 0 || imports.length > 0) {\n const templatePairs: string[] = []\n for (const entry of imports) {\n templatePairs.push(`...${entry.importName}`)\n }\n for (const template of templates) {\n const rendered = renderer.renderNodes(template.nodes, 'scope', '__wxs_modules', options.componentTags)\n templatePairs.push(`${JSON.stringify(template.name)}: (scope, ctx) => ${rendered}`)\n }\n bodyLines.push(`const __templates = { ${templatePairs.join(', ')} }`)\n }\n else {\n bodyLines.push(`const __templates = {}`)\n }\n\n if (wxs.length > 0) {\n bodyLines.push(`const __wxs_inline_cache = Object.create(null)`)\n bodyLines.push(`let __wxs_modules = {}`)\n const wxsMapEntries: string[] = []\n for (const entry of wxs) {\n if (entry.kind === 'inline') {\n const inlineCode = entry.value.trim()\n const cacheKey = JSON.stringify(entry.module)\n if (inlineCode) {\n bodyLines.push(`function ${entry.importName}(ctx) {`)\n bodyLines.push(` if (!__wxs_inline_cache[${cacheKey}]) {`)\n bodyLines.push(` __wxs_inline_cache[${cacheKey}] = ctx.createWxsModule(${JSON.stringify(inlineCode)}, ${JSON.stringify(options.id)})`)\n bodyLines.push(` }`)\n bodyLines.push(` return __wxs_inline_cache[${cacheKey}]`)\n bodyLines.push(`}`)\n }\n else {\n bodyLines.push(`function ${entry.importName}() { return {} }`)\n }\n wxsMapEntries.push(`${JSON.stringify(entry.module)}: ${entry.importName}(ctx)`)\n continue\n }\n wxsMapEntries.push(`${JSON.stringify(entry.module)}: ${entry.importName}`)\n }\n bodyLines.push(`function __resolveWxsModules(ctx) {`)\n bodyLines.push(` return { ${wxsMapEntries.join(', ')} }`)\n bodyLines.push(`}`)\n }\n else {\n bodyLines.push(`const __wxs_modules = {}`)\n }\n\n const includesRender = includes.map(entry => `${entry.importName}(scope, ctx)`)\n const renderContent = renderer.renderNodes(renderNodesList, 'scope', '__wxs_modules', options.componentTags)\n const contentExpr = includesRender.length > 0\n ? `[${[...includesRender, renderContent].join(', ')}]`\n : renderContent\n\n bodyLines.push(`export function render(scope, ctx) {`)\n if (wxs.length > 0) {\n bodyLines.push(` __wxs_modules = __resolveWxsModules(ctx)`)\n }\n bodyLines.push(` return ${contentExpr}`)\n bodyLines.push(`}`)\n bodyLines.push(`export const templates = __templates`)\n bodyLines.push(`export default render`)\n\n if (expandDependencies) {\n dependencyContext.visited.add(options.id)\n dependencyContext.active.add(options.id)\n expandDependencyTree(directDependencies, options.id)\n dependencyContext.active.delete(options.id)\n }\n\n const code = [...importLines, '', ...bodyLines].join('\\n')\n const dependencies = expandDependencies ? dependencyContext.dependencies : directDependencies\n return {\n code,\n dependencies,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,YAAY,SAAgD;CAC1E,MAAM,oBAAoB,QAAQ,qBAAqB,wBAAwB;CAC/E,MAAM,qBAAqB,QAAQ,sBAAsB,CAAC,QAAQ;CAClE,MAAM,WAAW,kBAAkB;CAEnC,MAAM,wBAAwB,cAAwB,aAAqB;EACzE,KAAK,MAAM,UAAU,cAAc;GACjC,IAAI,CAAC,QACH;GAEF,IAAI,kBAAkB,OAAO,IAAI,MAAM,GAAG;IACxC,qBAAqB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4C;CAE7D,UAAU,KAAK,YAAY,aAAa;CACxC,UAAU,KAAK,GAAG;CAClB,UAAU,KAAK,sCAAsC;CACrD,UAAU,KAAK,uBAAuB;CAEtC,IAAI,oBAAoB;EACtB,kBAAkB,QAAQ,IAAI,QAAQ,EAAE;EACxC,kBAAkB,OAAO,IAAI,QAAQ,EAAE;EACvC,qBAAqB,oBAAoB,QAAQ,EAAE;EACnD,kBAAkB,OAAO,OAAO,QAAQ,EAAE;CAC5C;CAIA,OAAO;EACL,MAHW;GAAC,GAAG;GAAa;GAAI,GAAG;EAAS,EAAE,KAAK,IAGhD;EACH,cAHmB,qBAAqB,kBAAkB,eAAe;EAIzE,UAAU,SAAS,SAAS,IAAI,WAAW;CAC7C;AACF"}
1
+ {"version":3,"file":"compile.mjs","names":[],"sources":["../../../src/compiler/wxml/compile.ts"],"sourcesContent":["import type {\n ImportEntry,\n IncludeEntry,\n TemplateDefinition,\n WxmlCompileOptions,\n WxmlCompileResult,\n WxsEntry,\n} from './types'\n\nimport { readFileSync } from 'node:fs'\nimport { addDependency, createDependencyContext, warnCircularTemplate, warnReadTemplate } from './dependency'\nimport { buildNavigationBarAttrs, extractNavigationBarFromPageMeta } from './navigation'\nimport { parseWxml } from './parser'\nimport { renderer } from './renderer'\nimport { collectSpecialNodes, normalizeTemplatePath, shouldMarkWxsImport, toRelativeImport } from './specialNodes'\n\nexport function compileWxml(options: WxmlCompileOptions): WxmlCompileResult {\n const dependencyContext = options.dependencyContext ?? createDependencyContext()\n const expandDependencies = options.expandDependencies ?? !options.dependencyContext\n const warnings = dependencyContext.warnings\n\n const expandDependencyTree = (dependencies: string[], importer: string) => {\n for (const target of dependencies) {\n if (!target) {\n continue\n }\n if (dependencyContext.active.has(target)) {\n warnCircularTemplate(dependencyContext, importer, target)\n continue\n }\n if (dependencyContext.visited.has(target)) {\n continue\n }\n dependencyContext.visited.add(target)\n dependencyContext.active.add(target)\n let source: string\n try {\n source = readFileSync(target, 'utf8')\n }\n catch {\n warnReadTemplate(dependencyContext, target)\n dependencyContext.active.delete(target)\n continue\n }\n try {\n const result = compileWxml({\n id: target,\n source,\n resolveTemplatePath: options.resolveTemplatePath,\n resolveWxsPath: options.resolveWxsPath,\n dependencyContext,\n expandDependencies: false,\n })\n expandDependencyTree(result.dependencies, target)\n }\n catch (error) {\n if (error instanceof Error && error.message) {\n warnings.push(`[web] 无法解析模板依赖: ${target} ${error.message}`)\n }\n }\n dependencyContext.active.delete(target)\n }\n }\n\n let nodes = parseWxml(options.source)\n let navigationBarAttrs: Record<string, string> | undefined\n if (options.navigationBar) {\n const extracted = extractNavigationBarFromPageMeta(nodes)\n nodes = extracted.nodes\n if (extracted.warnings.length > 0) {\n warnings.push(...extracted.warnings)\n }\n navigationBarAttrs = extracted.attrs\n }\n\n const templates: TemplateDefinition[] = []\n const includes: IncludeEntry[] = []\n const imports: ImportEntry[] = []\n const wxs: WxsEntry[] = []\n const wxsModules = new Map<string, string>()\n\n const renderNodesList = collectSpecialNodes(nodes, {\n templates,\n includes,\n imports,\n wxs,\n wxsModules,\n warnings,\n sourceId: options.id,\n resolveTemplate: (raw: string) => options.resolveTemplatePath(raw, options.id),\n resolveWxs: (raw: string) => options.resolveWxsPath(raw, options.id),\n })\n\n if (options.navigationBar && options.navigationBar.config.navigationStyle !== 'custom') {\n const attrs = buildNavigationBarAttrs(options.navigationBar.config, navigationBarAttrs)\n renderNodesList.unshift({\n type: 'element',\n name: 'weapp-navigation-bar',\n attribs: attrs,\n })\n }\n\n const importLines: string[] = [\n `import { html } from 'lit'`,\n `import { repeat } from 'lit/directives/repeat.js'`,\n ]\n const bodyLines: string[] = []\n const directDependencies: string[] = []\n\n for (const entry of imports) {\n const importPath = normalizeTemplatePath(toRelativeImport(options.id, entry.id))\n importLines.push(`import { templates as ${entry.importName} } from '${importPath}'`)\n addDependency(entry.id, dependencyContext, directDependencies)\n }\n\n for (const entry of includes) {\n const importPath = normalizeTemplatePath(toRelativeImport(options.id, entry.id))\n importLines.push(`import { render as ${entry.importName} } from '${importPath}'`)\n addDependency(entry.id, dependencyContext, directDependencies)\n }\n\n for (const entry of wxs) {\n if (entry.kind === 'src') {\n const baseImport = normalizeTemplatePath(toRelativeImport(options.id, entry.value))\n const importPath = shouldMarkWxsImport(entry.value)\n ? `${baseImport}?wxs`\n : baseImport\n importLines.push(`import ${entry.importName} from '${importPath}'`)\n addDependency(entry.value, dependencyContext, directDependencies)\n }\n }\n\n if (templates.length > 0 || imports.length > 0) {\n const templatePairs: string[] = []\n for (const entry of imports) {\n templatePairs.push(`...${entry.importName}`)\n }\n for (const template of templates) {\n const rendered = renderer.renderNodes(template.nodes, 'scope', '__wxs_modules', options.componentTags)\n templatePairs.push(`${JSON.stringify(template.name)}: (scope, ctx) => ${rendered}`)\n }\n bodyLines.push(`const __templates = { ${templatePairs.join(', ')} }`)\n }\n else {\n bodyLines.push(`const __templates = {}`)\n }\n\n if (wxs.length > 0) {\n bodyLines.push(`const __wxs_inline_cache = Object.create(null)`)\n bodyLines.push(`let __wxs_modules = {}`)\n const wxsMapEntries: string[] = []\n for (const entry of wxs) {\n if (entry.kind === 'inline') {\n const inlineCode = entry.value.trim()\n const cacheKey = JSON.stringify(entry.module)\n if (inlineCode) {\n bodyLines.push(`function ${entry.importName}(ctx) {`)\n bodyLines.push(` if (!__wxs_inline_cache[${cacheKey}]) {`)\n bodyLines.push(` __wxs_inline_cache[${cacheKey}] = ctx.createWxsModule(${JSON.stringify(inlineCode)}, ${JSON.stringify(options.id)})`)\n bodyLines.push(` }`)\n bodyLines.push(` return __wxs_inline_cache[${cacheKey}]`)\n bodyLines.push(`}`)\n }\n else {\n bodyLines.push(`function ${entry.importName}() { return {} }`)\n }\n wxsMapEntries.push(`${JSON.stringify(entry.module)}: ${entry.importName}(ctx)`)\n continue\n }\n wxsMapEntries.push(`${JSON.stringify(entry.module)}: ${entry.importName}`)\n }\n bodyLines.push(`function __resolveWxsModules(ctx) {`)\n bodyLines.push(` return { ${wxsMapEntries.join(', ')} }`)\n bodyLines.push(`}`)\n }\n else {\n bodyLines.push(`const __wxs_modules = {}`)\n }\n\n const includesRender = includes.map(entry => `${entry.importName}(scope, ctx)`)\n const renderContent = renderer.renderNodes(renderNodesList, 'scope', '__wxs_modules', options.componentTags)\n const contentExpr = includesRender.length > 0\n ? `[${[...includesRender, renderContent].join(', ')}]`\n : renderContent\n\n bodyLines.push(`export function render(scope, ctx) {`)\n if (wxs.length > 0) {\n bodyLines.push(` __wxs_modules = __resolveWxsModules(ctx)`)\n }\n bodyLines.push(` return ${contentExpr}`)\n bodyLines.push(`}`)\n bodyLines.push(`export const templates = __templates`)\n bodyLines.push(`export default render`)\n\n if (expandDependencies) {\n dependencyContext.visited.add(options.id)\n dependencyContext.active.add(options.id)\n expandDependencyTree(directDependencies, options.id)\n dependencyContext.active.delete(options.id)\n }\n\n const code = [...importLines, '', ...bodyLines].join('\\n')\n const dependencies = expandDependencies ? dependencyContext.dependencies : directDependencies\n return {\n code,\n dependencies,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n}\n"],"mappings":";;;;;;;;AAgBA,SAAgB,YAAY,SAAgD;CAC1E,MAAM,oBAAoB,QAAQ,qBAAqB,wBAAwB;CAC/E,MAAM,qBAAqB,QAAQ,sBAAsB,CAAC,QAAQ;CAClE,MAAM,WAAW,kBAAkB;CAEnC,MAAM,wBAAwB,cAAwB,aAAqB;EACzE,KAAK,MAAM,UAAU,cAAc;GACjC,IAAI,CAAC,QACH;GAEF,IAAI,kBAAkB,OAAO,IAAI,MAAM,GAAG;IACxC,qBAAqB,mBAAmB,UAAU,MAAM;IACxD;GACF;GACA,IAAI,kBAAkB,QAAQ,IAAI,MAAM,GACtC;GAEF,kBAAkB,QAAQ,IAAI,MAAM;GACpC,kBAAkB,OAAO,IAAI,MAAM;GACnC,IAAI;GACJ,IAAI;IACF,SAAS,aAAa,QAAQ,MAAM;GACtC,QACM;IACJ,iBAAiB,mBAAmB,MAAM;IAC1C,kBAAkB,OAAO,OAAO,MAAM;IAC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AO,QAAQ,EAAE;CAC5C;CAIA,OAAO;EACL,MAHW;GAAC,GAAG;GAAa;GAAI,GAAG;EAAS,EAAE,KAAK,IAGhD;EACH,cAHmB,qBAAqB,kBAAkB,eAAe;EAIzE,UAAU,SAAS,SAAS,IAAI,WAAW;CAC7C;AACF"}
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  //#region src/compiler/wxml/dependency.ts
10
2
  function createDependencyContext() {
11
3
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"dependency.mjs","names":[],"sources":["../../../src/compiler/wxml/dependency.ts"],"sourcesContent":["import type { WxmlDependencyContext } from './types'\n\nexport function createDependencyContext(): WxmlDependencyContext {\n return {\n warnings: [],\n dependencies: [],\n dependencySet: new Set(),\n visited: new Set(),\n active: new Set(),\n circularWarnings: new Set(),\n }\n}\n\nexport function addDependency(\n value: string,\n context: WxmlDependencyContext,\n direct?: string[],\n) {\n if (!context.dependencySet.has(value)) {\n context.dependencySet.add(value)\n context.dependencies.push(value)\n direct?.push(value)\n }\n}\n\nexport function warnReadTemplate(context: WxmlDependencyContext, target: string) {\n context.warnings.push(`[web] 无法读取模板依赖: ${target}`)\n}\n\nexport function warnCircularTemplate(\n context: WxmlDependencyContext,\n from: string,\n target: string,\n) {\n const key = `${from}=>${target}`\n if (context.circularWarnings.has(key)) {\n return\n }\n context.circularWarnings.add(key)\n context.warnings.push(`[web] WXML 循环引用: ${from} -> ${target}`)\n}\n"],"mappings":";;;;;;;;;AAEA,SAAgB,0BAAiD;CAC/D,OAAO;EACL,UAAU,CAAC;EACX,cAAc,CAAC;EACf,+BAAe,IAAI,IAAI;EACvB,yBAAS,IAAI,IAAI;EACjB,wBAAQ,IAAI,IAAI;EAChB,kCAAkB,IAAI,IAAI;CAC5B;AACF;AAEA,SAAgB,cACd,OACA,SACA,QACA;CACA,IAAI,CAAC,QAAQ,cAAc,IAAI,KAAK,GAAG;EACrC,QAAQ,cAAc,IAAI,KAAK;EAC/B,QAAQ,aAAa,KAAK,KAAK;EAC/B,QAAQ,KAAK,KAAK;CACpB;AACF;AAEA,SAAgB,iBAAiB,SAAgC,QAAgB;CAC/E,QAAQ,SAAS,KAAK,mBAAmB,QAAQ;AACnD;AAEA,SAAgB,qBACd,SACA,MACA,QACA;CACA,MAAM,MAAM,GAAG,KAAK,IAAI;CACxB,IAAI,QAAQ,iBAAiB,IAAI,GAAG,GAClC;CAEF,QAAQ,iBAAiB,IAAI,GAAG;CAChC,QAAQ,SAAS,KAAK,oBAAoB,KAAK,MAAM,QAAQ;AAC/D"}
1
+ {"version":3,"file":"dependency.mjs","names":[],"sources":["../../../src/compiler/wxml/dependency.ts"],"sourcesContent":["import type { WxmlDependencyContext } from './types'\n\nexport function createDependencyContext(): WxmlDependencyContext {\n return {\n warnings: [],\n dependencies: [],\n dependencySet: new Set(),\n visited: new Set(),\n active: new Set(),\n circularWarnings: new Set(),\n }\n}\n\nexport function addDependency(\n value: string,\n context: WxmlDependencyContext,\n direct?: string[],\n) {\n if (!context.dependencySet.has(value)) {\n context.dependencySet.add(value)\n context.dependencies.push(value)\n direct?.push(value)\n }\n}\n\nexport function warnReadTemplate(context: WxmlDependencyContext, target: string) {\n context.warnings.push(`[web] 无法读取模板依赖: ${target}`)\n}\n\nexport function warnCircularTemplate(\n context: WxmlDependencyContext,\n from: string,\n target: string,\n) {\n const key = `${from}=>${target}`\n if (context.circularWarnings.has(key)) {\n return\n }\n context.circularWarnings.add(key)\n context.warnings.push(`[web] WXML 循环引用: ${from} -> ${target}`)\n}\n"],"mappings":";AAEA,SAAgB,0BAAiD;CAC/D,OAAO;EACL,UAAU,CAAC;EACX,cAAc,CAAC;EACf,+BAAe,IAAI,IAAI;EACvB,yBAAS,IAAI,IAAI;EACjB,wBAAQ,IAAI,IAAI;EAChB,kCAAkB,IAAI,IAAI;CAC5B;AACF;AAEA,SAAgB,cACd,OACA,SACA,QACA;CACA,IAAI,CAAC,QAAQ,cAAc,IAAI,KAAK,GAAG;EACrC,QAAQ,cAAc,IAAI,KAAK;EAC/B,QAAQ,aAAa,KAAK,KAAK;EAC/B,QAAQ,KAAK,KAAK;CACpB;AACF;AAEA,SAAgB,iBAAiB,SAAgC,QAAgB;CAC/E,QAAQ,SAAS,KAAK,mBAAmB,QAAQ;AACnD;AAEA,SAAgB,qBACd,SACA,MACA,QACA;CACA,MAAM,MAAM,GAAG,KAAK,IAAI;CACxB,IAAI,QAAQ,iBAAiB,IAAI,GAAG,GAClC;CAEF,QAAQ,iBAAiB,IAAI,GAAG;CAChC,QAAQ,SAAS,KAAK,oBAAoB,KAAK,MAAM,QAAQ;AAC/D"}
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  //#region src/compiler/wxml/interpolation.ts
10
2
  function parseInterpolations(value) {
11
3
  const parts = [];
@@ -1 +1 @@
1
- {"version":3,"file":"interpolation.mjs","names":[],"sources":["../../../src/compiler/wxml/interpolation.ts"],"sourcesContent":["import type { InterpolationPart } from './types'\n\nexport function parseInterpolations(value: string): InterpolationPart[] {\n const parts: InterpolationPart[] = []\n if (!value.includes('{{')) {\n return [{ type: 'text', value }]\n }\n let cursor = 0\n while (cursor < value.length) {\n const start = value.indexOf('{{', cursor)\n if (start === -1) {\n parts.push({ type: 'text', value: value.slice(cursor) })\n break\n }\n if (start > cursor) {\n parts.push({ type: 'text', value: value.slice(cursor, start) })\n }\n const end = value.indexOf('}}', start + 2)\n if (end === -1) {\n parts.push({ type: 'text', value: value.slice(start) })\n break\n }\n const expr = value.slice(start + 2, end).trim()\n if (expr) {\n parts.push({ type: 'expr', value: expr })\n }\n cursor = end + 2\n }\n return parts\n}\n\nexport function buildExpression(parts: InterpolationPart[], scopeVar: string, wxsVar: string) {\n if (parts.length === 0) {\n return '\"\"'\n }\n if (parts.length === 1 && parts[0]?.type === 'text') {\n return JSON.stringify(parts[0].value)\n }\n if (parts.length === 1 && parts[0]?.type === 'expr') {\n return `ctx.eval(${JSON.stringify(parts[0].value)}, ${scopeVar}, ${wxsVar})`\n }\n const segments = parts.map((part) => {\n if (part.type === 'text') {\n return JSON.stringify(part.value)\n }\n return `ctx.eval(${JSON.stringify(part.value)}, ${scopeVar}, ${wxsVar})`\n })\n return `(${segments.join(' + ')})`\n}\n\nfunction hasTopLevelColon(expression: string) {\n let depth = 0\n let inSingleQuote = false\n let inDoubleQuote = false\n let inTemplate = false\n let escaped = false\n let sawTopLevelQuestion = false\n\n for (let index = 0; index < expression.length; index += 1) {\n const char = expression[index]!\n\n if (inSingleQuote) {\n if (escaped) {\n escaped = false\n continue\n }\n if (char === '\\\\') {\n escaped = true\n continue\n }\n if (char === '\\'') {\n inSingleQuote = false\n }\n continue\n }\n if (inDoubleQuote) {\n if (escaped) {\n escaped = false\n continue\n }\n if (char === '\\\\') {\n escaped = true\n continue\n }\n if (char === '\"') {\n inDoubleQuote = false\n }\n continue\n }\n if (inTemplate) {\n if (escaped) {\n escaped = false\n continue\n }\n if (char === '\\\\') {\n escaped = true\n continue\n }\n if (char === '`') {\n inTemplate = false\n }\n continue\n }\n\n if (char === '\\'') {\n inSingleQuote = true\n continue\n }\n if (char === '\"') {\n inDoubleQuote = true\n continue\n }\n if (char === '`') {\n inTemplate = true\n continue\n }\n\n if (char === '(' || char === '[' || char === '{') {\n depth += 1\n continue\n }\n if (char === ')' || char === ']' || char === '}') {\n depth = Math.max(0, depth - 1)\n continue\n }\n\n if (depth !== 0) {\n continue\n }\n\n if (char === '?') {\n sawTopLevelQuestion = true\n continue\n }\n if (char === ':') {\n return !sawTopLevelQuestion\n }\n }\n\n return false\n}\n\nfunction shouldWrapShorthandObject(expression: string) {\n const trimmed = expression.trim()\n if (!trimmed) {\n return false\n }\n if (trimmed.startsWith('{') || trimmed.startsWith('[') || trimmed.startsWith('(')) {\n return false\n }\n return hasTopLevelColon(trimmed)\n}\n\nexport function buildTemplateDataExpression(raw: string, scopeVar: string, wxsVar: string) {\n const trimmed = raw.trim()\n const parts = parseInterpolations(trimmed)\n if (parts.length === 1 && parts[0]?.type === 'expr') {\n const expr = parts[0].value.trim()\n if (expr) {\n const normalizedExpr = shouldWrapShorthandObject(expr) ? `{ ${expr} }` : expr\n return buildExpression([{ type: 'expr', value: normalizedExpr }], scopeVar, wxsVar)\n }\n }\n return buildExpression(parseInterpolations(raw), scopeVar, wxsVar)\n}\n"],"mappings":";;;;;;;;;AAEA,SAAgB,oBAAoB,OAAoC;CACtE,MAAM,QAA6B,CAAC;CACpC,IAAI,CAAC,MAAM,SAAS,IAAI,GACtB,OAAO,CAAC;EAAE,MAAM;EAAQ;CAAM,CAAC;CAEjC,IAAI,SAAS;CACb,OAAO,SAAS,MAAM,QAAQ;EAC5B,MAAM,QAAQ,MAAM,QAAQ,MAAM,MAAM;EACxC,IAAI,UAAU,IAAI;GAChB,MAAM,KAAK;IAAE,MAAM;IAAQ,OAAO,MAAM,MAAM,MAAM;GAAE,CAAC;GACvD;EACF;EACA,IAAI,QAAQ,QACV,MAAM,KAAK;GAAE,MAAM;GAAQ,OAAO,MAAM,MAAM,QAAQ,KAAK;EAAE,CAAC;EAEhE,MAAM,MAAM,MAAM,QAAQ,MAAM,QAAQ,CAAC;EACzC,IAAI,QAAQ,IAAI;GACd,MAAM,KAAK;IAAE,MAAM;IAAQ,OAAO,MAAM,MAAM,KAAK;GAAE,CAAC;GACtD;EACF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ACX,UAAU;IACV;GACF;GACA,IAAI,SAAS,MAAM;IACjB,UAAU;IACV;GACF;GACA,IAAI,SAAS,KACX,aAAa;GAEf;EACF;EAEA,IAAI,SAAS,KAAM;GACjB,gBAAgB;GAChB;EACF;EACA,IAAI,SAAS,MAAK;GAChB,gBAAgB;GAChB;EACF;EACA,IAAI,SAAS,KAAK;GAChB,aAAa;GACb;EACF;EAEA,IAAI,SAAS,OAAO,SAAS,OAAO,SAAS,KAAK;GAChD,SAAS;GACT;EACF;EACA,IAAI,SAAS,OAAO,SAAS,OAAO,SAAS,KAAK;GAChD,QAAQ,KAAK,IAAI,GAAG,QAAQ,CAAC;GAC7B;EACF;EAEA,IAAI,UAAU,GACZ;EAGF,IAAI,SAAS,KAAK;GAChB,sBAAsB;GACtB;EACF;EACA,IAAI,SAAS,KACX,OAAO,CAAC;CAEZ;CAEA,OAAO;AACT;AAEA,SAAS,0BAA0B,YAAoB;CACrD,MAAM,UAAU,WAAW,KAAK;CAChC,IAAI,CAAC,SACH,OAAO;CAET,IAAI,QAAQ,WAAW,GAAG,KAAK,QAAQ,WAAW,GAAG,KAAK,QAAQ,WAAW,GAAG,GAC9E,OAAO;CAET,OAAO,iBAAiB,OAAO;AACjC;AAEA,SAAgB,4BAA4B,KAAa,UAAkB,QAAgB;CAEzF,MAAM,QAAQ,oBADE,IAAI,KACoB,CAAC;CACzC,IAAI,MAAM,WAAW,KAAK,MAAM,IAAI,SAAS,QAAQ;EACnD,MAAM,OAAO,MAAM,GAAG,MAAM,KAAK;EACjC,IAAI,MAEF,OAAO,gBAAgB,CAAC;GAAE,MAAM;GAAQ,OADjB,0BAA0B,IAAI,IAAI,KAAK,KAAK,MAAM;EACX,CAAC,GAAG,UAAU,MAAM;CAEtF;CACA,OAAO,gBAAgB,oBAAoB,GAAG,GAAG,UAAU,MAAM;AACnE"}
1
+ {"version":3,"file":"interpolation.mjs","names":[],"sources":["../../../src/compiler/wxml/interpolation.ts"],"sourcesContent":["import type { InterpolationPart } from './types'\n\nexport function parseInterpolations(value: string): InterpolationPart[] {\n const parts: InterpolationPart[] = []\n if (!value.includes('{{')) {\n return [{ type: 'text', value }]\n }\n let cursor = 0\n while (cursor < value.length) {\n const start = value.indexOf('{{', cursor)\n if (start === -1) {\n parts.push({ type: 'text', value: value.slice(cursor) })\n break\n }\n if (start > cursor) {\n parts.push({ type: 'text', value: value.slice(cursor, start) })\n }\n const end = value.indexOf('}}', start + 2)\n if (end === -1) {\n parts.push({ type: 'text', value: value.slice(start) })\n break\n }\n const expr = value.slice(start + 2, end).trim()\n if (expr) {\n parts.push({ type: 'expr', value: expr })\n }\n cursor = end + 2\n }\n return parts\n}\n\nexport function buildExpression(parts: InterpolationPart[], scopeVar: string, wxsVar: string) {\n if (parts.length === 0) {\n return '\"\"'\n }\n if (parts.length === 1 && parts[0]?.type === 'text') {\n return JSON.stringify(parts[0].value)\n }\n if (parts.length === 1 && parts[0]?.type === 'expr') {\n return `ctx.eval(${JSON.stringify(parts[0].value)}, ${scopeVar}, ${wxsVar})`\n }\n const segments = parts.map((part) => {\n if (part.type === 'text') {\n return JSON.stringify(part.value)\n }\n return `ctx.eval(${JSON.stringify(part.value)}, ${scopeVar}, ${wxsVar})`\n })\n return `(${segments.join(' + ')})`\n}\n\nfunction hasTopLevelColon(expression: string) {\n let depth = 0\n let inSingleQuote = false\n let inDoubleQuote = false\n let inTemplate = false\n let escaped = false\n let sawTopLevelQuestion = false\n\n for (let index = 0; index < expression.length; index += 1) {\n const char = expression[index]!\n\n if (inSingleQuote) {\n if (escaped) {\n escaped = false\n continue\n }\n if (char === '\\\\') {\n escaped = true\n continue\n }\n if (char === '\\'') {\n inSingleQuote = false\n }\n continue\n }\n if (inDoubleQuote) {\n if (escaped) {\n escaped = false\n continue\n }\n if (char === '\\\\') {\n escaped = true\n continue\n }\n if (char === '\"') {\n inDoubleQuote = false\n }\n continue\n }\n if (inTemplate) {\n if (escaped) {\n escaped = false\n continue\n }\n if (char === '\\\\') {\n escaped = true\n continue\n }\n if (char === '`') {\n inTemplate = false\n }\n continue\n }\n\n if (char === '\\'') {\n inSingleQuote = true\n continue\n }\n if (char === '\"') {\n inDoubleQuote = true\n continue\n }\n if (char === '`') {\n inTemplate = true\n continue\n }\n\n if (char === '(' || char === '[' || char === '{') {\n depth += 1\n continue\n }\n if (char === ')' || char === ']' || char === '}') {\n depth = Math.max(0, depth - 1)\n continue\n }\n\n if (depth !== 0) {\n continue\n }\n\n if (char === '?') {\n sawTopLevelQuestion = true\n continue\n }\n if (char === ':') {\n return !sawTopLevelQuestion\n }\n }\n\n return false\n}\n\nfunction shouldWrapShorthandObject(expression: string) {\n const trimmed = expression.trim()\n if (!trimmed) {\n return false\n }\n if (trimmed.startsWith('{') || trimmed.startsWith('[') || trimmed.startsWith('(')) {\n return false\n }\n return hasTopLevelColon(trimmed)\n}\n\nexport function buildTemplateDataExpression(raw: string, scopeVar: string, wxsVar: string) {\n const trimmed = raw.trim()\n const parts = parseInterpolations(trimmed)\n if (parts.length === 1 && parts[0]?.type === 'expr') {\n const expr = parts[0].value.trim()\n if (expr) {\n const normalizedExpr = shouldWrapShorthandObject(expr) ? `{ ${expr} }` : expr\n return buildExpression([{ type: 'expr', value: normalizedExpr }], scopeVar, wxsVar)\n }\n }\n return buildExpression(parseInterpolations(raw), scopeVar, wxsVar)\n}\n"],"mappings":";AAEA,SAAgB,oBAAoB,OAAoC;CACtE,MAAM,QAA6B,CAAC;CACpC,IAAI,CAAC,MAAM,SAAS,IAAI,GACtB,OAAO,CAAC;EAAE,MAAM;EAAQ;CAAM,CAAC;CAEjC,IAAI,SAAS;CACb,OAAO,SAAS,MAAM,QAAQ;EAC5B,MAAM,QAAQ,MAAM,QAAQ,MAAM,MAAM;EACxC,IAAI,UAAU,IAAI;GAChB,MAAM,KAAK;IAAE,MAAM;IAAQ,OAAO,MAAM,MAAM,MAAM;GAAE,CAAC;GACvD;EACF;EACA,IAAI,QAAQ,QACV,MAAM,KAAK;GAAE,MAAM;GAAQ,OA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K,KAAK,MAAM;EACX,CAAC,GAAG,UAAU,MAAM;CAEtF;CACA,OAAO,gBAAgB,oBAAoB,GAAG,GAAG,UAAU,MAAM;AACnE"}
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  //#region src/compiler/wxml/navigation.ts
10
2
  const NAVIGATION_BAR_ATTRS = new Set([
11
3
  "title",
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.mjs","names":[],"sources":["../../../src/compiler/wxml/navigation.ts"],"sourcesContent":["import type { NavigationBarConfig, RenderElementNode, RenderNode } from './types'\n\nconst NAVIGATION_BAR_ATTRS = new Set([\n 'title',\n 'background-color',\n 'text-style',\n 'front-color',\n 'loading',\n])\n\nfunction stripPageMetaNodes(nodes: RenderNode[]): RenderNode[] {\n const stripped: RenderNode[] = []\n for (const node of nodes) {\n if (node.type === 'element' && node.name === 'page-meta') {\n continue\n }\n if (node.type === 'element' && node.children?.length) {\n const nextChildren = stripPageMetaNodes(node.children)\n if (nextChildren !== node.children) {\n stripped.push({ ...node, children: nextChildren })\n continue\n }\n }\n stripped.push(node)\n }\n return stripped\n}\n\nfunction pickNavigationBarAttrs(attribs: Record<string, string> | undefined) {\n if (!attribs) {\n return undefined\n }\n const picked: Record<string, string> = {}\n for (const [key, value] of Object.entries(attribs)) {\n if (NAVIGATION_BAR_ATTRS.has(key)) {\n picked[key] = value\n }\n }\n return Object.keys(picked).length > 0 ? picked : undefined\n}\n\nfunction findNavigationBarInPageMeta(node: RenderElementNode) {\n const children = node.children ?? []\n for (const child of children) {\n if (child.type === 'element' && child.name === 'navigation-bar') {\n return child\n }\n }\n return undefined\n}\n\nexport function extractNavigationBarFromPageMeta(nodes: RenderNode[]): {\n nodes: RenderNode[]\n attrs?: Record<string, string>\n warnings: string[]\n} {\n let pageMetaIndex = -1\n let navigationBar: RenderElementNode | undefined\n for (let i = 0; i < nodes.length; i += 1) {\n const node = nodes[i]\n if (node.type === 'element' && node.name === 'page-meta') {\n if (pageMetaIndex === -1) {\n pageMetaIndex = i\n }\n if (!navigationBar) {\n navigationBar = findNavigationBarInPageMeta(node)\n }\n }\n }\n const warnings: string[] = []\n if (pageMetaIndex > 0) {\n warnings.push('[web] page-meta 需要作为页面第一个节点,已忽略其位置约束。')\n }\n const cleaned = pageMetaIndex === -1 ? nodes : stripPageMetaNodes(nodes)\n const attrs = navigationBar ? pickNavigationBarAttrs(navigationBar.attribs) : undefined\n return { nodes: cleaned, attrs, warnings }\n}\n\nfunction toAttributeValue(value: unknown) {\n if (value == null) {\n return undefined\n }\n if (typeof value === 'string') {\n return value\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value)\n }\n return undefined\n}\n\nexport function buildNavigationBarAttrs(\n config: NavigationBarConfig | undefined,\n overrides?: Record<string, string>,\n) {\n const attrs: Record<string, string> = {}\n if (config?.title !== undefined) {\n const value = toAttributeValue(config.title)\n if (value !== undefined) {\n attrs.title = value\n }\n }\n if (config?.backgroundColor !== undefined) {\n const value = toAttributeValue(config.backgroundColor)\n if (value !== undefined) {\n attrs['background-color'] = value\n }\n }\n if (config?.textStyle !== undefined) {\n const value = toAttributeValue(config.textStyle)\n if (value !== undefined) {\n attrs['text-style'] = value\n }\n }\n if (config?.frontColor !== undefined) {\n const value = toAttributeValue(config.frontColor)\n if (value !== undefined) {\n attrs['front-color'] = value\n }\n }\n if (config?.loading) {\n attrs.loading = 'true'\n }\n if (overrides) {\n for (const [key, value] of Object.entries(overrides)) {\n attrs[key] = value\n }\n }\n return attrs\n}\n"],"mappings":";;;;;;;;;AAEA,MAAM,uBAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;AACF,CAAC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AI;EAC9C;CAAS;AAC3C;AAEA,SAAS,iBAAiB,OAAgB;CACxC,IAAI,SAAS,MACX;CAEF,IAAI,OAAO,UAAU,UACnB,OAAO;CAET,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;AAGvB;AAEA,SAAgB,wBACd,QACA,WACA;CACA,MAAM,QAAgC,CAAC;CACvC,IAAI,QAAQ,UAAU,QAAW;EAC/B,MAAM,QAAQ,iBAAiB,OAAO,KAAK;EAC3C,IAAI,UAAU,QACZ,MAAM,QAAQ;CAElB;CACA,IAAI,QAAQ,oBAAoB,QAAW;EACzC,MAAM,QAAQ,iBAAiB,OAAO,eAAe;EACrD,IAAI,UAAU,QACZ,MAAM,sBAAsB;CAEhC;CACA,IAAI,QAAQ,cAAc,QAAW;EACnC,MAAM,QAAQ,iBAAiB,OAAO,SAAS;EAC/C,IAAI,UAAU,QACZ,MAAM,gBAAgB;CAE1B;CACA,IAAI,QAAQ,eAAe,QAAW;EACpC,MAAM,QAAQ,iBAAiB,OAAO,UAAU;EAChD,IAAI,UAAU,QACZ,MAAM,iBAAiB;CAE3B;CACA,IAAI,QAAQ,SACV,MAAM,UAAU;CAElB,IAAI,WACF,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,GACjD,MAAM,OAAO;CAGjB,OAAO;AACT"}
1
+ {"version":3,"file":"navigation.mjs","names":[],"sources":["../../../src/compiler/wxml/navigation.ts"],"sourcesContent":["import type { NavigationBarConfig, RenderElementNode, RenderNode } from './types'\n\nconst NAVIGATION_BAR_ATTRS = new Set([\n 'title',\n 'background-color',\n 'text-style',\n 'front-color',\n 'loading',\n])\n\nfunction stripPageMetaNodes(nodes: RenderNode[]): RenderNode[] {\n const stripped: RenderNode[] = []\n for (const node of nodes) {\n if (node.type === 'element' && node.name === 'page-meta') {\n continue\n }\n if (node.type === 'element' && node.children?.length) {\n const nextChildren = stripPageMetaNodes(node.children)\n if (nextChildren !== node.children) {\n stripped.push({ ...node, children: nextChildren })\n continue\n }\n }\n stripped.push(node)\n }\n return stripped\n}\n\nfunction pickNavigationBarAttrs(attribs: Record<string, string> | undefined) {\n if (!attribs) {\n return undefined\n }\n const picked: Record<string, string> = {}\n for (const [key, value] of Object.entries(attribs)) {\n if (NAVIGATION_BAR_ATTRS.has(key)) {\n picked[key] = value\n }\n }\n return Object.keys(picked).length > 0 ? picked : undefined\n}\n\nfunction findNavigationBarInPageMeta(node: RenderElementNode) {\n const children = node.children ?? []\n for (const child of children) {\n if (child.type === 'element' && child.name === 'navigation-bar') {\n return child\n }\n }\n return undefined\n}\n\nexport function extractNavigationBarFromPageMeta(nodes: RenderNode[]): {\n nodes: RenderNode[]\n attrs?: Record<string, string>\n warnings: string[]\n} {\n let pageMetaIndex = -1\n let navigationBar: RenderElementNode | undefined\n for (let i = 0; i < nodes.length; i += 1) {\n const node = nodes[i]\n if (node.type === 'element' && node.name === 'page-meta') {\n if (pageMetaIndex === -1) {\n pageMetaIndex = i\n }\n if (!navigationBar) {\n navigationBar = findNavigationBarInPageMeta(node)\n }\n }\n }\n const warnings: string[] = []\n if (pageMetaIndex > 0) {\n warnings.push('[web] page-meta 需要作为页面第一个节点,已忽略其位置约束。')\n }\n const cleaned = pageMetaIndex === -1 ? nodes : stripPageMetaNodes(nodes)\n const attrs = navigationBar ? pickNavigationBarAttrs(navigationBar.attribs) : undefined\n return { nodes: cleaned, attrs, warnings }\n}\n\nfunction toAttributeValue(value: unknown) {\n if (value == null) {\n return undefined\n }\n if (typeof value === 'string') {\n return value\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value)\n }\n return undefined\n}\n\nexport function buildNavigationBarAttrs(\n config: NavigationBarConfig | undefined,\n overrides?: Record<string, string>,\n) {\n const attrs: Record<string, string> = {}\n if (config?.title !== undefined) {\n const value = toAttributeValue(config.title)\n if (value !== undefined) {\n attrs.title = value\n }\n }\n if (config?.backgroundColor !== undefined) {\n const value = toAttributeValue(config.backgroundColor)\n if (value !== undefined) {\n attrs['background-color'] = value\n }\n }\n if (config?.textStyle !== undefined) {\n const value = toAttributeValue(config.textStyle)\n if (value !== undefined) {\n attrs['text-style'] = value\n }\n }\n if (config?.frontColor !== undefined) {\n const value = toAttributeValue(config.frontColor)\n if (value !== undefined) {\n attrs['front-color'] = value\n }\n }\n if (config?.loading) {\n attrs.loading = 'true'\n }\n if (overrides) {\n for (const [key, value] of Object.entries(overrides)) {\n attrs[key] = value\n }\n }\n return attrs\n}\n"],"mappings":";AAEA,MAAM,uBAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,mBAAmB,OAAmC;CAC7D,MAAM,WAAyB,CAAC;CAChC,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,KAAK,SAAS,aAAa,KAAK,SAAS,aAC3C;EAEF,IAAI,KAAK,SAAS,aAAa,KAAK,UAAU,QAAQ;GACpD,MAAM,eAAe,mBAAmB,KAAK,QAAQ;GACrD,IAAI,iBAAiB,KAAK,UAAU;IAClC,SAAS,KAAK;KAAE,GAAG;KAAM,UAAU;IAAa,CAAC;IACjD;GACF;EACF;EACA,SAAS,KAAK,IAAI;CACpB;CACA,OAAO;AACT;AAEA,SAAS,uBAAuB,SAA6C;CAC3E,IAAI,CAAC,SACH;CAEF,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAC/C,IAAI,qBAAqB,IAAI,GAAG,GAC9B,OAAO,OAAO;CAGlB,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,SAAS;AACnD;AAEA,SAAS,4BAA4B,MAAyB;CAC5D,MAAM,WAAW,KAAK,YAAY,CAAC;CACnC,KAAK,MAAM,SAAS,UAClB,IAAI,MAAM,SAAS,aAAa,MAAM,SAAS,kBAC7C,OAAO;AAIb;AAEA,SAAgB,iCAAiC,OAI/C;CACA,IAAI,gBAAgB;CACpB,IAAI;CACJ,KAAK,IAAI,IAAI,G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,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { parseDocument } from "htmlparser2";
10
2
 
11
3
  //#region src/compiler/wxml/parser.ts
@@ -1 +1 @@
1
- {"version":3,"file":"parser.mjs","names":[],"sources":["../../../src/compiler/wxml/parser.ts"],"sourcesContent":["import type { ChildNode, DataNode, Element, Node } from 'domhandler'\n\nimport type { RenderNode } from './types'\n\nimport { parseDocument } from 'htmlparser2'\n\nfunction isRenderableNode(node: Node) {\n if (node.type === 'directive' || node.type === 'comment') {\n return false\n }\n if (node.type === 'text') {\n const data = (node as DataNode).data ?? ''\n return data.trim().length > 0\n }\n return true\n}\n\ntype NodeWithChildren = Node & { children: ChildNode[] }\n\nfunction hasChildren(node: Node): node is NodeWithChildren {\n return Array.isArray((node as NodeWithChildren).children)\n}\n\nfunction toRenderNode(node: Node, children?: RenderNode[]): RenderNode | undefined {\n if (node.type === 'text') {\n const data = (node as DataNode).data ?? ''\n return { type: 'text', data }\n }\n if (node.type === 'tag' || node.type === 'script' || node.type === 'style') {\n const element = node as Element\n return {\n type: 'element',\n name: element.name,\n attribs: element.attribs ?? {},\n children,\n }\n }\n return undefined\n}\n\nfunction convertNode(node: Node): RenderNode | undefined {\n if (!isRenderableNode(node)) {\n return undefined\n }\n const children = (hasChildren(node) && node.children.length > 0)\n ? node.children.map(child => convertNode(child)).filter((child): child is RenderNode => Boolean(child))\n : undefined\n return toRenderNode(node, children)\n}\n\nexport function parseWxml(source: string): RenderNode[] {\n const document = parseDocument(source, {\n xmlMode: true,\n decodeEntities: true,\n recognizeSelfClosing: true,\n })\n const nodes = (document.children ?? []).filter(isRenderableNode)\n return nodes\n .map(node => convertNode(node))\n .filter((node): node is RenderNode => Boolean(node))\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAS,iBAAiB,MAAY;CACpC,IAAI,KAAK,SAAS,eAAe,KAAK,SAAS,WAC7C,OAAO;CAET,IAAI,KAAK,SAAS,QAEhB,QADc,KAAkB,QAAQ,IAC5B,KAAK,EAAE,SAAS;CAE9B,OAAO;AACT;AAIA,SAAS,YAAY,MAAsC;CACzD,OAAO,MAAM,QAAS,KAA0B,QAAQ;AAC1D;AAEA,SAAS,aAAa,MAAY,UAAiD;CACjF,IAAI,KAAK,SAAS,QAEhB,OAAO;EAAE,MAAM;EAAQ,MADT,KAAkB,QAAQ;CACZ;CAE9B,IAAI,KAAK,SAAS,SAAS,KAAK,SAAS,YAAY,KAAK,SAAS,SAAS;EAC1E,MAAM,UAAU;EAChB,OAAO;GACL,MAAM;GACN,MAAM,QAAQ;GACd,SAAS,QAAQ,WAAW,CAAC;GAC7B;EACF;CACF;AAEF;AAEA,SAAS,YAAY,MAAoC;CACvD,IAAI,CAAC,iBAAiB,IAAI,GACxB;CAKF,OAAO,aAAa,MAHF,YAAY,IAAI,KAAK,KAAK,SAAS,SAAS,IAC1D,KAAK,SAAS,KAAI,UAAS,YAAY,KAAK,CAAC,EAAE,QAAQ,UAA+B,QAAQ,KAAK,CAAC,IACpG,MAC8B;AACpC;AAEA,SAAgB,UAAU,QAA8B;CAOtD,QANiB,cAAc,QAAQ;EACrC,SAAS;EACT,gBAAgB;EAChB,sBAAsB;CACxB,CACsB,EAAE,YAAY,CAAC,GAAG,OAAO,gBACpC,EACR,KAAI,SAAQ,YAAY,IAAI,CAAC,EAC7B,QAAQ,SAA6B,QAAQ,IAAI,CAAC;AACvD"}
1
+ {"version":3,"file":"parser.mjs","names":[],"sources":["../../../src/compiler/wxml/parser.ts"],"sourcesContent":["import type { ChildNode, DataNode, Element, Node } from 'domhandler'\n\nimport type { RenderNode } from './types'\n\nimport { parseDocument } from 'htmlparser2'\n\nfunction isRenderableNode(node: Node) {\n if (node.type === 'directive' || node.type === 'comment') {\n return false\n }\n if (node.type === 'text') {\n const data = (node as DataNode).data ?? ''\n return data.trim().length > 0\n }\n return true\n}\n\ntype NodeWithChildren = Node & { children: ChildNode[] }\n\nfunction hasChildren(node: Node): node is NodeWithChildren {\n return Array.isArray((node as NodeWithChildren).children)\n}\n\nfunction toRenderNode(node: Node, children?: RenderNode[]): RenderNode | undefined {\n if (node.type === 'text') {\n const data = (node as DataNode).data ?? ''\n return { type: 'text', data }\n }\n if (node.type === 'tag' || node.type === 'script' || node.type === 'style') {\n const element = node as Element\n return {\n type: 'element',\n name: element.name,\n attribs: element.attribs ?? {},\n children,\n }\n }\n return undefined\n}\n\nfunction convertNode(node: Node): RenderNode | undefined {\n if (!isRenderableNode(node)) {\n return undefined\n }\n const children = (hasChildren(node) && node.children.length > 0)\n ? node.children.map(child => convertNode(child)).filter((child): child is RenderNode => Boolean(child))\n : undefined\n return toRenderNode(node, children)\n}\n\nexport function parseWxml(source: string): RenderNode[] {\n const document = parseDocument(source, {\n xmlMode: true,\n decodeEntities: true,\n recognizeSelfClosing: true,\n })\n const nodes = (document.children ?? []).filter(isRenderableNode)\n return nodes\n .map(node => convertNode(node))\n .filter((node): node is RenderNode => Boolean(node))\n}\n"],"mappings":";;;AAMA,SAAS,iBAAiB,MAAY;CACpC,IAAI,KAAK,SAAS,eAAe,KAAK,SAAS,WAC7C,OAAO;CAET,IAAI,KAAK,SAAS,QAEhB,QADc,KAAkB,QAAQ,IAC5B,KAAK,EAAE,SAAS;CAE9B,OAAO;AACT;AAIA,SAAS,YAAY,MAAsC;CACzD,OAAO,MAAM,QAAS,KAA0B,QAAQ;AAC1D;AAEA,SAAS,aAAa,MAAY,UAAiD;CACjF,IAAI,KAAK,SAAS,QAEhB,OAAO;EAAE,MAAM;EAAQ,MADT,KAAkB,QAAQ;CACZ;CAE9B,IAAI,KAAK,SAAS,SAAS,KAAK,SAAS,YAAY,KAAK,SAAS,SAAS;EAC1E,MAAM,UAAU;EAChB,OAAO;GACL,MAAM;GACN,MAAM,QAAQ;GACd,SAAS,QAAQ,WAAW,CAAC;GAC7B;EACF;CACF;AAEF;AAEA,SAAS,YAAY,MAAoC;CACvD,IAAI,CAAC,iBAAiB,IAAI,GACxB;CAKF,OAAO,aAAa,MAHF,YAAY,IAAI,KAAK,KAAK,SAAS,SAAS,IAC1D,KAAK,SAAS,KAAI,UAAS,YAAY,KAAK,CAAC,EAAE,QAAQ,UAA+B,QAAQ,KAAK,CAAC,IACpG,MAC8B;AACpC;AAEA,SAAgB,UAAU,QAA8B;CAOtD,QANiB,cAAc,QAAQ;EACrC,SAAS;EACT,gBAAgB;EAChB,sBAAsB;CACxB,CACsB,EAAE,YAAY,CAAC,GAAG,OAAO,gBACpC,EACR,KAAI,SAAQ,YAAY,IAAI,CAAC,EAC7B,QAAQ,SAA6B,QAAQ,IAAI,CAAC;AACvD"}
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { SELF_CLOSING_TAGS, hasControlAttribute, normalizeTagName, resolveControlAttributeValue } from "../../shared/wxml.mjs";
10
2
  import { buildExpression, buildTemplateDataExpression, parseInterpolations } from "./interpolation.mjs";
11
3
  import { extractFor, isConditionalElement, renderAttributes, resolveComponentTagName, stripControlAttributes } from "./attributes.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.mjs","names":[],"sources":["../../../src/compiler/wxml/renderer.ts"],"sourcesContent":["import type { RenderElementNode, RenderNode } from './types'\nimport {\n hasControlAttribute,\n normalizeTagName,\n resolveControlAttributeValue,\n SELF_CLOSING_TAGS,\n} from '../../shared/wxml'\nimport {\n extractFor,\n isConditionalElement,\n renderAttributes,\n resolveComponentTagName,\n stripControlAttributes,\n} from './attributes'\nimport { buildExpression, buildTemplateDataExpression, parseInterpolations } from './interpolation'\n\ninterface RenderElementOptions {\n skipFor?: boolean\n overrideAttribs?: Record<string, string>\n}\n\nexport class Renderer {\n renderNodes(\n nodes: RenderNode[],\n scopeVar: string,\n wxsVar: string,\n componentTags?: Record<string, string>,\n ): string {\n const parts: string[] = []\n for (let index = 0; index < nodes.length; index += 1) {\n const node = nodes[index]\n if (isConditionalElement(node)) {\n const { rendered, endIndex } = this.renderConditionalSequence(\n nodes,\n index,\n scopeVar,\n wxsVar,\n componentTags,\n )\n parts.push(rendered)\n index = endIndex\n continue\n }\n parts.push(this.renderNode(node, scopeVar, wxsVar, componentTags))\n }\n if (parts.length === 0) {\n return '\"\"'\n }\n if (parts.length === 1) {\n return parts[0]!\n }\n return `[${parts.join(', ')}]`\n }\n\n private renderConditionalSequence(\n nodes: RenderNode[],\n startIndex: number,\n scopeVar: string,\n wxsVar: string,\n componentTags?: Record<string, string>,\n ): { rendered: string, endIndex: number } {\n const branches: Array<{ node: RenderElementNode, attribs: Record<string, string> }> = []\n let cursor = startIndex\n while (cursor < nodes.length) {\n const candidate = nodes[cursor]\n if (!isConditionalElement(candidate)) {\n break\n }\n const attribs = candidate.attribs ?? {}\n if (branches.length === 0 && !hasControlAttribute(attribs, 'if')) {\n break\n }\n if (branches.length > 0 && !hasControlAttribute(attribs, 'elif') && !hasControlAttribute(attribs, 'else')) {\n break\n }\n branches.push({ node: candidate, attribs })\n cursor += 1\n if (hasControlAttribute(attribs, 'else')) {\n break\n }\n }\n if (!branches.length) {\n const node = nodes[startIndex]\n if (!node) {\n return { rendered: '\"\"', endIndex: startIndex }\n }\n return { rendered: this.renderNode(node, scopeVar, wxsVar, componentTags), endIndex: startIndex }\n }\n let expr = '\"\"'\n for (let index = branches.length - 1; index >= 0; index -= 1) {\n const { node, attribs } = branches[index]!\n const cleanedAttribs = stripControlAttributes(attribs)\n if (hasControlAttribute(attribs, 'else')) {\n expr = this.renderElement(node, scopeVar, wxsVar, componentTags, { overrideAttribs: cleanedAttribs })\n continue\n }\n const conditionExpr = resolveControlAttributeValue(attribs, 'if')\n ?? resolveControlAttributeValue(attribs, 'elif')\n ?? ''\n const rendered = this.renderElement(node, scopeVar, wxsVar, componentTags, { overrideAttribs: cleanedAttribs })\n const condition = buildExpression(parseInterpolations(conditionExpr), scopeVar, wxsVar)\n expr = `(${condition} ? ${rendered} : ${expr})`\n }\n return { rendered: expr, endIndex: startIndex + branches.length - 1 }\n }\n\n private renderNode(\n node: RenderNode,\n scopeVar: string,\n wxsVar: string,\n componentTags?: Record<string, string>,\n ): string {\n if (node.type === 'text') {\n const parts = parseInterpolations(node.data ?? '')\n return buildExpression(parts, scopeVar, wxsVar)\n }\n if (node.type === 'element') {\n if (node.name === 'template' && node.attribs?.is) {\n return this.renderTemplateInvoke(node, scopeVar, wxsVar)\n }\n return this.renderElement(node, scopeVar, wxsVar, componentTags)\n }\n return '\"\"'\n }\n\n private renderTemplateInvoke(\n node: RenderElementNode,\n scopeVar: string,\n wxsVar: string,\n ): string {\n const attribs = node.attribs ?? {}\n const isExpr = buildExpression(parseInterpolations(attribs.is ?? ''), scopeVar, wxsVar)\n const dataExpr = attribs.data\n ? buildTemplateDataExpression(attribs.data, scopeVar, wxsVar)\n : undefined\n const scopeExpr = dataExpr\n ? `ctx.mergeScope(${scopeVar}, ${dataExpr})`\n : scopeVar\n return `ctx.renderTemplate(__templates, ${isExpr}, ${scopeExpr}, ctx)`\n }\n\n private renderElement(\n node: RenderElementNode,\n scopeVar: string,\n wxsVar: string,\n componentTags?: Record<string, string>,\n options: RenderElementOptions = {},\n ): string {\n const attribs = options.overrideAttribs ?? node.attribs ?? {}\n if (!options.skipFor) {\n const forInfo = extractFor(node.attribs ?? {})\n if (forInfo.expr) {\n const listExpression = buildExpression(parseInterpolations(forInfo.expr), scopeVar, wxsVar)\n const listExpr = `ctx.normalizeList(${listExpression})`\n const itemVar = forInfo.itemName\n const indexVar = forInfo.indexName\n const scopeExpr = `ctx.createScope(${scopeVar}, { ${itemVar}: ${itemVar}, ${indexVar}: ${indexVar} })`\n const itemRender = this.renderElement(\n node,\n '__scope',\n wxsVar,\n componentTags,\n { skipFor: true, overrideAttribs: forInfo.restAttribs },\n )\n const keyExpr = `ctx.key(${JSON.stringify(forInfo.key ?? '')}, ${itemVar}, ${indexVar}, ${scopeExpr}, ${wxsVar})`\n return `repeat(${listExpr}, (${itemVar}, ${indexVar}) => ${keyExpr}, (${itemVar}, ${indexVar}) => { const __scope = ${scopeExpr}; return ${itemRender}; })`\n }\n }\n\n const customTag = resolveComponentTagName(node.name ?? '', componentTags)\n const tagName = customTag ?? normalizeTagName(node.name ?? '')\n if (tagName === '#fragment') {\n return this.renderNodes(node.children ?? [], scopeVar, wxsVar, componentTags)\n }\n\n const attrs = renderAttributes(attribs, scopeVar, wxsVar, {\n skipControl: true,\n preferProperty: Boolean(customTag),\n })\n const childNodes = node.children ?? []\n const children = childNodes\n .map(child => `\\${${this.renderNode(child, scopeVar, wxsVar, componentTags)}}`)\n .join('')\n if (SELF_CLOSING_TAGS.has(tagName) && childNodes.length === 0) {\n return `html\\`<${tagName}${attrs} />\\``\n }\n return `html\\`<${tagName}${attrs}>${children}</${tagName}>\\``\n }\n}\n\nexport const renderer = new Renderer()\n"],"mappings":";;;;;;;;;;;;;AAqBA,IAAa,WAAb,MAAsB;CACpB,YACE,OACA,UACA,QACA,eACQ;EACR,MAAM,QAAkB,CAAC;EACzB,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;GACpD,MAAM,OAAO,MAAM;GACnB,IAAI,qBAAqB,IAAI,GAAG;IAC9B,MAAM,EAAE,UAAU,aAAa,KAAK,0BAClC,OACA,OACA,UACA,QACA,aACF;IACA,MAAM,KAAK,QAAQ;IACnB,QAAQ;IACR;GACF;GACA,MAAM,KAAK,KAAK,WAAW,MAAM,UA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AAS,IAAI,SAAS;IAClG,MAAM,aAAa,KAAK,cACtB,MACA,WACA,QACA,eACA;KAAE,SAAS;KAAM,iBAAiB,QAAQ;IAAY,CACxD;IAEA,OAAO,UAAU,SAAS,KAAK,QAAQ,IAAI,SAAS,OAAO,WADhC,KAAK,UAAU,QAAQ,OAAO,EAAE,EAAE,IAAI,QAAQ,IAAI,SAAS,IAAI,UAAU,IAAI,OAAO,GAC5C,KAAK,QAAQ,IAAI,SAAS,yBAAyB,UAAU,WAAW,WAAW;GACxJ;EACF;EAEA,MAAM,YAAY,wBAAwB,KAAK,QAAQ,IAAI,aAAa;EACxE,MAAM,UAAU,aAAa,iBAAiB,KAAK,QAAQ,EAAE;EAC7D,IAAI,YAAY,aACd,OAAO,KAAK,YAAY,KAAK,YAAY,CAAC,GAAG,UAAU,QAAQ,aAAa;EAG9E,MAAM,QAAQ,iBAAiB,SAAS,UAAU,QAAQ;GACxD,aAAa;GACb,gBAAgB,QAAQ,SAAS;EACnC,CAAC;EACD,MAAM,aAAa,KAAK,YAAY,CAAC;EACrC,MAAM,WAAW,WACd,KAAI,UAAS,MAAM,KAAK,WAAW,OAAO,UAAU,QAAQ,aAAa,EAAE,EAAE,EAC7E,KAAK,EAAE;EACV,IAAI,kBAAkB,IAAI,OAAO,KAAK,WAAW,WAAW,GAC1D,OAAO,UAAU,UAAU,MAAM;EAEnC,OAAO,UAAU,UAAU,MAAM,GAAG,SAAS,IAAI,QAAQ;CAC3D;AACF;AAEA,MAAa,WAAW,IAAI,SAAS"}
1
+ {"version":3,"file":"renderer.mjs","names":[],"sources":["../../../src/compiler/wxml/renderer.ts"],"sourcesContent":["import type { RenderElementNode, RenderNode } from './types'\nimport {\n hasControlAttribute,\n normalizeTagName,\n resolveControlAttributeValue,\n SELF_CLOSING_TAGS,\n} from '../../shared/wxml'\nimport {\n extractFor,\n isConditionalElement,\n renderAttributes,\n resolveComponentTagName,\n stripControlAttributes,\n} from './attributes'\nimport { buildExpression, buildTemplateDataExpression, parseInterpolations } from './interpolation'\n\ninterface RenderElementOptions {\n skipFor?: boolean\n overrideAttribs?: Record<string, string>\n}\n\nexport class Renderer {\n renderNodes(\n nodes: RenderNode[],\n scopeVar: string,\n wxsVar: string,\n componentTags?: Record<string, string>,\n ): string {\n const parts: string[] = []\n for (let index = 0; index < nodes.length; index += 1) {\n const node = nodes[index]\n if (isConditionalElement(node)) {\n const { rendered, endIndex } = this.renderConditionalSequence(\n nodes,\n index,\n scopeVar,\n wxsVar,\n componentTags,\n )\n parts.push(rendered)\n index = endIndex\n continue\n }\n parts.push(this.renderNode(node, scopeVar, wxsVar, componentTags))\n }\n if (parts.length === 0) {\n return '\"\"'\n }\n if (parts.length === 1) {\n return parts[0]!\n }\n return `[${parts.join(', ')}]`\n }\n\n private renderConditionalSequence(\n nodes: RenderNode[],\n startIndex: number,\n scopeVar: string,\n wxsVar: string,\n componentTags?: Record<string, string>,\n ): { rendered: string, endIndex: number } {\n const branches: Array<{ node: RenderElementNode, attribs: Record<string, string> }> = []\n let cursor = startIndex\n while (cursor < nodes.length) {\n const candidate = nodes[cursor]\n if (!isConditionalElement(candidate)) {\n break\n }\n const attribs = candidate.attribs ?? {}\n if (branches.length === 0 && !hasControlAttribute(attribs, 'if')) {\n break\n }\n if (branches.length > 0 && !hasControlAttribute(attribs, 'elif') && !hasControlAttribute(attribs, 'else')) {\n break\n }\n branches.push({ node: candidate, attribs })\n cursor += 1\n if (hasControlAttribute(attribs, 'else')) {\n break\n }\n }\n if (!branches.length) {\n const node = nodes[startIndex]\n if (!node) {\n return { rendered: '\"\"', endIndex: startIndex }\n }\n return { rendered: this.renderNode(node, scopeVar, wxsVar, componentTags), endIndex: startIndex }\n }\n let expr = '\"\"'\n for (let index = branches.length - 1; index >= 0; index -= 1) {\n const { node, attribs } = branches[index]!\n const cleanedAttribs = stripControlAttributes(attribs)\n if (hasControlAttribute(attribs, 'else')) {\n expr = this.renderElement(node, scopeVar, wxsVar, componentTags, { overrideAttribs: cleanedAttribs })\n continue\n }\n const conditionExpr = resolveControlAttributeValue(attribs, 'if')\n ?? resolveControlAttributeValue(attribs, 'elif')\n ?? ''\n const rendered = this.renderElement(node, scopeVar, wxsVar, componentTags, { overrideAttribs: cleanedAttribs })\n const condition = buildExpression(parseInterpolations(conditionExpr), scopeVar, wxsVar)\n expr = `(${condition} ? ${rendered} : ${expr})`\n }\n return { rendered: expr, endIndex: startIndex + branches.length - 1 }\n }\n\n private renderNode(\n node: RenderNode,\n scopeVar: string,\n wxsVar: string,\n componentTags?: Record<string, string>,\n ): string {\n if (node.type === 'text') {\n const parts = parseInterpolations(node.data ?? '')\n return buildExpression(parts, scopeVar, wxsVar)\n }\n if (node.type === 'element') {\n if (node.name === 'template' && node.attribs?.is) {\n return this.renderTemplateInvoke(node, scopeVar, wxsVar)\n }\n return this.renderElement(node, scopeVar, wxsVar, componentTags)\n }\n return '\"\"'\n }\n\n private renderTemplateInvoke(\n node: RenderElementNode,\n scopeVar: string,\n wxsVar: string,\n ): string {\n const attribs = node.attribs ?? {}\n const isExpr = buildExpression(parseInterpolations(attribs.is ?? ''), scopeVar, wxsVar)\n const dataExpr = attribs.data\n ? buildTemplateDataExpression(attribs.data, scopeVar, wxsVar)\n : undefined\n const scopeExpr = dataExpr\n ? `ctx.mergeScope(${scopeVar}, ${dataExpr})`\n : scopeVar\n return `ctx.renderTemplate(__templates, ${isExpr}, ${scopeExpr}, ctx)`\n }\n\n private renderElement(\n node: RenderElementNode,\n scopeVar: string,\n wxsVar: string,\n componentTags?: Record<string, string>,\n options: RenderElementOptions = {},\n ): string {\n const attribs = options.overrideAttribs ?? node.attribs ?? {}\n if (!options.skipFor) {\n const forInfo = extractFor(node.attribs ?? {})\n if (forInfo.expr) {\n const listExpression = buildExpression(parseInterpolations(forInfo.expr), scopeVar, wxsVar)\n const listExpr = `ctx.normalizeList(${listExpression})`\n const itemVar = forInfo.itemName\n const indexVar = forInfo.indexName\n const scopeExpr = `ctx.createScope(${scopeVar}, { ${itemVar}: ${itemVar}, ${indexVar}: ${indexVar} })`\n const itemRender = this.renderElement(\n node,\n '__scope',\n wxsVar,\n componentTags,\n { skipFor: true, overrideAttribs: forInfo.restAttribs },\n )\n const keyExpr = `ctx.key(${JSON.stringify(forInfo.key ?? '')}, ${itemVar}, ${indexVar}, ${scopeExpr}, ${wxsVar})`\n return `repeat(${listExpr}, (${itemVar}, ${indexVar}) => ${keyExpr}, (${itemVar}, ${indexVar}) => { const __scope = ${scopeExpr}; return ${itemRender}; })`\n }\n }\n\n const customTag = resolveComponentTagName(node.name ?? '', componentTags)\n const tagName = customTag ?? normalizeTagName(node.name ?? '')\n if (tagName === '#fragment') {\n return this.renderNodes(node.children ?? [], scopeVar, wxsVar, componentTags)\n }\n\n const attrs = renderAttributes(attribs, scopeVar, wxsVar, {\n skipControl: true,\n preferProperty: Boolean(customTag),\n })\n const childNodes = node.children ?? []\n const children = childNodes\n .map(child => `\\${${this.renderNode(child, scopeVar, wxsVar, componentTags)}}`)\n .join('')\n if (SELF_CLOSING_TAGS.has(tagName) && childNodes.length === 0) {\n return `html\\`<${tagName}${attrs} />\\``\n }\n return `html\\`<${tagName}${attrs}>${children}</${tagName}>\\``\n }\n}\n\nexport const renderer = new Renderer()\n"],"mappings":";;;;;AAqBA,IAAa,WAAb,MAAsB;CACpB,YACE,OACA,UACA,QACA,eACQ;EACR,MAAM,QAAkB,CAAC;EACzB,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;GACpD,MAAM,OAAO,MAAM;GACnB,IAAI,qBAAqB,IAAI,GAAG;IAC9B,MAAM,EAAE,UAAU,aAAa,KAAK,0BAClC,OACA,OACA,UACA,QACA,aACF;IACA,MAAM,KAAK,QAAQ;IACnB,QAAQ;IACR;GACF;GACA,MAAM,KAAK,KAAK,WAAW,MAAM,UAAU,QAAQ,aAAa,CAAC;EACnE;EACA,IAAI,MAAM,WAAW,GACnB,OAAO;EAET,IAAI,MAAM,WAAW,GACnB,OAAO,MAAM;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,CACxD;IAEA,OAAO,UAAU,SAAS,KAAK,QAAQ,IAAI,SAAS,OAAO,WADhC,KAAK,UAAU,QAAQ,OAAO,EAAE,EAAE,IAAI,QAAQ,IAAI,SAAS,IAAI,UAAU,IAAI,OAAO,GAC5C,KAAK,QAAQ,IAAI,SAAS,yBAAyB,UAAU,WAAW,WAAW;GACxJ;EACF;EAEA,MAAM,YAAY,wBAAwB,KAAK,QAAQ,IAAI,aAAa;EACxE,MAAM,UAAU,aAAa,iBAAiB,KAAK,QAAQ,EAAE;EAC7D,IAAI,YAAY,aACd,OAAO,KAAK,YAAY,KAAK,YAAY,CAAC,GAAG,UAAU,QAAQ,aAAa;EAG9E,MAAM,QAAQ,iBAAiB,SAAS,UAAU,QAAQ;GACxD,aAAa;GACb,gBAAgB,QAAQ,SAAS;EACnC,CAAC;EACD,MAAM,aAAa,KAAK,YAAY,CAAC;EACrC,MAAM,WAAW,WACd,KAAI,UAAS,MAAM,KAAK,WAAW,OAAO,UAAU,QAAQ,aAAa,EAAE,EAAE,EAC7E,KAAK,EAAE;EACV,IAAI,kBAAkB,IAAI,OAAO,KAAK,WAAW,WAAW,GAC1D,OAAO,UAAU,UAAU,MAAM;EAEnC,OAAO,UAAU,UAAU,MAAM,GAAG,SAAS,IAAI,QAAQ;CAC3D;AACF;AAEA,MAAa,WAAW,IAAI,SAAS"}
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { TEMPLATE_IMPORT_TAG_NAMES, TEMPLATE_INCLUDE_TAG_NAMES } from "../../shared/wxml.mjs";
10
2
  import { dirname, relative } from "pathe";
11
3
 
@@ -1 +1 @@
1
- {"version":3,"file":"specialNodes.mjs","names":[],"sources":["../../../src/compiler/wxml/specialNodes.ts"],"sourcesContent":["import type {\n ImportEntry,\n IncludeEntry,\n RenderNode,\n TemplateDefinition,\n WxsEntry,\n} from './types'\n\nimport { dirname, relative } from 'pathe'\nimport { TEMPLATE_IMPORT_TAG_NAMES, TEMPLATE_INCLUDE_TAG_NAMES } from '../../shared/wxml'\n\nexport function shouldMarkWxsImport(pathname: string) {\n const lower = pathname.toLowerCase()\n if (lower.endsWith('.wxs') || lower.endsWith('.wxs.ts') || lower.endsWith('.wxs.js')) {\n return false\n }\n return lower.endsWith('.ts') || lower.endsWith('.js')\n}\n\ninterface CollectSpecialNodesContext {\n templates: TemplateDefinition[]\n includes: IncludeEntry[]\n imports: ImportEntry[]\n wxs: WxsEntry[]\n wxsModules: Map<string, string>\n warnings: string[]\n sourceId: string\n resolveTemplate: (raw: string) => string | undefined\n resolveWxs: (raw: string) => string | undefined\n}\n\nexport function collectSpecialNodes(nodes: RenderNode[], context: CollectSpecialNodesContext) {\n const renderable: RenderNode[] = []\n for (const node of nodes) {\n if (node.type === 'element') {\n const name = node.name ?? ''\n if (name === 'template' && node.attribs?.name) {\n context.templates.push({\n name: node.attribs.name,\n nodes: collectSpecialNodes(node.children ?? [], context),\n })\n continue\n }\n if (TEMPLATE_IMPORT_TAG_NAMES.includes(name) && node.attribs?.src) {\n const resolved = context.resolveTemplate(node.attribs.src)\n if (resolved) {\n context.imports.push({\n id: resolved,\n importName: `__wxml_import_${context.imports.length}`,\n })\n }\n else {\n context.warnings.push(`[web] 无法解析模板依赖: ${node.attribs.src} (from ${context.sourceId})`)\n }\n continue\n }\n if (TEMPLATE_INCLUDE_TAG_NAMES.includes(name) && node.attribs?.src) {\n const resolved = context.resolveTemplate(node.attribs.src)\n if (resolved) {\n context.includes.push({\n id: resolved,\n importName: `__wxml_include_${context.includes.length}`,\n })\n }\n else {\n context.warnings.push(`[web] 无法解析模板依赖: ${node.attribs.src} (from ${context.sourceId})`)\n }\n continue\n }\n if (name === 'wxs') {\n const moduleName = node.attribs?.module?.trim()\n if (moduleName) {\n const previousSource = context.wxsModules.get(moduleName)\n if (previousSource) {\n context.warnings.push(`[web] WXS 模块名重复: ${moduleName} (from ${context.sourceId})`)\n }\n context.wxsModules.set(moduleName, context.sourceId)\n if (node.attribs?.src) {\n const resolved = context.resolveWxs(node.attribs.src)\n if (resolved) {\n context.wxs.push({\n module: moduleName,\n kind: 'src',\n importName: `__wxs_${context.wxs.length}`,\n value: resolved,\n })\n }\n }\n else {\n const inlineCode = (node.children ?? [])\n .filter(child => child.type === 'text')\n .map(child => child.data ?? '')\n .join('')\n context.wxs.push({\n module: moduleName,\n kind: 'inline',\n importName: `__wxs_${context.wxs.length}`,\n value: inlineCode,\n })\n }\n }\n continue\n }\n if (node.children?.length) {\n node.children = collectSpecialNodes(node.children, context)\n }\n }\n renderable.push(node)\n }\n return renderable\n}\n\nexport function normalizeTemplatePath(pathname: string) {\n return pathname.split('\\\\').join('/')\n}\n\nexport function toRelativeImport(from: string, target: string) {\n const fromDir = dirname(from)\n const rel = relative(fromDir, target)\n if (!rel || rel.startsWith('.')) {\n const fallback = normalizeTemplatePath(target).split('/').pop() ?? ''\n return rel || `./${fallback}`\n }\n return `./${rel}`\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,oBAAoB,UAAkB;CACpD,MAAM,QAAQ,SAAS,YAAY;CACnC,IAAI,MAAM,SAAS,MAAM,KAAK,MAAM,SAAS,SAAS,KAAK,MAAM,SAAS,SAAS,GACjF,OAAO;CAET,OAAO,MAAM,SAAS,KAAK,KAAK,MAAM,SAAS,KAAK;AACtD;AAcA,SAAgB,oBAAoB,OAAqB,SAAqC;CAC5F,MAAM,aAA2B,CAAC;CAClC,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,KAAK,SAAS,WAAW;GAC3B,MAAM,OAAO,KAAK,QAAQ;GAC1B,IAAI,SAAS,cAAc,KAAK,SAAS,MAAM;IAC7C,QAAQ,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Q,EAAE,EAC7B,KAAK,EAAE;MACV,QAAQ,IAAI,KAAK;OACf,QAAQ;OACR,MAAM;OACN,YAAY,SAAS,QAAQ,IAAI;OACjC,OAAO;MACT,CAAC;KACH;IACF;IACA;GACF;GACA,IAAI,KAAK,UAAU,QACjB,KAAK,WAAW,oBAAoB,KAAK,UAAU,OAAO;EAE9D;EACA,WAAW,KAAK,IAAI;CACtB;CACA,OAAO;AACT;AAEA,SAAgB,sBAAsB,UAAkB;CACtD,OAAO,SAAS,MAAM,IAAI,EAAE,KAAK,GAAG;AACtC;AAEA,SAAgB,iBAAiB,MAAc,QAAgB;CAE7D,MAAM,MAAM,SADI,QAAQ,IACG,GAAG,MAAM;CACpC,IAAI,CAAC,OAAO,IAAI,WAAW,GAAG,GAAG;EAC/B,MAAM,WAAW,sBAAsB,MAAM,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK;EACnE,OAAO,OAAO,KAAK;CACrB;CACA,OAAO,KAAK;AACd"}
1
+ {"version":3,"file":"specialNodes.mjs","names":[],"sources":["../../../src/compiler/wxml/specialNodes.ts"],"sourcesContent":["import type {\n ImportEntry,\n IncludeEntry,\n RenderNode,\n TemplateDefinition,\n WxsEntry,\n} from './types'\n\nimport { dirname, relative } from 'pathe'\nimport { TEMPLATE_IMPORT_TAG_NAMES, TEMPLATE_INCLUDE_TAG_NAMES } from '../../shared/wxml'\n\nexport function shouldMarkWxsImport(pathname: string) {\n const lower = pathname.toLowerCase()\n if (lower.endsWith('.wxs') || lower.endsWith('.wxs.ts') || lower.endsWith('.wxs.js')) {\n return false\n }\n return lower.endsWith('.ts') || lower.endsWith('.js')\n}\n\ninterface CollectSpecialNodesContext {\n templates: TemplateDefinition[]\n includes: IncludeEntry[]\n imports: ImportEntry[]\n wxs: WxsEntry[]\n wxsModules: Map<string, string>\n warnings: string[]\n sourceId: string\n resolveTemplate: (raw: string) => string | undefined\n resolveWxs: (raw: string) => string | undefined\n}\n\nexport function collectSpecialNodes(nodes: RenderNode[], context: CollectSpecialNodesContext) {\n const renderable: RenderNode[] = []\n for (const node of nodes) {\n if (node.type === 'element') {\n const name = node.name ?? ''\n if (name === 'template' && node.attribs?.name) {\n context.templates.push({\n name: node.attribs.name,\n nodes: collectSpecialNodes(node.children ?? [], context),\n })\n continue\n }\n if (TEMPLATE_IMPORT_TAG_NAMES.includes(name) && node.attribs?.src) {\n const resolved = context.resolveTemplate(node.attribs.src)\n if (resolved) {\n context.imports.push({\n id: resolved,\n importName: `__wxml_import_${context.imports.length}`,\n })\n }\n else {\n context.warnings.push(`[web] 无法解析模板依赖: ${node.attribs.src} (from ${context.sourceId})`)\n }\n continue\n }\n if (TEMPLATE_INCLUDE_TAG_NAMES.includes(name) && node.attribs?.src) {\n const resolved = context.resolveTemplate(node.attribs.src)\n if (resolved) {\n context.includes.push({\n id: resolved,\n importName: `__wxml_include_${context.includes.length}`,\n })\n }\n else {\n context.warnings.push(`[web] 无法解析模板依赖: ${node.attribs.src} (from ${context.sourceId})`)\n }\n continue\n }\n if (name === 'wxs') {\n const moduleName = node.attribs?.module?.trim()\n if (moduleName) {\n const previousSource = context.wxsModules.get(moduleName)\n if (previousSource) {\n context.warnings.push(`[web] WXS 模块名重复: ${moduleName} (from ${context.sourceId})`)\n }\n context.wxsModules.set(moduleName, context.sourceId)\n if (node.attribs?.src) {\n const resolved = context.resolveWxs(node.attribs.src)\n if (resolved) {\n context.wxs.push({\n module: moduleName,\n kind: 'src',\n importName: `__wxs_${context.wxs.length}`,\n value: resolved,\n })\n }\n }\n else {\n const inlineCode = (node.children ?? [])\n .filter(child => child.type === 'text')\n .map(child => child.data ?? '')\n .join('')\n context.wxs.push({\n module: moduleName,\n kind: 'inline',\n importName: `__wxs_${context.wxs.length}`,\n value: inlineCode,\n })\n }\n }\n continue\n }\n if (node.children?.length) {\n node.children = collectSpecialNodes(node.children, context)\n }\n }\n renderable.push(node)\n }\n return renderable\n}\n\nexport function normalizeTemplatePath(pathname: string) {\n return pathname.split('\\\\').join('/')\n}\n\nexport function toRelativeImport(from: string, target: string) {\n const fromDir = dirname(from)\n const rel = relative(fromDir, target)\n if (!rel || rel.startsWith('.')) {\n const fallback = normalizeTemplatePath(target).split('/').pop() ?? ''\n return rel || `./${fallback}`\n }\n return `./${rel}`\n}\n"],"mappings":";;;;AAWA,SAAgB,oBAAoB,UAAkB;CACpD,MAAM,QAAQ,SAAS,YAAY;CACnC,IAAI,MAAM,SAAS,MAAM,KAAK,MAAM,SAAS,SAAS,KAAK,MAAM,SAAS,SAAS,GACjF,OAAO;CAET,OAAO,MAAM,SAAS,KAAK,KAAK,MAAM,SAAS,KAAK;AACtD;AAcA,SAAgB,oBAAoB,OAAqB,SAAqC;CAC5F,MAAM,aAA2B,CAAC;CAClC,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,KAAK,SAAS,WAAW;GAC3B,MAAM,OAAO,KAAK,QAAQ;GAC1B,IAAI,SAAS,cAAc,KAAK,SAAS,MAAM;IAC7C,QAAQ,UAAU,KAAK;KACrB,MAAM,KAAK,QAAQ;KACnB,OAAO,oBAAoB,KAAK,YAAY,CAAC,GAAG,OAAO;IACzD,CAAC;IACD;GACF;GACA,IAAI,0BAA0B,SAAS,IAAI,KAAK,KAAK,SAAS,KAAK;IACjE,MAAM,WAAW,QAAQ,gBAAgB,KAAK,QAAQ,GAAG;IACzD,IAAI,UACF,QAAQ,QAAQ,KAAK;KACnB,IAAI;KACJ,YAAY,iBAAiB,QAAQ,QAAQ;IAC/C,CAAC;SAGD,QAAQ,SAAS,KAAK,mBAAmB,KAAK,QAAQ,IAAI,SAAS,QAAQ,SAAS,EAAE;IAExF;GACF;GACA,IAAI,2BAA2B,SAAS,IAAI,KAAK,KAAK,SAAS,KAAK;IAClE,MAAM,WAAW,QAAQ,gBAAgB,KAAK,QAAQ,GAAG;IACzD,IAAI,UACF,QAAQ,SAAS,KAAK;KACpB,IAAI;KACJ,YAAY,kBAAkB,QAAQ,SAAS;IACjD,CAAC;SAGD,QAAQ,SAAS,KAA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2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  //#region src/compiler/wxs.ts
10
2
  const REQUIRE_RE = /require\(\s*['"]([^'"]+)['"]\s*\)/g;
11
3
  function normalizePath(p) {
@@ -1 +1 @@
1
- {"version":3,"file":"wxs.mjs","names":[],"sources":["../../src/compiler/wxs.ts"],"sourcesContent":["export interface WxsTransformResult {\n code: string\n dependencies: string[]\n warnings?: string[]\n}\n\nexport interface WxsTransformOptions {\n resolvePath: (request: string, importer: string) => string | undefined\n toImportPath?: (resolved: string, importer: string) => string\n}\n\nconst REQUIRE_RE = /require\\(\\s*['\"]([^'\"]+)['\"]\\s*\\)/g\n\nfunction normalizePath(p: string) {\n return p.split('\\\\\\\\').join('/')\n}\n\nfunction isPlainWxsScript(pathname: string) {\n const lower = pathname.toLowerCase()\n if (lower.endsWith('.wxs') || lower.endsWith('.wxs.ts') || lower.endsWith('.wxs.js')) {\n return false\n }\n return lower.endsWith('.ts') || lower.endsWith('.js')\n}\n\nfunction appendWxsQuery(pathname: string) {\n if (pathname.includes('?wxs') || pathname.includes('&wxs')) {\n return pathname\n }\n return `${pathname}${pathname.includes('?') ? '&' : '?'}wxs`\n}\n\nfunction isSupportedRequirePath(request: string) {\n const normalized = request.replace(/\\\\/g, '/')\n return normalized.startsWith('.') || normalized.startsWith('/')\n}\n\nexport function transformWxsToEsm(code: string, id: string, options: WxsTransformOptions): WxsTransformResult {\n const dependencies: string[] = []\n const importLines: string[] = []\n const mapEntries: string[] = []\n const warnings: string[] = []\n\n const seen = new Set<string>()\n while (true) {\n const match = REQUIRE_RE.exec(code)\n if (!match) {\n break\n }\n const request = match[1]\n if (!request || seen.has(request)) {\n continue\n }\n seen.add(request)\n if (!isSupportedRequirePath(request)) {\n warnings.push(`[@weapp-vite/web] WXS require 仅支持相对或绝对路径: ${request} (from ${id})`)\n continue\n }\n const normalizedRequest = request.replace(/\\\\/g, '/')\n const resolved = options.resolvePath(normalizedRequest, id)\n if (!resolved) {\n warnings.push(`[@weapp-vite/web] 无法解析 WXS require: ${request} (from ${id})`)\n continue\n }\n let importPath = normalizePath(options.toImportPath?.(resolved, id) ?? resolved)\n if (isPlainWxsScript(resolved)) {\n importPath = appendWxsQuery(importPath)\n }\n const importName = `__wxs_dep_${dependencies.length}`\n importLines.push(`import ${importName} from '${importPath}'`)\n mapEntries.push(`[${JSON.stringify(request)}, ${importName}]`)\n dependencies.push(resolved)\n }\n\n const requireMap = `const __wxs_require_map = new Map([${mapEntries.join(', ')}])`\n const requireFn = [\n `const __wxs_require_warned = new Set()`,\n `function require(id) {`,\n ` if (__wxs_require_map.has(id)) {`,\n ` return __wxs_require_map.get(id)`,\n ` }`,\n ` if (!__wxs_require_warned.has(id)) {`,\n ` __wxs_require_warned.add(id)`,\n ` if (typeof console !== 'undefined' && typeof console.warn === 'function') {`,\n ` console.warn(\\`[@weapp-vite/web] WXS require 未解析: \\${id}\\`)`,\n ` }`,\n ` }`,\n ` return undefined`,\n `}`,\n ].join('\\\\n')\n const moduleInit = `const module = { exports: {} }\\\\nconst exports = module.exports`\n const helpers = `const getRegExp = (pattern, flags) => new RegExp(pattern, flags)\\\\nconst getDate = (value) => (value == null ? new Date() : new Date(value))`\n\n const body = [\n ...importLines,\n requireMap,\n requireFn,\n moduleInit,\n helpers,\n code,\n `export default module.exports`,\n ].join('\\\\n')\n\n return {\n code: body,\n dependencies,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n}\n"],"mappings":";;;;;;;;;AAWA,MAAM,aAAa;AAEnB,SAAS,cAAc,GAAW;CAChC,OAAO,EAAE,MAAM,MAAM,EAAE,KAAK,GAAG;AACjC;AAEA,SAAS,iBAAiB,UAAkB;CAC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aAAa,aAAa,aAAa;EAC7C,YAAY,KAAK,UAAU,WAAW,SAAS,WAAW,EAAE;EAC5D,WAAW,KAAK,IAAI,KAAK,UAAU,OAAO,EAAE,IAAI,WAAW,EAAE;EAC7D,aAAa,KAAK,QAAQ;CAC5B;CAEA,MAAM,aAAa,sCAAsC,WAAW,KAAK,IAAI,EAAE;CAC/E,MAAM,YAAY;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,EAAE,KAAK,KAAK;CACZ,MAAM,aAAa;CACnB,MAAM,UAAU;CAYhB,OAAO;EACL,MAXW;GACX,GAAG;GACH;GACA;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,KAGI;EACT;EACA,UAAU,SAAS,SAAS,IAAI,WAAW;CAC7C;AACF"}
1
+ {"version":3,"file":"wxs.mjs","names":[],"sources":["../../src/compiler/wxs.ts"],"sourcesContent":["export interface WxsTransformResult {\n code: string\n dependencies: string[]\n warnings?: string[]\n}\n\nexport interface WxsTransformOptions {\n resolvePath: (request: string, importer: string) => string | undefined\n toImportPath?: (resolved: string, importer: string) => string\n}\n\nconst REQUIRE_RE = /require\\(\\s*['\"]([^'\"]+)['\"]\\s*\\)/g\n\nfunction normalizePath(p: string) {\n return p.split('\\\\\\\\').join('/')\n}\n\nfunction isPlainWxsScript(pathname: string) {\n const lower = pathname.toLowerCase()\n if (lower.endsWith('.wxs') || lower.endsWith('.wxs.ts') || lower.endsWith('.wxs.js')) {\n return false\n }\n return lower.endsWith('.ts') || lower.endsWith('.js')\n}\n\nfunction appendWxsQuery(pathname: string) {\n if (pathname.includes('?wxs') || pathname.includes('&wxs')) {\n return pathname\n }\n return `${pathname}${pathname.includes('?') ? '&' : '?'}wxs`\n}\n\nfunction isSupportedRequirePath(request: string) {\n const normalized = request.replace(/\\\\/g, '/')\n return normalized.startsWith('.') || normalized.startsWith('/')\n}\n\nexport function transformWxsToEsm(code: string, id: string, options: WxsTransformOptions): WxsTransformResult {\n const dependencies: string[] = []\n const importLines: string[] = []\n const mapEntries: string[] = []\n const warnings: string[] = []\n\n const seen = new Set<string>()\n while (true) {\n const match = REQUIRE_RE.exec(code)\n if (!match) {\n break\n }\n const request = match[1]\n if (!request || seen.has(request)) {\n continue\n }\n seen.add(request)\n if (!isSupportedRequirePath(request)) {\n warnings.push(`[@weapp-vite/web] WXS require 仅支持相对或绝对路径: ${request} (from ${id})`)\n continue\n }\n const normalizedRequest = request.replace(/\\\\/g, '/')\n const resolved = options.resolvePath(normalizedRequest, id)\n if (!resolved) {\n warnings.push(`[@weapp-vite/web] 无法解析 WXS require: ${request} (from ${id})`)\n continue\n }\n let importPath = normalizePath(options.toImportPath?.(resolved, id) ?? resolved)\n if (isPlainWxsScript(resolved)) {\n importPath = appendWxsQuery(importPath)\n }\n const importName = `__wxs_dep_${dependencies.length}`\n importLines.push(`import ${importName} from '${importPath}'`)\n mapEntries.push(`[${JSON.stringify(request)}, ${importName}]`)\n dependencies.push(resolved)\n }\n\n const requireMap = `const __wxs_require_map = new Map([${mapEntries.join(', ')}])`\n const requireFn = [\n `const __wxs_require_warned = new Set()`,\n `function require(id) {`,\n ` if (__wxs_require_map.has(id)) {`,\n ` return __wxs_require_map.get(id)`,\n ` }`,\n ` if (!__wxs_require_warned.has(id)) {`,\n ` __wxs_require_warned.add(id)`,\n ` if (typeof console !== 'undefined' && typeof console.warn === 'function') {`,\n ` console.warn(\\`[@weapp-vite/web] WXS require 未解析: \\${id}\\`)`,\n ` }`,\n ` }`,\n ` return undefined`,\n `}`,\n ].join('\\\\n')\n const moduleInit = `const module = { exports: {} }\\\\nconst exports = module.exports`\n const helpers = `const getRegExp = (pattern, flags) => new RegExp(pattern, flags)\\\\nconst getDate = (value) => (value == null ? new Date() : new Date(value))`\n\n const body = [\n ...importLines,\n requireMap,\n requireFn,\n moduleInit,\n helpers,\n code,\n `export default module.exports`,\n ].join('\\\\n')\n\n return {\n code: body,\n dependencies,\n warnings: warnings.length > 0 ? warnings : undefined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AG,EAAE;GAC3E;EACF;EACA,IAAI,aAAa,cAAc,QAAQ,eAAe,UAAU,EAAE,KAAK,QAAQ;EAC/E,IAAI,iBAAiB,QAAQ,GAC3B,aAAa,eAAe,UAAU;EAExC,MAAM,aAAa,aAAa,aAAa;EAC7C,YAAY,KAAK,UAAU,WAAW,SAAS,WAAW,EAAE;EAC5D,WAAW,KAAK,IAAI,KAAK,UAAU,OAAO,EAAE,IAAI,WAAW,EAAE;EAC7D,aAAa,KAAK,QAAQ;CAC5B;CAEA,MAAM,aAAa,sCAAsC,WAAW,KAAK,IAAI,EAAE;CAC/E,MAAM,YAAY;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,EAAE,KAAK,KAAK;CACZ,MAAM,aAAa;CACnB,MAAM,UAAU;CAYhB,OAAO;EACL,MAXW;GACX,GAAG;GACH;GACA;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,KAGI;EACT;EACA,UAAU,SAAS,SAAS,IAAI,WAAW;CAC7C;AACF"}
@@ -1,5 +1,3 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
1
  //#region src/css/wxss.d.ts
4
2
  interface WxssTransformOptions {
5
3
  /**
package/dist/css/wxss.mjs CHANGED
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  //#region src/css/wxss.ts
10
2
  const RPX_RE = /(-?(?:\d+(?:\.\d+)?|\.\d+))rpx/gi;
11
3
  function transformWxssToCss(source, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"wxss.mjs","names":[],"sources":["../../src/css/wxss.ts"],"sourcesContent":["export interface WxssTransformOptions {\n /**\n * 1rpx 对应的 CSS 像素数。\n * 默认值近似于 750rpx 设计稿在 375px 屏幕上的换算。\n */\n pxPerRpx?: number\n /**\n * rpx 换算的设计宽度。传入后会把 rpx 转为\n * `calc(var(--rpx) * N)` 以实现响应式缩放。\n */\n designWidth?: number\n /**\n * 用于存储运行时 rpx 大小的 CSS 变量名。\n * @default \"--rpx\"\n */\n rpxVar?: string\n}\n\nexport interface WxssTransformResult {\n css: string\n}\n\nconst RPX_RE = /(-?(?:\\d+(?:\\.\\d+)?|\\.\\d+))rpx/gi\n\nexport function transformWxssToCss(source: string, options?: WxssTransformOptions): WxssTransformResult {\n const rpxVar = options?.rpxVar ?? '--rpx'\n const useVariable = typeof options?.designWidth === 'number' && Number.isFinite(options.designWidth)\n const ratio = options?.pxPerRpx ?? 0.5\n const css = source.replace(RPX_RE, (_, value: string) => {\n const numeric = Number.parseFloat(value)\n if (Number.isNaN(numeric)) {\n return `${value}px`\n }\n if (useVariable) {\n return `calc(var(${rpxVar}) * ${numeric})`\n }\n const converted = Math.round(numeric * ratio * 1000) / 1000\n return `${converted}px`\n })\n return {\n css,\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,SAAS;AAEf,SAAgB,mBAAmB,QAAgB,SAAqD;CACtG,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM,cAAc,OAAO,SAAS,gBAAgB,YAAY,OAAO,SAAS,QAAQ,WAAW;CACnG,MAAM,QAAQ,SAAS,YAAY;CAYnC,OAAO,EACL,KAZU,OAAO,QAAQ,SAAS,GAAG,UAAkB;EACvD,MAAM,UAAU,OAAO,WAAW,KAAK;EACvC,IAAI,OAAO,MAAM,OAAO,GACtB,OAAO,GAAG,MAAM;EAElB,IAAI,aACF,OAAO,YAAY,OAAO,MAAM,QAAQ;EAG1C,OAAO,GADW,KAAK,MAAM,UAAU,QAAQ,GAAI,IAAI,IACnC;CACtB,CAEI,EACJ;AACF"}
1
+ {"version":3,"file":"wxss.mjs","names":[],"sources":["../../src/css/wxss.ts"],"sourcesContent":["export interface WxssTransformOptions {\n /**\n * 1rpx 对应的 CSS 像素数。\n * 默认值近似于 750rpx 设计稿在 375px 屏幕上的换算。\n */\n pxPerRpx?: number\n /**\n * rpx 换算的设计宽度。传入后会把 rpx 转为\n * `calc(var(--rpx) * N)` 以实现响应式缩放。\n */\n designWidth?: number\n /**\n * 用于存储运行时 rpx 大小的 CSS 变量名。\n * @default \"--rpx\"\n */\n rpxVar?: string\n}\n\nexport interface WxssTransformResult {\n css: string\n}\n\nconst RPX_RE = /(-?(?:\\d+(?:\\.\\d+)?|\\.\\d+))rpx/gi\n\nexport function transformWxssToCss(source: string, options?: WxssTransformOptions): WxssTransformResult {\n const rpxVar = options?.rpxVar ?? '--rpx'\n const useVariable = typeof options?.designWidth === 'number' && Number.isFinite(options.designWidth)\n const ratio = options?.pxPerRpx ?? 0.5\n const css = source.replace(RPX_RE, (_, value: string) => {\n const numeric = Number.parseFloat(value)\n if (Number.isNaN(numeric)) {\n return `${value}px`\n }\n if (useVariable) {\n return `calc(var(${rpxVar}) * ${numeric})`\n }\n const converted = Math.round(numeric * ratio * 1000) / 1000\n return `${converted}px`\n })\n return {\n css,\n }\n}\n"],"mappings":";AAsBA,MAAM,SAAS;AAEf,SAAgB,mBAAmB,QAAgB,SAAqD;CACtG,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM,cAAc,OAAO,SAAS,gBAAgB,YAAY,OAAO,SAAS,QAAQ,WAAW;CACnG,MAAM,QAAQ,SAAS,YAAY;CAYnC,OAAO,EACL,KAZU,OAAO,QAAQ,SAAS,GAAG,UAAkB;EACvD,MAAM,UAAU,OAAO,WAAW,KAAK;EACvC,IAAI,OAAO,MAAM,OAAO,GACtB,OAAO,GAAG,MAAM;EAElB,IAAI,aACF,OAAO,YAAY,OAAO,MAAM,QAAQ;EAG1C,OAAO,GADW,KAAK,MAAM,UAAU,QAAQ,GAAI,IAAI,IACnC;CACtB,CAEI,EACJ;AACF"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,3 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
1
  import { transformWxssToCss } from "./css/wxss.mjs";
4
2
  import { WeappWebPluginOptions } from "./plugin/types.mjs";
5
3
  import { weappWebPlugin } from "./plugin/index.mjs";
package/dist/index.mjs CHANGED
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { transformWxssToCss } from "./css/wxss.mjs";
10
2
  import { weappWebPlugin } from "./plugin/index.mjs";
11
3
  import { injectStyle, removeStyle } from "./runtime/style.mjs";
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  //#region src/plugin/constants.ts
10
2
  const SCRIPT_EXTS = [
11
3
  ".ts",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../../src/plugin/constants.ts"],"sourcesContent":["export const SCRIPT_EXTS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs']\nexport const STYLE_EXTS = ['.wxss', '.scss', '.less', '.css']\nexport const TRANSFORM_STYLE_EXTS = ['.wxss']\nexport const TEMPLATE_EXTS = ['.wxml', '.axml', '.swan', '.ttml', '.qml', '.ksml', '.xhsml', '.html']\nexport const WXS_EXTS = ['.wxs', '.wxs.ts', '.wxs.js']\nexport const WXS_RESOLVE_EXTS = ['.wxs', '.wxs.ts', '.wxs.js', '.ts', '.js']\n\nexport const ENTRY_ID = '\\0@weapp-vite/web/entry'\n"],"mappings":";;;;;;;;;AAAA,MAAa,cAAc;CAAC;CAAO;CAAQ;CAAO;CAAQ;CAAQ;AAAM;AACxE,MAAa,aAAa;CAAC;CAAS;CAAS;CAAS;AAAM;AAC5D,MAAa,uBAAuB,CAAC,OAAO;AAC5C,MAAa,gBAAgB;CAAC;CAAS;CAAS;CAAS;CAAS;CAAQ;CAAS;CAAU;AAAO;AACpG,MAAa,WAAW;CAAC;CAAQ;CAAW;AAAS;AACrD,MAAa,mBAAmB;CAAC;CAAQ;CAAW;CAAW;CAAO;AAAK;AAE3E,MAAa,WAAW"}
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../../src/plugin/constants.ts"],"sourcesContent":["export const SCRIPT_EXTS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs']\nexport const STYLE_EXTS = ['.wxss', '.scss', '.less', '.css']\nexport const TRANSFORM_STYLE_EXTS = ['.wxss']\nexport const TEMPLATE_EXTS = ['.wxml', '.axml', '.swan', '.ttml', '.qml', '.ksml', '.xhsml', '.html']\nexport const WXS_EXTS = ['.wxs', '.wxs.ts', '.wxs.js']\nexport const WXS_RESOLVE_EXTS = ['.wxs', '.wxs.ts', '.wxs.js', '.ts', '.js']\n\nexport const ENTRY_ID = '\\0@weapp-vite/web/entry'\n"],"mappings":";AAAA,MAAa,cAAc;CAAC;CAAO;CAAQ;CAAO;CAAQ;CAAQ;AAAM;AACxE,MAAa,aAAa;CAAC;CAAS;CAAS;CAAS;AAAM;AAC5D,MAAa,uBAAuB,CAAC,OAAO;AAC5C,MAAa,gBAAgB;CAAC;CAAS;CAAS;CAAS;CAAS;CAAQ;CAAS;CAAU;AAAO;AACpG,MAAa,WAAW;CAAC;CAAQ;CAAW;AAAS;AACrD,MAAa,mBAAmB;CAAC;CAAQ;CAAW;CAAW;CAAO;AAAK;AAE3E,MAAa,WAAW"}
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { relativeModuleId, resolveRuntimePolyfillPath, toViteFsImport } from "./path.mjs";
10
2
 
11
3
  //#region src/plugin/entry.ts
@@ -1 +1 @@
1
- {"version":3,"file":"entry.mjs","names":[],"sources":["../../src/plugin/entry.ts"],"sourcesContent":["import type { WxssTransformOptions } from '../css/wxss'\n\nimport type { ScanResult, WeappWebPluginOptions } from './types'\nimport { relativeModuleId, resolveRuntimePolyfillPath, toViteFsImport } from './path'\n\nexport function generateEntryModule(\n result: ScanResult,\n root: string,\n wxssOptions?: WxssTransformOptions,\n pluginOptions?: WeappWebPluginOptions,\n) {\n const runtimePolyfillId = toViteFsImport(resolveRuntimePolyfillPath())\n const importLines: string[] = [`import { initializePageRoutes } from '${runtimePolyfillId}'`]\n const bodyLines: string[] = []\n\n for (const page of result.pages) {\n importLines.push(`import '${relativeModuleId(root, page.script)}'`)\n }\n for (const component of result.components) {\n importLines.push(`import '${relativeModuleId(root, component.script)}'`)\n }\n if (result.app) {\n importLines.push(`import '${relativeModuleId(root, result.app)}'`)\n }\n\n const pageOrder = result.pages.map(page => page.id)\n const rpxConfig = wxssOptions?.designWidth\n ? { designWidth: wxssOptions.designWidth, varName: wxssOptions.rpxVar }\n : undefined\n\n const initOptions: Record<string, any> = {}\n if (rpxConfig) {\n initOptions.rpx = rpxConfig\n }\n if (pluginOptions?.form?.preventDefault !== undefined) {\n initOptions.form = { preventDefault: pluginOptions.form.preventDefault }\n }\n\n const runtimeOptions: Record<string, any> = {}\n if (pluginOptions?.runtime?.executionMode) {\n runtimeOptions.executionMode = pluginOptions.runtime.executionMode\n }\n if (pluginOptions?.runtime?.warnings) {\n runtimeOptions.warnings = pluginOptions.runtime.warnings\n }\n if (Object.keys(runtimeOptions).length > 0) {\n initOptions.runtime = runtimeOptions\n }\n\n const initOptionsCode = Object.keys(initOptions).length > 0 ? `, ${JSON.stringify(initOptions)}` : ''\n bodyLines.push(`initializePageRoutes(${JSON.stringify(pageOrder)}${initOptionsCode})`)\n return [...importLines, ...bodyLines].join('\\n')\n}\n"],"mappings":";;;;;;;;;;;AAKA,SAAgB,oBACd,QACA,MACA,aACA,eACA;CAEA,MAAM,cAAwB,CAAC,yCADL,eAAe,2BAA2B,CACoB,EAAE,EAAE;CAC5F,MAAM,YAAsB,CAAC;CAE7B,KAAK,MAAM,QAAQ,OAAO,OACxB,YAAY,KAAK,WAAW,iBAAiB,MAAM,KAAK,MAAM,EAAE,EAAE;CAEpE,KAAK,MAAM,aAAa,OAAO,YAC7B,YAAY,KAAK,WAAW,iBAAiB,MAAM,UAAU,MAAM,EAAE,EAAE;CAEzE,IAAI,OAAO,KACT,YAAY,KAAK,WAAW,iBAAiB,MAAM,OAAO,GAAG,EAAE,EAAE;CAGnE,MAAM,YAAY,OAAO,MAAM,KAAI,SAAQ,KAAK,EAAE;CAClD,MAAM,YAAY,aAAa,cAC3B;EAAE,aAAa,YAAY;EAAa,SAAS,YAAY;CAAO,IACpE;CAEJ,MAAM,cAAmC,CAAC;CAC1C,IAAI,WACF,YAAY,MAAM;CAEpB,IAAI,eAAe,MAAM,mBAAmB,QAC1C,YAAY,OAAO,EAAE,gBAAgB,cAAc,KAAK,eAAe;CAGzE,MAAM,iBAAsC,CAAC;CAC7C,IAAI,eAAe,SAAS,eAC1B,eAAe,gBAAgB,cAAc,QAAQ;CAEvD,IAAI,eAAe,SAAS,UAC1B,eAAe,WAAW,cAAc,QAAQ;CAElD,IAAI,OAAO,KAAK,cAAc,EAAE,SAAS,GACvC,YAAY,UAAU;CAGxB,MAAM,kBAAkB,OAAO,KAAK,WAAW,EAAE,SAAS,IAAI,KAAK,KAAK,UAAU,WAAW,MAAM;CACnG,UAAU,KAAK,wBAAwB,KAAK,UAAU,SAAS,IAAI,gBAAgB,EAAE;CACrF,OAAO,CAAC,GAAG,aAAa,GAAG,SAAS,EAAE,KAAK,IAAI;AACjD"}
1
+ {"version":3,"file":"entry.mjs","names":[],"sources":["../../src/plugin/entry.ts"],"sourcesContent":["import type { WxssTransformOptions } from '../css/wxss'\n\nimport type { ScanResult, WeappWebPluginOptions } from './types'\nimport { relativeModuleId, resolveRuntimePolyfillPath, toViteFsImport } from './path'\n\nexport function generateEntryModule(\n result: ScanResult,\n root: string,\n wxssOptions?: WxssTransformOptions,\n pluginOptions?: WeappWebPluginOptions,\n) {\n const runtimePolyfillId = toViteFsImport(resolveRuntimePolyfillPath())\n const importLines: string[] = [`import { initializePageRoutes } from '${runtimePolyfillId}'`]\n const bodyLines: string[] = []\n\n for (const page of result.pages) {\n importLines.push(`import '${relativeModuleId(root, page.script)}'`)\n }\n for (const component of result.components) {\n importLines.push(`import '${relativeModuleId(root, component.script)}'`)\n }\n if (result.app) {\n importLines.push(`import '${relativeModuleId(root, result.app)}'`)\n }\n\n const pageOrder = result.pages.map(page => page.id)\n const rpxConfig = wxssOptions?.designWidth\n ? { designWidth: wxssOptions.designWidth, varName: wxssOptions.rpxVar }\n : undefined\n\n const initOptions: Record<string, any> = {}\n if (rpxConfig) {\n initOptions.rpx = rpxConfig\n }\n if (pluginOptions?.form?.preventDefault !== undefined) {\n initOptions.form = { preventDefault: pluginOptions.form.preventDefault }\n }\n\n const runtimeOptions: Record<string, any> = {}\n if (pluginOptions?.runtime?.executionMode) {\n runtimeOptions.executionMode = pluginOptions.runtime.executionMode\n }\n if (pluginOptions?.runtime?.warnings) {\n runtimeOptions.warnings = pluginOptions.runtime.warnings\n }\n if (Object.keys(runtimeOptions).length > 0) {\n initOptions.runtime = runtimeOptions\n }\n\n const initOptionsCode = Object.keys(initOptions).length > 0 ? `, ${JSON.stringify(initOptions)}` : ''\n bodyLines.push(`initializePageRoutes(${JSON.stringify(pageOrder)}${initOptionsCode})`)\n return [...importLines, ...bodyLines].join('\\n')\n}\n"],"mappings":";;;AAKA,SAAgB,oBACd,QACA,MACA,aACA,eACA;CAEA,MAAM,cAAwB,CAAC,yCADL,eAAe,2BAA2B,CACoB,EAAE,EAAE;CAC5F,MAAM,YAAsB,CAAC;CAE7B,KAAK,MAAM,QAAQ,OAAO,OACxB,YAAY,KAAK,WAAW,iBAAiB,MAAM,KAAK,MAAM,EAAE,EAAE;CAEpE,KAAK,MAAM,aAAa,OAAO,YAC7B,YAAY,KAAK,WAAW,iBAAiB,MAAM,UAAU,MAAM,EAAE,EAAE;CAEzE,IAAI,OAAO,KACT,YAAY,KAAK,WAAW,iBAAiB,MAAM,OAAO,GAAG,EAAE,EAAE;CAGnE,MAAM,YAAY,OAAO,MAAM,KAAI,SAAQ,KAAK,EAAE;CAClD,MAAM,YAAY,aAAa,cAC3B;EAAE,aAAa,YAAY;EAAa,SAAS,YAAY;CAAO,IACpE;CAEJ,MAAM,cAAmC,CAAC;CAC1C,IAAI,WACF,YAAY,MAAM;CAEpB,IAAI,eAAe,MAAM,mBAAmB,QAC1C,YAAY,OAAO,EAAE,gBAAgB,cAAc,KAAK,eAAe;CAGzE,MAAM,iBAAsC,CAAC;CAC7C,IAAI,eAAe,SAAS,eAC1B,eAAe,gBAAgB,cAAc,QAAQ;CAEvD,IAAI,eAAe,SAAS,UAC1B,eAAe,WAAW,cAAc,QAAQ;CAElD,IAAI,OAAO,KAAK,cAAc,EAAE,SAAS,GACvC,YAAY,UAAU;CAGxB,MAAM,kBAAkB,OAAO,KAAK,WAAW,EAAE,SAAS,IAAI,KAAK,KAAK,UAAU,WAAW,MAAM;CACnG,UAAU,KAAK,wBAAwB,KAAK,UAAU,SAAS,IAAI,gBAAgB,EAAE;CACrF,OAAO,CAAC,GAAG,aAAa,GAAG,SAAS,EAAE,KAAK,IAAI;AACjD"}
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { SCRIPT_EXTS, STYLE_EXTS, TEMPLATE_EXTS } from "./constants.mjs";
10
2
  import { extname } from "pathe";
11
3
  import { fs } from "@weapp-core/shared/fs";
@@ -1 +1 @@
1
- {"version":3,"file":"files.mjs","names":[],"sources":["../../src/plugin/files.ts"],"sourcesContent":["import { fs } from '@weapp-core/shared/fs'\nimport { extname } from 'pathe'\nimport { bundleRequire } from 'rolldown-require'\n\nimport { SCRIPT_EXTS, STYLE_EXTS, TEMPLATE_EXTS } from './constants'\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport async function readJsonFile(pathname: string) {\n const candidates = [pathname]\n if (pathname.endsWith('.json')) {\n candidates.push(`${pathname}.ts`, `${pathname}.js`)\n }\n\n for (const candidate of candidates) {\n if (!(await fs.pathExists(candidate))) {\n continue\n }\n if (candidate.endsWith('.json')) {\n const json = await fs.readJson(candidate).catch(() => undefined)\n if (!isRecord(json)) {\n return undefined\n }\n return json\n }\n const { mod } = await bundleRequire({\n filepath: candidate,\n preserveTemporaryFile: true,\n })\n const resolved = typeof mod.default === 'function'\n ? await mod.default()\n : mod.default\n if (!isRecord(resolved)) {\n return undefined\n }\n return resolved\n }\n\n return undefined\n}\n\nexport async function resolveJsonPath(basePath: string) {\n const candidates = [basePath]\n if (basePath.endsWith('.json')) {\n candidates.push(`${basePath}.ts`, `${basePath}.js`)\n }\n for (const candidate of candidates) {\n if (await fs.pathExists(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n\nexport async function resolveScriptFile(basePath: string) {\n const ext = extname(basePath)\n if (ext && (await fs.pathExists(basePath))) {\n return basePath\n }\n for (const candidateExt of SCRIPT_EXTS) {\n const candidate = `${basePath}${candidateExt}`\n if (await fs.pathExists(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n\nexport async function resolveStyleFile(scriptPath: string) {\n const base = scriptPath.replace(new RegExp(`${extname(scriptPath)}$`), '')\n for (const ext of STYLE_EXTS) {\n const candidate = `${base}${ext}`\n if (await fs.pathExists(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n\nexport async function resolveTemplateFile(scriptPath: string) {\n const base = scriptPath.replace(new RegExp(`${extname(scriptPath)}$`), '')\n for (const ext of TEMPLATE_EXTS) {\n const candidate = `${base}${ext}`\n if (await fs.pathExists(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAgB,SAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,eAAsB,aAAa,UAAkB;CACnD,MAAM,aAAa,CAAC,QAAQ;CAC5B,IAAI,SAAS,SAAS,OAAO,GAC3B,WAAW,KAAK,GAAG,SAAS,MAAM,GAAG,SAAS,IAAI;CAGpD,KAAK,MAAM,aAAa,YAAY;EAClC,IAAI,CAAE,MAAM,GAAG,WAAW,SAAS,GACjC;EAEF,IAAI,UAAU,SAAS,OAAO,GAAG;GAC/B,MAAM,OAAO,MAAM,GAAG,SAAS,SAAS,EAAE,YAAY,MAAS;GAC/D,IAAI,CAAC,SAAS,IAAI,GAChB;GAEF,OAAO;EACT;EACA,MAAM,EAAE,QAAQ,MAAM,cAAc;GAClC,UAAU;GACV,uBAAuB;EACzB,CAAC;EACD,MAAM,WAAW,OAAO,IAAI,YAAY,aACpC,MAAM,IAAI,QAAQ,IAClB,IAAI;EACR,IAAI,CAAC,SAAS,QAAQ,GACpB;EAEF,OAAO;CACT;AAGF;AAEA,eAAsB,gBAAgB,UAAkB;CACtD,MAAM,aAAa,CAAC,QAAQ;CAC5B,IAAI,SAAS,SAAS,OAAO,GAC3B,WAAW,KAAK,GAAG,SAAS,MAAM,GAAG,SAAS,IAAI;CAEpD,KAAK,MAAM,aAAa,YACtB,IAAI,MAAM,GAAG,WAAW,SAAS,GAC/B,OAAO;AAIb;AAEA,eAAsB,kBAAkB,UAAkB;CAExD,IADY,QAAQ,QACd,KAAM,MAAM,GAAG,WAAW,QAAQ,GACtC,OAAO;CAET,KAAK,MAAM,gBAAgB,aAAa;EACtC,MAAM,YAAY,GAAG,WAAW;EAChC,IAAI,MAAM,GAAG,WAAW,SAAS,GAC/B,OAAO;CAEX;AAEF;AAEA,eAAsB,iBAAiB,YAAoB;CACzD,MAAM,OAAO,WAAW,QAAQ,IAAI,OAAO,GAAG,QAAQ,UAAU,EAAE,EAAE,GAAG,EAAE;CACzE,KAAK,MAAM,OAAO,YAAY;EAC5B,MAAM,YAAY,GAAG,OAAO;EAC5B,IAAI,MAAM,GAAG,WAAW,SAAS,GAC/B,OAAO;CAEX;AAEF;AAEA,eAAsB,oBAAoB,YAAoB;CAC5D,MAAM,OAAO,WAAW,QAAQ,IAAI,OAAO,GAAG,QAAQ,UAAU,EAAE,EAAE,GAAG,EAAE;CACzE,KAAK,MAAM,OAAO,eAAe;EAC/B,MAAM,YAAY,GAAG,OAAO;EAC5B,IAAI,MAAM,GAAG,WAAW,SAAS,GAC/B,OAAO;CAEX;AAEF"}
1
+ {"version":3,"file":"files.mjs","names":[],"sources":["../../src/plugin/files.ts"],"sourcesContent":["import { fs } from '@weapp-core/shared/fs'\nimport { extname } from 'pathe'\nimport { bundleRequire } from 'rolldown-require'\n\nimport { SCRIPT_EXTS, STYLE_EXTS, TEMPLATE_EXTS } from './constants'\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport async function readJsonFile(pathname: string) {\n const candidates = [pathname]\n if (pathname.endsWith('.json')) {\n candidates.push(`${pathname}.ts`, `${pathname}.js`)\n }\n\n for (const candidate of candidates) {\n if (!(await fs.pathExists(candidate))) {\n continue\n }\n if (candidate.endsWith('.json')) {\n const json = await fs.readJson(candidate).catch(() => undefined)\n if (!isRecord(json)) {\n return undefined\n }\n return json\n }\n const { mod } = await bundleRequire({\n filepath: candidate,\n preserveTemporaryFile: true,\n })\n const resolved = typeof mod.default === 'function'\n ? await mod.default()\n : mod.default\n if (!isRecord(resolved)) {\n return undefined\n }\n return resolved\n }\n\n return undefined\n}\n\nexport async function resolveJsonPath(basePath: string) {\n const candidates = [basePath]\n if (basePath.endsWith('.json')) {\n candidates.push(`${basePath}.ts`, `${basePath}.js`)\n }\n for (const candidate of candidates) {\n if (await fs.pathExists(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n\nexport async function resolveScriptFile(basePath: string) {\n const ext = extname(basePath)\n if (ext && (await fs.pathExists(basePath))) {\n return basePath\n }\n for (const candidateExt of SCRIPT_EXTS) {\n const candidate = `${basePath}${candidateExt}`\n if (await fs.pathExists(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n\nexport async function resolveStyleFile(scriptPath: string) {\n const base = scriptPath.replace(new RegExp(`${extname(scriptPath)}$`), '')\n for (const ext of STYLE_EXTS) {\n const candidate = `${base}${ext}`\n if (await fs.pathExists(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n\nexport async function resolveTemplateFile(scriptPath: string) {\n const base = scriptPath.replace(new RegExp(`${extname(scriptPath)}$`), '')\n for (const ext of TEMPLATE_EXTS) {\n const candidate = `${base}${ext}`\n if (await fs.pathExists(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n"],"mappings":";;;;;;AAMA,SAAgB,SAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,eAAsB,aAAa,UAAkB;CACnD,MAAM,aAAa,CAAC,QAAQ;CAC5B,IAAI,SAAS,S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O,WAAW,QAAQ,IAAI,OAAO,GAAG,QAAQ,UAAU,EAAE,EAAE,GAAG,EAAE;CACzE,KAAK,MAAM,OAAO,eAAe;EAC/B,MAAM,YAAY,GAAG,OAAO;EAC5B,IAAI,MAAM,GAAG,WAAW,SAAS,GAC/B,OAAO;CAEX;AAEF"}
@@ -1,5 +1,3 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
1
  import { WeappWebPluginOptions } from "./types.mjs";
4
2
  import { SourceMap } from "magic-string";
5
3
 
@@ -1,11 +1,3 @@
1
-
2
-
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
5
-
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
-
9
1
  import { transformWxssToCss } from "../css/wxss.mjs";
10
2
  import { compileWxml } from "../compiler/wxml/compile.mjs";
11
3
  import { transformWxsToEsm } from "../compiler/wxs.mjs";