@parcel/utils 2.0.0-nightly.934 → 2.0.0-nightly.944
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/lib/blob.js +14 -4
- package/lib/config.js +0 -1
- package/lib/index.js +8 -0
- package/lib/shared-buffer.js +31 -0
- package/package.json +12 -7
- package/src/blob.js +1 -0
- package/src/config.js +0 -1
- package/src/index.js +1 -0
- package/src/shared-buffer.js +24 -0
- package/test/config.test.js +50 -0
- package/test/input/config/config.json +3 -0
- package/test/input/config/empty.json +0 -0
- package/test/input/config/empty.toml +0 -0
- package/src/.babelrc +0 -3
package/lib/blob.js
CHANGED
|
@@ -6,6 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.blobToBuffer = blobToBuffer;
|
|
7
7
|
exports.blobToString = blobToString;
|
|
8
8
|
|
|
9
|
+
function _buffer() {
|
|
10
|
+
const data = require("buffer");
|
|
11
|
+
|
|
12
|
+
_buffer = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
var _ = require("./");
|
|
10
20
|
|
|
11
21
|
function _stream() {
|
|
@@ -21,17 +31,17 @@ function _stream() {
|
|
|
21
31
|
function blobToBuffer(blob) {
|
|
22
32
|
if (blob instanceof _stream().Readable) {
|
|
23
33
|
return (0, _.bufferStream)(blob);
|
|
24
|
-
} else if (blob instanceof Buffer) {
|
|
25
|
-
return Promise.resolve(Buffer.from(blob));
|
|
34
|
+
} else if (blob instanceof _buffer().Buffer) {
|
|
35
|
+
return Promise.resolve(_buffer().Buffer.from(blob));
|
|
26
36
|
} else {
|
|
27
|
-
return Promise.resolve(Buffer.from(blob, 'utf8'));
|
|
37
|
+
return Promise.resolve(_buffer().Buffer.from(blob, 'utf8'));
|
|
28
38
|
}
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
async function blobToString(blob) {
|
|
32
42
|
if (blob instanceof _stream().Readable) {
|
|
33
43
|
return (await (0, _.bufferStream)(blob)).toString();
|
|
34
|
-
} else if (blob instanceof Buffer) {
|
|
44
|
+
} else if (blob instanceof _buffer().Buffer) {
|
|
35
45
|
return blob.toString();
|
|
36
46
|
} else {
|
|
37
47
|
return blob;
|
package/lib/config.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -249,6 +249,12 @@ Object.defineProperty(exports, "hashFile", {
|
|
|
249
249
|
return _hash.hashFile;
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
|
+
Object.defineProperty(exports, "SharedBuffer", {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function () {
|
|
255
|
+
return _sharedBuffer.SharedBuffer;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
252
258
|
Object.defineProperty(exports, "createHTTPServer", {
|
|
253
259
|
enumerable: true,
|
|
254
260
|
get: function () {
|
|
@@ -430,6 +436,8 @@ var _glob = require("./glob");
|
|
|
430
436
|
|
|
431
437
|
var _hash = require("./hash");
|
|
432
438
|
|
|
439
|
+
var _sharedBuffer = require("./shared-buffer");
|
|
440
|
+
|
|
433
441
|
var _httpServer = require("./http-server");
|
|
434
442
|
|
|
435
443
|
var _path = require("./path");
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SharedBuffer = void 0;
|
|
7
|
+
|
|
8
|
+
/* global MessageChannel:readonly */
|
|
9
|
+
let SharedBuffer; // $FlowFixMe[prop-missing]
|
|
10
|
+
|
|
11
|
+
exports.SharedBuffer = SharedBuffer;
|
|
12
|
+
|
|
13
|
+
if (process.browser) {
|
|
14
|
+
exports.SharedBuffer = SharedBuffer = ArrayBuffer; // Safari has removed the constructor
|
|
15
|
+
|
|
16
|
+
if (typeof SharedArrayBuffer !== 'undefined') {
|
|
17
|
+
let channel = new MessageChannel();
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
// Firefox might throw when sending the Buffer over a MessagePort
|
|
21
|
+
channel.port1.postMessage(new SharedArrayBuffer(0));
|
|
22
|
+
exports.SharedBuffer = SharedBuffer = SharedArrayBuffer;
|
|
23
|
+
} catch (_) {// NOOP
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
channel.port1.close();
|
|
27
|
+
channel.port2.close();
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
exports.SharedBuffer = SharedBuffer = SharedArrayBuffer;
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/utils",
|
|
3
|
-
"version": "2.0.0-nightly.
|
|
3
|
+
"version": "2.0.0-nightly.944+8ee562ae",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@iarna/toml": "^2.2.0",
|
|
24
|
-
"@parcel/codeframe": "2.0.0-nightly.
|
|
25
|
-
"@parcel/diagnostic": "2.0.0-nightly.
|
|
26
|
-
"@parcel/hash": "2.0.2-nightly.
|
|
27
|
-
"@parcel/logger": "2.0.0-nightly.
|
|
28
|
-
"@parcel/markdown-ansi": "2.0.0-nightly.
|
|
24
|
+
"@parcel/codeframe": "2.0.0-nightly.944+8ee562ae",
|
|
25
|
+
"@parcel/diagnostic": "2.0.0-nightly.944+8ee562ae",
|
|
26
|
+
"@parcel/hash": "2.0.2-nightly.2566+8ee562ae",
|
|
27
|
+
"@parcel/logger": "2.0.0-nightly.944+8ee562ae",
|
|
28
|
+
"@parcel/markdown-ansi": "2.0.0-nightly.944+8ee562ae",
|
|
29
29
|
"@parcel/source-map": "^2.0.0",
|
|
30
30
|
"ansi-html-community": "0.0.8",
|
|
31
31
|
"chalk": "^4.1.0",
|
|
@@ -46,5 +46,10 @@
|
|
|
46
46
|
"@babel/plugin-transform-flow-strip-types": "^7.2.0",
|
|
47
47
|
"random-int": "^1.0.0"
|
|
48
48
|
},
|
|
49
|
-
"
|
|
49
|
+
"browser": {
|
|
50
|
+
"./src/generateCertificate.js": false,
|
|
51
|
+
"./src/http-server.js": false,
|
|
52
|
+
"./src/openInBrowser.js": false
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "8ee562aefc03a8ae4f3008109581f4170d7bda66"
|
|
50
55
|
}
|
package/src/blob.js
CHANGED
package/src/config.js
CHANGED
package/src/index.js
CHANGED
|
@@ -41,6 +41,7 @@ export {DefaultMap, DefaultWeakMap} from './DefaultMap';
|
|
|
41
41
|
export {makeDeferredWithPromise} from './Deferred';
|
|
42
42
|
export {isGlob, isGlobMatch, globSync, glob} from './glob';
|
|
43
43
|
export {hashStream, hashObject, hashFile} from './hash';
|
|
44
|
+
export {SharedBuffer} from './shared-buffer';
|
|
44
45
|
export {fuzzySearch} from './schema';
|
|
45
46
|
export {createHTTPServer} from './http-server';
|
|
46
47
|
export {normalizePath, normalizeSeparators, relativePath} from './path';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
/* global MessageChannel:readonly */
|
|
3
|
+
|
|
4
|
+
export let SharedBuffer: Class<ArrayBuffer> | Class<SharedArrayBuffer>;
|
|
5
|
+
|
|
6
|
+
// $FlowFixMe[prop-missing]
|
|
7
|
+
if (process.browser) {
|
|
8
|
+
SharedBuffer = ArrayBuffer;
|
|
9
|
+
// Safari has removed the constructor
|
|
10
|
+
if (typeof SharedArrayBuffer !== 'undefined') {
|
|
11
|
+
let channel = new MessageChannel();
|
|
12
|
+
try {
|
|
13
|
+
// Firefox might throw when sending the Buffer over a MessagePort
|
|
14
|
+
channel.port1.postMessage(new SharedArrayBuffer(0));
|
|
15
|
+
SharedBuffer = SharedArrayBuffer;
|
|
16
|
+
} catch (_) {
|
|
17
|
+
// NOOP
|
|
18
|
+
}
|
|
19
|
+
channel.port1.close();
|
|
20
|
+
channel.port2.close();
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
SharedBuffer = SharedArrayBuffer;
|
|
24
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
3
|
+
import assert from 'assert';
|
|
4
|
+
import {loadConfig} from '../src/config';
|
|
5
|
+
import {inputFS as fs} from '@parcel/test-utils';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
|
|
8
|
+
describe('loadConfig', () => {
|
|
9
|
+
it('load config with json', async () => {
|
|
10
|
+
assert.deepEqual(
|
|
11
|
+
(
|
|
12
|
+
await loadConfig(
|
|
13
|
+
fs,
|
|
14
|
+
path.join(__dirname, './input/config/config.json'),
|
|
15
|
+
['config.json'],
|
|
16
|
+
path.join(__dirname, './input/config/'),
|
|
17
|
+
)
|
|
18
|
+
)?.config,
|
|
19
|
+
{
|
|
20
|
+
hoge: 'fuga',
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should throw error with empty string json', async () => {
|
|
26
|
+
// $FlowFixMe[prop-missing]
|
|
27
|
+
await assert.rejects(async () => {
|
|
28
|
+
await loadConfig(
|
|
29
|
+
fs,
|
|
30
|
+
path.join(__dirname, './input/config/empty.json'),
|
|
31
|
+
['empty.json'],
|
|
32
|
+
path.join(__dirname, './input/config/'),
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should load with empty string config toml', async () => {
|
|
38
|
+
assert.deepEqual(
|
|
39
|
+
(
|
|
40
|
+
await loadConfig(
|
|
41
|
+
fs,
|
|
42
|
+
path.join(__dirname, './input/config/empty.toml'),
|
|
43
|
+
['empty.toml'],
|
|
44
|
+
path.join(__dirname, './input/config/'),
|
|
45
|
+
)
|
|
46
|
+
)?.config,
|
|
47
|
+
{},
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
File without changes
|
|
File without changes
|
package/src/.babelrc
DELETED