天天看点

Scratch项目整合

源文链接:

https://github.com/LLK/scratch-gui/wiki/Getting-Started

The Scratch editor is built up modularly from several repos. Each can stand alone, but for development purposes you may need to make dependent changes in multiple repos at once.

Scratch编辑器由多个存储库模块化构成,每个都可以单独使用,但为了开发目的,你可以需要同时对多个repos

进行依赖更改

You probably won’t need all the repos. Clone the repo for the issue you are working on, and clone and link other repos as you need them.

你可能不需要所有的库,克隆你正在处理问题的库和克隆和连接其他你需要的

最主要的是:

• GUI - the React-based front end (基于React的前端)

• VM - Manages state and does business logic. It sends the state to the GUI.(管理状态并执行业务逻辑。它

将状态发送到GUI。)

• Scratch Blocks - branched from Blockly. This repo handles both the UI and logic for the portions of the

editor that blocks appear in. Talks to the GUI, which often pipes things through to the VM.

从Blockly分支。此存储库处理出现在其中的编辑器部分的UI和逻辑。 与GUI对话,GUI通常将内容通过管

道传递到VM。

• Renderer - WebGL-based handler of what appears in the stage area. The GUI tells this what to do.

舞台区域中基于WebGL的处理程序。GUI告诉该怎么做。

整合 Scratch-blocks & Scratch-gui & Scratch-vm
mkdir Scratch
cd Scratch

git clone https://github.com/llk/scratch-gui # if making changes fork the project and check out your copy

git clone https://github.com/llk/scratch-vm # if making changes fork the project and check out your copy

git clone https://github.com/llk/scratch-blocks # if making changes fork the project and check out your copy

cd scratch-vm
npm install
npm link
npm run watch

cd ../scratch-blocks
npm install
npm link

cd ../scratch-gui
npm install
npm link scratch-vm scratch-blocks

npm start
           
  • 期间遇到的问题
    Scratch-Block 使用 Npm install 命令,报错
               
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] prepublish: `python build.py && webpack`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] prepublish script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
               

    解决办法:

    修改Scratch-block中的build.py

    1.
       proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
     修改为:
       outfile = open("dash_args.txt","w+") 
       outfile.write("\n".join(args[11:]))
       outfile.close()
       args =  args[:11]
       args.extend(['--flagfile','dash_args.txt'])
       proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell = True)
     
     2.
       test_proc = subprocess.Popen(test_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
     修改为:
       test_proc=subprocess.Popen(test_args,stdin=subprocess.PIPE,stdout=subprocess.PIPE,shell=True)
               
    参考链接:
    • https://github.com/LLK/scratch-blocks/issues/1620
    • https://blog.csdn.net/weixin_41602509/article/details/103636151

继续阅读