238 Matching Annotations
  1. Last 7 days
  2. Apr 2022
  3. Feb 2022
  4. Jan 2022
    1. A note on setting worker-loader’s publicPath with webpack 5

      Webpack 5 introduced a mechanism to detect the publicPath that should be used automatically

      [...]

      Webpack 5 exposes a global variable called __webpack_public_path__ that allows you to do that.

      // Updates the `publicPath` at runtime, overriding whatever was set in the
      // webpack's `output` section.
      __webpack_public_path__ = "/workers/";
      
      const myWorker = new Worker(
        new URL("/workers/worker.js");
      );
      
      // Eventually, restore the `publicPath` to whatever was set in output.
      __webpack_public_path__ = "https://my-static-cdn/";
      
    1. Barry McAree 💙. (2022, January 6). Teachers on these islands will get FFP2(rightly so).Healthcare workers on other parts of these islands..nah!..Surgical masks/spit guards/not PPE,for working with COVID-positive patients risking other patient’s, our own & our family’s health.”Protect the NHS”🤔⁦@CMO_England⁩ https://t.co/OngrD5BBPU [Tweet]. @BarryMcAree. https://twitter.com/BarryMcAree/status/1478883258305814536

  5. Dec 2021
    1. Web Workers

      As of webpack 5, you can use Web Workers without worker-loader.

      Syntax

      new Worker(new URL('./worker.js', import.meta.url));
      
    1. // main.js
      const { RemoteReadableStream, RemoteWritableStream } = RemoteWebStreams;
      (async () => {
        const worker = new Worker('./worker.js');
        // create a stream to send the input to the worker
        const { writable, readablePort } = new RemoteWritableStream();
        // create a stream to receive the output from the worker
        const { readable, writablePort } = new RemoteReadableStream();
        // transfer the other ends to the worker
        worker.postMessage({ readablePort, writablePort }, [readablePort, writablePort]);
      
        const response = await fetch('./some-data.txt');
        await response.body
          // send the downloaded data to the worker
          // and receive the results back
          .pipeThrough({ readable, writable })
          // show the results as they come in
          .pipeTo(new WritableStream({
            write(chunk) {
              const results = document.getElementById('results');
              results.appendChild(document.createTextNode(chunk)); // tadaa!
            }
          }));
      })();
      
      // worker.js
      const { fromReadablePort, fromWritablePort } = RemoteWebStreams;
      self.onmessage = async (event) => {
        // create the input and output streams from the transferred ports
        const { readablePort, writablePort } = event.data;
        const readable = fromReadablePort(readablePort);
        const writable = fromWritablePort(writablePort);
      
        // process data
        await readable
          .pipeThrough(new TransformStream({
            transform(chunk, controller) {
              controller.enqueue(process(chunk)); // do the actual work
            }
          }))
          .pipeTo(writable); // send the results back to main thread
      };
      
    1. What you're trying to do is known as the "Application Shell" architectural pattern.

      The trick is to have your service worker's fetch handler check to see whether an incoming request is a navigation (event.request.mode === 'navigate'), and if so, respond with the cached App Shell HTML (which sounds like /index.html in your case).

      A generic way of doing this would be:

      self.addEventListener('fetch', (event) => {
        if (event.request.mode === 'navigate') {
          event.respondWith(caches.match('/index.html'));
        } else {
          // Your other response logic goes here.
        }
      });
      

      This will cause your service worker to behave in a similar fashion to how you're web server is already configured.

    1. Fetch and modify response properties which are immutable by creating a copy first.
      /**
       * @param {string} headerNameSrc Header to get the new value from
       * @param {string} headerNameDst Header to set based off of value in src
       */
      const headerNameSrc = "foo" //"Orig-Header"
      const headerNameDst = "Last-Modified"
      
      async function handleRequest(request) {
        /**
         * Response properties are immutable. To change them, construct a new
         * Response and pass modified status or statusText in the ResponseInit
         * object. Response headers can be modified through the headers `set` method.
         */
        const originalResponse = await fetch(request)
      
        // Change status and statusText, but preserve body and headers
        let response = new Response(originalResponse.body, {
          status: 500,
          statusText: "some message",
          headers: originalResponse.headers,
        })
      
        // Change response body by adding the foo prop
        const originalBody = await originalResponse.json()
        const body = JSON.stringify({ foo: "bar", ...originalBody })
        response = new Response(body, response)
      
        // Add a header using set method
        response.headers.set("foo", "bar")
      
        // Set destination header to the value of the source header
        const src = response.headers.get(headerNameSrc)
      
        if (src != null) {
          response.headers.set(headerNameDst, src)
          console.log(
            `Response header "${headerNameDst}" was set to "${response.headers.get(
              headerNameDst,
            )}"`,
          )
        }
        return response
      }
      
      addEventListener("fetch", event => {
        event.respondWith(handleRequest(event.request))
      })
      
    1. shinydoc. (2021, December 12). I love how I, an actual GP...who was involved in the initial covid vaccination programme ...has to tune in at 8pm with the public to find out that apparently we are vaccinating the entire adult population with boosters by the end of the year [Tweet]. @irishayesha. https://twitter.com/irishayesha/status/1470123478221303810

    1. // To know the maximum numbers of thread that can be used
      // on user’s system, use
      
      window.navigator.hardwareConcurrency property.
      
  6. Nov 2021
  7. Oct 2021
    1. Kenneth Baillie. (2021, October 27). When a healthcare system fails, increasing numbers of people suffer and die needlessly. That’s all. If you aren’t a patient or staff, you don’t see it. But this is happening, now, all over the UK. 2/n [Tweet]. @kennethbaillie. https://twitter.com/kennethbaillie/status/1453422360795680769

  8. Sep 2021
    1. Ensure there's only one version of your site running at once. That last one is pretty important. Without service workers, users can load one tab to your site, then later open another. This can result in two versions of your site running at the same time. Sometimes this is ok, but if you're dealing with storage you can easily end up with two tabs having very different opinions on how their shared storage should be managed. This can result in errors, or worse, data loss.

      I wonder how can we identify issues like this when they occur

    1. David Dowdy on Twitter: “@NEJM joining the waning immunity debate. I’m going to push back a bit. Data from @UCSDHealth of vax effectiveness in health workers: 94% in June, 65% in July. Interpreted as ‘likely to be due to...delta and waning immunity over time, compounded by end of masking requirements.’ https://t.co/flDOfBbTs7” / Twitter. (n.d.). Retrieved September 2, 2021, from https://twitter.com/davidwdowdy/status/1433254675915157504?s=20

  9. Aug 2021
    1. Pham, Q. T., Le, X. T. T., Phan, T. C., Nguyen, Q. N., Ta, N. K. T., Nguyen, A. N., Nguyen, T. T., Nguyen, Q. T., Le, H. T., Luong, A. M., Koh, D., Hoang, M. T., Pham, H. Q., Vu, L. G., Nguyen, T. H., Tran, B. X., Latkin, C. A., Ho, C. S. H., & Ho, R. C. M. (2021). Impacts of COVID-19 on the Life and Work of Healthcare Workers During the Nationwide Partial Lockdown in Vietnam. Frontiers in Psychology, 12, 563193. https://doi.org/10.3389/fpsyg.2021.563193

    1. Bergwerk, M., Gonen, T., Lustig, Y., Amit, S., Lipsitch, M., Cohen, C., Mandelboim, M., Gal Levin, E., Rubin, C., Indenbaum, V., Tal, I., Zavitan, M., Zuckerman, N., Bar-Chaim, A., Kreiss, Y., & Regev-Yochay, G. (2021). Covid-19 Breakthrough Infections in Vaccinated Health Care Workers. New England Journal of Medicine, 0(0), null. https://doi.org/10.1056/NEJMoa2109072

    1. Zeke Emanuel on Twitter: “Masks are off, theaters and indoor dining are back: Life seems to be returning to normal. But the highly transmissible Delta variant is spreading quickly, & we aren’t even halfway to a fully vaccinated population. It’s time for employer vaccine mandates. Https://t.co/34UArFfHN5” / Twitter. (n.d.). Retrieved August 1, 2021, from https://twitter.com/ZekeEmanuel/status/1418266496749428737?s=20

  10. Jul 2021
  11. Jun 2021
    1. V Shah, A. S., Gribben, C., Bishop, J., Hanlon, P., Caldwell, D., Wood, R., Reid, M., McMenamin, J., Goldberg, D., Stockton, D., Hutchinson, S., Robertson, C., McKeigue, P. M., Colhoun, H. M., & McAllister, D. A. (2021). Effect of vaccination on transmission of COVID-19: An observational study in healthcare workers and their households [Preprint]. Public and Global Health. https://doi.org/10.1101/2021.03.11.21253275

    1. Woolf, K., McManus, I. C., Martin, C. A., Nellums, L. B., Guyatt, A. L., Melbourne, C., Bryant, L., Gogoi, M., Wobi, F., Al-Oraibi, A., Hassan, O., Gupta, A., John, C., Tobin, M. D., Carr, S., Simpson, S., Gregary, B., Aujayeb, A., Zingwe, S., … Pareek, M. (2021). Ethnic differences in SARS-CoV-2 vaccine hesitancy in United Kingdom healthcare workers: Results from the UK-REACH prospective nationwide cohort study [Preprint]. Public and Global Health. https://doi.org/10.1101/2021.04.26.21255788

    1. Hall, V. J., Foulkes, S., Saei, A., Andrews, N., Oguti, B., Charlett, A., Wellington, E., Stowe, J., Gillson, N., Atti, A., Islam, J., Karagiannis, I., Munro, K., Khawam, J., Group, T. S. S., Chand, M. A., Brown, C., Ramsay, M. E., Bernal, J. L., & Hopkins, S. (2021). Effectiveness of BNT162b2 mRNA Vaccine Against Infection and COVID-19 Vaccine Coverage in Healthcare Workers in England, Multicentre Prospective Cohort Study (the SIREN Study) (SSRN Scholarly Paper ID 3790399). Social Science Research Network. https://doi.org/10.2139/ssrn.3790399

  12. May 2021
  13. Apr 2021
  14. Mar 2021
    1. However, if these timeouts are moved into a web worker, they should run to time and not get de-prioritised by the browser.
  15. Feb 2021
  16. Dec 2020