@noodleseed/one 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/dist/cli.js +5 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/shared.d.ts +1 -1
  4. package/dist/commands/shared.d.ts.map +1 -1
  5. package/dist/commands/shared.js +2 -2
  6. package/dist/commands/shared.js.map +1 -1
  7. package/dist/react-widget-build.js +20 -1
  8. package/dist/react-widget-build.js.map +1 -1
  9. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.d.ts.map +1 -1
  10. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js +1 -0
  11. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js.map +1 -1
  12. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.d.ts.map +1 -1
  13. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +1 -0
  14. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js.map +1 -1
  15. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  16. package/package.json +2 -20
  17. package/node_modules/@oxc-project/types/LICENSE +0 -22
  18. package/node_modules/@oxc-project/types/README.md +0 -3
  19. package/node_modules/@oxc-project/types/package.json +0 -26
  20. package/node_modules/@oxc-project/types/types.d.ts +0 -1912
  21. package/node_modules/@rolldown/binding-linux-x64-gnu/README.md +0 -3
  22. package/node_modules/@rolldown/binding-linux-x64-gnu/package.json +0 -40
  23. package/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
  24. package/node_modules/@rolldown/pluginutils/LICENSE +0 -21
  25. package/node_modules/@rolldown/pluginutils/README.md +0 -145
  26. package/node_modules/@rolldown/pluginutils/dist/filter/index.d.mts +0 -194
  27. package/node_modules/@rolldown/pluginutils/dist/filter/index.mjs +0 -2
  28. package/node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs +0 -323
  29. package/node_modules/@rolldown/pluginutils/dist/index.d.mts +0 -2
  30. package/node_modules/@rolldown/pluginutils/dist/index.mjs +0 -2
  31. package/node_modules/@rolldown/pluginutils/package.json +0 -40
  32. package/node_modules/@vitejs/plugin-react/LICENSE +0 -21
  33. package/node_modules/@vitejs/plugin-react/README.md +0 -169
  34. package/node_modules/@vitejs/plugin-react/dist/index.d.ts +0 -48
  35. package/node_modules/@vitejs/plugin-react/dist/index.js +0 -200
  36. package/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js +0 -663
  37. package/node_modules/@vitejs/plugin-react/package.json +0 -87
  38. package/node_modules/@vitejs/plugin-react/types/optionalTypes.d.ts +0 -12
  39. package/node_modules/@vitejs/plugin-react/types/preamble.d.ts +0 -1
  40. package/node_modules/detect-libc/LICENSE +0 -201
  41. package/node_modules/detect-libc/README.md +0 -163
  42. package/node_modules/detect-libc/index.d.ts +0 -14
  43. package/node_modules/detect-libc/lib/detect-libc.js +0 -313
  44. package/node_modules/detect-libc/lib/elf.js +0 -39
  45. package/node_modules/detect-libc/lib/filesystem.js +0 -51
  46. package/node_modules/detect-libc/lib/process.js +0 -24
  47. package/node_modules/detect-libc/package.json +0 -44
  48. package/node_modules/fdir/LICENSE +0 -7
  49. package/node_modules/fdir/README.md +0 -91
  50. package/node_modules/fdir/dist/index.cjs +0 -588
  51. package/node_modules/fdir/dist/index.d.cts +0 -155
  52. package/node_modules/fdir/dist/index.d.mts +0 -155
  53. package/node_modules/fdir/dist/index.mjs +0 -570
  54. package/node_modules/fdir/package.json +0 -103
  55. package/node_modules/lightningcss/LICENSE +0 -373
  56. package/node_modules/lightningcss/README.md +0 -105
  57. package/node_modules/lightningcss/node/ast.d.ts +0 -9892
  58. package/node_modules/lightningcss/node/ast.js.flow +0 -10539
  59. package/node_modules/lightningcss/node/browserslistToTargets.js +0 -48
  60. package/node_modules/lightningcss/node/composeVisitors.js +0 -450
  61. package/node_modules/lightningcss/node/flags.js +0 -28
  62. package/node_modules/lightningcss/node/index.d.ts +0 -494
  63. package/node_modules/lightningcss/node/index.js +0 -59
  64. package/node_modules/lightningcss/node/index.js.flow +0 -843
  65. package/node_modules/lightningcss/node/index.mjs +0 -4
  66. package/node_modules/lightningcss/node/targets.d.ts +0 -40
  67. package/node_modules/lightningcss/node/targets.js.flow +0 -39
  68. package/node_modules/lightningcss/package.json +0 -110
  69. package/node_modules/lightningcss-linux-x64-gnu/LICENSE +0 -373
  70. package/node_modules/lightningcss-linux-x64-gnu/README.md +0 -1
  71. package/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node +0 -0
  72. package/node_modules/lightningcss-linux-x64-gnu/package.json +0 -37
  73. package/node_modules/nanoid/.claude/settings.local.json +0 -14
  74. package/node_modules/nanoid/LICENSE +0 -20
  75. package/node_modules/nanoid/README.md +0 -39
  76. package/node_modules/nanoid/async/index.browser.cjs +0 -69
  77. package/node_modules/nanoid/async/index.browser.js +0 -34
  78. package/node_modules/nanoid/async/index.cjs +0 -71
  79. package/node_modules/nanoid/async/index.d.ts +0 -56
  80. package/node_modules/nanoid/async/index.js +0 -35
  81. package/node_modules/nanoid/async/index.native.js +0 -26
  82. package/node_modules/nanoid/async/package.json +0 -12
  83. package/node_modules/nanoid/bin/nanoid.cjs +0 -55
  84. package/node_modules/nanoid/index.browser.cjs +0 -72
  85. package/node_modules/nanoid/index.browser.js +0 -34
  86. package/node_modules/nanoid/index.cjs +0 -86
  87. package/node_modules/nanoid/index.d.cts +0 -91
  88. package/node_modules/nanoid/index.d.ts +0 -91
  89. package/node_modules/nanoid/index.js +0 -46
  90. package/node_modules/nanoid/nanoid.js +0 -1
  91. package/node_modules/nanoid/non-secure/index.cjs +0 -34
  92. package/node_modules/nanoid/non-secure/index.d.ts +0 -33
  93. package/node_modules/nanoid/non-secure/index.js +0 -21
  94. package/node_modules/nanoid/non-secure/package.json +0 -6
  95. package/node_modules/nanoid/package.json +0 -89
  96. package/node_modules/nanoid/url-alphabet/index.cjs +0 -7
  97. package/node_modules/nanoid/url-alphabet/index.js +0 -3
  98. package/node_modules/nanoid/url-alphabet/package.json +0 -6
  99. package/node_modules/picocolors/LICENSE +0 -15
  100. package/node_modules/picocolors/README.md +0 -21
  101. package/node_modules/picocolors/package.json +0 -25
  102. package/node_modules/picocolors/picocolors.browser.js +0 -4
  103. package/node_modules/picocolors/picocolors.d.ts +0 -5
  104. package/node_modules/picocolors/picocolors.js +0 -75
  105. package/node_modules/picocolors/types.d.ts +0 -51
  106. package/node_modules/picomatch/LICENSE +0 -21
  107. package/node_modules/picomatch/README.md +0 -749
  108. package/node_modules/picomatch/index.js +0 -17
  109. package/node_modules/picomatch/lib/constants.js +0 -184
  110. package/node_modules/picomatch/lib/parse.js +0 -1386
  111. package/node_modules/picomatch/lib/picomatch.js +0 -349
  112. package/node_modules/picomatch/lib/scan.js +0 -391
  113. package/node_modules/picomatch/lib/utils.js +0 -72
  114. package/node_modules/picomatch/package.json +0 -82
  115. package/node_modules/picomatch/posix.js +0 -3
  116. package/node_modules/postcss/LICENSE +0 -20
  117. package/node_modules/postcss/README.md +0 -28
  118. package/node_modules/postcss/lib/at-rule.d.ts +0 -139
  119. package/node_modules/postcss/lib/at-rule.js +0 -25
  120. package/node_modules/postcss/lib/comment.d.ts +0 -67
  121. package/node_modules/postcss/lib/comment.js +0 -13
  122. package/node_modules/postcss/lib/container.d.ts +0 -478
  123. package/node_modules/postcss/lib/container.js +0 -447
  124. package/node_modules/postcss/lib/css-syntax-error.d.ts +0 -247
  125. package/node_modules/postcss/lib/css-syntax-error.js +0 -133
  126. package/node_modules/postcss/lib/declaration.d.ts +0 -150
  127. package/node_modules/postcss/lib/declaration.js +0 -24
  128. package/node_modules/postcss/lib/document.d.ts +0 -68
  129. package/node_modules/postcss/lib/document.js +0 -33
  130. package/node_modules/postcss/lib/fromJSON.d.ts +0 -9
  131. package/node_modules/postcss/lib/fromJSON.js +0 -54
  132. package/node_modules/postcss/lib/input.d.ts +0 -226
  133. package/node_modules/postcss/lib/input.js +0 -273
  134. package/node_modules/postcss/lib/lazy-result.d.ts +0 -189
  135. package/node_modules/postcss/lib/lazy-result.js +0 -563
  136. package/node_modules/postcss/lib/list.d.ts +0 -60
  137. package/node_modules/postcss/lib/list.js +0 -58
  138. package/node_modules/postcss/lib/map-generator.js +0 -376
  139. package/node_modules/postcss/lib/no-work-result.d.ts +0 -45
  140. package/node_modules/postcss/lib/no-work-result.js +0 -137
  141. package/node_modules/postcss/lib/node.d.ts +0 -555
  142. package/node_modules/postcss/lib/node.js +0 -449
  143. package/node_modules/postcss/lib/parse.d.ts +0 -9
  144. package/node_modules/postcss/lib/parse.js +0 -42
  145. package/node_modules/postcss/lib/parser.js +0 -618
  146. package/node_modules/postcss/lib/postcss.d.mts +0 -66
  147. package/node_modules/postcss/lib/postcss.d.ts +0 -461
  148. package/node_modules/postcss/lib/postcss.js +0 -101
  149. package/node_modules/postcss/lib/postcss.mjs +0 -30
  150. package/node_modules/postcss/lib/previous-map.d.ts +0 -80
  151. package/node_modules/postcss/lib/previous-map.js +0 -161
  152. package/node_modules/postcss/lib/processor.d.ts +0 -114
  153. package/node_modules/postcss/lib/processor.js +0 -67
  154. package/node_modules/postcss/lib/result.d.ts +0 -204
  155. package/node_modules/postcss/lib/result.js +0 -42
  156. package/node_modules/postcss/lib/root.d.ts +0 -86
  157. package/node_modules/postcss/lib/root.js +0 -61
  158. package/node_modules/postcss/lib/rule.d.ts +0 -126
  159. package/node_modules/postcss/lib/rule.js +0 -27
  160. package/node_modules/postcss/lib/stringifier.d.ts +0 -45
  161. package/node_modules/postcss/lib/stringifier.js +0 -374
  162. package/node_modules/postcss/lib/stringify.d.ts +0 -9
  163. package/node_modules/postcss/lib/stringify.js +0 -11
  164. package/node_modules/postcss/lib/symbols.js +0 -5
  165. package/node_modules/postcss/lib/terminal-highlight.js +0 -70
  166. package/node_modules/postcss/lib/tokenize.js +0 -270
  167. package/node_modules/postcss/lib/warn-once.js +0 -13
  168. package/node_modules/postcss/lib/warning.d.ts +0 -146
  169. package/node_modules/postcss/lib/warning.js +0 -37
  170. package/node_modules/postcss/package.json +0 -88
  171. package/node_modules/rolldown/LICENSE +0 -25
  172. package/node_modules/rolldown/README.md +0 -11
  173. package/node_modules/rolldown/bin/cli.mjs +0 -2
  174. package/node_modules/rolldown/dist/cli.d.mts +0 -1
  175. package/node_modules/rolldown/dist/cli.mjs +0 -1202
  176. package/node_modules/rolldown/dist/config.d.mts +0 -14
  177. package/node_modules/rolldown/dist/config.mjs +0 -4
  178. package/node_modules/rolldown/dist/experimental-index.d.mts +0 -280
  179. package/node_modules/rolldown/dist/experimental-index.mjs +0 -330
  180. package/node_modules/rolldown/dist/experimental-runtime-types.d.ts +0 -107
  181. package/node_modules/rolldown/dist/filter-index.d.mts +0 -195
  182. package/node_modules/rolldown/dist/filter-index.mjs +0 -380
  183. package/node_modules/rolldown/dist/get-log-filter.d.mts +0 -3
  184. package/node_modules/rolldown/dist/get-log-filter.mjs +0 -68
  185. package/node_modules/rolldown/dist/index.d.mts +0 -4
  186. package/node_modules/rolldown/dist/index.mjs +0 -50
  187. package/node_modules/rolldown/dist/parallel-plugin-worker.d.mts +0 -1
  188. package/node_modules/rolldown/dist/parallel-plugin-worker.mjs +0 -28
  189. package/node_modules/rolldown/dist/parallel-plugin.d.mts +0 -13
  190. package/node_modules/rolldown/dist/parallel-plugin.mjs +0 -6
  191. package/node_modules/rolldown/dist/parse-ast-index.d.mts +0 -32
  192. package/node_modules/rolldown/dist/parse-ast-index.mjs +0 -60
  193. package/node_modules/rolldown/dist/plugins-index.d.mts +0 -33
  194. package/node_modules/rolldown/dist/plugins-index.mjs +0 -40
  195. package/node_modules/rolldown/dist/shared/binding-B1q9aYT-.d.mts +0 -1947
  196. package/node_modules/rolldown/dist/shared/binding-Dh6LYCIB.mjs +0 -589
  197. package/node_modules/rolldown/dist/shared/bindingify-input-options-CzVhGygm.mjs +0 -2240
  198. package/node_modules/rolldown/dist/shared/constructors-688OwP2q.mjs +0 -65
  199. package/node_modules/rolldown/dist/shared/constructors-awZ1VNvg.d.mts +0 -36
  200. package/node_modules/rolldown/dist/shared/define-config-Demdg3_4.mjs +0 -6
  201. package/node_modules/rolldown/dist/shared/define-config-sxBscJ3M.d.mts +0 -3901
  202. package/node_modules/rolldown/dist/shared/error-B68YLzl3.mjs +0 -85
  203. package/node_modules/rolldown/dist/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
  204. package/node_modules/rolldown/dist/shared/load-config-BvPPEM7l.mjs +0 -120
  205. package/node_modules/rolldown/dist/shared/logging-BSNejiLS.d.mts +0 -50
  206. package/node_modules/rolldown/dist/shared/logs-aMKUxRpj.mjs +0 -180
  207. package/node_modules/rolldown/dist/shared/misc-CoQm4NHO.mjs +0 -21
  208. package/node_modules/rolldown/dist/shared/normalize-string-or-regex-BpXHYeN4.mjs +0 -68
  209. package/node_modules/rolldown/dist/shared/parse-CTgsjpo8.mjs +0 -74
  210. package/node_modules/rolldown/dist/shared/prompt-B1Yc1NPt.mjs +0 -847
  211. package/node_modules/rolldown/dist/shared/resolve-tsconfig-BkhP9bkX.mjs +0 -124
  212. package/node_modules/rolldown/dist/shared/rolldown-Brph2NSU.mjs +0 -40
  213. package/node_modules/rolldown/dist/shared/rolldown-build-DR0wzp0V.mjs +0 -3264
  214. package/node_modules/rolldown/dist/shared/transform-CEmFsvJW.d.mts +0 -149
  215. package/node_modules/rolldown/dist/shared/watch-FrHSqg24.mjs +0 -374
  216. package/node_modules/rolldown/dist/utils-index.d.mts +0 -376
  217. package/node_modules/rolldown/dist/utils-index.mjs +0 -2414
  218. package/node_modules/rolldown/package.json +0 -153
  219. package/node_modules/source-map-js/LICENSE +0 -28
  220. package/node_modules/source-map-js/README.md +0 -765
  221. package/node_modules/source-map-js/lib/array-set.js +0 -121
  222. package/node_modules/source-map-js/lib/base64-vlq.js +0 -140
  223. package/node_modules/source-map-js/lib/base64.js +0 -67
  224. package/node_modules/source-map-js/lib/binary-search.js +0 -111
  225. package/node_modules/source-map-js/lib/mapping-list.js +0 -79
  226. package/node_modules/source-map-js/lib/quick-sort.js +0 -132
  227. package/node_modules/source-map-js/lib/source-map-consumer.d.ts +0 -1
  228. package/node_modules/source-map-js/lib/source-map-consumer.js +0 -1188
  229. package/node_modules/source-map-js/lib/source-map-generator.d.ts +0 -1
  230. package/node_modules/source-map-js/lib/source-map-generator.js +0 -444
  231. package/node_modules/source-map-js/lib/source-node.d.ts +0 -1
  232. package/node_modules/source-map-js/lib/source-node.js +0 -413
  233. package/node_modules/source-map-js/lib/util.js +0 -594
  234. package/node_modules/source-map-js/package.json +0 -71
  235. package/node_modules/source-map-js/source-map.d.ts +0 -104
  236. package/node_modules/source-map-js/source-map.js +0 -8
  237. package/node_modules/tinyglobby/LICENSE +0 -21
  238. package/node_modules/tinyglobby/README.md +0 -25
  239. package/node_modules/tinyglobby/dist/index.cjs +0 -335
  240. package/node_modules/tinyglobby/dist/index.d.cts +0 -148
  241. package/node_modules/tinyglobby/dist/index.d.mts +0 -148
  242. package/node_modules/tinyglobby/dist/index.mjs +0 -307
  243. package/node_modules/tinyglobby/package.json +0 -70
  244. package/node_modules/vite/LICENSE.md +0 -2287
  245. package/node_modules/vite/README.md +0 -20
  246. package/node_modules/vite/bin/openChrome.js +0 -68
  247. package/node_modules/vite/bin/vite.js +0 -79
  248. package/node_modules/vite/client.d.ts +0 -285
  249. package/node_modules/vite/dist/client/client.mjs +0 -1269
  250. package/node_modules/vite/dist/client/env.mjs +0 -18
  251. package/node_modules/vite/dist/node/chunks/build.js +0 -5371
  252. package/node_modules/vite/dist/node/chunks/dist.js +0 -6784
  253. package/node_modules/vite/dist/node/chunks/lib.js +0 -371
  254. package/node_modules/vite/dist/node/chunks/logger.js +0 -364
  255. package/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +0 -96
  256. package/node_modules/vite/dist/node/chunks/node.js +0 -35770
  257. package/node_modules/vite/dist/node/chunks/postcss-import.js +0 -467
  258. package/node_modules/vite/dist/node/cli.js +0 -836
  259. package/node_modules/vite/dist/node/index.d.ts +0 -4010
  260. package/node_modules/vite/dist/node/index.js +0 -3
  261. package/node_modules/vite/dist/node/internal.d.ts +0 -2
  262. package/node_modules/vite/dist/node/internal.js +0 -2
  263. package/node_modules/vite/dist/node/module-runner.d.ts +0 -314
  264. package/node_modules/vite/dist/node/module-runner.js +0 -1274
  265. package/node_modules/vite/misc/false.js +0 -1
  266. package/node_modules/vite/misc/true.js +0 -1
  267. package/node_modules/vite/package.json +0 -194
  268. package/node_modules/vite/types/customEvent.d.ts +0 -79
  269. package/node_modules/vite/types/hmrPayload.d.ts +0 -80
  270. package/node_modules/vite/types/hot.d.ts +0 -39
  271. package/node_modules/vite/types/import-meta.d.ts +0 -5
  272. package/node_modules/vite/types/importGlob.d.ts +0 -131
  273. package/node_modules/vite/types/importMeta.d.ts +0 -30
  274. package/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts +0 -44
  275. package/node_modules/vite/types/internal/esbuildOptions.d.ts +0 -28
  276. package/node_modules/vite/types/internal/lightningcssOptions.d.ts +0 -18
  277. package/node_modules/vite/types/internal/rollupTypeCompat.d.ts +0 -24
  278. package/node_modules/vite/types/internal/terserOptions.d.ts +0 -11
  279. package/node_modules/vite/types/metadata.d.ts +0 -47
@@ -1,2240 +0,0 @@
1
- import { n as __toESM, t as require_binding } from "./binding-Dh6LYCIB.mjs";
2
- import { a as logInvalidLogPosition, c as logPluginError, n as error, r as logCycleLoading, t as augmentCodeLocation } from "./logs-aMKUxRpj.mjs";
3
- import { i as bindingifyManifestPlugin, n as BuiltinPlugin, r as bindingifyBuiltInPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-BpXHYeN4.mjs";
4
- import { a as unreachable, o as unsupported, r as noop, t as arraify } from "./misc-CoQm4NHO.mjs";
5
- import { a as bindingifySourcemap, i as unwrapBindingResult, t as aggregateBindingErrorsIntoJsError } from "./error-B68YLzl3.mjs";
6
- import { parseAst } from "../parse-ast-index.mjs";
7
- import path from "node:path";
8
- import * as filter from "@rolldown/pluginutils";
9
- import fsp from "node:fs/promises";
10
- //#region package.json
11
- var version = "1.1.3";
12
- var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
13
- //#endregion
14
- //#region src/constants/version.ts
15
- /**
16
- * The version of Rolldown.
17
- * @example `'1.0.0'`
18
- *
19
- * @category Plugin APIs
20
- */
21
- const VERSION = version;
22
- //#endregion
23
- //#region src/constants/index.ts
24
- /**
25
- * Runtime helper module ID
26
- */
27
- const RUNTIME_MODULE_ID = "\0rolldown/runtime.js";
28
- //#endregion
29
- //#region src/log/logging.ts
30
- const LOG_LEVEL_SILENT = "silent";
31
- const LOG_LEVEL_ERROR = "error";
32
- const LOG_LEVEL_WARN = "warn";
33
- const LOG_LEVEL_INFO = "info";
34
- const LOG_LEVEL_DEBUG = "debug";
35
- const logLevelPriority = {
36
- [LOG_LEVEL_DEBUG]: 0,
37
- [LOG_LEVEL_INFO]: 1,
38
- [LOG_LEVEL_WARN]: 2,
39
- [LOG_LEVEL_SILENT]: 3
40
- };
41
- //#endregion
42
- //#region src/log/log-handler.ts
43
- const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
44
- function getLogHandler(level, code, logger, pluginName, logLevel) {
45
- if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
46
- return (log, pos) => {
47
- if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
48
- log = normalizeLog(log);
49
- if (log.code && !log.pluginCode) log.pluginCode = log.code;
50
- log.code = code;
51
- log.plugin = pluginName;
52
- logger(level, log);
53
- };
54
- }
55
- //#endregion
56
- //#region src/utils/normalize-hook.ts
57
- function normalizeHook(hook) {
58
- if (typeof hook === "function" || typeof hook === "string") return {
59
- handler: hook,
60
- options: {},
61
- meta: {}
62
- };
63
- if (typeof hook === "object" && hook !== null) {
64
- const { handler, order, ...options } = hook;
65
- return {
66
- handler,
67
- options,
68
- meta: { order }
69
- };
70
- }
71
- unreachable("Invalid hook type");
72
- }
73
- //#endregion
74
- //#region src/plugin/minimal-plugin-context.ts
75
- var MinimalPluginContextImpl = class {
76
- pluginName;
77
- hookName;
78
- info;
79
- warn;
80
- debug;
81
- meta;
82
- constructor(onLog, logLevel, pluginName, watchMode, hookName) {
83
- this.pluginName = pluginName;
84
- this.hookName = hookName;
85
- this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
86
- this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
87
- this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
88
- this.meta = {
89
- rollupVersion: "4.23.0",
90
- rolldownVersion: VERSION,
91
- watchMode
92
- };
93
- }
94
- error(e) {
95
- return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
96
- }
97
- };
98
- //#endregion
99
- //#region src/types/plain-object-like.ts
100
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
101
- const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
102
- /**
103
- * Base class for classes that use `@lazyProp` decorated properties.
104
- *
105
- * **Design Pattern in Rolldown:**
106
- * This is a common pattern in Rolldown due to its three-layer architecture:
107
- * TypeScript API → NAPI Bindings → Rust Core
108
- *
109
- * **Why we use getters:**
110
- * For performance - to lazily fetch data from Rust bindings only when needed,
111
- * rather than eagerly fetching all data during object construction.
112
- *
113
- * **The problem:**
114
- * Getters defined on class prototypes are non-enumerable by default, which breaks:
115
- * - Object spread operators ({...obj})
116
- * - Object.keys() and similar methods
117
- * - Standard JavaScript object semantics
118
- *
119
- * **The solution:**
120
- * This base class automatically converts `@lazyProp` decorated getters into
121
- * own enumerable getters on each instance during construction.
122
- *
123
- * **Result:**
124
- * Objects get both lazy-loading performance benefits AND plain JavaScript object behavior.
125
- *
126
- * @example
127
- * ```typescript
128
- * class MyClass extends PlainObjectLike {
129
- * @lazyProp
130
- * get myProp() {
131
- * return fetchFromRustBinding();
132
- * }
133
- * }
134
- * ```
135
- */
136
- var PlainObjectLike = class {
137
- constructor() {
138
- setupLazyProperties(this);
139
- }
140
- };
141
- /**
142
- * Set up lazy properties as own getters on an instance.
143
- * This is called automatically by the `PlainObjectLike` base class constructor.
144
- *
145
- * @param instance - The instance to set up lazy properties on
146
- * @internal
147
- */
148
- function setupLazyProperties(instance) {
149
- const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
150
- if (!lazyFields) return;
151
- for (const [propertyKey, originalGetter] of lazyFields.entries()) {
152
- let cachedValue;
153
- let hasValue = false;
154
- Object.defineProperty(instance, propertyKey, {
155
- get() {
156
- if (!hasValue) {
157
- cachedValue = originalGetter.call(this);
158
- hasValue = true;
159
- }
160
- return cachedValue;
161
- },
162
- enumerable: true,
163
- configurable: true
164
- });
165
- }
166
- }
167
- /**
168
- * Get all lazy field names from a class instance.
169
- *
170
- * @param instance - Instance to inspect
171
- * @returns Set of lazy property names
172
- */
173
- function getLazyFields(instance) {
174
- const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
175
- return lazyFields ? new Set(lazyFields.keys()) : /* @__PURE__ */ new Set();
176
- }
177
- //#endregion
178
- //#region src/decorators/lazy.ts
179
- /**
180
- * Decorator that marks a getter as lazy-evaluated and cached.
181
- *
182
- * **What "lazy" means here:**
183
- * 1. Data is lazily fetched from Rust bindings only when the property is accessed (not eagerly on construction)
184
- * 2. Once fetched, the data is cached for subsequent accesses (performance optimization)
185
- * 3. Despite being a getter, it behaves like a plain object property (enumerable, appears in Object.keys())
186
- *
187
- * **Important**: Properties decorated with `@lazyProp` are defined as own enumerable
188
- * properties on each instance (not on the prototype). This ensures they:
189
- * - Appear in Object.keys() and Object.getOwnPropertyNames()
190
- * - Are included in object spreads ({...obj})
191
- * - Are enumerable in for...in loops
192
- *
193
- * Classes using this decorator must extend `PlainObjectLike` base class.
194
- *
195
- * @example
196
- * ```typescript
197
- * class MyClass extends PlainObjectLike {
198
- * @lazyProp
199
- * get expensiveValue() {
200
- * return someExpensiveComputation();
201
- * }
202
- * }
203
- * ```
204
- */
205
- function lazyProp(target, propertyKey, descriptor) {
206
- if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Map();
207
- const originalGetter = descriptor.get;
208
- target.constructor[LAZY_FIELDS_KEY].set(propertyKey, originalGetter);
209
- return {
210
- enumerable: false,
211
- configurable: true
212
- };
213
- }
214
- //#endregion
215
- //#region src/utils/asset-source.ts
216
- function transformAssetSource(bindingAssetSource) {
217
- return bindingAssetSource.inner;
218
- }
219
- function bindingAssetSource(source) {
220
- return { inner: source };
221
- }
222
- //#endregion
223
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
224
- function __decorate(decorators, target, key, desc) {
225
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
226
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
227
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
228
- return c > 3 && r && Object.defineProperty(target, key, r), r;
229
- }
230
- //#endregion
231
- //#region src/types/output-asset-impl.ts
232
- var OutputAssetImpl = class extends PlainObjectLike {
233
- bindingAsset;
234
- type = "asset";
235
- constructor(bindingAsset) {
236
- super();
237
- this.bindingAsset = bindingAsset;
238
- }
239
- get fileName() {
240
- return this.bindingAsset.getFileName();
241
- }
242
- get originalFileName() {
243
- return this.bindingAsset.getOriginalFileName() || null;
244
- }
245
- get originalFileNames() {
246
- return this.bindingAsset.getOriginalFileNames();
247
- }
248
- get name() {
249
- return this.bindingAsset.getName() ?? void 0;
250
- }
251
- get names() {
252
- return this.bindingAsset.getNames();
253
- }
254
- get source() {
255
- return transformAssetSource(this.bindingAsset.getSource());
256
- }
257
- __rolldown_external_memory_handle__(keepDataAlive) {
258
- if (keepDataAlive) this.#evaluateAllLazyFields();
259
- return this.bindingAsset.dropInner();
260
- }
261
- #evaluateAllLazyFields() {
262
- for (const field of getLazyFields(this)) this[field];
263
- }
264
- };
265
- __decorate([lazyProp], OutputAssetImpl.prototype, "fileName", null);
266
- __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileName", null);
267
- __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileNames", null);
268
- __decorate([lazyProp], OutputAssetImpl.prototype, "name", null);
269
- __decorate([lazyProp], OutputAssetImpl.prototype, "names", null);
270
- __decorate([lazyProp], OutputAssetImpl.prototype, "source", null);
271
- //#endregion
272
- //#region src/utils/transform-rendered-module.ts
273
- function transformToRenderedModule(bindingRenderedModule) {
274
- return {
275
- get code() {
276
- return bindingRenderedModule.code;
277
- },
278
- get renderedLength() {
279
- return bindingRenderedModule.code?.length || 0;
280
- },
281
- get renderedExports() {
282
- return bindingRenderedModule.renderedExports;
283
- }
284
- };
285
- }
286
- //#endregion
287
- //#region src/utils/transform-rendered-chunk.ts
288
- function transformRenderedChunk(chunk) {
289
- let modules = null;
290
- return {
291
- type: "chunk",
292
- get name() {
293
- return chunk.name;
294
- },
295
- get isEntry() {
296
- return chunk.isEntry;
297
- },
298
- get isDynamicEntry() {
299
- return chunk.isDynamicEntry;
300
- },
301
- get facadeModuleId() {
302
- return chunk.facadeModuleId;
303
- },
304
- get moduleIds() {
305
- return chunk.moduleIds;
306
- },
307
- get exports() {
308
- return chunk.exports;
309
- },
310
- get fileName() {
311
- return chunk.fileName;
312
- },
313
- get imports() {
314
- return chunk.imports;
315
- },
316
- get dynamicImports() {
317
- return chunk.dynamicImports;
318
- },
319
- get modules() {
320
- if (!modules) modules = transformChunkModules(chunk.modules);
321
- return modules;
322
- }
323
- };
324
- }
325
- function transformChunkModules(modules) {
326
- const result = {};
327
- for (let i = 0; i < modules.values.length; i++) {
328
- let key = modules.keys[i];
329
- const mod = modules.values[i];
330
- result[key] = transformToRenderedModule(mod);
331
- }
332
- return result;
333
- }
334
- //#endregion
335
- //#region src/types/output-chunk-impl.ts
336
- var OutputChunkImpl = class extends PlainObjectLike {
337
- bindingChunk;
338
- type = "chunk";
339
- constructor(bindingChunk) {
340
- super();
341
- this.bindingChunk = bindingChunk;
342
- }
343
- get fileName() {
344
- return this.bindingChunk.getFileName();
345
- }
346
- get name() {
347
- return this.bindingChunk.getName();
348
- }
349
- get exports() {
350
- return this.bindingChunk.getExports();
351
- }
352
- get isEntry() {
353
- return this.bindingChunk.getIsEntry();
354
- }
355
- get facadeModuleId() {
356
- return this.bindingChunk.getFacadeModuleId() || null;
357
- }
358
- get isDynamicEntry() {
359
- return this.bindingChunk.getIsDynamicEntry();
360
- }
361
- get sourcemapFileName() {
362
- return this.bindingChunk.getSourcemapFileName() || null;
363
- }
364
- get preliminaryFileName() {
365
- return this.bindingChunk.getPreliminaryFileName();
366
- }
367
- get code() {
368
- return this.bindingChunk.getCode();
369
- }
370
- get modules() {
371
- return transformChunkModules(this.bindingChunk.getModules());
372
- }
373
- get imports() {
374
- return this.bindingChunk.getImports();
375
- }
376
- get dynamicImports() {
377
- return this.bindingChunk.getDynamicImports();
378
- }
379
- get moduleIds() {
380
- return this.bindingChunk.getModuleIds();
381
- }
382
- get map() {
383
- const mapString = this.bindingChunk.getMap();
384
- return mapString ? transformToRollupSourceMap(mapString) : null;
385
- }
386
- __rolldown_external_memory_handle__(keepDataAlive) {
387
- if (keepDataAlive) this.#evaluateAllLazyFields();
388
- return this.bindingChunk.dropInner();
389
- }
390
- #evaluateAllLazyFields() {
391
- for (const field of getLazyFields(this)) this[field];
392
- }
393
- };
394
- __decorate([lazyProp], OutputChunkImpl.prototype, "fileName", null);
395
- __decorate([lazyProp], OutputChunkImpl.prototype, "name", null);
396
- __decorate([lazyProp], OutputChunkImpl.prototype, "exports", null);
397
- __decorate([lazyProp], OutputChunkImpl.prototype, "isEntry", null);
398
- __decorate([lazyProp], OutputChunkImpl.prototype, "facadeModuleId", null);
399
- __decorate([lazyProp], OutputChunkImpl.prototype, "isDynamicEntry", null);
400
- __decorate([lazyProp], OutputChunkImpl.prototype, "sourcemapFileName", null);
401
- __decorate([lazyProp], OutputChunkImpl.prototype, "preliminaryFileName", null);
402
- __decorate([lazyProp], OutputChunkImpl.prototype, "code", null);
403
- __decorate([lazyProp], OutputChunkImpl.prototype, "modules", null);
404
- __decorate([lazyProp], OutputChunkImpl.prototype, "imports", null);
405
- __decorate([lazyProp], OutputChunkImpl.prototype, "dynamicImports", null);
406
- __decorate([lazyProp], OutputChunkImpl.prototype, "moduleIds", null);
407
- __decorate([lazyProp], OutputChunkImpl.prototype, "map", null);
408
- //#endregion
409
- //#region src/utils/transform-to-rollup-output.ts
410
- function transformToRollupSourceMap(map) {
411
- const obj = {
412
- ...JSON.parse(map),
413
- toString() {
414
- return JSON.stringify(obj);
415
- },
416
- toUrl() {
417
- return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
418
- }
419
- };
420
- return obj;
421
- }
422
- function transformToRollupOutputChunk(bindingChunk) {
423
- return new OutputChunkImpl(bindingChunk);
424
- }
425
- function transformToMutableRollupOutputChunk(bindingChunk, changed) {
426
- const chunk = {
427
- type: "chunk",
428
- get code() {
429
- return bindingChunk.getCode();
430
- },
431
- fileName: bindingChunk.getFileName(),
432
- name: bindingChunk.getName(),
433
- get modules() {
434
- return transformChunkModules(bindingChunk.getModules());
435
- },
436
- get imports() {
437
- return bindingChunk.getImports();
438
- },
439
- get dynamicImports() {
440
- return bindingChunk.getDynamicImports();
441
- },
442
- exports: bindingChunk.getExports(),
443
- isEntry: bindingChunk.getIsEntry(),
444
- facadeModuleId: bindingChunk.getFacadeModuleId() || null,
445
- isDynamicEntry: bindingChunk.getIsDynamicEntry(),
446
- get moduleIds() {
447
- return bindingChunk.getModuleIds();
448
- },
449
- get map() {
450
- const map = bindingChunk.getMap();
451
- return map ? transformToRollupSourceMap(map) : null;
452
- },
453
- sourcemapFileName: bindingChunk.getSourcemapFileName() || null,
454
- preliminaryFileName: bindingChunk.getPreliminaryFileName()
455
- };
456
- const cache = {};
457
- return new Proxy(chunk, {
458
- get(target, p) {
459
- if (p in cache) return cache[p];
460
- const value = target[p];
461
- cache[p] = value;
462
- return value;
463
- },
464
- set(_target, p, newValue) {
465
- cache[p] = newValue;
466
- changed.updated.add(bindingChunk.getFileName());
467
- return true;
468
- },
469
- has(target, p) {
470
- if (p in cache) return true;
471
- return p in target;
472
- }
473
- });
474
- }
475
- function transformToRollupOutputAsset(bindingAsset) {
476
- return new OutputAssetImpl(bindingAsset);
477
- }
478
- function transformToMutableRollupOutputAsset(bindingAsset, changed) {
479
- const asset = {
480
- type: "asset",
481
- fileName: bindingAsset.getFileName(),
482
- originalFileName: bindingAsset.getOriginalFileName() || null,
483
- originalFileNames: bindingAsset.getOriginalFileNames(),
484
- get source() {
485
- return transformAssetSource(bindingAsset.getSource());
486
- },
487
- name: bindingAsset.getName() ?? void 0,
488
- names: bindingAsset.getNames()
489
- };
490
- const cache = {};
491
- return new Proxy(asset, {
492
- get(target, p) {
493
- if (p in cache) return cache[p];
494
- const value = target[p];
495
- cache[p] = value;
496
- return value;
497
- },
498
- set(_target, p, newValue) {
499
- cache[p] = newValue;
500
- changed.updated.add(bindingAsset.getFileName());
501
- return true;
502
- }
503
- });
504
- }
505
- function transformToRollupOutput(output) {
506
- const { chunks, assets } = output;
507
- return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk)), ...assets.map((asset) => transformToRollupOutputAsset(asset))] };
508
- }
509
- function transformToMutableRollupOutput(output, changed) {
510
- const { chunks, assets } = output;
511
- return { output: [...chunks.map((chunk) => transformToMutableRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToMutableRollupOutputAsset(asset, changed))] };
512
- }
513
- function transformToOutputBundle(context, output, changed) {
514
- const bundle = Object.fromEntries(transformToMutableRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
515
- return new Proxy(bundle, {
516
- set(_target, _p, _newValue, _receiver) {
517
- const originalStackTraceLimit = Error.stackTraceLimit;
518
- Error.stackTraceLimit = 2;
519
- const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
520
- const stack = (/* @__PURE__ */ new Error(message)).stack ?? message;
521
- Error.stackTraceLimit = originalStackTraceLimit;
522
- context.warn({
523
- message: stack,
524
- code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
525
- });
526
- return true;
527
- },
528
- deleteProperty(target, property) {
529
- if (typeof property === "string") changed.deleted.add(property);
530
- return true;
531
- }
532
- });
533
- }
534
- function collectChangedBundle(changed, bundle) {
535
- const changes = {};
536
- for (const key in bundle) {
537
- if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
538
- const item = bundle[key];
539
- if (item.type === "asset") changes[key] = {
540
- filename: item.fileName,
541
- originalFileNames: item.originalFileNames,
542
- source: bindingAssetSource(item.source),
543
- names: item.names
544
- };
545
- else changes[key] = {
546
- code: item.code,
547
- filename: item.fileName,
548
- name: item.name,
549
- isEntry: item.isEntry,
550
- exports: item.exports,
551
- modules: {},
552
- imports: item.imports,
553
- dynamicImports: item.dynamicImports,
554
- facadeModuleId: item.facadeModuleId || void 0,
555
- isDynamicEntry: item.isDynamicEntry,
556
- moduleIds: item.moduleIds,
557
- map: bindingifySourcemap(item.map),
558
- sourcemapFilename: item.sourcemapFileName || void 0,
559
- preliminaryFilename: item.preliminaryFileName
560
- };
561
- }
562
- return {
563
- changes,
564
- deleted: changed.deleted
565
- };
566
- }
567
- //#endregion
568
- //#region src/options/normalized-input-options.ts
569
- var NormalizedInputOptionsImpl = class extends PlainObjectLike {
570
- onLog;
571
- inputPlugins;
572
- inner;
573
- constructor(inner, onLog, inputPlugins) {
574
- super();
575
- this.onLog = onLog;
576
- this.inputPlugins = inputPlugins;
577
- this.inner = inner;
578
- }
579
- get shimMissingExports() {
580
- return this.inner.shimMissingExports;
581
- }
582
- get input() {
583
- return this.inner.input;
584
- }
585
- get cwd() {
586
- return this.inner.cwd;
587
- }
588
- get platform() {
589
- return this.inner.platform;
590
- }
591
- get context() {
592
- return this.inner.context;
593
- }
594
- get plugins() {
595
- return this.inputPlugins;
596
- }
597
- };
598
- __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "shimMissingExports", null);
599
- __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "input", null);
600
- __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "cwd", null);
601
- __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "platform", null);
602
- __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "context", null);
603
- //#endregion
604
- //#region src/options/normalized-output-options.ts
605
- var NormalizedOutputOptionsImpl = class extends PlainObjectLike {
606
- inner;
607
- outputOptions;
608
- normalizedOutputPlugins;
609
- constructor(inner, outputOptions, normalizedOutputPlugins) {
610
- super();
611
- this.inner = inner;
612
- this.outputOptions = outputOptions;
613
- this.normalizedOutputPlugins = normalizedOutputPlugins;
614
- }
615
- get dir() {
616
- return this.inner.dir ?? void 0;
617
- }
618
- get entryFileNames() {
619
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
620
- }
621
- get chunkFileNames() {
622
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
623
- }
624
- get assetFileNames() {
625
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
626
- }
627
- get format() {
628
- return this.inner.format;
629
- }
630
- get exports() {
631
- return this.inner.exports;
632
- }
633
- get sourcemap() {
634
- return this.inner.sourcemap;
635
- }
636
- get sourcemapBaseUrl() {
637
- return this.inner.sourcemapBaseUrl ?? void 0;
638
- }
639
- get shimMissingExports() {
640
- return this.inner.shimMissingExports;
641
- }
642
- get name() {
643
- return this.inner.name ?? void 0;
644
- }
645
- get file() {
646
- return this.inner.file ?? void 0;
647
- }
648
- get codeSplitting() {
649
- return this.inner.codeSplitting;
650
- }
651
- /**
652
- * @deprecated Use `codeSplitting` instead.
653
- */
654
- get inlineDynamicImports() {
655
- return !this.inner.codeSplitting;
656
- }
657
- get dynamicImportInCjs() {
658
- return this.inner.dynamicImportInCjs;
659
- }
660
- get externalLiveBindings() {
661
- return this.inner.externalLiveBindings;
662
- }
663
- get banner() {
664
- return normalizeAddon(this.outputOptions.banner);
665
- }
666
- get footer() {
667
- return normalizeAddon(this.outputOptions.footer);
668
- }
669
- get postBanner() {
670
- return normalizeAddon(this.outputOptions.postBanner);
671
- }
672
- get postFooter() {
673
- return normalizeAddon(this.outputOptions.postFooter);
674
- }
675
- get intro() {
676
- return normalizeAddon(this.outputOptions.intro);
677
- }
678
- get outro() {
679
- return normalizeAddon(this.outputOptions.outro);
680
- }
681
- get esModule() {
682
- return this.inner.esModule;
683
- }
684
- get extend() {
685
- return this.inner.extend;
686
- }
687
- get globals() {
688
- return this.inner.globals || this.outputOptions.globals;
689
- }
690
- get paths() {
691
- return this.outputOptions.paths;
692
- }
693
- get hashCharacters() {
694
- return this.inner.hashCharacters;
695
- }
696
- get sourcemapDebugIds() {
697
- return this.inner.sourcemapDebugIds;
698
- }
699
- get sourcemapExcludeSources() {
700
- return this.inner.sourcemapExcludeSources;
701
- }
702
- get sourcemapIgnoreList() {
703
- return this.outputOptions.sourcemapIgnoreList;
704
- }
705
- get sourcemapPathTransform() {
706
- return this.outputOptions.sourcemapPathTransform;
707
- }
708
- get minify() {
709
- let ret = this.inner.minify;
710
- if (typeof ret === "object" && ret !== null) {
711
- delete ret["codegen"];
712
- delete ret["module"];
713
- delete ret["sourcemap"];
714
- }
715
- return ret;
716
- }
717
- get legalComments() {
718
- return this.inner.legalComments;
719
- }
720
- get comments() {
721
- const c = this.inner.comments;
722
- return {
723
- legal: c.legal ?? true,
724
- annotation: c.annotation ?? true,
725
- jsdoc: c.jsdoc ?? true
726
- };
727
- }
728
- get polyfillRequire() {
729
- return this.inner.polyfillRequire;
730
- }
731
- get plugins() {
732
- return this.normalizedOutputPlugins;
733
- }
734
- get preserveModules() {
735
- return this.inner.preserveModules;
736
- }
737
- get preserveModulesRoot() {
738
- return this.inner.preserveModulesRoot;
739
- }
740
- get virtualDirname() {
741
- return this.inner.virtualDirname;
742
- }
743
- get topLevelVar() {
744
- return this.inner.topLevelVar ?? false;
745
- }
746
- get minifyInternalExports() {
747
- return this.inner.minifyInternalExports ?? false;
748
- }
749
- };
750
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dir", null);
751
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "entryFileNames", null);
752
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "chunkFileNames", null);
753
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "assetFileNames", null);
754
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "format", null);
755
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "exports", null);
756
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemap", null);
757
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapBaseUrl", null);
758
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "shimMissingExports", null);
759
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "name", null);
760
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "file", null);
761
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "codeSplitting", null);
762
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "inlineDynamicImports", null);
763
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dynamicImportInCjs", null);
764
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "externalLiveBindings", null);
765
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "banner", null);
766
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "footer", null);
767
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "postBanner", null);
768
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "postFooter", null);
769
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "intro", null);
770
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "outro", null);
771
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "esModule", null);
772
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "extend", null);
773
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "globals", null);
774
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "paths", null);
775
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "hashCharacters", null);
776
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapDebugIds", null);
777
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapExcludeSources", null);
778
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapIgnoreList", null);
779
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapPathTransform", null);
780
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minify", null);
781
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "legalComments", null);
782
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "comments", null);
783
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "polyfillRequire", null);
784
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "plugins", null);
785
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModules", null);
786
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModulesRoot", null);
787
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "virtualDirname", null);
788
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "topLevelVar", null);
789
- __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minifyInternalExports", null);
790
- function normalizeAddon(value) {
791
- if (typeof value === "function") return value;
792
- return () => value || "";
793
- }
794
- //#endregion
795
- //#region src/utils/transform-module-info.ts
796
- function transformModuleInfo(info, option) {
797
- return {
798
- get ast() {
799
- return unsupported("ModuleInfo#ast");
800
- },
801
- get code() {
802
- return info.code;
803
- },
804
- id: info.id,
805
- importers: info.importers,
806
- dynamicImporters: info.dynamicImporters,
807
- importedIds: info.importedIds,
808
- dynamicallyImportedIds: info.dynamicallyImportedIds,
809
- exports: info.exports,
810
- isEntry: info.isEntry,
811
- inputFormat: info.inputFormat,
812
- ...option
813
- };
814
- }
815
- //#endregion
816
- //#region src/plugin/plugin-context-data.ts
817
- var PluginContextData = class {
818
- onLog;
819
- outputOptions;
820
- normalizedInputPlugins;
821
- normalizedOutputPlugins;
822
- moduleOptionMap = /* @__PURE__ */ new Map();
823
- resolveOptionsMap = /* @__PURE__ */ new Map();
824
- loadModulePromiseMap = /* @__PURE__ */ new Map();
825
- renderedChunkMeta = null;
826
- normalizedInputOptions = null;
827
- normalizedOutputOptions = null;
828
- constructor(onLog, outputOptions, normalizedInputPlugins, normalizedOutputPlugins) {
829
- this.onLog = onLog;
830
- this.outputOptions = outputOptions;
831
- this.normalizedInputPlugins = normalizedInputPlugins;
832
- this.normalizedOutputPlugins = normalizedOutputPlugins;
833
- }
834
- updateModuleOption(id, option) {
835
- const existing = this.moduleOptionMap.get(id);
836
- if (existing) {
837
- if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
838
- if (option.meta != null) Object.assign(existing.meta, option.meta);
839
- if (option.invalidate != null) existing.invalidate = option.invalidate;
840
- } else {
841
- this.moduleOptionMap.set(id, option);
842
- return option;
843
- }
844
- return existing;
845
- }
846
- getModuleOption(id) {
847
- const option = this.moduleOptionMap.get(id);
848
- if (!option) {
849
- const raw = {
850
- moduleSideEffects: null,
851
- meta: {}
852
- };
853
- this.moduleOptionMap.set(id, raw);
854
- return raw;
855
- }
856
- return option;
857
- }
858
- getModuleInfo(id, context) {
859
- const bindingInfo = context.getModuleInfo(id);
860
- if (bindingInfo) {
861
- const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
862
- return this.proxyModuleInfo(id, info);
863
- }
864
- return null;
865
- }
866
- proxyModuleInfo(id, info) {
867
- let moduleSideEffects = info.moduleSideEffects;
868
- Object.defineProperty(info, "moduleSideEffects", {
869
- get() {
870
- return moduleSideEffects;
871
- },
872
- set: (v) => {
873
- this.updateModuleOption(id, {
874
- moduleSideEffects: v,
875
- meta: info.meta,
876
- invalidate: true
877
- });
878
- moduleSideEffects = v;
879
- }
880
- });
881
- return info;
882
- }
883
- getModuleIds(context) {
884
- return context.getModuleIds().values();
885
- }
886
- saveResolveOptions(options) {
887
- const index = this.resolveOptionsMap.size;
888
- this.resolveOptionsMap.set(index, options);
889
- return index;
890
- }
891
- getSavedResolveOptions(receipt) {
892
- return this.resolveOptionsMap.get(receipt);
893
- }
894
- removeSavedResolveOptions(receipt) {
895
- this.resolveOptionsMap.delete(receipt);
896
- }
897
- setRenderChunkMeta(meta) {
898
- this.renderedChunkMeta = meta;
899
- }
900
- getRenderChunkMeta() {
901
- return this.renderedChunkMeta;
902
- }
903
- getInputOptions(opts) {
904
- this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog, this.normalizedInputPlugins);
905
- return this.normalizedInputOptions;
906
- }
907
- getOutputOptions(opts) {
908
- this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
909
- return this.normalizedOutputOptions;
910
- }
911
- clear() {
912
- this.renderedChunkMeta = null;
913
- this.loadModulePromiseMap.clear();
914
- }
915
- };
916
- //#endregion
917
- //#region src/binding-magic-string.ts
918
- Object.defineProperty(import_binding.BindingMagicString.prototype, "isRolldownMagicString", {
919
- value: true,
920
- writable: false,
921
- configurable: false
922
- });
923
- function assertString(content, msg) {
924
- if (typeof content !== "string") throw new TypeError(msg);
925
- }
926
- const nativeAppend = import_binding.BindingMagicString.prototype.append;
927
- const nativePrepend = import_binding.BindingMagicString.prototype.prepend;
928
- const nativeAppendLeft = import_binding.BindingMagicString.prototype.appendLeft;
929
- const nativeAppendRight = import_binding.BindingMagicString.prototype.appendRight;
930
- const nativePrependLeft = import_binding.BindingMagicString.prototype.prependLeft;
931
- const nativePrependRight = import_binding.BindingMagicString.prototype.prependRight;
932
- const nativeOverwrite = import_binding.BindingMagicString.prototype.overwrite;
933
- const nativeUpdate = import_binding.BindingMagicString.prototype.update;
934
- import_binding.BindingMagicString.prototype.append = function(content) {
935
- assertString(content, "outro content must be a string");
936
- return nativeAppend.call(this, content);
937
- };
938
- import_binding.BindingMagicString.prototype.prepend = function(content) {
939
- assertString(content, "outro content must be a string");
940
- return nativePrepend.call(this, content);
941
- };
942
- import_binding.BindingMagicString.prototype.appendLeft = function(index, content) {
943
- assertString(content, "inserted content must be a string");
944
- return nativeAppendLeft.call(this, index, content);
945
- };
946
- import_binding.BindingMagicString.prototype.appendRight = function(index, content) {
947
- assertString(content, "inserted content must be a string");
948
- return nativeAppendRight.call(this, index, content);
949
- };
950
- import_binding.BindingMagicString.prototype.prependLeft = function(index, content) {
951
- assertString(content, "inserted content must be a string");
952
- return nativePrependLeft.call(this, index, content);
953
- };
954
- import_binding.BindingMagicString.prototype.prependRight = function(index, content) {
955
- assertString(content, "inserted content must be a string");
956
- return nativePrependRight.call(this, index, content);
957
- };
958
- import_binding.BindingMagicString.prototype.overwrite = function(start, end, content, options) {
959
- assertString(content, "replacement content must be a string");
960
- return nativeOverwrite.call(this, start, end, content, options);
961
- };
962
- import_binding.BindingMagicString.prototype.update = function(start, end, content, options) {
963
- assertString(content, "replacement content must be a string");
964
- return nativeUpdate.call(this, start, end, content, options);
965
- };
966
- const nativeReplace = import_binding.BindingMagicString.prototype.replace;
967
- const nativeReplaceAll = import_binding.BindingMagicString.prototype.replaceAll;
968
- import_binding.BindingMagicString.prototype.replace = function(searchValue, replacement) {
969
- if (typeof searchValue === "string") return nativeReplace.call(this, searchValue, replacement);
970
- if (searchValue.global) searchValue.lastIndex = 0;
971
- const lastMatchEnd = this.replaceRegex(searchValue, replacement);
972
- if (searchValue.global) searchValue.lastIndex = 0;
973
- else if (searchValue.sticky) searchValue.lastIndex = lastMatchEnd === -1 ? 0 : lastMatchEnd;
974
- return this;
975
- };
976
- import_binding.BindingMagicString.prototype.replaceAll = function(searchValue, replacement) {
977
- if (typeof searchValue === "string") return nativeReplaceAll.call(this, searchValue, replacement);
978
- if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
979
- searchValue.lastIndex = 0;
980
- this.replaceRegex(searchValue, replacement);
981
- searchValue.lastIndex = 0;
982
- return this;
983
- };
984
- /**
985
- * A native MagicString implementation powered by Rust.
986
- *
987
- * @experimental
988
- */
989
- const RolldownMagicString = import_binding.BindingMagicString;
990
- //#endregion
991
- //#region src/utils/transform-sourcemap.ts
992
- function isEmptySourcemapFiled(array) {
993
- if (!array) return true;
994
- if (array.length === 0 || !array[0]) return true;
995
- return false;
996
- }
997
- function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
998
- if (!rawMap) return;
999
- let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
1000
- if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
1001
- if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
1002
- return map;
1003
- }
1004
- //#endregion
1005
- //#region ../../node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/lazyDataLastImpl--3B10z3s.js
1006
- function e(e, t, n) {
1007
- let r = (n) => e(n, ...t);
1008
- return n === void 0 ? r : Object.assign(r, {
1009
- lazy: n,
1010
- lazyArgs: t
1011
- });
1012
- }
1013
- //#endregion
1014
- //#region ../../node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/purry.js
1015
- function t$1(t, n, r) {
1016
- let i = t.length - n.length;
1017
- if (i === 0) return t(...n);
1018
- if (i === 1) return e(t, n, r);
1019
- throw Error(`Wrong number of arguments`);
1020
- }
1021
- //#endregion
1022
- //#region ../../node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/partition.js
1023
- function t(...t) {
1024
- return t$1(n, t);
1025
- }
1026
- const n = (e, t) => {
1027
- let n = [[], []];
1028
- for (let [r, i] of e.entries()) t(i, r, e) ? n[0].push(i) : n[1].push(i);
1029
- return n;
1030
- };
1031
- //#endregion
1032
- //#region src/plugin/bindingify-hook-filter.ts
1033
- function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
1034
- if (typeof matcher === "string" || matcher instanceof RegExp) return [filter.include(generateAtomMatcher(stringKind, matcher))];
1035
- if (Array.isArray(matcher)) return matcher.map((m) => filter.include(generateAtomMatcher(stringKind, m)));
1036
- let ret = [];
1037
- if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => filter.exclude(generateAtomMatcher(stringKind, m))));
1038
- if (matcher.include) ret.push(...arraify(matcher.include).map((m) => filter.include(generateAtomMatcher(stringKind, m))));
1039
- return ret;
1040
- }
1041
- function generateAtomMatcher(kind, matcher) {
1042
- return kind === "code" ? filter.code(matcher) : filter.id(matcher);
1043
- }
1044
- function transformFilterMatcherToFilterExprs(filterOption) {
1045
- if (!filterOption) return;
1046
- if (Array.isArray(filterOption)) return filterOption;
1047
- const { id, code, moduleType } = filterOption;
1048
- let ret = [];
1049
- let idIncludes = [];
1050
- let idExcludes = [];
1051
- let codeIncludes = [];
1052
- let codeExcludes = [];
1053
- if (id) [idIncludes, idExcludes] = t(generalHookFilterMatcherToFilterExprs(id, "id") ?? [], (m) => m.kind === "include");
1054
- if (code) [codeIncludes, codeExcludes] = t(generalHookFilterMatcherToFilterExprs(code, "code") ?? [], (m) => m.kind === "include");
1055
- ret.push(...idExcludes);
1056
- ret.push(...codeExcludes);
1057
- let andExprList = [];
1058
- if (moduleType) {
1059
- let moduleTypes = Array.isArray(moduleType) ? moduleType : moduleType.include ?? [];
1060
- andExprList.push(filter.or(...moduleTypes.map((m) => filter.moduleType(m))));
1061
- }
1062
- if (idIncludes.length) andExprList.push(filter.or(...idIncludes.map((item) => item.expr)));
1063
- if (codeIncludes.length) andExprList.push(filter.or(...codeIncludes.map((item) => item.expr)));
1064
- if (andExprList.length) ret.push(filter.include(filter.and(...andExprList)));
1065
- return ret;
1066
- }
1067
- function bindingifyGeneralHookFilter(stringKind, pattern) {
1068
- let filterExprs = generalHookFilterMatcherToFilterExprs(pattern, stringKind);
1069
- let ret = [];
1070
- if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
1071
- return ret.length > 0 ? { value: ret } : void 0;
1072
- }
1073
- function bindingifyFilterExpr(expr) {
1074
- let list = [];
1075
- bindingifyFilterExprImpl(expr, list);
1076
- return list;
1077
- }
1078
- function containsImporterId(expr) {
1079
- switch (expr.kind) {
1080
- case "and":
1081
- case "or": return expr.args.some(containsImporterId);
1082
- case "not":
1083
- case "include":
1084
- case "exclude": return containsImporterId(expr.expr);
1085
- case "importerId": return true;
1086
- default: return false;
1087
- }
1088
- }
1089
- function assertNoImporterId(filterExprs, hookName) {
1090
- if (filterExprs?.some(containsImporterId)) throw new Error(`The \`importerId\` filter can only be used with the \`resolveId\` hook, but it was used with the \`${hookName}\` hook.`);
1091
- }
1092
- function bindingifyFilterExprImpl(expr, list) {
1093
- switch (expr.kind) {
1094
- case "and": {
1095
- let args = expr.args;
1096
- for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
1097
- list.push({
1098
- kind: "And",
1099
- payload: args.length
1100
- });
1101
- break;
1102
- }
1103
- case "or": {
1104
- let args = expr.args;
1105
- for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
1106
- list.push({
1107
- kind: "Or",
1108
- payload: args.length
1109
- });
1110
- break;
1111
- }
1112
- case "not":
1113
- bindingifyFilterExprImpl(expr.expr, list);
1114
- list.push({ kind: "Not" });
1115
- break;
1116
- case "id":
1117
- list.push({
1118
- kind: "Id",
1119
- payload: expr.pattern
1120
- });
1121
- if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
1122
- break;
1123
- case "importerId":
1124
- list.push({
1125
- kind: "ImporterId",
1126
- payload: expr.pattern
1127
- });
1128
- if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
1129
- break;
1130
- case "moduleType":
1131
- list.push({
1132
- kind: "ModuleType",
1133
- payload: expr.pattern
1134
- });
1135
- break;
1136
- case "code":
1137
- list.push({
1138
- kind: "Code",
1139
- payload: expr.pattern
1140
- });
1141
- break;
1142
- case "include":
1143
- bindingifyFilterExprImpl(expr.expr, list);
1144
- list.push({ kind: "Include" });
1145
- break;
1146
- case "exclude":
1147
- bindingifyFilterExprImpl(expr.expr, list);
1148
- list.push({ kind: "Exclude" });
1149
- break;
1150
- case "query":
1151
- list.push({
1152
- kind: "QueryKey",
1153
- payload: expr.key
1154
- });
1155
- list.push({
1156
- kind: "QueryValue",
1157
- payload: expr.pattern
1158
- });
1159
- break;
1160
- default: throw new Error(`Unknown filter expression: ${expr}`);
1161
- }
1162
- }
1163
- function bindingifyResolveIdFilter(filterOption) {
1164
- if (!filterOption) return;
1165
- if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
1166
- return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
1167
- }
1168
- function bindingifyLoadFilter(filterOption) {
1169
- if (!filterOption) return;
1170
- if (Array.isArray(filterOption)) {
1171
- assertNoImporterId(filterOption, "load");
1172
- return { value: filterOption.map(bindingifyFilterExpr) };
1173
- }
1174
- return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
1175
- }
1176
- function bindingifyTransformFilter(filterOption) {
1177
- if (!filterOption) return;
1178
- let filterExprs = transformFilterMatcherToFilterExprs(filterOption);
1179
- assertNoImporterId(filterExprs, "transform");
1180
- let ret = [];
1181
- if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
1182
- return { value: ret.length > 0 ? ret : void 0 };
1183
- }
1184
- function bindingifyRenderChunkFilter(filterOption) {
1185
- if (!filterOption) return;
1186
- if (Array.isArray(filterOption)) {
1187
- assertNoImporterId(filterOption, "renderChunk");
1188
- return { value: filterOption.map(bindingifyFilterExpr) };
1189
- }
1190
- return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
1191
- }
1192
- //#endregion
1193
- //#region src/plugin/bindingify-plugin-hook-meta.ts
1194
- function bindingifyPluginHookMeta(options) {
1195
- return { order: bindingPluginOrder(options.order) };
1196
- }
1197
- function bindingPluginOrder(order) {
1198
- switch (order) {
1199
- case "post": return import_binding.BindingPluginOrder.Post;
1200
- case "pre": return import_binding.BindingPluginOrder.Pre;
1201
- case null:
1202
- case void 0: return;
1203
- default: throw new Error(`Unknown plugin order: ${order}`);
1204
- }
1205
- }
1206
- //#endregion
1207
- //#region src/plugin/fs.ts
1208
- const fsModule = {
1209
- appendFile: fsp.appendFile,
1210
- copyFile: fsp.copyFile,
1211
- mkdir: fsp.mkdir,
1212
- mkdtemp: fsp.mkdtemp,
1213
- readdir: fsp.readdir,
1214
- readFile: fsp.readFile,
1215
- realpath: fsp.realpath,
1216
- rename: fsp.rename,
1217
- rmdir: fsp.rmdir,
1218
- stat: fsp.stat,
1219
- lstat: fsp.lstat,
1220
- unlink: fsp.unlink,
1221
- writeFile: fsp.writeFile
1222
- };
1223
- //#endregion
1224
- //#region src/plugin/plugin-context.ts
1225
- var PluginContextImpl = class extends MinimalPluginContextImpl {
1226
- outputOptions;
1227
- context;
1228
- data;
1229
- onLog;
1230
- currentLoadingModule;
1231
- fs = fsModule;
1232
- getModuleInfo;
1233
- constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
1234
- super(onLog, logLevel, plugin.name, watchMode);
1235
- this.outputOptions = outputOptions;
1236
- this.context = context;
1237
- this.data = data;
1238
- this.onLog = onLog;
1239
- this.currentLoadingModule = currentLoadingModule;
1240
- this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
1241
- }
1242
- async load(options) {
1243
- const id = options.id;
1244
- if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
1245
- const moduleInfo = this.data.getModuleInfo(id, this.context);
1246
- if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
1247
- const rawOptions = {
1248
- meta: options.meta || {},
1249
- moduleSideEffects: options.moduleSideEffects || null,
1250
- invalidate: false
1251
- };
1252
- this.data.updateModuleOption(id, rawOptions);
1253
- let loadPromise = this.data.loadModulePromiseMap.get(id);
1254
- if (!loadPromise) {
1255
- loadPromise = this.context.load(id, options.moduleSideEffects ?? void 0, options.packageJsonPath ?? void 0).catch(() => {
1256
- this.data.loadModulePromiseMap.delete(id);
1257
- });
1258
- this.data.loadModulePromiseMap.set(id, loadPromise);
1259
- }
1260
- await loadPromise;
1261
- return this.data.getModuleInfo(id, this.context);
1262
- }
1263
- async resolve(source, importer, options) {
1264
- let receipt = void 0;
1265
- if (options != null) receipt = this.data.saveResolveOptions(options);
1266
- const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
1267
- if (key.startsWith("vite:")) (acc ??= {})[key] = value;
1268
- return acc;
1269
- }, void 0);
1270
- const res = await this.context.resolve(source, importer, {
1271
- importKind: options?.kind,
1272
- custom: receipt,
1273
- isEntry: options?.isEntry,
1274
- skipSelf: options?.skipSelf,
1275
- vitePluginCustom
1276
- });
1277
- if (receipt != null) this.data.removeSavedResolveOptions(receipt);
1278
- if (res == null) return null;
1279
- const info = this.data.getModuleOption(res.id) || {};
1280
- return {
1281
- ...res,
1282
- external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
1283
- ...info,
1284
- moduleSideEffects: info.moduleSideEffects ?? res.moduleSideEffects ?? null,
1285
- packageJsonPath: res.packageJsonPath
1286
- };
1287
- }
1288
- emitFile = (file) => {
1289
- if (file.type === "prebuilt-chunk") return this.context.emitPrebuiltChunk({
1290
- fileName: file.fileName,
1291
- name: file.name,
1292
- code: file.code,
1293
- exports: file.exports,
1294
- map: bindingifySourcemap(file.map),
1295
- sourcemapFileName: file.sourcemapFileName,
1296
- facadeModuleId: file.facadeModuleId,
1297
- isEntry: file.isEntry,
1298
- isDynamicEntry: file.isDynamicEntry
1299
- });
1300
- if (file.type === "chunk") return this.context.emitChunk({
1301
- preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
1302
- ...file
1303
- });
1304
- const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
1305
- const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
1306
- return this.context.emitFile({
1307
- ...file,
1308
- originalFileName: file.originalFileName || void 0,
1309
- source: bindingAssetSource(file.source)
1310
- }, filename, fnSanitizedFileName);
1311
- };
1312
- getAssetFileNames(file) {
1313
- if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
1314
- type: "asset",
1315
- name: file.name,
1316
- names: file.name ? [file.name] : [],
1317
- originalFileName: file.originalFileName,
1318
- originalFileNames: file.originalFileName ? [file.originalFileName] : [],
1319
- source: file.source
1320
- });
1321
- }
1322
- getFileName(referenceId) {
1323
- return this.context.getFileName(referenceId);
1324
- }
1325
- getModuleIds() {
1326
- return this.data.getModuleIds(this.context);
1327
- }
1328
- addWatchFile(id) {
1329
- this.context.addWatchFile(id);
1330
- }
1331
- parse(input, options) {
1332
- return parseAst(input, options);
1333
- }
1334
- };
1335
- //#endregion
1336
- //#region src/plugin/load-plugin-context.ts
1337
- var LoadPluginContextImpl = class extends PluginContextImpl {
1338
- inner;
1339
- constructor(outputOptions, context, plugin, data, inner, moduleId, onLog, logLevelOption, watchMode) {
1340
- super(outputOptions, context, plugin, data, onLog, logLevelOption, watchMode, moduleId);
1341
- this.inner = inner;
1342
- }
1343
- addWatchFile(id) {
1344
- this.inner.addWatchFile(id);
1345
- }
1346
- };
1347
- //#endregion
1348
- //#region src/plugin/transform-plugin-context.ts
1349
- var TransformPluginContextImpl = class extends PluginContextImpl {
1350
- inner;
1351
- moduleId;
1352
- moduleSource;
1353
- constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
1354
- super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
1355
- this.inner = inner;
1356
- this.moduleId = moduleId;
1357
- this.moduleSource = moduleSource;
1358
- const getLogHandler = (handler) => (log, pos) => {
1359
- log = normalizeLog(log);
1360
- if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
1361
- log.id = moduleId;
1362
- log.hook = "transform";
1363
- handler(log);
1364
- };
1365
- this.debug = getLogHandler(this.debug);
1366
- this.warn = getLogHandler(this.warn);
1367
- this.info = getLogHandler(this.info);
1368
- }
1369
- error(e, pos) {
1370
- if (typeof e === "string") e = { message: e };
1371
- if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
1372
- e.id = this.moduleId;
1373
- e.hook = "transform";
1374
- return error(logPluginError(normalizeLog(e), this.pluginName));
1375
- }
1376
- getCombinedSourcemap() {
1377
- return JSON.parse(this.inner.getCombinedSourcemap());
1378
- }
1379
- addWatchFile(id) {
1380
- this.inner.addWatchFile(id);
1381
- }
1382
- sendMagicString(s) {
1383
- this.inner.sendMagicString(s);
1384
- }
1385
- };
1386
- //#endregion
1387
- //#region src/plugin/bindingify-build-hooks.ts
1388
- function createPluginContext(args, ctx) {
1389
- return new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1390
- }
1391
- function bindingifyBuildStart(args) {
1392
- const hook = args.plugin.buildStart;
1393
- if (!hook) return {};
1394
- const { handler, meta } = normalizeHook(hook);
1395
- return {
1396
- plugin: async (ctx, opts) => {
1397
- await handler.call(createPluginContext(args, ctx), args.pluginContextData.getInputOptions(opts));
1398
- },
1399
- meta: bindingifyPluginHookMeta(meta)
1400
- };
1401
- }
1402
- function bindingifyBuildEnd(args) {
1403
- const hook = args.plugin.buildEnd;
1404
- if (!hook) return {};
1405
- const { handler, meta } = normalizeHook(hook);
1406
- return {
1407
- plugin: async (ctx, err) => {
1408
- await handler.call(createPluginContext(args, ctx), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
1409
- },
1410
- meta: bindingifyPluginHookMeta(meta)
1411
- };
1412
- }
1413
- function bindingifyResolveId(args) {
1414
- const hook = args.plugin.resolveId;
1415
- if (!hook) return {};
1416
- const { handler, meta, options } = normalizeHook(hook);
1417
- return {
1418
- plugin: async (ctx, specifier, importer, extraOptions) => {
1419
- const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
1420
- const ret = await handler.call(createPluginContext(args, ctx), specifier, importer ?? void 0, {
1421
- ...extraOptions,
1422
- custom: contextResolveOptions?.custom
1423
- });
1424
- if (ret == null) return;
1425
- if (ret === false) return {
1426
- id: specifier,
1427
- external: true,
1428
- normalizeExternalId: true
1429
- };
1430
- if (typeof ret === "string") return {
1431
- id: ret,
1432
- normalizeExternalId: false
1433
- };
1434
- let exist = args.pluginContextData.updateModuleOption(ret.id, {
1435
- meta: ret.meta || {},
1436
- moduleSideEffects: ret.moduleSideEffects ?? null,
1437
- invalidate: false
1438
- });
1439
- return {
1440
- id: ret.id,
1441
- external: ret.external,
1442
- normalizeExternalId: false,
1443
- moduleSideEffects: exist.moduleSideEffects ?? void 0,
1444
- packageJsonPath: ret.packageJsonPath
1445
- };
1446
- },
1447
- meta: bindingifyPluginHookMeta(meta),
1448
- filter: bindingifyResolveIdFilter(options.filter)
1449
- };
1450
- }
1451
- function bindingifyResolveDynamicImport(args) {
1452
- const hook = args.plugin.resolveDynamicImport;
1453
- if (!hook) return {};
1454
- const { handler, meta } = normalizeHook(hook);
1455
- return {
1456
- plugin: async (ctx, specifier, importer) => {
1457
- const ret = await handler.call(createPluginContext(args, ctx), specifier, importer ?? void 0);
1458
- if (ret == null) return;
1459
- if (ret === false) return {
1460
- id: specifier,
1461
- external: true
1462
- };
1463
- if (typeof ret === "string") return { id: ret };
1464
- const result = {
1465
- id: ret.id,
1466
- external: ret.external,
1467
- packageJsonPath: ret.packageJsonPath
1468
- };
1469
- if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
1470
- args.pluginContextData.updateModuleOption(ret.id, {
1471
- meta: ret.meta || {},
1472
- moduleSideEffects: ret.moduleSideEffects || null,
1473
- invalidate: false
1474
- });
1475
- return result;
1476
- },
1477
- meta: bindingifyPluginHookMeta(meta)
1478
- };
1479
- }
1480
- function bindingifyTransform(args) {
1481
- const hook = args.plugin.transform;
1482
- if (!hook) return {};
1483
- const { handler, meta, options } = normalizeHook(hook);
1484
- return {
1485
- plugin: async (ctx, code, id, meta) => {
1486
- let magicStringInstance, astInstance;
1487
- Object.defineProperties(meta, {
1488
- magicString: { get() {
1489
- if (magicStringInstance) return magicStringInstance;
1490
- magicStringInstance = new RolldownMagicString(code);
1491
- return magicStringInstance;
1492
- } },
1493
- ast: { get() {
1494
- if (astInstance) return astInstance;
1495
- let lang = "js";
1496
- switch (meta.moduleType) {
1497
- case "js":
1498
- case "jsx":
1499
- case "ts":
1500
- case "tsx":
1501
- lang = meta.moduleType;
1502
- break;
1503
- default: break;
1504
- }
1505
- astInstance = parseAst(code, {
1506
- astType: meta.moduleType.includes("ts") ? "ts" : "js",
1507
- lang
1508
- });
1509
- return astInstance;
1510
- } }
1511
- });
1512
- const transformCtx = new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, code, args.onLog, args.logLevel, args.watchMode);
1513
- const ret = await handler.call(transformCtx, code, id, meta);
1514
- if (ret == null) return;
1515
- if (typeof ret === "string") return { code: ret };
1516
- let moduleOption = args.pluginContextData.updateModuleOption(id, {
1517
- meta: ret.meta ?? {},
1518
- moduleSideEffects: ret.moduleSideEffects ?? null,
1519
- invalidate: false
1520
- });
1521
- let normalizedCode = void 0;
1522
- let map = ret.map;
1523
- let mapHandledByNativeChannel = false;
1524
- if (typeof ret.code === "string") normalizedCode = ret.code;
1525
- else if (ret.code instanceof RolldownMagicString) {
1526
- let magicString = ret.code;
1527
- normalizedCode = magicString.toString();
1528
- let fallbackSourcemap = ctx.sendMagicString(magicString);
1529
- if (fallbackSourcemap != void 0) map = fallbackSourcemap;
1530
- else mapHandledByNativeChannel = true;
1531
- }
1532
- return {
1533
- code: normalizedCode,
1534
- map: bindingifySourcemap(normalizeTransformHookSourcemap(id, code, map)) ?? (mapHandledByNativeChannel || ret.map === null ? null : void 0),
1535
- moduleSideEffects: moduleOption.moduleSideEffects ?? void 0,
1536
- moduleType: ret.moduleType
1537
- };
1538
- },
1539
- meta: bindingifyPluginHookMeta(meta),
1540
- filter: bindingifyTransformFilter(options.filter)
1541
- };
1542
- }
1543
- function bindingifyLoad(args) {
1544
- const hook = args.plugin.load;
1545
- if (!hook) return {};
1546
- const { handler, meta, options } = normalizeHook(hook);
1547
- return {
1548
- plugin: async (ctx, id) => {
1549
- const ret = await handler.call(new LoadPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, args.onLog, args.logLevel, args.watchMode), id);
1550
- if (ret == null) return;
1551
- if (typeof ret === "string") return { code: ret };
1552
- let moduleOption = args.pluginContextData.updateModuleOption(id, {
1553
- meta: ret.meta || {},
1554
- moduleSideEffects: ret.moduleSideEffects ?? null,
1555
- invalidate: false
1556
- });
1557
- let map = preProcessSourceMap(ret, id);
1558
- return {
1559
- code: ret.code,
1560
- map: bindingifySourcemap(map),
1561
- moduleType: ret.moduleType,
1562
- moduleSideEffects: moduleOption.moduleSideEffects ?? void 0
1563
- };
1564
- },
1565
- meta: bindingifyPluginHookMeta(meta),
1566
- filter: bindingifyLoadFilter(options.filter)
1567
- };
1568
- }
1569
- function preProcessSourceMap(ret, id) {
1570
- if (!ret.map) return;
1571
- let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
1572
- if (!isEmptySourcemapFiled(map.sources)) {
1573
- const directory = path.dirname(id) || ".";
1574
- const sourceRoot = map.sourceRoot || ".";
1575
- map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
1576
- }
1577
- return map;
1578
- }
1579
- function bindingifyModuleParsed(args) {
1580
- const hook = args.plugin.moduleParsed;
1581
- if (!hook) return {};
1582
- const { handler, meta } = normalizeHook(hook);
1583
- return {
1584
- plugin: async (ctx, moduleInfo) => {
1585
- await handler.call(createPluginContext(args, ctx), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
1586
- },
1587
- meta: bindingifyPluginHookMeta(meta)
1588
- };
1589
- }
1590
- //#endregion
1591
- //#region src/plugin/bindingify-output-hooks.ts
1592
- function bindingifyRenderStart(args) {
1593
- const hook = args.plugin.renderStart;
1594
- if (!hook) return {};
1595
- const { handler, meta } = normalizeHook(hook);
1596
- return {
1597
- plugin: async (ctx, opts) => {
1598
- handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), args.pluginContextData.getOutputOptions(opts), args.pluginContextData.getInputOptions(opts));
1599
- },
1600
- meta: bindingifyPluginHookMeta(meta)
1601
- };
1602
- }
1603
- function bindingifyRenderChunk(args) {
1604
- const hook = args.plugin.renderChunk;
1605
- if (!hook) return {};
1606
- const { handler, meta, options } = normalizeHook(hook);
1607
- return {
1608
- plugin: async (ctx, code, chunk, opts, meta) => {
1609
- if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
1610
- const renderChunkMeta = args.pluginContextData.getRenderChunkMeta();
1611
- let magicStringInstance;
1612
- if (args.options.experimental?.nativeMagicString) Object.defineProperty(renderChunkMeta, "magicString", {
1613
- get() {
1614
- if (magicStringInstance) return magicStringInstance;
1615
- magicStringInstance = new RolldownMagicString(code);
1616
- return magicStringInstance;
1617
- },
1618
- configurable: true
1619
- });
1620
- const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code, transformRenderedChunk(chunk), args.pluginContextData.getOutputOptions(opts), renderChunkMeta);
1621
- if (ret == null) return;
1622
- if (ret instanceof RolldownMagicString) {
1623
- const normalizedCode = ret.toString();
1624
- const generatedMap = ret.generateMap();
1625
- return {
1626
- code: normalizedCode,
1627
- map: bindingifySourcemap({
1628
- file: generatedMap.file,
1629
- mappings: generatedMap.mappings,
1630
- names: generatedMap.names,
1631
- sources: generatedMap.sources,
1632
- sourcesContent: generatedMap.sourcesContent.map((s) => s ?? null)
1633
- })
1634
- };
1635
- }
1636
- if (typeof ret === "string") return { code: ret };
1637
- if (ret.code instanceof RolldownMagicString) {
1638
- const magicString = ret.code;
1639
- const normalizedCode = magicString.toString();
1640
- if (ret.map === null) return {
1641
- code: normalizedCode,
1642
- map: null
1643
- };
1644
- if (ret.map === void 0) {
1645
- const generatedMap = magicString.generateMap();
1646
- return {
1647
- code: normalizedCode,
1648
- map: bindingifySourcemap({
1649
- file: generatedMap.file,
1650
- mappings: generatedMap.mappings,
1651
- names: generatedMap.names,
1652
- sources: generatedMap.sources,
1653
- sourcesContent: generatedMap.sourcesContent.map((s) => s ?? null)
1654
- })
1655
- };
1656
- }
1657
- return {
1658
- code: normalizedCode,
1659
- map: bindingifySourcemap(ret.map)
1660
- };
1661
- }
1662
- if (ret.map === null) return {
1663
- code: ret.code,
1664
- map: null
1665
- };
1666
- return {
1667
- code: ret.code,
1668
- map: bindingifySourcemap(ret.map)
1669
- };
1670
- },
1671
- meta: bindingifyPluginHookMeta(meta),
1672
- filter: bindingifyRenderChunkFilter(options.filter)
1673
- };
1674
- }
1675
- function bindingifyAugmentChunkHash(args) {
1676
- const hook = args.plugin.augmentChunkHash;
1677
- if (!hook) return {};
1678
- const { handler, meta } = normalizeHook(hook);
1679
- return {
1680
- plugin: async (ctx, chunk) => {
1681
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1682
- },
1683
- meta: bindingifyPluginHookMeta(meta)
1684
- };
1685
- }
1686
- function bindingifyRenderError(args) {
1687
- const hook = args.plugin.renderError;
1688
- if (!hook) return {};
1689
- const { handler, meta } = normalizeHook(hook);
1690
- return {
1691
- plugin: async (ctx, err) => {
1692
- handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), aggregateBindingErrorsIntoJsError(err));
1693
- },
1694
- meta: bindingifyPluginHookMeta(meta)
1695
- };
1696
- }
1697
- function bindingifyGenerateBundle(args) {
1698
- const hook = args.plugin.generateBundle;
1699
- if (!hook) return {};
1700
- const { handler, meta } = normalizeHook(hook);
1701
- return {
1702
- plugin: async (ctx, bundle, isWrite, opts) => {
1703
- const changed = {
1704
- updated: /* @__PURE__ */ new Set(),
1705
- deleted: /* @__PURE__ */ new Set()
1706
- };
1707
- const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1708
- const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
1709
- await handler.call(context, args.pluginContextData.getOutputOptions(opts), output, isWrite);
1710
- return collectChangedBundle(changed, output);
1711
- },
1712
- meta: bindingifyPluginHookMeta(meta)
1713
- };
1714
- }
1715
- function bindingifyWriteBundle(args) {
1716
- const hook = args.plugin.writeBundle;
1717
- if (!hook) return {};
1718
- const { handler, meta } = normalizeHook(hook);
1719
- return {
1720
- plugin: async (ctx, bundle, opts) => {
1721
- const changed = {
1722
- updated: /* @__PURE__ */ new Set(),
1723
- deleted: /* @__PURE__ */ new Set()
1724
- };
1725
- const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1726
- const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
1727
- await handler.call(context, args.pluginContextData.getOutputOptions(opts), output);
1728
- return collectChangedBundle(changed, output);
1729
- },
1730
- meta: bindingifyPluginHookMeta(meta)
1731
- };
1732
- }
1733
- function bindingifyCloseBundle(args) {
1734
- const hook = args.plugin.closeBundle;
1735
- if (!hook) return {};
1736
- const { handler, meta } = normalizeHook(hook);
1737
- return {
1738
- plugin: async (ctx, err) => {
1739
- await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
1740
- },
1741
- meta: bindingifyPluginHookMeta(meta)
1742
- };
1743
- }
1744
- function bindingifyBanner(args) {
1745
- const hook = args.plugin.banner;
1746
- if (!hook) return {};
1747
- const { handler, meta } = normalizeHook(hook);
1748
- return {
1749
- plugin: async (ctx, chunk) => {
1750
- if (typeof handler === "string") return handler;
1751
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1752
- },
1753
- meta: bindingifyPluginHookMeta(meta)
1754
- };
1755
- }
1756
- function bindingifyFooter(args) {
1757
- const hook = args.plugin.footer;
1758
- if (!hook) return {};
1759
- const { handler, meta } = normalizeHook(hook);
1760
- return {
1761
- plugin: async (ctx, chunk) => {
1762
- if (typeof handler === "string") return handler;
1763
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1764
- },
1765
- meta: bindingifyPluginHookMeta(meta)
1766
- };
1767
- }
1768
- function bindingifyIntro(args) {
1769
- const hook = args.plugin.intro;
1770
- if (!hook) return {};
1771
- const { handler, meta } = normalizeHook(hook);
1772
- return {
1773
- plugin: async (ctx, chunk) => {
1774
- if (typeof handler === "string") return handler;
1775
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1776
- },
1777
- meta: bindingifyPluginHookMeta(meta)
1778
- };
1779
- }
1780
- function bindingifyOutro(args) {
1781
- const hook = args.plugin.outro;
1782
- if (!hook) return {};
1783
- const { handler, meta } = normalizeHook(hook);
1784
- return {
1785
- plugin: async (ctx, chunk) => {
1786
- if (typeof handler === "string") return handler;
1787
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1788
- },
1789
- meta: bindingifyPluginHookMeta(meta)
1790
- };
1791
- }
1792
- //#endregion
1793
- //#region src/plugin/bindingify-watch-hooks.ts
1794
- function bindingifyWatchChange(args) {
1795
- const hook = args.plugin.watchChange;
1796
- if (!hook) return {};
1797
- const { handler, meta } = normalizeHook(hook);
1798
- return {
1799
- plugin: async (ctx, id, event) => {
1800
- await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id, { event });
1801
- },
1802
- meta: bindingifyPluginHookMeta(meta)
1803
- };
1804
- }
1805
- function bindingifyCloseWatcher(args) {
1806
- const hook = args.plugin.closeWatcher;
1807
- if (!hook) return {};
1808
- const { handler, meta } = normalizeHook(hook);
1809
- return {
1810
- plugin: async (ctx) => {
1811
- await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
1812
- },
1813
- meta: bindingifyPluginHookMeta(meta)
1814
- };
1815
- }
1816
- //#endregion
1817
- //#region src/plugin/generated/hook-usage.ts
1818
- var HookUsage = class {
1819
- bitflag = BigInt(0);
1820
- constructor() {}
1821
- union(kind) {
1822
- this.bitflag |= BigInt(kind);
1823
- }
1824
- inner() {
1825
- return Number(this.bitflag);
1826
- }
1827
- };
1828
- function extractHookUsage(plugin) {
1829
- let hookUsage = new HookUsage();
1830
- if (plugin.buildStart) hookUsage.union(1);
1831
- if (plugin.resolveId) hookUsage.union(2);
1832
- if (plugin.resolveDynamicImport) hookUsage.union(4);
1833
- if (plugin.load) hookUsage.union(8);
1834
- if (plugin.transform) hookUsage.union(16);
1835
- if (plugin.moduleParsed) hookUsage.union(32);
1836
- if (plugin.buildEnd) hookUsage.union(64);
1837
- if (plugin.renderStart) hookUsage.union(128);
1838
- if (plugin.renderError) hookUsage.union(256);
1839
- if (plugin.renderChunk) hookUsage.union(512);
1840
- if (plugin.augmentChunkHash) hookUsage.union(1024);
1841
- if (plugin.generateBundle) hookUsage.union(2048);
1842
- if (plugin.writeBundle) hookUsage.union(4096);
1843
- if (plugin.closeBundle) hookUsage.union(8192);
1844
- if (plugin.watchChange) hookUsage.union(16384);
1845
- if (plugin.closeWatcher) hookUsage.union(32768);
1846
- if (plugin.banner) hookUsage.union(131072);
1847
- if (plugin.footer) hookUsage.union(262144);
1848
- if (plugin.intro) hookUsage.union(524288);
1849
- if (plugin.outro) hookUsage.union(1048576);
1850
- return hookUsage;
1851
- }
1852
- //#endregion
1853
- //#region src/plugin/bindingify-plugin.ts
1854
- function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
1855
- const args = {
1856
- plugin,
1857
- options,
1858
- outputOptions,
1859
- pluginContextData,
1860
- onLog,
1861
- logLevel,
1862
- watchMode,
1863
- normalizedOutputPlugins
1864
- };
1865
- const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
1866
- const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
1867
- const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
1868
- const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
1869
- const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
1870
- const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
1871
- const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
1872
- const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
1873
- const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
1874
- const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
1875
- const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
1876
- const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
1877
- const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
1878
- const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
1879
- const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
1880
- const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
1881
- const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
1882
- const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
1883
- const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
1884
- const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
1885
- let hookUsage = extractHookUsage(plugin).inner();
1886
- return wrapHandlers({
1887
- name: plugin.name,
1888
- buildStart,
1889
- buildStartMeta,
1890
- resolveId,
1891
- resolveIdMeta,
1892
- resolveIdFilter,
1893
- resolveDynamicImport,
1894
- resolveDynamicImportMeta,
1895
- buildEnd,
1896
- buildEndMeta,
1897
- transform,
1898
- transformMeta,
1899
- transformFilter,
1900
- moduleParsed,
1901
- moduleParsedMeta,
1902
- load,
1903
- loadMeta,
1904
- loadFilter,
1905
- renderChunk,
1906
- renderChunkMeta,
1907
- renderChunkFilter,
1908
- augmentChunkHash,
1909
- augmentChunkHashMeta,
1910
- renderStart,
1911
- renderStartMeta,
1912
- renderError,
1913
- renderErrorMeta,
1914
- generateBundle,
1915
- generateBundleMeta,
1916
- writeBundle,
1917
- writeBundleMeta,
1918
- closeBundle,
1919
- closeBundleMeta,
1920
- banner,
1921
- bannerMeta,
1922
- footer,
1923
- footerMeta,
1924
- intro,
1925
- introMeta,
1926
- outro,
1927
- outroMeta,
1928
- watchChange,
1929
- watchChangeMeta,
1930
- closeWatcher,
1931
- closeWatcherMeta,
1932
- hookUsage
1933
- });
1934
- }
1935
- function wrapHandlers(plugin) {
1936
- for (const hookName of [
1937
- "buildStart",
1938
- "resolveId",
1939
- "resolveDynamicImport",
1940
- "buildEnd",
1941
- "transform",
1942
- "moduleParsed",
1943
- "load",
1944
- "renderChunk",
1945
- "augmentChunkHash",
1946
- "renderStart",
1947
- "renderError",
1948
- "generateBundle",
1949
- "writeBundle",
1950
- "closeBundle",
1951
- "banner",
1952
- "footer",
1953
- "intro",
1954
- "outro",
1955
- "watchChange",
1956
- "closeWatcher"
1957
- ]) {
1958
- const handler = plugin[hookName];
1959
- if (handler) plugin[hookName] = async (...args) => {
1960
- try {
1961
- return await handler(...args);
1962
- } catch (e) {
1963
- return error(logPluginError(e, plugin.name, {
1964
- hook: hookName,
1965
- id: hookName === "transform" ? args[2] : void 0
1966
- }));
1967
- }
1968
- };
1969
- }
1970
- return plugin;
1971
- }
1972
- //#endregion
1973
- //#region src/utils/normalize-transform-options.ts
1974
- /**
1975
- * Normalizes transform options by extracting `define`, `inject`, and `dropLabels` separately from OXC transform options.
1976
- *
1977
- * Prioritizes values from `transform.define`, `transform.inject`, and `transform.dropLabels` over deprecated top-level options.
1978
- */
1979
- function normalizeTransformOptions(inputOptions) {
1980
- const transform = inputOptions.transform;
1981
- const define = transform?.define ? Object.entries(transform.define) : void 0;
1982
- const inject = transform?.inject;
1983
- const dropLabels = transform?.dropLabels;
1984
- let oxcTransformOptions;
1985
- if (transform) {
1986
- const { define: _define, inject: _inject, dropLabels: _dropLabels, ...rest } = transform;
1987
- if (Object.keys(rest).length > 0) {
1988
- if (rest.jsx === false) rest.jsx = "disable";
1989
- oxcTransformOptions = rest;
1990
- }
1991
- }
1992
- return {
1993
- define,
1994
- inject,
1995
- dropLabels,
1996
- oxcTransformOptions
1997
- };
1998
- }
1999
- //#endregion
2000
- //#region src/utils/bindingify-input-options.ts
2001
- function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
2002
- const plugins = rawPlugins.map((plugin) => {
2003
- if ("_parallel" in plugin) return;
2004
- if (plugin instanceof BuiltinPlugin) switch (plugin.name) {
2005
- case "builtin:vite-manifest": return bindingifyManifestPlugin(plugin, pluginContextData);
2006
- default: return bindingifyBuiltInPlugin(plugin);
2007
- }
2008
- return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
2009
- });
2010
- const normalizedTransform = normalizeTransformOptions(inputOptions);
2011
- return {
2012
- input: bindingifyInput(inputOptions.input),
2013
- plugins,
2014
- cwd: inputOptions.cwd ?? process.cwd(),
2015
- external: bindingifyExternal(inputOptions.external),
2016
- resolve: bindingifyResolve(inputOptions.resolve),
2017
- platform: inputOptions.platform,
2018
- shimMissingExports: inputOptions.shimMissingExports,
2019
- logLevel: bindingifyLogLevel(logLevel),
2020
- onLog,
2021
- treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
2022
- moduleTypes: inputOptions.moduleTypes,
2023
- define: normalizedTransform.define,
2024
- inject: bindingifyInject(normalizedTransform.inject),
2025
- experimental: bindingifyExperimental(inputOptions.experimental),
2026
- profilerNames: outputOptions.generatedCode?.profilerNames,
2027
- transform: normalizedTransform.oxcTransformOptions,
2028
- watch: bindingifyWatch(inputOptions.watch),
2029
- dropLabels: normalizedTransform.dropLabels,
2030
- keepNames: outputOptions.keepNames,
2031
- checks: inputOptions.checks,
2032
- deferSyncScanData: () => {
2033
- let ret = [];
2034
- pluginContextData.moduleOptionMap.forEach((value, key) => {
2035
- if (value.invalidate) ret.push({
2036
- id: key,
2037
- sideEffects: value.moduleSideEffects ?? void 0
2038
- });
2039
- });
2040
- return ret;
2041
- },
2042
- makeAbsoluteExternalsRelative: bindingifyMakeAbsoluteExternalsRelative(inputOptions.makeAbsoluteExternalsRelative),
2043
- devtools: inputOptions.devtools,
2044
- invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
2045
- preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
2046
- optimization: inputOptions.optimization,
2047
- context: inputOptions.context,
2048
- tsconfig: inputOptions.resolve?.tsconfigFilename ?? inputOptions.tsconfig
2049
- };
2050
- }
2051
- function bindingifyDevMode(devMode) {
2052
- if (devMode) {
2053
- if (typeof devMode === "boolean") return devMode ? {} : void 0;
2054
- return devMode;
2055
- }
2056
- }
2057
- function bindingifyAttachDebugInfo(attachDebugInfo) {
2058
- switch (attachDebugInfo) {
2059
- case void 0: return;
2060
- case "full": return import_binding.BindingAttachDebugInfo.Full;
2061
- case "simple": return import_binding.BindingAttachDebugInfo.Simple;
2062
- case "none": return import_binding.BindingAttachDebugInfo.None;
2063
- }
2064
- }
2065
- function bindingifyExternal(external) {
2066
- if (external) {
2067
- if (typeof external === "function") return (id, importer, isResolved) => {
2068
- if (id.startsWith("\0")) return false;
2069
- return external(id, importer, isResolved) ?? false;
2070
- };
2071
- return arraify(external);
2072
- }
2073
- }
2074
- function bindingifyExperimental(experimental) {
2075
- let chunkModulesOrder = import_binding.BindingChunkModuleOrderBy.ExecOrder;
2076
- if (experimental?.chunkModulesOrder) switch (experimental.chunkModulesOrder) {
2077
- case "exec-order":
2078
- chunkModulesOrder = import_binding.BindingChunkModuleOrderBy.ExecOrder;
2079
- break;
2080
- case "module-id":
2081
- chunkModulesOrder = import_binding.BindingChunkModuleOrderBy.ModuleId;
2082
- break;
2083
- default: throw new Error(`Unexpected chunkModulesOrder: ${experimental.chunkModulesOrder}`);
2084
- }
2085
- return {
2086
- viteMode: experimental?.viteMode,
2087
- resolveNewUrlToAsset: experimental?.resolveNewUrlToAsset,
2088
- devMode: bindingifyDevMode(experimental?.devMode),
2089
- attachDebugInfo: bindingifyAttachDebugInfo(experimental?.attachDebugInfo),
2090
- chunkModulesOrder,
2091
- chunkImportMap: experimental?.chunkImportMap,
2092
- onDemandWrapping: experimental?.onDemandWrapping,
2093
- incrementalBuild: experimental?.incrementalBuild,
2094
- nativeMagicString: experimental?.nativeMagicString,
2095
- chunkOptimization: experimental?.chunkOptimization,
2096
- lazyBarrel: experimental?.lazyBarrel
2097
- };
2098
- }
2099
- function bindingifyResolve(resolve) {
2100
- const yarnPnp = typeof process === "object" && !!process.versions?.pnp;
2101
- if (resolve) {
2102
- const { alias, extensionAlias, ...rest } = resolve;
2103
- return {
2104
- alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
2105
- find: name,
2106
- replacements: replacement === false ? [void 0] : arraify(replacement)
2107
- })) : void 0,
2108
- extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
2109
- target: name,
2110
- replacements: value
2111
- })) : void 0,
2112
- yarnPnp,
2113
- ...rest
2114
- };
2115
- } else return { yarnPnp };
2116
- }
2117
- function bindingifyInject(inject) {
2118
- if (inject) return Object.entries(inject).map(([alias, item]) => {
2119
- if (Array.isArray(item)) {
2120
- if (item[1] === "*") return {
2121
- tagNamespace: true,
2122
- alias,
2123
- from: item[0]
2124
- };
2125
- return {
2126
- tagNamed: true,
2127
- alias,
2128
- from: item[0],
2129
- imported: item[1]
2130
- };
2131
- } else return {
2132
- tagNamed: true,
2133
- imported: "default",
2134
- alias,
2135
- from: item
2136
- };
2137
- });
2138
- }
2139
- function bindingifyLogLevel(logLevel) {
2140
- switch (logLevel) {
2141
- case "silent": return import_binding.BindingLogLevel.Silent;
2142
- case "debug": return import_binding.BindingLogLevel.Debug;
2143
- case "warn": return import_binding.BindingLogLevel.Warn;
2144
- case "info": return import_binding.BindingLogLevel.Info;
2145
- default: throw new Error(`Unexpected log level: ${logLevel}`);
2146
- }
2147
- }
2148
- function bindingifyInput(input) {
2149
- if (input === void 0) return [];
2150
- if (typeof input === "string") return [{ import: input }];
2151
- if (Array.isArray(input)) return input.map((src) => ({ import: src }));
2152
- return Object.entries(input).map(([name, import_path]) => {
2153
- return {
2154
- name,
2155
- import: import_path
2156
- };
2157
- });
2158
- }
2159
- function bindingifyWatch(watch) {
2160
- if (watch) {
2161
- if (watch.notify) console.warn("The \"watch.notify\" option is deprecated. Please use \"watch.watcher\" instead.");
2162
- const watcher = {
2163
- ...watch.notify,
2164
- ...watch.watcher
2165
- };
2166
- return {
2167
- buildDelay: watch.buildDelay,
2168
- skipWrite: watch.skipWrite,
2169
- usePolling: watcher.usePolling,
2170
- pollInterval: watcher.pollInterval,
2171
- compareContentsForPolling: watcher.compareContentsForPolling,
2172
- useDebounce: watcher.useDebounce,
2173
- debounceDelay: watcher.debounceDelay,
2174
- debounceTickRate: watcher.debounceTickRate,
2175
- include: normalizedStringOrRegex(watch.include),
2176
- exclude: normalizedStringOrRegex(watch.exclude),
2177
- onInvalidate: (...args) => watch.onInvalidate?.(...args)
2178
- };
2179
- }
2180
- }
2181
- function bindingifyTreeshakeOptions(config) {
2182
- if (config === false) return;
2183
- if (config === true || config === void 0) return { moduleSideEffects: true };
2184
- let normalizedConfig = {
2185
- moduleSideEffects: true,
2186
- annotations: config.annotations,
2187
- manualPureFunctions: config.manualPureFunctions,
2188
- unknownGlobalSideEffects: config.unknownGlobalSideEffects,
2189
- invalidImportSideEffects: config.invalidImportSideEffects,
2190
- commonjs: config.commonjs
2191
- };
2192
- switch (config.propertyReadSideEffects) {
2193
- case "always":
2194
- normalizedConfig.propertyReadSideEffects = import_binding.BindingPropertyReadSideEffects.Always;
2195
- break;
2196
- case false:
2197
- normalizedConfig.propertyReadSideEffects = import_binding.BindingPropertyReadSideEffects.False;
2198
- break;
2199
- default:
2200
- }
2201
- switch (config.propertyWriteSideEffects) {
2202
- case "always":
2203
- normalizedConfig.propertyWriteSideEffects = import_binding.BindingPropertyWriteSideEffects.Always;
2204
- break;
2205
- case false:
2206
- normalizedConfig.propertyWriteSideEffects = import_binding.BindingPropertyWriteSideEffects.False;
2207
- break;
2208
- default:
2209
- }
2210
- if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
2211
- else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
2212
- external: true,
2213
- sideEffects: false
2214
- }, {
2215
- external: false,
2216
- sideEffects: true
2217
- }];
2218
- else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
2219
- return normalizedConfig;
2220
- }
2221
- function bindingifyMakeAbsoluteExternalsRelative(makeAbsoluteExternalsRelative) {
2222
- if (makeAbsoluteExternalsRelative === "ifRelativeSource") return { type: "IfRelativeSource" };
2223
- if (typeof makeAbsoluteExternalsRelative === "boolean") return {
2224
- type: "Bool",
2225
- field0: makeAbsoluteExternalsRelative
2226
- };
2227
- }
2228
- function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
2229
- if (preserveEntrySignatures == void 0) return;
2230
- else if (typeof preserveEntrySignatures === "string") return {
2231
- type: "String",
2232
- field0: preserveEntrySignatures
2233
- };
2234
- else return {
2235
- type: "Bool",
2236
- field0: preserveEntrySignatures
2237
- };
2238
- }
2239
- //#endregion
2240
- export { version as C, description as S, LOG_LEVEL_INFO as _, transformModuleInfo as a, RUNTIME_MODULE_ID as b, __decorate as c, PlainObjectLike as d, MinimalPluginContextImpl as f, LOG_LEVEL_ERROR as g, LOG_LEVEL_DEBUG as h, PluginContextData as i, transformAssetSource as l, normalizeLog as m, bindingifyPlugin as n, transformToRollupOutput as o, normalizeHook as p, RolldownMagicString as r, transformRenderedChunk as s, bindingifyInputOptions as t, lazyProp as u, LOG_LEVEL_WARN as v, VERSION as x, logLevelPriority as y };