@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.
- package/dist/es/agent/agent.mjs +103 -6
- package/dist/es/agent/agent.mjs.map +1 -1
- package/dist/es/agent/index.mjs +4 -3
- package/dist/es/agent/tasks.mjs +2 -2
- package/dist/es/agent/tasks.mjs.map +1 -1
- package/dist/es/agent/test-runner-nodes.mjs +291 -40
- package/dist/es/agent/test-runner-nodes.mjs.map +1 -1
- package/dist/es/agent/utils.mjs +1 -1
- package/dist/es/device/index.mjs +15 -2
- package/dist/es/device/index.mjs.map +1 -1
- package/dist/es/dump/html-utils.mjs +37 -4
- package/dist/es/dump/html-utils.mjs.map +1 -1
- package/dist/es/dump/screenshot-store.mjs +8 -1
- package/dist/es/dump/screenshot-store.mjs.map +1 -1
- package/dist/es/report-cli.mjs +9 -4
- package/dist/es/report-cli.mjs.map +1 -1
- package/dist/es/report-generator.mjs +117 -4
- package/dist/es/report-generator.mjs.map +1 -1
- package/dist/es/report-html-template.mjs +1 -1
- package/dist/es/report.mjs +190 -41
- package/dist/es/report.mjs.map +1 -1
- package/dist/es/test-run-report.mjs.map +1 -1
- package/dist/es/test-runner/engine/case-runner.mjs +52 -0
- package/dist/es/test-runner/engine/case-runner.mjs.map +1 -0
- package/dist/es/test-runner/engine/document-runtime.mjs +273 -0
- package/dist/es/test-runner/engine/document-runtime.mjs.map +1 -0
- package/dist/es/test-runner/engine/execute-step.mjs +177 -0
- package/dist/es/test-runner/engine/execute-step.mjs.map +1 -0
- package/dist/es/test-runner/engine/execution-failure.mjs +39 -0
- package/dist/es/test-runner/engine/execution-failure.mjs.map +1 -0
- package/dist/es/test-runner/engine/index.mjs +12 -0
- package/dist/es/test-runner/engine/project-runtime.mjs +142 -0
- package/dist/es/test-runner/engine/project-runtime.mjs.map +1 -0
- package/dist/es/test-runner/engine/registry.mjs +61 -0
- package/dist/es/test-runner/engine/registry.mjs.map +1 -0
- package/dist/es/test-runner/engine/resource-operations.mjs +211 -0
- package/dist/es/test-runner/engine/resource-operations.mjs.map +1 -0
- package/dist/es/test-runner/engine/run-collected-case.mjs +193 -0
- package/dist/es/test-runner/engine/run-collected-case.mjs.map +1 -0
- package/dist/es/test-runner/engine/run-workflow-document.mjs +155 -0
- package/dist/es/test-runner/engine/run-workflow-document.mjs.map +1 -0
- package/dist/es/test-runner/engine/scheduler.mjs +27 -0
- package/dist/es/test-runner/engine/scheduler.mjs.map +1 -0
- package/dist/es/test-runner/engine/scope-teardown.mjs +16 -0
- package/dist/es/test-runner/engine/scope-teardown.mjs.map +1 -0
- package/dist/es/test-runner/engine/types.mjs +0 -0
- package/dist/es/test-runner/errors.mjs +201 -0
- package/dist/es/test-runner/errors.mjs.map +1 -0
- package/dist/es/test-runner/execution-record.mjs +83 -0
- package/dist/es/test-runner/execution-record.mjs.map +1 -0
- package/dist/es/test-runner/index.mjs +12 -0
- package/dist/es/test-runner/node/define-node.mjs +44 -0
- package/dist/es/test-runner/node/define-node.mjs.map +1 -0
- package/dist/es/test-runner/node/index.mjs +2 -0
- package/dist/es/test-runner/node/types.mjs +0 -0
- package/dist/es/test-runner/parser/document-format.mjs +21 -0
- package/dist/es/test-runner/parser/document-format.mjs.map +1 -0
- package/dist/es/test-runner/parser/normalize.mjs +87 -0
- package/dist/es/test-runner/parser/normalize.mjs.map +1 -0
- package/dist/es/test-runner/parser/types.mjs +0 -0
- package/dist/es/test-runner/project.mjs +0 -0
- package/dist/es/test-runner/reporting/agent-report.mjs +23 -0
- package/dist/es/test-runner/reporting/agent-report.mjs.map +1 -0
- package/dist/es/test-runner/reporting/execution-record.mjs +73 -0
- package/dist/es/test-runner/reporting/execution-record.mjs.map +1 -0
- package/dist/es/test-runner/reporting/merge-report.mjs +231 -0
- package/dist/es/test-runner/reporting/merge-report.mjs.map +1 -0
- package/dist/es/test-runner/reporting/sanitize.mjs +162 -0
- package/dist/es/test-runner/reporting/sanitize.mjs.map +1 -0
- package/dist/es/test-runner/reporting/test-run-report.mjs +327 -0
- package/dist/es/test-runner/reporting/test-run-report.mjs.map +1 -0
- package/dist/es/test-runner/reporting/types.mjs +0 -0
- package/dist/es/utils.mjs +1 -1
- package/dist/es/yaml/execution-context.node.mjs +6 -0
- package/dist/es/yaml/execution-context.node.mjs.map +1 -0
- package/dist/es/yaml/execution-context.stub.mjs +8 -0
- package/dist/es/yaml/execution-context.stub.mjs.map +1 -0
- package/dist/es/yaml/execution-session.mjs +90 -0
- package/dist/es/yaml/execution-session.mjs.map +1 -0
- package/dist/es/yaml/index.mjs +2 -1
- package/dist/es/yaml/legacy-yaml-execution-record.mjs +47 -0
- package/dist/es/yaml/legacy-yaml-execution-record.mjs.map +1 -0
- package/dist/es/yaml/legacy-yaml-report.mjs +52 -0
- package/dist/es/yaml/legacy-yaml-report.mjs.map +1 -0
- package/dist/es/yaml/legacy-yaml-runtime.mjs +119 -0
- package/dist/es/yaml/legacy-yaml-runtime.mjs.map +1 -0
- package/dist/es/yaml/player-state.mjs +15 -0
- package/dist/es/yaml/player-state.mjs.map +1 -0
- package/dist/es/yaml/player.mjs +214 -348
- package/dist/es/yaml/player.mjs.map +1 -1
- package/dist/es/yaml/report-policy.mjs +7 -0
- package/dist/es/yaml/report-policy.mjs.map +1 -0
- package/dist/es/yaml/test-runner-compat.mjs +301 -0
- package/dist/es/yaml/test-runner-compat.mjs.map +1 -0
- package/dist/es/yaml/test-runner-nodes.mjs +147 -0
- package/dist/es/yaml/test-runner-nodes.mjs.map +1 -0
- package/dist/es/yaml/utils.mjs +12 -1
- package/dist/es/yaml/utils.mjs.map +1 -1
- package/dist/es/yaml-runtime.mjs +7 -0
- package/dist/es/yaml.mjs.map +1 -1
- package/dist/lib/agent/agent.js +103 -6
- package/dist/lib/agent/agent.js.map +1 -1
- package/dist/lib/agent/index.js +37 -3
- package/dist/lib/agent/tasks.js +2 -2
- package/dist/lib/agent/tasks.js.map +1 -1
- package/dist/lib/agent/test-runner-nodes.js +329 -45
- package/dist/lib/agent/test-runner-nodes.js.map +1 -1
- package/dist/lib/agent/utils.js +1 -1
- package/dist/lib/device/index.js +15 -2
- package/dist/lib/device/index.js.map +1 -1
- package/dist/lib/dump/html-utils.js +43 -4
- package/dist/lib/dump/html-utils.js.map +1 -1
- package/dist/lib/dump/screenshot-store.js +8 -1
- package/dist/lib/dump/screenshot-store.js.map +1 -1
- package/dist/lib/report-cli.js +8 -3
- package/dist/lib/report-cli.js.map +1 -1
- package/dist/lib/report-generator.js +114 -1
- package/dist/lib/report-generator.js.map +1 -1
- package/dist/lib/report-html-template.js +1 -1
- package/dist/lib/report.js +187 -38
- package/dist/lib/report.js.map +1 -1
- package/dist/lib/test-run-report.js.map +1 -1
- package/dist/lib/test-runner/engine/case-runner.js +89 -0
- package/dist/lib/test-runner/engine/case-runner.js.map +1 -0
- package/dist/lib/test-runner/engine/document-runtime.js +307 -0
- package/dist/lib/test-runner/engine/document-runtime.js.map +1 -0
- package/dist/lib/test-runner/engine/execute-step.js +211 -0
- package/dist/lib/test-runner/engine/execute-step.js.map +1 -0
- package/dist/lib/test-runner/engine/execution-failure.js +79 -0
- package/dist/lib/test-runner/engine/execution-failure.js.map +1 -0
- package/dist/lib/test-runner/engine/index.js +137 -0
- package/dist/lib/test-runner/engine/index.js.map +1 -0
- package/dist/lib/test-runner/engine/project-runtime.js +176 -0
- package/dist/lib/test-runner/engine/project-runtime.js.map +1 -0
- package/dist/lib/test-runner/engine/registry.js +95 -0
- package/dist/lib/test-runner/engine/registry.js.map +1 -0
- package/dist/lib/test-runner/engine/resource-operations.js +272 -0
- package/dist/lib/test-runner/engine/resource-operations.js.map +1 -0
- package/dist/lib/test-runner/engine/run-collected-case.js +227 -0
- package/dist/lib/test-runner/engine/run-collected-case.js.map +1 -0
- package/dist/lib/test-runner/engine/run-workflow-document.js +189 -0
- package/dist/lib/test-runner/engine/run-workflow-document.js.map +1 -0
- package/dist/lib/test-runner/engine/scheduler.js +64 -0
- package/dist/lib/test-runner/engine/scheduler.js.map +1 -0
- package/dist/lib/test-runner/engine/scope-teardown.js +50 -0
- package/dist/lib/test-runner/engine/scope-teardown.js.map +1 -0
- package/dist/lib/test-runner/engine/types.js +20 -0
- package/dist/lib/test-runner/engine/types.js.map +1 -0
- package/dist/lib/test-runner/errors.js +283 -0
- package/dist/lib/test-runner/errors.js.map +1 -0
- package/dist/lib/test-runner/execution-record.js +123 -0
- package/dist/lib/test-runner/execution-record.js.map +1 -0
- package/dist/lib/test-runner/index.js +137 -0
- package/dist/lib/test-runner/index.js.map +1 -0
- package/dist/lib/test-runner/node/define-node.js +78 -0
- package/dist/lib/test-runner/node/define-node.js.map +1 -0
- package/dist/lib/test-runner/node/index.js +67 -0
- package/dist/lib/test-runner/node/index.js.map +1 -0
- package/dist/lib/test-runner/node/types.js +20 -0
- package/dist/lib/test-runner/node/types.js.map +1 -0
- package/dist/lib/test-runner/parser/document-format.js +58 -0
- package/dist/lib/test-runner/parser/document-format.js.map +1 -0
- package/dist/lib/test-runner/parser/normalize.js +124 -0
- package/dist/lib/test-runner/parser/normalize.js.map +1 -0
- package/dist/lib/test-runner/parser/types.js +20 -0
- package/dist/lib/test-runner/parser/types.js.map +1 -0
- package/dist/lib/test-runner/project.js +20 -0
- package/dist/lib/test-runner/project.js.map +1 -0
- package/dist/lib/test-runner/reporting/agent-report.js +57 -0
- package/dist/lib/test-runner/reporting/agent-report.js.map +1 -0
- package/dist/lib/test-runner/reporting/execution-record.js +107 -0
- package/dist/lib/test-runner/reporting/execution-record.js.map +1 -0
- package/dist/lib/test-runner/reporting/merge-report.js +265 -0
- package/dist/lib/test-runner/reporting/merge-report.js.map +1 -0
- package/dist/lib/test-runner/reporting/sanitize.js +202 -0
- package/dist/lib/test-runner/reporting/sanitize.js.map +1 -0
- package/dist/lib/test-runner/reporting/test-run-report.js +364 -0
- package/dist/lib/test-runner/reporting/test-run-report.js.map +1 -0
- package/dist/lib/test-runner/reporting/types.js +20 -0
- package/dist/lib/test-runner/reporting/types.js.map +1 -0
- package/dist/lib/utils.js +1 -1
- package/dist/lib/yaml/execution-context.node.js +43 -0
- package/dist/lib/yaml/execution-context.node.js.map +1 -0
- package/dist/lib/yaml/execution-context.stub.js +45 -0
- package/dist/lib/yaml/execution-context.stub.js.map +1 -0
- package/dist/lib/yaml/execution-session.js +136 -0
- package/dist/lib/yaml/execution-session.js.map +1 -0
- package/dist/lib/yaml/index.js +49 -7
- package/dist/lib/yaml/legacy-yaml-execution-record.js +81 -0
- package/dist/lib/yaml/legacy-yaml-execution-record.js.map +1 -0
- package/dist/lib/yaml/legacy-yaml-report.js +86 -0
- package/dist/lib/yaml/legacy-yaml-report.js.map +1 -0
- package/dist/lib/yaml/legacy-yaml-runtime.js +156 -0
- package/dist/lib/yaml/legacy-yaml-runtime.js.map +1 -0
- package/dist/lib/yaml/player-state.js +52 -0
- package/dist/lib/yaml/player-state.js.map +1 -0
- package/dist/lib/yaml/player.js +213 -347
- package/dist/lib/yaml/player.js.map +1 -1
- package/dist/lib/yaml/report-policy.js +41 -0
- package/dist/lib/yaml/report-policy.js.map +1 -0
- package/dist/lib/yaml/test-runner-compat.js +344 -0
- package/dist/lib/yaml/test-runner-compat.js.map +1 -0
- package/dist/lib/yaml/test-runner-nodes.js +184 -0
- package/dist/lib/yaml/test-runner-nodes.js.map +1 -0
- package/dist/lib/yaml/utils.js +18 -1
- package/dist/lib/yaml/utils.js.map +1 -1
- package/dist/lib/yaml-runtime.js +67 -0
- package/dist/lib/yaml-runtime.js.map +1 -0
- package/dist/lib/yaml.js.map +1 -1
- package/dist/types/agent/agent.d.ts +14 -1
- package/dist/types/agent/agent.d.ts.map +1 -1
- package/dist/types/agent/index.d.ts +4 -3
- package/dist/types/agent/index.d.ts.map +1 -1
- package/dist/types/agent/tasks.d.ts +1 -1
- package/dist/types/agent/tasks.d.ts.map +1 -1
- package/dist/types/agent/test-runner-nodes.d.ts +226 -0
- package/dist/types/agent/test-runner-nodes.d.ts.map +1 -1
- package/dist/types/device/index.d.ts +1 -1
- package/dist/types/device/index.d.ts.map +1 -1
- package/dist/types/dump/html-utils.d.ts +4 -0
- package/dist/types/dump/html-utils.d.ts.map +1 -1
- package/dist/types/dump/screenshot-store.d.ts +2 -1
- package/dist/types/dump/screenshot-store.d.ts.map +1 -1
- package/dist/types/report-cli.d.ts.map +1 -1
- package/dist/types/report-generator.d.ts +10 -0
- package/dist/types/report-generator.d.ts.map +1 -1
- package/dist/types/report.d.ts +3 -1
- package/dist/types/report.d.ts.map +1 -1
- package/dist/types/test-run-report.d.ts +18 -2
- package/dist/types/test-run-report.d.ts.map +1 -1
- package/dist/types/test-runner/engine/case-runner.d.ts +13 -0
- package/dist/types/test-runner/engine/case-runner.d.ts.map +1 -0
- package/dist/types/test-runner/engine/document-runtime.d.ts +4 -0
- package/dist/types/test-runner/engine/document-runtime.d.ts.map +1 -0
- package/dist/types/test-runner/engine/execute-step.d.ts +17 -0
- package/dist/types/test-runner/engine/execute-step.d.ts.map +1 -0
- package/dist/types/test-runner/engine/execution-failure.d.ts +13 -0
- package/dist/types/test-runner/engine/execution-failure.d.ts.map +1 -0
- package/dist/types/test-runner/engine/index.d.ts +13 -0
- package/dist/types/test-runner/engine/index.d.ts.map +1 -0
- package/dist/types/test-runner/engine/project-runtime.d.ts +3 -0
- package/dist/types/test-runner/engine/project-runtime.d.ts.map +1 -0
- package/dist/types/test-runner/engine/registry.d.ts +12 -0
- package/dist/types/test-runner/engine/registry.d.ts.map +1 -0
- package/dist/types/test-runner/engine/resource-operations.d.ts +32 -0
- package/dist/types/test-runner/engine/resource-operations.d.ts.map +1 -0
- package/dist/types/test-runner/engine/run-collected-case.d.ts +4 -0
- package/dist/types/test-runner/engine/run-collected-case.d.ts.map +1 -0
- package/dist/types/test-runner/engine/run-workflow-document.d.ts +4 -0
- package/dist/types/test-runner/engine/run-workflow-document.d.ts.map +1 -0
- package/dist/types/test-runner/engine/scheduler.d.ts +12 -0
- package/dist/types/test-runner/engine/scheduler.d.ts.map +1 -0
- package/dist/types/test-runner/engine/scope-teardown.d.ts +3 -0
- package/dist/types/test-runner/engine/scope-teardown.d.ts.map +1 -0
- package/dist/types/test-runner/engine/types.d.ts +226 -0
- package/dist/types/test-runner/engine/types.d.ts.map +1 -0
- package/dist/types/test-runner/errors.d.ts +79 -0
- package/dist/types/test-runner/errors.d.ts.map +1 -0
- package/dist/types/test-runner/execution-record.d.ts +43 -0
- package/dist/types/test-runner/execution-record.d.ts.map +1 -0
- package/dist/types/test-runner/index.d.ts +20 -0
- package/dist/types/test-runner/index.d.ts.map +1 -0
- package/dist/types/test-runner/node/define-node.d.ts +4 -0
- package/dist/types/test-runner/node/define-node.d.ts.map +1 -0
- package/dist/types/test-runner/node/index.d.ts +3 -0
- package/dist/types/test-runner/node/index.d.ts.map +1 -0
- package/dist/types/test-runner/node/types.d.ts +66 -0
- package/dist/types/test-runner/node/types.d.ts.map +1 -0
- package/dist/types/test-runner/parser/document-format.d.ts +8 -0
- package/dist/types/test-runner/parser/document-format.d.ts.map +1 -0
- package/dist/types/test-runner/parser/normalize.d.ts +9 -0
- package/dist/types/test-runner/parser/normalize.d.ts.map +1 -0
- package/dist/types/test-runner/parser/types.d.ts +69 -0
- package/dist/types/test-runner/parser/types.d.ts.map +1 -0
- package/dist/types/test-runner/project.d.ts +75 -0
- package/dist/types/test-runner/project.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/agent-report.d.ts +9 -0
- package/dist/types/test-runner/reporting/agent-report.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/execution-record.d.ts +9 -0
- package/dist/types/test-runner/reporting/execution-record.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/merge-report.d.ts +15 -0
- package/dist/types/test-runner/reporting/merge-report.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/sanitize.d.ts +6 -0
- package/dist/types/test-runner/reporting/sanitize.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/test-run-report.d.ts +5 -0
- package/dist/types/test-runner/reporting/test-run-report.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/types.d.ts +34 -0
- package/dist/types/test-runner/reporting/types.d.ts.map +1 -0
- package/dist/types/yaml/execution-context.node.d.ts +4 -0
- package/dist/types/yaml/execution-context.node.d.ts.map +1 -0
- package/dist/types/yaml/execution-context.stub.d.ts +6 -0
- package/dist/types/yaml/execution-context.stub.d.ts.map +1 -0
- package/dist/types/yaml/execution-session.d.ts +17 -0
- package/dist/types/yaml/execution-session.d.ts.map +1 -0
- package/dist/types/yaml/index.d.ts +1 -1
- package/dist/types/yaml/index.d.ts.map +1 -1
- package/dist/types/yaml/legacy-yaml-execution-record.d.ts +24 -0
- package/dist/types/yaml/legacy-yaml-execution-record.d.ts.map +1 -0
- package/dist/types/yaml/legacy-yaml-report.d.ts +19 -0
- package/dist/types/yaml/legacy-yaml-report.d.ts.map +1 -0
- package/dist/types/yaml/legacy-yaml-runtime.d.ts +23 -0
- package/dist/types/yaml/legacy-yaml-runtime.d.ts.map +1 -0
- package/dist/types/yaml/player-state.d.ts +11 -0
- package/dist/types/yaml/player-state.d.ts.map +1 -0
- package/dist/types/yaml/player.d.ts +11 -3
- package/dist/types/yaml/player.d.ts.map +1 -1
- package/dist/types/yaml/report-policy.d.ts +4 -0
- package/dist/types/yaml/report-policy.d.ts.map +1 -0
- package/dist/types/yaml/test-runner-compat.d.ts +17 -0
- package/dist/types/yaml/test-runner-compat.d.ts.map +1 -0
- package/dist/types/yaml/test-runner-nodes.d.ts +6 -0
- package/dist/types/yaml/test-runner-nodes.d.ts.map +1 -0
- package/dist/types/yaml/utils.d.ts +9 -0
- package/dist/types/yaml/utils.d.ts.map +1 -1
- package/dist/types/yaml-runtime.d.ts +13 -0
- package/dist/types/yaml-runtime.d.ts.map +1 -0
- package/dist/types/yaml.d.ts +25 -7
- package/dist/types/yaml.d.ts.map +1 -1
- package/package.json +28 -2
|
@@ -0,0 +1,272 @@
|
|
|
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
|
+
linkResourceSignal: ()=>linkResourceSignal,
|
|
28
|
+
RESOURCE_CLEANUP_GRACE_MS: ()=>RESOURCE_CLEANUP_GRACE_MS,
|
|
29
|
+
ResourceCleanupDeferredError: ()=>ResourceCleanupDeferredError,
|
|
30
|
+
waitForResourceIdle: ()=>waitForResourceIdle,
|
|
31
|
+
createResourceScope: ()=>createResourceScope,
|
|
32
|
+
trackResourceOperation: ()=>trackResourceOperation,
|
|
33
|
+
cleanupScopeResources: ()=>cleanupScopeResources,
|
|
34
|
+
assertResourceAvailable: ()=>assertResourceAvailable,
|
|
35
|
+
getResourceCleanupCompletion: ()=>getResourceCleanupCompletion,
|
|
36
|
+
cleanupResources: ()=>cleanupResources
|
|
37
|
+
});
|
|
38
|
+
const external_errors_js_namespaceObject = require("../errors.js");
|
|
39
|
+
const stateKey = Symbol.for('@midscene/core/resource-operations/v3');
|
|
40
|
+
const host = globalThis;
|
|
41
|
+
host[stateKey] ??= {
|
|
42
|
+
resources: new WeakMap(),
|
|
43
|
+
scopes: new WeakMap(),
|
|
44
|
+
parents: new WeakMap(),
|
|
45
|
+
cleanupOwners: new WeakMap()
|
|
46
|
+
};
|
|
47
|
+
const { resources: resource_operations_resources, scopes, parents, cleanupOwners } = host[stateKey];
|
|
48
|
+
const resourceHandle = (resource)=>{
|
|
49
|
+
let handle = resource_operations_resources.get(resource);
|
|
50
|
+
if (!handle) {
|
|
51
|
+
handle = {
|
|
52
|
+
operations: new Map(),
|
|
53
|
+
retiring: new Set()
|
|
54
|
+
};
|
|
55
|
+
resource_operations_resources.set(resource, handle);
|
|
56
|
+
}
|
|
57
|
+
return handle;
|
|
58
|
+
};
|
|
59
|
+
const getResourceCleanupCompletion = (owner)=>resource_operations_resources.get(owner)?.cleanup;
|
|
60
|
+
const RESOURCE_CLEANUP_GRACE_MS = 1000;
|
|
61
|
+
function linkResourceSignal(signal, parent) {
|
|
62
|
+
if (parent && parent !== signal) parents.set(signal, parent);
|
|
63
|
+
}
|
|
64
|
+
function* ownerSignals(signal) {
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
for(let owner = signal; owner && !seen.has(owner); owner = parents.get(owner)){
|
|
67
|
+
seen.add(owner);
|
|
68
|
+
yield owner;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function createResourceScope(parent) {
|
|
72
|
+
const controller = new AbortController();
|
|
73
|
+
const scope = {
|
|
74
|
+
operations: new Map(),
|
|
75
|
+
resources: new Set()
|
|
76
|
+
};
|
|
77
|
+
scopes.set(controller.signal, scope);
|
|
78
|
+
linkResourceSignal(controller.signal, parent);
|
|
79
|
+
const abort = ()=>controller.abort(parent?.reason);
|
|
80
|
+
if (parent?.aborted) abort();
|
|
81
|
+
else parent?.addEventListener('abort', abort, {
|
|
82
|
+
once: true
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
signal: controller.signal,
|
|
86
|
+
dispose () {
|
|
87
|
+
parent?.removeEventListener('abort', abort);
|
|
88
|
+
scope.resources = void 0;
|
|
89
|
+
if (!scope.operations.size) scopes.delete(controller.signal);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function assertResourceAvailable(resource, exclusive = false, signal) {
|
|
94
|
+
const retiringOwners = resource_operations_resources.get(resource)?.retiring;
|
|
95
|
+
const isOwnerCleanup = [
|
|
96
|
+
...ownerSignals(signal)
|
|
97
|
+
].some((ownerSignal)=>{
|
|
98
|
+
const owner = cleanupOwners.get(ownerSignal);
|
|
99
|
+
return void 0 !== owner && retiringOwners?.has(owner);
|
|
100
|
+
});
|
|
101
|
+
if (retiringOwners?.size && !isOwnerCleanup) throw new external_errors_js_namespaceObject.WorkflowError('A resource cannot execute overlapping Runner operations while its cleanup is pending.', {
|
|
102
|
+
code: 'RESOURCE_CLEANUP_PENDING'
|
|
103
|
+
});
|
|
104
|
+
const pending = resource_operations_resources.get(resource)?.operations;
|
|
105
|
+
if (exclusive && pending?.size && !isOwnerCleanup) throw new external_errors_js_namespaceObject.WorkflowError('The same Agent instance cannot execute overlapping Runner operations.', {
|
|
106
|
+
code: 'RESOURCE_OPERATION_PENDING'
|
|
107
|
+
});
|
|
108
|
+
if (pending && !isOwnerCleanup && [
|
|
109
|
+
...pending.values()
|
|
110
|
+
].some((signal)=>signal.aborted)) throw new external_errors_js_namespaceObject.WorkflowError('Cannot reuse an Agent while an aborted YAML action or Runner operation is still running.', {
|
|
111
|
+
code: 'RESOURCE_OPERATION_PENDING'
|
|
112
|
+
});
|
|
113
|
+
return isOwnerCleanup;
|
|
114
|
+
}
|
|
115
|
+
const retainForCleanup = (owner, resource)=>{
|
|
116
|
+
owner.resources.add(resource);
|
|
117
|
+
resourceHandle(resource).retiring.add(owner);
|
|
118
|
+
};
|
|
119
|
+
function trackResourceOperation(resource, operation, signal) {
|
|
120
|
+
const active = resourceHandle(resource).operations;
|
|
121
|
+
active.set(operation, signal);
|
|
122
|
+
const ownerScopes = [];
|
|
123
|
+
let retainedByScope = false;
|
|
124
|
+
for (const ownerSignal of ownerSignals(signal)){
|
|
125
|
+
const scope = scopes.get(ownerSignal) ?? {
|
|
126
|
+
operations: new Map()
|
|
127
|
+
};
|
|
128
|
+
scopes.set(ownerSignal, scope);
|
|
129
|
+
scope.operations.set(resource, (scope.operations.get(resource) ?? 0) + 1);
|
|
130
|
+
ownerScopes.push([
|
|
131
|
+
ownerSignal,
|
|
132
|
+
scope
|
|
133
|
+
]);
|
|
134
|
+
if (!retainedByScope && scope.resources) {
|
|
135
|
+
scope.resources.add(resource);
|
|
136
|
+
retainedByScope = true;
|
|
137
|
+
}
|
|
138
|
+
const cleanupOwner = cleanupOwners.get(ownerSignal);
|
|
139
|
+
if (cleanupOwner) retainForCleanup(cleanupOwner, resource);
|
|
140
|
+
}
|
|
141
|
+
const finish = ()=>{
|
|
142
|
+
active.delete(operation);
|
|
143
|
+
for (const [ownerSignal, scope] of ownerScopes){
|
|
144
|
+
const count = scope.operations.get(resource) - 1;
|
|
145
|
+
if (count) scope.operations.set(resource, count);
|
|
146
|
+
else scope.operations.delete(resource);
|
|
147
|
+
if (!scope.operations.size && !scope.resources) scopes.delete(ownerSignal);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
operation.then(finish, finish);
|
|
151
|
+
return operation;
|
|
152
|
+
}
|
|
153
|
+
async function waitForResourceIdle(resource) {
|
|
154
|
+
while(resource_operations_resources.get(resource)?.operations?.size)await Promise.allSettled([
|
|
155
|
+
...resource_operations_resources.get(resource).operations.keys()
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
class ResourceCleanupDeferredError extends external_errors_js_namespaceObject.WorkflowError {
|
|
159
|
+
constructor(graceMs, resourceCount){
|
|
160
|
+
super('Resource cleanup was deferred because an operation did not stop after cancellation. The resource remains quarantined and cleanup will run when that operation settles.', {
|
|
161
|
+
code: 'RESOURCE_CLEANUP_DEFERRED',
|
|
162
|
+
details: {
|
|
163
|
+
graceMs,
|
|
164
|
+
resourceCount
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async function runResourceCleanup(resources, cleanup, options, beforeCleanup) {
|
|
170
|
+
const owner = {
|
|
171
|
+
resources: new Set(),
|
|
172
|
+
signal: beforeCleanup?.signal
|
|
173
|
+
};
|
|
174
|
+
for (const resource of resources)retainForCleanup(owner, resource);
|
|
175
|
+
if (owner.signal) cleanupOwners.set(owner.signal, owner);
|
|
176
|
+
let defer;
|
|
177
|
+
const deferred = new Promise((resolve)=>{
|
|
178
|
+
defer = ()=>resolve({
|
|
179
|
+
deferred: true
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
const graceMs = options.graceMs ?? RESOURCE_CLEANUP_GRACE_MS;
|
|
183
|
+
const drain = async ()=>{
|
|
184
|
+
const pending = [
|
|
185
|
+
...owner.resources
|
|
186
|
+
].filter((resource)=>resourceHandle(resource).operations.size);
|
|
187
|
+
if (!pending.length) return;
|
|
188
|
+
const timer = setTimeout(defer, graceMs);
|
|
189
|
+
try {
|
|
190
|
+
await Promise.all(pending.map(waitForResourceIdle));
|
|
191
|
+
} finally{
|
|
192
|
+
clearTimeout(timer);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const completion = (async ()=>{
|
|
196
|
+
try {
|
|
197
|
+
if (beforeCleanup) await beforeCleanup.run(beforeCleanup.signal);
|
|
198
|
+
await drain();
|
|
199
|
+
return await cleanup();
|
|
200
|
+
} finally{
|
|
201
|
+
if (owner.signal) cleanupOwners.delete(owner.signal);
|
|
202
|
+
for (const resource of owner.resources){
|
|
203
|
+
const owners = resourceHandle(resource).retiring;
|
|
204
|
+
owners.delete(owner);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
208
|
+
const ownerKey = options.owner ?? beforeCleanup?.signal ?? resources[0];
|
|
209
|
+
if (ownerKey) resourceHandle(ownerKey).cleanup = completion;
|
|
210
|
+
const outcome = await Promise.race([
|
|
211
|
+
completion.then((value)=>({
|
|
212
|
+
value
|
|
213
|
+
})),
|
|
214
|
+
deferred
|
|
215
|
+
]);
|
|
216
|
+
if ('deferred' in outcome) {
|
|
217
|
+
completion.catch((error)=>{
|
|
218
|
+
try {
|
|
219
|
+
options.onDeferredError(error);
|
|
220
|
+
} catch {}
|
|
221
|
+
});
|
|
222
|
+
if (options.signal) trackResourceOperation({}, completion, options.signal);
|
|
223
|
+
throw new ResourceCleanupDeferredError(graceMs, owner.resources.size);
|
|
224
|
+
}
|
|
225
|
+
return outcome.value;
|
|
226
|
+
}
|
|
227
|
+
function cleanupResources(resources, cleanup, options) {
|
|
228
|
+
return runResourceCleanup(resources, cleanup, options);
|
|
229
|
+
}
|
|
230
|
+
async function cleanupScopeResources(signal, cleanup, options) {
|
|
231
|
+
const cleanupSignal = new AbortController().signal;
|
|
232
|
+
linkResourceSignal(cleanupSignal, signal);
|
|
233
|
+
const scope = scopes.get(signal);
|
|
234
|
+
return runResourceCleanup([
|
|
235
|
+
...scope?.resources ?? [],
|
|
236
|
+
...scope?.operations.keys() ?? []
|
|
237
|
+
], cleanup, {
|
|
238
|
+
...options,
|
|
239
|
+
owner: signal,
|
|
240
|
+
signal
|
|
241
|
+
}, options.beforeCleanup ? {
|
|
242
|
+
signal: cleanupSignal,
|
|
243
|
+
run: options.beforeCleanup
|
|
244
|
+
} : void 0);
|
|
245
|
+
}
|
|
246
|
+
exports.RESOURCE_CLEANUP_GRACE_MS = __webpack_exports__.RESOURCE_CLEANUP_GRACE_MS;
|
|
247
|
+
exports.ResourceCleanupDeferredError = __webpack_exports__.ResourceCleanupDeferredError;
|
|
248
|
+
exports.assertResourceAvailable = __webpack_exports__.assertResourceAvailable;
|
|
249
|
+
exports.cleanupResources = __webpack_exports__.cleanupResources;
|
|
250
|
+
exports.cleanupScopeResources = __webpack_exports__.cleanupScopeResources;
|
|
251
|
+
exports.createResourceScope = __webpack_exports__.createResourceScope;
|
|
252
|
+
exports.getResourceCleanupCompletion = __webpack_exports__.getResourceCleanupCompletion;
|
|
253
|
+
exports.linkResourceSignal = __webpack_exports__.linkResourceSignal;
|
|
254
|
+
exports.trackResourceOperation = __webpack_exports__.trackResourceOperation;
|
|
255
|
+
exports.waitForResourceIdle = __webpack_exports__.waitForResourceIdle;
|
|
256
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
257
|
+
"RESOURCE_CLEANUP_GRACE_MS",
|
|
258
|
+
"ResourceCleanupDeferredError",
|
|
259
|
+
"assertResourceAvailable",
|
|
260
|
+
"cleanupResources",
|
|
261
|
+
"cleanupScopeResources",
|
|
262
|
+
"createResourceScope",
|
|
263
|
+
"getResourceCleanupCompletion",
|
|
264
|
+
"linkResourceSignal",
|
|
265
|
+
"trackResourceOperation",
|
|
266
|
+
"waitForResourceIdle"
|
|
267
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
268
|
+
Object.defineProperty(exports, '__esModule', {
|
|
269
|
+
value: true
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
//# sourceMappingURL=resource-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runner/engine/resource-operations.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/resource-operations.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 { WorkflowError } from '../errors';\n\ninterface CleanupOwner {\n resources: Set<object>;\n signal?: AbortSignal;\n}\n\ninterface ResourceScope {\n operations: Map<object, number>;\n resources?: Set<object>;\n}\n\ninterface ResourceHandle {\n operations: Map<Promise<unknown>, AbortSignal>;\n retiring: Set<CleanupOwner>;\n cleanup?: Promise<unknown>;\n}\n\ninterface ResourceState {\n resources: WeakMap<object, ResourceHandle>;\n scopes: WeakMap<AbortSignal, ResourceScope>;\n parents: WeakMap<AbortSignal, AbortSignal>;\n cleanupOwners: WeakMap<AbortSignal, CleanupOwner>;\n}\n\n// CJS and ESM hosts must agree about ownership of the same Agent instance.\nconst stateKey = Symbol.for('@midscene/core/resource-operations/v3');\nconst host = globalThis as typeof globalThis & { [stateKey]?: ResourceState };\nhost[stateKey] ??= {\n resources: new WeakMap(),\n scopes: new WeakMap(),\n parents: new WeakMap(),\n cleanupOwners: new WeakMap(),\n};\nconst { resources, scopes, parents, cleanupOwners } = host[stateKey];\nconst resourceHandle = (resource: object): ResourceHandle => {\n let handle = resources.get(resource);\n if (!handle) {\n handle = { operations: new Map(), retiring: new Set() };\n resources.set(resource, handle);\n }\n return handle;\n};\n\n/** Actual teardown completion belongs to the owner, never to a thrown error. */\nexport const getResourceCleanupCompletion = (\n owner: object,\n): Promise<unknown> | undefined => resources.get(owner)?.cleanup;\n\nexport const RESOURCE_CLEANUP_GRACE_MS = 1000;\n\n/** Resource ancestry is independent of cancellation: cleanup can outlive abort. */\nexport function linkResourceSignal(signal: AbortSignal, parent?: AbortSignal) {\n if (parent && parent !== signal) parents.set(signal, parent);\n}\n\nfunction* ownerSignals(signal?: AbortSignal): Generator<AbortSignal> {\n const seen = new Set<AbortSignal>();\n for (\n let owner = signal;\n owner && !seen.has(owner);\n owner = parents.get(owner)\n ) {\n seen.add(owner);\n yield owner;\n }\n}\n\n/** Each Case/document owns its cleanup, even when cancellation is shared. */\nexport function createResourceScope(parent?: AbortSignal) {\n const controller = new AbortController();\n const scope: ResourceScope = { operations: new Map(), resources: new Set() };\n scopes.set(controller.signal, scope);\n linkResourceSignal(controller.signal, parent);\n const abort = () => controller.abort(parent?.reason);\n if (parent?.aborted) abort();\n else parent?.addEventListener('abort', abort, { once: true });\n return {\n signal: controller.signal,\n dispose() {\n parent?.removeEventListener('abort', abort);\n scope.resources = undefined;\n if (!scope.operations.size) scopes.delete(controller.signal);\n },\n };\n}\n\nexport function assertResourceAvailable(\n resource: object,\n exclusive = false,\n signal?: AbortSignal,\n): boolean {\n const retiringOwners = resources.get(resource)?.retiring;\n const isOwnerCleanup = [...ownerSignals(signal)].some((ownerSignal) => {\n const owner = cleanupOwners.get(ownerSignal);\n return owner !== undefined && retiringOwners?.has(owner);\n });\n if (retiringOwners?.size && !isOwnerCleanup)\n throw new WorkflowError(\n 'A resource cannot execute overlapping Runner operations while its cleanup is pending.',\n { code: 'RESOURCE_CLEANUP_PENDING' },\n );\n const pending = resources.get(resource)?.operations;\n if (exclusive && pending?.size && !isOwnerCleanup)\n throw new WorkflowError(\n 'The same Agent instance cannot execute overlapping Runner operations.',\n { code: 'RESOURCE_OPERATION_PENDING' },\n );\n if (\n pending &&\n !isOwnerCleanup &&\n [...pending.values()].some((signal) => signal.aborted)\n )\n throw new WorkflowError(\n 'Cannot reuse an Agent while an aborted YAML action or Runner operation is still running.',\n { code: 'RESOURCE_OPERATION_PENDING' },\n );\n return isOwnerCleanup;\n}\n\nconst retainForCleanup = (owner: CleanupOwner, resource: object) => {\n owner.resources.add(resource);\n resourceHandle(resource).retiring.add(owner);\n};\n\n/** Track actual completion, not the Runner timeout race. */\nexport function trackResourceOperation<T>(\n resource: object,\n operation: Promise<T>,\n signal: AbortSignal,\n): Promise<T> {\n const active = resourceHandle(resource).operations;\n active.set(operation, signal);\n const ownerScopes: Array<[AbortSignal, ResourceScope]> = [];\n let retainedByScope = false;\n for (const ownerSignal of ownerSignals(signal)) {\n const scope: ResourceScope = scopes.get(ownerSignal) ?? {\n operations: new Map(),\n };\n scopes.set(ownerSignal, scope);\n scope.operations.set(resource, (scope.operations.get(resource) ?? 0) + 1);\n ownerScopes.push([ownerSignal, scope]);\n // Only the closest owner retains idle resources for its teardown. Parents\n // wait on active operations, not every Agent used by completed Cases.\n if (!retainedByScope && scope.resources) {\n scope.resources.add(resource);\n retainedByScope = true;\n }\n const cleanupOwner = cleanupOwners.get(ownerSignal);\n if (cleanupOwner) retainForCleanup(cleanupOwner, resource);\n }\n const finish = () => {\n active.delete(operation);\n for (const [ownerSignal, scope] of ownerScopes) {\n const count = scope.operations.get(resource)! - 1;\n if (count) scope.operations.set(resource, count);\n else scope.operations.delete(resource);\n if (!scope.operations.size && !scope.resources)\n scopes.delete(ownerSignal);\n }\n };\n void operation.then(finish, finish);\n return operation;\n}\n\nexport async function waitForResourceIdle(resource: object): Promise<void> {\n while (resources.get(resource)?.operations?.size)\n await Promise.allSettled([...resources.get(resource)!.operations.keys()]);\n}\n\nexport class ResourceCleanupDeferredError extends WorkflowError {\n constructor(graceMs: number, resourceCount: number) {\n super(\n 'Resource cleanup was deferred because an operation did not stop after cancellation. The resource remains quarantined and cleanup will run when that operation settles.',\n {\n code: 'RESOURCE_CLEANUP_DEFERRED',\n details: { graceMs, resourceCount },\n },\n );\n }\n}\n\ninterface CleanupOptions {\n /** Stable owner of this cleanup, distinct from borrowed resource identities. */\n owner?: object;\n /** Parent scope observes deferred completion without host-specific forwarding. */\n signal?: AbortSignal;\n graceMs?: number;\n onDeferredError(error: unknown): void;\n}\n\n/** Bound draining, but keep ownership until the actual cleanup has finished. */\nasync function runResourceCleanup<T>(\n resources: readonly object[],\n cleanup: () => Promise<T>,\n options: CleanupOptions,\n beforeCleanup?: {\n signal: AbortSignal;\n run(signal: AbortSignal): Promise<void>;\n },\n): Promise<T> {\n const owner: CleanupOwner = {\n resources: new Set(),\n signal: beforeCleanup?.signal,\n };\n for (const resource of resources) retainForCleanup(owner, resource);\n if (owner.signal) cleanupOwners.set(owner.signal, owner);\n\n let defer!: () => void;\n const deferred = new Promise<{ deferred: true }>((resolve) => {\n defer = () => resolve({ deferred: true });\n });\n const graceMs = options.graceMs ?? RESOURCE_CLEANUP_GRACE_MS;\n const drain = async () => {\n const pending = [...owner.resources].filter(\n (resource) => resourceHandle(resource).operations.size,\n );\n if (!pending.length) return;\n const timer = setTimeout(defer, graceMs);\n try {\n await Promise.all(pending.map(waitForResourceIdle));\n } finally {\n clearTimeout(timer);\n }\n };\n const completion = (async () => {\n try {\n if (beforeCleanup) {\n // Authored lifecycle cleanup must be allowed to stop or reset a\n // resource whose timed-out operation is still settling. Its signal is\n // registered as the retiring owner's cleanup signal, so unrelated\n // scopes remain quarantined while this hook runs.\n await beforeCleanup.run(beforeCleanup.signal);\n }\n // Lifecycle hooks can themselves time out with an action still running.\n // Drain both the original work and any operation started by the hook\n // before disposing the resource.\n await drain();\n return await cleanup();\n } finally {\n if (owner.signal) cleanupOwners.delete(owner.signal);\n for (const resource of owner.resources) {\n const owners = resourceHandle(resource).retiring;\n owners.delete(owner);\n }\n }\n })();\n const ownerKey = options.owner ?? beforeCleanup?.signal ?? resources[0];\n if (ownerKey) resourceHandle(ownerKey).cleanup = completion;\n const outcome = await Promise.race([\n completion.then((value) => ({ value })),\n deferred,\n ]);\n if ('deferred' in outcome) {\n void completion.catch((error) => {\n try {\n options.onDeferredError(error);\n } catch {\n // The returned completion still carries the original cleanup failure.\n }\n });\n if (options.signal) trackResourceOperation({}, completion, options.signal);\n throw new ResourceCleanupDeferredError(graceMs, owner.resources.size);\n }\n return outcome.value;\n}\n\nexport function cleanupResources<T>(\n resources: readonly object[],\n cleanup: () => Promise<T>,\n options: CleanupOptions,\n): Promise<T> {\n return runResourceCleanup(resources, cleanup, options);\n}\n\nexport async function cleanupScopeResources<T>(\n signal: AbortSignal,\n cleanup: () => Promise<T>,\n options: CleanupOptions & {\n beforeCleanup?(signal: AbortSignal): Promise<void>;\n },\n): Promise<T> {\n const cleanupSignal = new AbortController().signal;\n linkResourceSignal(cleanupSignal, signal);\n const scope = scopes.get(signal);\n return runResourceCleanup(\n [...(scope?.resources ?? []), ...(scope?.operations.keys() ?? [])],\n cleanup,\n { ...options, owner: signal, signal },\n options.beforeCleanup\n ? { signal: cleanupSignal, run: options.beforeCleanup }\n : undefined,\n );\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","stateKey","host","globalThis","WeakMap","resources","scopes","parents","cleanupOwners","resourceHandle","resource","handle","Map","Set","getResourceCleanupCompletion","owner","RESOURCE_CLEANUP_GRACE_MS","linkResourceSignal","signal","parent","ownerSignals","seen","createResourceScope","controller","AbortController","scope","abort","undefined","assertResourceAvailable","exclusive","retiringOwners","isOwnerCleanup","ownerSignal","WorkflowError","pending","retainForCleanup","trackResourceOperation","operation","active","ownerScopes","retainedByScope","cleanupOwner","finish","count","waitForResourceIdle","Promise","ResourceCleanupDeferredError","graceMs","resourceCount","runResourceCleanup","cleanup","options","beforeCleanup","defer","deferred","resolve","drain","timer","setTimeout","clearTimeout","completion","owners","ownerKey","outcome","value","error","cleanupResources","cleanupScopeResources","cleanupSignal"],"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;;;;;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AW,IAAI,CAAC,CAACI,QAAW;gBAAEA;YAAM;QACpCV;KACD;IACD,IAAI,cAAcS,SAAS;QACpBH,WAAW,KAAK,CAAC,CAACK;YACrB,IAAI;gBACFd,QAAQ,eAAe,CAACc;YAC1B,EAAE,OAAM,CAER;QACF;QACA,IAAId,QAAQ,MAAM,EAAEf,uBAAuB,CAAC,GAAGwB,YAAYT,QAAQ,MAAM;QACzE,MAAM,IAAIL,6BAA6BC,SAAShC,MAAM,SAAS,CAAC,IAAI;IACtE;IACA,OAAOgD,QAAQ,KAAK;AACtB;AAEO,SAASG,iBACd7D,SAA4B,EAC5B6C,OAAyB,EACzBC,OAAuB;IAEvB,OAAOF,mBAAmB5C,WAAW6C,SAASC;AAChD;AAEO,eAAegB,sBACpBjD,MAAmB,EACnBgC,OAAyB,EACzBC,OAEC;IAED,MAAMiB,gBAAgB,IAAI5C,kBAAkB,MAAM;IAClDP,mBAAmBmD,eAAelD;IAClC,MAAMO,QAAQnB,OAAO,GAAG,CAACY;IACzB,OAAO+B,mBACL;WAAKxB,OAAO,aAAa,EAAE;WAAOA,OAAO,WAAW,UAAU,EAAE;KAAE,EAClEyB,SACA;QAAE,GAAGC,OAAO;QAAE,OAAOjC;QAAQA;IAAO,GACpCiC,QAAQ,aAAa,GACjB;QAAE,QAAQiB;QAAe,KAAKjB,QAAQ,aAAa;IAAC,IACpDxB;AAER"}
|
|
@@ -0,0 +1,227 @@
|
|
|
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
|
+
runCollectedCase: ()=>runCollectedCase
|
|
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
|
+
async function runCollectedCase(collectedCase, options) {
|
|
37
|
+
const phases = {
|
|
38
|
+
beforeEach: options.beforeEach ?? [],
|
|
39
|
+
steps: collectedCase.definition.steps,
|
|
40
|
+
afterEach: options.afterEach ?? []
|
|
41
|
+
};
|
|
42
|
+
const nodes = {
|
|
43
|
+
beforeEach: phases.beforeEach.map((step)=>options.resolveNode(step.node)),
|
|
44
|
+
steps: phases.steps.map((step)=>options.resolveNode(step.node)),
|
|
45
|
+
afterEach: phases.afterEach.map((step)=>options.resolveNode(step.node))
|
|
46
|
+
};
|
|
47
|
+
const resourceScope = (0, external_resource_operations_js_namespaceObject.createResourceScope)(options.signal);
|
|
48
|
+
const scopeSignal = resourceScope.signal;
|
|
49
|
+
const runId = options.createRunId?.() ?? (0, utils_namespaceObject.uuid)();
|
|
50
|
+
const startedAt = new Date();
|
|
51
|
+
const beforeEach = [];
|
|
52
|
+
const steps = [];
|
|
53
|
+
const afterEach = [];
|
|
54
|
+
const teardownStack = [];
|
|
55
|
+
let acceptingTeardowns = true;
|
|
56
|
+
const onTeardown = (node, teardown)=>{
|
|
57
|
+
if (!acceptingTeardowns) throw new external_errors_js_namespaceObject.WorkflowLifecycleError('Node teardown can only be registered while a case attempt is running.', {
|
|
58
|
+
runId,
|
|
59
|
+
node
|
|
60
|
+
});
|
|
61
|
+
if ('function' != typeof teardown) throw new external_errors_js_namespaceObject.WorkflowLifecycleError('Node onTeardown() requires a teardown function.', {
|
|
62
|
+
runId,
|
|
63
|
+
node
|
|
64
|
+
});
|
|
65
|
+
teardownStack.push({
|
|
66
|
+
registrationIndex: teardownStack.length,
|
|
67
|
+
node,
|
|
68
|
+
teardown
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const runPhase = async (phase, results, signal = scopeSignal)=>{
|
|
72
|
+
for (const [stepIndex, step] of phases[phase].entries()){
|
|
73
|
+
const caseContext = {
|
|
74
|
+
caseId: collectedCase.caseId,
|
|
75
|
+
runId,
|
|
76
|
+
projectName: options.projectName ?? collectedCase.projectId,
|
|
77
|
+
attemptIndex: options.attemptIndex ?? 0,
|
|
78
|
+
name: collectedCase.definition.name,
|
|
79
|
+
sourcePath: collectedCase.sourcePath,
|
|
80
|
+
caseIndex: collectedCase.caseIndex,
|
|
81
|
+
phase,
|
|
82
|
+
stepIndex
|
|
83
|
+
};
|
|
84
|
+
const stepInfo = {
|
|
85
|
+
scope: 'case',
|
|
86
|
+
node: step.node,
|
|
87
|
+
stepCount: phases[phase].length,
|
|
88
|
+
case: caseContext
|
|
89
|
+
};
|
|
90
|
+
await options.onStepStart?.(stepInfo);
|
|
91
|
+
const result = await (0, external_execute_step_js_namespaceObject.executeStep)(step, nodes[phase][stepIndex], {
|
|
92
|
+
scope: 'case',
|
|
93
|
+
case: caseContext
|
|
94
|
+
}, options.context, {
|
|
95
|
+
signal,
|
|
96
|
+
defaultTimeoutMs: options.defaultTimeoutMs,
|
|
97
|
+
onTeardown
|
|
98
|
+
});
|
|
99
|
+
results.push(result);
|
|
100
|
+
await options.onStepResult?.(stepInfo, result);
|
|
101
|
+
if ('failed' === result.status && !result.continuedAfterError) break;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const executionErrors = [];
|
|
105
|
+
try {
|
|
106
|
+
await runPhase('beforeEach', beforeEach);
|
|
107
|
+
if (!beforeEach.some((step)=>'failed' === step.status)) await runPhase('steps', steps);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
executionErrors.push(error);
|
|
110
|
+
}
|
|
111
|
+
const teardownErrors = [];
|
|
112
|
+
const reportPaths = new Set();
|
|
113
|
+
const reportSources = [];
|
|
114
|
+
const cleanupExecutionErrors = [];
|
|
115
|
+
let deferredCleanup = false;
|
|
116
|
+
const cleanup = async ()=>{
|
|
117
|
+
const priorTeardownErrors = teardownErrors.length;
|
|
118
|
+
acceptingTeardowns = false;
|
|
119
|
+
for (const { registrationIndex, node, teardown } of teardownStack.reverse())try {
|
|
120
|
+
const released = await teardown();
|
|
121
|
+
reportSources.push(...released?.reportSources ?? []);
|
|
122
|
+
for (const path of (0, external_scope_teardown_js_namespaceObject.reportPathsFromTeardown)(released))reportPaths.add(path);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
teardownErrors.push(new external_errors_js_namespaceObject.NodeScopeTeardownError(error, {
|
|
125
|
+
scope: 'case',
|
|
126
|
+
scopeId: runId,
|
|
127
|
+
node,
|
|
128
|
+
registrationIndex
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
if (deferredCleanup) {
|
|
132
|
+
const errors = [
|
|
133
|
+
...cleanupExecutionErrors,
|
|
134
|
+
...teardownErrors.slice(priorTeardownErrors)
|
|
135
|
+
];
|
|
136
|
+
if (errors.length) throw new AggregateError(errors, 'Deferred Case cleanup failed');
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
try {
|
|
140
|
+
if (phases.afterEach.length || teardownStack.length) await (0, external_resource_operations_js_namespaceObject.cleanupScopeResources)(scopeSignal, cleanup, {
|
|
141
|
+
beforeCleanup: async (cleanupSignal)=>{
|
|
142
|
+
try {
|
|
143
|
+
await runPhase('afterEach', afterEach, cleanupSignal);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
executionErrors.push(error);
|
|
146
|
+
cleanupExecutionErrors.push(error);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
onDeferredError: (error)=>(0, logger_namespaceObject.getDebug)('runner:cleanup', {
|
|
150
|
+
console: true
|
|
151
|
+
})(`Deferred Case cleanup failed: ${String(error)}`)
|
|
152
|
+
});
|
|
153
|
+
else acceptingTeardowns = false;
|
|
154
|
+
} catch (error) {
|
|
155
|
+
deferredCleanup = error instanceof external_resource_operations_js_namespaceObject.ResourceCleanupDeferredError;
|
|
156
|
+
if (!deferredCleanup) acceptingTeardowns = false;
|
|
157
|
+
teardownErrors.push(new external_errors_js_namespaceObject.NodeScopeTeardownError(error, {
|
|
158
|
+
scope: 'case',
|
|
159
|
+
scopeId: runId,
|
|
160
|
+
node: 'resource-drain',
|
|
161
|
+
registrationIndex: -1
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
const endedAt = new Date();
|
|
165
|
+
const result = {
|
|
166
|
+
caseId: collectedCase.caseId,
|
|
167
|
+
runId,
|
|
168
|
+
projectName: options.projectName ?? collectedCase.projectId,
|
|
169
|
+
attemptIndex: options.attemptIndex ?? 0,
|
|
170
|
+
name: collectedCase.definition.name,
|
|
171
|
+
sourcePath: collectedCase.sourcePath,
|
|
172
|
+
caseIndex: collectedCase.caseIndex,
|
|
173
|
+
status: executionErrors.length > 0 || beforeEach.some((step)=>'failed' === step.status) || steps.some((step)=>'failed' === step.status) || afterEach.some((step)=>'failed' === step.status) || teardownErrors.length > 0 ? 'failed' : 'success',
|
|
174
|
+
beforeEach: [
|
|
175
|
+
...beforeEach
|
|
176
|
+
],
|
|
177
|
+
steps: [
|
|
178
|
+
...steps
|
|
179
|
+
],
|
|
180
|
+
afterEach: [
|
|
181
|
+
...afterEach
|
|
182
|
+
],
|
|
183
|
+
...executionErrors.length ? {
|
|
184
|
+
executionErrors: executionErrors.map(external_execution_failure_js_namespaceObject.asExecutionError)
|
|
185
|
+
} : {},
|
|
186
|
+
...teardownErrors.length > 0 ? {
|
|
187
|
+
teardownErrors: [
|
|
188
|
+
...teardownErrors
|
|
189
|
+
]
|
|
190
|
+
} : {},
|
|
191
|
+
...reportPaths.size > 0 ? {
|
|
192
|
+
reportPaths: [
|
|
193
|
+
...reportPaths
|
|
194
|
+
]
|
|
195
|
+
} : {},
|
|
196
|
+
...reportSources.length ? {
|
|
197
|
+
reportSources: [
|
|
198
|
+
...reportSources
|
|
199
|
+
]
|
|
200
|
+
} : {},
|
|
201
|
+
...options.reportScopeId ? {
|
|
202
|
+
reportScopeId: options.reportScopeId
|
|
203
|
+
} : {},
|
|
204
|
+
startedAt: startedAt.toISOString(),
|
|
205
|
+
endedAt: endedAt.toISOString(),
|
|
206
|
+
durationMs: Math.max(0, endedAt.getTime() - startedAt.getTime())
|
|
207
|
+
};
|
|
208
|
+
try {
|
|
209
|
+
await options.onResult?.(result);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
executionErrors.push(error);
|
|
212
|
+
result.status = 'failed';
|
|
213
|
+
result.executionErrors = executionErrors.map(external_execution_failure_js_namespaceObject.asExecutionError);
|
|
214
|
+
}
|
|
215
|
+
resourceScope.dispose();
|
|
216
|
+
if (executionErrors.length) throw new external_execution_failure_js_namespaceObject.WorkflowExecutionFailure(result, executionErrors);
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
exports.runCollectedCase = __webpack_exports__.runCollectedCase;
|
|
220
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
221
|
+
"runCollectedCase"
|
|
222
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
223
|
+
Object.defineProperty(exports, '__esModule', {
|
|
224
|
+
value: true
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=run-collected-case.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runner/engine/run-collected-case.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/run-collected-case.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 { NodeScopeTeardownError, WorkflowLifecycleError } from '../errors';\nimport type { CollectedCase, NormalizedStep } 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 CaseNodePhase,\n CaseRunResult,\n NodeCaseContext,\n NodeScopeTeardown,\n RunCollectedCaseOptions,\n StepRunResult,\n} from './types';\n\nexport async function runCollectedCase<TContext = undefined>(\n collectedCase: CollectedCase,\n options: RunCollectedCaseOptions<TContext>,\n): Promise<CaseRunResult> {\n const phases: Record<CaseNodePhase, readonly NormalizedStep[]> = {\n beforeEach: options.beforeEach ?? [],\n steps: collectedCase.definition.steps,\n afterEach: options.afterEach ?? [],\n };\n const nodes = {\n beforeEach: phases.beforeEach.map((step) => options.resolveNode(step.node)),\n steps: phases.steps.map((step) => options.resolveNode(step.node)),\n afterEach: phases.afterEach.map((step) => options.resolveNode(step.node)),\n };\n const resourceScope = createResourceScope(options.signal);\n const scopeSignal = resourceScope.signal;\n const runId = options.createRunId?.() ?? randomUUID();\n const startedAt = new Date();\n const beforeEach: StepRunResult[] = [];\n const steps: StepRunResult[] = [];\n const afterEach: StepRunResult[] = [];\n const teardownStack: Array<{\n registrationIndex: number;\n node: string;\n teardown: NodeScopeTeardown;\n }> = [];\n let acceptingTeardowns = true;\n\n const onTeardown = (node: string, teardown: NodeScopeTeardown): void => {\n if (!acceptingTeardowns) {\n throw new WorkflowLifecycleError(\n 'Node teardown can only be registered while a case attempt is running.',\n { runId, node },\n );\n }\n if (typeof teardown !== 'function') {\n throw new WorkflowLifecycleError(\n 'Node onTeardown() requires a teardown function.',\n { runId, node },\n );\n }\n teardownStack.push({\n registrationIndex: teardownStack.length,\n node,\n teardown,\n });\n };\n\n const runPhase = async (\n phase: CaseNodePhase,\n results: StepRunResult[],\n signal = scopeSignal,\n ): Promise<void> => {\n for (const [stepIndex, step] of phases[phase].entries()) {\n const caseContext: NodeCaseContext = {\n caseId: collectedCase.caseId,\n runId,\n projectName: options.projectName ?? collectedCase.projectId,\n attemptIndex: options.attemptIndex ?? 0,\n name: collectedCase.definition.name,\n sourcePath: collectedCase.sourcePath,\n caseIndex: collectedCase.caseIndex,\n phase,\n stepIndex,\n };\n const stepInfo = {\n scope: 'case' as const,\n node: step.node,\n stepCount: phases[phase].length,\n case: caseContext,\n };\n await options.onStepStart?.(stepInfo);\n const result = await executeStep(\n step,\n nodes[phase][stepIndex],\n { scope: 'case', case: caseContext },\n options.context as TContext,\n {\n signal,\n defaultTimeoutMs: options.defaultTimeoutMs,\n onTeardown,\n },\n );\n results.push(result);\n await options.onStepResult?.(stepInfo, result);\n if (result.status === 'failed' && !result.continuedAfterError) break;\n }\n };\n\n const executionErrors: unknown[] = [];\n try {\n await runPhase('beforeEach', beforeEach);\n if (!beforeEach.some((step) => step.status === 'failed')) {\n await runPhase('steps', steps);\n }\n } catch (error) {\n executionErrors.push(error);\n }\n const teardownErrors: NodeScopeTeardownError[] = [];\n const reportPaths = new Set<string>();\n const reportSources: import('./types').WorkflowReportSource[] = [];\n const cleanupExecutionErrors: unknown[] = [];\n let deferredCleanup = false;\n const cleanup = async () => {\n const priorTeardownErrors = teardownErrors.length;\n acceptingTeardowns = false;\n for (const {\n registrationIndex,\n node,\n teardown,\n } of teardownStack.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 teardownErrors.push(\n new NodeScopeTeardownError(error, {\n scope: 'case',\n scopeId: runId,\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(errors, 'Deferred Case cleanup failed');\n }\n };\n try {\n if (phases.afterEach.length || teardownStack.length)\n await cleanupScopeResources(scopeSignal, cleanup, {\n beforeCleanup: async (cleanupSignal) => {\n try {\n await runPhase('afterEach', afterEach, 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 Case cleanup failed: ${String(error)}`,\n ),\n });\n else acceptingTeardowns = false;\n } catch (error) {\n deferredCleanup = error instanceof ResourceCleanupDeferredError;\n if (!deferredCleanup) acceptingTeardowns = false;\n teardownErrors.push(\n new NodeScopeTeardownError(error, {\n scope: 'case',\n scopeId: runId,\n node: 'resource-drain',\n registrationIndex: -1,\n }),\n );\n }\n const endedAt = new Date();\n const result: CaseRunResult = {\n caseId: collectedCase.caseId,\n runId,\n projectName: options.projectName ?? collectedCase.projectId,\n attemptIndex: options.attemptIndex ?? 0,\n name: collectedCase.definition.name,\n sourcePath: collectedCase.sourcePath,\n caseIndex: collectedCase.caseIndex,\n status:\n executionErrors.length > 0 ||\n beforeEach.some((step) => step.status === 'failed') ||\n steps.some((step) => step.status === 'failed') ||\n afterEach.some((step) => step.status === 'failed') ||\n teardownErrors.length > 0\n ? 'failed'\n : 'success',\n beforeEach: [...beforeEach],\n steps: [...steps],\n afterEach: [...afterEach],\n ...(executionErrors.length\n ? { executionErrors: executionErrors.map(asExecutionError) }\n : {}),\n ...(teardownErrors.length > 0\n ? { teardownErrors: [...teardownErrors] }\n : {}),\n ...(reportPaths.size > 0 ? { reportPaths: [...reportPaths] } : {}),\n ...(reportSources.length ? { reportSources: [...reportSources] } : {}),\n ...(options.reportScopeId ? { reportScopeId: options.reportScopeId } : {}),\n startedAt: startedAt.toISOString(),\n endedAt: endedAt.toISOString(),\n durationMs: Math.max(0, endedAt.getTime() - startedAt.getTime()),\n };\n\n try {\n await options.onResult?.(result);\n } catch (error) {\n executionErrors.push(error);\n result.status = 'failed';\n result.executionErrors = executionErrors.map(asExecutionError);\n }\n resourceScope.dispose();\n if (executionErrors.length)\n throw new WorkflowExecutionFailure(result, executionErrors);\n return result;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","runCollectedCase","collectedCase","options","phases","nodes","step","resourceScope","createResourceScope","scopeSignal","runId","randomUUID","startedAt","Date","beforeEach","steps","afterEach","teardownStack","acceptingTeardowns","onTeardown","node","teardown","WorkflowLifecycleError","runPhase","phase","results","signal","stepIndex","caseContext","stepInfo","result","executeStep","executionErrors","error","teardownErrors","reportPaths","Set","reportSources","cleanupExecutionErrors","deferredCleanup","cleanup","priorTeardownErrors","registrationIndex","released","path","reportPathsFromTeardown","NodeScopeTeardownError","errors","AggregateError","cleanupScopeResources","cleanupSignal","getDebug","String","ResourceCleanupDeferredError","endedAt","asExecutionError","Math","WorkflowExecutionFailure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