Skip to content

Commit 9999f23

Browse files
authored
Merge pull request #1313 from remotestorage/chore/node-20
Support node.js 18, 20
2 parents 1e0cccc + 9b12647 commit 9999f23

12 files changed

+981
-6682
lines changed

.browserslistrc

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
cover 99.5%
44
ie >= 11
5-
maintained node versions
65
not dead

.github/workflows/test-and-lint.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
strategy:
1313
matrix:
1414
# Support LTS versions based on https://nodejs.org/en/about/releases/
15-
node-version: ['14', '16']
15+
node-version: ['18', '20']
1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v3
19+
uses: actions/setup-node@v4
2020
with:
2121
node-version: ${{ matrix.node-version }}
2222
- name: Install dependencies

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

package-lock.json

+821-6,369
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
"ts-node": "^10.9.1",
5454
"typedoc": "^0.19.2",
5555
"typescript": "^4.8.3",
56-
"webpack": "^4.46.0",
57-
"webpack-cli": "^4.10.0"
56+
"webpack": "^5.92.0",
57+
"webpack-cli": "^5.1.4"
5858
},
5959
"dependencies": {
60-
"@types/node": "16.11.59",
60+
"@types/node": "20.14.0",
6161
"@types/tv4": "^1.2.29",
6262
"esm": "^3.2.25",
6363
"tv4": "^1.3.0",

src/discover.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import log from './log';
66
import { globalContext, localStorageAvailable } from './util';
77

88
// feature detection flags
9-
let haveXMLHttpRequest, hasLocalStorage;
9+
let hasLocalStorage;
1010

1111
// used to store settings in localStorage
1212
const SETTINGS_KEY = 'remotestorage:discover';
@@ -66,7 +66,7 @@ const Discover = function Discover(userAddress: string): Promise<StorageInfo> {
6666
};
6767

6868
if (hasLocalStorage) {
69-
localStorage[SETTINGS_KEY] = JSON.stringify({ cache: cachedInfo });
69+
localStorage.setItem(SETTINGS_KEY, JSON.stringify({ cache: cachedInfo }));
7070
}
7171

7272
return resolve(cachedInfo[userAddress]);
@@ -95,8 +95,8 @@ Discover._rs_init = function (/*remoteStorage*/): void {
9595
};
9696

9797
Discover._rs_supported = function (): boolean {
98-
haveXMLHttpRequest = Object.prototype.hasOwnProperty.call(globalContext, 'XMLHttpRequest');
99-
return haveXMLHttpRequest;
98+
return Object.prototype.hasOwnProperty.call(globalContext, 'fetch') ||
99+
Object.prototype.hasOwnProperty.call(globalContext, 'XMLHttpRequest');
100100
};
101101

102102
Discover._rs_cleanup = function (): void {

src/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const shouldBeTreatedAsBinary = (content: string | ArrayBuffer, mimeType:
245245
*/
246246
export const getTextFromArrayBuffer = (arrayBuffer: ArrayBuffer, encoding): Promise<string | ArrayBuffer> => {
247247
return new Promise((resolve/*, reject*/) => {
248-
if (typeof Blob === 'undefined') {
248+
if (typeof Blob === 'undefined' || typeof FileReader === 'undefined') {
249249
const buffer = Buffer.from(arrayBuffer);
250250
resolve(buffer.toString(encoding));
251251
} else {

test/helpers/location.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ class MockLocation {
8484
}
8585
}
8686

87-
8887
export default function locationFactory(url) {
89-
if (!('document' in global)) {
90-
global["document"] = {} as Document;
88+
if (!('document' in globalThis)) {
89+
globalThis["document"] = {} as Document;
9190
}
92-
global.document.location = new MockLocation(url) as unknown as Location;
91+
globalThis.document.location = new MockLocation(url) as unknown as Location;
9392
}

test/unit/authorize.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class MockRemote extends RemoteBase implements Remote {
4040
}
4141

4242
locationFactory('https://foo/bar');
43-
global.localStorageAvailable = localStorageAvailable;
44-
global["sessionStorage"] = sessionStorage;
43+
globalThis.localStorageAvailable = localStorageAvailable;
44+
globalThis["sessionStorage"] = sessionStorage;
4545

4646
describe("authorization", () => {
4747
const sandbox = sinon.createSandbox();
@@ -54,7 +54,7 @@ describe("authorization", () => {
5454
sessionStorage.removeItem('remotestorage:codeVerifier');
5555
sessionStorage.removeItem('remotestorage:state');
5656

57-
global.document.location.href = 'https://foo/bar';
57+
globalThis.document.location.href = 'https://foo/bar';
5858
});
5959

6060
afterEach(() => {

0 commit comments

Comments
 (0)