@parcel/graph 2.8.0 → 2.8.1-nightly.2828

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.
@@ -25,15 +25,7 @@ function _nullthrows() {
25
25
  return data;
26
26
  }
27
27
 
28
- function _utils() {
29
- const data = require("@parcel/utils");
30
-
31
- _utils = function () {
32
- return data;
33
- };
34
-
35
- return data;
36
- }
28
+ var _sharedBuffer = require("./shared-buffer");
37
29
 
38
30
  var _types = require("./types");
39
31
 
@@ -573,7 +565,7 @@ class SharedTypeMap {
573
565
  } = Uint32Array;
574
566
  let CAPACITY = SharedTypeMap.#CAPACITY; // $FlowFixMe[incompatible-call]
575
567
 
576
- this.data = new Uint32Array(new (_utils().SharedBuffer)(this.getLength(capacityOrData) * BYTES_PER_ELEMENT));
568
+ this.data = new Uint32Array(new _sharedBuffer.SharedBuffer(this.getLength(capacityOrData) * BYTES_PER_ELEMENT));
577
569
  this.data[CAPACITY] = capacityOrData;
578
570
  } else {
579
571
  this.data = capacityOrData;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SharedBuffer = void 0;
7
+
8
+ /* global MessageChannel:readonly */
9
+ // Copy from @parcel/utils to fix: https://github.com/stackblitz/core/issues/1855
10
+ let SharedBuffer; // $FlowFixMe[prop-missing]
11
+
12
+ exports.SharedBuffer = SharedBuffer;
13
+
14
+ if (process.browser) {
15
+ exports.SharedBuffer = SharedBuffer = ArrayBuffer; // Safari has removed the constructor
16
+
17
+ if (typeof SharedArrayBuffer !== 'undefined') {
18
+ let channel = new MessageChannel();
19
+
20
+ try {
21
+ // Firefox might throw when sending the Buffer over a MessagePort
22
+ channel.port1.postMessage(new SharedArrayBuffer(0));
23
+ exports.SharedBuffer = SharedBuffer = SharedArrayBuffer;
24
+ } catch (_) {// NOOP
25
+ }
26
+
27
+ channel.port1.close();
28
+ channel.port2.close();
29
+ }
30
+ } else {
31
+ exports.SharedBuffer = SharedBuffer = SharedArrayBuffer;
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/graph",
3
- "version": "2.8.0",
3
+ "version": "2.8.1-nightly.2828+711ae183f",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -20,8 +20,7 @@
20
20
  "node": ">= 12.0.0"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/utils": "2.8.0",
24
23
  "nullthrows": "^1.1.1"
25
24
  },
26
- "gitHead": "c3bbe0a6160186f496ca2f9e9bead9376c0522f1"
25
+ "gitHead": "711ae183f7b61be36128e9da0e424d874d836015"
27
26
  }
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import assert from 'assert';
3
3
  import nullthrows from 'nullthrows';
4
- import {SharedBuffer} from '@parcel/utils';
4
+ import {SharedBuffer} from './shared-buffer';
5
5
  import {fromNodeId, toNodeId} from './types';
6
6
  import {ALL_EDGE_TYPES, type NullEdgeType, type AllEdgeTypes} from './Graph';
7
7
  import type {NodeId} from './types';
@@ -0,0 +1,24 @@
1
+ // @flow
2
+ /* global MessageChannel:readonly */
3
+ // Copy from @parcel/utils to fix: https://github.com/stackblitz/core/issues/1855
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
+ }