Skip to content

Conversation

@Outcue
Copy link
Owner

@Outcue Outcue commented Aug 8, 2021

No description provided.

gbracha and others added 30 commits December 20, 2023 18:47
…s of the persistent representation. Cleaned out old code.
  - This commit fixes the failure of the Newspeak service worker (sw.js) to
    update its caches. This issue caused the Newspeak PWA client app on the user's
    device to never pick up server updates, notably the changed HopscotchWebIDE.vfuel.
  - The changed files are sw.js, index.html, build.sh; there is a new script 'increase-pwa-version.sh'
    called from 'build.sh'.
  - Apart from fixing the end-user experience, this change also touches Newspeak development
    (without any changes in the developer's workflow), as running '. ./build.sh' now changes
    the variable pwaVersion in 'sw.js'
  - How to test this change:
    - Server / build
      - Get the latest version and make sure webIDE/index.html is copied to the webIDE directory
        where Newspeak is served locally for https://localhost:8080/webIDE,
        or for https://newspeaklanguage.org/webIDE.
        I am serving from the git version of webIDE, so I do not have to copy anything.
      - Run . ./build.sh as normally.
      - Make sure the updated webIDE/sw.js is copied into the webIDE directory where Newspeak is served.
        I am serving from the git version of webIDE, so I do not have to copy anything.

    - PWA Client / browser
      - You do NOT have to do anything, the versioned sw.js should now be installed,
        and use its versioned cache. But if you want to check:
        - In Browser, navigate to  https://localhost:8080/webIDE,
          or https://newspeaklanguage.org/webIDE.
        - Open the PWA
        - In both browser and PWA, if you press F12 to debug (Chrome) and look at:
            Application -> Storage -> Cache Storage.
          you should see a versioned cache number, such as 'newspeak-ide-cache-version-13'.
      - Every time a new server version is build and the new build deployed,
        you should see a new cache version on the client PWA or browser,
        such as 'newspeak-ide-cache-version-14'.

Motivation for change:

  - 'Before this change': After a new Newspeak version deployment on
    https://newspeaklanguage.org/webIDE, the PWA client app on the user's device
    did not update even after multiple launches, unless a manual cache clean was performed.
    I had the same experience (the PWA client not updating) with the webIDE server
    running on localhost, and the PWA client created from it.
    In fact, even the in-browser running webIDE did not update after server deployment.

  - Having looked into how service workers function, it seems clear that
    the mechanism that causes the service worker update on the user's device
    (changing some bits) was never triggered.  As a result, the service worker caches are never automatically
    updated, causing, among other things, the same (old) HopscotchWebIDE.vfuel to be used after server update.

Service worker lifecycle - summary

  - From https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Tutorials/CycleTracker/Service_workers:
    - Once the PWA is installed on the user's machine, THE ONLY WAY to inform
      the browser that there are updated files to be retrieved is to change
      the service worker (this file, sw.js) on the server.

  - Corollary: The only way for a PWA website to force an update of the service worker
      is to make a bit-change on the server's service worker (the sw.js).

      Such enforced update of the service worker, causes the browser to call a one-time 'install' and 'activate' on the
      service worker, which the service worker can use to delete old caches and cache the new assets.

Changes in more detail:

  - index.html
    - moved caching of assets (cache.addAll) to the 'install' event in sw.js
    - added catching errors during serviceWorker.register
  - sw.js
    - almost complete rewrite, although keeping the basics of using cache-first strategy
      (assuming used to lighten load on the server)
    - added a version number which should be changed on every deployment,
      to support the reinstall of the service worker on the client PWA browser.
      This number is increased automatically, during running each '. ./build.sh'
      by calling the added 'increase-pwa-version.sh'
      - 'const pwaVersion = 12;'
    - added a versioned cache name
      - 'const pwaCacheName = 'newspeak-ide-cache-version-' + pwaVersion;'
    - added a full list of assets
      - 'const pwaAppResources = [ .. see code .. ];'
    - added processing in the 'install' event:
      - all assets listed in 'pwaAppResources' are added to the NEW cache version 'pwaCacheName'
    - added processing in the 'activate' event:
      - OLD caches are deleted
    - modified processing in the 'fetch' event
      - In principle, this remains the cache-first fetching, but error checking was added etc
      - Assets not in 'pwaAppResources' would still cache here from network
  - build.sh
    - added call to 'increase-pwa-version.sh' which increases version number in sw.js by 1, example
      - 'const pwaVersion = 12;' => 'const pwaVersion = 13;'
  - increase-pwa-version.sh
    - a simple sed script that edits sw.js and increases version number by 1.
…HTML source, i.e., those induced by show it or make button operations.
TL;DR:   This commit fixes the failure of the Newspeak service worker (sw.js) to update its caches.  See description for (much more) details.
…pplications to drag in the entire IDE and more. It may not be the only one, We'll know once we put back fixes to the Psoup on web branch as well.
…cation, but mor eimportantly helps resolve a memory leak.
…nterss. This is a good, cheap heuristic, but not perfect. It would be more correct to parse all literal strings to check if they are valid selectors. We can check that later.
…version numbers are managed and stored in git.

Only the PWA version for newspeaklanguage.org is kept in git. Others, such as the PWA version for localhost or any other URL is not kept in git, but users can choose to manage it locally outside of git.

README.md is significantly modified and expanded, it now describes more details about
installing Newspeak from scratch, building, deploying and serving Newspeak applications.
…ments withthese. Still needs cleanup - code is messy and repetitive (and there might even be some non-determinism hiding in all this hideous use of JS async APIs ).
… and loading of Docu-apps that need to persist specialized data, and bug fixes around loading transcluded docs. Also some unused code that may come in handy to refaactor the loading code. An additional small fix for the drag-drop handlers, so they don't misbehave when docs are transcluded in others.
…sically this a document that replace the Telescreen application.
…sources.

This can be argued both wyas. This is the internal format, which could change. On the other had, this real source code.
gbracha-f5 and others added 30 commits September 17, 2025 11:52
WIP to make this run on the WASM version.  The change here is designed to use mirrors rather than relying on #perform methods inherited in Squeak (where this last ran).
Small bug fix to JS deployment (which ha snever worke don the WASM version).
This parser has not been used on the WASM version because the WASM system is too slow. It is the basis for the colorizer, but that involves overriding many things, so a lot of functionality is not exercised. This is a step toward addressing that.
…ntation.

Now produces output - but fails to run.
…or lazy slots (partial; no work on mirrors yet).Also bug fixes to manage resouces (esp. images).
…slot compilation and on making APIs more compatible with Psoup.
… file name in case the file already exists. This is just the JS and only would work on Chromium based browsers at this time.
…c platform level. A more refined notion of Transcript works at the IDE level, and maybe an intermediate one at the Hopscotch level.
Electron is being removed from the Ministry of Truth. With the latest changes to file saving, the web version is as convenient to use as the electron version. We have not updasted the electron version in a long time, we don't have the bandwidth, and the old version raises security concerns.
…y any means. Simple things run, the IDE not yet.
…th AI (and quite a few corrections from NI).
… one command is implemented (goHome) but it works and furthee commands will follow. Extensions to supprt IDE specific behavior etc. are planned as well.
…ing - the logic doesn't appear to be quite right.
… less. This will do until more infra is added to the IDE to support identfying the specific context we're in. That will also support the AI integration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants