scratch-storage 2.3.1 → 2.3.2

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.
@@ -0,0 +1 @@
1
+ @scratchfoundation/scratch-engineering
@@ -0,0 +1,51 @@
1
+ name: CI/CD
2
+
3
+ on:
4
+ workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
5
+ push: # Runs whenever a commit is pushed to the repository
6
+
7
+ concurrency:
8
+ group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
9
+ cancel-in-progress: true
10
+
11
+ permissions:
12
+ contents: write # publish a GitHub release
13
+ pages: write # deploy to GitHub Pages
14
+ issues: write # comment on released issues
15
+ pull-requests: write # comment on released pull requests
16
+
17
+ jobs:
18
+ ci-cd:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
22
+
23
+ - uses: wagoid/commitlint-github-action@5ce82f5d814d4010519d15f0552aec4f17a1e1fe # v5
24
+ if: github.event_name == 'pull_request'
25
+
26
+ - uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
27
+ with:
28
+ cache: "npm"
29
+ node-version-file: ".nvmrc"
30
+
31
+ - name: Info
32
+ run: |
33
+ cat <<EOF
34
+ Node version: $(node --version)
35
+ NPM version: $(npm --version)
36
+ GitHub ref: ${{ github.ref }}
37
+ GitHub head ref: ${{ github.head_ref }}
38
+ EOF
39
+
40
+ - name: Setup & Test
41
+ run: |
42
+ npm ci
43
+ npm run build
44
+ npm run test
45
+
46
+ - name: Semantic release (configured to run dry if branch is other than 'develop')
47
+ env:
48
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50
+ run: |
51
+ npx --no -- semantic-release
@@ -0,0 +1,12 @@
1
+ name: Lint commit messages
2
+ on: [pull_request]
3
+
4
+ concurrency:
5
+ group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.sha }}"
6
+
7
+ jobs:
8
+ commitlint:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
12
+ - uses: wagoid/commitlint-github-action@5ce82f5d814d4010519d15f0552aec4f17a1e1fe # v5
@@ -0,0 +1 @@
1
+ * text eol=lf
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx --no-install commitlint --edit "$1"
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ v16
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See
4
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [2.3.2](https://github.com/scratchfoundation/scratch-storage/compare/v2.3.1...v2.3.2) (2024-02-21)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **deps:** lock file maintenance ([ca51101](https://github.com/scratchfoundation/scratch-storage/commit/ca511019f5caddf8bc540a12ebfc808bb75973d0))
@@ -1 +1,4 @@
1
- module.exports = {extends: ['@commitlint/config-conventional']};
1
+ module.exports = {
2
+ extends: ['@commitlint/config-conventional'],
3
+ ignores: [message => message.startsWith('chore(release):')]
4
+ };
@@ -94,11 +94,12 @@
94
94
  /***/ (function(module, exports, __webpack_require__) {
95
95
 
96
96
  /* eslint-env worker */
97
- var crossFetch = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetch/dist/node-ponyfill.js").default;
98
97
 
98
+ var crossFetch = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetch/dist/node-ponyfill.js").default;
99
99
  var jobsActive = 0;
100
100
  var complete = [];
101
101
  var intervalId = null;
102
+
102
103
  /**
103
104
  * Register a step function.
104
105
  *
@@ -106,13 +107,13 @@ var intervalId = null;
106
107
  * parent. Then it checks the jobs count. If there are no further jobs, clear
107
108
  * the step.
108
109
  */
109
-
110
110
  var registerStep = function registerStep() {
111
111
  intervalId = setInterval(function () {
112
112
  if (complete.length) {
113
113
  // Send our chunk of completed requests and instruct postMessage to
114
114
  // transfer the buffers instead of copying them.
115
- postMessage(complete.slice(), // Instruct postMessage that these buffers in the sent message
115
+ postMessage(complete.slice(),
116
+ // Instruct postMessage that these buffers in the sent message
116
117
  // should use their Transferable trait. After the postMessage
117
118
  // call the "buffers" will still be in complete if you looked,
118
119
  // but they will all be length 0 as the data they reference has
@@ -124,26 +125,22 @@ var registerStep = function registerStep() {
124
125
  }).filter(Boolean));
125
126
  complete.length = 0;
126
127
  }
127
-
128
128
  if (jobsActive === 0) {
129
129
  clearInterval(intervalId);
130
130
  intervalId = null;
131
131
  }
132
132
  }, 1);
133
133
  };
134
+
134
135
  /**
135
136
  * Receive a job from the parent and fetch the requested data.
136
137
  * @param {object} options.job A job id, url, and options descriptor to perform.
137
138
  */
138
-
139
-
140
139
  var onMessage = function onMessage(_ref) {
141
140
  var job = _ref.data;
142
-
143
141
  if (jobsActive === 0 && !intervalId) {
144
142
  registerStep();
145
143
  }
146
-
147
144
  jobsActive++;
148
145
  crossFetch(job.url, job.options).then(function (result) {
149
146
  if (result.ok) return result.arrayBuffer();
@@ -162,9 +159,9 @@ var onMessage = function onMessage(_ref) {
162
159
  }).then(function () {
163
160
  return jobsActive--;
164
161
  });
165
- }; // crossFetch means "fetch" is now always supported
166
-
162
+ };
167
163
 
164
+ // crossFetch means "fetch" is now always supported
168
165
  postMessage({
169
166
  support: {
170
167
  fetch: true
@@ -211,7 +208,7 @@ exports.default = fetch
211
208
  /*!***********************************************!*\
212
209
  !*** ./node_modules/node-fetch/lib/index.mjs ***!
213
210
  \***********************************************/
214
- /*! exports provided: default, Headers, Request, Response, FetchError */
211
+ /*! exports provided: default, Headers, Request, Response, FetchError, AbortError */
215
212
  /***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
216
213
 
217
214
  "use strict";
@@ -220,6 +217,7 @@ __webpack_require__.r(__webpack_exports__);
220
217
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Request", function() { return Request; });
221
218
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Response", function() { return Response; });
222
219
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FetchError", function() { return FetchError; });
220
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbortError", function() { return AbortError; });
223
221
  /* harmony import */ var stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! stream */ "stream");
224
222
  /* harmony import */ var http__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! http */ "http");
225
223
  /* harmony import */ var url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! url */ "url");
@@ -1587,10 +1585,6 @@ function getNodeRequestOptions(request) {
1587
1585
  agent = agent(parsedURL);
1588
1586
  }
1589
1587
 
1590
- if (!headers.has('Connection') && !agent) {
1591
- headers.set('Connection', 'close');
1592
- }
1593
-
1594
1588
  // HTTP-network fetch step 4.2
1595
1589
  // chunked encoding is handled by Node.js
1596
1590
 
@@ -1639,6 +1633,20 @@ const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original)
1639
1633
  return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
1640
1634
  };
1641
1635
 
1636
+ /**
1637
+ * isSameProtocol reports whether the two provided URLs use the same protocol.
1638
+ *
1639
+ * Both domains must already be in canonical form.
1640
+ * @param {string|URL} original
1641
+ * @param {string|URL} destination
1642
+ */
1643
+ const isSameProtocol = function isSameProtocol(destination, original) {
1644
+ const orig = new URL$1(original).protocol;
1645
+ const dest = new URL$1(destination).protocol;
1646
+
1647
+ return orig === dest;
1648
+ };
1649
+
1642
1650
  /**
1643
1651
  * Fetch function
1644
1652
  *
@@ -1670,7 +1678,7 @@ function fetch(url, opts) {
1670
1678
  let error = new AbortError('The user aborted a request.');
1671
1679
  reject(error);
1672
1680
  if (request.body && request.body instanceof stream__WEBPACK_IMPORTED_MODULE_0__.Readable) {
1673
- request.body.destroy(error);
1681
+ destroyStream(request.body, error);
1674
1682
  }
1675
1683
  if (!response || !response.body) return;
1676
1684
  response.body.emit('error', error);
@@ -1711,9 +1719,43 @@ function fetch(url, opts) {
1711
1719
 
1712
1720
  req.on('error', function (err) {
1713
1721
  reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
1722
+
1723
+ if (response && response.body) {
1724
+ destroyStream(response.body, err);
1725
+ }
1726
+
1714
1727
  finalize();
1715
1728
  });
1716
1729
 
1730
+ fixResponseChunkedTransferBadEnding(req, function (err) {
1731
+ if (signal && signal.aborted) {
1732
+ return;
1733
+ }
1734
+
1735
+ if (response && response.body) {
1736
+ destroyStream(response.body, err);
1737
+ }
1738
+ });
1739
+
1740
+ /* c8 ignore next 18 */
1741
+ if (parseInt(process.version.substring(1)) < 14) {
1742
+ // Before Node.js 14, pipeline() does not fully support async iterators and does not always
1743
+ // properly handle when the socket close/end events are out of order.
1744
+ req.on('socket', function (s) {
1745
+ s.addListener('close', function (hadError) {
1746
+ // if a data listener is still present we didn't end cleanly
1747
+ const hasDataListener = s.listenerCount('data') > 0;
1748
+
1749
+ // if end happened before close but the socket didn't emit an error, do it now
1750
+ if (response && hasDataListener && !hadError && !(signal && signal.aborted)) {
1751
+ const err = new Error('Premature close');
1752
+ err.code = 'ERR_STREAM_PREMATURE_CLOSE';
1753
+ response.body.emit('error', err);
1754
+ }
1755
+ });
1756
+ });
1757
+ }
1758
+
1717
1759
  req.on('response', function (res) {
1718
1760
  clearTimeout(reqTimeout);
1719
1761
 
@@ -1785,7 +1827,7 @@ function fetch(url, opts) {
1785
1827
  size: request.size
1786
1828
  };
1787
1829
 
1788
- if (!isDomainOrSubdomain(request.url, locationURL)) {
1830
+ if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
1789
1831
  for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
1790
1832
  requestOpts.headers.delete(name);
1791
1833
  }
@@ -1878,6 +1920,13 @@ function fetch(url, opts) {
1878
1920
  response = new Response(body, response_options);
1879
1921
  resolve(response);
1880
1922
  });
1923
+ raw.on('end', function () {
1924
+ // some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted.
1925
+ if (!response) {
1926
+ response = new Response(body, response_options);
1927
+ resolve(response);
1928
+ }
1929
+ });
1881
1930
  return;
1882
1931
  }
1883
1932
 
@@ -1897,6 +1946,44 @@ function fetch(url, opts) {
1897
1946
  writeToStream(req, request);
1898
1947
  });
1899
1948
  }
1949
+ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
1950
+ let socket;
1951
+
1952
+ request.on('socket', function (s) {
1953
+ socket = s;
1954
+ });
1955
+
1956
+ request.on('response', function (response) {
1957
+ const headers = response.headers;
1958
+
1959
+ if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) {
1960
+ response.once('close', function (hadError) {
1961
+ // tests for socket presence, as in some situations the
1962
+ // the 'socket' event is not triggered for the request
1963
+ // (happens in deno), avoids `TypeError`
1964
+ // if a data listener is still present we didn't end cleanly
1965
+ const hasDataListener = socket && socket.listenerCount('data') > 0;
1966
+
1967
+ if (hasDataListener && !hadError) {
1968
+ const err = new Error('Premature close');
1969
+ err.code = 'ERR_STREAM_PREMATURE_CLOSE';
1970
+ errorCallback(err);
1971
+ }
1972
+ });
1973
+ }
1974
+ });
1975
+ }
1976
+
1977
+ function destroyStream(stream, err) {
1978
+ if (stream.destroy) {
1979
+ stream.destroy(err);
1980
+ } else {
1981
+ // node < 8
1982
+ stream.emit('error', err);
1983
+ stream.end();
1984
+ }
1985
+ }
1986
+
1900
1987
  /**
1901
1988
  * Redirect code matching
1902
1989
  *
@@ -4184,4 +4271,4 @@ module.exports = require("zlib");
4184
4271
  /***/ })
4185
4272
 
4186
4273
  /******/ });
4187
- //# sourceMappingURL=8c63ecb0448dfbb8e804.worker.js.map
4274
+ //# sourceMappingURL=ce8a01e629587e4f90e4.worker.js.map