@atlaspack/core 2.12.1-canary.3454 → 2.12.1-canary.3456

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.
@@ -18,7 +18,7 @@ class MutableDependencySymbols {
18
18
  local,
19
19
  loc,
20
20
  isWeak
21
- } of inner) {
21
+ } of inner || []) {
22
22
  this.set(exported, local, loc, isWeak);
23
23
  }
24
24
  }
@@ -59,34 +59,134 @@ class MutableDependencySymbols {
59
59
  return this.#symbols.values();
60
60
  }
61
61
  }
62
-
63
- // TODO
64
62
  exports.MutableDependencySymbols = MutableDependencySymbols;
65
- class AssetSymbols extends Array {
66
- // eslint-disable-next-line no-unused-vars
67
- get() {}
68
-
69
- // eslint-disable-next-line no-unused-vars
70
- hasExportSymbol() {
71
- throw new Error('AssetSymbols.hasExportSymbol');
63
+ class AssetSymbols {
64
+ #symbols;
65
+ #locals;
66
+ get isCleared() {
67
+ return this.#symbols.size === 0;
72
68
  }
73
-
74
- // eslint-disable-next-line no-unused-vars
75
- hasLocalSymbol() {
76
- throw new Error('AssetSymbols.hasExportSymbol');
69
+ constructor(inner) {
70
+ this.#symbols = new Map();
71
+ this.#locals = new Set();
72
+ for (const {
73
+ exported,
74
+ local,
75
+ loc
76
+ } of inner || []) {
77
+ this.#set(exported, local, loc);
78
+ }
79
+ }
80
+ #set(exportSymbol, local, loc) {
81
+ this.#locals.add(local);
82
+ this.#symbols.set(exportSymbol, {
83
+ local,
84
+ loc,
85
+ meta: {}
86
+ });
87
+ }
88
+ get(exportSymbol) {
89
+ return this.#symbols.get(exportSymbol);
90
+ }
91
+ hasExportSymbol(exportSymbol) {
92
+ return this.#symbols.has(exportSymbol);
93
+ }
94
+ hasLocalSymbol(local) {
95
+ return this.#locals.has(local);
77
96
  }
78
97
  exportSymbols() {
98
+ return this.#symbols.keys();
99
+ }
100
+ intoNapi() {
79
101
  return [];
80
102
  }
81
- }
82
103
 
83
- // TODO
104
+ /*:: @@iterator(): Iterator<[Symbol, AssetSymbol]> { return ({}: any); } */
105
+ // $FlowFixMe Flow can't do computed properties
106
+ [Symbol.iterator]() {
107
+ return this.#symbols.values();
108
+ }
109
+ }
84
110
  exports.AssetSymbols = AssetSymbols;
85
- class MutableAssetSymbols extends AssetSymbols {
86
- ensure() {}
87
- set() {}
111
+ class MutableAssetSymbols {
112
+ #symbols;
113
+ #locals;
114
+ get isCleared() {
115
+ return this.#symbols.size === 0;
116
+ }
117
+ constructor(inner) {
118
+ this.#symbols = new Map();
119
+ this.#locals = new Set();
120
+ for (const {
121
+ exported,
122
+ local,
123
+ loc
124
+ } of inner || []) {
125
+ this.set(exported, local, loc);
126
+ }
127
+ }
128
+ intoNapi() {
129
+ const results = [];
130
+ for (const [exportSymbol, {
131
+ local,
132
+ loc
133
+ }] of this.#symbols.entries()) {
134
+ results.push({
135
+ exported: exportSymbol,
136
+ local,
137
+ loc: loc ? {
138
+ filePath: loc.filePath,
139
+ start: {
140
+ line: loc.start.line,
141
+ column: loc.start.column
142
+ },
143
+ end: {
144
+ line: loc.end.line,
145
+ column: loc.end.column
146
+ }
147
+ } : undefined,
148
+ // TODO
149
+ isWeak: false,
150
+ isEsmExport: false,
151
+ selfReferenced: false
152
+ });
153
+ }
154
+ return results;
155
+ }
156
+ ensure() {
157
+ throw new Error('MutableAssetSymbols.ensure()');
158
+ }
159
+ set(exportSymbol, local, loc) {
160
+ this.#locals.add(local);
161
+ this.#symbols.set(exportSymbol, {
162
+ local,
163
+ loc,
164
+ meta: {}
165
+ });
166
+ }
167
+ get(exportSymbol) {
168
+ return this.#symbols.get(exportSymbol);
169
+ }
170
+ hasExportSymbol(exportSymbol) {
171
+ return this.#symbols.has(exportSymbol);
172
+ }
173
+ hasLocalSymbol(local) {
174
+ return this.#locals.has(local);
175
+ }
176
+ exportSymbols() {
177
+ return this.#symbols.keys();
178
+ }
179
+ delete(exportSymbol) {
180
+ let existing = this.#symbols.get(exportSymbol);
181
+ if (!existing) return;
182
+ this.#locals.delete(existing.local);
183
+ this.#symbols.delete(exportSymbol);
184
+ }
88
185
 
89
- // eslint-disable-next-line no-unused-vars
90
- delete() {}
186
+ /*:: @@iterator(): Iterator<[Symbol, AssetSymbol]> { return ({}: any); } */
187
+ // $FlowFixMe Flow can't do computed properties
188
+ [Symbol.iterator]() {
189
+ return this.#symbols.values();
190
+ }
91
191
  }
92
192
  exports.MutableAssetSymbols = MutableAssetSymbols;
@@ -22,6 +22,12 @@ class BitFlags {
22
22
  }
23
23
  return found;
24
24
  }
25
+ intoNullable(key) {
26
+ if (key === undefined || key === null) {
27
+ return undefined;
28
+ }
29
+ return this.into(key);
30
+ }
25
31
  intoArray(keys) {
26
32
  return keys.map(key => this.into(key));
27
33
  }
@@ -33,6 +39,12 @@ class BitFlags {
33
39
  }
34
40
  return found;
35
41
  }
42
+ fromNullable(key) {
43
+ if (key === undefined || key === null) {
44
+ return undefined;
45
+ }
46
+ return this.from(key);
47
+ }
36
48
  fromArray(keys) {
37
49
  return keys.map(key => this.from(key));
38
50
  }
@@ -3,28 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _assetCompat = require("./asset-compat");
7
- Object.keys(_assetCompat).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _assetCompat[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _assetCompat[key];
14
- }
15
- });
16
- });
17
- var _assetSymbols = require("./asset-symbols");
18
- Object.keys(_assetSymbols).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _assetSymbols[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _assetSymbols[key];
25
- }
26
- });
27
- });
28
6
  var _bitflags = require("./bitflags");
29
7
  Object.keys(_bitflags).forEach(function (key) {
30
8
  if (key === "default" || key === "__esModule") return;
@@ -68,4 +46,59 @@ Object.keys(_target).forEach(function (key) {
68
46
  return _target[key];
69
47
  }
70
48
  });
49
+ });
50
+ var _pluginConfig = require("./plugin-config");
51
+ Object.keys(_pluginConfig).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _pluginConfig[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _pluginConfig[key];
58
+ }
59
+ });
60
+ });
61
+ var _pluginTracer = require("./plugin-tracer");
62
+ Object.keys(_pluginTracer).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _pluginTracer[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _pluginTracer[key];
69
+ }
70
+ });
71
+ });
72
+ var _pluginLogger = require("./plugin-logger");
73
+ Object.keys(_pluginLogger).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _pluginLogger[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _pluginLogger[key];
80
+ }
81
+ });
82
+ });
83
+ var _pluginOptions = require("./plugin-options");
84
+ Object.keys(_pluginOptions).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _pluginOptions[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _pluginOptions[key];
91
+ }
92
+ });
93
+ });
94
+ var _mutableAsset = require("./mutable-asset");
95
+ Object.keys(_mutableAsset).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _mutableAsset[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _mutableAsset[key];
102
+ }
103
+ });
71
104
  });
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MutableAsset = void 0;
7
+ function _stream() {
8
+ const data = require("stream");
9
+ _stream = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ var _bitflags = require("./bitflags");
15
+ var _assetSymbols = require("./asset-symbols");
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ class MutableAsset {
19
+ #inner;
20
+ #ast;
21
+ #contents;
22
+ get astGenerator() {
23
+ throw new Error('get MutableAsset.astGenerator');
24
+ }
25
+ set astGenerator(value) {
26
+ throw new Error('set MutableAsset.astGenerator');
27
+ }
28
+ constructor(asset, fs, env) {
29
+ this.#inner = asset;
30
+ this.stats = asset.stats;
31
+ this.id = asset.id;
32
+ this.filePath = asset.filePath;
33
+ this.type;
34
+ this.symbols = new _assetSymbols.MutableAssetSymbols(asset.symbols);
35
+ this.stats = asset.stats;
36
+ this.id = asset.id;
37
+ this.filePath = asset.filePath;
38
+ this.type = asset.type;
39
+ this.query = new URLSearchParams(asset.query);
40
+ this.isSource = asset.isSource;
41
+ this.meta = asset.meta;
42
+ this.bundleBehavior = _bitflags.bundleBehaviorMap.fromNullable(asset.bundleBehavior);
43
+ this.isBundleSplittable = asset.isBundleSplittable;
44
+ this.sideEffects = asset.sideEffects;
45
+ this.uniqueKey = asset.uniqueKey;
46
+ this.pipeline = asset.pipeline;
47
+ this.#contents = Buffer.from(asset.code);
48
+ this.fs = fs;
49
+ this.env = env;
50
+ }
51
+
52
+ // eslint-disable-next-line require-await
53
+ async getAST() {
54
+ return this.#ast;
55
+ }
56
+ setAST(ast) {
57
+ this.#ast = ast;
58
+ }
59
+ isASTDirty() {
60
+ throw new Error('MutableAsset.isASTDirty()');
61
+ }
62
+
63
+ // eslint-disable-next-line require-await
64
+ async getCode() {
65
+ return this.#contents.toString();
66
+ }
67
+ setCode(code) {
68
+ this.#contents = Buffer.from(code);
69
+ }
70
+
71
+ // eslint-disable-next-line require-await
72
+ async getBuffer() {
73
+ return this.#contents;
74
+ }
75
+ setBuffer(buf) {
76
+ this.#contents = buf;
77
+ }
78
+ getStream() {
79
+ return _stream().Readable.from(this.#contents);
80
+ }
81
+ setStream(stream) {
82
+ const data = [];
83
+ stream.on('data', chunk => {
84
+ data.push(chunk);
85
+ });
86
+ stream.on('end', () => {
87
+ this.#contents = Buffer.concat(data);
88
+ });
89
+ stream.on('error', () => {
90
+ throw new Error('MutableAsset.setStream()');
91
+ });
92
+ }
93
+ getMap() {
94
+ throw new Error('MutableAsset.getMap');
95
+ }
96
+
97
+ // eslint-disable-next-line no-unused-vars
98
+ setMap() {
99
+ throw new Error('MutableAsset.setMap()');
100
+ }
101
+ getMapBuffer() {
102
+ throw new Error('MutableAsset.getMapBuffer');
103
+ }
104
+ getDependencies() {
105
+ throw new Error('MutableAsset.getDependencies');
106
+ }
107
+
108
+ // eslint-disable-next-line no-unused-vars
109
+ addDependency() {
110
+ throw new Error('MutableAsset.addDependency()');
111
+ }
112
+
113
+ // eslint-disable-next-line no-unused-vars
114
+ addURLDependency() {
115
+ throw new Error('MutableAsset.addURLDependency()');
116
+ }
117
+
118
+ // eslint-disable-next-line no-unused-vars
119
+ setEnvironment() {
120
+ throw new Error('MutableAsset.setEnvironment()');
121
+ }
122
+
123
+ // eslint-disable-next-line no-unused-vars
124
+ invalidateOnFileChange() {
125
+ throw new Error('MutableAsset.invalidateOnFileChange()');
126
+ }
127
+
128
+ // eslint-disable-next-line no-unused-vars
129
+ invalidateOnFileCreate() {
130
+ throw new Error('MutableAsset.invalidateOnFileCreate()');
131
+ }
132
+
133
+ // eslint-disable-next-line no-unused-vars
134
+ invalidateOnEnvChange() {
135
+ throw new Error('MutableAsset.invalidateOnEnvChange()');
136
+ }
137
+ invalidateOnStartup() {
138
+ throw new Error('MutableAsset.invalidateOnStartup()');
139
+ }
140
+ invalidateOnBuild() {
141
+ throw new Error('MutableAsset.invalidateOnBuild()');
142
+ }
143
+ }
144
+ exports.MutableAsset = MutableAsset;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PluginConfig = void 0;
7
+ class PluginConfig {
8
+ constructor({
9
+ env,
10
+ isSource,
11
+ searchPath
12
+ }) {
13
+ this.env = env;
14
+ this.isSource = isSource;
15
+ this.searchPath = searchPath;
16
+ }
17
+
18
+ // eslint-disable-next-line no-unused-vars
19
+ invalidateOnFileChange() {
20
+ throw new Error('PluginOptions.invalidateOnFileChange');
21
+ }
22
+
23
+ // eslint-disable-next-line no-unused-vars
24
+ invalidateOnFileCreate() {
25
+ throw new Error('PluginOptions.invalidateOnFileCreate');
26
+ }
27
+
28
+ // eslint-disable-next-line no-unused-vars
29
+ invalidateOnEnvChange() {
30
+ throw new Error('PluginOptions.invalidateOnEnvChange');
31
+ }
32
+ invalidateOnStartup() {
33
+ throw new Error('PluginOptions.invalidateOnStartup');
34
+ }
35
+ invalidateOnBuild() {
36
+ throw new Error('PluginOptions.invalidateOnBuild');
37
+ }
38
+
39
+ // eslint-disable-next-line no-unused-vars
40
+ addDevDependency() {
41
+ throw new Error('PluginOptions.addDevDependency');
42
+ }
43
+
44
+ // eslint-disable-next-line no-unused-vars
45
+ setCacheKey() {
46
+ throw new Error('PluginOptions.setCacheKey');
47
+ }
48
+ getConfig() {
49
+ throw new Error('PluginOptions.getConfig');
50
+ }
51
+ getConfigFrom() {
52
+ throw new Error('PluginOptions.getConfigFrom');
53
+ }
54
+ getPackage() {
55
+ throw new Error('PluginOptions.getPackage');
56
+ }
57
+ }
58
+ exports.PluginConfig = PluginConfig;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PluginLogger = void 0;
7
+ class PluginLogger {
8
+ verbose(diagnostic) {
9
+ // eslint-disable-next-line no-console
10
+ console.log(diagnostic);
11
+ }
12
+ info(diagnostic) {
13
+ // eslint-disable-next-line no-console
14
+ console.info(diagnostic);
15
+ }
16
+ log(diagnostic) {
17
+ // eslint-disable-next-line no-console
18
+ console.log(diagnostic);
19
+ }
20
+ warn(diagnostic) {
21
+ // eslint-disable-next-line no-console
22
+ console.warn(diagnostic);
23
+ }
24
+ error(input) {
25
+ // eslint-disable-next-line no-console
26
+ console.error(input);
27
+ }
28
+ }
29
+ exports.PluginLogger = PluginLogger;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PluginOptions = void 0;
7
+ class PluginOptions {
8
+ #options;
9
+ get env() {
10
+ if (!('env' in this.#options)) {
11
+ return process.env;
12
+ // throw new Error('PluginOptions.env');
13
+ }
14
+
15
+ return this.#options.env;
16
+ }
17
+ get projectRoot() {
18
+ if (!('projectRoot' in this.#options)) {
19
+ throw new Error('PluginOptions.projectRoot');
20
+ }
21
+ return this.#options.projectRoot;
22
+ }
23
+ get packageManager() {
24
+ if (!('packageManager' in this.#options)) {
25
+ throw new Error('PluginOptions.packageManager');
26
+ }
27
+ return this.#options.packageManager;
28
+ }
29
+ get mode() {
30
+ if (!('mode' in this.#options)) {
31
+ throw new Error('PluginOptions.mode');
32
+ }
33
+ return this.#options.mode;
34
+ }
35
+ get parcelVersion() {
36
+ if (!('parcelVersion' in this.#options)) {
37
+ return 'UNKNOWN VERSION';
38
+ // throw new Error('PluginOptions.parcelVersion');
39
+ }
40
+
41
+ return this.#options.parcelVersion;
42
+ }
43
+ get hmrOptions() {
44
+ if (!('hmrOptions' in this.#options)) {
45
+ throw new Error('PluginOptions.hmrOptions');
46
+ }
47
+ return this.#options.hmrOptions;
48
+ }
49
+ get serveOptions() {
50
+ if (!('serveOptions' in this.#options)) {
51
+ throw new Error('PluginOptions.serveOptions');
52
+ }
53
+ return this.#options.serveOptions;
54
+ }
55
+ get shouldBuildLazily() {
56
+ if (!('shouldBuildLazily' in this.#options)) {
57
+ throw new Error('PluginOptions.shouldBuildLazily');
58
+ }
59
+ return this.#options.shouldBuildLazily;
60
+ }
61
+ get shouldAutoInstall() {
62
+ if (!('shouldAutoInstall' in this.#options)) {
63
+ throw new Error('PluginOptions.shouldAutoInstall');
64
+ }
65
+ return this.#options.shouldAutoInstall;
66
+ }
67
+ get logLevel() {
68
+ if (!('logLevel' in this.#options)) {
69
+ throw new Error('PluginOptions.logLevel');
70
+ }
71
+ return this.#options.logLevel;
72
+ }
73
+ get cacheDir() {
74
+ if (!('cacheDir' in this.#options)) {
75
+ throw new Error('PluginOptions.cacheDir');
76
+ }
77
+ return this.#options.cacheDir;
78
+ }
79
+ get inputFS() {
80
+ if (!('inputFS' in this.#options)) {
81
+ throw new Error('PluginOptions.inputFS');
82
+ }
83
+ return this.#options.inputFS;
84
+ }
85
+ get outputFS() {
86
+ if (!('outputFS' in this.#options)) {
87
+ throw new Error('PluginOptions.outputFS');
88
+ }
89
+ return this.#options.outputFS;
90
+ }
91
+ get instanceId() {
92
+ if (!('instanceId' in this.#options)) {
93
+ throw new Error('PluginOptions.instanceId');
94
+ }
95
+ return this.#options.instanceId;
96
+ }
97
+ get detailedReport() {
98
+ if (!('detailedReport' in this.#options)) {
99
+ throw new Error('PluginOptions.detailedReport');
100
+ }
101
+ return this.#options.detailedReport;
102
+ }
103
+ get featureFlags() {
104
+ if (!('featureFlags' in this.#options)) {
105
+ throw new Error('PluginOptions.featureFlags');
106
+ }
107
+ return this.#options.featureFlags;
108
+ }
109
+ constructor(options) {
110
+ this.#options = options;
111
+ }
112
+ }
113
+ exports.PluginOptions = PluginOptions;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PluginTracer = void 0;
7
+ class PluginTracer {
8
+ createMeasurement() {
9
+ throw new Error('PluginTracer.createMeasurement');
10
+ }
11
+ }
12
+ exports.PluginTracer = PluginTracer;