@atlaspack/core 2.24.0 → 2.24.2-dev-ts-project-refs-d30e9754f.0

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +201 -0
  3. package/dist/AssetGraph.js +591 -0
  4. package/dist/Atlaspack.js +656 -0
  5. package/dist/AtlaspackConfig.js +324 -0
  6. package/dist/AtlaspackConfig.schema.js +108 -0
  7. package/dist/BundleGraph.js +1628 -0
  8. package/dist/CommittedAsset.js +142 -0
  9. package/dist/Dependency.js +125 -0
  10. package/dist/Environment.js +132 -0
  11. package/dist/EnvironmentManager.js +108 -0
  12. package/dist/IdentifierRegistry.js +38 -0
  13. package/dist/InternalConfig.js +37 -0
  14. package/dist/PackagerRunner.js +531 -0
  15. package/dist/ReporterRunner.js +151 -0
  16. package/dist/RequestTracker.js +1368 -0
  17. package/dist/SymbolPropagation.js +620 -0
  18. package/dist/TargetDescriptor.schema.js +143 -0
  19. package/dist/Transformation.js +487 -0
  20. package/dist/UncommittedAsset.js +315 -0
  21. package/dist/Validation.js +196 -0
  22. package/dist/applyRuntimes.js +305 -0
  23. package/dist/assetUtils.js +168 -0
  24. package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
  25. package/dist/atlaspack-v3/NapiWorkerPool.js +57 -0
  26. package/dist/atlaspack-v3/fs.js +52 -0
  27. package/dist/atlaspack-v3/index.js +25 -0
  28. package/dist/atlaspack-v3/jsCallable.js +16 -0
  29. package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
  30. package/dist/atlaspack-v3/worker/compat/bitflags.js +94 -0
  31. package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
  32. package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
  33. package/dist/atlaspack-v3/worker/compat/index.js +25 -0
  34. package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
  35. package/dist/atlaspack-v3/worker/compat/plugin-config.js +76 -0
  36. package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
  37. package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -0
  38. package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
  39. package/dist/atlaspack-v3/worker/compat/target.js +14 -0
  40. package/dist/atlaspack-v3/worker/worker.js +292 -0
  41. package/dist/constants.js +17 -0
  42. package/dist/dumpGraphToGraphViz.js +281 -0
  43. package/dist/index.js +62 -0
  44. package/dist/loadAtlaspackPlugin.js +128 -0
  45. package/dist/loadDotEnv.js +41 -0
  46. package/dist/projectPath.js +83 -0
  47. package/dist/public/Asset.js +279 -0
  48. package/dist/public/Bundle.js +224 -0
  49. package/dist/public/BundleGraph.js +359 -0
  50. package/dist/public/BundleGroup.js +53 -0
  51. package/dist/public/Config.js +286 -0
  52. package/dist/public/Dependency.js +138 -0
  53. package/dist/public/Environment.js +278 -0
  54. package/dist/public/MutableBundleGraph.js +277 -0
  55. package/dist/public/PluginOptions.js +80 -0
  56. package/dist/public/Symbols.js +248 -0
  57. package/dist/public/Target.js +69 -0
  58. package/dist/registerCoreWithSerializer.js +38 -0
  59. package/dist/requests/AssetGraphRequest.js +429 -0
  60. package/dist/requests/AssetGraphRequestRust.js +246 -0
  61. package/dist/requests/AssetRequest.js +130 -0
  62. package/dist/requests/AtlaspackBuildRequest.js +60 -0
  63. package/dist/requests/AtlaspackConfigRequest.js +490 -0
  64. package/dist/requests/BundleGraphRequest.js +441 -0
  65. package/dist/requests/ConfigRequest.js +222 -0
  66. package/dist/requests/DevDepRequest.js +204 -0
  67. package/dist/requests/EntryRequest.js +314 -0
  68. package/dist/requests/PackageRequest.js +65 -0
  69. package/dist/requests/PathRequest.js +349 -0
  70. package/dist/requests/TargetRequest.js +1310 -0
  71. package/dist/requests/ValidationRequest.js +49 -0
  72. package/dist/requests/WriteBundleRequest.js +254 -0
  73. package/dist/requests/WriteBundlesRequest.js +165 -0
  74. package/dist/requests/asset-graph-diff.js +126 -0
  75. package/dist/requests/asset-graph-dot.js +131 -0
  76. package/dist/resolveOptions.js +268 -0
  77. package/dist/rustWorkerThreadDylibHack.js +19 -0
  78. package/dist/serializerCore.browser.js +43 -0
  79. package/dist/summarizeRequest.js +39 -0
  80. package/dist/types.js +31 -0
  81. package/dist/utils.js +172 -0
  82. package/dist/worker.js +130 -0
  83. package/lib/AssetGraph.js +1 -0
  84. package/lib/atlaspack-v3/AtlaspackV3.js +7 -3
  85. package/lib/requests/AssetGraphRequestRust.js +1 -1
  86. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +1 -1
  87. package/package.json +22 -22
  88. package/src/AssetGraph.ts +1 -0
  89. package/src/atlaspack-v3/AtlaspackV3.ts +12 -3
  90. package/src/requests/AssetGraphRequestRust.ts +1 -1
  91. package/tsconfig.json +55 -2
  92. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.NapiWorkerPool = exports.AtlaspackV3 = exports.FileSystemV3 = void 0;
18
+ var fs_1 = require("./fs");
19
+ Object.defineProperty(exports, "FileSystemV3", { enumerable: true, get: function () { return fs_1.FileSystemV3; } });
20
+ var AtlaspackV3_1 = require("./AtlaspackV3");
21
+ Object.defineProperty(exports, "AtlaspackV3", { enumerable: true, get: function () { return AtlaspackV3_1.AtlaspackV3; } });
22
+ var NapiWorkerPool_1 = require("./NapiWorkerPool");
23
+ Object.defineProperty(exports, "NapiWorkerPool", { enumerable: true, get: function () { return NapiWorkerPool_1.NapiWorkerPool; } });
24
+ __exportStar(require("./AtlaspackV3"), exports);
25
+ __exportStar(require("./NapiWorkerPool"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsCallable = jsCallable;
4
+ function jsCallable(fn) {
5
+ return async (...args) => {
6
+ try {
7
+ // Promises and is safe to use on non-promises
8
+ return await fn(...args);
9
+ }
10
+ catch (error) {
11
+ // eslint-disable-next-line no-console
12
+ console.error(error);
13
+ throw error;
14
+ }
15
+ };
16
+ }
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var _MutableDependencySymbols_symbols, _MutableDependencySymbols_locals, _AssetSymbols_instances, _AssetSymbols_symbols, _AssetSymbols_locals, _AssetSymbols_set, _MutableAssetSymbols_symbols, _MutableAssetSymbols_locals;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MutableAssetSymbols = exports.AssetSymbols = exports.MutableDependencySymbols = void 0;
16
+ class MutableDependencySymbols {
17
+ get isCleared() {
18
+ return __classPrivateFieldGet(this, _MutableDependencySymbols_symbols, "f").size === 0;
19
+ }
20
+ constructor(inner) {
21
+ _MutableDependencySymbols_symbols.set(this, void 0);
22
+ _MutableDependencySymbols_locals.set(this, void 0);
23
+ __classPrivateFieldSet(this, _MutableDependencySymbols_symbols, new Map(), "f");
24
+ __classPrivateFieldSet(this, _MutableDependencySymbols_locals, new Set(), "f");
25
+ for (const { exported, local, loc, isWeak } of inner || []) {
26
+ this.set(exported, local, loc, isWeak);
27
+ }
28
+ }
29
+ ensure() {
30
+ throw new Error('MutableDependencySymbols.ensure()');
31
+ }
32
+ get(exportSymbol) {
33
+ return __classPrivateFieldGet(this, _MutableDependencySymbols_symbols, "f").get(exportSymbol);
34
+ }
35
+ hasExportSymbol(exportSymbol) {
36
+ return __classPrivateFieldGet(this, _MutableDependencySymbols_symbols, "f").has(exportSymbol);
37
+ }
38
+ hasLocalSymbol(local) {
39
+ return __classPrivateFieldGet(this, _MutableDependencySymbols_locals, "f").has(local);
40
+ }
41
+ exportSymbols() {
42
+ return __classPrivateFieldGet(this, _MutableDependencySymbols_symbols, "f").keys();
43
+ }
44
+ set(exportSymbol, local, loc, isWeak) {
45
+ __classPrivateFieldGet(this, _MutableDependencySymbols_locals, "f").add(local);
46
+ __classPrivateFieldGet(this, _MutableDependencySymbols_symbols, "f").set(exportSymbol, {
47
+ local,
48
+ loc,
49
+ meta: {},
50
+ isWeak: isWeak ?? false,
51
+ });
52
+ }
53
+ delete(exportSymbol) {
54
+ let existing = __classPrivateFieldGet(this, _MutableDependencySymbols_symbols, "f").get(exportSymbol);
55
+ if (!existing)
56
+ return;
57
+ __classPrivateFieldGet(this, _MutableDependencySymbols_locals, "f").delete(existing.local);
58
+ __classPrivateFieldGet(this, _MutableDependencySymbols_symbols, "f").delete(exportSymbol);
59
+ }
60
+ /*:: @@iterator(): Iterator<[Symbol, DependencyAssetSymbol]> { return ({}: any); } */
61
+ // @ts-expect-error TS2416
62
+ [(_MutableDependencySymbols_symbols = new WeakMap(), _MutableDependencySymbols_locals = new WeakMap(), Symbol.iterator)]() {
63
+ return __classPrivateFieldGet(this, _MutableDependencySymbols_symbols, "f").values();
64
+ }
65
+ }
66
+ exports.MutableDependencySymbols = MutableDependencySymbols;
67
+ class AssetSymbols {
68
+ get isCleared() {
69
+ return __classPrivateFieldGet(this, _AssetSymbols_symbols, "f").size === 0;
70
+ }
71
+ constructor(inner) {
72
+ _AssetSymbols_instances.add(this);
73
+ _AssetSymbols_symbols.set(this, void 0);
74
+ _AssetSymbols_locals.set(this, void 0);
75
+ __classPrivateFieldSet(this, _AssetSymbols_symbols, new Map(), "f");
76
+ __classPrivateFieldSet(this, _AssetSymbols_locals, new Set(), "f");
77
+ for (const { exported, local, loc } of inner || []) {
78
+ __classPrivateFieldGet(this, _AssetSymbols_instances, "m", _AssetSymbols_set).call(this, exported, local, loc);
79
+ }
80
+ }
81
+ get(exportSymbol) {
82
+ return __classPrivateFieldGet(this, _AssetSymbols_symbols, "f").get(exportSymbol);
83
+ }
84
+ hasExportSymbol(exportSymbol) {
85
+ return __classPrivateFieldGet(this, _AssetSymbols_symbols, "f").has(exportSymbol);
86
+ }
87
+ hasLocalSymbol(local) {
88
+ return __classPrivateFieldGet(this, _AssetSymbols_locals, "f").has(local);
89
+ }
90
+ exportSymbols() {
91
+ return __classPrivateFieldGet(this, _AssetSymbols_symbols, "f").keys();
92
+ }
93
+ intoNapi() {
94
+ return [];
95
+ }
96
+ /*:: @@iterator(): Iterator<[Symbol, AssetSymbol]> { return ({}: any); } */
97
+ // @ts-expect-error TS2416
98
+ [(_AssetSymbols_symbols = new WeakMap(), _AssetSymbols_locals = new WeakMap(), _AssetSymbols_instances = new WeakSet(), _AssetSymbols_set = function _AssetSymbols_set(exportSymbol, local, loc) {
99
+ __classPrivateFieldGet(this, _AssetSymbols_locals, "f").add(local);
100
+ __classPrivateFieldGet(this, _AssetSymbols_symbols, "f").set(exportSymbol, {
101
+ local,
102
+ loc,
103
+ meta: {},
104
+ });
105
+ }, Symbol.iterator)]() {
106
+ return __classPrivateFieldGet(this, _AssetSymbols_symbols, "f").values();
107
+ }
108
+ }
109
+ exports.AssetSymbols = AssetSymbols;
110
+ class MutableAssetSymbols {
111
+ get isCleared() {
112
+ return __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").size === 0;
113
+ }
114
+ constructor(inner) {
115
+ _MutableAssetSymbols_symbols.set(this, void 0);
116
+ _MutableAssetSymbols_locals.set(this, void 0);
117
+ __classPrivateFieldSet(this, _MutableAssetSymbols_symbols, new Map(), "f");
118
+ __classPrivateFieldSet(this, _MutableAssetSymbols_locals, new Set(), "f");
119
+ for (const { exported, loc, local, isEsmExport, selfReferenced, isStaticBindingSafe, } of inner || []) {
120
+ this.set(exported, local, loc, {
121
+ isEsm: isEsmExport,
122
+ isStaticBindingSafe,
123
+ selfReferenced,
124
+ });
125
+ }
126
+ }
127
+ intoNapi() {
128
+ const results = [];
129
+ for (const [exportSymbol, { local, loc, meta }] of __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").entries()) {
130
+ results.push({
131
+ exported: exportSymbol,
132
+ local,
133
+ loc: loc
134
+ ? {
135
+ filePath: loc.filePath,
136
+ start: {
137
+ line: loc.start.line,
138
+ column: loc.start.column,
139
+ },
140
+ end: {
141
+ line: loc.end.line,
142
+ column: loc.end.column,
143
+ },
144
+ }
145
+ : undefined,
146
+ isEsmExport: Boolean(meta?.isEsm),
147
+ isStaticBindingSafe: Boolean(meta?.isStaticBindingSafe),
148
+ isWeak: false,
149
+ selfReferenced: Boolean(meta?.selfReferenced),
150
+ });
151
+ }
152
+ return results;
153
+ }
154
+ ensure() {
155
+ throw new Error('MutableAssetSymbols.ensure()');
156
+ }
157
+ set(exportSymbol, local, loc, meta) {
158
+ __classPrivateFieldGet(this, _MutableAssetSymbols_locals, "f").add(local);
159
+ __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").set(exportSymbol, {
160
+ local,
161
+ loc,
162
+ meta,
163
+ });
164
+ }
165
+ get(exportSymbol) {
166
+ return __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").get(exportSymbol);
167
+ }
168
+ hasExportSymbol(exportSymbol) {
169
+ return __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").has(exportSymbol);
170
+ }
171
+ hasLocalSymbol(local) {
172
+ return __classPrivateFieldGet(this, _MutableAssetSymbols_locals, "f").has(local);
173
+ }
174
+ exportSymbols() {
175
+ return __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").keys();
176
+ }
177
+ delete(exportSymbol) {
178
+ let existing = __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").get(exportSymbol);
179
+ if (!existing)
180
+ return;
181
+ __classPrivateFieldGet(this, _MutableAssetSymbols_locals, "f").delete(existing.local);
182
+ __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").delete(exportSymbol);
183
+ }
184
+ /*:: @@iterator(): Iterator<[Symbol, AssetSymbol]> { return ({}: any); } */
185
+ // @ts-expect-error TS2416
186
+ [(_MutableAssetSymbols_symbols = new WeakMap(), _MutableAssetSymbols_locals = new WeakMap(), Symbol.iterator)]() {
187
+ return __classPrivateFieldGet(this, _MutableAssetSymbols_symbols, "f").values();
188
+ }
189
+ }
190
+ exports.MutableAssetSymbols = MutableAssetSymbols;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _BitFlags_kv, _BitFlags_vk;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.specifierTypeMap = exports.packageConditionsMap = exports.dependencyPriorityMap = exports.bundleBehaviorMap = exports.BitFlags = void 0;
16
+ /// BitFlags is used to map number/string types from napi types
17
+ class BitFlags {
18
+ // @ts-expect-error TS2344
19
+ constructor(source) {
20
+ // @ts-expect-error TS2344
21
+ _BitFlags_kv.set(this, void 0);
22
+ // @ts-expect-error TS2344
23
+ _BitFlags_vk.set(this, void 0);
24
+ __classPrivateFieldSet(this, _BitFlags_kv, source, "f");
25
+ __classPrivateFieldSet(this, _BitFlags_vk, Object.fromEntries(Object.entries(source).map((a) => a.reverse())), "f");
26
+ }
27
+ into(key) {
28
+ const found = __classPrivateFieldGet(this, _BitFlags_kv, "f")[key];
29
+ if (found === undefined) {
30
+ throw new Error(`Invalid BundleBehavior(${key})`);
31
+ }
32
+ return found;
33
+ }
34
+ intoNullable(key) {
35
+ if (key === undefined || key === null) {
36
+ return undefined;
37
+ }
38
+ return this.into(key);
39
+ }
40
+ intoArray(keys) {
41
+ return keys.map((key) => this.into(key));
42
+ }
43
+ from(key) {
44
+ const found = __classPrivateFieldGet(this, _BitFlags_vk, "f")[key];
45
+ if (found === undefined) {
46
+ throw new Error(`Invalid BundleBehavior(${key})`);
47
+ }
48
+ return found;
49
+ }
50
+ fromNullable(key) {
51
+ if (key === undefined || key === null) {
52
+ return undefined;
53
+ }
54
+ return this.from(key);
55
+ }
56
+ fromArray(keys) {
57
+ return keys.map((key) => this.from(key));
58
+ }
59
+ }
60
+ exports.BitFlags = BitFlags;
61
+ _BitFlags_kv = new WeakMap(), _BitFlags_vk = new WeakMap();
62
+ exports.bundleBehaviorMap = new BitFlags({
63
+ inline: 0,
64
+ isolated: 1,
65
+ inlineIsolated: 2,
66
+ });
67
+ exports.dependencyPriorityMap = new BitFlags({
68
+ sync: 0,
69
+ parallel: 1,
70
+ lazy: 2,
71
+ conditional: 3,
72
+ });
73
+ exports.packageConditionsMap = new BitFlags({
74
+ import: 0,
75
+ require: 1,
76
+ module: 2,
77
+ node: 3,
78
+ browser: 4,
79
+ worker: 5,
80
+ worklet: 6,
81
+ electron: 7,
82
+ development: 8,
83
+ production: 9,
84
+ types: 10,
85
+ default: 11,
86
+ style: 12,
87
+ sass: 13,
88
+ });
89
+ exports.specifierTypeMap = new BitFlags({
90
+ esm: 0,
91
+ commonjs: 1,
92
+ url: 2,
93
+ custom: 3,
94
+ });
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dependency = void 0;
4
+ const target_1 = require("./target");
5
+ const asset_symbols_1 = require("./asset-symbols");
6
+ const bitflags_1 = require("./bitflags");
7
+ class Dependency {
8
+ get id() {
9
+ throw new Error('Dependency.id');
10
+ }
11
+ constructor(inner, env) {
12
+ this.env = env;
13
+ this.meta = inner.meta || {};
14
+ this.target = undefined;
15
+ if (inner.target) {
16
+ this.target = new target_1.Target(inner.target, this.env);
17
+ }
18
+ if (!inner.bundleBehavior) {
19
+ this.bundleBehavior = undefined;
20
+ }
21
+ else {
22
+ this.bundleBehavior = bitflags_1.bundleBehaviorMap.from(inner.bundleBehavior);
23
+ }
24
+ this.bundleBehavior = undefined;
25
+ // @ts-expect-error TS2322
26
+ this.symbols = new asset_symbols_1.MutableDependencySymbols(inner.symbols || []);
27
+ this.specifier = inner.specifier;
28
+ this.specifierType = bitflags_1.specifierTypeMap.from(inner.specifierType);
29
+ this.priority = bitflags_1.dependencyPriorityMap.from(inner.priority);
30
+ this.needsStableName = inner.needsStableName;
31
+ this.isOptional = inner.isOptional;
32
+ this.isEntry = inner.isEntry;
33
+ this.loc = inner.loc;
34
+ this.packageConditions = bitflags_1.packageConditionsMap.fromArray(inner.packageConditions || []);
35
+ this.sourceAssetId = inner.sourceAssetId;
36
+ this.sourcePath = inner.sourcePath;
37
+ this.sourceAssetType = inner.sourceAssetType;
38
+ this.resolveFrom = inner.resolveFrom ?? inner.sourcePath;
39
+ this.range = inner.range;
40
+ this.pipeline = inner.pipeline;
41
+ }
42
+ }
43
+ exports.Dependency = Dependency;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Environment = void 0;
4
+ class Environment {
5
+ constructor(inner) {
6
+ // TODO
7
+ this.id = '';
8
+ this.includeNodeModules = inner.includeNodeModules;
9
+ this.context = inner.context;
10
+ this.engines = inner.engines;
11
+ this.outputFormat = inner.outputFormat;
12
+ this.sourceType = inner.sourceType;
13
+ this.isLibrary = inner.isLibrary;
14
+ this.shouldOptimize = inner.shouldOptimize;
15
+ this.shouldScopeHoist = inner.shouldScopeHoist;
16
+ this.sourceMap = inner.sourceMap;
17
+ this.loc = inner.loc;
18
+ this.unstableSingleFileOutput = false;
19
+ this.customEnv = inner.customEnv;
20
+ }
21
+ isBrowser() {
22
+ return (this.context === 'browser' ||
23
+ this.isWorker() ||
24
+ this.isTesseract() ||
25
+ this.isWorklet() ||
26
+ this.context === 'electron-renderer');
27
+ }
28
+ isNode() {
29
+ return this.context === 'node' || this.isElectron();
30
+ }
31
+ isElectron() {
32
+ return (this.context === 'electron-main' || this.context === 'electron-renderer');
33
+ }
34
+ isWorker() {
35
+ return this.context === 'web-worker' || this.context === 'service-worker';
36
+ }
37
+ isWorklet() {
38
+ return this.context === 'worklet';
39
+ }
40
+ isTesseract() {
41
+ return this.context === 'tesseract';
42
+ }
43
+ isIsolated() {
44
+ return this.isWorker() || this.isTesseract() || this.isWorklet();
45
+ }
46
+ // TODO
47
+ // eslint-disable-next-line no-unused-vars
48
+ matchesEngines(minVersions, defaultValue) {
49
+ return true;
50
+ }
51
+ // TODO
52
+ // eslint-disable-next-line no-unused-vars
53
+ supports(feature, defaultValue) {
54
+ return true;
55
+ }
56
+ }
57
+ exports.Environment = Environment;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./bitflags"), exports);
18
+ __exportStar(require("./dependency"), exports);
19
+ __exportStar(require("./environment"), exports);
20
+ __exportStar(require("./target"), exports);
21
+ __exportStar(require("./plugin-config"), exports);
22
+ __exportStar(require("./plugin-tracer"), exports);
23
+ __exportStar(require("./plugin-logger"), exports);
24
+ __exportStar(require("./plugin-options"), exports);
25
+ __exportStar(require("./mutable-asset"), exports);
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _MutableAsset_astDirty, _MutableAsset_ast, _MutableAsset_contents, _MutableAsset_inner, _MutableAsset_map, _MutableAsset_projectRoot, _MutableAsset_sourceMap;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.MutableAsset = void 0;
19
+ const source_map_1 = __importDefault(require("@parcel/source-map"));
20
+ const stream_1 = require("stream");
21
+ const bitflags_1 = require("./bitflags");
22
+ const asset_symbols_1 = require("./asset-symbols");
23
+ class MutableAsset {
24
+ get astGenerator() {
25
+ throw new Error('get MutableAsset.astGenerator');
26
+ }
27
+ // @ts-expect-error TS1051
28
+ set astGenerator(value) {
29
+ throw new Error('set MutableAsset.astGenerator');
30
+ }
31
+ constructor(asset, contents, env, fs, map, projectRoot) {
32
+ _MutableAsset_astDirty.set(this, void 0);
33
+ _MutableAsset_ast.set(this, void 0);
34
+ _MutableAsset_contents.set(this, void 0);
35
+ _MutableAsset_inner.set(this, void 0);
36
+ _MutableAsset_map.set(this, void 0);
37
+ _MutableAsset_projectRoot.set(this, void 0);
38
+ _MutableAsset_sourceMap.set(this, void 0);
39
+ this.bundleBehavior = bitflags_1.bundleBehaviorMap.fromNullable(asset.bundleBehavior);
40
+ this.env = env;
41
+ this.filePath = asset.filePath;
42
+ this.fs = fs;
43
+ this.id = asset.id;
44
+ this.isBundleSplittable = asset.isBundleSplittable;
45
+ this.isSource = asset.isSource;
46
+ this.meta = asset.meta;
47
+ this.pipeline = asset.pipeline;
48
+ this.query = new URLSearchParams(asset.query);
49
+ this.sideEffects = asset.sideEffects;
50
+ this.stats = asset.stats;
51
+ this.symbols = new asset_symbols_1.MutableAssetSymbols(asset.symbols);
52
+ this.type = asset.type;
53
+ this.uniqueKey = asset.uniqueKey;
54
+ __classPrivateFieldSet(this, _MutableAsset_astDirty, false, "f");
55
+ __classPrivateFieldSet(this, _MutableAsset_contents, contents, "f");
56
+ __classPrivateFieldSet(this, _MutableAsset_inner, asset, "f");
57
+ __classPrivateFieldSet(this, _MutableAsset_map, map, "f");
58
+ __classPrivateFieldSet(this, _MutableAsset_projectRoot, projectRoot, "f");
59
+ }
60
+ // eslint-disable-next-line require-await
61
+ async getAST() {
62
+ return __classPrivateFieldGet(this, _MutableAsset_ast, "f");
63
+ }
64
+ setAST(ast) {
65
+ __classPrivateFieldSet(this, _MutableAsset_astDirty, true, "f");
66
+ __classPrivateFieldSet(this, _MutableAsset_ast, ast, "f");
67
+ }
68
+ isASTDirty() {
69
+ return __classPrivateFieldGet(this, _MutableAsset_astDirty, "f");
70
+ }
71
+ // eslint-disable-next-line require-await
72
+ async getCode() {
73
+ return __classPrivateFieldGet(this, _MutableAsset_contents, "f").toString();
74
+ }
75
+ setCode(code) {
76
+ __classPrivateFieldSet(this, _MutableAsset_contents, Buffer.from(code), "f");
77
+ }
78
+ // eslint-disable-next-line require-await
79
+ async getBuffer() {
80
+ return __classPrivateFieldGet(this, _MutableAsset_contents, "f");
81
+ }
82
+ setBuffer(buf) {
83
+ __classPrivateFieldSet(this, _MutableAsset_contents, buf, "f");
84
+ }
85
+ getStream() {
86
+ return stream_1.Readable.from(__classPrivateFieldGet(this, _MutableAsset_contents, "f"));
87
+ }
88
+ setStream(stream) {
89
+ const data = [];
90
+ stream.on('data', (chunk) => {
91
+ data.push(chunk);
92
+ });
93
+ stream.on('end', () => {
94
+ __classPrivateFieldSet(this, _MutableAsset_contents, Buffer.concat(data), "f");
95
+ });
96
+ stream.on('error', () => {
97
+ throw new Error('MutableAsset.setStream()');
98
+ });
99
+ }
100
+ getMap() {
101
+ // Only create the source map if it is requested
102
+ if (!__classPrivateFieldGet(this, _MutableAsset_sourceMap, "f") && __classPrivateFieldGet(this, _MutableAsset_map, "f") && typeof __classPrivateFieldGet(this, _MutableAsset_map, "f") === 'string') {
103
+ let sourceMap = new source_map_1.default(__classPrivateFieldGet(this, _MutableAsset_projectRoot, "f"));
104
+ sourceMap.addVLQMap(JSON.parse(__classPrivateFieldGet(this, _MutableAsset_map, "f")));
105
+ __classPrivateFieldSet(this, _MutableAsset_sourceMap, sourceMap, "f");
106
+ }
107
+ return Promise.resolve(__classPrivateFieldGet(this, _MutableAsset_sourceMap, "f"));
108
+ }
109
+ // eslint-disable-next-line no-unused-vars
110
+ setMap(sourceMap) {
111
+ this.isMapDirty = true;
112
+ __classPrivateFieldSet(this, _MutableAsset_sourceMap, sourceMap, "f");
113
+ }
114
+ getMapBuffer() {
115
+ throw new Error('getMapBuffer() is considered an internal implementation detail, please use getMap() instead');
116
+ }
117
+ getDependencies() {
118
+ throw new Error('MutableAsset.getDependencies');
119
+ }
120
+ // eslint-disable-next-line no-unused-vars
121
+ addDependency(options) {
122
+ throw new Error('MutableAsset.addDependency()');
123
+ }
124
+ // eslint-disable-next-line no-unused-vars
125
+ addURLDependency(url, opts) {
126
+ throw new Error('MutableAsset.addURLDependency()');
127
+ }
128
+ // eslint-disable-next-line no-unused-vars
129
+ setEnvironment(opts) {
130
+ throw new Error('MutableAsset.setEnvironment()');
131
+ }
132
+ // eslint-disable-next-line no-unused-vars
133
+ invalidateOnFileChange(invalidation) {
134
+ // TODO: Forward invalidations to Rust
135
+ }
136
+ // eslint-disable-next-line no-unused-vars
137
+ invalidateOnFileCreate(invalidation) {
138
+ // TODO: Forward invalidations to Rust
139
+ }
140
+ // eslint-disable-next-line no-unused-vars
141
+ invalidateOnEnvChange(invalidation) {
142
+ // TODO: Forward invalidations to Rust
143
+ }
144
+ invalidateOnStartup() {
145
+ // TODO: Forward invalidations to Rust
146
+ }
147
+ invalidateOnBuild() {
148
+ // TODO: Forward invalidations to Rust
149
+ }
150
+ }
151
+ exports.MutableAsset = MutableAsset;
152
+ _MutableAsset_astDirty = new WeakMap(), _MutableAsset_ast = new WeakMap(), _MutableAsset_contents = new WeakMap(), _MutableAsset_inner = new WeakMap(), _MutableAsset_map = new WeakMap(), _MutableAsset_projectRoot = new WeakMap(), _MutableAsset_sourceMap = new WeakMap();