@qpqjs/user-script 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/README.md +9 -2
  2. package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.d.ts +1 -0
  3. package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.js +69 -0
  4. package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.js.map +1 -0
  5. package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.d.ts +3 -0
  6. package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.js +20 -0
  7. package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.js.map +1 -0
  8. package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.d.ts +1 -0
  9. package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.js +79 -0
  10. package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.js.map +1 -0
  11. package/lib/commonjs/actionProcessor/index.d.ts +4 -0
  12. package/lib/commonjs/actionProcessor/index.js +21 -0
  13. package/lib/commonjs/actionProcessor/index.js.map +1 -0
  14. package/lib/commonjs/actionProcessor/logic/BuiltUserScript.d.ts +4 -0
  15. package/lib/commonjs/actionProcessor/logic/BuiltUserScript.js +3 -0
  16. package/lib/commonjs/actionProcessor/logic/BuiltUserScript.js.map +1 -0
  17. package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.d.ts +5 -0
  18. package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js +9 -0
  19. package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js.map +1 -0
  20. package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.d.ts +10 -0
  21. package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.js +22 -0
  22. package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.js.map +1 -0
  23. package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.d.ts +5 -0
  24. package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.js +3 -0
  25. package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.js.map +1 -0
  26. package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.d.ts +8 -0
  27. package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.js +30 -0
  28. package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.js.map +1 -0
  29. package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.d.ts +9 -0
  30. package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.js +53 -0
  31. package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.js.map +1 -0
  32. package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.d.ts +3 -0
  33. package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.js +9 -0
  34. package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.js.map +1 -0
  35. package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.d.ts +9 -0
  36. package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.js +41 -0
  37. package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.js.map +1 -0
  38. package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.d.ts +8 -0
  39. package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.js +148 -0
  40. package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.js.map +1 -0
  41. package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.d.ts +7 -0
  42. package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.js +20 -0
  43. package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.js.map +1 -0
  44. package/lib/commonjs/actionProcessor/logic/index.d.ts +12 -0
  45. package/lib/commonjs/actionProcessor/logic/index.js +29 -0
  46. package/lib/commonjs/actionProcessor/logic/index.js.map +1 -0
  47. package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.d.ts +5 -0
  48. package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.js +13 -0
  49. package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.js.map +1 -0
  50. package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.d.ts +3 -0
  51. package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.js +23 -0
  52. package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.js.map +1 -0
  53. package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.d.ts +2 -0
  54. package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.js +6 -0
  55. package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.js.map +1 -0
  56. package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.d.ts +2 -0
  57. package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.js +6 -0
  58. package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.js.map +1 -0
  59. package/lib/commonjs/build/UserScriptBuildError.d.ts +12 -0
  60. package/lib/commonjs/build/UserScriptBuildError.js +26 -0
  61. package/lib/commonjs/build/UserScriptBuildError.js.map +1 -0
  62. package/lib/commonjs/build/UserScriptBuildResult.d.ts +4 -0
  63. package/lib/commonjs/build/UserScriptBuildResult.js +3 -0
  64. package/lib/commonjs/build/UserScriptBuildResult.js.map +1 -0
  65. package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.d.ts +1 -0
  66. package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.js +6 -0
  67. package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.js.map +1 -0
  68. package/lib/commonjs/build/__fixtures__/basic/src/main.d.ts +4 -0
  69. package/lib/commonjs/build/__fixtures__/basic/src/main.js +17 -0
  70. package/lib/commonjs/build/__fixtures__/basic/src/main.js.map +1 -0
  71. package/lib/commonjs/build/__fixtures__/builtin/src/main.d.ts +1 -0
  72. package/lib/commonjs/build/__fixtures__/builtin/src/main.js +7 -0
  73. package/lib/commonjs/build/__fixtures__/builtin/src/main.js.map +1 -0
  74. package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.d.ts +1 -0
  75. package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.js +6 -0
  76. package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.js.map +1 -0
  77. package/lib/commonjs/build/__fixtures__/nonFunction/src/main.d.ts +2 -0
  78. package/lib/commonjs/build/__fixtures__/nonFunction/src/main.js +7 -0
  79. package/lib/commonjs/build/__fixtures__/nonFunction/src/main.js.map +1 -0
  80. package/lib/commonjs/build/assertUserScriptExports.d.ts +6 -0
  81. package/lib/commonjs/build/assertUserScriptExports.js +20 -0
  82. package/lib/commonjs/build/assertUserScriptExports.js.map +1 -0
  83. package/lib/commonjs/build/buildUserScript.d.ts +15 -0
  84. package/lib/commonjs/build/buildUserScript.js +55 -0
  85. package/lib/commonjs/build/buildUserScript.js.map +1 -0
  86. package/lib/commonjs/build/checkUserScriptOutput.d.ts +7 -0
  87. package/lib/commonjs/build/checkUserScriptOutput.js +17 -0
  88. package/lib/commonjs/build/checkUserScriptOutput.js.map +1 -0
  89. package/lib/commonjs/build/createUserScriptExternals.d.ts +11 -0
  90. package/lib/commonjs/build/createUserScriptExternals.js +34 -0
  91. package/lib/commonjs/build/createUserScriptExternals.js.map +1 -0
  92. package/lib/commonjs/build/getUserScriptRspackConfig.d.ts +15 -0
  93. package/lib/commonjs/build/getUserScriptRspackConfig.js +49 -0
  94. package/lib/commonjs/build/getUserScriptRspackConfig.js.map +1 -0
  95. package/lib/commonjs/build/index.d.ts +13 -0
  96. package/lib/commonjs/build/index.js +30 -0
  97. package/lib/commonjs/build/index.js.map +1 -0
  98. package/lib/commonjs/build/loadRspackModule.d.ts +8 -0
  99. package/lib/commonjs/build/loadRspackModule.js +51 -0
  100. package/lib/commonjs/build/loadRspackModule.js.map +1 -0
  101. package/lib/commonjs/build/resolveUserScriptEntry.d.ts +2 -0
  102. package/lib/commonjs/build/resolveUserScriptEntry.js +20 -0
  103. package/lib/commonjs/build/resolveUserScriptEntry.js.map +1 -0
  104. package/lib/commonjs/build/runUserScriptRspack.d.ts +7 -0
  105. package/lib/commonjs/build/runUserScriptRspack.js +32 -0
  106. package/lib/commonjs/build/runUserScriptRspack.js.map +1 -0
  107. package/lib/commonjs/build/userScriptTsRule.d.ts +6 -0
  108. package/lib/commonjs/build/userScriptTsRule.js +21 -0
  109. package/lib/commonjs/build/userScriptTsRule.js.map +1 -0
  110. package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.d.ts +5 -0
  111. package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js +9 -0
  112. package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js.map +1 -0
  113. package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.d.ts +2 -0
  114. package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.js +6 -0
  115. package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.js.map +1 -0
  116. package/lib/commonjs/config/defineUserScriptBuilder.d.ts +7 -0
  117. package/lib/commonjs/config/defineUserScriptBuilder.js +16 -0
  118. package/lib/commonjs/config/defineUserScriptBuilder.js.map +1 -0
  119. package/lib/commonjs/config/getUserScriptBuilderApiLayer.d.ts +7 -0
  120. package/lib/commonjs/config/getUserScriptBuilderApiLayer.js +18 -0
  121. package/lib/commonjs/config/getUserScriptBuilderApiLayer.js.map +1 -0
  122. package/lib/commonjs/config/getUserScriptBuilderLayerDir.d.ts +6 -0
  123. package/lib/commonjs/config/getUserScriptBuilderLayerDir.js +33 -0
  124. package/lib/commonjs/config/getUserScriptBuilderLayerDir.js.map +1 -0
  125. package/lib/commonjs/config/index.d.ts +5 -0
  126. package/lib/commonjs/config/index.js +22 -0
  127. package/lib/commonjs/config/index.js.map +1 -0
  128. package/lib/commonjs/index.d.ts +3 -0
  129. package/lib/commonjs/index.js +20 -0
  130. package/lib/commonjs/index.js.map +1 -0
  131. package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.d.ts +1 -0
  132. package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.js +56 -0
  133. package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.js.map +1 -0
  134. package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.d.ts +3 -0
  135. package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.js +8 -0
  136. package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.js.map +1 -0
  137. package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.d.ts +1 -0
  138. package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.js +66 -0
  139. package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.js.map +1 -0
  140. package/lib/esm/actionProcessor/index.d.ts +4 -0
  141. package/lib/esm/actionProcessor/index.js +5 -0
  142. package/lib/esm/actionProcessor/index.js.map +1 -0
  143. package/lib/esm/actionProcessor/logic/BuiltUserScript.d.ts +4 -0
  144. package/lib/esm/actionProcessor/logic/BuiltUserScript.js +2 -0
  145. package/lib/esm/actionProcessor/logic/BuiltUserScript.js.map +1 -0
  146. package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.d.ts +5 -0
  147. package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js +6 -0
  148. package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js.map +1 -0
  149. package/lib/esm/actionProcessor/logic/UserScriptArchiveError.d.ts +10 -0
  150. package/lib/esm/actionProcessor/logic/UserScriptArchiveError.js +19 -0
  151. package/lib/esm/actionProcessor/logic/UserScriptArchiveError.js.map +1 -0
  152. package/lib/esm/actionProcessor/logic/UserScriptSourceFile.d.ts +5 -0
  153. package/lib/esm/actionProcessor/logic/UserScriptSourceFile.js +2 -0
  154. package/lib/esm/actionProcessor/logic/UserScriptSourceFile.js.map +1 -0
  155. package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.d.ts +8 -0
  156. package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.js +27 -0
  157. package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.js.map +1 -0
  158. package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.d.ts +9 -0
  159. package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.js +50 -0
  160. package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.js.map +1 -0
  161. package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.d.ts +3 -0
  162. package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.js +6 -0
  163. package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.js.map +1 -0
  164. package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.d.ts +9 -0
  165. package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.js +25 -0
  166. package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.js.map +1 -0
  167. package/lib/esm/actionProcessor/logic/extractUserScriptZip.d.ts +8 -0
  168. package/lib/esm/actionProcessor/logic/extractUserScriptZip.js +132 -0
  169. package/lib/esm/actionProcessor/logic/extractUserScriptZip.js.map +1 -0
  170. package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.d.ts +7 -0
  171. package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.js +16 -0
  172. package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.js.map +1 -0
  173. package/lib/esm/actionProcessor/logic/index.d.ts +12 -0
  174. package/lib/esm/actionProcessor/logic/index.js +13 -0
  175. package/lib/esm/actionProcessor/logic/index.js.map +1 -0
  176. package/lib/esm/actionProcessor/logic/isSafeProjectPath.d.ts +5 -0
  177. package/lib/esm/actionProcessor/logic/isSafeProjectPath.js +9 -0
  178. package/lib/esm/actionProcessor/logic/isSafeProjectPath.js.map +1 -0
  179. package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.d.ts +3 -0
  180. package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.js +16 -0
  181. package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.js.map +1 -0
  182. package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.d.ts +2 -0
  183. package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.js +3 -0
  184. package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.js.map +1 -0
  185. package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.d.ts +2 -0
  186. package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.js +3 -0
  187. package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.js.map +1 -0
  188. package/lib/esm/build/UserScriptBuildError.d.ts +12 -0
  189. package/lib/esm/build/UserScriptBuildError.js +23 -0
  190. package/lib/esm/build/UserScriptBuildError.js.map +1 -0
  191. package/lib/esm/build/UserScriptBuildResult.d.ts +4 -0
  192. package/lib/esm/build/UserScriptBuildResult.js +2 -0
  193. package/lib/esm/build/UserScriptBuildResult.js.map +1 -0
  194. package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.d.ts +1 -0
  195. package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.js +2 -0
  196. package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.js.map +1 -0
  197. package/lib/esm/build/__fixtures__/basic/src/main.d.ts +4 -0
  198. package/lib/esm/build/__fixtures__/basic/src/main.js +11 -0
  199. package/lib/esm/build/__fixtures__/basic/src/main.js.map +1 -0
  200. package/lib/esm/build/__fixtures__/builtin/src/main.d.ts +1 -0
  201. package/lib/esm/build/__fixtures__/builtin/src/main.js +3 -0
  202. package/lib/esm/build/__fixtures__/builtin/src/main.js.map +1 -0
  203. package/lib/esm/build/__fixtures__/noEntry/src/notMain.d.ts +1 -0
  204. package/lib/esm/build/__fixtures__/noEntry/src/notMain.js +2 -0
  205. package/lib/esm/build/__fixtures__/noEntry/src/notMain.js.map +1 -0
  206. package/lib/esm/build/__fixtures__/nonFunction/src/main.d.ts +2 -0
  207. package/lib/esm/build/__fixtures__/nonFunction/src/main.js +3 -0
  208. package/lib/esm/build/__fixtures__/nonFunction/src/main.js.map +1 -0
  209. package/lib/esm/build/assertUserScriptExports.d.ts +6 -0
  210. package/lib/esm/build/assertUserScriptExports.js +16 -0
  211. package/lib/esm/build/assertUserScriptExports.js.map +1 -0
  212. package/lib/esm/build/buildUserScript.d.ts +15 -0
  213. package/lib/esm/build/buildUserScript.js +39 -0
  214. package/lib/esm/build/buildUserScript.js.map +1 -0
  215. package/lib/esm/build/checkUserScriptOutput.d.ts +7 -0
  216. package/lib/esm/build/checkUserScriptOutput.js +10 -0
  217. package/lib/esm/build/checkUserScriptOutput.js.map +1 -0
  218. package/lib/esm/build/createUserScriptExternals.d.ts +11 -0
  219. package/lib/esm/build/createUserScriptExternals.js +30 -0
  220. package/lib/esm/build/createUserScriptExternals.js.map +1 -0
  221. package/lib/esm/build/getUserScriptRspackConfig.d.ts +15 -0
  222. package/lib/esm/build/getUserScriptRspackConfig.js +42 -0
  223. package/lib/esm/build/getUserScriptRspackConfig.js.map +1 -0
  224. package/lib/esm/build/index.d.ts +13 -0
  225. package/lib/esm/build/index.js +14 -0
  226. package/lib/esm/build/index.js.map +1 -0
  227. package/lib/esm/build/loadRspackModule.d.ts +8 -0
  228. package/lib/esm/build/loadRspackModule.js +38 -0
  229. package/lib/esm/build/loadRspackModule.js.map +1 -0
  230. package/lib/esm/build/resolveUserScriptEntry.d.ts +2 -0
  231. package/lib/esm/build/resolveUserScriptEntry.js +13 -0
  232. package/lib/esm/build/resolveUserScriptEntry.js.map +1 -0
  233. package/lib/esm/build/runUserScriptRspack.d.ts +7 -0
  234. package/lib/esm/build/runUserScriptRspack.js +19 -0
  235. package/lib/esm/build/runUserScriptRspack.js.map +1 -0
  236. package/lib/esm/build/userScriptTsRule.d.ts +6 -0
  237. package/lib/esm/build/userScriptTsRule.js +17 -0
  238. package/lib/esm/build/userScriptTsRule.js.map +1 -0
  239. package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.d.ts +5 -0
  240. package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js +6 -0
  241. package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js.map +1 -0
  242. package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.d.ts +2 -0
  243. package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.js +3 -0
  244. package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.js.map +1 -0
  245. package/lib/esm/config/defineUserScriptBuilder.d.ts +7 -0
  246. package/lib/esm/config/defineUserScriptBuilder.js +12 -0
  247. package/lib/esm/config/defineUserScriptBuilder.js.map +1 -0
  248. package/lib/esm/config/getUserScriptBuilderApiLayer.d.ts +7 -0
  249. package/lib/esm/config/getUserScriptBuilderApiLayer.js +14 -0
  250. package/lib/esm/config/getUserScriptBuilderApiLayer.js.map +1 -0
  251. package/lib/esm/config/getUserScriptBuilderLayerDir.d.ts +6 -0
  252. package/lib/esm/config/getUserScriptBuilderLayerDir.js +26 -0
  253. package/lib/esm/config/getUserScriptBuilderLayerDir.js.map +1 -0
  254. package/lib/esm/config/index.d.ts +5 -0
  255. package/lib/esm/config/index.js +6 -0
  256. package/lib/esm/config/index.js.map +1 -0
  257. package/lib/esm/index.d.ts +3 -0
  258. package/lib/esm/index.js +4 -0
  259. package/lib/esm/index.js.map +1 -0
  260. package/package.json +49 -3
@@ -0,0 +1,132 @@
1
+ import fs from 'fs';
2
+ import { Transform } from 'node:stream';
3
+ import { pipeline } from 'node:stream/promises';
4
+ import path from 'path';
5
+ import yauzl from 'yauzl';
6
+ import { isSafeProjectPath } from './isSafeProjectPath';
7
+ import { USER_SCRIPT_SOURCE_LIMITS } from './USER_SCRIPT_SOURCE_LIMITS';
8
+ import { UserScriptArchiveError, UserScriptArchiveErrorCode } from './UserScriptArchiveError';
9
+ const REFUSED_DIRECTORY = 'node_modules';
10
+ const SYMLINK_MODE = 0o120000;
11
+ const FILE_TYPE_MASK = 0o170000;
12
+ // Unix mode lives in the high 16 bits of the external attributes; zips made on other
13
+ // systems leave it zero, which reads as "not a symlink".
14
+ const isSymlinkEntry = (entry) => ((entry.externalFileAttributes >>> 16) & FILE_TYPE_MASK) === SYMLINK_MODE;
15
+ // With decodeStrings off, yauzl hands names over raw so it does not apply its own path
16
+ // rules before ours.
17
+ const entryName = (entry) => (Buffer.isBuffer(entry.fileName) ? entry.fileName.toString('utf8') : String(entry.fileName));
18
+ const isDirectoryEntry = (name) => name.endsWith('/');
19
+ const openZip = (zip) => new Promise((resolve, reject) => {
20
+ // Header sizes are never consulted: the byte cap on the inflated stream is the only
21
+ // authority, so yauzl's own size validation is off rather than a second, trusted, rule.
22
+ yauzl.fromBuffer(zip, { lazyEntries: true, decodeStrings: false, validateEntrySizes: false }, (error, zipFile) => error ? reject(error) : resolve(zipFile));
23
+ });
24
+ const readEntries = (zipFile, onEntry) => new Promise((resolve, reject) => {
25
+ zipFile.on('error', reject);
26
+ zipFile.on('end', resolve);
27
+ zipFile.on('entry', (entry) => {
28
+ // A rule that throws synchronously must still reject here, not escape yauzl's
29
+ // event emitter where it would be lost and leave the zip hanging.
30
+ Promise.resolve()
31
+ .then(() => onEntry(entry))
32
+ .then(() => zipFile.readEntry(), (error) => {
33
+ zipFile.close();
34
+ reject(error);
35
+ });
36
+ });
37
+ zipFile.readEntry();
38
+ });
39
+ const openEntryStream = (zipFile, entry) => new Promise((resolve, reject) => {
40
+ zipFile.openReadStream(entry, (error, stream) => (error ? reject(error) : resolve(stream)));
41
+ });
42
+ const tooLarge = (message) => new UserScriptArchiveError(UserScriptArchiveErrorCode.SourceTooLarge, message);
43
+ const unsafe = (message) => new UserScriptArchiveError(UserScriptArchiveErrorCode.UnsafeArchiveEntry, message);
44
+ const invalid = (message) => new UserScriptArchiveError(UserScriptArchiveErrorCode.InvalidArchive, message);
45
+ // Counts the bytes that really come out of the inflater and fails the pipeline the moment
46
+ // the project cap is crossed, so a zip that lies about its sizes cannot fill the disk.
47
+ const createByteCap = (counter, onExceeded) => new Transform({
48
+ transform(chunk, _encoding, callback) {
49
+ counter.total += chunk.length;
50
+ if (counter.total > USER_SCRIPT_SOURCE_LIMITS.maxBytes) {
51
+ callback(onExceeded());
52
+ return;
53
+ }
54
+ callback(null, chunk);
55
+ },
56
+ });
57
+ // Accepts the project at the zip root (anything under `src/`), or wrapped in exactly one
58
+ // top-level folder (how most tools zip a directory): when nothing is under `src/` at the
59
+ // root, every file shares the same first segment, and none sits at the root, that segment
60
+ // is stripped. A root `src/` always wins, so a project with only `src/` is never stripped.
61
+ const stripCommonFolder = (names) => {
62
+ if (names.length === 0 || names.some((name) => name.startsWith('src/')))
63
+ return 0;
64
+ const firstSegments = new Set(names.map((name) => name.split('/')[0]));
65
+ const allNested = names.every((name) => name.includes('/'));
66
+ return firstSegments.size === 1 && allNested ? [...firstSegments][0].length + 1 : 0;
67
+ };
68
+ const planEntries = async (zip) => {
69
+ const files = [];
70
+ const zipFile = await openZip(zip);
71
+ await readEntries(zipFile, (entry) => {
72
+ const name = entryName(entry);
73
+ if (isDirectoryEntry(name))
74
+ return;
75
+ if (entry.isEncrypted())
76
+ throw invalid(`entry [${name}] is encrypted`);
77
+ if (isSymlinkEntry(entry))
78
+ throw unsafe(`entry [${name}] is a symlink`);
79
+ if (!isSafeProjectPath(name))
80
+ throw unsafe(`entry [${name}] is not a plain relative path inside the project`);
81
+ if (name.split('/').includes(REFUSED_DIRECTORY)) {
82
+ throw tooLarge(`entry [${name}] is inside a ${REFUSED_DIRECTORY} folder; dependencies are not supported in a user script yet`);
83
+ }
84
+ files.push({ entry, relativePath: name });
85
+ if (files.length > USER_SCRIPT_SOURCE_LIMITS.maxFiles) {
86
+ throw tooLarge(`the archive holds more than ${USER_SCRIPT_SOURCE_LIMITS.maxFiles} files`);
87
+ }
88
+ });
89
+ const strip = stripCommonFolder(files.map((file) => file.relativePath));
90
+ return files.map((file) => ({ ...file, relativePath: file.relativePath.slice(strip) }));
91
+ };
92
+ /**
93
+ * Unpacks a user-controlled zip into the project directory under the same rules as a
94
+ * directory build: plain relative paths only, no symlinks, no node_modules, at most
95
+ * USER_SCRIPT_SOURCE_LIMITS files and unpacked bytes counted as they are written (the
96
+ * sizes in the zip's headers are never trusted). Directory entries are ignored; folders
97
+ * come from file paths. Returns the project-relative paths written.
98
+ */
99
+ export const extractUserScriptZip = async (zip, projectDir) => {
100
+ let planned;
101
+ try {
102
+ planned = await planEntries(zip);
103
+ }
104
+ catch (error) {
105
+ if (error instanceof UserScriptArchiveError)
106
+ throw error;
107
+ throw invalid(`cannot read the archive: ${error instanceof Error ? error.message : String(error)}`);
108
+ }
109
+ const counter = { total: 0 };
110
+ const written = [];
111
+ const zipFile = await openZip(zip);
112
+ const plannedByEntryName = new Map(planned.map((file) => [entryName(file.entry), file.relativePath]));
113
+ try {
114
+ await readEntries(zipFile, async (entry) => {
115
+ const relativePath = plannedByEntryName.get(entryName(entry));
116
+ if (relativePath === undefined)
117
+ return;
118
+ const target = path.join(projectDir, ...relativePath.split('/'));
119
+ fs.mkdirSync(path.dirname(target), { recursive: true });
120
+ const stream = await openEntryStream(zipFile, entry);
121
+ await pipeline(stream, createByteCap(counter, () => tooLarge(`the archive unpacks to more than ${USER_SCRIPT_SOURCE_LIMITS.maxBytes} bytes`)), fs.createWriteStream(target));
122
+ written.push(relativePath);
123
+ });
124
+ }
125
+ catch (error) {
126
+ if (error instanceof UserScriptArchiveError)
127
+ throw error;
128
+ throw invalid(`cannot unpack the archive: ${error instanceof Error ? error.message : String(error)}`);
129
+ }
130
+ return written;
131
+ };
132
+ //# sourceMappingURL=extractUserScriptZip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractUserScriptZip.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/extractUserScriptZip.ts"],"names":[],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import fs from 'fs';\nimport { Readable, Transform } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport path from 'path';\nimport yauzl, { Entry, ZipFile } from 'yauzl';\n\nimport { isSafeProjectPath } from './isSafeProjectPath';\nimport { USER_SCRIPT_SOURCE_LIMITS } from './USER_SCRIPT_SOURCE_LIMITS';\nimport { UserScriptArchiveError, UserScriptArchiveErrorCode } from './UserScriptArchiveError';\n\nconst REFUSED_DIRECTORY = 'node_modules';\nconst SYMLINK_MODE = 0o120000;\nconst FILE_TYPE_MASK = 0o170000;\n\n// Unix mode lives in the high 16 bits of the external attributes; zips made on other\n// systems leave it zero, which reads as \"not a symlink\".\nconst isSymlinkEntry = (entry: Entry): boolean => ((entry.externalFileAttributes >>> 16) & FILE_TYPE_MASK) === SYMLINK_MODE;\n\n// With decodeStrings off, yauzl hands names over raw so it does not apply its own path\n// rules before ours.\nconst entryName = (entry: Entry): string => (Buffer.isBuffer(entry.fileName) ? entry.fileName.toString('utf8') : String(entry.fileName));\n\nconst isDirectoryEntry = (name: string): boolean => name.endsWith('/');\n\nconst openZip = (zip: Buffer): Promise<ZipFile> =>\n new Promise((resolve, reject) => {\n // Header sizes are never consulted: the byte cap on the inflated stream is the only\n // authority, so yauzl's own size validation is off rather than a second, trusted, rule.\n yauzl.fromBuffer(zip, { lazyEntries: true, decodeStrings: false, validateEntrySizes: false }, (error, zipFile) =>\n error ? reject(error) : resolve(zipFile),\n );\n });\n\nconst readEntries = (zipFile: ZipFile, onEntry: (entry: Entry) => Promise<void> | void): Promise<void> =>\n new Promise((resolve, reject) => {\n zipFile.on('error', reject);\n zipFile.on('end', resolve);\n zipFile.on('entry', (entry: Entry) => {\n // A rule that throws synchronously must still reject here, not escape yauzl's\n // event emitter where it would be lost and leave the zip hanging.\n Promise.resolve()\n .then(() => onEntry(entry))\n .then(\n () => zipFile.readEntry(),\n (error) => {\n zipFile.close();\n reject(error);\n },\n );\n });\n zipFile.readEntry();\n });\n\nconst openEntryStream = (zipFile: ZipFile, entry: Entry): Promise<Readable> =>\n new Promise((resolve, reject) => {\n zipFile.openReadStream(entry, (error, stream) => (error ? reject(error) : resolve(stream)));\n });\n\nconst tooLarge = (message: string): UserScriptArchiveError => new UserScriptArchiveError(UserScriptArchiveErrorCode.SourceTooLarge, message);\nconst unsafe = (message: string): UserScriptArchiveError => new UserScriptArchiveError(UserScriptArchiveErrorCode.UnsafeArchiveEntry, message);\nconst invalid = (message: string): UserScriptArchiveError => new UserScriptArchiveError(UserScriptArchiveErrorCode.InvalidArchive, message);\n\n// Counts the bytes that really come out of the inflater and fails the pipeline the moment\n// the project cap is crossed, so a zip that lies about its sizes cannot fill the disk.\nconst createByteCap = (counter: { total: number }, onExceeded: () => Error): Transform =>\n new Transform({\n transform(chunk: Buffer, _encoding, callback) {\n counter.total += chunk.length;\n if (counter.total > USER_SCRIPT_SOURCE_LIMITS.maxBytes) {\n callback(onExceeded());\n return;\n }\n callback(null, chunk);\n },\n });\n\ntype PlannedEntry = { entry: Entry; relativePath: string };\n\n// Accepts the project at the zip root (anything under `src/`), or wrapped in exactly one\n// top-level folder (how most tools zip a directory): when nothing is under `src/` at the\n// root, every file shares the same first segment, and none sits at the root, that segment\n// is stripped. A root `src/` always wins, so a project with only `src/` is never stripped.\nconst stripCommonFolder = (names: string[]): number => {\n if (names.length === 0 || names.some((name) => name.startsWith('src/'))) return 0;\n\n const firstSegments = new Set(names.map((name) => name.split('/')[0]));\n const allNested = names.every((name) => name.includes('/'));\n\n return firstSegments.size === 1 && allNested ? [...firstSegments][0].length + 1 : 0;\n};\n\nconst planEntries = async (zip: Buffer): Promise<PlannedEntry[]> => {\n const files: PlannedEntry[] = [];\n const zipFile = await openZip(zip);\n\n await readEntries(zipFile, (entry) => {\n const name = entryName(entry);\n if (isDirectoryEntry(name)) return;\n\n if (entry.isEncrypted()) throw invalid(`entry [${name}] is encrypted`);\n if (isSymlinkEntry(entry)) throw unsafe(`entry [${name}] is a symlink`);\n if (!isSafeProjectPath(name)) throw unsafe(`entry [${name}] is not a plain relative path inside the project`);\n if (name.split('/').includes(REFUSED_DIRECTORY)) {\n throw tooLarge(`entry [${name}] is inside a ${REFUSED_DIRECTORY} folder; dependencies are not supported in a user script yet`);\n }\n\n files.push({ entry, relativePath: name });\n if (files.length > USER_SCRIPT_SOURCE_LIMITS.maxFiles) {\n throw tooLarge(`the archive holds more than ${USER_SCRIPT_SOURCE_LIMITS.maxFiles} files`);\n }\n });\n\n const strip = stripCommonFolder(files.map((file) => file.relativePath));\n\n return files.map((file) => ({ ...file, relativePath: file.relativePath.slice(strip) }));\n};\n\n/**\n * Unpacks a user-controlled zip into the project directory under the same rules as a\n * directory build: plain relative paths only, no symlinks, no node_modules, at most\n * USER_SCRIPT_SOURCE_LIMITS files and unpacked bytes counted as they are written (the\n * sizes in the zip's headers are never trusted). Directory entries are ignored; folders\n * come from file paths. Returns the project-relative paths written.\n */\nexport const extractUserScriptZip = async (zip: Buffer, projectDir: string): Promise<string[]> => {\n let planned: PlannedEntry[];\n try {\n planned = await planEntries(zip);\n } catch (error) {\n if (error instanceof UserScriptArchiveError) throw error;\n throw invalid(`cannot read the archive: ${error instanceof Error ? error.message : String(error)}`);\n }\n\n const counter = { total: 0 };\n const written: string[] = [];\n const zipFile = await openZip(zip);\n const plannedByEntryName = new Map(planned.map((file) => [entryName(file.entry), file.relativePath]));\n\n try {\n await readEntries(zipFile, async (entry) => {\n const relativePath = plannedByEntryName.get(entryName(entry));\n if (relativePath === undefined) return;\n\n const target = path.join(projectDir, ...relativePath.split('/'));\n fs.mkdirSync(path.dirname(target), { recursive: true });\n\n const stream = await openEntryStream(zipFile, entry);\n await pipeline(\n stream,\n createByteCap(counter, () => tooLarge(`the archive unpacks to more than ${USER_SCRIPT_SOURCE_LIMITS.maxBytes} bytes`)),\n fs.createWriteStream(target),\n );\n written.push(relativePath);\n });\n } catch (error) {\n if (error instanceof UserScriptArchiveError) throw error;\n throw invalid(`cannot unpack the archive: ${error instanceof Error ? error.message : String(error)}`);\n }\n\n return written;\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import { UserScriptBuildErrorCode } from '../../build/UserScriptBuildError';
2
+ export type UserScriptBuildErrorCatalog = Record<'SourceNotFound' | 'BuildFailed' | 'OutputNotSingleFile' | 'NoExports' | 'NonFunctionExport', string>;
3
+ /**
4
+ * The action error type for a build failure. Codes map one to one, except that a missing
5
+ * entry is the caller's source being wrong, not the build, so it is SourceNotFound.
6
+ */
7
+ export declare const getUserScriptBuildErrorType: (code: UserScriptBuildErrorCode, errorType: UserScriptBuildErrorCatalog) => string;
@@ -0,0 +1,16 @@
1
+ import { UserScriptBuildErrorCode } from '../../build/UserScriptBuildError';
2
+ /**
3
+ * The action error type for a build failure. Codes map one to one, except that a missing
4
+ * entry is the caller's source being wrong, not the build, so it is SourceNotFound.
5
+ */
6
+ export const getUserScriptBuildErrorType = (code, errorType) => {
7
+ const byCode = {
8
+ [UserScriptBuildErrorCode.NoEntry]: errorType.SourceNotFound,
9
+ [UserScriptBuildErrorCode.BuildFailed]: errorType.BuildFailed,
10
+ [UserScriptBuildErrorCode.OutputNotSingleFile]: errorType.OutputNotSingleFile,
11
+ [UserScriptBuildErrorCode.NoExports]: errorType.NoExports,
12
+ [UserScriptBuildErrorCode.NonFunctionExport]: errorType.NonFunctionExport,
13
+ };
14
+ return byCode[code];
15
+ };
16
+ //# sourceMappingURL=getUserScriptBuildErrorType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUserScriptBuildErrorType.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/getUserScriptBuildErrorType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAQ5E;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAA8B,EAAE,SAAsC,EAAU,EAAE;IAC5H,MAAM,MAAM,GAA6C;QACvD,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,cAAc;QAC5D,CAAC,wBAAwB,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,WAAW;QAC7D,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,EAAE,SAAS,CAAC,mBAAmB;QAC7E,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS;QACzD,CAAC,wBAAwB,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC,iBAAiB;KAC1E,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import { UserScriptBuildErrorCode } from '../../build/UserScriptBuildError';\n\n// The error names a build action's catalog must carry for the build's own codes.\nexport type UserScriptBuildErrorCatalog = Record<\n 'SourceNotFound' | 'BuildFailed' | 'OutputNotSingleFile' | 'NoExports' | 'NonFunctionExport',\n string\n>;\n\n/**\n * The action error type for a build failure. Codes map one to one, except that a missing\n * entry is the caller's source being wrong, not the build, so it is SourceNotFound.\n */\nexport const getUserScriptBuildErrorType = (code: UserScriptBuildErrorCode, errorType: UserScriptBuildErrorCatalog): string => {\n const byCode: Record<UserScriptBuildErrorCode, string> = {\n [UserScriptBuildErrorCode.NoEntry]: errorType.SourceNotFound,\n [UserScriptBuildErrorCode.BuildFailed]: errorType.BuildFailed,\n [UserScriptBuildErrorCode.OutputNotSingleFile]: errorType.OutputNotSingleFile,\n [UserScriptBuildErrorCode.NoExports]: errorType.NoExports,\n [UserScriptBuildErrorCode.NonFunctionExport]: errorType.NonFunctionExport,\n };\n\n return byCode[code];\n};\n"]}
@@ -0,0 +1,12 @@
1
+ export * from './askUserScriptCheckPublishedOutput';
2
+ export * from './askUserScriptCollectSource';
3
+ export * from './askUserScriptPublishOutput';
4
+ export * from './buildUserScriptInTempDir';
5
+ export * from './BuiltUserScript';
6
+ export * from './extractUserScriptZip';
7
+ export * from './getUserScriptBuildErrorType';
8
+ export * from './isSafeProjectPath';
9
+ export * from './materialiseUserScriptSource';
10
+ export * from './USER_SCRIPT_SOURCE_LIMITS';
11
+ export * from './UserScriptArchiveError';
12
+ export * from './UserScriptSourceFile';
@@ -0,0 +1,13 @@
1
+ export * from './askUserScriptCheckPublishedOutput';
2
+ export * from './askUserScriptCollectSource';
3
+ export * from './askUserScriptPublishOutput';
4
+ export * from './buildUserScriptInTempDir';
5
+ export * from './BuiltUserScript';
6
+ export * from './extractUserScriptZip';
7
+ export * from './getUserScriptBuildErrorType';
8
+ export * from './isSafeProjectPath';
9
+ export * from './materialiseUserScriptSource';
10
+ export * from './USER_SCRIPT_SOURCE_LIMITS';
11
+ export * from './UserScriptArchiveError';
12
+ export * from './UserScriptSourceFile';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './askUserScriptCheckPublishedOutput';\nexport * from './askUserScriptCollectSource';\nexport * from './askUserScriptPublishOutput';\nexport * from './buildUserScriptInTempDir';\nexport * from './BuiltUserScript';\nexport * from './extractUserScriptZip';\nexport * from './getUserScriptBuildErrorType';\nexport * from './isSafeProjectPath';\nexport * from './materialiseUserScriptSource';\nexport * from './USER_SCRIPT_SOURCE_LIMITS';\nexport * from './UserScriptArchiveError';\nexport * from './UserScriptSourceFile';\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Whether a path from an untrusted source (a drive listing, a zip entry) may be written
3
+ * under a project directory: relative, forward slashes only, no `..`, no empty segment.
4
+ */
5
+ export declare const isSafeProjectPath: (relativePath: string) => boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Whether a path from an untrusted source (a drive listing, a zip entry) may be written
3
+ * under a project directory: relative, forward slashes only, no `..`, no empty segment.
4
+ */
5
+ export const isSafeProjectPath = (relativePath) => relativePath.length > 0 &&
6
+ !relativePath.includes('\\') &&
7
+ !relativePath.startsWith('/') &&
8
+ !relativePath.split('/').some((segment) => segment === '' || segment === '.' || segment === '..');
9
+ //# sourceMappingURL=isSafeProjectPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSafeProjectPath.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/isSafeProjectPath.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAAoB,EAAW,EAAE,CACjE,YAAY,CAAC,MAAM,GAAG,CAAC;IACvB,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;IAC7B,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC","sourcesContent":["/**\n * Whether a path from an untrusted source (a drive listing, a zip entry) may be written\n * under a project directory: relative, forward slashes only, no `..`, no empty segment.\n */\nexport const isSafeProjectPath = (relativePath: string): boolean =>\n relativePath.length > 0 &&\n !relativePath.includes('\\\\') &&\n !relativePath.startsWith('/') &&\n !relativePath.split('/').some((segment) => segment === '' || segment === '.' || segment === '..');\n"]}
@@ -0,0 +1,3 @@
1
+ import { UserScriptSourceFile } from './UserScriptSourceFile';
2
+ /** Writes collected source files under the project directory, refusing any path that would leave it. */
3
+ export declare const materialiseUserScriptSource: (projectDir: string, files: UserScriptSourceFile[]) => void;
@@ -0,0 +1,16 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { UserScriptBuildError, UserScriptBuildErrorCode } from '../../build/UserScriptBuildError';
4
+ import { isSafeProjectPath } from './isSafeProjectPath';
5
+ /** Writes collected source files under the project directory, refusing any path that would leave it. */
6
+ export const materialiseUserScriptSource = (projectDir, files) => {
7
+ for (const file of files) {
8
+ if (!isSafeProjectPath(file.path)) {
9
+ throw new UserScriptBuildError(UserScriptBuildErrorCode.BuildFailed, `Refusing source path [${file.path}]`);
10
+ }
11
+ const target = path.join(projectDir, ...file.path.split('/'));
12
+ fs.mkdirSync(path.dirname(target), { recursive: true });
13
+ fs.writeFileSync(target, file.text);
14
+ }
15
+ };
16
+ //# sourceMappingURL=materialiseUserScriptSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materialiseUserScriptSource.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/materialiseUserScriptSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,wGAAwG;AACxG,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,UAAkB,EAAE,KAA6B,EAAQ,EAAE;IACrG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,oBAAoB,CAAC,wBAAwB,CAAC,WAAW,EAAE,yBAAyB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9G,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9D,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;AACH,CAAC,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { UserScriptBuildError, UserScriptBuildErrorCode } from '../../build/UserScriptBuildError';\nimport { isSafeProjectPath } from './isSafeProjectPath';\nimport { UserScriptSourceFile } from './UserScriptSourceFile';\n\n/** Writes collected source files under the project directory, refusing any path that would leave it. */\nexport const materialiseUserScriptSource = (projectDir: string, files: UserScriptSourceFile[]): void => {\n for (const file of files) {\n if (!isSafeProjectPath(file.path)) {\n throw new UserScriptBuildError(UserScriptBuildErrorCode.BuildFailed, `Refusing source path [${file.path}]`);\n }\n const target = path.join(projectDir, ...file.path.split('/'));\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, file.text);\n }\n};\n"]}
@@ -0,0 +1,2 @@
1
+ /** The entry files a script project may have, relative to its root, in the order they are tried. */
2
+ export declare const USER_SCRIPT_ENTRY_CANDIDATES: readonly ["src/main.ts", "src/main.js"];
@@ -0,0 +1,3 @@
1
+ /** The entry files a script project may have, relative to its root, in the order they are tried. */
2
+ export const USER_SCRIPT_ENTRY_CANDIDATES = ['src/main.ts', 'src/main.js'];
3
+ //# sourceMappingURL=USER_SCRIPT_ENTRY_CANDIDATES.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"USER_SCRIPT_ENTRY_CANDIDATES.js","sourceRoot":"","sources":["../../../src/build/USER_SCRIPT_ENTRY_CANDIDATES.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,aAAa,EAAE,aAAa,CAAU,CAAC","sourcesContent":["/** The entry files a script project may have, relative to its root, in the order they are tried. */\nexport const USER_SCRIPT_ENTRY_CANDIDATES = ['src/main.ts', 'src/main.js'] as const;\n"]}
@@ -0,0 +1,2 @@
1
+ /** The name a build writes the script under in its own out dir; a platform build then publishes that file to the caller's `outputFilepath`. */
2
+ export declare const USER_SCRIPT_OUTPUT_FILENAME = "main.js";
@@ -0,0 +1,3 @@
1
+ /** The name a build writes the script under in its own out dir; a platform build then publishes that file to the caller's `outputFilepath`. */
2
+ export const USER_SCRIPT_OUTPUT_FILENAME = 'main.js';
3
+ //# sourceMappingURL=USER_SCRIPT_OUTPUT_FILENAME.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"USER_SCRIPT_OUTPUT_FILENAME.js","sourceRoot":"","sources":["../../../src/build/USER_SCRIPT_OUTPUT_FILENAME.ts"],"names":[],"mappings":"AAAA,+IAA+I;AAC/I,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC","sourcesContent":["/** The name a build writes the script under in its own out dir; a platform build then publishes that file to the caller's `outputFilepath`. */\nexport const USER_SCRIPT_OUTPUT_FILENAME = 'main.js';\n"]}
@@ -0,0 +1,12 @@
1
+ export declare enum UserScriptBuildErrorCode {
2
+ NoEntry = "NoEntry",
3
+ BuildFailed = "BuildFailed",
4
+ OutputNotSingleFile = "OutputNotSingleFile",
5
+ NoExports = "NoExports",
6
+ NonFunctionExport = "NonFunctionExport"
7
+ }
8
+ /** Thrown by buildUserScript; `code` says which step refused the project. */
9
+ export declare class UserScriptBuildError extends Error {
10
+ readonly code: UserScriptBuildErrorCode;
11
+ constructor(code: UserScriptBuildErrorCode, message: string);
12
+ }
@@ -0,0 +1,23 @@
1
+ export var UserScriptBuildErrorCode;
2
+ (function (UserScriptBuildErrorCode) {
3
+ // No src/main.ts or src/main.js in the project.
4
+ UserScriptBuildErrorCode["NoEntry"] = "NoEntry";
5
+ // Rspack reported errors (a refused Node builtin among them).
6
+ UserScriptBuildErrorCode["BuildFailed"] = "BuildFailed";
7
+ // The build emitted more than one JavaScript file, so the output is not one loadable module.
8
+ UserScriptBuildErrorCode["OutputNotSingleFile"] = "OutputNotSingleFile";
9
+ // The built module has no own enumerable exports.
10
+ UserScriptBuildErrorCode["NoExports"] = "NoExports";
11
+ // An own enumerable export of the built module is not a function.
12
+ UserScriptBuildErrorCode["NonFunctionExport"] = "NonFunctionExport";
13
+ })(UserScriptBuildErrorCode || (UserScriptBuildErrorCode = {}));
14
+ /** Thrown by buildUserScript; `code` says which step refused the project. */
15
+ export class UserScriptBuildError extends Error {
16
+ code;
17
+ constructor(code, message) {
18
+ super(message);
19
+ this.code = code;
20
+ this.name = 'UserScriptBuildError';
21
+ }
22
+ }
23
+ //# sourceMappingURL=UserScriptBuildError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserScriptBuildError.js","sourceRoot":"","sources":["../../../src/build/UserScriptBuildError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,wBAWX;AAXD,WAAY,wBAAwB;IAClC,gDAAgD;IAChD,+CAAmB,CAAA;IACnB,8DAA8D;IAC9D,uDAA2B,CAAA;IAC3B,6FAA6F;IAC7F,uEAA2C,CAAA;IAC3C,kDAAkD;IAClD,mDAAuB,CAAA;IACvB,kEAAkE;IAClE,mEAAuC,CAAA;AACzC,CAAC,EAXW,wBAAwB,KAAxB,wBAAwB,QAWnC;AAED,6EAA6E;AAC7E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE3B;IADlB,YACkB,IAA8B,EAC9C,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAA0B;QAI9C,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF","sourcesContent":["export enum UserScriptBuildErrorCode {\n // No src/main.ts or src/main.js in the project.\n NoEntry = 'NoEntry',\n // Rspack reported errors (a refused Node builtin among them).\n BuildFailed = 'BuildFailed',\n // The build emitted more than one JavaScript file, so the output is not one loadable module.\n OutputNotSingleFile = 'OutputNotSingleFile',\n // The built module has no own enumerable exports.\n NoExports = 'NoExports',\n // An own enumerable export of the built module is not a function.\n NonFunctionExport = 'NonFunctionExport',\n}\n\n/** Thrown by buildUserScript; `code` says which step refused the project. */\nexport class UserScriptBuildError extends Error {\n constructor(\n public readonly code: UserScriptBuildErrorCode,\n message: string,\n ) {\n super(message);\n this.name = 'UserScriptBuildError';\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /** What a successful user-script build produced. */
2
+ export type UserScriptBuildResult = {
3
+ entryPath: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=UserScriptBuildResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserScriptBuildResult.js","sourceRoot":"","sources":["../../../src/build/UserScriptBuildResult.ts"],"names":[],"mappings":"","sourcesContent":["/** What a successful user-script build produced. */\nexport type UserScriptBuildResult = {\n // Absolute path of the single CommonJS output, `<outDir>/main.js`, the only file written.\n entryPath: string;\n};\n"]}
@@ -0,0 +1 @@
1
+ export declare const formatSum: (sum: number) => string;
@@ -0,0 +1,2 @@
1
+ export const formatSum = (sum) => `added ${sum}`;
2
+ //# sourceMappingURL=formatSum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatSum.js","sourceRoot":"","sources":["../../../../../../../src/build/__fixtures__/basic/src/helpers/formatSum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC","sourcesContent":["export const formatSum = (sum: number): string => `added ${sum}`;\n"]}
@@ -0,0 +1,4 @@
1
+ import { AskResponse } from '@qpqjs/core';
2
+ export declare function add(drive: string, filepath: string, a: number, b: number): AskResponse<number>;
3
+ export declare const greet: (name: string) => string;
4
+ export declare const makeId: () => string;
@@ -0,0 +1,11 @@
1
+ import { askFileWriteTextContents } from '@qpqjs/core';
2
+ import { uuidv7 } from 'uuidv7';
3
+ import { formatSum } from './helpers/formatSum';
4
+ export function* add(drive, filepath, a, b) {
5
+ const sum = a + b;
6
+ yield* askFileWriteTextContents(drive, filepath, formatSum(sum));
7
+ return sum;
8
+ }
9
+ export const greet = (name) => `hello ${name}`;
10
+ export const makeId = () => uuidv7();
11
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../../../src/build/__fixtures__/basic/src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAe,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,SAAS,CAAC,CAAC,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAE,CAAS,EAAE,CAAS;IACxE,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,KAAK,CAAC,CAAC,wBAAwB,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC;AAE/D,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE,CAAC,MAAM,EAAE,CAAC","sourcesContent":["import { askFileWriteTextContents, AskResponse } from '@qpqjs/core';\n\nimport { uuidv7 } from 'uuidv7';\n\nimport { formatSum } from './helpers/formatSum';\n\nexport function* add(drive: string, filepath: string, a: number, b: number): AskResponse<number> {\n const sum = a + b;\n yield* askFileWriteTextContents(drive, filepath, formatSum(sum));\n return sum;\n}\n\nexport const greet = (name: string): string => `hello ${name}`;\n\nexport const makeId = (): string => uuidv7();\n"]}
@@ -0,0 +1 @@
1
+ export declare const readIt: () => string;
@@ -0,0 +1,3 @@
1
+ import { readFileSync } from 'fs';
2
+ export const readIt = () => readFileSync('/etc/hostname', 'utf8');
3
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../../../src/build/__fixtures__/builtin/src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import { readFileSync } from 'fs';\n\nexport const readIt = (): string => readFileSync('/etc/hostname', 'utf8');\n"]}
@@ -0,0 +1 @@
1
+ export declare const nothing: () => void;
@@ -0,0 +1,2 @@
1
+ export const nothing = () => { };
2
+ //# sourceMappingURL=notMain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notMain.js","sourceRoot":"","sources":["../../../../../../src/build/__fixtures__/noEntry/src/notMain.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC","sourcesContent":["export const nothing = (): void => {};\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const greet: (name: string) => string;
2
+ export declare const version = 3;
@@ -0,0 +1,3 @@
1
+ export const greet = (name) => `hello ${name}`;
2
+ export const version = 3;
3
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../../../src/build/__fixtures__/nonFunction/src/main.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC;AAC/D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC","sourcesContent":["export const greet = (name: string): string => `hello ${name}`;\nexport const version = 3;\n"]}
@@ -0,0 +1,6 @@
1
+ import { UserScriptModuleExports } from '@qpqjs/core';
2
+ /**
3
+ * The output contract, judged on what loading the built module reported: at least one export,
4
+ * and every export a function. Returns the function names in definition order.
5
+ */
6
+ export declare const assertUserScriptExports: (label: string, exports: UserScriptModuleExports) => string[];
@@ -0,0 +1,16 @@
1
+ import { UserScriptBuildError, UserScriptBuildErrorCode } from './UserScriptBuildError';
2
+ /**
3
+ * The output contract, judged on what loading the built module reported: at least one export,
4
+ * and every export a function. Returns the function names in definition order.
5
+ */
6
+ export const assertUserScriptExports = (label, exports) => {
7
+ if (exports.functions.length === 0 && exports.nonFunctions.length === 0) {
8
+ throw new UserScriptBuildError(UserScriptBuildErrorCode.NoExports, `[${label}] exports nothing; a script must export at least one function`);
9
+ }
10
+ const [nonFunction] = exports.nonFunctions;
11
+ if (nonFunction) {
12
+ throw new UserScriptBuildError(UserScriptBuildErrorCode.NonFunctionExport, `[${label}] export [${nonFunction}] is not a function; a script may only export functions`);
13
+ }
14
+ return exports.functions;
15
+ };
16
+ //# sourceMappingURL=assertUserScriptExports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertUserScriptExports.js","sourceRoot":"","sources":["../../../src/build/assertUserScriptExports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAExF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAa,EAAE,OAAgC,EAAY,EAAE;IACnG,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,oBAAoB,CAAC,wBAAwB,CAAC,SAAS,EAAE,IAAI,KAAK,+DAA+D,CAAC,CAAC;IAC/I,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3C,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,IAAI,oBAAoB,CAC5B,wBAAwB,CAAC,iBAAiB,EAC1C,IAAI,KAAK,aAAa,WAAW,yDAAyD,CAC3F,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,SAAS,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import { UserScriptModuleExports } from '@qpqjs/core';\n\nimport { UserScriptBuildError, UserScriptBuildErrorCode } from './UserScriptBuildError';\n\n/**\n * The output contract, judged on what loading the built module reported: at least one export,\n * and every export a function. Returns the function names in definition order.\n */\nexport const assertUserScriptExports = (label: string, exports: UserScriptModuleExports): string[] => {\n if (exports.functions.length === 0 && exports.nonFunctions.length === 0) {\n throw new UserScriptBuildError(UserScriptBuildErrorCode.NoExports, `[${label}] exports nothing; a script must export at least one function`);\n }\n\n const [nonFunction] = exports.nonFunctions;\n if (nonFunction) {\n throw new UserScriptBuildError(\n UserScriptBuildErrorCode.NonFunctionExport,\n `[${label}] export [${nonFunction}] is not a function; a script may only export functions`,\n );\n }\n\n return exports.functions;\n};\n"]}
@@ -0,0 +1,15 @@
1
+ import { UserScriptModuleMap } from '@qpqjs/actionprocessor-node';
2
+ import { UserScriptBuildResult } from './UserScriptBuildResult';
3
+ export type BuildUserScriptOptions = {
4
+ projectDir: string;
5
+ outDir: string;
6
+ sourceMap?: boolean;
7
+ hostModules?: UserScriptModuleMap;
8
+ };
9
+ /**
10
+ * Builds a script project into `<outDir>/main.js`, the only file written. The output is not
11
+ * loaded here: a platform build has the sandbox report its exports (askUserScriptListExports)
12
+ * and a local build uses checkUserScriptOutput. Throws UserScriptBuildError; the `code` says
13
+ * whether the project or the bundle was at fault. `outDir` is emptied first.
14
+ */
15
+ export declare const buildUserScript: ({ projectDir, outDir, sourceMap, hostModules, }: BuildUserScriptOptions) => Promise<UserScriptBuildResult>;
@@ -0,0 +1,39 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { getUserScriptRspackConfig } from './getUserScriptRspackConfig';
4
+ import { resolveUserScriptEntry } from './resolveUserScriptEntry';
5
+ import { runUserScriptRspack } from './runUserScriptRspack';
6
+ import { USER_SCRIPT_OUTPUT_FILENAME } from './USER_SCRIPT_OUTPUT_FILENAME';
7
+ import { UserScriptBuildError, UserScriptBuildErrorCode } from './UserScriptBuildError';
8
+ const getErrorMessage = (error) => (error instanceof Error ? error.message : String(error));
9
+ /**
10
+ * Builds a script project into `<outDir>/main.js`, the only file written. The output is not
11
+ * loaded here: a platform build has the sandbox report its exports (askUserScriptListExports)
12
+ * and a local build uses checkUserScriptOutput. Throws UserScriptBuildError; the `code` says
13
+ * whether the project or the bundle was at fault. `outDir` is emptied first.
14
+ */
15
+ export const buildUserScript = async ({ projectDir, outDir, sourceMap = false, hostModules = {}, }) => {
16
+ const absoluteProjectDir = path.resolve(projectDir);
17
+ const absoluteOutDir = path.resolve(outDir);
18
+ const entrySource = resolveUserScriptEntry(absoluteProjectDir);
19
+ try {
20
+ await runUserScriptRspack(getUserScriptRspackConfig({
21
+ projectDir: absoluteProjectDir,
22
+ entryPath: entrySource,
23
+ outDir: absoluteOutDir,
24
+ sourceMap,
25
+ hostModuleNames: Object.keys(hostModules),
26
+ }));
27
+ }
28
+ catch (error) {
29
+ throw new UserScriptBuildError(UserScriptBuildErrorCode.BuildFailed, `Building [${absoluteProjectDir}] failed:\n${getErrorMessage(error)}`);
30
+ }
31
+ // Every emitted file counts, not just scripts: the build's whole output is one file, so a
32
+ // stray map, chunk or asset would be silently lost when only main.js is published.
33
+ const emitted = fs.readdirSync(absoluteOutDir);
34
+ if (emitted.length !== 1 || emitted[0] !== USER_SCRIPT_OUTPUT_FILENAME) {
35
+ throw new UserScriptBuildError(UserScriptBuildErrorCode.OutputNotSingleFile, `Building [${absoluteProjectDir}] emitted [${emitted.join(', ')}]; a script must build to exactly ${USER_SCRIPT_OUTPUT_FILENAME}`);
36
+ }
37
+ return { entryPath: path.join(absoluteOutDir, USER_SCRIPT_OUTPUT_FILENAME) };
38
+ };
39
+ //# sourceMappingURL=buildUserScript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildUserScript.js","sourceRoot":"","sources":["../../../src/build/buildUserScript.ts"],"names":[],"mappings":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AK,CAAC,EAAE,CAAC,CAAC;IAC9I,CAAC;IAED,0FAA0F;IAC1F,mFAAmF;IACnF,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,2BAA2B,EAAE,CAAC;QACvE,MAAM,IAAI,oBAAoB,CAC5B,wBAAwB,CAAC,mBAAmB,EAC5C,aAAa,kBAAkB,cAAc,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,qCAAqC,2BAA2B,EAAE,CAClI,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,2BAA2B,CAAC,EAAE,CAAC;AAC/E,CAAC,CAAC","sourcesContent":["import { UserScriptModuleMap } from '@qpqjs/actionprocessor-node';\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { getUserScriptRspackConfig } from './getUserScriptRspackConfig';\nimport { resolveUserScriptEntry } from './resolveUserScriptEntry';\nimport { runUserScriptRspack } from './runUserScriptRspack';\nimport { USER_SCRIPT_OUTPUT_FILENAME } from './USER_SCRIPT_OUTPUT_FILENAME';\nimport { UserScriptBuildError, UserScriptBuildErrorCode } from './UserScriptBuildError';\nimport { UserScriptBuildResult } from './UserScriptBuildResult';\n\nexport type BuildUserScriptOptions = {\n projectDir: string;\n outDir: string;\n // Embed a source map in main.js. Off by default; a separate .map file is never written.\n sourceMap?: boolean;\n // The service's own script modules (defineUserScriptModule), by import name, which the\n // bundler keeps external. A local build has none.\n hostModules?: UserScriptModuleMap;\n};\n\nconst getErrorMessage = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n/**\n * Builds a script project into `<outDir>/main.js`, the only file written. The output is not\n * loaded here: a platform build has the sandbox report its exports (askUserScriptListExports)\n * and a local build uses checkUserScriptOutput. Throws UserScriptBuildError; the `code` says\n * whether the project or the bundle was at fault. `outDir` is emptied first.\n */\nexport const buildUserScript = async ({\n projectDir,\n outDir,\n sourceMap = false,\n hostModules = {},\n}: BuildUserScriptOptions): Promise<UserScriptBuildResult> => {\n const absoluteProjectDir = path.resolve(projectDir);\n const absoluteOutDir = path.resolve(outDir);\n const entrySource = resolveUserScriptEntry(absoluteProjectDir);\n\n try {\n await runUserScriptRspack(\n getUserScriptRspackConfig({\n projectDir: absoluteProjectDir,\n entryPath: entrySource,\n outDir: absoluteOutDir,\n sourceMap,\n hostModuleNames: Object.keys(hostModules),\n }),\n );\n } catch (error) {\n throw new UserScriptBuildError(UserScriptBuildErrorCode.BuildFailed, `Building [${absoluteProjectDir}] failed:\\n${getErrorMessage(error)}`);\n }\n\n // Every emitted file counts, not just scripts: the build's whole output is one file, so a\n // stray map, chunk or asset would be silently lost when only main.js is published.\n const emitted = fs.readdirSync(absoluteOutDir);\n if (emitted.length !== 1 || emitted[0] !== USER_SCRIPT_OUTPUT_FILENAME) {\n throw new UserScriptBuildError(\n UserScriptBuildErrorCode.OutputNotSingleFile,\n `Building [${absoluteProjectDir}] emitted [${emitted.join(', ')}]; a script must build to exactly ${USER_SCRIPT_OUTPUT_FILENAME}`,\n );\n }\n\n return { entryPath: path.join(absoluteOutDir, USER_SCRIPT_OUTPUT_FILENAME) };\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import { UserScriptModuleMap } from '@qpqjs/actionprocessor-node';
2
+ /**
3
+ * Loads a built file in this process and applies the output contract. For a developer's own
4
+ * build (`qpq script:build`) only: a platform build asks the sandbox with
5
+ * askUserScriptListExports instead, so no script code runs in the host.
6
+ */
7
+ export declare const checkUserScriptOutput: (entryPath: string, hostModules?: UserScriptModuleMap) => string[];
@@ -0,0 +1,10 @@
1
+ import { getUserScriptModuleMap, listUserScriptExports } from '@qpqjs/actionprocessor-node';
2
+ import fs from 'fs';
3
+ import { assertUserScriptExports } from './assertUserScriptExports';
4
+ /**
5
+ * Loads a built file in this process and applies the output contract. For a developer's own
6
+ * build (`qpq script:build`) only: a platform build asks the sandbox with
7
+ * askUserScriptListExports instead, so no script code runs in the host.
8
+ */
9
+ export const checkUserScriptOutput = (entryPath, hostModules = {}) => assertUserScriptExports(entryPath, listUserScriptExports(entryPath, fs.readFileSync(entryPath, 'utf8'), getUserScriptModuleMap(hostModules)));
10
+ //# sourceMappingURL=checkUserScriptOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkUserScriptOutput.js","sourceRoot":"","sources":["../../../src/build/checkUserScriptOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAuB,MAAM,6BAA6B,CAAC;AAEjH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAiB,EAAE,cAAmC,EAAE,EAAY,EAAE,CAC1G,uBAAuB,CAAC,SAAS,EAAE,qBAAqB,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import { getUserScriptModuleMap, listUserScriptExports, UserScriptModuleMap } from '@qpqjs/actionprocessor-node';\n\nimport fs from 'fs';\n\nimport { assertUserScriptExports } from './assertUserScriptExports';\n\n/**\n * Loads a built file in this process and applies the output contract. For a developer's own\n * build (`qpq script:build`) only: a platform build asks the sandbox with\n * askUserScriptListExports instead, so no script code runs in the host.\n */\nexport const checkUserScriptOutput = (entryPath: string, hostModules: UserScriptModuleMap = {}): string[] =>\n assertUserScriptExports(entryPath, listUserScriptExports(entryPath, fs.readFileSync(entryPath, 'utf8'), getUserScriptModuleMap(hostModules)));\n"]}
@@ -0,0 +1,11 @@
1
+ import type { ExternalItemFunctionData } from '@rspack/core';
2
+ type ExternalsCallback = (error?: Error, result?: string) => void;
3
+ /**
4
+ * The externals rule for a user-script build: the shared framework packages and the
5
+ * service's own script modules (`hostModuleNames`, from defineUserScriptModule) stay
6
+ * external (the host provides them at run time), Node builtins are refused here with
7
+ * the importing file named, because the loader would refuse them at run time anyway,
8
+ * and everything else is bundled.
9
+ */
10
+ export declare const createUserScriptExternals: (hostModuleNames?: readonly string[]) => ({ request, contextInfo }: ExternalItemFunctionData, callback: ExternalsCallback) => void;
11
+ export {};