@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,52 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import { ifInBrowser, ifInWorker } from "@midscene/shared/utils";
|
|
3
|
+
import { ReportGenerator } from "../report-generator.mjs";
|
|
4
|
+
import { executionRecordsToReportInput } from "../test-runner/reporting/execution-record.mjs";
|
|
5
|
+
import { getVersion } from "../utils.mjs";
|
|
6
|
+
import { isYamlReportEnabled } from "./report-policy.mjs";
|
|
7
|
+
async function publishLegacyYamlReport(options) {
|
|
8
|
+
const { agent, runId } = options;
|
|
9
|
+
let record = options.record;
|
|
10
|
+
if (agent) {
|
|
11
|
+
const reportFile = await agent._writeYamlExecutionReport?.(record) ?? agent.reportFile;
|
|
12
|
+
const source = await agent._createReportSource?.(runId);
|
|
13
|
+
if (source) record = Object.freeze({
|
|
14
|
+
...record,
|
|
15
|
+
reportSources: [
|
|
16
|
+
source
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
record,
|
|
21
|
+
reportFile
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (ifInBrowser || ifInWorker || !isYamlReportEnabled(options.script)) return {
|
|
25
|
+
record
|
|
26
|
+
};
|
|
27
|
+
const generator = ReportGenerator.create(options.fallbackReportFileName ?? options.script.agent?.reportFileName ?? options.script.agent?.testId ?? (options.scriptPath ? basename(options.scriptPath).replace(/\.ya?ml$/i, '') : `script-${runId}`), options.script.agent ?? {});
|
|
28
|
+
const reportFile = await generator.writeRunnerReport?.(executionRecordsToReportInput([
|
|
29
|
+
record
|
|
30
|
+
], {
|
|
31
|
+
runId
|
|
32
|
+
}), runId, {
|
|
33
|
+
groupName: 'YAML execution',
|
|
34
|
+
sdkVersion: getVersion(),
|
|
35
|
+
modelBriefs: []
|
|
36
|
+
});
|
|
37
|
+
await generator.finalize();
|
|
38
|
+
const source = await generator.createSourceSnapshot?.(runId);
|
|
39
|
+
if (source) record = Object.freeze({
|
|
40
|
+
...record,
|
|
41
|
+
reportSources: [
|
|
42
|
+
source
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
record,
|
|
47
|
+
reportFile
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export { publishLegacyYamlReport };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=legacy-yaml-report.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml/legacy-yaml-report.mjs","sources":["../../../src/yaml/legacy-yaml-report.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { Agent } from '@/agent/agent';\nimport type { MidsceneYamlScript } from '@/types';\nimport { ifInBrowser, ifInWorker } from '@midscene/shared/utils';\nimport { ReportGenerator } from '../report-generator';\nimport type { WorkflowExecutionRecord } from '../test-runner';\nimport { executionRecordsToReportInput } from '../test-runner/reporting/execution-record';\nimport { getVersion } from '../utils';\nimport { isYamlReportEnabled } from './report-policy';\n\ninterface PublishLegacyYamlReportOptions {\n agent: Agent | null;\n record: WorkflowExecutionRecord;\n runId: string;\n script: MidsceneYamlScript;\n scriptPath?: string;\n fallbackReportFileName?: string;\n}\n\nexport interface PublishedLegacyYamlReport {\n record: WorkflowExecutionRecord;\n reportFile?: string | null;\n}\n\n/** Report publication is a host projection, not a ScriptPlayer state concern. */\nexport async function publishLegacyYamlReport(\n options: PublishLegacyYamlReportOptions,\n): Promise<PublishedLegacyYamlReport> {\n const { agent, runId } = options;\n let record = options.record;\n if (agent) {\n const reportFile =\n (await agent._writeYamlExecutionReport?.(record)) ?? agent.reportFile;\n const source = await agent._createReportSource?.(runId);\n if (source) record = Object.freeze({ ...record, reportSources: [source] });\n return { record, reportFile };\n }\n if (ifInBrowser || ifInWorker || !isYamlReportEnabled(options.script))\n return { record };\n\n const generator = ReportGenerator.create(\n options.fallbackReportFileName ??\n options.script.agent?.reportFileName ??\n options.script.agent?.testId ??\n (options.scriptPath\n ? basename(options.scriptPath).replace(/\\.ya?ml$/i, '')\n : `script-${runId}`),\n options.script.agent ?? {},\n );\n const reportFile = await generator.writeRunnerReport?.(\n executionRecordsToReportInput([record], { runId }),\n runId,\n {\n groupName: 'YAML execution',\n sdkVersion: getVersion(),\n modelBriefs: [],\n },\n );\n await generator.finalize();\n const source = await generator.createSourceSnapshot?.(runId);\n if (source) record = Object.freeze({ ...record, reportSources: [source] });\n return { record, reportFile };\n}\n"],"names":["publishLegacyYamlReport","options","agent","runId","record","reportFile","source","Object","ifInBrowser","ifInWorker","isYamlReportEnabled","generator","ReportGenerator","basename","executionRecordsToReportInput","getVersion"],"mappings":";;;;;;AAyBO,eAAeA,wBACpBC,OAAuC;IAEvC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;IACzB,IAAIG,SAASH,QAAQ,MAAM;IAC3B,IAAIC,OAAO;QACT,MAAMG,aACH,MAAMH,MAAM,yBAAyB,GAAGE,WAAYF,MAAM,UAAU;QACvE,MAAMI,SAAS,MAAMJ,MAAM,mBAAmB,GAAGC;QACjD,IAAIG,QAAQF,SAASG,OAAO,MAAM,CAAC;YAAE,GAAGH,MAAM;YAAE,eAAe;gBAACE;aAAO;QAAC;QACxE,OAAO;YAAEF;YAAQC;QAAW;IAC9B;IACA,IAAIG,eAAeC,cAAc,CAACC,oBAAoBT,QAAQ,MAAM,GAClE,OAAO;QAAEG;IAAO;IAElB,MAAMO,YAAYC,gBAAgB,MAAM,CACtCX,QAAQ,sBAAsB,IAC5BA,QAAQ,MAAM,CAAC,KAAK,EAAE,kBACtBA,QAAQ,MAAM,CAAC,KAAK,EAAE,UACrBA,CAAAA,QAAQ,UAAU,GACfY,SAASZ,QAAQ,UAAU,EAAE,OAAO,CAAC,aAAa,MAClD,CAAC,OAAO,EAAEE,OAAM,GACtBF,QAAQ,MAAM,CAAC,KAAK,IAAI,CAAC;IAE3B,MAAMI,aAAa,MAAMM,UAAU,iBAAiB,GAClDG,8BAA8B;QAACV;KAAO,EAAE;QAAED;IAAM,IAChDA,OACA;QACE,WAAW;QACX,YAAYY;QACZ,aAAa,EAAE;IACjB;IAEF,MAAMJ,UAAU,QAAQ;IACxB,MAAML,SAAS,MAAMK,UAAU,oBAAoB,GAAGR;IACtD,IAAIG,QAAQF,SAASG,OAAO,MAAM,CAAC;QAAE,GAAGH,MAAM;QAAE,eAAe;YAACE;SAAO;IAAC;IACxE,OAAO;QAAEF;QAAQC;IAAW;AAC9B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { deriveCaseStatus } from "../dump/task-status.mjs";
|
|
2
|
+
import { getDebug } from "@midscene/shared/logger";
|
|
3
|
+
import { assert } from "@midscene/shared/utils";
|
|
4
|
+
import { assertResourceAvailable, defineNode, runWorkflowDocument, trackResourceOperation, waitForResourceIdle } from "../test-runner/index.mjs";
|
|
5
|
+
import { enterYamlAction, runInYamlExecutionContext } from "./execution-session.mjs";
|
|
6
|
+
import { collectLegacyYamlDocument, collectLegacyYamlTaskDocument } from "./test-runner-compat.mjs";
|
|
7
|
+
import { getLegacyYamlResultData, legacyAgentTestRunnerNodeDefinitions } from "./test-runner-nodes.mjs";
|
|
8
|
+
const debug = getDebug('yaml-player');
|
|
9
|
+
const hasFailedReportExecutionSince = (agent, executionCountBefore)=>'failed' === deriveCaseStatus((agent.dump?.executions ?? []).slice(executionCountBefore));
|
|
10
|
+
const recordYamlTaskError = async (agent, task, flowItemIndex, error)=>{
|
|
11
|
+
const recordErrorToReport = agent.recordErrorToReport;
|
|
12
|
+
if ('function' != typeof recordErrorToReport) return;
|
|
13
|
+
try {
|
|
14
|
+
await recordErrorToReport.call(agent, `YAML task failed - ${task.name}`, {
|
|
15
|
+
error,
|
|
16
|
+
content: `Step ${flowItemIndex} failed while running YAML task "${task.name}".`
|
|
17
|
+
});
|
|
18
|
+
} catch (reportError) {
|
|
19
|
+
debug('failed to record yaml error to report', reportError);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const createLegacyYamlNodeResolver = (options, resolveTask, recordTaskErrors, captureReportTraces)=>{
|
|
23
|
+
const definitions = new Map(legacyAgentTestRunnerNodeDefinitions.map((definition)=>[
|
|
24
|
+
definition.name,
|
|
25
|
+
definition
|
|
26
|
+
]));
|
|
27
|
+
const nodes = new Map();
|
|
28
|
+
return (name)=>{
|
|
29
|
+
const existing = nodes.get(name);
|
|
30
|
+
if (existing) return existing;
|
|
31
|
+
const definition = definitions.get(name);
|
|
32
|
+
assert(definition, `Unknown Agent Node: ${name}`);
|
|
33
|
+
const node = defineNode({
|
|
34
|
+
name,
|
|
35
|
+
inputSchema: definition.inputSchema,
|
|
36
|
+
execute: (ctx)=>runInYamlExecutionContext(async ()=>{
|
|
37
|
+
ctx.signal.throwIfAborted();
|
|
38
|
+
assertResourceAvailable(options.agent, false, ctx.signal);
|
|
39
|
+
assert('case' === ctx.scope, 'YAML task requires a Case scope');
|
|
40
|
+
const taskIndex = ctx.case.caseIndex;
|
|
41
|
+
const flowItemIndex = ctx.case.stepIndex;
|
|
42
|
+
const task = resolveTask(taskIndex);
|
|
43
|
+
assert(task, `missing YAML task at index ${taskIndex}`);
|
|
44
|
+
assert(task.flow, 'missing flow in task');
|
|
45
|
+
const executionCountBeforeStep = options.agent.dump?.executions?.length ?? 0;
|
|
46
|
+
const addDumpUpdateListener = captureReportTraces ? options.agent.addDumpUpdateListener : void 0;
|
|
47
|
+
const removeDumpListener = 'function' == typeof addDumpUpdateListener ? addDumpUpdateListener.call(options.agent, (_dump, execution)=>{
|
|
48
|
+
if (!ctx.signal.aborted && execution?.id) ctx.report.addTrace({
|
|
49
|
+
type: 'midscene-execution',
|
|
50
|
+
executionId: execution.id
|
|
51
|
+
});
|
|
52
|
+
}) : void 0;
|
|
53
|
+
let listening = true;
|
|
54
|
+
const removeListener = ()=>{
|
|
55
|
+
if (!listening) return;
|
|
56
|
+
listening = false;
|
|
57
|
+
removeDumpListener?.();
|
|
58
|
+
};
|
|
59
|
+
const operation = trackResourceOperation(options.agent, Promise.resolve().then(()=>{
|
|
60
|
+
ctx.signal.throwIfAborted();
|
|
61
|
+
return definition.execute(options.agent, ctx.input, {
|
|
62
|
+
signal: ctx.signal
|
|
63
|
+
});
|
|
64
|
+
}), ctx.signal);
|
|
65
|
+
const leaveAction = enterYamlAction(options.agent, ctx.signal);
|
|
66
|
+
const onAbort = ()=>{
|
|
67
|
+
removeListener();
|
|
68
|
+
};
|
|
69
|
+
ctx.signal.addEventListener('abort', onAbort, {
|
|
70
|
+
once: true
|
|
71
|
+
});
|
|
72
|
+
try {
|
|
73
|
+
return await operation;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
const reportAlreadyContainsFailure = hasFailedReportExecutionSince(options.agent, executionCountBeforeStep);
|
|
76
|
+
if (!ctx.signal.aborted && recordTaskErrors && !reportAlreadyContainsFailure) await recordYamlTaskError(options.agent, task, flowItemIndex, error);
|
|
77
|
+
throw error;
|
|
78
|
+
} finally{
|
|
79
|
+
ctx.signal.removeEventListener('abort', onAbort);
|
|
80
|
+
removeListener();
|
|
81
|
+
leaveAction();
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
nodes.set(name, node);
|
|
86
|
+
return node;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const runLegacyYamlDocument = (document, options, resolveTask, recordTaskErrors, captureReportTraces, runOptions)=>runWorkflowDocument(document, {
|
|
90
|
+
...runOptions ?? {},
|
|
91
|
+
onStepResult: async (info, result)=>{
|
|
92
|
+
if (result.meta.captureResult && result.output && Object.hasOwn(result.output, 'data')) await options.setResult(result.meta.resultName, getLegacyYamlResultData(result.node, result.output));
|
|
93
|
+
await runOptions?.onStepResult?.(info, result);
|
|
94
|
+
},
|
|
95
|
+
resolveNode: createLegacyYamlNodeResolver(options, resolveTask, recordTaskErrors, captureReportTraces),
|
|
96
|
+
projectContext: options.agent,
|
|
97
|
+
retry: 0,
|
|
98
|
+
resolveCaseReportScopeId: (_collectedCase, _attemptIndex, documentRunId)=>documentRunId
|
|
99
|
+
});
|
|
100
|
+
const createLegacyYamlRuntime = (options)=>{
|
|
101
|
+
const sourcePath = options.sourcePath ?? '<inline-yaml>';
|
|
102
|
+
return {
|
|
103
|
+
waitForIdle: ()=>waitForResourceIdle(options.agent),
|
|
104
|
+
runScript: (script, runOptions)=>runLegacyYamlDocument(runOptions?.document ?? collectLegacyYamlDocument(script, sourcePath, options.actionSpace), options, (taskIndex)=>script.tasks?.[taskIndex], true, true, runOptions),
|
|
105
|
+
runTask: (task, taskIndex, runOptions)=>runLegacyYamlDocument(collectLegacyYamlTaskDocument(task, taskIndex, sourcePath, options.actionSpace), options, ()=>task, false, false, runOptions)
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
const legacyYamlOutcomeError = (outcome)=>{
|
|
109
|
+
const failedStep = [
|
|
110
|
+
...outcome.run?.beforeEach ?? [],
|
|
111
|
+
...outcome.run?.steps ?? [],
|
|
112
|
+
...outcome.run?.afterEach ?? []
|
|
113
|
+
].find((step)=>'failed' === step.status);
|
|
114
|
+
const error = failedStep?.error;
|
|
115
|
+
return error?.code === 'NODE_EXECUTION_ERROR' && error.cause instanceof Error ? error.cause : error ?? new Error(`Task "${outcome.name}" failed`);
|
|
116
|
+
};
|
|
117
|
+
export { createLegacyYamlRuntime, legacyYamlOutcomeError };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=legacy-yaml-runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml/legacy-yaml-runtime.mjs","sources":["../../../src/yaml/legacy-yaml-runtime.ts"],"sourcesContent":["import type { Agent } from '@/agent/agent';\nimport { deriveCaseStatus } from '@/dump/task-status';\nimport type {\n DeviceAction,\n MidsceneYamlScript,\n MidsceneYamlTask,\n} from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport {\n type CaseRunOutcome,\n type CollectedWorkflowDocument,\n type NodeDefinition,\n type RunWorkflowDocumentOptions,\n type WorkflowDocumentExecutionResult,\n assertResourceAvailable,\n defineNode,\n runWorkflowDocument,\n trackResourceOperation,\n waitForResourceIdle,\n} from '../test-runner';\nimport {\n enterYamlAction,\n runInYamlExecutionContext,\n} from './execution-session';\nimport {\n collectLegacyYamlDocument,\n collectLegacyYamlTaskDocument,\n} from './test-runner-compat';\nimport {\n getLegacyYamlResultData,\n legacyAgentTestRunnerNodeDefinitions,\n} from './test-runner-nodes';\nconst debug = getDebug('yaml-player');\n\ntype SetLegacyYamlResult = (\n key: string | undefined,\n value: any,\n) => void | Promise<void>;\n\nexport type LegacyYamlRuntimeRunOptions = Omit<\n RunWorkflowDocumentOptions<Agent>,\n 'projectContext' | 'resolveCaseReportScopeId' | 'resolveNode' | 'retry'\n> & { document?: CollectedWorkflowDocument };\n\nexport interface LegacyYamlRuntimeOptions {\n agent: Agent;\n actionSpace: readonly DeviceAction[];\n sourcePath?: string;\n setResult: SetLegacyYamlResult;\n}\n\nexport interface LegacyYamlRuntime {\n /** Wait before releasing an Agent whose non-cooperative action was aborted. */\n waitForIdle(): Promise<void>;\n runScript(\n script: MidsceneYamlScript,\n options?: LegacyYamlRuntimeRunOptions,\n ): Promise<WorkflowDocumentExecutionResult>;\n runTask(\n task: MidsceneYamlTask,\n taskIndex: number,\n options?: LegacyYamlRuntimeRunOptions,\n ): Promise<WorkflowDocumentExecutionResult>;\n}\n\nconst hasFailedReportExecutionSince = (\n agent: Agent,\n executionCountBefore: number,\n): boolean =>\n deriveCaseStatus(\n (agent.dump?.executions ?? []).slice(executionCountBefore),\n ) === 'failed';\n\nconst recordYamlTaskError = async (\n agent: Agent,\n task: MidsceneYamlTask,\n flowItemIndex: number,\n error: Error,\n): Promise<void> => {\n const recordErrorToReport = (agent as any).recordErrorToReport;\n if (typeof recordErrorToReport !== 'function') return;\n\n try {\n await recordErrorToReport.call(agent, `YAML task failed - ${task.name}`, {\n error,\n content: `Step ${flowItemIndex} failed while running YAML task \"${task.name}\".`,\n });\n } catch (reportError) {\n debug('failed to record yaml error to report', reportError);\n }\n};\n\nconst createLegacyYamlNodeResolver = (\n options: LegacyYamlRuntimeOptions,\n resolveTask: (taskIndex: number) => MidsceneYamlTask | undefined,\n recordTaskErrors: boolean,\n captureReportTraces: boolean,\n): ((\n name: string,\n) => NodeDefinition<Record<string, unknown>, unknown, Agent>) => {\n const definitions = new Map(\n legacyAgentTestRunnerNodeDefinitions.map((definition) => [\n definition.name,\n definition,\n ]),\n );\n const nodes = new Map<\n string,\n NodeDefinition<Record<string, unknown>, unknown, Agent>\n >();\n\n return (name) => {\n const existing = nodes.get(name);\n if (existing) return existing;\n\n const definition = definitions.get(name);\n assert(definition, `Unknown Agent Node: ${name}`);\n const node = defineNode<Record<string, unknown>, unknown, Agent>({\n name,\n inputSchema: definition.inputSchema,\n execute: (ctx) =>\n runInYamlExecutionContext(async () => {\n ctx.signal.throwIfAborted();\n assertResourceAvailable(options.agent, false, ctx.signal);\n assert(ctx.scope === 'case', 'YAML task requires a Case scope');\n const taskIndex = ctx.case.caseIndex;\n const flowItemIndex = ctx.case.stepIndex;\n const task = resolveTask(taskIndex);\n assert(task, `missing YAML task at index ${taskIndex}`);\n assert(task.flow, 'missing flow in task');\n\n const executionCountBeforeStep =\n options.agent.dump?.executions?.length ?? 0;\n const addDumpUpdateListener = captureReportTraces\n ? (options.agent as any).addDumpUpdateListener\n : undefined;\n const removeDumpListener =\n typeof addDumpUpdateListener === 'function'\n ? addDumpUpdateListener.call(\n options.agent,\n (_dump: string, execution?: { id?: string }) => {\n if (!ctx.signal.aborted && execution?.id) {\n ctx.report.addTrace({\n type: 'midscene-execution',\n executionId: execution.id,\n });\n }\n },\n )\n : undefined;\n\n let listening = true;\n const removeListener = () => {\n if (!listening) return;\n listening = false;\n removeDumpListener?.();\n };\n const operation = trackResourceOperation(\n options.agent,\n Promise.resolve().then(() => {\n ctx.signal.throwIfAborted();\n return definition.execute(options.agent, ctx.input, {\n signal: ctx.signal,\n });\n }),\n ctx.signal,\n );\n const leaveAction = enterYamlAction(options.agent, ctx.signal);\n const onAbort = () => {\n removeListener();\n };\n ctx.signal.addEventListener('abort', onAbort, { once: true });\n\n try {\n return await operation;\n } catch (error) {\n const reportAlreadyContainsFailure = hasFailedReportExecutionSince(\n options.agent,\n executionCountBeforeStep,\n );\n if (\n !ctx.signal.aborted &&\n recordTaskErrors &&\n !reportAlreadyContainsFailure\n ) {\n await recordYamlTaskError(\n options.agent,\n task,\n flowItemIndex,\n error as Error,\n );\n }\n throw error;\n } finally {\n ctx.signal.removeEventListener('abort', onAbort);\n removeListener();\n leaveAction();\n }\n }),\n });\n nodes.set(name, node);\n return node;\n };\n};\n\nconst runLegacyYamlDocument = (\n document: CollectedWorkflowDocument,\n options: LegacyYamlRuntimeOptions,\n resolveTask: (taskIndex: number) => MidsceneYamlTask | undefined,\n recordTaskErrors: boolean,\n captureReportTraces: boolean,\n runOptions?: LegacyYamlRuntimeRunOptions,\n): Promise<WorkflowDocumentExecutionResult> => {\n return runWorkflowDocument(document, {\n ...(runOptions ?? {}),\n onStepResult: async (info, result) => {\n if (\n result.meta.captureResult &&\n result.output &&\n Object.hasOwn(result.output, 'data')\n ) {\n // Publication follows the recorded action. The Node result is never mutated.\n await options.setResult(\n result.meta.resultName,\n getLegacyYamlResultData(result.node, result.output),\n );\n }\n await runOptions?.onStepResult?.(info, result);\n },\n resolveNode: createLegacyYamlNodeResolver(\n options,\n resolveTask,\n recordTaskErrors,\n captureReportTraces,\n ),\n projectContext: options.agent,\n // Legacy CLI retry recreates the whole player and Agent outside this\n // runtime, so the shared kernel must not retry a Case here.\n retry: 0,\n // One legacy YAML file owns one Agent report shared by all of its tasks.\n resolveCaseReportScopeId: (_collectedCase, _attemptIndex, documentRunId) =>\n documentRunId,\n });\n};\n\nexport const createLegacyYamlRuntime = (\n options: LegacyYamlRuntimeOptions,\n): LegacyYamlRuntime => {\n const sourcePath = options.sourcePath ?? '<inline-yaml>';\n return {\n waitForIdle: () => waitForResourceIdle(options.agent),\n runScript: (script, runOptions) =>\n runLegacyYamlDocument(\n runOptions?.document ??\n collectLegacyYamlDocument(script, sourcePath, options.actionSpace),\n options,\n (taskIndex) => script.tasks?.[taskIndex],\n true,\n true,\n runOptions,\n ),\n runTask: (task, taskIndex, runOptions) =>\n runLegacyYamlDocument(\n collectLegacyYamlTaskDocument(\n task,\n taskIndex,\n sourcePath,\n options.actionSpace,\n ),\n options,\n () => task,\n false,\n false,\n runOptions,\n ),\n };\n};\n\nexport const legacyYamlOutcomeError = (outcome: CaseRunOutcome): Error => {\n const failedStep = [\n ...(outcome.run?.beforeEach ?? []),\n ...(outcome.run?.steps ?? []),\n ...(outcome.run?.afterEach ?? []),\n ].find((step) => step.status === 'failed');\n const error = failedStep?.error;\n return error?.code === 'NODE_EXECUTION_ERROR' && error.cause instanceof Error\n ? error.cause\n : (error ?? new Error(`Task \"${outcome.name}\" failed`));\n};\n"],"names":["debug","getDebug","hasFailedReportExecutionSince","agent","executionCountBefore","deriveCaseStatus","recordYamlTaskError","task","flowItemIndex","error","recordErrorToReport","reportError","createLegacyYamlNodeResolver","options","resolveTask","recordTaskErrors","captureReportTraces","definitions","Map","legacyAgentTestRunnerNodeDefinitions","definition","nodes","name","existing","assert","node","defineNode","ctx","runInYamlExecutionContext","assertResourceAvailable","taskIndex","executionCountBeforeStep","addDumpUpdateListener","undefined","removeDumpListener","_dump","execution","listening","removeListener","operation","trackResourceOperation","Promise","leaveAction","enterYamlAction","onAbort","reportAlreadyContainsFailure","runLegacyYamlDocument","document","runOptions","runWorkflowDocument","info","result","Object","getLegacyYamlResultData","_collectedCase","_attemptIndex","documentRunId","createLegacyYamlRuntime","sourcePath","waitForResourceIdle","script","collectLegacyYamlDocument","collectLegacyYamlTaskDocument","legacyYamlOutcomeError","outcome","failedStep","step","Error"],"mappings":";;;;;;;AAiCA,MAAMA,QAAQC,SAAS;AAiCvB,MAAMC,gCAAgC,CACpCC,OACAC,uBAEAC,AAEM,aAFNA,iBACGF,AAAAA,CAAAA,MAAM,IAAI,EAAE,cAAc,EAAC,EAAG,KAAK,CAACC;AAGzC,MAAME,sBAAsB,OAC1BH,OACAI,MACAC,eACAC;IAEA,MAAMC,sBAAuBP,MAAc,mBA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M,KAAK,GACVA,SAAS,IAAI0D,MAAM,CAAC,MAAM,EAAEH,QAAQ,IAAI,CAAC,QAAQ,CAAC;AACzD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const stateKey = Symbol.for('@midscene/core/yaml-player-state/v1');
|
|
2
|
+
const host = globalThis;
|
|
3
|
+
host[stateKey] ??= new WeakMap();
|
|
4
|
+
const states = host[stateKey];
|
|
5
|
+
function initializeLegacyYamlPlayerState(player) {
|
|
6
|
+
states.set(player, {});
|
|
7
|
+
}
|
|
8
|
+
function getLegacyYamlPlayerState(player) {
|
|
9
|
+
const state = states.get(player);
|
|
10
|
+
if (!state) throw new Error('Expected an initialized YAML ScriptPlayer.');
|
|
11
|
+
return state;
|
|
12
|
+
}
|
|
13
|
+
export { getLegacyYamlPlayerState, initializeLegacyYamlPlayerState };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=player-state.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml/player-state.mjs","sources":["../../../src/yaml/player-state.ts"],"sourcesContent":["import type {\n WorkflowDocumentExecutionResult,\n WorkflowExecutionRecord,\n} from '../test-runner';\n\ninterface LegacyYamlPlayerState {\n executionResult?: WorkflowDocumentExecutionResult;\n executionRecord?: WorkflowExecutionRecord;\n fallbackReportFileName?: string;\n}\n\n// Hosts can load the public player through CJS and internal integration through ESM.\nconst stateKey = Symbol.for('@midscene/core/yaml-player-state/v1');\nconst host = globalThis as typeof globalThis & {\n [stateKey]?: WeakMap<object, LegacyYamlPlayerState>;\n};\nhost[stateKey] ??= new WeakMap();\nconst states = host[stateKey];\n\nexport function initializeLegacyYamlPlayerState(player: object): void {\n states.set(player, {});\n}\n\n/** Package integration only; do not expose host controls on ScriptPlayer. */\nexport function getLegacyYamlPlayerState(\n player: object,\n): LegacyYamlPlayerState {\n const state = states.get(player);\n if (!state) throw new Error('Expected an initialized YAML ScriptPlayer.');\n return state;\n}\n"],"names":["stateKey","Symbol","host","globalThis","WeakMap","states","initializeLegacyYamlPlayerState","player","getLegacyYamlPlayerState","state","Error"],"mappings":"AAYA,MAAMA,WAAWC,OAAO,GAAG,CAAC;AAC5B,MAAMC,OAAOC;AAGbD,IAAI,CAACF,SAAS,KAAK,IAAII;AACvB,MAAMC,SAASH,IAAI,CAACF,SAAS;AAEtB,SAASM,gCAAgCC,MAAc;IAC5DF,OAAO,GAAG,CAACE,QAAQ,CAAC;AACtB;AAGO,SAASC,yBACdD,MAAc;IAEd,MAAME,QAAQJ,OAAO,GAAG,CAACE;IACzB,IAAI,CAACE,OAAO,MAAM,IAAIC,MAAM;IAC5B,OAAOD;AACT"}
|