@sasjs/cli 6.12.0 → 6.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -341,7 +341,7 @@ var countJsPrograms = function (files) {
341
341
  return inProgramFolder && key.toLowerCase().endsWith('.js');
342
342
  }).length;
343
343
  };
344
- var loaderScript = function (mainScript, version) { return "<script>\n // Boot order: register the service worker that hosts the mock backend, wait\n // until it controls this page, hand it the persisted drive, install the XHR\n // bridge, then start the app.\n (function () {\n function load(src, next, isModule) {\n var s = document.createElement('script')\n if (isModule) s.type = 'module'\n s.src = src\n s.onload = next\n s.onerror = function () { console.error('[mock] failed to load ' + src); next() }\n document.body.appendChild(s)\n }\n function start() {\n load('host/persist.js?v=".concat(version, "', function () {\n Promise.resolve(window.__sasjsMockReady).then(function (boot) {\n if (boot && boot.error) console.error('[mock] boot: ' + boot.error)\n load('host/intercept.js?v=").concat(version, "', function () {\n load('").concat(mainScript, "', function () {}, true)\n })\n })\n })\n }\n if (!('serviceWorker' in navigator)) {\n console.error('[mock] service workers are unavailable - the mock backend cannot run')\n start()\n return\n }\n navigator.serviceWorker\n .register('/sw.js', { scope: '/' })\n .then(function () { return navigator.serviceWorker.ready })\n .then(function () {\n if (navigator.serviceWorker.controller) return\n return new Promise(function (resolve) {\n var timer = setTimeout(resolve, 4000)\n navigator.serviceWorker.addEventListener('controllerchange', function () {\n clearTimeout(timer)\n resolve()\n })\n })\n })\n .then(function () {\n if (navigator.serviceWorker.controller) return start()\n if (!sessionStorage.getItem('mock-sw-reloaded')) {\n sessionStorage.setItem('mock-sw-reloaded', '1')\n location.reload()\n return\n }\n console.error('[mock] no service worker controller - requests will fail')\n start()\n })\n .catch(function (err) {\n console.error('[mock] service worker registration failed: ' + err)\n start()\n })\n })()\n </script>"); };
344
+ var loaderScript = function (mainScript, version) { return "<script>\n // Boot order: register the service worker that hosts the mock backend, wait\n // until it controls this page, hand it the persisted drive, install the XHR\n // bridge, then start the app.\n (function () {\n function load(src, next, isModule) {\n var s = document.createElement('script')\n if (isModule) s.type = 'module'\n s.src = src\n s.onload = next\n s.onerror = function () { console.error('[mock] failed to load ' + src); next() }\n document.body.appendChild(s)\n }\n function start() {\n load('host/persist.js?v=".concat(version, "', function () {\n Promise.resolve(window.__sasjsMockReady).then(function (boot) {\n if (boot && boot.error) console.error('[mock] boot: ' + boot.error)\n load('host/intercept.js?v=").concat(version, "', function () {\n load('").concat(mainScript, "', function () {}, true)\n })\n })\n })\n }\n if (!('serviceWorker' in navigator)) {\n console.error('[mock] service workers are unavailable - the mock backend cannot run')\n start()\n return\n }\n navigator.serviceWorker\n // The worker script's own URL is the only thing a returning visitor\n // cannot bypass: the host files behind it are cache-busted with a\n // version query, but a cached sw.js keeps serving the previous\n // build's worker until the browser next revalidates it - and that\n // worker imports the previous runtime, which may know nothing of\n // what this build deploys. Stamping the script URL makes the new\n // worker a different script, so it installs and takes over at once;\n // updateViaCache keeps a proxy from answering the check with the\n // old copy.\n .register('/sw.js?v=").concat(version, "', { scope: '/', updateViaCache: 'none' })\n .then(function () { return navigator.serviceWorker.ready })\n .then(function () {\n if (navigator.serviceWorker.controller) return\n return new Promise(function (resolve) {\n var timer = setTimeout(resolve, 4000)\n navigator.serviceWorker.addEventListener('controllerchange', function () {\n clearTimeout(timer)\n resolve()\n })\n })\n })\n .then(function () {\n if (navigator.serviceWorker.controller) return start()\n if (!sessionStorage.getItem('mock-sw-reloaded')) {\n sessionStorage.setItem('mock-sw-reloaded', '1')\n location.reload()\n return\n }\n console.error('[mock] no service worker controller - requests will fail')\n start()\n })\n .catch(function (err) {\n console.error('[mock] service worker registration failed: ' + err)\n start()\n })\n })()\n </script>"); };
345
345
  /**
346
346
  * Points the app at its own origin and replaces its bundle tag with the
347
347
  * boot loader. Both changes are reported when the expected markup is absent,
@@ -353,7 +353,11 @@ describe('browser-hosted build', function () {
353
353
  expect(html).toContain('serverurl=""');
354
354
  expect(html).toContain('loginmechanism="Default"');
355
355
  expect(html).not.toContain('https://sas.example.com');
356
- expect(html).toContain("register('/sw.js'");
356
+ expect(html).toContain("register('/sw.js?v=");
357
+ // A cached worker script must not keep a returning visitor on the previous
358
+ // build's runtime: the URL carries the host version, and the check skips
359
+ // the HTTP cache.
360
+ expect(html).toContain("updateViaCache: 'none'");
357
361
  expect(html).toContain('host/persist.js');
358
362
  expect(html).toContain('main.abc123.js');
359
363
  return [2 /*return*/];
package/package.json CHANGED
@@ -124,5 +124,5 @@
124
124
  "ws": "8.21.0",
125
125
  "nanoid": "3.3.18"
126
126
  },
127
- "version": "6.12.0"
127
+ "version": "6.12.1"
128
128
  }