Scratch 3源码设置断点

Setting breakpoints in Scratch 3 source code

我之前使用过主要基于动作脚本的 Scratch 2.0 源代码。我现在想深入研究已经转移到 JavaScript 的 3.0 代码,但在该领域几乎没有经验。我在 Windows 10.

工作

这些是我在本地准备代码所采取的步骤 -

git clone https://github.com/llk/scratch-gui
git clone https://github.com/llk/scratch-vm

cd scratch-vm
npm install
npm link
npm run watch

cd ..\scratch-gui
npm install
npm link scratch-vm
npm start

随后在 Chrome 浏览器中打开 http://localhost:8601

这很好,允许我修改 vm 代码(在 VS 代码中)并 "instantly" 在浏览器中查看结果。我希望能够做的是设置断点能够单步,设置手表等等

我假设我需要设置 launch.json 才能执行此操作,但我尝试的所有配置都会导致编译成功,然后在尝试连接到运行时进程时超时。

这是我正在使用的 launch.json 文件(虽然我已经尝试了很多变体,但都产生了相同的结果)。

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "runtimeExecutable": "npm",
            "autoAttachChildProcesses": true,
            "runtimeArgs": ["start", "--"],
            "protocol": "inspector",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "sourceMaps": true,
            "timeout": 30000,
            "outputCapture": "std",
            "address": "http://localhost",
            "port": 8601
        }
    ]
}

我意识到我可能错过了一步或犯了一个明显的错误,但非常感谢任何正确方向的指示。

我对你所做的事情没有什么经验,但如果它有帮助,JavaScript 断点关键字是:

调试器;

这是 official page 用于使用 Visual Studio 调试 Scratch 3.0。我计算了让断点在多个工作区上工作所需的额外步骤,它们现在已添加到标题下的官方页面步骤 3:multi-root 工作区的更多源映射.