@midscene/core 1.12.10-beta-20260920031616.0 → 1.13.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 (319) hide show
  1. package/dist/es/agent/agent.mjs +103 -6
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/index.mjs +4 -3
  4. package/dist/es/agent/tasks.mjs +2 -2
  5. package/dist/es/agent/tasks.mjs.map +1 -1
  6. package/dist/es/agent/test-runner-nodes.mjs +291 -40
  7. package/dist/es/agent/test-runner-nodes.mjs.map +1 -1
  8. package/dist/es/agent/utils.mjs +1 -1
  9. package/dist/es/device/index.mjs +15 -2
  10. package/dist/es/device/index.mjs.map +1 -1
  11. package/dist/es/dump/html-utils.mjs +37 -4
  12. package/dist/es/dump/html-utils.mjs.map +1 -1
  13. package/dist/es/dump/screenshot-store.mjs +8 -1
  14. package/dist/es/dump/screenshot-store.mjs.map +1 -1
  15. package/dist/es/report-cli.mjs +9 -4
  16. package/dist/es/report-cli.mjs.map +1 -1
  17. package/dist/es/report-generator.mjs +117 -4
  18. package/dist/es/report-generator.mjs.map +1 -1
  19. package/dist/es/report-html-template.mjs +1 -1
  20. package/dist/es/report.mjs +190 -41
  21. package/dist/es/report.mjs.map +1 -1
  22. package/dist/es/test-run-report.mjs.map +1 -1
  23. package/dist/es/test-runner/engine/case-runner.mjs +52 -0
  24. package/dist/es/test-runner/engine/case-runner.mjs.map +1 -0
  25. package/dist/es/test-runner/engine/document-runtime.mjs +273 -0
  26. package/dist/es/test-runner/engine/document-runtime.mjs.map +1 -0
  27. package/dist/es/test-runner/engine/execute-step.mjs +177 -0
  28. package/dist/es/test-runner/engine/execute-step.mjs.map +1 -0
  29. package/dist/es/test-runner/engine/execution-failure.mjs +39 -0
  30. package/dist/es/test-runner/engine/execution-failure.mjs.map +1 -0
  31. package/dist/es/test-runner/engine/index.mjs +12 -0
  32. package/dist/es/test-runner/engine/project-runtime.mjs +142 -0
  33. package/dist/es/test-runner/engine/project-runtime.mjs.map +1 -0
  34. package/dist/es/test-runner/engine/registry.mjs +61 -0
  35. package/dist/es/test-runner/engine/registry.mjs.map +1 -0
  36. package/dist/es/test-runner/engine/resource-operations.mjs +211 -0
  37. package/dist/es/test-runner/engine/resource-operations.mjs.map +1 -0
  38. package/dist/es/test-runner/engine/run-collected-case.mjs +193 -0
  39. package/dist/es/test-runner/engine/run-collected-case.mjs.map +1 -0
  40. package/dist/es/test-runner/engine/run-workflow-document.mjs +155 -0
  41. package/dist/es/test-runner/engine/run-workflow-document.mjs.map +1 -0
  42. package/dist/es/test-runner/engine/scheduler.mjs +27 -0
  43. package/dist/es/test-runner/engine/scheduler.mjs.map +1 -0
  44. package/dist/es/test-runner/engine/scope-teardown.mjs +16 -0
  45. package/dist/es/test-runner/engine/scope-teardown.mjs.map +1 -0
  46. package/dist/es/test-runner/engine/types.mjs +0 -0
  47. package/dist/es/test-runner/errors.mjs +201 -0
  48. package/dist/es/test-runner/errors.mjs.map +1 -0
  49. package/dist/es/test-runner/execution-record.mjs +83 -0
  50. package/dist/es/test-runner/execution-record.mjs.map +1 -0
  51. package/dist/es/test-runner/index.mjs +12 -0
  52. package/dist/es/test-runner/node/define-node.mjs +44 -0
  53. package/dist/es/test-runner/node/define-node.mjs.map +1 -0
  54. package/dist/es/test-runner/node/index.mjs +2 -0
  55. package/dist/es/test-runner/node/types.mjs +0 -0
  56. package/dist/es/test-runner/parser/document-format.mjs +21 -0
  57. package/dist/es/test-runner/parser/document-format.mjs.map +1 -0
  58. package/dist/es/test-runner/parser/normalize.mjs +87 -0
  59. package/dist/es/test-runner/parser/normalize.mjs.map +1 -0
  60. package/dist/es/test-runner/parser/types.mjs +0 -0
  61. package/dist/es/test-runner/project.mjs +0 -0
  62. package/dist/es/test-runner/reporting/agent-report.mjs +23 -0
  63. package/dist/es/test-runner/reporting/agent-report.mjs.map +1 -0
  64. package/dist/es/test-runner/reporting/execution-record.mjs +73 -0
  65. package/dist/es/test-runner/reporting/execution-record.mjs.map +1 -0
  66. package/dist/es/test-runner/reporting/merge-report.mjs +231 -0
  67. package/dist/es/test-runner/reporting/merge-report.mjs.map +1 -0
  68. package/dist/es/test-runner/reporting/sanitize.mjs +162 -0
  69. package/dist/es/test-runner/reporting/sanitize.mjs.map +1 -0
  70. package/dist/es/test-runner/reporting/test-run-report.mjs +327 -0
  71. package/dist/es/test-runner/reporting/test-run-report.mjs.map +1 -0
  72. package/dist/es/test-runner/reporting/types.mjs +0 -0
  73. package/dist/es/utils.mjs +1 -1
  74. package/dist/es/yaml/execution-context.node.mjs +6 -0
  75. package/dist/es/yaml/execution-context.node.mjs.map +1 -0
  76. package/dist/es/yaml/execution-context.stub.mjs +8 -0
  77. package/dist/es/yaml/execution-context.stub.mjs.map +1 -0
  78. package/dist/es/yaml/execution-session.mjs +90 -0
  79. package/dist/es/yaml/execution-session.mjs.map +1 -0
  80. package/dist/es/yaml/index.mjs +2 -1
  81. package/dist/es/yaml/legacy-yaml-execution-record.mjs +47 -0
  82. package/dist/es/yaml/legacy-yaml-execution-record.mjs.map +1 -0
  83. package/dist/es/yaml/legacy-yaml-report.mjs +52 -0
  84. package/dist/es/yaml/legacy-yaml-report.mjs.map +1 -0
  85. package/dist/es/yaml/legacy-yaml-runtime.mjs +119 -0
  86. package/dist/es/yaml/legacy-yaml-runtime.mjs.map +1 -0
  87. package/dist/es/yaml/player-state.mjs +15 -0
  88. package/dist/es/yaml/player-state.mjs.map +1 -0
  89. package/dist/es/yaml/player.mjs +214 -348
  90. package/dist/es/yaml/player.mjs.map +1 -1
  91. package/dist/es/yaml/report-policy.mjs +7 -0
  92. package/dist/es/yaml/report-policy.mjs.map +1 -0
  93. package/dist/es/yaml/test-runner-compat.mjs +301 -0
  94. package/dist/es/yaml/test-runner-compat.mjs.map +1 -0
  95. package/dist/es/yaml/test-runner-nodes.mjs +147 -0
  96. package/dist/es/yaml/test-runner-nodes.mjs.map +1 -0
  97. package/dist/es/yaml/utils.mjs +12 -1
  98. package/dist/es/yaml/utils.mjs.map +1 -1
  99. package/dist/es/yaml-runtime.mjs +7 -0
  100. package/dist/es/yaml.mjs.map +1 -1
  101. package/dist/lib/agent/agent.js +103 -6
  102. package/dist/lib/agent/agent.js.map +1 -1
  103. package/dist/lib/agent/index.js +37 -3
  104. package/dist/lib/agent/tasks.js +2 -2
  105. package/dist/lib/agent/tasks.js.map +1 -1
  106. package/dist/lib/agent/test-runner-nodes.js +329 -45
  107. package/dist/lib/agent/test-runner-nodes.js.map +1 -1
  108. package/dist/lib/agent/utils.js +1 -1
  109. package/dist/lib/device/index.js +15 -2
  110. package/dist/lib/device/index.js.map +1 -1
  111. package/dist/lib/dump/html-utils.js +43 -4
  112. package/dist/lib/dump/html-utils.js.map +1 -1
  113. package/dist/lib/dump/screenshot-store.js +8 -1
  114. package/dist/lib/dump/screenshot-store.js.map +1 -1
  115. package/dist/lib/report-cli.js +8 -3
  116. package/dist/lib/report-cli.js.map +1 -1
  117. package/dist/lib/report-generator.js +114 -1
  118. package/dist/lib/report-generator.js.map +1 -1
  119. package/dist/lib/report-html-template.js +1 -1
  120. package/dist/lib/report.js +187 -38
  121. package/dist/lib/report.js.map +1 -1
  122. package/dist/lib/test-run-report.js.map +1 -1
  123. package/dist/lib/test-runner/engine/case-runner.js +89 -0
  124. package/dist/lib/test-runner/engine/case-runner.js.map +1 -0
  125. package/dist/lib/test-runner/engine/document-runtime.js +307 -0
  126. package/dist/lib/test-runner/engine/document-runtime.js.map +1 -0
  127. package/dist/lib/test-runner/engine/execute-step.js +211 -0
  128. package/dist/lib/test-runner/engine/execute-step.js.map +1 -0
  129. package/dist/lib/test-runner/engine/execution-failure.js +79 -0
  130. package/dist/lib/test-runner/engine/execution-failure.js.map +1 -0
  131. package/dist/lib/test-runner/engine/index.js +137 -0
  132. package/dist/lib/test-runner/engine/index.js.map +1 -0
  133. package/dist/lib/test-runner/engine/project-runtime.js +176 -0
  134. package/dist/lib/test-runner/engine/project-runtime.js.map +1 -0
  135. package/dist/lib/test-runner/engine/registry.js +95 -0
  136. package/dist/lib/test-runner/engine/registry.js.map +1 -0
  137. package/dist/lib/test-runner/engine/resource-operations.js +272 -0
  138. package/dist/lib/test-runner/engine/resource-operations.js.map +1 -0
  139. package/dist/lib/test-runner/engine/run-collected-case.js +227 -0
  140. package/dist/lib/test-runner/engine/run-collected-case.js.map +1 -0
  141. package/dist/lib/test-runner/engine/run-workflow-document.js +189 -0
  142. package/dist/lib/test-runner/engine/run-workflow-document.js.map +1 -0
  143. package/dist/lib/test-runner/engine/scheduler.js +64 -0
  144. package/dist/lib/test-runner/engine/scheduler.js.map +1 -0
  145. package/dist/lib/test-runner/engine/scope-teardown.js +50 -0
  146. package/dist/lib/test-runner/engine/scope-teardown.js.map +1 -0
  147. package/dist/lib/test-runner/engine/types.js +20 -0
  148. package/dist/lib/test-runner/engine/types.js.map +1 -0
  149. package/dist/lib/test-runner/errors.js +283 -0
  150. package/dist/lib/test-runner/errors.js.map +1 -0
  151. package/dist/lib/test-runner/execution-record.js +123 -0
  152. package/dist/lib/test-runner/execution-record.js.map +1 -0
  153. package/dist/lib/test-runner/index.js +137 -0
  154. package/dist/lib/test-runner/index.js.map +1 -0
  155. package/dist/lib/test-runner/node/define-node.js +78 -0
  156. package/dist/lib/test-runner/node/define-node.js.map +1 -0
  157. package/dist/lib/test-runner/node/index.js +67 -0
  158. package/dist/lib/test-runner/node/index.js.map +1 -0
  159. package/dist/lib/test-runner/node/types.js +20 -0
  160. package/dist/lib/test-runner/node/types.js.map +1 -0
  161. package/dist/lib/test-runner/parser/document-format.js +58 -0
  162. package/dist/lib/test-runner/parser/document-format.js.map +1 -0
  163. package/dist/lib/test-runner/parser/normalize.js +124 -0
  164. package/dist/lib/test-runner/parser/normalize.js.map +1 -0
  165. package/dist/lib/test-runner/parser/types.js +20 -0
  166. package/dist/lib/test-runner/parser/types.js.map +1 -0
  167. package/dist/lib/test-runner/project.js +20 -0
  168. package/dist/lib/test-runner/project.js.map +1 -0
  169. package/dist/lib/test-runner/reporting/agent-report.js +57 -0
  170. package/dist/lib/test-runner/reporting/agent-report.js.map +1 -0
  171. package/dist/lib/test-runner/reporting/execution-record.js +107 -0
  172. package/dist/lib/test-runner/reporting/execution-record.js.map +1 -0
  173. package/dist/lib/test-runner/reporting/merge-report.js +265 -0
  174. package/dist/lib/test-runner/reporting/merge-report.js.map +1 -0
  175. package/dist/lib/test-runner/reporting/sanitize.js +202 -0
  176. package/dist/lib/test-runner/reporting/sanitize.js.map +1 -0
  177. package/dist/lib/test-runner/reporting/test-run-report.js +364 -0
  178. package/dist/lib/test-runner/reporting/test-run-report.js.map +1 -0
  179. package/dist/lib/test-runner/reporting/types.js +20 -0
  180. package/dist/lib/test-runner/reporting/types.js.map +1 -0
  181. package/dist/lib/utils.js +1 -1
  182. package/dist/lib/yaml/execution-context.node.js +43 -0
  183. package/dist/lib/yaml/execution-context.node.js.map +1 -0
  184. package/dist/lib/yaml/execution-context.stub.js +45 -0
  185. package/dist/lib/yaml/execution-context.stub.js.map +1 -0
  186. package/dist/lib/yaml/execution-session.js +136 -0
  187. package/dist/lib/yaml/execution-session.js.map +1 -0
  188. package/dist/lib/yaml/index.js +49 -7
  189. package/dist/lib/yaml/legacy-yaml-execution-record.js +81 -0
  190. package/dist/lib/yaml/legacy-yaml-execution-record.js.map +1 -0
  191. package/dist/lib/yaml/legacy-yaml-report.js +86 -0
  192. package/dist/lib/yaml/legacy-yaml-report.js.map +1 -0
  193. package/dist/lib/yaml/legacy-yaml-runtime.js +156 -0
  194. package/dist/lib/yaml/legacy-yaml-runtime.js.map +1 -0
  195. package/dist/lib/yaml/player-state.js +52 -0
  196. package/dist/lib/yaml/player-state.js.map +1 -0
  197. package/dist/lib/yaml/player.js +213 -347
  198. package/dist/lib/yaml/player.js.map +1 -1
  199. package/dist/lib/yaml/report-policy.js +41 -0
  200. package/dist/lib/yaml/report-policy.js.map +1 -0
  201. package/dist/lib/yaml/test-runner-compat.js +344 -0
  202. package/dist/lib/yaml/test-runner-compat.js.map +1 -0
  203. package/dist/lib/yaml/test-runner-nodes.js +184 -0
  204. package/dist/lib/yaml/test-runner-nodes.js.map +1 -0
  205. package/dist/lib/yaml/utils.js +18 -1
  206. package/dist/lib/yaml/utils.js.map +1 -1
  207. package/dist/lib/yaml-runtime.js +67 -0
  208. package/dist/lib/yaml-runtime.js.map +1 -0
  209. package/dist/lib/yaml.js.map +1 -1
  210. package/dist/types/agent/agent.d.ts +14 -1
  211. package/dist/types/agent/agent.d.ts.map +1 -1
  212. package/dist/types/agent/index.d.ts +4 -3
  213. package/dist/types/agent/index.d.ts.map +1 -1
  214. package/dist/types/agent/tasks.d.ts +1 -1
  215. package/dist/types/agent/tasks.d.ts.map +1 -1
  216. package/dist/types/agent/test-runner-nodes.d.ts +226 -0
  217. package/dist/types/agent/test-runner-nodes.d.ts.map +1 -1
  218. package/dist/types/device/index.d.ts +1 -1
  219. package/dist/types/device/index.d.ts.map +1 -1
  220. package/dist/types/dump/html-utils.d.ts +4 -0
  221. package/dist/types/dump/html-utils.d.ts.map +1 -1
  222. package/dist/types/dump/screenshot-store.d.ts +2 -1
  223. package/dist/types/dump/screenshot-store.d.ts.map +1 -1
  224. package/dist/types/report-cli.d.ts.map +1 -1
  225. package/dist/types/report-generator.d.ts +10 -0
  226. package/dist/types/report-generator.d.ts.map +1 -1
  227. package/dist/types/report.d.ts +3 -1
  228. package/dist/types/report.d.ts.map +1 -1
  229. package/dist/types/test-run-report.d.ts +18 -2
  230. package/dist/types/test-run-report.d.ts.map +1 -1
  231. package/dist/types/test-runner/engine/case-runner.d.ts +13 -0
  232. package/dist/types/test-runner/engine/case-runner.d.ts.map +1 -0
  233. package/dist/types/test-runner/engine/document-runtime.d.ts +4 -0
  234. package/dist/types/test-runner/engine/document-runtime.d.ts.map +1 -0
  235. package/dist/types/test-runner/engine/execute-step.d.ts +17 -0
  236. package/dist/types/test-runner/engine/execute-step.d.ts.map +1 -0
  237. package/dist/types/test-runner/engine/execution-failure.d.ts +13 -0
  238. package/dist/types/test-runner/engine/execution-failure.d.ts.map +1 -0
  239. package/dist/types/test-runner/engine/index.d.ts +13 -0
  240. package/dist/types/test-runner/engine/index.d.ts.map +1 -0
  241. package/dist/types/test-runner/engine/project-runtime.d.ts +3 -0
  242. package/dist/types/test-runner/engine/project-runtime.d.ts.map +1 -0
  243. package/dist/types/test-runner/engine/registry.d.ts +12 -0
  244. package/dist/types/test-runner/engine/registry.d.ts.map +1 -0
  245. package/dist/types/test-runner/engine/resource-operations.d.ts +32 -0
  246. package/dist/types/test-runner/engine/resource-operations.d.ts.map +1 -0
  247. package/dist/types/test-runner/engine/run-collected-case.d.ts +4 -0
  248. package/dist/types/test-runner/engine/run-collected-case.d.ts.map +1 -0
  249. package/dist/types/test-runner/engine/run-workflow-document.d.ts +4 -0
  250. package/dist/types/test-runner/engine/run-workflow-document.d.ts.map +1 -0
  251. package/dist/types/test-runner/engine/scheduler.d.ts +12 -0
  252. package/dist/types/test-runner/engine/scheduler.d.ts.map +1 -0
  253. package/dist/types/test-runner/engine/scope-teardown.d.ts +3 -0
  254. package/dist/types/test-runner/engine/scope-teardown.d.ts.map +1 -0
  255. package/dist/types/test-runner/engine/types.d.ts +226 -0
  256. package/dist/types/test-runner/engine/types.d.ts.map +1 -0
  257. package/dist/types/test-runner/errors.d.ts +79 -0
  258. package/dist/types/test-runner/errors.d.ts.map +1 -0
  259. package/dist/types/test-runner/execution-record.d.ts +43 -0
  260. package/dist/types/test-runner/execution-record.d.ts.map +1 -0
  261. package/dist/types/test-runner/index.d.ts +20 -0
  262. package/dist/types/test-runner/index.d.ts.map +1 -0
  263. package/dist/types/test-runner/node/define-node.d.ts +4 -0
  264. package/dist/types/test-runner/node/define-node.d.ts.map +1 -0
  265. package/dist/types/test-runner/node/index.d.ts +3 -0
  266. package/dist/types/test-runner/node/index.d.ts.map +1 -0
  267. package/dist/types/test-runner/node/types.d.ts +66 -0
  268. package/dist/types/test-runner/node/types.d.ts.map +1 -0
  269. package/dist/types/test-runner/parser/document-format.d.ts +8 -0
  270. package/dist/types/test-runner/parser/document-format.d.ts.map +1 -0
  271. package/dist/types/test-runner/parser/normalize.d.ts +9 -0
  272. package/dist/types/test-runner/parser/normalize.d.ts.map +1 -0
  273. package/dist/types/test-runner/parser/types.d.ts +69 -0
  274. package/dist/types/test-runner/parser/types.d.ts.map +1 -0
  275. package/dist/types/test-runner/project.d.ts +75 -0
  276. package/dist/types/test-runner/project.d.ts.map +1 -0
  277. package/dist/types/test-runner/reporting/agent-report.d.ts +9 -0
  278. package/dist/types/test-runner/reporting/agent-report.d.ts.map +1 -0
  279. package/dist/types/test-runner/reporting/execution-record.d.ts +9 -0
  280. package/dist/types/test-runner/reporting/execution-record.d.ts.map +1 -0
  281. package/dist/types/test-runner/reporting/merge-report.d.ts +15 -0
  282. package/dist/types/test-runner/reporting/merge-report.d.ts.map +1 -0
  283. package/dist/types/test-runner/reporting/sanitize.d.ts +6 -0
  284. package/dist/types/test-runner/reporting/sanitize.d.ts.map +1 -0
  285. package/dist/types/test-runner/reporting/test-run-report.d.ts +5 -0
  286. package/dist/types/test-runner/reporting/test-run-report.d.ts.map +1 -0
  287. package/dist/types/test-runner/reporting/types.d.ts +34 -0
  288. package/dist/types/test-runner/reporting/types.d.ts.map +1 -0
  289. package/dist/types/yaml/execution-context.node.d.ts +4 -0
  290. package/dist/types/yaml/execution-context.node.d.ts.map +1 -0
  291. package/dist/types/yaml/execution-context.stub.d.ts +6 -0
  292. package/dist/types/yaml/execution-context.stub.d.ts.map +1 -0
  293. package/dist/types/yaml/execution-session.d.ts +17 -0
  294. package/dist/types/yaml/execution-session.d.ts.map +1 -0
  295. package/dist/types/yaml/index.d.ts +1 -1
  296. package/dist/types/yaml/index.d.ts.map +1 -1
  297. package/dist/types/yaml/legacy-yaml-execution-record.d.ts +24 -0
  298. package/dist/types/yaml/legacy-yaml-execution-record.d.ts.map +1 -0
  299. package/dist/types/yaml/legacy-yaml-report.d.ts +19 -0
  300. package/dist/types/yaml/legacy-yaml-report.d.ts.map +1 -0
  301. package/dist/types/yaml/legacy-yaml-runtime.d.ts +23 -0
  302. package/dist/types/yaml/legacy-yaml-runtime.d.ts.map +1 -0
  303. package/dist/types/yaml/player-state.d.ts +11 -0
  304. package/dist/types/yaml/player-state.d.ts.map +1 -0
  305. package/dist/types/yaml/player.d.ts +11 -3
  306. package/dist/types/yaml/player.d.ts.map +1 -1
  307. package/dist/types/yaml/report-policy.d.ts +4 -0
  308. package/dist/types/yaml/report-policy.d.ts.map +1 -0
  309. package/dist/types/yaml/test-runner-compat.d.ts +17 -0
  310. package/dist/types/yaml/test-runner-compat.d.ts.map +1 -0
  311. package/dist/types/yaml/test-runner-nodes.d.ts +6 -0
  312. package/dist/types/yaml/test-runner-nodes.d.ts.map +1 -0
  313. package/dist/types/yaml/utils.d.ts +9 -0
  314. package/dist/types/yaml/utils.d.ts.map +1 -1
  315. package/dist/types/yaml-runtime.d.ts +13 -0
  316. package/dist/types/yaml-runtime.d.ts.map +1 -0
  317. package/dist/types/yaml.d.ts +25 -7
  318. package/dist/types/yaml.d.ts.map +1 -1
  319. package/package.json +28 -2
@@ -0,0 +1,307 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ createDocumentRuntime: ()=>createDocumentRuntime
28
+ });
29
+ const logger_namespaceObject = require("@midscene/shared/logger");
30
+ const utils_namespaceObject = require("@midscene/shared/utils");
31
+ const external_errors_js_namespaceObject = require("../errors.js");
32
+ const external_execute_step_js_namespaceObject = require("./execute-step.js");
33
+ const external_execution_failure_js_namespaceObject = require("./execution-failure.js");
34
+ const external_resource_operations_js_namespaceObject = require("./resource-operations.js");
35
+ const external_scope_teardown_js_namespaceObject = require("./scope-teardown.js");
36
+ function createDocumentRuntime(document, options) {
37
+ const documentRunId = options.createDocumentRunId?.() ?? (0, utils_namespaceObject.uuid)();
38
+ const startedAt = new Date();
39
+ const beforeAll = [];
40
+ const afterAll = [];
41
+ const nodes = {
42
+ beforeAll: document.lifecycle.beforeAll.map((step)=>options.resolveNode(step.node)),
43
+ afterAll: document.lifecycle.afterAll.map((step)=>options.resolveNode(step.node))
44
+ };
45
+ const project = options.project ?? Object.freeze({
46
+ projectId: document.projectId,
47
+ name: document.projectId,
48
+ retry: 0
49
+ });
50
+ let context = options.projectContext;
51
+ const resourceScope = (0, external_resource_operations_js_namespaceObject.createResourceScope)(options.signal);
52
+ const signal = resourceScope.signal;
53
+ const nodeTeardownStack = [];
54
+ let acceptingNodeTeardowns = true;
55
+ let started = false;
56
+ let finishedResult;
57
+ let finishPromise;
58
+ const reportPaths = new Set();
59
+ const reportSources = [];
60
+ const executionErrors = [];
61
+ const hostErrors = [];
62
+ let acceptingSetupTeardowns = false;
63
+ const createResult = (teardownErrors = [])=>{
64
+ const endedAt = new Date();
65
+ return {
66
+ documentId: document.documentId,
67
+ documentRunId,
68
+ ...void 0 === options.documentAttemptIndex ? {} : {
69
+ attemptIndex: options.documentAttemptIndex
70
+ },
71
+ projectId: document.projectId,
72
+ projectName: project.name,
73
+ sourcePath: document.sourcePath,
74
+ status: executionErrors.length > 0 || hostErrors.length > 0 || beforeAll.some((step)=>'failed' === step.status) || afterAll.some((step)=>'failed' === step.status) || teardownErrors.length > 0 ? 'failed' : 'success',
75
+ startedAt: startedAt.toISOString(),
76
+ endedAt: endedAt.toISOString(),
77
+ durationMs: Math.max(0, endedAt.getTime() - startedAt.getTime()),
78
+ beforeAll: [
79
+ ...beforeAll
80
+ ],
81
+ afterAll: [
82
+ ...afterAll
83
+ ],
84
+ ...executionErrors.length ? {
85
+ executionErrors: executionErrors.map(external_execution_failure_js_namespaceObject.asExecutionError)
86
+ } : {},
87
+ ...hostErrors.length ? {
88
+ hostErrors: [
89
+ ...hostErrors
90
+ ]
91
+ } : {},
92
+ ...teardownErrors.length > 0 ? {
93
+ teardownErrors: [
94
+ ...teardownErrors
95
+ ]
96
+ } : {},
97
+ ...reportPaths.size > 0 ? {
98
+ reportPaths: [
99
+ ...reportPaths
100
+ ]
101
+ } : {},
102
+ ...reportSources.length ? {
103
+ reportSources: [
104
+ ...reportSources
105
+ ]
106
+ } : {}
107
+ };
108
+ };
109
+ const runPhase = async (phase, results, executionSignal = signal)=>{
110
+ for (const [stepIndex, step] of document.lifecycle[phase].entries()){
111
+ const documentContext = {
112
+ documentId: document.documentId,
113
+ documentRunId,
114
+ projectId: document.projectId,
115
+ projectName: project.name,
116
+ sourcePath: document.sourcePath,
117
+ phase,
118
+ stepIndex
119
+ };
120
+ const stepInfo = {
121
+ scope: 'document',
122
+ node: step.node,
123
+ stepCount: document.lifecycle[phase].length,
124
+ document: documentContext
125
+ };
126
+ await options.onStepStart?.(stepInfo);
127
+ const result = await (0, external_execute_step_js_namespaceObject.executeStep)(step, nodes[phase][stepIndex], {
128
+ scope: 'document',
129
+ document: documentContext
130
+ }, context, {
131
+ signal: executionSignal,
132
+ defaultTimeoutMs: options.defaultTimeoutMs,
133
+ onTeardown (node, teardown) {
134
+ if (!acceptingNodeTeardowns) throw new external_errors_js_namespaceObject.WorkflowLifecycleError('Node teardown can only be registered while a workflow document is running.', {
135
+ documentId: document.documentId,
136
+ documentRunId,
137
+ node
138
+ });
139
+ if ('function' != typeof teardown) throw new external_errors_js_namespaceObject.WorkflowLifecycleError('Node onTeardown() requires a teardown function.', {
140
+ documentId: document.documentId,
141
+ documentRunId,
142
+ node
143
+ });
144
+ nodeTeardownStack.push({
145
+ registrationIndex: nodeTeardownStack.length,
146
+ node,
147
+ teardown
148
+ });
149
+ }
150
+ });
151
+ results.push(result);
152
+ await options.onStepResult?.(stepInfo, result);
153
+ if ('failed' === result.status && !result.continuedAfterError) break;
154
+ }
155
+ };
156
+ return {
157
+ signal,
158
+ get context () {
159
+ return context;
160
+ },
161
+ get canRunCases () {
162
+ return started && 0 === executionErrors.length && 0 === hostErrors.length && !signal.aborted && !beforeAll.some((step)=>'failed' === step.status);
163
+ },
164
+ async start () {
165
+ if (started) throw new external_errors_js_namespaceObject.WorkflowLifecycleError('Workflow document runtime has already started.', {
166
+ documentId: document.documentId,
167
+ documentRunId
168
+ });
169
+ started = true;
170
+ if (!signal.aborted && options.documentSetup) {
171
+ acceptingSetupTeardowns = true;
172
+ try {
173
+ context = await options.documentSetup.setup({
174
+ project,
175
+ projectContext: options.projectContext,
176
+ document: {
177
+ documentId: document.documentId,
178
+ documentRunId,
179
+ sourcePath: document.sourcePath,
180
+ attemptIndex: options.documentAttemptIndex ?? 0
181
+ },
182
+ signal,
183
+ onTeardown (teardown) {
184
+ if (!acceptingSetupTeardowns || 'function' != typeof teardown) throw new external_errors_js_namespaceObject.WorkflowLifecycleError('Document setup onTeardown() requires a function registered during setup.', {
185
+ documentId: document.documentId,
186
+ documentRunId
187
+ });
188
+ nodeTeardownStack.push({
189
+ registrationIndex: nodeTeardownStack.length,
190
+ node: options.documentSetup.name,
191
+ teardown,
192
+ host: true
193
+ });
194
+ }
195
+ });
196
+ } catch (error) {
197
+ hostErrors.push({
198
+ phase: 'setup',
199
+ error: (0, external_execution_failure_js_namespaceObject.asExecutionError)(error)
200
+ });
201
+ } finally{
202
+ acceptingSetupTeardowns = false;
203
+ }
204
+ }
205
+ try {
206
+ if (!signal.aborted && !hostErrors.length) await runPhase('beforeAll', beforeAll);
207
+ } catch (error) {
208
+ executionErrors.push(error);
209
+ throw new external_execution_failure_js_namespaceObject.WorkflowExecutionFailure(createResult(), [
210
+ ...executionErrors
211
+ ]);
212
+ }
213
+ return createResult();
214
+ },
215
+ async finish () {
216
+ if (finishPromise) return finishPromise;
217
+ if (!started) throw new external_errors_js_namespaceObject.WorkflowLifecycleError('Workflow document runtime must start before it can finish.', {
218
+ documentId: document.documentId,
219
+ documentRunId
220
+ });
221
+ finishPromise = (async ()=>{
222
+ const teardownErrors = [];
223
+ const cleanupExecutionErrors = [];
224
+ let deferredCleanup = false;
225
+ const cleanup = async ()=>{
226
+ const priorTeardownErrors = teardownErrors.length;
227
+ acceptingNodeTeardowns = false;
228
+ for (const { registrationIndex, node, teardown, host } of nodeTeardownStack.reverse())try {
229
+ const released = await teardown();
230
+ reportSources.push(...released?.reportSources ?? []);
231
+ for (const path of (0, external_scope_teardown_js_namespaceObject.reportPathsFromTeardown)(released))reportPaths.add(path);
232
+ } catch (error) {
233
+ if (host) {
234
+ hostErrors.push({
235
+ phase: 'cleanup',
236
+ error: (0, external_execution_failure_js_namespaceObject.asExecutionError)(error)
237
+ });
238
+ executionErrors.push(error);
239
+ cleanupExecutionErrors.push(error);
240
+ continue;
241
+ }
242
+ teardownErrors.push(new external_errors_js_namespaceObject.NodeScopeTeardownError(error, {
243
+ scope: 'document',
244
+ scopeId: documentRunId,
245
+ node,
246
+ registrationIndex
247
+ }));
248
+ }
249
+ if (deferredCleanup) {
250
+ const errors = [
251
+ ...cleanupExecutionErrors,
252
+ ...teardownErrors.slice(priorTeardownErrors)
253
+ ];
254
+ if (errors.length) throw new AggregateError(errors, 'Deferred document cleanup failed');
255
+ }
256
+ };
257
+ try {
258
+ if (document.lifecycle.afterAll.length || nodeTeardownStack.length) await (0, external_resource_operations_js_namespaceObject.cleanupScopeResources)(signal, cleanup, {
259
+ beforeCleanup: async (cleanupSignal)=>{
260
+ try {
261
+ if (!hostErrors.some((error)=>'setup' === error.phase)) await runPhase('afterAll', afterAll, cleanupSignal);
262
+ } catch (error) {
263
+ executionErrors.push(error);
264
+ cleanupExecutionErrors.push(error);
265
+ }
266
+ },
267
+ onDeferredError: (error)=>(0, logger_namespaceObject.getDebug)('runner:cleanup', {
268
+ console: true
269
+ })(`Deferred document cleanup failed: ${String(error)}`)
270
+ });
271
+ else acceptingNodeTeardowns = false;
272
+ } catch (error) {
273
+ deferredCleanup = error instanceof external_resource_operations_js_namespaceObject.ResourceCleanupDeferredError;
274
+ if (!deferredCleanup) acceptingNodeTeardowns = false;
275
+ teardownErrors.push(new external_errors_js_namespaceObject.NodeScopeTeardownError(error, {
276
+ scope: 'document',
277
+ scopeId: documentRunId,
278
+ node: 'resource-drain',
279
+ registrationIndex: -1
280
+ }));
281
+ }
282
+ finishedResult = createResult(teardownErrors);
283
+ try {
284
+ await options.onResult?.(finishedResult);
285
+ } catch (error) {
286
+ executionErrors.push(error);
287
+ finishedResult = createResult(teardownErrors);
288
+ }
289
+ resourceScope.dispose();
290
+ if (executionErrors.length) throw new external_execution_failure_js_namespaceObject.WorkflowExecutionFailure(finishedResult, [
291
+ ...executionErrors
292
+ ]);
293
+ return finishedResult;
294
+ })();
295
+ return finishPromise;
296
+ }
297
+ };
298
+ }
299
+ exports.createDocumentRuntime = __webpack_exports__.createDocumentRuntime;
300
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
301
+ "createDocumentRuntime"
302
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
303
+ Object.defineProperty(exports, '__esModule', {
304
+ value: true
305
+ });
306
+
307
+ //# sourceMappingURL=document-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-runner/engine/document-runtime.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/document-runtime.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { uuid as randomUUID } from '@midscene/shared/utils';\nimport {\n NodeScopeTeardownError,\n type WorkflowError,\n WorkflowLifecycleError,\n} from '../errors';\nimport type { CollectedWorkflowDocument } from '../parser/types';\nimport { executeStep } from './execute-step';\nimport {\n WorkflowExecutionFailure,\n asExecutionError,\n} from './execution-failure';\nimport {\n ResourceCleanupDeferredError,\n cleanupScopeResources,\n createResourceScope,\n} from './resource-operations';\nimport { reportPathsFromTeardown } from './scope-teardown';\nimport type {\n CreateDocumentRuntimeOptions,\n DocumentNodePhase,\n NodeDocumentContext,\n NodeScopeTeardown,\n StepRunResult,\n WorkflowDocumentRunResult,\n WorkflowDocumentRuntime,\n WorkflowHostError,\n} from './types';\n\nexport function createDocumentRuntime<TContext = undefined>(\n document: CollectedWorkflowDocument,\n options: CreateDocumentRuntimeOptions<TContext>,\n): WorkflowDocumentRuntime<TContext> {\n const documentRunId = options.createDocumentRunId?.() ?? randomUUID();\n const startedAt = new Date();\n const beforeAll: StepRunResult[] = [];\n const afterAll: StepRunResult[] = [];\n const nodes = {\n beforeAll: document.lifecycle.beforeAll.map((step) =>\n options.resolveNode(step.node),\n ),\n afterAll: document.lifecycle.afterAll.map((step) =>\n options.resolveNode(step.node),\n ),\n };\n const project =\n options.project ??\n Object.freeze({\n projectId: document.projectId,\n name: document.projectId,\n retry: 0,\n });\n let context = options.projectContext as TContext;\n const resourceScope = createResourceScope(options.signal);\n const signal = resourceScope.signal;\n const nodeTeardownStack: Array<{\n registrationIndex: number;\n node: string;\n teardown: NodeScopeTeardown;\n host?: boolean;\n }> = [];\n let acceptingNodeTeardowns = true;\n let started = false;\n let finishedResult: WorkflowDocumentRunResult | undefined;\n let finishPromise: Promise<WorkflowDocumentRunResult> | undefined;\n const reportPaths = new Set<string>();\n const reportSources: import('./types').WorkflowReportSource[] = [];\n const executionErrors: unknown[] = [];\n const hostErrors: WorkflowHostError[] = [];\n let acceptingSetupTeardowns = false;\n\n const createResult = (\n teardownErrors: WorkflowError[] = [],\n ): WorkflowDocumentRunResult => {\n const endedAt = new Date();\n return {\n documentId: document.documentId,\n documentRunId,\n ...(options.documentAttemptIndex === undefined\n ? {}\n : { attemptIndex: options.documentAttemptIndex }),\n projectId: document.projectId,\n projectName: project.name,\n sourcePath: document.sourcePath,\n status:\n executionErrors.length > 0 ||\n hostErrors.length > 0 ||\n beforeAll.some((step) => step.status === 'failed') ||\n afterAll.some((step) => step.status === 'failed') ||\n teardownErrors.length > 0\n ? 'failed'\n : 'success',\n startedAt: startedAt.toISOString(),\n endedAt: endedAt.toISOString(),\n durationMs: Math.max(0, endedAt.getTime() - startedAt.getTime()),\n beforeAll: [...beforeAll],\n afterAll: [...afterAll],\n ...(executionErrors.length\n ? { executionErrors: executionErrors.map(asExecutionError) }\n : {}),\n ...(hostErrors.length ? { hostErrors: [...hostErrors] } : {}),\n ...(teardownErrors.length > 0\n ? { teardownErrors: [...teardownErrors] }\n : {}),\n ...(reportPaths.size > 0 ? { reportPaths: [...reportPaths] } : {}),\n ...(reportSources.length ? { reportSources: [...reportSources] } : {}),\n };\n };\n\n const runPhase = async (\n phase: DocumentNodePhase,\n results: StepRunResult[],\n executionSignal = signal,\n ): Promise<void> => {\n for (const [stepIndex, step] of document.lifecycle[phase].entries()) {\n const documentContext: NodeDocumentContext = {\n documentId: document.documentId,\n documentRunId,\n projectId: document.projectId,\n projectName: project.name,\n sourcePath: document.sourcePath,\n phase,\n stepIndex,\n };\n const stepInfo = {\n scope: 'document' as const,\n node: step.node,\n stepCount: document.lifecycle[phase].length,\n document: documentContext,\n };\n await options.onStepStart?.(stepInfo);\n const result = await executeStep(\n step,\n nodes[phase][stepIndex],\n { scope: 'document', document: documentContext },\n context,\n {\n signal: executionSignal,\n defaultTimeoutMs: options.defaultTimeoutMs,\n onTeardown(node, teardown) {\n if (!acceptingNodeTeardowns) {\n throw new WorkflowLifecycleError(\n 'Node teardown can only be registered while a workflow document is running.',\n { documentId: document.documentId, documentRunId, node },\n );\n }\n if (typeof teardown !== 'function') {\n throw new WorkflowLifecycleError(\n 'Node onTeardown() requires a teardown function.',\n { documentId: document.documentId, documentRunId, node },\n );\n }\n nodeTeardownStack.push({\n registrationIndex: nodeTeardownStack.length,\n node,\n teardown,\n });\n },\n },\n );\n results.push(result);\n await options.onStepResult?.(stepInfo, result);\n if (result.status === 'failed' && !result.continuedAfterError) break;\n }\n };\n\n return {\n signal,\n get context() {\n return context;\n },\n get canRunCases() {\n return (\n started &&\n executionErrors.length === 0 &&\n hostErrors.length === 0 &&\n !signal.aborted &&\n !beforeAll.some((step) => step.status === 'failed')\n );\n },\n async start() {\n if (started) {\n throw new WorkflowLifecycleError(\n 'Workflow document runtime has already started.',\n { documentId: document.documentId, documentRunId },\n );\n }\n started = true;\n if (!signal.aborted && options.documentSetup) {\n acceptingSetupTeardowns = true;\n try {\n context = await options.documentSetup.setup({\n project,\n projectContext: options.projectContext,\n document: {\n documentId: document.documentId,\n documentRunId,\n sourcePath: document.sourcePath,\n attemptIndex: options.documentAttemptIndex ?? 0,\n },\n signal,\n onTeardown(teardown) {\n if (!acceptingSetupTeardowns || typeof teardown !== 'function')\n throw new WorkflowLifecycleError(\n 'Document setup onTeardown() requires a function registered during setup.',\n { documentId: document.documentId, documentRunId },\n );\n nodeTeardownStack.push({\n registrationIndex: nodeTeardownStack.length,\n node: options.documentSetup!.name,\n teardown,\n host: true,\n });\n },\n });\n } catch (error) {\n hostErrors.push({ phase: 'setup', error: asExecutionError(error) });\n } finally {\n acceptingSetupTeardowns = false;\n }\n }\n try {\n if (!signal.aborted && !hostErrors.length)\n await runPhase('beforeAll', beforeAll);\n } catch (error) {\n executionErrors.push(error);\n throw new WorkflowExecutionFailure(createResult(), [\n ...executionErrors,\n ]);\n }\n return createResult();\n },\n async finish() {\n if (finishPromise) return finishPromise;\n if (!started) {\n throw new WorkflowLifecycleError(\n 'Workflow document runtime must start before it can finish.',\n { documentId: document.documentId, documentRunId },\n );\n }\n finishPromise = (async () => {\n const teardownErrors: WorkflowError[] = [];\n const cleanupExecutionErrors: unknown[] = [];\n let deferredCleanup = false;\n const cleanup = async () => {\n const priorTeardownErrors = teardownErrors.length;\n acceptingNodeTeardowns = false;\n for (const {\n registrationIndex,\n node,\n teardown,\n host,\n } of nodeTeardownStack.reverse()) {\n try {\n const released = await teardown();\n reportSources.push(...(released?.reportSources ?? []));\n for (const path of reportPathsFromTeardown(released)) {\n reportPaths.add(path);\n }\n } catch (error) {\n if (host) {\n hostErrors.push({\n phase: 'cleanup',\n error: asExecutionError(error),\n });\n executionErrors.push(error);\n cleanupExecutionErrors.push(error);\n continue;\n }\n teardownErrors.push(\n new NodeScopeTeardownError(error, {\n scope: 'document',\n scopeId: documentRunId,\n node,\n registrationIndex,\n }),\n );\n }\n }\n if (deferredCleanup) {\n const errors = [\n ...cleanupExecutionErrors,\n ...teardownErrors.slice(priorTeardownErrors),\n ];\n if (errors.length)\n throw new AggregateError(\n errors,\n 'Deferred document cleanup failed',\n );\n }\n };\n try {\n if (document.lifecycle.afterAll.length || nodeTeardownStack.length)\n await cleanupScopeResources(signal, cleanup, {\n beforeCleanup: async (cleanupSignal) => {\n try {\n if (!hostErrors.some((error) => error.phase === 'setup'))\n await runPhase('afterAll', afterAll, cleanupSignal);\n } catch (error) {\n executionErrors.push(error);\n cleanupExecutionErrors.push(error);\n }\n },\n onDeferredError: (error) =>\n getDebug('runner:cleanup', { console: true })(\n `Deferred document cleanup failed: ${String(error)}`,\n ),\n });\n else acceptingNodeTeardowns = false;\n } catch (error) {\n deferredCleanup = error instanceof ResourceCleanupDeferredError;\n if (!deferredCleanup) acceptingNodeTeardowns = false;\n teardownErrors.push(\n new NodeScopeTeardownError(error, {\n scope: 'document',\n scopeId: documentRunId,\n node: 'resource-drain',\n registrationIndex: -1,\n }),\n );\n }\n finishedResult = createResult(teardownErrors);\n try {\n await options.onResult?.(finishedResult);\n } catch (error) {\n executionErrors.push(error);\n finishedResult = createResult(teardownErrors);\n }\n resourceScope.dispose();\n if (executionErrors.length)\n throw new WorkflowExecutionFailure(finishedResult, [\n ...executionErrors,\n ]);\n return finishedResult;\n })();\n return finishPromise;\n },\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","createDocumentRuntime","document","options","documentRunId","randomUUID","startedAt","Date","beforeAll","afterAll","nodes","step","project","context","resourceScope","createResourceScope","signal","nodeTeardownStack","acceptingNodeTeardowns","started","finishedResult","finishPromise","reportPaths","Set","reportSources","executionErrors","hostErrors","acceptingSetupTeardowns","createResult","teardownErrors","endedAt","undefined","Math","asExecutionError","runPhase","phase","results","executionSignal","stepIndex","documentContext","stepInfo","result","executeStep","node","teardown","WorkflowLifecycleError","error","WorkflowExecutionFailure","cleanupExecutionErrors","deferredCleanup","cleanup","priorTeardownErrors","registrationIndex","host","released","path","reportPathsFromTeardown","NodeScopeTeardownError","errors","AggregateError","cleanupScopeResources","cleanupSignal","getDebug","String","ResourceCleanupDeferredError"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc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
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ executeStep: ()=>executeStep
28
+ });
29
+ const external_errors_js_namespaceObject = require("../errors.js");
30
+ const external_resource_operations_js_namespaceObject = require("./resource-operations.js");
31
+ function validateNodeOutput(output, node) {
32
+ if (void 0 === output) return;
33
+ if ('object' != typeof output || null === output || Array.isArray(output)) throw new external_errors_js_namespaceObject.NodeExecutionError(node, new TypeError('Node output must be an object or undefined.'));
34
+ if ('summary' in output && void 0 !== output.summary && 'string' != typeof output.summary) throw new external_errors_js_namespaceObject.NodeExecutionError(node, new TypeError('Node output summary must be a string.'));
35
+ return output;
36
+ }
37
+ function createStepResultBase(step, startedAt, phase, stepIndex) {
38
+ const endedAt = new Date();
39
+ return {
40
+ node: step.node,
41
+ phase,
42
+ stepIndex,
43
+ input: step.input,
44
+ meta: step.meta,
45
+ startedAt: startedAt.toISOString(),
46
+ endedAt: endedAt.toISOString(),
47
+ durationMs: Math.max(0, endedAt.getTime() - startedAt.getTime())
48
+ };
49
+ }
50
+ async function executeNode(step, execute, phase, stepIndex, options) {
51
+ const startedAt = new Date();
52
+ const abortController = new AbortController();
53
+ const parentSignal = options.parentSignal;
54
+ (0, external_resource_operations_js_namespaceObject.linkResourceSignal)(abortController.signal, parentSignal);
55
+ const abortFromParent = ()=>abortController.abort(parentSignal?.reason);
56
+ if (parentSignal?.aborted) abortFromParent();
57
+ else parentSignal?.addEventListener('abort', abortFromParent, {
58
+ once: true
59
+ });
60
+ const timeoutMs = step.meta.timeoutMs ?? options.defaultTimeoutMs;
61
+ let timeout;
62
+ let abortGraceTimeout;
63
+ const execution = Promise.resolve().then(()=>{
64
+ abortController.signal.throwIfAborted();
65
+ return execute(abortController.signal);
66
+ });
67
+ let settleOnAbort;
68
+ const abortedExecution = new Promise((_, reject)=>{
69
+ settleOnAbort = ()=>{
70
+ abortGraceTimeout = setTimeout(()=>{
71
+ reject(abortController.signal.reason);
72
+ }, 0);
73
+ };
74
+ if (abortController.signal.aborted) settleOnAbort();
75
+ else abortController.signal.addEventListener('abort', settleOnAbort, {
76
+ once: true
77
+ });
78
+ });
79
+ const timeoutExecution = void 0 === timeoutMs ? void 0 : new Promise((_, reject)=>{
80
+ timeout = setTimeout(()=>{
81
+ if (abortController.signal.aborted) return void reject(abortController.signal.reason);
82
+ const timeoutError = new external_errors_js_namespaceObject.StepTimeoutError(timeoutMs, step.node);
83
+ abortController.abort(timeoutError);
84
+ reject(timeoutError);
85
+ }, timeoutMs);
86
+ });
87
+ const settledExecution = Promise.race([
88
+ execution,
89
+ abortedExecution,
90
+ ...void 0 === timeoutExecution ? [] : [
91
+ timeoutExecution
92
+ ]
93
+ ]);
94
+ try {
95
+ const output = validateNodeOutput(await settledExecution, step.node);
96
+ return {
97
+ ...createStepResultBase(step, startedAt, phase, stepIndex),
98
+ status: 'success',
99
+ continuedAfterError: false,
100
+ ...void 0 === output ? {} : {
101
+ output
102
+ }
103
+ };
104
+ } catch (error) {
105
+ let output;
106
+ let failure = error;
107
+ if (error instanceof external_errors_js_namespaceObject.NodeExecutionError && void 0 !== error.output) try {
108
+ output = validateNodeOutput(error.output, step.node);
109
+ } catch (validationError) {
110
+ failure = validationError;
111
+ }
112
+ return {
113
+ ...createStepResultBase(step, startedAt, phase, stepIndex),
114
+ status: 'failed',
115
+ continuedAfterError: step.meta.continueOnError,
116
+ error: (0, external_errors_js_namespaceObject.normalizeNodeExecutionError)(failure, step.node),
117
+ ...void 0 === output ? {} : {
118
+ output
119
+ }
120
+ };
121
+ } finally{
122
+ if (void 0 !== timeout) clearTimeout(timeout);
123
+ if (void 0 !== abortGraceTimeout) clearTimeout(abortGraceTimeout);
124
+ if (void 0 !== settleOnAbort) abortController.signal.removeEventListener('abort', settleOnAbort);
125
+ parentSignal?.removeEventListener('abort', abortFromParent);
126
+ }
127
+ }
128
+ function createNodeReportCollector(node) {
129
+ const traces = new Map();
130
+ let accepting = true;
131
+ return {
132
+ collector: Object.freeze({
133
+ addTrace (trace) {
134
+ if (!accepting) throw new external_errors_js_namespaceObject.NodeExecutionError(node, new Error('Report traces can only be added while the current Step is running.'));
135
+ if (!trace || 'object' != typeof trace || 'midscene-execution' !== trace.type) throw new external_errors_js_namespaceObject.NodeExecutionError(node, new TypeError('Report trace type must be "midscene-execution".'));
136
+ if ('string' != typeof trace.executionId || 0 === trace.executionId.trim().length) throw new external_errors_js_namespaceObject.NodeExecutionError(node, new TypeError('Report trace executionId must be non-empty.'));
137
+ const normalized = Object.freeze({
138
+ type: 'midscene-execution',
139
+ executionId: trace.executionId
140
+ });
141
+ traces.set(`${normalized.type}:${normalized.executionId}`, normalized);
142
+ }
143
+ }),
144
+ close () {
145
+ accepting = false;
146
+ return Object.freeze([
147
+ ...traces.values()
148
+ ]);
149
+ }
150
+ };
151
+ }
152
+ async function parseNodeInput(node, input) {
153
+ if (!node.inputSchema) return input;
154
+ const parsed = await node.inputSchema.safeParseAsync(input);
155
+ if (!parsed.success) throw external_errors_js_namespaceObject.NodeInputValidationError.fromZod(node.name, parsed.error);
156
+ return parsed.data;
157
+ }
158
+ async function executeStep(step, node, target, context, execution = {}) {
159
+ const phase = 'case' === target.scope ? target.case.phase : target.document.phase;
160
+ const stepIndex = 'case' === target.scope ? target.case.stepIndex : target.document.stepIndex;
161
+ const reportCollector = createNodeReportCollector(step.node);
162
+ let result;
163
+ try {
164
+ result = await executeNode(step, async (signal)=>{
165
+ const input = await parseNodeInput(node, step.input);
166
+ signal.throwIfAborted();
167
+ const common = {
168
+ input,
169
+ $: step.meta,
170
+ signal,
171
+ context,
172
+ report: reportCollector.collector,
173
+ onTeardown: (teardown)=>{
174
+ if (!execution.onTeardown) throw new external_errors_js_namespaceObject.NodeExecutionError(step.node, new Error('The current execution scope cannot register teardown.'));
175
+ execution.onTeardown(step.node, teardown);
176
+ }
177
+ };
178
+ return 'case' === target.scope ? node.execute({
179
+ ...common,
180
+ scope: 'case',
181
+ case: target.case
182
+ }) : node.execute({
183
+ ...common,
184
+ scope: 'document',
185
+ document: target.document
186
+ });
187
+ }, phase, stepIndex, {
188
+ parentSignal: execution.signal,
189
+ defaultTimeoutMs: execution.defaultTimeoutMs
190
+ });
191
+ } finally{
192
+ const traces = reportCollector.close();
193
+ if (traces.length > 0 && result) result = {
194
+ ...result,
195
+ report: {
196
+ traces
197
+ }
198
+ };
199
+ }
200
+ if (!result) throw new external_errors_js_namespaceObject.NodeExecutionError(step.node, new Error('Step execution completed without a result.'));
201
+ return result;
202
+ }
203
+ exports.executeStep = __webpack_exports__.executeStep;
204
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
205
+ "executeStep"
206
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
207
+ Object.defineProperty(exports, '__esModule', {
208
+ value: true
209
+ });
210
+
211
+ //# sourceMappingURL=execute-step.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-runner/engine/execute-step.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/execute-step.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {\n NodeExecutionError,\n NodeInputValidationError,\n StepTimeoutError,\n normalizeNodeExecutionError,\n} from '../errors';\nimport type {\n NodeDefinition,\n NodeReportCollector,\n NodeReportTrace,\n NodeResult,\n} from '../node/types';\nimport type { NormalizedStep } from '../parser/types';\nimport { linkResourceSignal } from './resource-operations';\nimport type {\n NodeCaseContext,\n NodeDocumentContext,\n NodeExecutionPhase,\n NodeScopeTeardown,\n StepRunResult,\n} from './types';\n\nfunction validateNodeOutput<TData>(\n output: unknown,\n node: string,\n): NodeResult<TData> | undefined {\n if (output === undefined) {\n return undefined;\n }\n\n if (typeof output !== 'object' || output === null || Array.isArray(output)) {\n throw new NodeExecutionError(\n node,\n new TypeError('Node output must be an object or undefined.'),\n );\n }\n\n if (\n 'summary' in output &&\n output.summary !== undefined &&\n typeof output.summary !== 'string'\n ) {\n throw new NodeExecutionError(\n node,\n new TypeError('Node output summary must be a string.'),\n );\n }\n\n // Node data is an API value. JSON serialization belongs to the publisher;\n // serialization failure must not turn completed actions into retryable work.\n\n return output as NodeResult<TData>;\n}\n\nfunction createStepResultBase(\n step: NormalizedStep,\n startedAt: Date,\n phase: NodeExecutionPhase,\n stepIndex: number,\n) {\n const endedAt = new Date();\n return {\n node: step.node,\n phase,\n stepIndex,\n input: step.input,\n meta: step.meta,\n startedAt: startedAt.toISOString(),\n endedAt: endedAt.toISOString(),\n durationMs: Math.max(0, endedAt.getTime() - startedAt.getTime()),\n };\n}\n\nasync function executeNode<TOutputData>(\n step: NormalizedStep,\n execute: (signal: AbortSignal) => unknown,\n phase: NodeExecutionPhase,\n stepIndex: number,\n options: { parentSignal?: AbortSignal; defaultTimeoutMs?: number },\n): Promise<StepRunResult<TOutputData>> {\n const startedAt = new Date();\n const abortController = new AbortController();\n const parentSignal = options.parentSignal;\n linkResourceSignal(abortController.signal, parentSignal);\n const abortFromParent = () => abortController.abort(parentSignal?.reason);\n if (parentSignal?.aborted) abortFromParent();\n else parentSignal?.addEventListener('abort', abortFromParent, { once: true });\n const timeoutMs = step.meta.timeoutMs ?? options.defaultTimeoutMs;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let abortGraceTimeout: ReturnType<typeof setTimeout> | undefined;\n const execution = Promise.resolve().then(() => {\n abortController.signal.throwIfAborted();\n return execute(abortController.signal);\n });\n let settleOnAbort: (() => void) | undefined;\n const abortedExecution = new Promise<never>((_, reject) => {\n settleOnAbort = () => {\n // Abort listeners run synchronously. Wait one task before rejecting so a\n // cooperative node can settle in response to the forwarded abort first.\n abortGraceTimeout = setTimeout(() => {\n reject(abortController.signal.reason);\n }, 0);\n };\n if (abortController.signal.aborted) settleOnAbort();\n else\n abortController.signal.addEventListener('abort', settleOnAbort, {\n once: true,\n });\n });\n const timeoutExecution =\n timeoutMs === undefined\n ? undefined\n : new Promise<never>((_, reject) => {\n timeout = setTimeout(() => {\n if (abortController.signal.aborted) {\n reject(abortController.signal.reason);\n return;\n }\n const timeoutError = new StepTimeoutError(timeoutMs, step.node);\n abortController.abort(timeoutError);\n reject(timeoutError);\n }, timeoutMs);\n });\n const settledExecution = Promise.race([\n execution,\n abortedExecution,\n ...(timeoutExecution === undefined ? [] : [timeoutExecution]),\n ]);\n\n try {\n const output = validateNodeOutput<TOutputData>(\n await settledExecution,\n step.node,\n );\n return {\n ...createStepResultBase(step, startedAt, phase, stepIndex),\n status: 'success',\n continuedAfterError: false,\n ...(output === undefined ? {} : { output }),\n };\n } catch (error) {\n let output: NodeResult<TOutputData> | undefined;\n let failure = error;\n if (error instanceof NodeExecutionError && error.output !== undefined) {\n try {\n output = validateNodeOutput<TOutputData>(error.output, step.node);\n } catch (validationError) {\n failure = validationError;\n }\n }\n return {\n ...createStepResultBase(step, startedAt, phase, stepIndex),\n status: 'failed',\n continuedAfterError: step.meta.continueOnError,\n error: normalizeNodeExecutionError(failure, step.node),\n ...(output === undefined ? {} : { output }),\n };\n } finally {\n if (timeout !== undefined) clearTimeout(timeout);\n if (abortGraceTimeout !== undefined) clearTimeout(abortGraceTimeout);\n if (settleOnAbort !== undefined) {\n abortController.signal.removeEventListener('abort', settleOnAbort);\n }\n parentSignal?.removeEventListener('abort', abortFromParent);\n }\n}\n\ntype StepExecutionTarget =\n | { scope: 'case'; case: NodeCaseContext }\n | { scope: 'document'; document: NodeDocumentContext };\n\nfunction createNodeReportCollector(node: string): {\n collector: NodeReportCollector;\n close(): readonly NodeReportTrace[];\n} {\n const traces = new Map<string, NodeReportTrace>();\n let accepting = true;\n\n return {\n collector: Object.freeze({\n addTrace(trace: NodeReportTrace): void {\n if (!accepting) {\n throw new NodeExecutionError(\n node,\n new Error(\n 'Report traces can only be added while the current Step is running.',\n ),\n );\n }\n if (\n !trace ||\n typeof trace !== 'object' ||\n (trace as { type?: unknown }).type !== 'midscene-execution'\n ) {\n throw new NodeExecutionError(\n node,\n new TypeError('Report trace type must be \"midscene-execution\".'),\n );\n }\n if (\n typeof trace.executionId !== 'string' ||\n trace.executionId.trim().length === 0\n ) {\n throw new NodeExecutionError(\n node,\n new TypeError('Report trace executionId must be non-empty.'),\n );\n }\n const normalized = Object.freeze({\n type: 'midscene-execution' as const,\n executionId: trace.executionId,\n });\n traces.set(`${normalized.type}:${normalized.executionId}`, normalized);\n },\n }),\n close(): readonly NodeReportTrace[] {\n accepting = false;\n return Object.freeze([...traces.values()]);\n },\n };\n}\n\nasync function parseNodeInput<TInput, TData, TContext>(\n node: NodeDefinition<TInput, TData, TContext>,\n input: Record<string, unknown>,\n): Promise<TInput> {\n if (!node.inputSchema) {\n return input as TInput;\n }\n\n const parsed = await node.inputSchema.safeParseAsync(input);\n if (!parsed.success) {\n throw NodeInputValidationError.fromZod(node.name, parsed.error);\n }\n return parsed.data as TInput;\n}\n\nexport async function executeStep<\n TInput = unknown,\n TOutputData = unknown,\n TContext = unknown,\n>(\n step: NormalizedStep,\n node: NodeDefinition<TInput, TOutputData, TContext>,\n target: StepExecutionTarget,\n context: TContext,\n execution: {\n signal?: AbortSignal;\n defaultTimeoutMs?: number;\n onTeardown?(node: string, teardown: NodeScopeTeardown): void;\n } = {},\n): Promise<StepRunResult<TOutputData>> {\n const phase =\n target.scope === 'case' ? target.case.phase : target.document.phase;\n const stepIndex =\n target.scope === 'case' ? target.case.stepIndex : target.document.stepIndex;\n\n const reportCollector = createNodeReportCollector(step.node);\n let result: StepRunResult<TOutputData> | undefined;\n\n try {\n result = await executeNode<TOutputData>(\n step,\n async (signal) => {\n const input = await parseNodeInput(node, step.input);\n signal.throwIfAborted();\n const common = {\n input,\n $: step.meta,\n signal,\n context,\n report: reportCollector.collector,\n onTeardown: (teardown: NodeScopeTeardown) => {\n if (!execution.onTeardown) {\n throw new NodeExecutionError(\n step.node,\n new Error(\n 'The current execution scope cannot register teardown.',\n ),\n );\n }\n execution.onTeardown(step.node, teardown);\n },\n };\n return target.scope === 'case'\n ? node.execute({ ...common, scope: 'case', case: target.case })\n : node.execute({\n ...common,\n scope: 'document',\n document: target.document,\n });\n },\n phase,\n stepIndex,\n {\n parentSignal: execution.signal,\n defaultTimeoutMs: execution.defaultTimeoutMs,\n },\n );\n } finally {\n const traces = reportCollector.close();\n if (traces.length > 0 && result) {\n result = { ...result, report: { traces } };\n }\n }\n\n if (!result) {\n throw new NodeExecutionError(\n step.node,\n new Error('Step execution completed without a result.'),\n );\n }\n return result;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","validateNodeOutput","output","node","undefined","Array","NodeExecutionError","TypeError","createStepResultBase","step","startedAt","phase","stepIndex","endedAt","Date","Math","executeNode","execute","options","abortController","AbortController","parentSignal","linkResourceSignal","abortFromParent","timeoutMs","timeout","abortGraceTimeout","execution","Promise","settleOnAbort","abortedExecution","_","reject","setTimeout","timeoutExecution","timeoutError","StepTimeoutError","settledExecution","error","failure","validationError","normalizeNodeExecutionError","clearTimeout","createNodeReportCollector","traces","Map","accepting","trace","Error","normalized","parseNodeInput","input","parsed","NodeInputValidationError","executeStep","target","context","reportCollector","result","signal","common","teardown"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACgBA,SAASI,mBACPC,MAAe,EACfC,IAAY;IAEZ,IAAID,AAAWE,WAAXF,QACF;IAGF,IAAI,AAAkB,YAAlB,OAAOA,UAAuBA,AAAW,SAAXA,UAAmBG,MAAM,OAAO,CAACH,SACjE,MAAM,IAAII,mCAAAA,kBAAkBA,CAC1BH,MACA,IAAII,UAAU;IAIlB,IACE,aAAaL,UACbA,AAAmBE,WAAnBF,OAAO,OAAO,IACd,AAA0B,YAA1B,OAAOA,OAAO,OAAO,EAErB,MAAM,IAAII,mCAAAA,kBAAkBA,CAC1BH,MACA,IAAII,UAAU;IAOlB,OAAOL;AACT;AAEA,SAASM,qBACPC,IAAoB,EACpBC,SAAe,EACfC,KAAyB,EACzB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