@interface-technologies/check-for-js-bundle-update-saga 4.0.0 → 4.0.4
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.
- package/CHANGELOG.md +5 -0
- package/LICENSE +6 -6
- package/dist/checkForJsBundleUpdateSaga.d.ts +14 -29
- package/dist/checkForJsBundleUpdateSaga.js +43 -51
- package/package.json +5 -4
- package/dist/checkForJsBundleUpdateSaga.js.map +0 -1
- package/dist/checkForJsBundleUpdateSaga.test.d.ts +0 -1
- package/dist/checkForJsBundleUpdateSaga.test.js +0 -65
- package/dist/checkForJsBundleUpdateSaga.test.js.map +0 -1
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
ADDED
package/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Copyright 2018 Interface Technologies, Inc.
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
-
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
-
|
1
|
+
Copyright 2018 Interface Technologies, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -7,9 +7,10 @@ export declare function reload(): void;
|
|
7
7
|
export interface CheckForJsBundleUpdateSagaOptions {
|
8
8
|
delayDuration?: moment.Duration;
|
9
9
|
onError(e: unknown): void;
|
10
|
+
bundleSrcPattern?: RegExp;
|
10
11
|
}
|
11
12
|
/**
|
12
|
-
*
|
13
|
+
* Periodically fetches `/` (`index.html`) to check if a new JavaScript bundle has been
|
13
14
|
* released.
|
14
15
|
*
|
15
16
|
* If the bundle has been updated, the user is prompted to refresh the page.
|
@@ -17,31 +18,21 @@ export interface CheckForJsBundleUpdateSagaOptions {
|
|
17
18
|
*
|
18
19
|
* Don't enable this in development!
|
19
20
|
*
|
20
|
-
* Your `index.html` must contain a
|
21
|
-
* contains a hash of the JavaScript bundle's entry point. Here's how to do this
|
22
|
-
* in ASP.NET Core:
|
21
|
+
* Your `index.html` must contain a script tag like:
|
23
22
|
*
|
24
|
-
* ```
|
25
|
-
*
|
26
|
-
*
|
23
|
+
* ```html
|
24
|
+
* <script src="app.23e590a23b49.js"></script>
|
25
|
+
* ```
|
27
26
|
*
|
28
|
-
*
|
29
|
-
* {
|
30
|
-
* var fullPath = System.IO.Path.Combine("wwwroot", path);
|
31
|
-
* using (var readStream = File.OpenRead(fullPath))
|
32
|
-
* {
|
33
|
-
* var hashBytes = sha256.ComputeHash(readStream);
|
34
|
-
* jsBundleHash = WebEncoders.Base64UrlEncode(hashBytes);
|
35
|
-
* }
|
36
|
-
* }
|
27
|
+
* or
|
37
28
|
*
|
38
|
-
*
|
39
|
-
* <
|
40
|
-
* @jsBundleHash
|
41
|
-
* </span>
|
29
|
+
* ```html
|
30
|
+
* <script src="dist/app.js?v=Gq0JHtehvL9fMpV"></script>
|
42
31
|
* ```
|
43
32
|
*
|
44
|
-
*
|
33
|
+
* `checkForJsBundleUpdateSaga` will compare the `src` attribute of the script tag.
|
34
|
+
*
|
35
|
+
* An example of using `checkForJsBundleUpdateSaga` from your TypeScript code:
|
45
36
|
*
|
46
37
|
* ```
|
47
38
|
* export function* myCheckForJsBundleUpdateSaga(): SagaIterator<void> {
|
@@ -49,17 +40,11 @@ export interface CheckForJsBundleUpdateSagaOptions {
|
|
49
40
|
*
|
50
41
|
* function onError(e: unknown): void {
|
51
42
|
* console.error(e)
|
52
|
-
*
|
53
|
-
* const ierror = processError(e)
|
54
|
-
*
|
55
|
-
* // Never show the user an error because of this
|
56
|
-
* if (shouldLogError(ierror)) {
|
57
|
-
* Bugsnag.notify(ierror)
|
58
|
-
* }
|
43
|
+
* Bugsnag.notify(e)
|
59
44
|
* }
|
60
45
|
*
|
61
46
|
* yield call(checkForJsBundleUpdateSaga, { onError })
|
62
47
|
* }
|
63
48
|
* ```
|
64
49
|
*/
|
65
|
-
export declare function checkForJsBundleUpdateSaga({ delayDuration, onError, }: CheckForJsBundleUpdateSagaOptions): SagaIterator<void>;
|
50
|
+
export declare function checkForJsBundleUpdateSaga({ delayDuration, onError, bundleSrcPattern, }: CheckForJsBundleUpdateSagaOptions): SagaIterator<void>;
|
@@ -8,7 +8,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
9
9
|
const effects_1 = require("redux-saga/effects");
|
10
10
|
const iti_react_1 = require("@interface-technologies/iti-react");
|
11
|
-
const hashElementId = 'jsBundleHash';
|
12
11
|
const defaultDelayDuration = moment_timezone_1.default.duration(4, 'minutes');
|
13
12
|
const forceRefreshAfterAlertCount = 3;
|
14
13
|
/** @internal */
|
@@ -28,8 +27,21 @@ function reload() {
|
|
28
27
|
window.location.reload();
|
29
28
|
}
|
30
29
|
exports.reload = reload;
|
30
|
+
function getBundleSrcFromDocument(doc, bundleSrcPattern) {
|
31
|
+
var _a;
|
32
|
+
const scripts = Array.from(doc.getElementsByTagName('script'));
|
33
|
+
for (const script of scripts) {
|
34
|
+
const parts = (_a = script.src) === null || _a === void 0 ? void 0 : _a.split('/');
|
35
|
+
if (parts.length === 0)
|
36
|
+
continue;
|
37
|
+
const src = parts[parts.length - 1];
|
38
|
+
if (bundleSrcPattern.test(src))
|
39
|
+
return src;
|
40
|
+
}
|
41
|
+
return undefined;
|
42
|
+
}
|
31
43
|
/**
|
32
|
-
*
|
44
|
+
* Periodically fetches `/` (`index.html`) to check if a new JavaScript bundle has been
|
33
45
|
* released.
|
34
46
|
*
|
35
47
|
* If the bundle has been updated, the user is prompted to refresh the page.
|
@@ -37,31 +49,21 @@ exports.reload = reload;
|
|
37
49
|
*
|
38
50
|
* Don't enable this in development!
|
39
51
|
*
|
40
|
-
* Your `index.html` must contain a
|
41
|
-
* contains a hash of the JavaScript bundle's entry point. Here's how to do this
|
42
|
-
* in ASP.NET Core:
|
52
|
+
* Your `index.html` must contain a script tag like:
|
43
53
|
*
|
44
|
-
* ```
|
45
|
-
*
|
46
|
-
*
|
54
|
+
* ```html
|
55
|
+
* <script src="app.23e590a23b49.js"></script>
|
56
|
+
* ```
|
47
57
|
*
|
48
|
-
*
|
49
|
-
* {
|
50
|
-
* var fullPath = System.IO.Path.Combine("wwwroot", path);
|
51
|
-
* using (var readStream = File.OpenRead(fullPath))
|
52
|
-
* {
|
53
|
-
* var hashBytes = sha256.ComputeHash(readStream);
|
54
|
-
* jsBundleHash = WebEncoders.Base64UrlEncode(hashBytes);
|
55
|
-
* }
|
56
|
-
* }
|
58
|
+
* or
|
57
59
|
*
|
58
|
-
*
|
59
|
-
* <
|
60
|
-
* @jsBundleHash
|
61
|
-
* </span>
|
60
|
+
* ```html
|
61
|
+
* <script src="dist/app.js?v=Gq0JHtehvL9fMpV"></script>
|
62
62
|
* ```
|
63
63
|
*
|
64
|
-
*
|
64
|
+
* `checkForJsBundleUpdateSaga` will compare the `src` attribute of the script tag.
|
65
|
+
*
|
66
|
+
* An example of using `checkForJsBundleUpdateSaga` from your TypeScript code:
|
65
67
|
*
|
66
68
|
* ```
|
67
69
|
* export function* myCheckForJsBundleUpdateSaga(): SagaIterator<void> {
|
@@ -69,24 +71,17 @@ exports.reload = reload;
|
|
69
71
|
*
|
70
72
|
* function onError(e: unknown): void {
|
71
73
|
* console.error(e)
|
72
|
-
*
|
73
|
-
* const ierror = processError(e)
|
74
|
-
*
|
75
|
-
* // Never show the user an error because of this
|
76
|
-
* if (shouldLogError(ierror)) {
|
77
|
-
* Bugsnag.notify(ierror)
|
78
|
-
* }
|
74
|
+
* Bugsnag.notify(e)
|
79
75
|
* }
|
80
76
|
*
|
81
77
|
* yield call(checkForJsBundleUpdateSaga, { onError })
|
82
78
|
* }
|
83
79
|
* ```
|
84
80
|
*/
|
85
|
-
function* checkForJsBundleUpdateSaga({ delayDuration = defaultDelayDuration, onError, }) {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
onError(new Error('Could not get jsBundleHash.'));
|
81
|
+
function* checkForJsBundleUpdateSaga({ delayDuration = defaultDelayDuration, onError, bundleSrcPattern = /app\.\S+\.js/, }) {
|
82
|
+
const bundleSrc = getBundleSrcFromDocument(document, bundleSrcPattern);
|
83
|
+
if (!bundleSrc) {
|
84
|
+
onError(new Error('Could not get bundle src from current document.'));
|
90
85
|
return;
|
91
86
|
}
|
92
87
|
yield (0, effects_1.delay)(delayDuration.asMilliseconds());
|
@@ -95,24 +90,21 @@ function* checkForJsBundleUpdateSaga({ delayDuration = defaultDelayDuration, onE
|
|
95
90
|
try {
|
96
91
|
const indexHtml = (yield (0, effects_1.call)(getIndexHtml));
|
97
92
|
if (indexHtml) {
|
98
|
-
const
|
99
|
-
const
|
100
|
-
if (
|
101
|
-
|
102
|
-
|
103
|
-
if (jsBundleHash !== newJsBundleHash) {
|
104
|
-
const content = ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { children: "Please save your work and refresh the page." }, void 0), (0, jsx_runtime_1.jsx)("p", { className: "mb-0", children: "You may encounter errors if you do not refresh the page." }, void 0)] }, void 0));
|
105
|
-
if (alertShownCount >= forceRefreshAfterAlertCount) {
|
106
|
-
window.onbeforeunload = null;
|
107
|
-
yield (0, effects_1.call)(reload);
|
108
|
-
return;
|
109
|
-
}
|
110
|
-
yield (0, effects_1.call)(iti_react_1.alert, content, { title: 'Website Update Available!' });
|
111
|
-
alertShownCount += 1;
|
112
|
-
}
|
93
|
+
const retrievedDocument = new DOMParser().parseFromString(indexHtml, 'text/html');
|
94
|
+
const retrievedBundleSrc = getBundleSrcFromDocument(retrievedDocument, bundleSrcPattern);
|
95
|
+
if (!retrievedBundleSrc) {
|
96
|
+
onError('Could not get bundle src from retrieved document.');
|
97
|
+
return;
|
113
98
|
}
|
114
|
-
|
115
|
-
|
99
|
+
if (bundleSrc !== retrievedBundleSrc) {
|
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." }, void 0), (0, jsx_runtime_1.jsx)("p", { className: "mb-0", children: "You may encounter errors if you do not refresh the page." }, void 0)] }, void 0));
|
101
|
+
if (alertShownCount >= forceRefreshAfterAlertCount) {
|
102
|
+
window.onbeforeunload = null;
|
103
|
+
yield (0, effects_1.call)(reload);
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
yield (0, effects_1.call)(iti_react_1.alert, content, { title: 'Website Update Available!' });
|
107
|
+
alertShownCount += 1;
|
116
108
|
}
|
117
109
|
}
|
118
110
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@interface-technologies/check-for-js-bundle-update-saga",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.4",
|
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": {
|
@@ -15,6 +15,7 @@
|
|
15
15
|
"files": [
|
16
16
|
"dist"
|
17
17
|
],
|
18
|
+
"sideEffects": false,
|
18
19
|
"prettier": "@interface-technologies/prettier-config",
|
19
20
|
"dependencies": {
|
20
21
|
"@types/react": "^17.0.35",
|
@@ -22,8 +23,8 @@
|
|
22
23
|
"redux-saga": "^1.1.3"
|
23
24
|
},
|
24
25
|
"devDependencies": {
|
25
|
-
"@interface-technologies/iti-react": "4.0.
|
26
|
-
"@interface-technologies/tsconfig": "4.0.
|
26
|
+
"@interface-technologies/iti-react": "4.0.4",
|
27
|
+
"@interface-technologies/tsconfig": "4.0.4",
|
27
28
|
"@redux-saga/is": "^1.1.2",
|
28
29
|
"@redux-saga/symbols": "^1.1.2",
|
29
30
|
"@testing-library/react-hooks": "^7.0.2",
|
@@ -31,7 +32,7 @@
|
|
31
32
|
"redux-saga-test-plan": "^4.0.4"
|
32
33
|
},
|
33
34
|
"peerDependencies": {
|
34
|
-
"@interface-technologies/iti-react": "^4.0.
|
35
|
+
"@interface-technologies/iti-react": "^4.0.4",
|
35
36
|
"@popperjs/core": "^2.10.2",
|
36
37
|
"bootstrap": "^5.1.2",
|
37
38
|
"react": "^17.0.2"
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"checkForJsBundleUpdateSaga.js","sourceRoot":"","sources":["../src/checkForJsBundleUpdateSaga.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAEpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AAEzD,MAAM,aAAa,GAAG,cAAc,CAAA;AACpC,MAAM,oBAAoB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;AAC1D,MAAM,2BAA2B,GAAG,CAAC,CAAA;AAErC,gBAAgB;AAChB,M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GAAG,MAAA,MAAM,CAAC,SAAS,0CAAE,IAAI,EAAE,CAAA;oBAEhD,IAAI,YAAY,KAAK,eAAe,EAAE;wBAClC,MAAM,OAAO,GAAG,CACZ;4BACI,6EAAkD;4BAClD,2BAAG,SAAS,EAAC,MAAM,+DAGf,CACF,CACT,CAAA;wBAED,IAAI,eAAe,IAAI,2BAA2B,EAAE;4BAChD,MAAM,CAAC,cAAc,GAAG,IAAI,CAAA;4BAC5B,MAAM,IAAI,CAAC,MAAM,CAAC,CAAA;4BAClB,OAAM;yBACT;wBAED,MAAM,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,2BAA2B,EAAE,CAAC,CAAA;wBAClE,eAAe,IAAI,CAAC,CAAA;qBACvB;iBACJ;qBAAM;oBACH,OAAO,CAAC,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC,CAAA;iBACxE;aACJ;SACJ;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,CAAC,CAAC,CAAC,CAAA;SACb;QAED,MAAM,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,CAAA;KAC9C;AACL,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,65 +0,0 @@
|
|
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
|
-
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
7
|
-
const redux_saga_test_plan_1 = require("redux-saga-test-plan");
|
8
|
-
const effects_1 = require("redux-saga/effects");
|
9
|
-
const iti_react_1 = require("@interface-technologies/iti-react");
|
10
|
-
const checkForJsBundleUpdateSaga_1 = require("./checkForJsBundleUpdateSaga");
|
11
|
-
jest.mock('@interface-technologies/iti-react');
|
12
|
-
// Mock window.location.reload since it not implemented in jsdom
|
13
|
-
// eslint-disable-next-line
|
14
|
-
delete window.location;
|
15
|
-
window.location = { reload: jest.fn() };
|
16
|
-
const jsBundleHash = 'hash0';
|
17
|
-
const newJsBundleHash = 'hash1';
|
18
|
-
beforeEach(() => {
|
19
|
-
jest.useRealTimers();
|
20
|
-
const jsBundleHashElement = document.createElement('span');
|
21
|
-
jsBundleHashElement.innerText = jsBundleHash;
|
22
|
-
jsBundleHashElement.id = 'jsBundleHash';
|
23
|
-
document.body.appendChild(jsBundleHashElement);
|
24
|
-
});
|
25
|
-
function getHtml(hash) {
|
26
|
-
return `
|
27
|
-
<html>
|
28
|
-
<head></head>
|
29
|
-
<body>
|
30
|
-
<span id="jsBundleHash">${hash}</span>
|
31
|
-
</body>
|
32
|
-
</html>
|
33
|
-
`;
|
34
|
-
}
|
35
|
-
const delayDuration = moment_timezone_1.default.duration(0, 'seconds');
|
36
|
-
it('does not show alert if hash matches', async () => {
|
37
|
-
const onError = jest.fn();
|
38
|
-
await (0, redux_saga_test_plan_1.expectSaga)(checkForJsBundleUpdateSaga_1.checkForJsBundleUpdateSaga, { delayDuration, onError })
|
39
|
-
.provide([[(0, effects_1.call)(checkForJsBundleUpdateSaga_1.getIndexHtml), getHtml(jsBundleHash)]])
|
40
|
-
.not.call.fn(iti_react_1.alert)
|
41
|
-
.not.call.fn(checkForJsBundleUpdateSaga_1.reload)
|
42
|
-
.silentRun();
|
43
|
-
expect(onError).not.toHaveBeenCalled();
|
44
|
-
});
|
45
|
-
it('does not call onError if getIndexHtml returns undefined', async () => {
|
46
|
-
const onError = jest.fn();
|
47
|
-
await (0, redux_saga_test_plan_1.expectSaga)(checkForJsBundleUpdateSaga_1.checkForJsBundleUpdateSaga, { delayDuration, onError })
|
48
|
-
.provide([[(0, effects_1.call)(checkForJsBundleUpdateSaga_1.getIndexHtml), undefined]])
|
49
|
-
.not.call.fn(iti_react_1.alert)
|
50
|
-
.not.call.fn(checkForJsBundleUpdateSaga_1.reload)
|
51
|
-
.silentRun();
|
52
|
-
expect(onError).not.toHaveBeenCalled();
|
53
|
-
});
|
54
|
-
it('shows alert several times and then refreshes page', async () => {
|
55
|
-
const onError = jest.fn((e) => console.error(e));
|
56
|
-
await (0, redux_saga_test_plan_1.expectSaga)(checkForJsBundleUpdateSaga_1.checkForJsBundleUpdateSaga, { delayDuration, onError })
|
57
|
-
.provide([[(0, effects_1.call)(checkForJsBundleUpdateSaga_1.getIndexHtml), getHtml(newJsBundleHash)]])
|
58
|
-
.call.fn(iti_react_1.alert)
|
59
|
-
.call.fn(iti_react_1.alert)
|
60
|
-
.call.fn(iti_react_1.alert)
|
61
|
-
.call(checkForJsBundleUpdateSaga_1.reload)
|
62
|
-
.run();
|
63
|
-
expect(onError).not.toHaveBeenCalled();
|
64
|
-
expect(window.location.reload).toHaveBeenCalled();
|
65
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"checkForJsBundleUpdateSaga.test.js","sourceRoot":"","sources":["../src/checkForJsBundleUpdateSaga.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AACzD,OAAO,EACH,YAAY,EACZ,0BAA0B,EAC1B,MAAM,GACT,MAAM,8BAA8B,CAAA;AAErC,IAAI,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAA;AAE9C,gEAAgE;AAChE,2BAA2B;AAC3B,OAAQ,MAAc,CAAC,QAAQ,CAAA;AAC/B,MAAM,CAAC,QAAQ,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,EAAyB,CAAA;AAE9D,MAAM,YAAY,GAAG,OAAO,CAAA;AAC5B,MAAM,eAAe,GAAG,OAAO,CAAA;AAE/B,UAAU,CAAC,GAAG,EAAE;IACZ,IAAI,CAAC,aAAa,EAAE,CAAA;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