@atlaspack/core 2.13.2-canary.3699 → 2.13.2-canary.3703

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/Atlaspack.js CHANGED
@@ -205,7 +205,7 @@ class Atlaspack {
205
205
  // $FlowFixMe
206
206
  const version = require('../package.json').version;
207
207
  await lmdb.put('current_session_version', Buffer.from(version));
208
- rustAtlaspack = new _atlaspackV.AtlaspackV3({
208
+ rustAtlaspack = await _atlaspackV.AtlaspackV3.create({
209
209
  ...options,
210
210
  corePath: _path().default.join(__dirname, '..'),
211
211
  threads: process.env.NODE_ENV === 'test' ? 2 : undefined,
@@ -21,7 +21,10 @@ function _diagnostic() {
21
21
  }
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
  class AtlaspackV3 {
24
- constructor({
24
+ constructor(atlaspack_napi) {
25
+ this._atlaspack_napi = atlaspack_napi;
26
+ }
27
+ static async create({
25
28
  fs,
26
29
  packageManager,
27
30
  threads,
@@ -33,16 +36,22 @@ class AtlaspackV3 {
33
36
  options.defaultTargetOptions = options.defaultTargetOptions || {};
34
37
  // $FlowFixMe "engines" are readonly
35
38
  options.defaultTargetOptions.engines = options.defaultTargetOptions.engines || {};
36
- this._internal = _rust().AtlaspackNapi.create({
39
+ const [internal, error] = await (0, _rust().atlaspackNapiCreate)({
37
40
  fs,
38
41
  packageManager,
39
42
  threads,
40
43
  options,
41
44
  napiWorkerPool
42
45
  }, lmdb);
46
+ if (error !== null) {
47
+ throw new (_diagnostic().default)({
48
+ diagnostic: error
49
+ });
50
+ }
51
+ return new AtlaspackV3(internal);
43
52
  }
44
53
  async buildAssetGraph() {
45
- let [graph, error] = await this._internal.buildAssetGraph();
54
+ let [graph, error] = await (0, _rust().atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
46
55
  if (error !== null) {
47
56
  throw new (_diagnostic().default)({
48
57
  diagnostic: error
@@ -51,7 +60,7 @@ class AtlaspackV3 {
51
60
  return graph;
52
61
  }
53
62
  respondToFsEvents(events) {
54
- return this._internal.respondToFsEvents(events);
63
+ return (0, _rust().atlaspackNapiRespondToFsEvents)(this._atlaspack_napi, events);
55
64
  }
56
65
  }
57
66
  exports.AtlaspackV3 = AtlaspackV3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.13.2-canary.3699+be63a515a",
3
+ "version": "2.13.2-canary.3703+2d6afc5ea",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,21 +20,21 @@
20
20
  "check-ts": "tsc --noEmit index.d.ts"
21
21
  },
22
22
  "dependencies": {
23
- "@atlaspack/build-cache": "2.13.2-canary.3699+be63a515a",
24
- "@atlaspack/cache": "2.13.2-canary.3699+be63a515a",
25
- "@atlaspack/diagnostic": "2.13.2-canary.3699+be63a515a",
26
- "@atlaspack/events": "2.13.2-canary.3699+be63a515a",
27
- "@atlaspack/feature-flags": "2.13.2-canary.3699+be63a515a",
28
- "@atlaspack/fs": "2.13.2-canary.3699+be63a515a",
29
- "@atlaspack/graph": "3.3.2-canary.3699+be63a515a",
30
- "@atlaspack/logger": "2.13.2-canary.3699+be63a515a",
31
- "@atlaspack/package-manager": "2.13.2-canary.3699+be63a515a",
32
- "@atlaspack/plugin": "2.13.2-canary.3699+be63a515a",
33
- "@atlaspack/profiler": "2.13.2-canary.3699+be63a515a",
34
- "@atlaspack/rust": "2.13.2-canary.3699+be63a515a",
35
- "@atlaspack/types": "2.13.2-canary.3699+be63a515a",
36
- "@atlaspack/utils": "2.13.2-canary.3699+be63a515a",
37
- "@atlaspack/workers": "2.13.2-canary.3699+be63a515a",
23
+ "@atlaspack/build-cache": "2.13.2-canary.3703+2d6afc5ea",
24
+ "@atlaspack/cache": "2.13.2-canary.3703+2d6afc5ea",
25
+ "@atlaspack/diagnostic": "2.13.2-canary.3703+2d6afc5ea",
26
+ "@atlaspack/events": "2.13.2-canary.3703+2d6afc5ea",
27
+ "@atlaspack/feature-flags": "2.13.2-canary.3703+2d6afc5ea",
28
+ "@atlaspack/fs": "2.13.2-canary.3703+2d6afc5ea",
29
+ "@atlaspack/graph": "3.3.2-canary.3703+2d6afc5ea",
30
+ "@atlaspack/logger": "2.13.2-canary.3703+2d6afc5ea",
31
+ "@atlaspack/package-manager": "2.13.2-canary.3703+2d6afc5ea",
32
+ "@atlaspack/plugin": "2.13.2-canary.3703+2d6afc5ea",
33
+ "@atlaspack/profiler": "2.13.2-canary.3703+2d6afc5ea",
34
+ "@atlaspack/rust": "2.13.2-canary.3703+2d6afc5ea",
35
+ "@atlaspack/types": "2.13.2-canary.3703+2d6afc5ea",
36
+ "@atlaspack/utils": "2.13.2-canary.3703+2d6afc5ea",
37
+ "@atlaspack/workers": "2.13.2-canary.3703+2d6afc5ea",
38
38
  "@mischnic/json-sourcemap": "^0.1.0",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
@@ -67,5 +67,5 @@
67
67
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
68
68
  },
69
69
  "type": "commonjs",
70
- "gitHead": "be63a515ad13dd5ec1e241843d9ef6fdae8699d5"
70
+ "gitHead": "2d6afc5eaa2bafbc3d0992748ae7ab9d54a22869"
71
71
  }
package/src/Atlaspack.js CHANGED
@@ -162,7 +162,7 @@ export default class Atlaspack {
162
162
  const version = require('../package.json').version;
163
163
  await lmdb.put('current_session_version', Buffer.from(version));
164
164
 
165
- rustAtlaspack = new AtlaspackV3({
165
+ rustAtlaspack = await AtlaspackV3.create({
166
166
  ...options,
167
167
  corePath: path.join(__dirname, '..'),
168
168
  threads: process.env.NODE_ENV === 'test' ? 2 : undefined,
@@ -1,7 +1,10 @@
1
1
  // @flow
2
2
 
3
3
  import {
4
- AtlaspackNapi,
4
+ atlaspackNapiCreate,
5
+ atlaspackNapiBuildAssetGraph,
6
+ atlaspackNapiRespondToFsEvents,
7
+ type AtlaspackNapi,
5
8
  type Lmdb,
6
9
  type AtlaspackNapiOptions,
7
10
  } from '@atlaspack/rust';
@@ -24,24 +27,27 @@ export type AtlaspackV3Options = {|
24
27
  |};
25
28
 
26
29
  export class AtlaspackV3 {
27
- _internal: AtlaspackNapi;
28
- _workerIds: any[];
30
+ _atlaspack_napi: AtlaspackNapi;
29
31
 
30
- constructor({
32
+ constructor(atlaspack_napi: AtlaspackNapi) {
33
+ this._atlaspack_napi = atlaspack_napi;
34
+ }
35
+
36
+ static async create({
31
37
  fs,
32
38
  packageManager,
33
39
  threads,
34
40
  lmdb,
35
41
  napiWorkerPool = new NapiWorkerPool(),
36
42
  ...options
37
- }: AtlaspackV3Options) {
43
+ }: AtlaspackV3Options): Promise<AtlaspackV3> {
38
44
  options.logLevel = options.logLevel || 'error';
39
45
  options.defaultTargetOptions = options.defaultTargetOptions || {};
40
46
  // $FlowFixMe "engines" are readonly
41
47
  options.defaultTargetOptions.engines =
42
48
  options.defaultTargetOptions.engines || {};
43
49
 
44
- this._internal = AtlaspackNapi.create(
50
+ const [internal, error] = await atlaspackNapiCreate(
45
51
  {
46
52
  fs,
47
53
  packageManager,
@@ -51,10 +57,20 @@ export class AtlaspackV3 {
51
57
  },
52
58
  lmdb,
53
59
  );
60
+
61
+ if (error !== null) {
62
+ throw new ThrowableDiagnostic({
63
+ diagnostic: error,
64
+ });
65
+ }
66
+
67
+ return new AtlaspackV3(internal);
54
68
  }
55
69
 
56
70
  async buildAssetGraph(): Promise<any> {
57
- let [graph, error] = await this._internal.buildAssetGraph();
71
+ let [graph, error] = await atlaspackNapiBuildAssetGraph(
72
+ this._atlaspack_napi,
73
+ );
58
74
 
59
75
  if (error !== null) {
60
76
  throw new ThrowableDiagnostic({
@@ -65,7 +81,7 @@ export class AtlaspackV3 {
65
81
  return graph;
66
82
  }
67
83
 
68
- respondToFsEvents(events: Array<Event>): Promise<boolean> {
69
- return this._internal.respondToFsEvents(events);
84
+ respondToFsEvents(events: Array<Event>): boolean {
85
+ return atlaspackNapiRespondToFsEvents(this._atlaspack_napi, events);
70
86
  }
71
87
  }