vite-plugin-taro 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/README.en.md +44 -0
  2. package/README.md +22 -497
  3. package/client.d.ts +9 -0
  4. package/dist/node/plugins/client/client-taro.d.ts +4 -0
  5. package/dist/node/plugins/client/client-taro.js +19 -0
  6. package/dist/node/plugins/client/constant.d.ts +4 -0
  7. package/dist/node/plugins/client/constant.js +4 -0
  8. package/dist/node/plugins/conditional/conditional-directives.d.ts +4 -0
  9. package/dist/node/plugins/{conditional-directives.js → conditional/conditional-directives.js} +27 -11
  10. package/dist/node/plugins/css/plugins.d.ts +4 -0
  11. package/dist/node/plugins/css/plugins.js +84 -0
  12. package/dist/node/plugins/h5/constant.d.ts +2 -0
  13. package/dist/node/plugins/h5/constant.js +3 -0
  14. package/dist/node/plugins/h5/plugins.d.ts +4 -0
  15. package/dist/node/plugins/h5/plugins.js +161 -0
  16. package/dist/node/plugins/h5/resolver/module-resolver.d.ts +14 -0
  17. package/dist/node/plugins/h5/resolver/module-resolver.js +19 -0
  18. package/dist/node/plugins/h5/transform-app.d.ts +10 -0
  19. package/dist/node/plugins/h5/transform-app.js +48 -0
  20. package/dist/node/plugins/wx/dev/dev-host.d.ts +15 -0
  21. package/dist/node/plugins/wx/dev/dev-host.js +352 -0
  22. package/dist/node/plugins/wx/dev/hmr-files.d.ts +28 -0
  23. package/dist/node/plugins/wx/dev/hmr-files.js +34 -0
  24. package/dist/node/plugins/wx/dev/patch-publisher.d.ts +22 -0
  25. package/dist/node/plugins/wx/dev/patch-publisher.js +40 -0
  26. package/dist/node/plugins/wx/dev/plugin.d.ts +7 -0
  27. package/dist/node/plugins/wx/dev/plugin.js +73 -0
  28. package/dist/node/plugins/wx/dev/react-refresh.d.ts +20 -0
  29. package/dist/node/plugins/wx/dev/react-refresh.js +198 -0
  30. package/dist/node/plugins/wx/module.d.ts +45 -0
  31. package/dist/node/plugins/wx/module.js +66 -0
  32. package/dist/node/plugins/wx/native/compile-native-component-interface.d.ts +21 -0
  33. package/dist/node/plugins/wx/native/compile-native-component-interface.js +29 -0
  34. package/dist/node/plugins/wx/native/create-native-component-output.d.ts +15 -0
  35. package/dist/node/plugins/wx/native/create-native-component-output.js +39 -0
  36. package/dist/node/plugins/wx/native/native-component-assets.d.ts +26 -0
  37. package/dist/node/plugins/wx/native/native-component-assets.js +76 -0
  38. package/dist/node/plugins/wx/native/native-component-interface.d.ts +12 -0
  39. package/dist/node/plugins/wx/native/native-component-interface.js +201 -0
  40. package/dist/node/plugins/wx/output/files.d.ts +12 -0
  41. package/dist/node/plugins/wx/output/files.js +12 -0
  42. package/dist/node/plugins/wx/output/json.d.ts +14 -0
  43. package/dist/node/plugins/wx/output/json.js +52 -0
  44. package/dist/node/plugins/wx/output/relative-root.d.ts +2 -0
  45. package/dist/node/plugins/wx/output/relative-root.js +6 -0
  46. package/dist/node/plugins/wx/output/templates.d.ts +7 -0
  47. package/dist/node/plugins/wx/output/templates.js +100 -0
  48. package/dist/node/plugins/wx/placement/placer.d.ts +78 -0
  49. package/dist/node/plugins/wx/placement/placer.js +145 -0
  50. package/dist/node/plugins/wx/placement/plan.d.ts +46 -0
  51. package/dist/node/plugins/wx/placement/plan.js +210 -0
  52. package/dist/node/plugins/wx/plugins.d.ts +4 -0
  53. package/dist/node/plugins/wx/plugins.js +137 -0
  54. package/dist/node/plugins/wx/render/capsule-wrapper.d.ts +3 -0
  55. package/dist/node/plugins/wx/render/capsule-wrapper.js +64 -0
  56. package/dist/node/plugins/wx/render/capsule.d.ts +4 -0
  57. package/dist/node/plugins/wx/render/capsule.js +13 -0
  58. package/dist/node/plugins/wx/render/native.d.ts +9 -0
  59. package/dist/node/plugins/wx/render/native.js +45 -0
  60. package/dist/node/plugins/wx/render/transport.d.ts +17 -0
  61. package/dist/node/plugins/wx/render/transport.js +94 -0
  62. package/dist/node/plugins/wx/resolve/resolver.d.ts +7 -0
  63. package/dist/node/plugins/wx/resolve/resolver.js +86 -0
  64. package/dist/node/plugins/wx/resolve/specialize-bootstrap.d.ts +9 -0
  65. package/dist/node/plugins/wx/resolve/specialize-bootstrap.js +9 -0
  66. package/dist/node/plugins/wx/resolve/specialize-page-capsule.d.ts +9 -0
  67. package/dist/node/plugins/wx/resolve/specialize-page-capsule.js +11 -0
  68. package/dist/node/utils/constant.d.ts +1 -0
  69. package/dist/node/utils/constant.js +1 -0
  70. package/dist/node/utils/memoize.d.ts +122 -0
  71. package/dist/node/utils/memoize.js +86 -0
  72. package/dist/node/utils/modules.d.ts +20 -24
  73. package/dist/node/utils/modules.js +21 -34
  74. package/dist/node/utils/once.d.ts +10 -0
  75. package/dist/node/utils/once.js +20 -0
  76. package/dist/node/utils/packages.d.ts +1 -0
  77. package/dist/node/utils/packages.js +1 -1
  78. package/dist/node/utils/project-config.d.ts +3 -0
  79. package/dist/node/utils/project-config.js +8 -0
  80. package/dist/node/utils/serialized-task-queue.d.ts +9 -0
  81. package/dist/node/utils/serialized-task-queue.js +17 -0
  82. package/dist/node/utils/transform.d.ts +11 -0
  83. package/dist/node/utils/transform.js +58 -0
  84. package/dist/node/vite-plugin.d.ts +1 -1
  85. package/dist/node/vite-plugin.js +11 -27
  86. package/dist/options.d.ts +3 -4
  87. package/dist/runtime/{taro → client/taro}/api.d.ts +0 -1
  88. package/dist/runtime/client/taro/api.js +9 -0
  89. package/dist/runtime/client/taro/component.d.ts +1 -0
  90. package/dist/runtime/client/taro/component.js +1 -0
  91. package/dist/runtime/client/taro/define-native-component.d.ts +7 -0
  92. package/dist/runtime/client/taro/define-native-component.js +4 -0
  93. package/dist/runtime/h5/app.d.ts +2 -0
  94. package/dist/runtime/h5/app.js +15 -0
  95. package/dist/runtime/h5/taro-runtime.d.ts +1 -1
  96. package/dist/runtime/h5/taro-runtime.js +1 -4
  97. package/dist/runtime/wx/amphibious/bootstrap.d.ts +4 -0
  98. package/dist/runtime/wx/amphibious/bootstrap.js +16 -0
  99. package/dist/runtime/wx/amphibious/transport.d.ts +2 -0
  100. package/dist/runtime/wx/amphibious/transport.js +4 -0
  101. package/dist/runtime/wx/capsule/app.d.ts +2 -0
  102. package/dist/runtime/wx/capsule/app.js +7 -0
  103. package/dist/runtime/wx/capsule/component.d.ts +3 -0
  104. package/dist/runtime/wx/capsule/component.js +4 -0
  105. package/dist/runtime/wx/capsule/page.d.ts +3 -0
  106. package/dist/runtime/wx/capsule/page.js +68 -0
  107. package/dist/runtime/wx/capsule/taro-runtime.d.ts +6 -0
  108. package/dist/runtime/wx/capsule/taro-runtime.js +6 -0
  109. package/dist/runtime/wx/dev/dev-runtime.d.ts +1 -0
  110. package/dist/runtime/wx/dev/dev-runtime.js +246 -0
  111. package/dist/runtime/wx/native/app.d.ts +1 -0
  112. package/dist/runtime/wx/native/app.js +3 -0
  113. package/dist/runtime/wx/native/component.d.ts +1 -0
  114. package/dist/runtime/wx/native/component.js +3 -0
  115. package/dist/runtime/wx/native/page.d.ts +1 -0
  116. package/dist/runtime/wx/native/page.js +4 -0
  117. package/dist/runtime/wx/systemjs/system-core.d.ts +4 -0
  118. package/dist/runtime/wx/systemjs/system-core.js +331 -0
  119. package/package.json +21 -14
  120. package/src/node/plugins/client/client-taro.ts +23 -0
  121. package/src/node/plugins/client/constant.ts +5 -0
  122. package/src/node/plugins/{conditional-directives.ts → conditional/conditional-directives.ts} +33 -13
  123. package/src/node/plugins/css/plugins.ts +96 -0
  124. package/src/node/plugins/h5/constant.ts +4 -0
  125. package/src/node/plugins/h5/plugins.ts +197 -0
  126. package/src/node/plugins/h5/resolver/module-resolver.ts +32 -0
  127. package/src/node/plugins/h5/transform-app.ts +90 -0
  128. package/src/node/plugins/wx/dev/dev-host.ts +448 -0
  129. package/src/node/plugins/wx/dev/hmr-files.ts +55 -0
  130. package/src/node/plugins/wx/dev/patch-publisher.ts +49 -0
  131. package/src/node/plugins/wx/dev/plugin.ts +82 -0
  132. package/src/node/plugins/wx/dev/react-refresh.ts +227 -0
  133. package/src/node/plugins/wx/module.ts +97 -0
  134. package/src/node/plugins/wx/native/compile-native-component-interface.ts +47 -0
  135. package/src/node/plugins/wx/native/create-native-component-output.ts +57 -0
  136. package/src/node/plugins/wx/native/native-component-assets.ts +114 -0
  137. package/src/node/plugins/wx/native/native-component-interface.ts +265 -0
  138. package/src/node/plugins/wx/output/files.ts +27 -0
  139. package/src/node/plugins/wx/output/json.ts +79 -0
  140. package/src/node/plugins/wx/output/relative-root.ts +7 -0
  141. package/src/node/plugins/wx/output/templates.ts +141 -0
  142. package/src/node/plugins/wx/placement/placer.ts +172 -0
  143. package/src/node/plugins/wx/placement/plan.ts +306 -0
  144. package/src/node/plugins/wx/plugins.ts +165 -0
  145. package/src/node/plugins/wx/render/capsule-wrapper.ts +86 -0
  146. package/src/node/plugins/wx/render/capsule.ts +21 -0
  147. package/src/node/plugins/wx/render/native.ts +84 -0
  148. package/src/node/plugins/wx/render/transport.ts +157 -0
  149. package/src/node/plugins/wx/resolve/resolver.ts +125 -0
  150. package/src/node/plugins/wx/resolve/specialize-bootstrap.ts +27 -0
  151. package/src/node/plugins/wx/resolve/specialize-page-capsule.ts +29 -0
  152. package/src/node/utils/constant.ts +1 -0
  153. package/src/node/utils/memoize.ts +149 -0
  154. package/src/node/utils/modules.ts +36 -38
  155. package/src/node/utils/once.ts +21 -0
  156. package/src/node/utils/packages.ts +1 -1
  157. package/src/node/utils/project-config.ts +10 -0
  158. package/src/node/utils/serialized-task-queue.ts +20 -0
  159. package/src/node/utils/transform.ts +82 -0
  160. package/src/node/vite-plugin.ts +12 -32
  161. package/src/options.ts +3 -4
  162. package/src/runtime/client/taro/api.ts +11 -0
  163. package/src/runtime/client/taro/component.ts +1 -0
  164. package/src/runtime/client/taro/define-native-component.ts +15 -0
  165. package/src/runtime/h5/app.ts +25 -0
  166. package/src/runtime/h5/taro-runtime.ts +1 -4
  167. package/src/runtime/wx/amphibious/bootstrap.ts +22 -0
  168. package/src/runtime/wx/amphibious/transport.ts +10 -0
  169. package/src/runtime/wx/capsule/app.ts +9 -0
  170. package/src/runtime/wx/capsule/component.ts +6 -0
  171. package/src/runtime/wx/capsule/page.ts +96 -0
  172. package/src/runtime/wx/capsule/taro-runtime.ts +14 -0
  173. package/src/runtime/wx/dev/dev-runtime.ts +317 -0
  174. package/src/runtime/wx/native/app.ts +4 -0
  175. package/src/runtime/wx/native/component.ts +4 -0
  176. package/src/runtime/wx/native/page.ts +6 -0
  177. package/src/runtime/wx/systemjs/LICENSE +10 -0
  178. package/src/runtime/wx/systemjs/system-core.js +370 -0
  179. package/src/runtime/wx/systemjs/system.d.ts +55 -0
  180. package/src/runtime/wx/wechat.d.ts +52 -0
  181. package/README.zh.md +0 -521
  182. package/dist/node/build-context.d.ts +0 -25
  183. package/dist/node/build-context.js +0 -47
  184. package/dist/node/css/css-pipeline.d.ts +0 -35
  185. package/dist/node/css/css-pipeline.js +0 -154
  186. package/dist/node/plugins/conditional-directives.d.ts +0 -3
  187. package/dist/node/plugins/taro-runtime.d.ts +0 -5
  188. package/dist/node/plugins/taro-runtime.js +0 -18
  189. package/dist/node/targets/h5/plugin.d.ts +0 -6
  190. package/dist/node/targets/h5/plugin.js +0 -117
  191. package/dist/node/targets/h5/virtual-modules.d.ts +0 -5
  192. package/dist/node/targets/h5/virtual-modules.js +0 -60
  193. package/dist/node/targets/wx/companion-assets.d.ts +0 -19
  194. package/dist/node/targets/wx/companion-assets.js +0 -129
  195. package/dist/node/targets/wx/dev-server/development-session.d.ts +0 -32
  196. package/dist/node/targets/wx/dev-server/development-session.js +0 -215
  197. package/dist/node/targets/wx/dev-server/full-build-scheduler.d.ts +0 -14
  198. package/dist/node/targets/wx/dev-server/full-build-scheduler.js +0 -60
  199. package/dist/node/targets/wx/dev-server/js-utils.d.ts +0 -5
  200. package/dist/node/targets/wx/dev-server/js-utils.js +0 -28
  201. package/dist/node/targets/wx/dev-server/output.d.ts +0 -19
  202. package/dist/node/targets/wx/dev-server/output.js +0 -44
  203. package/dist/node/targets/wx/dev-server/rolldown-runtime-source.d.ts +0 -8
  204. package/dist/node/targets/wx/dev-server/rolldown-runtime-source.js +0 -95
  205. package/dist/node/targets/wx/dev-server/update-server-state.d.ts +0 -65
  206. package/dist/node/targets/wx/dev-server/update-server-state.js +0 -116
  207. package/dist/node/targets/wx/dev-server/update-transport.d.ts +0 -28
  208. package/dist/node/targets/wx/dev-server/update-transport.js +0 -212
  209. package/dist/node/targets/wx/dev-server/vite-bundled-dev-adapter.d.ts +0 -44
  210. package/dist/node/targets/wx/dev-server/vite-bundled-dev-adapter.js +0 -145
  211. package/dist/node/targets/wx/development-files.d.ts +0 -8
  212. package/dist/node/targets/wx/development-files.js +0 -8
  213. package/dist/node/targets/wx/plugin.d.ts +0 -6
  214. package/dist/node/targets/wx/plugin.js +0 -144
  215. package/dist/node/targets/wx/react-refresh.d.ts +0 -4
  216. package/dist/node/targets/wx/react-refresh.js +0 -38
  217. package/dist/node/targets/wx/virtual-modules.d.ts +0 -16
  218. package/dist/node/targets/wx/virtual-modules.js +0 -120
  219. package/dist/node/utils/async.d.ts +0 -8
  220. package/dist/node/utils/async.js +0 -16
  221. package/dist/node/utils/filesystem.d.ts +0 -13
  222. package/dist/node/utils/filesystem.js +0 -43
  223. package/dist/runtime/taro/api.js +0 -11
  224. package/dist/runtime/taro/components.d.ts +0 -2
  225. package/dist/runtime/taro/components.js +0 -2
  226. package/dist/runtime/wx/page-update.d.ts +0 -6
  227. package/dist/runtime/wx/page-update.js +0 -157
  228. package/dist/runtime/wx/taro-runtime.d.ts +0 -5
  229. package/dist/runtime/wx/taro-runtime.js +0 -6
  230. package/dist/runtime/wx/update-client-state.d.ts +0 -68
  231. package/dist/runtime/wx/update-client-state.js +0 -84
  232. package/dist/runtime/wx/update-client.d.ts +0 -1
  233. package/dist/runtime/wx/update-client.js +0 -171
  234. package/src/node/build-context.ts +0 -62
  235. package/src/node/css/css-pipeline.ts +0 -171
  236. package/src/node/plugins/taro-runtime.ts +0 -22
  237. package/src/node/targets/h5/plugin.ts +0 -135
  238. package/src/node/targets/h5/virtual-modules.ts +0 -71
  239. package/src/node/targets/wx/companion-assets.ts +0 -174
  240. package/src/node/targets/wx/dev-server/development-session.ts +0 -271
  241. package/src/node/targets/wx/dev-server/full-build-scheduler.ts +0 -62
  242. package/src/node/targets/wx/dev-server/js-utils.ts +0 -33
  243. package/src/node/targets/wx/dev-server/output.ts +0 -56
  244. package/src/node/targets/wx/dev-server/rolldown-runtime-source.ts +0 -95
  245. package/src/node/targets/wx/dev-server/update-server-state.ts +0 -183
  246. package/src/node/targets/wx/dev-server/update-transport.ts +0 -261
  247. package/src/node/targets/wx/dev-server/vite-bundled-dev-adapter.ts +0 -203
  248. package/src/node/targets/wx/development-files.ts +0 -11
  249. package/src/node/targets/wx/plugin.ts +0 -164
  250. package/src/node/targets/wx/react-refresh.ts +0 -51
  251. package/src/node/targets/wx/virtual-modules.ts +0 -152
  252. package/src/node/utils/async.ts +0 -19
  253. package/src/node/utils/filesystem.ts +0 -45
  254. package/src/runtime/taro/api.ts +0 -13
  255. package/src/runtime/taro/components.ts +0 -2
  256. package/src/runtime/wx/page-update.ts +0 -230
  257. package/src/runtime/wx/react-refresh.d.ts +0 -20
  258. package/src/runtime/wx/taro-runtime.ts +0 -7
  259. package/src/runtime/wx/update-client-state.ts +0 -138
  260. package/src/runtime/wx/update-client.ts +0 -223
@@ -0,0 +1,370 @@
1
+ // biome-ignore-start lint: vendored SystemJS core
2
+
3
+ /*
4
+ * SystemJS Core
5
+ *
6
+ * Provides
7
+ * - System.import and System.importSync
8
+ * - System.register support for
9
+ * live bindings, function hoisting through circular references,
10
+ * reexports, dynamic import, import.meta.url, top-level await
11
+ * - System.getRegister to get the registration
12
+ * - Symbol.toStringTag support in Module objects
13
+ * - Hookable System.createContext to customize import.meta
14
+ *
15
+ * Core comes with no System.prototype.resolve or
16
+ * System.prototype.instantiate implementations
17
+ */
18
+ var envGlobal = global
19
+ var hasSymbol = typeof Symbol !== 'undefined'
20
+
21
+ function errMsg(errCode, msg) {
22
+ return (msg || '') + ' (SystemJS https://github.com/systemjs/systemjs/blob/main/docs/errors.md#' + errCode + ')'
23
+ }
24
+
25
+ export { REGISTRY, systemJSPrototype }
26
+
27
+ var toStringTag = hasSymbol && Symbol.toStringTag
28
+ var REGISTRY = hasSymbol ? Symbol() : '@'
29
+
30
+ function SystemJS() {
31
+ this[REGISTRY] = {}
32
+ }
33
+
34
+ var systemJSPrototype = SystemJS.prototype
35
+
36
+ systemJSPrototype.import = function (id, parentId, meta) {
37
+ var loader = this
38
+ if (parentId && typeof parentId === 'object') meta = parentId
39
+ var load = getOrCreateLoad(loader, id, undefined, meta)
40
+ return Promise.resolve(load.C || topLevelLoad(loader, load))
41
+ }
42
+
43
+ /**
44
+ * Instantiates, links, and evaluates a graph without yielding the current JavaScript turn.
45
+ *
46
+ * WX placement guarantees that every registration in a synchronous graph uses the main-package transport. Encountering
47
+ * a thenable therefore indicates a fatal placement invariant violation. No rollback is attempted: rows already published
48
+ * to the shared registry remain there and the current runtime heap must not be reused.
49
+ */
50
+ systemJSPrototype.importSync = function (id) {
51
+ var loader = this
52
+ var load = linkLoadSync(loader, id)
53
+ var execution = postOrderExec(loader, load, {})
54
+ if (isThenable(execution)) throw createAsyncGraphError(id)
55
+
56
+ // Share completion and namespace identity with normal System.import calls.
57
+ load.C = load.n
58
+ return load.n
59
+ }
60
+
61
+ // Hookable createContext function -> allowing eg custom import meta
62
+ systemJSPrototype.createContext = function (parentId) {
63
+ return { url: parentId }
64
+ }
65
+
66
+ /** Publishes one synchronous row before linking dependencies so cycles observe the same live namespace. */
67
+ function linkLoadSync(loader, id) {
68
+ var existing = loader[REGISTRY][id]
69
+ if (existing) return existing
70
+
71
+ var registration = loader.instantiate(id)
72
+ if (isThenable(registration)) throw createAsyncGraphError(id)
73
+ if (!registration) throw Error(errMsg(2, id))
74
+
75
+ // This row is intentionally mutable SystemJS-owned linking and execution state.
76
+ var load = {
77
+ id: id,
78
+ i: [],
79
+ n: createModuleNamespace(),
80
+ h: false,
81
+ d: undefined,
82
+ e: undefined,
83
+ C: undefined
84
+ }
85
+ loader[REGISTRY][id] = load
86
+
87
+ var declared = registration[1](
88
+ createExport(load),
89
+ registration[1].length === 2 ? createDeclarationContext(loader, id) : undefined
90
+ )
91
+ load.e = declared.execute || function () {}
92
+ var setters = declared.setters || []
93
+ load.d = registration[0].map(function (dependency, index) {
94
+ var dependencyLoad = linkLoadSync(loader, dependency)
95
+ var setter = setters[index]
96
+ if (setter) {
97
+ dependencyLoad.i.push(setter)
98
+ if (dependencyLoad.h || dependencyLoad.C === dependencyLoad.n) setter(dependencyLoad.n)
99
+ }
100
+ return dependencyLoad
101
+ })
102
+ return load
103
+ }
104
+
105
+ /** Supplies dynamic import and import.meta using the canonical IDs emitted at build time. */
106
+ function createDeclarationContext(loader, id) {
107
+ return {
108
+ import: function (dependency, meta) {
109
+ return loader.import(dependency, undefined, meta)
110
+ },
111
+ meta: loader.createContext(id)
112
+ }
113
+ }
114
+
115
+ /** Creates a live module namespace shared by both completion policies. */
116
+ function createModuleNamespace() {
117
+ var namespace = Object.create(null)
118
+ if (toStringTag) Object.defineProperty(namespace, toStringTag, { value: 'Module' })
119
+ return namespace
120
+ }
121
+
122
+ /** Creates the shared live-binding publisher used by synchronous and asynchronous load records. */
123
+ function createExport(load) {
124
+ return function (name, value) {
125
+ load.h = true
126
+ // This flag coalesces object-form exports into one importer notification pass.
127
+ var changed = false
128
+ if (typeof name === 'string') {
129
+ if (!(name in load.n) || load.n[name] !== value) {
130
+ load.n[name] = value
131
+ changed = true
132
+ }
133
+ } else {
134
+ for (var property in name) {
135
+ var propertyValue = name[property]
136
+ if (!(property in load.n) || load.n[property] !== propertyValue) {
137
+ load.n[property] = propertyValue
138
+ changed = true
139
+ }
140
+ }
141
+ if (name && name.__esModule) load.n.__esModule = name.__esModule
142
+ }
143
+ if (changed) {
144
+ for (var i = 0; i < load.i.length; i++) {
145
+ var setter = load.i[i]
146
+ if (setter) setter(load.n)
147
+ }
148
+ }
149
+ return value
150
+ }
151
+ }
152
+
153
+ /** Accepts cross-realm and custom thenables rather than only native Promises. */
154
+ function isThenable(value) {
155
+ return (
156
+ value !== null && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function'
157
+ )
158
+ }
159
+
160
+ function createAsyncGraphError(id) {
161
+ return Error('Cannot synchronously import ' + id + ': module graph is asynchronous')
162
+ }
163
+
164
+ var lastRegister
165
+ systemJSPrototype.register = function (deps, declare, metas) {
166
+ lastRegister = [deps, declare, metas]
167
+ }
168
+
169
+ /*
170
+ * getRegister provides the last anonymous System.register call
171
+ */
172
+ systemJSPrototype.getRegister = function () {
173
+ var _lastRegister = lastRegister
174
+ lastRegister = undefined
175
+ return _lastRegister
176
+ }
177
+
178
+ export function getOrCreateLoad(loader, id, firstParentUrl, meta) {
179
+ var load = loader[REGISTRY][id]
180
+ if (load) return load
181
+
182
+ var importerSetters = []
183
+ var ns = createModuleNamespace()
184
+
185
+ var instantiatePromise = Promise.resolve()
186
+ .then(function () {
187
+ return loader.instantiate(id, firstParentUrl, meta)
188
+ })
189
+ .then(
190
+ function (registration) {
191
+ if (!registration) throw Error(errMsg(2, id))
192
+ var declared = registration[1](
193
+ createExport(load),
194
+ registration[1].length === 2 ? createDeclarationContext(loader, id) : undefined
195
+ )
196
+ load.e = declared.execute || function () {}
197
+ return [registration[0], declared.setters || [], registration[2] || []]
198
+ },
199
+ function (err) {
200
+ load.e = null
201
+ load.er = err
202
+ throw err
203
+ }
204
+ )
205
+
206
+ var linkPromise = instantiatePromise.then(function (instantiation) {
207
+ return Promise.all(
208
+ instantiation[0].map(function (dep, i) {
209
+ var setter = instantiation[1][i]
210
+ var meta = instantiation[2][i]
211
+ var depLoad = getOrCreateLoad(loader, dep, id, meta)
212
+ // depLoad.I may be undefined for already-evaluated
213
+ return Promise.resolve(depLoad.I).then(function () {
214
+ if (setter) {
215
+ depLoad.i.push(setter)
216
+ // only run early setters when there are hoisted exports of that module
217
+ // the timing works here as pending hoisted export calls will trigger through importerSetters
218
+ if (depLoad.h || !depLoad.I) setter(depLoad.n)
219
+ }
220
+ return depLoad
221
+ })
222
+ })
223
+ ).then(function (depLoads) {
224
+ load.d = depLoads
225
+ })
226
+ })
227
+
228
+ // Capital letter = a promise function
229
+ return (load = loader[REGISTRY][id] =
230
+ {
231
+ id: id,
232
+ // importerSetters, the setters functions registered to this dependency
233
+ // we retain this to add more later
234
+ i: importerSetters,
235
+ // module namespace object
236
+ n: ns,
237
+ // extra module information for import assertion
238
+ // shape like: { assert: { type: 'xyz' } }
239
+ m: meta,
240
+
241
+ // instantiate
242
+ I: instantiatePromise,
243
+ // link
244
+ L: linkPromise,
245
+ // whether it has hoisted exports
246
+ h: false,
247
+
248
+ // On instantiate completion we have populated:
249
+ // dependency load records
250
+ d: undefined,
251
+ // execution function
252
+ e: undefined,
253
+
254
+ // On execution we have populated:
255
+ // the execution error if any
256
+ er: undefined,
257
+ // in the case of TLA, the execution promise
258
+ E: undefined,
259
+
260
+ // On execution, L, I, E cleared
261
+
262
+ // Promise for top-level completion
263
+ C: undefined,
264
+
265
+ // parent instantiator / executor
266
+ p: undefined
267
+ })
268
+ }
269
+
270
+ function instantiateAll(loader, load, parent, loaded) {
271
+ if (!loaded[load.id]) {
272
+ loaded[load.id] = true
273
+ // load.L may be undefined for already-instantiated
274
+ return Promise.resolve(load.L)
275
+ .then(function () {
276
+ if (!load.p || load.p.e === null) load.p = parent
277
+ return Promise.all(
278
+ load.d.map(function (dep) {
279
+ return instantiateAll(loader, dep, parent, loaded)
280
+ })
281
+ )
282
+ })
283
+ .catch(function (err) {
284
+ if (load.er) throw err
285
+ load.e = null
286
+ throw err
287
+ })
288
+ }
289
+ }
290
+
291
+ function topLevelLoad(loader, load) {
292
+ return (load.C = instantiateAll(loader, load, load, {})
293
+ .then(function () {
294
+ return postOrderExec(loader, load, {})
295
+ })
296
+ .then(function () {
297
+ return load.n
298
+ }))
299
+ }
300
+
301
+ // the closest we can get to call(undefined)
302
+ var nullContext = Object.freeze(Object.create(null))
303
+
304
+ // returns a promise if and only if a top-level await subgraph
305
+ // throws on sync errors
306
+ function postOrderExec(loader, load, seen) {
307
+ if (seen[load.id]) return
308
+ seen[load.id] = true
309
+
310
+ if (!load.e) {
311
+ if (load.er) throw load.er
312
+ if (load.E) return load.E
313
+ return
314
+ }
315
+
316
+ // From here we're about to execute the load.
317
+ // Because the execution may be async, we pop the `load.e` first.
318
+ // So `load.e === null` always means the load has been executed or is executing.
319
+ // To inspect the state:
320
+ // - If `load.er` is truthy, the execution has threw or has been rejected;
321
+ // - otherwise, either the `load.E` is a promise, means it's under async execution, or
322
+ // - the `load.E` is null, means the load has completed the execution or has been async resolved.
323
+ var exec = load.e
324
+ load.e = null
325
+
326
+ // deps execute first, unless circular
327
+ var depLoadPromises
328
+ load.d.forEach(function (depLoad) {
329
+ try {
330
+ var depLoadPromise = postOrderExec(loader, depLoad, seen)
331
+ if (depLoadPromise) (depLoadPromises = depLoadPromises || []).push(depLoadPromise)
332
+ } catch (err) {
333
+ load.er = err
334
+ throw err
335
+ }
336
+ })
337
+ if (depLoadPromises) return Promise.all(depLoadPromises).then(doExec)
338
+
339
+ return doExec()
340
+
341
+ function doExec() {
342
+ try {
343
+ var execPromise = exec.call(nullContext)
344
+ if (execPromise) {
345
+ execPromise = execPromise.then(
346
+ function () {
347
+ load.C = load.n
348
+ load.E = null // indicates completion
349
+ },
350
+ function (err) {
351
+ load.er = err
352
+ load.E = null
353
+ throw err
354
+ }
355
+ )
356
+ return (load.E = execPromise)
357
+ }
358
+ // (should be a promise, but a minify optimization to leave out Promise.resolve)
359
+ load.C = load.n
360
+ load.L = load.I = undefined
361
+ } catch (err) {
362
+ load.er = err
363
+ throw err
364
+ }
365
+ }
366
+ }
367
+
368
+ envGlobal.System = new SystemJS()
369
+
370
+ // biome-ignore-end lint: vendored SystemJS core
@@ -0,0 +1,55 @@
1
+ export {}
2
+
3
+ declare global {
4
+ namespace System {
5
+ /** A live SystemJS module namespace. */
6
+ type Module = Readonly<Record<string, unknown>>
7
+
8
+ /** Publishes bindings from a System.register declaration. */
9
+ type Export = (name: string | Readonly<Record<string, unknown>>, value?: unknown) => unknown
10
+
11
+ /** Receives live updates from a dependency namespace. */
12
+ type Setter = (module: Module) => void
13
+
14
+ /** The linker callbacks and evaluator returned by a module declaration. */
15
+ interface Declaration {
16
+ setters?: readonly (Setter | undefined)[]
17
+ execute?: () => void | PromiseLike<void>
18
+ }
19
+
20
+ /** The import.meta object supplied to a module declaration. */
21
+ interface Meta {
22
+ readonly url: string
23
+ readonly [name: string]: unknown
24
+ }
25
+
26
+ /** Runtime operations supplied to a module declaration. */
27
+ interface Context {
28
+ readonly import: (id: string) => Promise<Module>
29
+ readonly meta: Meta
30
+ }
31
+
32
+ /** Declares a module without executing it. */
33
+ type Declare = (exportBinding: Export, context: Context) => Declaration
34
+
35
+ /** The registration captured from one System.register call. */
36
+ type Registration = readonly [dependencies: readonly string[], declare: Declare]
37
+
38
+ /** A hookable SystemJS loader instance. */
39
+ interface Loader {
40
+ /** Creates the import.meta context supplied to a registration declaration. */
41
+ createContext(parentId: string): Meta
42
+
43
+ /** Links and evaluates a graph through the normal asynchronous completion policy. */
44
+ import(id: string): Promise<Module>
45
+
46
+ /**
47
+ * Uses the same registry and evaluator but requires every unresolved registration and execute function in the
48
+ * static closure to complete synchronously. An asynchronous phase throws without rollback and must be treated
49
+ * as a fatal placement invariant violation for the current runtime heap.
50
+ */
51
+ importSync(id: string): Module
52
+ instantiate(id: string): Registration | PromiseLike<Registration>
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The WeChat global. Free-variable reads never resolve its properties (verified: the
3
+ * free lookup is undefined while `global.X` exists), so everything stored here must be
4
+ * accessed as an explicit member expression.
5
+ */
6
+ type WeChatGlobal = {
7
+ /** React DevTools hook installed by the dev runtime; the renderer reads it via `global.`. */
8
+ __REACT_DEVTOOLS_GLOBAL_HOOK__?: unknown
9
+ }
10
+
11
+ /** The App-global Rolldown dev runtime; present only in wx development builds. */
12
+ declare const __rolldown_runtime__:
13
+ | {
14
+ isHotReloading(): boolean
15
+ clearHotReloading(): void
16
+ }
17
+ | undefined
18
+
19
+ // This object is available everywhere, but no globalThis, window on WeChat Mini Program
20
+ declare const global: WeChatGlobal
21
+
22
+ /** Minimal wx.request surface used by the DevRuntime; application API types remain owned by Taro/WeChat packages. */
23
+ type WeChatRequestOptions = Readonly<{
24
+ url: string
25
+ method: 'POST'
26
+ data: unknown
27
+ header: Readonly<Record<string, string>>
28
+ timeout?: number
29
+ success(result: unknown): void
30
+ fail(error: unknown): void
31
+ }>
32
+
33
+ /** Native HTTP request API available in the Mini Program JavaScript environment. */
34
+ declare const wx: {
35
+ request(options: WeChatRequestOptions): void
36
+ }
37
+
38
+ /** Registers the native WeChat Mini Program application. */
39
+ declare function App(options: object): void
40
+
41
+ /** Registers a native WeChat Mini Program page. */
42
+ declare function Page(options: object): void
43
+
44
+ /** Registers a native WeChat Mini Program component. */
45
+ declare function Component(options: object): void
46
+
47
+ /**
48
+ * Returns the native WeChat Mini Program application instance.
49
+ * Only available after App() is called.
50
+ * https://developers.weixin.qq.com/miniprogram/dev/reference/api/getApp.html
51
+ */
52
+ declare function getApp(options: object): { globalData: unknown }