@interface-technologies/check-for-js-bundle-update-saga 6.0.3 → 6.0.5

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.
@@ -1,11 +1,19 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import moment from 'moment-timezone';
3
- import { delay, call } from 'redux-saga/effects';
4
- import { alert } from '@interface-technologies/iti-react';
5
- const defaultDelayDuration = moment.duration(4, 'minutes');
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getIndexHtml = getIndexHtml;
7
+ exports.reload = reload;
8
+ exports.checkForJsBundleUpdateSaga = checkForJsBundleUpdateSaga;
9
+ const jsx_runtime_1 = require("react/jsx-runtime");
10
+ const moment_timezone_1 = __importDefault(require("moment-timezone"));
11
+ const effects_1 = require("redux-saga/effects");
12
+ const iti_react_1 = require("@interface-technologies/iti-react");
13
+ const defaultDelayDuration = moment_timezone_1.default.duration(4, 'minutes');
6
14
  const forceRefreshAfterAlertCount = 3;
7
15
  /** @internal */
8
- export function getIndexHtml() {
16
+ function getIndexHtml() {
9
17
  return (fetch('/')
10
18
  .then((response) => {
11
19
  if (!response.ok)
@@ -16,7 +24,7 @@ export function getIndexHtml() {
16
24
  .catch(() => undefined));
17
25
  }
18
26
  /** @internal */
19
- export function reload() {
27
+ function reload() {
20
28
  window.location.reload();
21
29
  }
22
30
  function getBundleSrcFromDocument(doc, bundleSrcPattern) {
@@ -70,17 +78,17 @@ function getBundleSrcFromDocument(doc, bundleSrcPattern) {
70
78
  * }
71
79
  * ```
72
80
  */
73
- export function* checkForJsBundleUpdateSaga({ delayDuration = defaultDelayDuration, onError, bundleSrcPattern = /app\.\S+\.js/, }) {
81
+ function* checkForJsBundleUpdateSaga({ delayDuration = defaultDelayDuration, onError, bundleSrcPattern = /app\.\S+\.js/, }) {
74
82
  const bundleSrc = getBundleSrcFromDocument(document, bundleSrcPattern);
75
83
  if (!bundleSrc) {
76
84
  onError(new Error('Could not get bundle src from current document.'));
77
85
  return;
78
86
  }
79
- yield delay(delayDuration.asMilliseconds());
87
+ yield (0, effects_1.delay)(delayDuration.asMilliseconds());
80
88
  let alertShownCount = 0;
81
89
  for (;;) {
82
90
  try {
83
- const indexHtml = (yield call(getIndexHtml));
91
+ const indexHtml = (yield (0, effects_1.call)(getIndexHtml));
84
92
  if (indexHtml) {
85
93
  const retrievedDocument = new DOMParser().parseFromString(indexHtml, 'text/html');
86
94
  const retrievedBundleSrc = getBundleSrcFromDocument(retrievedDocument, bundleSrcPattern);
@@ -89,13 +97,13 @@ export function* checkForJsBundleUpdateSaga({ delayDuration = defaultDelayDurati
89
97
  return;
90
98
  }
91
99
  if (bundleSrc !== retrievedBundleSrc) {
92
- const content = (_jsxs("div", { children: [_jsx("p", { children: "Please save your work and refresh the page." }), _jsx("p", { className: "mb-0", children: "You may encounter errors if you do not refresh the page." })] }));
100
+ const content = ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { children: "Please save your work and refresh the page." }), (0, jsx_runtime_1.jsx)("p", { className: "mb-0", children: "You may encounter errors if you do not refresh the page." })] }));
93
101
  if (alertShownCount >= forceRefreshAfterAlertCount) {
94
102
  window.onbeforeunload = null;
95
- yield call(reload);
103
+ yield (0, effects_1.call)(reload);
96
104
  return;
97
105
  }
98
- yield call(alert, content, { title: 'Website Update Available!' });
106
+ yield (0, effects_1.call)(iti_react_1.alert, content, { title: 'Website Update Available!' });
99
107
  alertShownCount += 1;
100
108
  }
101
109
  }
@@ -103,6 +111,6 @@ export function* checkForJsBundleUpdateSaga({ delayDuration = defaultDelayDurati
103
111
  catch (e) {
104
112
  onError(e);
105
113
  }
106
- yield delay(delayDuration.asMilliseconds());
114
+ yield (0, effects_1.delay)(delayDuration.asMilliseconds());
107
115
  }
108
116
  }
package/dist/index.js CHANGED
@@ -1 +1,5 @@
1
- export { checkForJsBundleUpdateSaga } from './checkForJsBundleUpdateSaga';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkForJsBundleUpdateSaga = void 0;
4
+ var checkForJsBundleUpdateSaga_1 = require("./checkForJsBundleUpdateSaga");
5
+ Object.defineProperty(exports, "checkForJsBundleUpdateSaga", { enumerable: true, get: function () { return checkForJsBundleUpdateSaga_1.checkForJsBundleUpdateSaga; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interface-technologies/check-for-js-bundle-update-saga",
3
- "version": "6.0.3",
3
+ "version": "6.0.5",
4
4
  "description": "Redux saga for checking if a JavaScript app has been deployed.",
5
5
  "homepage": "https://github.com/srmagura/iti-react",
6
6
  "repository": {
@@ -9,7 +9,6 @@
9
9
  },
10
10
  "license": "MIT",
11
11
  "author": "Interface Technologies, Inc.",
12
- "type": "module",
13
12
  "main": "dist/index.js",
14
13
  "types": "dist/index.d.ts",
15
14
  "files": [
@@ -23,8 +22,8 @@
23
22
  "redux-saga": "^1.3.0"
24
23
  },
25
24
  "devDependencies": {
26
- "@interface-technologies/iti-react": "6.0.3",
27
- "@interface-technologies/tsconfig": "6.0.3",
25
+ "@interface-technologies/iti-react": "6.0.5",
26
+ "@interface-technologies/tsconfig": "6.0.5",
28
27
  "@redux-saga/is": "^1.1.3",
29
28
  "@redux-saga/symbols": "^1.1.3",
30
29
  "react": "^19.2.4",