codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
365 stars 75 forks source link

Self-hosted saving? #116

Closed pavel-krivanek closed 3 years ago

pavel-krivanek commented 3 years ago

This is not a real issue but just an idea for thinking. What do you think about an idea to have an optional self-hosted system for SqueakJS in the same regard as TiddlyWiki? That you serve SqueakJS images somewhere and then be able to save the image with all the SqueakJS code and dependent packages into one static HTML file.

I did this experiment with Amber, and it worked (only Legacy IDE works, there is a Save image button that saves the new version): https://pavel-krivanek.github.io/amber/amber.html

It could be quite easily combined with an option to bootstrap it from sources (and "unpack" them if needed)

codefrau commented 3 years ago

Huh, that would be quite a hack (in the good sense of the word). Not really useful, but cool if it works.

Then again, if it worked, someone might find an actual use case. Are you using Amber this way?

pavel-krivanek commented 3 years ago

Not really using, I just tried it as (successful) proof of concept. Besides a better debugger, it was one thing that missed for Lively. It could significantly lower the barrier for newcomers because then they do not need to set up the server etc. And once the working version lasts working forever as a snapshot.

For Amber, I needed very slightly (and in defined way that can be reverted) modify the modules definition to be able to concatenate everything into one file. The idea is that you may even modify these scripts from inside the page and save everything as a new version, but if you are serving it from a proper server, you may push the new versions there or reload the newer versions from the server (mostly for updates of external packages, that may be regular versions that everyone is using, just slightly modified during export/import)

pavel-krivanek commented 3 years ago

The hacks to to libraries were moslty like:

content copyReplaceAll: 'define(function' with: ('define("', prefix, moduleName, '",function').

or

content copyReplaceAll: 'define(factory' with: ('define("', prefix, moduleName, '",factory').

or

content copyReplaceAll: 'define([' with: ('define("', prefix, moduleName, '",[').
codefrau commented 3 years ago

Not really sure what you mean by "do not need to set up the server". SqueakJS uses IndexedDB as persistent storage, you do not need a server to run in.

pavel-krivanek commented 3 years ago

I know, it is a great feature. However, you need a server for the first time to answer XMLHttpRequests (not big issue, anyway)

codefrau commented 3 years ago

You do not need a server. You can just drop an image into the /run/ page.

codefrau commented 3 years ago

Ah, I see, we broke that, because the bundled squeak.js is not in the same dir anymore.

But it can be made to work easily by moving the JS file to the same directory as the html. And it would be even easier, as you say, if we inlined the JS in the HTML using a bundler.

pavel-krivanek commented 3 years ago

Ok, great, I think I we can close this issue, it served its purpose :-)

Btw. when working on Lively, have you considered TiddlyWiki-like self-hosting architecture?

codefrau commented 3 years ago

That would be a question for Dan - I don't know.

Closing this for now.