@weapp-vite/web 1.3.15 → 1.3.17

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 (243) hide show
  1. package/README.md +2 -2
  2. package/dist/_virtual/_rolldown/runtime.mjs +18 -0
  3. package/dist/compiler/wxml/attributes.mjs +93 -0
  4. package/dist/compiler/wxml/attributes.mjs.map +1 -0
  5. package/dist/compiler/wxml/compile.mjs +158 -0
  6. package/dist/compiler/wxml/compile.mjs.map +1 -0
  7. package/dist/compiler/wxml/dependency.mjs +31 -0
  8. package/dist/compiler/wxml/dependency.mjs.map +1 -0
  9. package/dist/compiler/wxml/interpolation.mjs +142 -0
  10. package/dist/compiler/wxml/interpolation.mjs.map +1 -0
  11. package/dist/compiler/wxml/navigation.mjs +85 -0
  12. package/dist/compiler/wxml/navigation.mjs.map +1 -0
  13. package/dist/compiler/wxml/parser.mjs +41 -0
  14. package/dist/compiler/wxml/parser.mjs.map +1 -0
  15. package/dist/compiler/wxml/renderer.mjs +114 -0
  16. package/dist/compiler/wxml/renderer.mjs.map +1 -0
  17. package/dist/compiler/wxml/specialNodes.mjs +85 -0
  18. package/dist/compiler/wxml/specialNodes.mjs.map +1 -0
  19. package/dist/compiler/wxs.mjs +83 -0
  20. package/dist/compiler/wxs.mjs.map +1 -0
  21. package/dist/css/wxss.d.mts +25 -0
  22. package/dist/css/wxss.mjs +17 -0
  23. package/dist/css/wxss.mjs.map +1 -0
  24. package/dist/index.d.mts +18 -2
  25. package/dist/index.mjs +18 -3
  26. package/dist/plugin/constants.mjs +43 -0
  27. package/dist/plugin/constants.mjs.map +1 -0
  28. package/dist/plugin/entry.mjs +29 -0
  29. package/dist/plugin/entry.mjs.map +1 -0
  30. package/dist/plugin/files.mjs +58 -0
  31. package/dist/plugin/files.mjs.map +1 -0
  32. package/dist/plugin/index.d.mts +33 -0
  33. package/dist/plugin/index.mjs +188 -0
  34. package/dist/plugin/index.mjs.map +1 -0
  35. package/dist/plugin/navigation.mjs +20 -0
  36. package/dist/plugin/navigation.mjs.map +1 -0
  37. package/dist/plugin/path.mjs +85 -0
  38. package/dist/plugin/path.mjs.map +1 -0
  39. package/dist/plugin/register.mjs +83 -0
  40. package/dist/plugin/register.mjs.map +1 -0
  41. package/dist/plugin/scan.mjs +195 -0
  42. package/dist/plugin/scan.mjs.map +1 -0
  43. package/dist/plugin/scanConfig.mjs +45 -0
  44. package/dist/plugin/scanConfig.mjs.map +1 -0
  45. package/dist/plugin/state.mjs +22 -0
  46. package/dist/plugin/state.mjs.map +1 -0
  47. package/dist/plugin/types.d.mts +46 -0
  48. package/dist/plugin.d.mts +3 -2
  49. package/dist/plugin.mjs +3 -2
  50. package/dist/runtime/button/helpers.mjs +92 -0
  51. package/dist/runtime/button/helpers.mjs.map +1 -0
  52. package/dist/runtime/button/index.d.mts +9 -0
  53. package/dist/runtime/button/index.mjs +198 -0
  54. package/dist/runtime/button/index.mjs.map +1 -0
  55. package/dist/runtime/button/style.mjs +168 -0
  56. package/dist/runtime/button/style.mjs.map +1 -0
  57. package/dist/runtime/component/behavior.mjs +98 -0
  58. package/dist/runtime/component/behavior.mjs.map +1 -0
  59. package/dist/runtime/component/constants.mjs +13 -0
  60. package/dist/runtime/component/constants.mjs.map +1 -0
  61. package/dist/runtime/component/dom.mjs +32 -0
  62. package/dist/runtime/component/dom.mjs.map +1 -0
  63. package/dist/runtime/component/element.mjs +208 -0
  64. package/dist/runtime/component/element.mjs.map +1 -0
  65. package/dist/runtime/component/events.mjs +49 -0
  66. package/dist/runtime/component/events.mjs.map +1 -0
  67. package/dist/runtime/component/index.d.mts +7 -0
  68. package/dist/runtime/component/index.mjs +44 -0
  69. package/dist/runtime/component/index.mjs.map +1 -0
  70. package/dist/runtime/component/state.mjs +63 -0
  71. package/dist/runtime/component/state.mjs.map +1 -0
  72. package/dist/runtime/component/types.d.mts +49 -0
  73. package/dist/runtime/component/utils.mjs +39 -0
  74. package/dist/runtime/component/utils.mjs.map +1 -0
  75. package/dist/runtime/execution.d.mts +7 -0
  76. package/dist/runtime/execution.mjs +37 -0
  77. package/dist/runtime/execution.mjs.map +1 -0
  78. package/dist/runtime/index.d.mts +16 -2
  79. package/dist/runtime/index.mjs +16 -2
  80. package/dist/runtime/legacyTemplate/dom.mjs +76 -0
  81. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -0
  82. package/dist/runtime/legacyTemplate/expression.mjs +113 -0
  83. package/dist/runtime/legacyTemplate/expression.mjs.map +1 -0
  84. package/dist/runtime/legacyTemplate/index.d.mts +9 -0
  85. package/dist/runtime/legacyTemplate/index.mjs +132 -0
  86. package/dist/runtime/legacyTemplate/index.mjs.map +1 -0
  87. package/dist/runtime/legacyTemplate/types.d.mts +6 -0
  88. package/dist/runtime/navigationBar/index.d.mts +10 -0
  89. package/dist/runtime/navigationBar/index.mjs +162 -0
  90. package/dist/runtime/navigationBar/index.mjs.map +1 -0
  91. package/dist/runtime/navigationBar/style.mjs +108 -0
  92. package/dist/runtime/navigationBar/style.mjs.map +1 -0
  93. package/dist/runtime/polyfill/ad.mjs +150 -0
  94. package/dist/runtime/polyfill/ad.mjs.map +1 -0
  95. package/dist/runtime/polyfill/appState.mjs +31 -0
  96. package/dist/runtime/polyfill/appState.mjs.map +1 -0
  97. package/dist/runtime/polyfill/async.mjs +31 -0
  98. package/dist/runtime/polyfill/async.mjs.map +1 -0
  99. package/dist/runtime/polyfill/auth.mjs +120 -0
  100. package/dist/runtime/polyfill/auth.mjs.map +1 -0
  101. package/dist/runtime/polyfill/authApi.mjs +101 -0
  102. package/dist/runtime/polyfill/authApi.mjs.map +1 -0
  103. package/dist/runtime/polyfill/background.mjs +31 -0
  104. package/dist/runtime/polyfill/background.mjs.map +1 -0
  105. package/dist/runtime/polyfill/canvasContext.mjs +115 -0
  106. package/dist/runtime/polyfill/canvasContext.mjs.map +1 -0
  107. package/dist/runtime/polyfill/capability.mjs +20 -0
  108. package/dist/runtime/polyfill/capability.mjs.map +1 -0
  109. package/dist/runtime/polyfill/cloud.mjs +39 -0
  110. package/dist/runtime/polyfill/cloud.mjs.map +1 -0
  111. package/dist/runtime/polyfill/device.mjs +44 -0
  112. package/dist/runtime/polyfill/device.mjs.map +1 -0
  113. package/dist/runtime/polyfill/deviceApi.mjs +31 -0
  114. package/dist/runtime/polyfill/deviceApi.mjs.map +1 -0
  115. package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +102 -0
  116. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +144 -0
  117. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -0
  118. package/dist/runtime/polyfill/filePicker.mjs +158 -0
  119. package/dist/runtime/polyfill/filePicker.mjs.map +1 -0
  120. package/dist/runtime/polyfill/fileSystemManager.mjs +45 -0
  121. package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -0
  122. package/dist/runtime/polyfill/files.mjs +118 -0
  123. package/dist/runtime/polyfill/files.mjs.map +1 -0
  124. package/dist/runtime/polyfill/index.d.mts +40 -0
  125. package/dist/runtime/polyfill/index.mjs +110 -0
  126. package/dist/runtime/polyfill/index.mjs.map +1 -0
  127. package/dist/runtime/polyfill/interaction.mjs +38 -0
  128. package/dist/runtime/polyfill/interaction.mjs.map +1 -0
  129. package/dist/runtime/polyfill/interactionApi.mjs +54 -0
  130. package/dist/runtime/polyfill/interactionApi.mjs.map +1 -0
  131. package/dist/runtime/polyfill/location.mjs +106 -0
  132. package/dist/runtime/polyfill/location.mjs.map +1 -0
  133. package/dist/runtime/polyfill/locationApi.mjs +120 -0
  134. package/dist/runtime/polyfill/locationApi.mjs.map +1 -0
  135. package/dist/runtime/polyfill/mediaActions.mjs +52 -0
  136. package/dist/runtime/polyfill/mediaActions.mjs.map +1 -0
  137. package/dist/runtime/polyfill/mediaApi/file.mjs +63 -0
  138. package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -0
  139. package/dist/runtime/polyfill/mediaApi/info.mjs +59 -0
  140. package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -0
  141. package/dist/runtime/polyfill/mediaApi/picker.mjs +82 -0
  142. package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -0
  143. package/dist/runtime/polyfill/mediaApi/preview.mjs +39 -0
  144. package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -0
  145. package/dist/runtime/polyfill/mediaApi/process.mjs +46 -0
  146. package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -0
  147. package/dist/runtime/polyfill/mediaInfo.mjs +136 -0
  148. package/dist/runtime/polyfill/mediaInfo.mjs.map +1 -0
  149. package/dist/runtime/polyfill/mediaPicker.mjs +213 -0
  150. package/dist/runtime/polyfill/mediaPicker.mjs.map +1 -0
  151. package/dist/runtime/polyfill/mediaProcess.mjs +65 -0
  152. package/dist/runtime/polyfill/mediaProcess.mjs.map +1 -0
  153. package/dist/runtime/polyfill/menuApi.mjs +70 -0
  154. package/dist/runtime/polyfill/menuApi.mjs.map +1 -0
  155. package/dist/runtime/polyfill/navigationBarRuntime.mjs +66 -0
  156. package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -0
  157. package/dist/runtime/polyfill/network/request.mjs +162 -0
  158. package/dist/runtime/polyfill/network/request.mjs.map +1 -0
  159. package/dist/runtime/polyfill/network/requestBridge.mjs +49 -0
  160. package/dist/runtime/polyfill/network/requestBridge.mjs.map +1 -0
  161. package/dist/runtime/polyfill/network/status.mjs +55 -0
  162. package/dist/runtime/polyfill/network/status.mjs.map +1 -0
  163. package/dist/runtime/polyfill/platformApi.mjs +33 -0
  164. package/dist/runtime/polyfill/platformApi.mjs.map +1 -0
  165. package/dist/runtime/polyfill/platformRuntime.mjs +120 -0
  166. package/dist/runtime/polyfill/platformRuntime.mjs.map +1 -0
  167. package/dist/runtime/polyfill/routeRuntime/dom.mjs +36 -0
  168. package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -0
  169. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +83 -0
  170. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -0
  171. package/dist/runtime/polyfill/routeRuntime/options.d.mts +33 -0
  172. package/dist/runtime/polyfill/routeRuntime/options.mjs +76 -0
  173. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -0
  174. package/dist/runtime/polyfill/routeRuntime/url.mjs +35 -0
  175. package/dist/runtime/polyfill/routeRuntime/url.mjs.map +1 -0
  176. package/dist/runtime/polyfill/routeRuntime.d.mts +43 -0
  177. package/dist/runtime/polyfill/routeRuntime.mjs +202 -0
  178. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -0
  179. package/dist/runtime/polyfill/runtimeCapabilityApi.mjs +26 -0
  180. package/dist/runtime/polyfill/runtimeCapabilityApi.mjs.map +1 -0
  181. package/dist/runtime/polyfill/runtimeDataApi.d.mts +79 -0
  182. package/dist/runtime/polyfill/runtimeDataApi.mjs +134 -0
  183. package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -0
  184. package/dist/runtime/polyfill/runtimeInfra.mjs +40 -0
  185. package/dist/runtime/polyfill/runtimeInfra.mjs.map +1 -0
  186. package/dist/runtime/polyfill/runtimeOps.mjs +62 -0
  187. package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -0
  188. package/dist/runtime/polyfill/selectorQuery.mjs +204 -0
  189. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -0
  190. package/dist/runtime/polyfill/storage.mjs +103 -0
  191. package/dist/runtime/polyfill/storage.mjs.map +1 -0
  192. package/dist/runtime/polyfill/storageAsync.mjs +62 -0
  193. package/dist/runtime/polyfill/storageAsync.mjs.map +1 -0
  194. package/dist/runtime/polyfill/subscribe.mjs +30 -0
  195. package/dist/runtime/polyfill/subscribe.mjs.map +1 -0
  196. package/dist/runtime/polyfill/system.mjs +111 -0
  197. package/dist/runtime/polyfill/system.mjs.map +1 -0
  198. package/dist/runtime/polyfill/systemApi.mjs +65 -0
  199. package/dist/runtime/polyfill/systemApi.mjs.map +1 -0
  200. package/dist/runtime/polyfill/types/base.d.mts +12 -0
  201. package/dist/runtime/polyfill/types/common.d.mts +126 -0
  202. package/dist/runtime/polyfill/types/locationRuntime.d.mts +151 -0
  203. package/dist/runtime/polyfill/types/mediaAuth.d.mts +152 -0
  204. package/dist/runtime/polyfill/types/platformRuntime.d.mts +141 -0
  205. package/dist/runtime/polyfill/types/systemAuth.d.mts +122 -0
  206. package/dist/runtime/polyfill/ui.mjs +135 -0
  207. package/dist/runtime/polyfill/ui.mjs.map +1 -0
  208. package/dist/runtime/polyfill/uiFeedback.mjs +35 -0
  209. package/dist/runtime/polyfill/uiFeedback.mjs.map +1 -0
  210. package/dist/runtime/polyfill/uiMediaApi.d.mts +172 -0
  211. package/dist/runtime/polyfill/uiMediaApi.mjs +162 -0
  212. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -0
  213. package/dist/runtime/polyfill/videoContext.mjs +56 -0
  214. package/dist/runtime/polyfill/videoContext.mjs.map +1 -0
  215. package/dist/runtime/polyfill/vkSession.mjs +58 -0
  216. package/dist/runtime/polyfill/vkSession.mjs.map +1 -0
  217. package/dist/runtime/polyfill/windowResize.mjs +39 -0
  218. package/dist/runtime/polyfill/windowResize.mjs.map +1 -0
  219. package/dist/runtime/polyfill/worker.mjs +77 -0
  220. package/dist/runtime/polyfill/worker.mjs.map +1 -0
  221. package/dist/runtime/polyfill.d.mts +5 -0
  222. package/dist/runtime/renderContext.d.mts +21 -0
  223. package/dist/runtime/renderContext.mjs +147 -0
  224. package/dist/runtime/renderContext.mjs.map +1 -0
  225. package/dist/runtime/rpx.d.mts +9 -0
  226. package/dist/runtime/rpx.mjs +27 -0
  227. package/dist/runtime/rpx.mjs.map +1 -0
  228. package/dist/runtime/style.d.mts +6 -0
  229. package/dist/runtime/style.mjs +37 -0
  230. package/dist/runtime/style.mjs.map +1 -0
  231. package/dist/runtime/template.d.mts +10 -0
  232. package/dist/runtime/warning.d.mts +10 -0
  233. package/dist/runtime/warning.mjs +43 -0
  234. package/dist/runtime/warning.mjs.map +1 -0
  235. package/dist/{slugify-B4l45KNs.mjs → shared/slugify.mjs} +3 -1
  236. package/dist/shared/slugify.mjs.map +1 -0
  237. package/dist/shared/wxml.mjs +83 -0
  238. package/dist/shared/wxml.mjs.map +1 -0
  239. package/package.json +2 -2
  240. package/dist/index-w9xxIH-l.d.mts +0 -1229
  241. package/dist/plugin-BARxSPO8.mjs +0 -1567
  242. package/dist/plugin-DP2iPVmw.d.mts +0 -96
  243. package/dist/runtime-D6j2_x_N.mjs +0 -6251
@@ -0,0 +1,41 @@
1
+ import { parseDocument } from "htmlparser2";
2
+
3
+ //#region src/compiler/wxml/parser.ts
4
+ function isRenderableNode(node) {
5
+ if (node.type === "directive" || node.type === "comment") return false;
6
+ if (node.type === "text") return (node.data ?? "").trim().length > 0;
7
+ return true;
8
+ }
9
+ function hasChildren(node) {
10
+ return Array.isArray(node.children);
11
+ }
12
+ function toRenderNode(node, children) {
13
+ if (node.type === "text") return {
14
+ type: "text",
15
+ data: node.data ?? ""
16
+ };
17
+ if (node.type === "tag" || node.type === "script" || node.type === "style") {
18
+ const element = node;
19
+ return {
20
+ type: "element",
21
+ name: element.name,
22
+ attribs: element.attribs ?? {},
23
+ children
24
+ };
25
+ }
26
+ }
27
+ function convertNode(node) {
28
+ if (!isRenderableNode(node)) return;
29
+ return toRenderNode(node, hasChildren(node) && node.children.length > 0 ? node.children.map((child) => convertNode(child)).filter((child) => Boolean(child)) : void 0);
30
+ }
31
+ function parseWxml(source) {
32
+ return (parseDocument(source, {
33
+ xmlMode: true,
34
+ decodeEntities: true,
35
+ recognizeSelfClosing: true
36
+ }).children ?? []).filter(isRenderableNode).map((node) => convertNode(node)).filter((node) => Boolean(node));
37
+ }
38
+
39
+ //#endregion
40
+ export { parseWxml };
41
+ //# sourceMappingURL=parser.mjs.map
@@ -0,0 +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;AACpC,KAAI,KAAK,SAAS,eAAe,KAAK,SAAS,UAC7C,QAAO;AAET,KAAI,KAAK,SAAS,OAEhB,SADc,KAAkB,QAAQ,IAC5B,MAAM,CAAC,SAAS;AAE9B,QAAO;;AAKT,SAAS,YAAY,MAAsC;AACzD,QAAO,MAAM,QAAS,KAA0B,SAAS;;AAG3D,SAAS,aAAa,MAAY,UAAiD;AACjF,KAAI,KAAK,SAAS,OAEhB,QAAO;EAAE,MAAM;EAAQ,MADT,KAAkB,QAAQ;EACX;AAE/B,KAAI,KAAK,SAAS,SAAS,KAAK,SAAS,YAAY,KAAK,SAAS,SAAS;EAC1E,MAAM,UAAU;AAChB,SAAO;GACL,MAAM;GACN,MAAM,QAAQ;GACd,SAAS,QAAQ,WAAW,EAAE;GAC9B;GACD;;;AAKL,SAAS,YAAY,MAAoC;AACvD,KAAI,CAAC,iBAAiB,KAAK,CACzB;AAKF,QAAO,aAAa,MAHF,YAAY,KAAK,IAAI,KAAK,SAAS,SAAS,IAC1D,KAAK,SAAS,KAAI,UAAS,YAAY,MAAM,CAAC,CAAC,QAAQ,UAA+B,QAAQ,MAAM,CAAC,GACrG,OAC+B;;AAGrC,SAAgB,UAAU,QAA8B;AAOtD,SANiB,cAAc,QAAQ;EACrC,SAAS;EACT,gBAAgB;EAChB,sBAAsB;EACvB,CAAC,CACsB,YAAY,EAAE,EAAE,OAAO,iBAAiB,CAE7D,KAAI,SAAQ,YAAY,KAAK,CAAC,CAC9B,QAAQ,SAA6B,QAAQ,KAAK,CAAC"}
@@ -0,0 +1,114 @@
1
+ import { SELF_CLOSING_TAGS, hasControlAttribute, normalizeTagName, resolveControlAttributeValue } from "../../shared/wxml.mjs";
2
+ import { buildExpression, buildTemplateDataExpression, parseInterpolations } from "./interpolation.mjs";
3
+ import { extractFor, isConditionalElement, renderAttributes, resolveComponentTagName, stripControlAttributes } from "./attributes.mjs";
4
+
5
+ //#region src/compiler/wxml/renderer.ts
6
+ var Renderer = class {
7
+ renderNodes(nodes, scopeVar, wxsVar, componentTags) {
8
+ const parts = [];
9
+ for (let index = 0; index < nodes.length; index += 1) {
10
+ const node = nodes[index];
11
+ if (isConditionalElement(node)) {
12
+ const { rendered, endIndex } = this.renderConditionalSequence(nodes, index, scopeVar, wxsVar, componentTags);
13
+ parts.push(rendered);
14
+ index = endIndex;
15
+ continue;
16
+ }
17
+ parts.push(this.renderNode(node, scopeVar, wxsVar, componentTags));
18
+ }
19
+ if (parts.length === 0) return "\"\"";
20
+ if (parts.length === 1) return parts[0];
21
+ return `[${parts.join(", ")}]`;
22
+ }
23
+ renderConditionalSequence(nodes, startIndex, scopeVar, wxsVar, componentTags) {
24
+ const branches = [];
25
+ let cursor = startIndex;
26
+ while (cursor < nodes.length) {
27
+ const candidate = nodes[cursor];
28
+ if (!isConditionalElement(candidate)) break;
29
+ const attribs = candidate.attribs ?? {};
30
+ if (branches.length === 0 && !hasControlAttribute(attribs, "if")) break;
31
+ if (branches.length > 0 && !hasControlAttribute(attribs, "elif") && !hasControlAttribute(attribs, "else")) break;
32
+ branches.push({
33
+ node: candidate,
34
+ attribs
35
+ });
36
+ cursor += 1;
37
+ if (hasControlAttribute(attribs, "else")) break;
38
+ }
39
+ if (!branches.length) {
40
+ const node = nodes[startIndex];
41
+ if (!node) return {
42
+ rendered: "\"\"",
43
+ endIndex: startIndex
44
+ };
45
+ return {
46
+ rendered: this.renderNode(node, scopeVar, wxsVar, componentTags),
47
+ endIndex: startIndex
48
+ };
49
+ }
50
+ let expr = "\"\"";
51
+ for (let index = branches.length - 1; index >= 0; index -= 1) {
52
+ const { node, attribs } = branches[index];
53
+ const cleanedAttribs = stripControlAttributes(attribs);
54
+ if (hasControlAttribute(attribs, "else")) {
55
+ expr = this.renderElement(node, scopeVar, wxsVar, componentTags, { overrideAttribs: cleanedAttribs });
56
+ continue;
57
+ }
58
+ const conditionExpr = resolveControlAttributeValue(attribs, "if") ?? resolveControlAttributeValue(attribs, "elif") ?? "";
59
+ const rendered = this.renderElement(node, scopeVar, wxsVar, componentTags, { overrideAttribs: cleanedAttribs });
60
+ expr = `(${buildExpression(parseInterpolations(conditionExpr), scopeVar, wxsVar)} ? ${rendered} : ${expr})`;
61
+ }
62
+ return {
63
+ rendered: expr,
64
+ endIndex: startIndex + branches.length - 1
65
+ };
66
+ }
67
+ renderNode(node, scopeVar, wxsVar, componentTags) {
68
+ if (node.type === "text") return buildExpression(parseInterpolations(node.data ?? ""), scopeVar, wxsVar);
69
+ if (node.type === "element") {
70
+ if (node.name === "template" && node.attribs?.is) return this.renderTemplateInvoke(node, scopeVar, wxsVar);
71
+ return this.renderElement(node, scopeVar, wxsVar, componentTags);
72
+ }
73
+ return "\"\"";
74
+ }
75
+ renderTemplateInvoke(node, scopeVar, wxsVar) {
76
+ const attribs = node.attribs ?? {};
77
+ const isExpr = buildExpression(parseInterpolations(attribs.is ?? ""), scopeVar, wxsVar);
78
+ const dataExpr = attribs.data ? buildTemplateDataExpression(attribs.data, scopeVar, wxsVar) : void 0;
79
+ return `ctx.renderTemplate(__templates, ${isExpr}, ${dataExpr ? `ctx.mergeScope(${scopeVar}, ${dataExpr})` : scopeVar}, ctx)`;
80
+ }
81
+ renderElement(node, scopeVar, wxsVar, componentTags, options = {}) {
82
+ const attribs = options.overrideAttribs ?? node.attribs ?? {};
83
+ if (!options.skipFor) {
84
+ const forInfo = extractFor(node.attribs ?? {});
85
+ if (forInfo.expr) {
86
+ const listExpr = `ctx.normalizeList(${buildExpression(parseInterpolations(forInfo.expr), scopeVar, wxsVar)})`;
87
+ const itemVar = forInfo.itemName;
88
+ const indexVar = forInfo.indexName;
89
+ const scopeExpr = `ctx.createScope(${scopeVar}, { ${itemVar}: ${itemVar}, ${indexVar}: ${indexVar} })`;
90
+ const itemRender = this.renderElement(node, "__scope", wxsVar, componentTags, {
91
+ skipFor: true,
92
+ overrideAttribs: forInfo.restAttribs
93
+ });
94
+ return `repeat(${listExpr}, (${itemVar}, ${indexVar}) => ${`ctx.key(${JSON.stringify(forInfo.key ?? "")}, ${itemVar}, ${indexVar}, ${scopeExpr}, ${wxsVar})`}, (${itemVar}, ${indexVar}) => { const __scope = ${scopeExpr}; return ${itemRender}; })`;
95
+ }
96
+ }
97
+ const customTag = resolveComponentTagName(node.name ?? "", componentTags);
98
+ const tagName = customTag ?? normalizeTagName(node.name ?? "");
99
+ if (tagName === "#fragment") return this.renderNodes(node.children ?? [], scopeVar, wxsVar, componentTags);
100
+ const attrs = renderAttributes(attribs, scopeVar, wxsVar, {
101
+ skipControl: true,
102
+ preferProperty: Boolean(customTag)
103
+ });
104
+ const childNodes = node.children ?? [];
105
+ const children = childNodes.map((child) => `\${${this.renderNode(child, scopeVar, wxsVar, componentTags)}}`).join("");
106
+ if (SELF_CLOSING_TAGS.has(tagName) && childNodes.length === 0) return `html\`<${tagName}${attrs} />\``;
107
+ return `html\`<${tagName}${attrs}>${children}</${tagName}>\``;
108
+ }
109
+ };
110
+ const renderer = new Renderer();
111
+
112
+ //#endregion
113
+ export { renderer };
114
+ //# sourceMappingURL=renderer.mjs.map
@@ -0,0 +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,EAAE;AAC1B,OAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;GACpD,MAAM,OAAO,MAAM;AACnB,OAAI,qBAAqB,KAAK,EAAE;IAC9B,MAAM,EAAE,UAAU,aAAa,KAAK,0BAClC,OACA,OACA,UACA,QACA,cACD;AACD,UAAM,KAAK,SAAS;AACpB,YAAQ;AACR;;AAEF,SAAM,KAAK,KAAK,WAAW,MAAM,UAAU,QAAQ,cAAc,CAAC;;AAEpE,MAAI,MAAM,WAAW,EACnB,QAAO;AAET,MAAI,MAAM,WAAW,EACnB,QAAO,MAAM;AAEf,SAAO,IAAI,MAAM,KAAK,KAAK,CAAC;;CAG9B,AAAQ,0BACN,OACA,YACA,UACA,QACA,eACwC;EACxC,MAAM,WAAgF,EAAE;EACxF,IAAI,SAAS;AACb,SAAO,SAAS,MAAM,QAAQ;GAC5B,MAAM,YAAY,MAAM;AACxB,OAAI,CAAC,qBAAqB,UAAU,CAClC;GAEF,MAAM,UAAU,UAAU,WAAW,EAAE;AACvC,OAAI,SAAS,WAAW,KAAK,CAAC,oBAAoB,SAAS,KAAK,CAC9D;AAEF,OAAI,SAAS,SAAS,KAAK,CAAC,oBAAoB,SAAS,OAAO,IAAI,CAAC,oBAAoB,SAAS,OAAO,CACvG;AAEF,YAAS,KAAK;IAAE,MAAM;IAAW;IAAS,CAAC;AAC3C,aAAU;AACV,OAAI,oBAAoB,SAAS,OAAO,CACtC;;AAGJ,MAAI,CAAC,SAAS,QAAQ;GACpB,MAAM,OAAO,MAAM;AACnB,OAAI,CAAC,KACH,QAAO;IAAE,UAAU;IAAM,UAAU;IAAY;AAEjD,UAAO;IAAE,UAAU,KAAK,WAAW,MAAM,UAAU,QAAQ,cAAc;IAAE,UAAU;IAAY;;EAEnG,IAAI,OAAO;AACX,OAAK,IAAI,QAAQ,SAAS,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG;GAC5D,MAAM,EAAE,MAAM,YAAY,SAAS;GACnC,MAAM,iBAAiB,uBAAuB,QAAQ;AACtD,OAAI,oBAAoB,SAAS,OAAO,EAAE;AACxC,WAAO,KAAK,cAAc,MAAM,UAAU,QAAQ,eAAe,EAAE,iBAAiB,gBAAgB,CAAC;AACrG;;GAEF,MAAM,gBAAgB,6BAA6B,SAAS,KAAK,IAC5D,6BAA6B,SAAS,OAAO,IAC7C;GACL,MAAM,WAAW,KAAK,cAAc,MAAM,UAAU,QAAQ,eAAe,EAAE,iBAAiB,gBAAgB,CAAC;AAE/G,UAAO,IADW,gBAAgB,oBAAoB,cAAc,EAAE,UAAU,OAAO,CAClE,KAAK,SAAS,KAAK,KAAK;;AAE/C,SAAO;GAAE,UAAU;GAAM,UAAU,aAAa,SAAS,SAAS;GAAG;;CAGvE,AAAQ,WACN,MACA,UACA,QACA,eACQ;AACR,MAAI,KAAK,SAAS,OAEhB,QAAO,gBADO,oBAAoB,KAAK,QAAQ,GAAG,EACpB,UAAU,OAAO;AAEjD,MAAI,KAAK,SAAS,WAAW;AAC3B,OAAI,KAAK,SAAS,cAAc,KAAK,SAAS,GAC5C,QAAO,KAAK,qBAAqB,MAAM,UAAU,OAAO;AAE1D,UAAO,KAAK,cAAc,MAAM,UAAU,QAAQ,cAAc;;AAElE,SAAO;;CAGT,AAAQ,qBACN,MACA,UACA,QACQ;EACR,MAAM,UAAU,KAAK,WAAW,EAAE;EAClC,MAAM,SAAS,gBAAgB,oBAAoB,QAAQ,MAAM,GAAG,EAAE,UAAU,OAAO;EACvF,MAAM,WAAW,QAAQ,OACrB,4BAA4B,QAAQ,MAAM,UAAU,OAAO,GAC3D;AAIJ,SAAO,mCAAmC,OAAO,IAH/B,WACd,kBAAkB,SAAS,IAAI,SAAS,KACxC,SAC2D;;CAGjE,AAAQ,cACN,MACA,UACA,QACA,eACA,UAAgC,EAAE,EAC1B;EACR,MAAM,UAAU,QAAQ,mBAAmB,KAAK,WAAW,EAAE;AAC7D,MAAI,CAAC,QAAQ,SAAS;GACpB,MAAM,UAAU,WAAW,KAAK,WAAW,EAAE,CAAC;AAC9C,OAAI,QAAQ,MAAM;IAEhB,MAAM,WAAW,qBADM,gBAAgB,oBAAoB,QAAQ,KAAK,EAAE,UAAU,OAAO,CACtC;IACrD,MAAM,UAAU,QAAQ;IACxB,MAAM,WAAW,QAAQ;IACzB,MAAM,YAAY,mBAAmB,SAAS,MAAM,QAAQ,IAAI,QAAQ,IAAI,SAAS,IAAI,SAAS;IAClG,MAAM,aAAa,KAAK,cACtB,MACA,WACA,QACA,eACA;KAAE,SAAS;KAAM,iBAAiB,QAAQ;KAAa,CACxD;AAED,WAAO,UAAU,SAAS,KAAK,QAAQ,IAAI,SAAS,OADpC,WAAW,KAAK,UAAU,QAAQ,OAAO,GAAG,CAAC,IAAI,QAAQ,IAAI,SAAS,IAAI,UAAU,IAAI,OAAO,GAC5C,KAAK,QAAQ,IAAI,SAAS,yBAAyB,UAAU,WAAW,WAAW;;;EAI1J,MAAM,YAAY,wBAAwB,KAAK,QAAQ,IAAI,cAAc;EACzE,MAAM,UAAU,aAAa,iBAAiB,KAAK,QAAQ,GAAG;AAC9D,MAAI,YAAY,YACd,QAAO,KAAK,YAAY,KAAK,YAAY,EAAE,EAAE,UAAU,QAAQ,cAAc;EAG/E,MAAM,QAAQ,iBAAiB,SAAS,UAAU,QAAQ;GACxD,aAAa;GACb,gBAAgB,QAAQ,UAAU;GACnC,CAAC;EACF,MAAM,aAAa,KAAK,YAAY,EAAE;EACtC,MAAM,WAAW,WACd,KAAI,UAAS,MAAM,KAAK,WAAW,OAAO,UAAU,QAAQ,cAAc,CAAC,GAAG,CAC9E,KAAK,GAAG;AACX,MAAI,kBAAkB,IAAI,QAAQ,IAAI,WAAW,WAAW,EAC1D,QAAO,UAAU,UAAU,MAAM;AAEnC,SAAO,UAAU,UAAU,MAAM,GAAG,SAAS,IAAI,QAAQ;;;AAI7D,MAAa,WAAW,IAAI,UAAU"}
@@ -0,0 +1,85 @@
1
+ import { TEMPLATE_IMPORT_TAG_NAMES, TEMPLATE_INCLUDE_TAG_NAMES } from "../../shared/wxml.mjs";
2
+ import { dirname, relative } from "pathe";
3
+
4
+ //#region src/compiler/wxml/specialNodes.ts
5
+ function shouldMarkWxsImport(pathname) {
6
+ const lower = pathname.toLowerCase();
7
+ if (lower.endsWith(".wxs") || lower.endsWith(".wxs.ts") || lower.endsWith(".wxs.js")) return false;
8
+ return lower.endsWith(".ts") || lower.endsWith(".js");
9
+ }
10
+ function collectSpecialNodes(nodes, context) {
11
+ const renderable = [];
12
+ for (const node of nodes) {
13
+ if (node.type === "element") {
14
+ const name = node.name ?? "";
15
+ if (name === "template" && node.attribs?.name) {
16
+ context.templates.push({
17
+ name: node.attribs.name,
18
+ nodes: collectSpecialNodes(node.children ?? [], context)
19
+ });
20
+ continue;
21
+ }
22
+ if (TEMPLATE_IMPORT_TAG_NAMES.includes(name) && node.attribs?.src) {
23
+ const resolved = context.resolveTemplate(node.attribs.src);
24
+ if (resolved) context.imports.push({
25
+ id: resolved,
26
+ importName: `__wxml_import_${context.imports.length}`
27
+ });
28
+ else context.warnings.push(`[web] 无法解析模板依赖: ${node.attribs.src} (from ${context.sourceId})`);
29
+ continue;
30
+ }
31
+ if (TEMPLATE_INCLUDE_TAG_NAMES.includes(name) && node.attribs?.src) {
32
+ const resolved = context.resolveTemplate(node.attribs.src);
33
+ if (resolved) context.includes.push({
34
+ id: resolved,
35
+ importName: `__wxml_include_${context.includes.length}`
36
+ });
37
+ else context.warnings.push(`[web] 无法解析模板依赖: ${node.attribs.src} (from ${context.sourceId})`);
38
+ continue;
39
+ }
40
+ if (name === "wxs") {
41
+ const moduleName = node.attribs?.module?.trim();
42
+ if (moduleName) {
43
+ if (context.wxsModules.get(moduleName)) context.warnings.push(`[web] WXS 模块名重复: ${moduleName} (from ${context.sourceId})`);
44
+ context.wxsModules.set(moduleName, context.sourceId);
45
+ if (node.attribs?.src) {
46
+ const resolved = context.resolveWxs(node.attribs.src);
47
+ if (resolved) context.wxs.push({
48
+ module: moduleName,
49
+ kind: "src",
50
+ importName: `__wxs_${context.wxs.length}`,
51
+ value: resolved
52
+ });
53
+ } else {
54
+ const inlineCode = (node.children ?? []).filter((child) => child.type === "text").map((child) => child.data ?? "").join("");
55
+ context.wxs.push({
56
+ module: moduleName,
57
+ kind: "inline",
58
+ importName: `__wxs_${context.wxs.length}`,
59
+ value: inlineCode
60
+ });
61
+ }
62
+ }
63
+ continue;
64
+ }
65
+ if (node.children?.length) node.children = collectSpecialNodes(node.children, context);
66
+ }
67
+ renderable.push(node);
68
+ }
69
+ return renderable;
70
+ }
71
+ function normalizeTemplatePath(pathname) {
72
+ return pathname.split("\\").join("/");
73
+ }
74
+ function toRelativeImport(from, target) {
75
+ const rel = relative(dirname(from), target);
76
+ if (!rel || rel.startsWith(".")) {
77
+ const fallback = normalizeTemplatePath(target).split("/").pop() ?? "";
78
+ return rel || `./${fallback}`;
79
+ }
80
+ return `./${rel}`;
81
+ }
82
+
83
+ //#endregion
84
+ export { collectSpecialNodes, normalizeTemplatePath, shouldMarkWxsImport, toRelativeImport };
85
+ //# sourceMappingURL=specialNodes.mjs.map
@@ -0,0 +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,aAAa;AACpC,KAAI,MAAM,SAAS,OAAO,IAAI,MAAM,SAAS,UAAU,IAAI,MAAM,SAAS,UAAU,CAClF,QAAO;AAET,QAAO,MAAM,SAAS,MAAM,IAAI,MAAM,SAAS,MAAM;;AAevD,SAAgB,oBAAoB,OAAqB,SAAqC;CAC5F,MAAM,aAA2B,EAAE;AACnC,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,KAAK,SAAS,WAAW;GAC3B,MAAM,OAAO,KAAK,QAAQ;AAC1B,OAAI,SAAS,cAAc,KAAK,SAAS,MAAM;AAC7C,YAAQ,UAAU,KAAK;KACrB,MAAM,KAAK,QAAQ;KACnB,OAAO,oBAAoB,KAAK,YAAY,EAAE,EAAE,QAAQ;KACzD,CAAC;AACF;;AAEF,OAAI,0BAA0B,SAAS,KAAK,IAAI,KAAK,SAAS,KAAK;IACjE,MAAM,WAAW,QAAQ,gBAAgB,KAAK,QAAQ,IAAI;AAC1D,QAAI,SACF,SAAQ,QAAQ,KAAK;KACnB,IAAI;KACJ,YAAY,iBAAiB,QAAQ,QAAQ;KAC9C,CAAC;QAGF,SAAQ,SAAS,KAAK,mBAAmB,KAAK,QAAQ,IAAI,SAAS,QAAQ,SAAS,GAAG;AAEzF;;AAEF,OAAI,2BAA2B,SAAS,KAAK,IAAI,KAAK,SAAS,KAAK;IAClE,MAAM,WAAW,QAAQ,gBAAgB,KAAK,QAAQ,IAAI;AAC1D,QAAI,SACF,SAAQ,SAAS,KAAK;KACpB,IAAI;KACJ,YAAY,kBAAkB,QAAQ,SAAS;KAChD,CAAC;QAGF,SAAQ,SAAS,KAAK,mBAAmB,KAAK,QAAQ,IAAI,SAAS,QAAQ,SAAS,GAAG;AAEzF;;AAEF,OAAI,SAAS,OAAO;IAClB,MAAM,aAAa,KAAK,SAAS,QAAQ,MAAM;AAC/C,QAAI,YAAY;AAEd,SADuB,QAAQ,WAAW,IAAI,WAAW,CAEvD,SAAQ,SAAS,KAAK,oBAAoB,WAAW,SAAS,QAAQ,SAAS,GAAG;AAEpF,aAAQ,WAAW,IAAI,YAAY,QAAQ,SAAS;AACpD,SAAI,KAAK,SAAS,KAAK;MACrB,MAAM,WAAW,QAAQ,WAAW,KAAK,QAAQ,IAAI;AACrD,UAAI,SACF,SAAQ,IAAI,KAAK;OACf,QAAQ;OACR,MAAM;OACN,YAAY,SAAS,QAAQ,IAAI;OACjC,OAAO;OACR,CAAC;YAGD;MACH,MAAM,cAAc,KAAK,YAAY,EAAE,EACpC,QAAO,UAAS,MAAM,SAAS,OAAO,CACtC,KAAI,UAAS,MAAM,QAAQ,GAAG,CAC9B,KAAK,GAAG;AACX,cAAQ,IAAI,KAAK;OACf,QAAQ;OACR,MAAM;OACN,YAAY,SAAS,QAAQ,IAAI;OACjC,OAAO;OACR,CAAC;;;AAGN;;AAEF,OAAI,KAAK,UAAU,OACjB,MAAK,WAAW,oBAAoB,KAAK,UAAU,QAAQ;;AAG/D,aAAW,KAAK,KAAK;;AAEvB,QAAO;;AAGT,SAAgB,sBAAsB,UAAkB;AACtD,QAAO,SAAS,MAAM,KAAK,CAAC,KAAK,IAAI;;AAGvC,SAAgB,iBAAiB,MAAc,QAAgB;CAE7D,MAAM,MAAM,SADI,QAAQ,KAAK,EACC,OAAO;AACrC,KAAI,CAAC,OAAO,IAAI,WAAW,IAAI,EAAE;EAC/B,MAAM,WAAW,sBAAsB,OAAO,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI;AACnE,SAAO,OAAO,KAAK;;AAErB,QAAO,KAAK"}
@@ -0,0 +1,83 @@
1
+ //#region src/compiler/wxs.ts
2
+ const REQUIRE_RE = /require\(\s*['"]([^'"]+)['"]\s*\)/g;
3
+ function normalizePath(p) {
4
+ return p.split("\\\\").join("/");
5
+ }
6
+ function isPlainWxsScript(pathname) {
7
+ const lower = pathname.toLowerCase();
8
+ if (lower.endsWith(".wxs") || lower.endsWith(".wxs.ts") || lower.endsWith(".wxs.js")) return false;
9
+ return lower.endsWith(".ts") || lower.endsWith(".js");
10
+ }
11
+ function appendWxsQuery(pathname) {
12
+ if (pathname.includes("?wxs") || pathname.includes("&wxs")) return pathname;
13
+ return `${pathname}${pathname.includes("?") ? "&" : "?"}wxs`;
14
+ }
15
+ function isSupportedRequirePath(request) {
16
+ const normalized = request.replace(/\\/g, "/");
17
+ return normalized.startsWith(".") || normalized.startsWith("/");
18
+ }
19
+ function transformWxsToEsm(code, id, options) {
20
+ const dependencies = [];
21
+ const importLines = [];
22
+ const mapEntries = [];
23
+ const warnings = [];
24
+ const seen = /* @__PURE__ */ new Set();
25
+ while (true) {
26
+ const match = REQUIRE_RE.exec(code);
27
+ if (!match) break;
28
+ const request = match[1];
29
+ if (!request || seen.has(request)) continue;
30
+ seen.add(request);
31
+ if (!isSupportedRequirePath(request)) {
32
+ warnings.push(`[@weapp-vite/web] WXS require 仅支持相对或绝对路径: ${request} (from ${id})`);
33
+ continue;
34
+ }
35
+ const normalizedRequest = request.replace(/\\/g, "/");
36
+ const resolved = options.resolvePath(normalizedRequest, id);
37
+ if (!resolved) {
38
+ warnings.push(`[@weapp-vite/web] 无法解析 WXS require: ${request} (from ${id})`);
39
+ continue;
40
+ }
41
+ let importPath = normalizePath(options.toImportPath?.(resolved, id) ?? resolved);
42
+ if (isPlainWxsScript(resolved)) importPath = appendWxsQuery(importPath);
43
+ const importName = `__wxs_dep_${dependencies.length}`;
44
+ importLines.push(`import ${importName} from '${importPath}'`);
45
+ mapEntries.push(`[${JSON.stringify(request)}, ${importName}]`);
46
+ dependencies.push(resolved);
47
+ }
48
+ const requireMap = `const __wxs_require_map = new Map([${mapEntries.join(", ")}])`;
49
+ const requireFn = [
50
+ `const __wxs_require_warned = new Set()`,
51
+ `function require(id) {`,
52
+ ` if (__wxs_require_map.has(id)) {`,
53
+ ` return __wxs_require_map.get(id)`,
54
+ ` }`,
55
+ ` if (!__wxs_require_warned.has(id)) {`,
56
+ ` __wxs_require_warned.add(id)`,
57
+ ` if (typeof console !== 'undefined' && typeof console.warn === 'function') {`,
58
+ ` console.warn(\`[@weapp-vite/web] WXS require 未解析: \${id}\`)`,
59
+ ` }`,
60
+ ` }`,
61
+ ` return undefined`,
62
+ `}`
63
+ ].join("\\n");
64
+ const moduleInit = `const module = { exports: {} }\\nconst exports = module.exports`;
65
+ const helpers = `const getRegExp = (pattern, flags) => new RegExp(pattern, flags)\\nconst getDate = (value) => (value == null ? new Date() : new Date(value))`;
66
+ return {
67
+ code: [
68
+ ...importLines,
69
+ requireMap,
70
+ requireFn,
71
+ moduleInit,
72
+ helpers,
73
+ code,
74
+ `export default module.exports`
75
+ ].join("\\n"),
76
+ dependencies,
77
+ warnings: warnings.length > 0 ? warnings : void 0
78
+ };
79
+ }
80
+
81
+ //#endregion
82
+ export { transformWxsToEsm };
83
+ //# sourceMappingURL=wxs.mjs.map
@@ -0,0 +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;AAChC,QAAO,EAAE,MAAM,OAAO,CAAC,KAAK,IAAI;;AAGlC,SAAS,iBAAiB,UAAkB;CAC1C,MAAM,QAAQ,SAAS,aAAa;AACpC,KAAI,MAAM,SAAS,OAAO,IAAI,MAAM,SAAS,UAAU,IAAI,MAAM,SAAS,UAAU,CAClF,QAAO;AAET,QAAO,MAAM,SAAS,MAAM,IAAI,MAAM,SAAS,MAAM;;AAGvD,SAAS,eAAe,UAAkB;AACxC,KAAI,SAAS,SAAS,OAAO,IAAI,SAAS,SAAS,OAAO,CACxD,QAAO;AAET,QAAO,GAAG,WAAW,SAAS,SAAS,IAAI,GAAG,MAAM,IAAI;;AAG1D,SAAS,uBAAuB,SAAiB;CAC/C,MAAM,aAAa,QAAQ,QAAQ,OAAO,IAAI;AAC9C,QAAO,WAAW,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI;;AAGjE,SAAgB,kBAAkB,MAAc,IAAY,SAAkD;CAC5G,MAAM,eAAyB,EAAE;CACjC,MAAM,cAAwB,EAAE;CAChC,MAAM,aAAuB,EAAE;CAC/B,MAAM,WAAqB,EAAE;CAE7B,MAAM,uBAAO,IAAI,KAAa;AAC9B,QAAO,MAAM;EACX,MAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,MAAI,CAAC,MACH;EAEF,MAAM,UAAU,MAAM;AACtB,MAAI,CAAC,WAAW,KAAK,IAAI,QAAQ,CAC/B;AAEF,OAAK,IAAI,QAAQ;AACjB,MAAI,CAAC,uBAAuB,QAAQ,EAAE;AACpC,YAAS,KAAK,6CAA6C,QAAQ,SAAS,GAAG,GAAG;AAClF;;EAEF,MAAM,oBAAoB,QAAQ,QAAQ,OAAO,IAAI;EACrD,MAAM,WAAW,QAAQ,YAAY,mBAAmB,GAAG;AAC3D,MAAI,CAAC,UAAU;AACb,YAAS,KAAK,uCAAuC,QAAQ,SAAS,GAAG,GAAG;AAC5E;;EAEF,IAAI,aAAa,cAAc,QAAQ,eAAe,UAAU,GAAG,IAAI,SAAS;AAChF,MAAI,iBAAiB,SAAS,CAC5B,cAAa,eAAe,WAAW;EAEzC,MAAM,aAAa,aAAa,aAAa;AAC7C,cAAY,KAAK,UAAU,WAAW,SAAS,WAAW,GAAG;AAC7D,aAAW,KAAK,IAAI,KAAK,UAAU,QAAQ,CAAC,IAAI,WAAW,GAAG;AAC9D,eAAa,KAAK,SAAS;;CAG7B,MAAM,aAAa,sCAAsC,WAAW,KAAK,KAAK,CAAC;CAC/E,MAAM,YAAY;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,MAAM;CACb,MAAM,aAAa;CACnB,MAAM,UAAU;AAYhB,QAAO;EACL,MAXW;GACX,GAAG;GACH;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,KAAK,MAAM;EAIX;EACA,UAAU,SAAS,SAAS,IAAI,WAAW;EAC5C"}
@@ -0,0 +1,25 @@
1
+ //#region src/css/wxss.d.ts
2
+ interface WxssTransformOptions {
3
+ /**
4
+ * 1rpx 对应的 CSS 像素数。
5
+ * 默认值近似于 750rpx 设计稿在 375px 屏幕上的换算。
6
+ */
7
+ pxPerRpx?: number;
8
+ /**
9
+ * rpx 换算的设计宽度。传入后会把 rpx 转为
10
+ * `calc(var(--rpx) * N)` 以实现响应式缩放。
11
+ */
12
+ designWidth?: number;
13
+ /**
14
+ * 用于存储运行时 rpx 大小的 CSS 变量名。
15
+ * @default "--rpx"
16
+ */
17
+ rpxVar?: string;
18
+ }
19
+ interface WxssTransformResult {
20
+ css: string;
21
+ }
22
+ declare function transformWxssToCss(source: string, options?: WxssTransformOptions): WxssTransformResult;
23
+ //#endregion
24
+ export { WxssTransformOptions, transformWxssToCss };
25
+ //# sourceMappingURL=wxss.d.mts.map
@@ -0,0 +1,17 @@
1
+ //#region src/css/wxss.ts
2
+ const RPX_RE = /(-?(?:\d+(?:\.\d+)?|\.\d+))rpx/gi;
3
+ function transformWxssToCss(source, options) {
4
+ const rpxVar = options?.rpxVar ?? "--rpx";
5
+ const useVariable = typeof options?.designWidth === "number" && Number.isFinite(options.designWidth);
6
+ const ratio = options?.pxPerRpx ?? .5;
7
+ return { css: source.replace(RPX_RE, (_, value) => {
8
+ const numeric = Number.parseFloat(value);
9
+ if (Number.isNaN(numeric)) return `${value}px`;
10
+ if (useVariable) return `calc(var(${rpxVar}) * ${numeric})`;
11
+ return `${Math.round(numeric * ratio * 1e3) / 1e3}px`;
12
+ }) };
13
+ }
14
+
15
+ //#endregion
16
+ export { transformWxssToCss };
17
+ //# sourceMappingURL=wxss.mjs.map
@@ -0,0 +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,YAAY;CACpG,MAAM,QAAQ,SAAS,YAAY;AAYnC,QAAO,EACL,KAZU,OAAO,QAAQ,SAAS,GAAG,UAAkB;EACvD,MAAM,UAAU,OAAO,WAAW,MAAM;AACxC,MAAI,OAAO,MAAM,QAAQ,CACvB,QAAO,GAAG,MAAM;AAElB,MAAI,YACF,QAAO,YAAY,OAAO,MAAM,QAAQ;AAG1C,SAAO,GADW,KAAK,MAAM,UAAU,QAAQ,IAAK,GAAG,IACnC;GACpB,EAGD"}
package/dist/index.d.mts CHANGED
@@ -1,3 +1,19 @@
1
- import { n as WeappWebPluginOptions, r as transformWxssToCss, t as weappWebPlugin } from "./plugin-DP2iPVmw.mjs";
2
- import { $ as showModal, $t as getMenuButtonBoundingClientRect, A as compressVideo, At as stopPullDownRefresh, B as openVideoEditor, Bt as registerComponent, C as chooseFile, Cn as createTemplate, Ct as preloadSubpackage, D as chooseMessageFile, Dn as ButtonFormConfig, Dt as setStorage, E as chooseMedia, En as createRenderContext, Et as request, F as hideTabBar, Ft as navigateBack, G as saveFile, Gt as getAccountInfoSync, H as previewMedia, Ht as switchTab, I as makePhoneCall, It as navigateTo, J as saveVideoToPhotosAlbum, Jt as getBatteryInfo, K as saveFileToDisk, Kt as getAppAuthorizeSetting, L as openCustomerServiceChat, Lt as reLaunch, M as getImageInfo, Mt as getEnterOptionsSync, N as getVideoInfo, Nt as getLaunchOptionsSync, O as chooseVideo, On as ensureButtonDefined, Ot as setStorageSync, P as hideLoading, Pt as initializePageRoutes, Q as showLoading, Qt as getLocation, R as openDocument, Rt as redirectTo, S as chooseAddress, Sn as TemplateScope, St as pageScrollTo, T as chooseLocation, Tn as RenderContext, Tt as removeStorageSync, U as requestPayment, Ut as authorize, V as previewImage, Vt as registerPage, W as requestSubscribeMessage, Wt as checkSession, X as setClipboardData, Xt as getDeviceInfo, Y as scanCode, Yt as getBatteryInfoSync, Z as showActionSheet, Zt as getFuzzyLocation, _ as setBackgroundColor, _n as setNavigationBarMetrics, _t as getStorageSync, a as removeStyle, an as getUserInfo, at as clearStorageSync, b as setNavigationBarTitle, bn as defineComponent, bt as navigateToMiniProgram, c as canIUse, cn as login, ct as createVKSession, d as getExtConfig, dn as onNetworkStatusChange, dt as downloadFile, en as getNetworkType, et as showShareMenu, f as getExtConfigSync, fn as onWindowResize, ft as exitMiniProgram, g as reportAnalytics, gn as NavigationBarMetrics, gt as getStorageInfoSync, h as hideNavigationBarLoading, hn as vibrateShort, ht as getStorageInfo, i as injectStyle, in as getSystemSetting, it as clearStorage, j as getClipboardData, jt as uploadFile, k as compressImage, kn as setButtonFormConfig, kt as startPullDownRefresh, l as createInterstitialAd, ln as offNetworkStatusChange, lt as createVideoContext, m as getUpdateManager, mn as openSetting, mt as getStorage, n as RuntimeWarningOptions, nn as getSystemInfo, nt as showToast, o as RpxConfig, on as getUserProfile, ot as createCanvasContext, p as getLogManager, pn as openAppAuthorizeSetting, pt as getFileSystemManager, q as saveImageToPhotosAlbum, qt as getAppBaseInfo, r as setRuntimeWarningOptions, rn as getSystemInfoSync, rt as updateShareMenu, s as setupRpx, sn as getWindowInfo, st as createSelectorQuery, t as RuntimeWarningLevel, tn as getSetting, tt as showTabBar, u as createRewardedVideoAd, un as offWindowResize, ut as createWorker, v as setBackgroundTextStyle, vn as getRuntimeExecutionMode, vt as hideKeyboard, w as chooseImage, wn as renderTemplate, wt as removeStorage, x as showNavigationBarLoading, xn as TemplateRenderer, xt as nextTick, y as setNavigationBarColor, yn as setRuntimeExecutionMode, yt as loadSubPackage, z as openLocation, zt as registerApp } from "./index-w9xxIH-l.mjs";
1
+ import { transformWxssToCss } from "./css/wxss.mjs";
2
+ import { WeappWebPluginOptions } from "./plugin/types.mjs";
3
+ import { weappWebPlugin } from "./plugin/index.mjs";
4
+ import { ButtonFormConfig, ensureButtonDefined, setButtonFormConfig } from "./runtime/button/index.mjs";
5
+ import { RenderContext, createRenderContext } from "./runtime/renderContext.mjs";
6
+ import { createTemplate, renderTemplate } from "./runtime/legacyTemplate/index.mjs";
7
+ import { TemplateRenderer, TemplateScope } from "./runtime/template.mjs";
8
+ import { defineComponent } from "./runtime/component/index.mjs";
9
+ import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./runtime/execution.mjs";
10
+ import { NavigationBarMetrics, setNavigationBarMetrics } from "./runtime/navigationBar/index.mjs";
11
+ import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./runtime/polyfill/deviceAuthSystemApi.mjs";
12
+ import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./runtime/polyfill/routeRuntime.mjs";
13
+ import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtime/polyfill/runtimeDataApi.mjs";
14
+ import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showToast, updateShareMenu } from "./runtime/polyfill/uiMediaApi.mjs";
15
+ import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./runtime/polyfill/index.mjs";
16
+ import { RpxConfig, setupRpx } from "./runtime/rpx.mjs";
17
+ import { injectStyle, removeStyle } from "./runtime/style.mjs";
18
+ import { RuntimeWarningLevel, RuntimeWarningOptions, setRuntimeWarningOptions } from "./runtime/warning.mjs";
3
19
  export { ButtonFormConfig, NavigationBarMetrics, RenderContext, RpxConfig, RuntimeWarningLevel, RuntimeWarningOptions, TemplateRenderer, TemplateScope, type WeappWebPluginOptions, authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRenderContext, createRewardedVideoAd, createSelectorQuery, createTemplate, createVKSession, createVideoContext, createWorker, defineComponent, downloadFile, ensureButtonDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeExecutionMode, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, initializePageRoutes, injectStyle, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeStyle, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setupRpx, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, transformWxssToCss, updateShareMenu, uploadFile, vibrateShort, weappWebPlugin };
package/dist/index.mjs CHANGED
@@ -1,3 +1,18 @@
1
- import { $ as clearStorage, $t as getSystemInfoSync, A as hideTabBar, At as navigateBack, B as saveFile, Bt as checkSession, C as chooseVideo, Ct as setStorageSync, D as getImageInfo, Dt as getEnterOptionsSync, E as getClipboardData, Et as uploadFile, F as openVideoEditor, Ft as registerComponent, G as setClipboardData, Gt as getBatteryInfoSync, H as saveImageToPhotosAlbum, Ht as getAppAuthorizeSetting, I as previewImage, It as registerPage, J as showModal, Jt as getLocation, K as showActionSheet, Kt as getDeviceInfo, L as previewMedia, Lt as switchTab, M as openCustomerServiceChat, Mt as reLaunch, N as openDocument, Nt as redirectTo, O as getVideoInfo, Ot as getLaunchOptionsSync, P as openLocation, Pt as registerApp, Q as updateShareMenu, Qt as getSystemInfo, R as requestPayment, Rt as setupRpx, S as chooseMessageFile, St as setStorage, T as compressVideo, Tt as stopPullDownRefresh, U as saveVideoToPhotosAlbum, Ut as getAppBaseInfo, V as saveFileToDisk, Vt as getAccountInfoSync, W as scanCode, Wt as getBatteryInfo, X as showTabBar, Xt as getNetworkType, Y as showShareMenu, Yt as getMenuButtonBoundingClientRect, Z as showToast, Zt as getSetting, _ as chooseAddress, _n as setRuntimeWarningOptions, _t as pageScrollTo, a as createRewardedVideoAd, an as offNetworkStatusChange, at as createWorker, b as chooseLocation, bn as injectStyle, bt as removeStorageSync, c as getLogManager, cn as onWindowResize, ct as getFileSystemManager, d as reportAnalytics, dn as vibrateShort, dt as getStorageInfoSync, en as getSystemSetting, et as clearStorageSync, f as setBackgroundColor, fn as setNavigationBarMetrics, ft as getStorageSync, g as showNavigationBarLoading, gn as setRuntimeExecutionMode, gt as nextTick, h as setNavigationBarTitle, hn as getRuntimeExecutionMode, ht as navigateToMiniProgram, i as createInterstitialAd, in as login, it as createVideoContext, j as makePhoneCall, jt as navigateTo, k as hideLoading, kt as initializePageRoutes, l as getUpdateManager, ln as openAppAuthorizeSetting, lt as getStorage, m as setNavigationBarColor, mn as createRenderContext, mt as loadSubPackage, n as renderTemplate, nn as getUserProfile, nt as createSelectorQuery, o as getExtConfig, on as offWindowResize, ot as downloadFile, p as setBackgroundTextStyle, pn as defineComponent, pt as hideKeyboard, q as showLoading, qt as getFuzzyLocation, r as canIUse, rn as getWindowInfo, rt as createVKSession, s as getExtConfigSync, sn as onNetworkStatusChange, st as exitMiniProgram, t as createTemplate, tn as getUserInfo, tt as createCanvasContext, u as hideNavigationBarLoading, un as openSetting, ut as getStorageInfo, v as chooseFile, vn as ensureButtonDefined, vt as preloadSubpackage, w as compressImage, wt as startPullDownRefresh, x as chooseMedia, xn as removeStyle, xt as request, y as chooseImage, yn as setButtonFormConfig, yt as removeStorage, z as requestSubscribeMessage, zt as authorize } from "./runtime-D6j2_x_N.mjs";
2
- import { n as transformWxssToCss, t as weappWebPlugin } from "./plugin-BARxSPO8.mjs";
3
- export { authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRenderContext, createRewardedVideoAd, createSelectorQuery, createTemplate, createVKSession, createVideoContext, createWorker, defineComponent, downloadFile, ensureButtonDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeExecutionMode, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, initializePageRoutes, injectStyle, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeStyle, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setupRpx, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, transformWxssToCss, updateShareMenu, uploadFile, vibrateShort, weappWebPlugin };
1
+ import { transformWxssToCss } from "./css/wxss.mjs";
2
+ import { weappWebPlugin } from "./plugin/index.mjs";
3
+ import { injectStyle, removeStyle } from "./runtime/style.mjs";
4
+ import { ensureButtonDefined, setButtonFormConfig } from "./runtime/button/index.mjs";
5
+ import { setRuntimeWarningOptions } from "./runtime/warning.mjs";
6
+ import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./runtime/execution.mjs";
7
+ import { createRenderContext } from "./runtime/renderContext.mjs";
8
+ import { defineComponent } from "./runtime/component/index.mjs";
9
+ import { setNavigationBarMetrics } from "./runtime/navigationBar/index.mjs";
10
+ import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./runtime/polyfill/deviceAuthSystemApi.mjs";
11
+ import { setupRpx } from "./runtime/rpx.mjs";
12
+ import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./runtime/polyfill/routeRuntime.mjs";
13
+ import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtime/polyfill/runtimeDataApi.mjs";
14
+ import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showToast, updateShareMenu } from "./runtime/polyfill/uiMediaApi.mjs";
15
+ import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./runtime/polyfill/index.mjs";
16
+ import { createTemplate, renderTemplate } from "./runtime/legacyTemplate/index.mjs";
17
+
18
+ export { authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRenderContext, createRewardedVideoAd, createSelectorQuery, createTemplate, createVKSession, createVideoContext, createWorker, defineComponent, downloadFile, ensureButtonDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeExecutionMode, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, initializePageRoutes, injectStyle, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeStyle, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setupRpx, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, transformWxssToCss, updateShareMenu, uploadFile, vibrateShort, weappWebPlugin };
@@ -0,0 +1,43 @@
1
+ //#region src/plugin/constants.ts
2
+ const SCRIPT_EXTS = [
3
+ ".ts",
4
+ ".tsx",
5
+ ".js",
6
+ ".jsx",
7
+ ".mjs",
8
+ ".cjs"
9
+ ];
10
+ const STYLE_EXTS = [
11
+ ".wxss",
12
+ ".scss",
13
+ ".less",
14
+ ".css"
15
+ ];
16
+ const TRANSFORM_STYLE_EXTS = [".wxss"];
17
+ const TEMPLATE_EXTS = [
18
+ ".wxml",
19
+ ".axml",
20
+ ".swan",
21
+ ".ttml",
22
+ ".qml",
23
+ ".ksml",
24
+ ".xhsml",
25
+ ".html"
26
+ ];
27
+ const WXS_EXTS = [
28
+ ".wxs",
29
+ ".wxs.ts",
30
+ ".wxs.js"
31
+ ];
32
+ const WXS_RESOLVE_EXTS = [
33
+ ".wxs",
34
+ ".wxs.ts",
35
+ ".wxs.js",
36
+ ".ts",
37
+ ".js"
38
+ ];
39
+ const ENTRY_ID = "\0@weapp-vite/web/entry";
40
+
41
+ //#endregion
42
+ export { ENTRY_ID, SCRIPT_EXTS, STYLE_EXTS, TEMPLATE_EXTS, TRANSFORM_STYLE_EXTS, WXS_EXTS, WXS_RESOLVE_EXTS };
43
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +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;CAAO;AACzE,MAAa,aAAa;CAAC;CAAS;CAAS;CAAS;CAAO;AAC7D,MAAa,uBAAuB,CAAC,QAAQ;AAC7C,MAAa,gBAAgB;CAAC;CAAS;CAAS;CAAS;CAAS;CAAQ;CAAS;CAAU;CAAQ;AACrG,MAAa,WAAW;CAAC;CAAQ;CAAW;CAAU;AACtD,MAAa,mBAAmB;CAAC;CAAQ;CAAW;CAAW;CAAO;CAAM;AAE5E,MAAa,WAAW"}
@@ -0,0 +1,29 @@
1
+ import { relativeModuleId, resolveRuntimePolyfillPath, toViteFsImport } from "./path.mjs";
2
+
3
+ //#region src/plugin/entry.ts
4
+ function generateEntryModule(result, root, wxssOptions, pluginOptions) {
5
+ const importLines = [`import { initializePageRoutes } from '${toViteFsImport(resolveRuntimePolyfillPath())}'`];
6
+ const bodyLines = [];
7
+ for (const page of result.pages) importLines.push(`import '${relativeModuleId(root, page.script)}'`);
8
+ for (const component of result.components) importLines.push(`import '${relativeModuleId(root, component.script)}'`);
9
+ if (result.app) importLines.push(`import '${relativeModuleId(root, result.app)}'`);
10
+ const pageOrder = result.pages.map((page) => page.id);
11
+ const rpxConfig = wxssOptions?.designWidth ? {
12
+ designWidth: wxssOptions.designWidth,
13
+ varName: wxssOptions.rpxVar
14
+ } : void 0;
15
+ const initOptions = {};
16
+ if (rpxConfig) initOptions.rpx = rpxConfig;
17
+ if (pluginOptions?.form?.preventDefault !== void 0) initOptions.form = { preventDefault: pluginOptions.form.preventDefault };
18
+ const runtimeOptions = {};
19
+ if (pluginOptions?.runtime?.executionMode) runtimeOptions.executionMode = pluginOptions.runtime.executionMode;
20
+ if (pluginOptions?.runtime?.warnings) runtimeOptions.warnings = pluginOptions.runtime.warnings;
21
+ if (Object.keys(runtimeOptions).length > 0) initOptions.runtime = runtimeOptions;
22
+ const initOptionsCode = Object.keys(initOptions).length > 0 ? `, ${JSON.stringify(initOptions)}` : "";
23
+ bodyLines.push(`initializePageRoutes(${JSON.stringify(pageOrder)}${initOptionsCode})`);
24
+ return [...importLines, ...bodyLines].join("\n");
25
+ }
26
+
27
+ //#endregion
28
+ export { generateEntryModule };
29
+ //# sourceMappingURL=entry.mjs.map
@@ -0,0 +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,4BAA4B,CAAC,CACoB,GAAG;CAC7F,MAAM,YAAsB,EAAE;AAE9B,MAAK,MAAM,QAAQ,OAAO,MACxB,aAAY,KAAK,WAAW,iBAAiB,MAAM,KAAK,OAAO,CAAC,GAAG;AAErE,MAAK,MAAM,aAAa,OAAO,WAC7B,aAAY,KAAK,WAAW,iBAAiB,MAAM,UAAU,OAAO,CAAC,GAAG;AAE1E,KAAI,OAAO,IACT,aAAY,KAAK,WAAW,iBAAiB,MAAM,OAAO,IAAI,CAAC,GAAG;CAGpE,MAAM,YAAY,OAAO,MAAM,KAAI,SAAQ,KAAK,GAAG;CACnD,MAAM,YAAY,aAAa,cAC3B;EAAE,aAAa,YAAY;EAAa,SAAS,YAAY;EAAQ,GACrE;CAEJ,MAAM,cAAmC,EAAE;AAC3C,KAAI,UACF,aAAY,MAAM;AAEpB,KAAI,eAAe,MAAM,mBAAmB,OAC1C,aAAY,OAAO,EAAE,gBAAgB,cAAc,KAAK,gBAAgB;CAG1E,MAAM,iBAAsC,EAAE;AAC9C,KAAI,eAAe,SAAS,cAC1B,gBAAe,gBAAgB,cAAc,QAAQ;AAEvD,KAAI,eAAe,SAAS,SAC1B,gBAAe,WAAW,cAAc,QAAQ;AAElD,KAAI,OAAO,KAAK,eAAe,CAAC,SAAS,EACvC,aAAY,UAAU;CAGxB,MAAM,kBAAkB,OAAO,KAAK,YAAY,CAAC,SAAS,IAAI,KAAK,KAAK,UAAU,YAAY,KAAK;AACnG,WAAU,KAAK,wBAAwB,KAAK,UAAU,UAAU,GAAG,gBAAgB,GAAG;AACtF,QAAO,CAAC,GAAG,aAAa,GAAG,UAAU,CAAC,KAAK,KAAK"}