tree-sitter icon indicating copy to clipboard operation
tree-sitter copied to clipboard

Playground in offline mode

Open songhtdo opened this issue 1 year ago • 3 comments

Problem

Thank you for providing a very useful tool. I am on a new computer and experiencing a network outage. I am unable to use the playground function properly and will display an error message in the browser console.

The error message displayed in the browser's console is as follows: image

Possible reason: In pages generated by tree sitter cli control, access to some network resources is required.

Expected behavior

I hope to be able to use the tree sit playground feature in a completely offline state. Thank you.

songhtdo avatar May 18 '24 07:05 songhtdo

clone the repo, run ./script/build-wasm, then run cargo install --path cli and it'll bundle in the locally built tree-sitter.js/wasm files, as for the others, I have no clue, I don't get what you're asking exactly, I'm just assuming you are asking how to run a playground without needing an internet connection in regards to the playground subcommand

amaanq avatar May 18 '24 19:05 amaanq

@amaanq Hello, thank you very much for your attention and reply.

Maybe I didn't express myself clearly, let me describe it again. Normally, our computer will be connected to the Internet, and we can access tree-siter.github.io/tree-sitter/playground through the browser to test some syntax. Alternatively, test it locally through tree-sitter playground. But in some cases, computers are completely separated from the Internet environment and physically isolated. At this point, to test some syntax with playground, I need to use the local tree sit playground command.

To run the tree-sitter program locally, I need to start from the https://cdnjs.cloudflare.com The website downloads some js/css files. This step is unsuccessful when the Internet cannot be accessed. cause http://127.0.0.1:8000 The page is not working properly.

I would like to ask if there is a way to solve this problem. Thank you again.

songhtdo avatar May 19 '24 03:05 songhtdo

I tested tree-sitter playground while disconnected from networks and at least for my setup, the result was not usable:

tree-sitter-playground-offline-in-firefox

After I re-established a network connection and reloaded, things started working:

tree-sitter-playground-online-in-firefox

IIUC, the former of the two results is what is being described as what is being experienced and the desire is for things to work even while offline.

sogaiu avatar May 19 '24 04:05 sogaiu

This issue has been resolved. I have developed a small local application by combining the tree sitter and csharp tree sitter projects. You can skip using tree -sitter playground anymore.

The project source code has been uploaded to the GitHub project: tree-sitter-play

The project screenshot is as follows: image

songhtdo avatar May 26 '24 15:05 songhtdo