@expo/metro-config 58.0.11 → 58.0.13
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/build/ExpoMetroConfig.js +25 -61
- package/build/ExpoMetroConfig.js.map +1 -1
- package/build/serializer/chunking/Chunk.d.ts +45 -0
- package/build/serializer/chunking/Chunk.js +409 -0
- package/build/serializer/chunking/Chunk.js.map +1 -0
- package/build/serializer/chunking/chunkingStrategy.d.ts +40 -0
- package/build/serializer/chunking/chunkingStrategy.js +155 -0
- package/build/serializer/chunking/chunkingStrategy.js.map +1 -0
- package/build/serializer/chunking/computeBitSetChunks.d.ts +49 -0
- package/build/serializer/chunking/computeBitSetChunks.js +268 -0
- package/build/serializer/chunking/computeBitSetChunks.js.map +1 -0
- package/build/serializer/{computeChunkFilenames.d.ts → chunking/computeChunkFilenames.d.ts} +1 -1
- package/build/serializer/chunking/computeChunkFilenames.js.map +1 -0
- package/build/serializer/chunking/createGranularChunkingStrategy.d.ts +2 -0
- package/build/serializer/chunking/createGranularChunkingStrategy.js +282 -0
- package/build/serializer/chunking/createGranularChunkingStrategy.js.map +1 -0
- package/build/serializer/chunking/createLegacyChunkingStrategy.d.ts +2 -0
- package/build/serializer/chunking/createLegacyChunkingStrategy.js +167 -0
- package/build/serializer/chunking/createLegacyChunkingStrategy.js.map +1 -0
- package/build/serializer/chunking/findUnsupportedWorkerAsyncDependency.d.ts +7 -0
- package/build/serializer/chunking/findUnsupportedWorkerAsyncDependency.js +54 -0
- package/build/serializer/chunking/findUnsupportedWorkerAsyncDependency.js.map +1 -0
- package/build/serializer/exportPath.d.ts +1 -0
- package/build/serializer/exportPath.js +18 -3
- package/build/serializer/exportPath.js.map +1 -1
- package/build/serializer/fork/baseJSBundle.d.ts +5 -1
- package/build/serializer/fork/baseJSBundle.js +23 -1
- package/build/serializer/fork/baseJSBundle.js.map +1 -1
- package/build/serializer/fork/js.d.ts +6 -4
- package/build/serializer/fork/js.js +11 -1
- package/build/serializer/fork/js.js.map +1 -1
- package/build/serializer/fork/processModules.d.ts +4 -14
- package/build/serializer/fork/processModules.js +2 -12
- package/build/serializer/fork/processModules.js.map +1 -1
- package/build/serializer/serializeChunks.d.ts +4 -47
- package/build/serializer/serializeChunks.js +17 -655
- package/build/serializer/serializeChunks.js.map +1 -1
- package/build/serializer/serializerAssets.d.ts +13 -1
- package/build/serializer/withExpoSerializers.js +11 -1
- package/build/serializer/withExpoSerializers.js.map +1 -1
- package/build/utils/getPkgVersion.d.ts +1 -1
- package/build/utils/getPkgVersion.js +20 -14
- package/build/utils/getPkgVersion.js.map +1 -1
- package/package.json +7 -7
- package/build/serializer/computeChunkFilenames.js.map +0 -1
- /package/build/serializer/{computeChunkFilenames.js → chunking/computeChunkFilenames.js} +0 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
Chunk: null,
|
|
7
|
+
getBaseUrlOption: null,
|
|
8
|
+
getPlatformOption: null,
|
|
9
|
+
getSortedModules: null
|
|
10
|
+
});
|
|
11
|
+
function _export(target, all) {
|
|
12
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_export(exports, {
|
|
18
|
+
get Chunk () {
|
|
19
|
+
return Chunk;
|
|
20
|
+
},
|
|
21
|
+
get getBaseUrlOption () {
|
|
22
|
+
return getBaseUrlOption;
|
|
23
|
+
},
|
|
24
|
+
get getPlatformOption () {
|
|
25
|
+
return getPlatformOption;
|
|
26
|
+
},
|
|
27
|
+
get getSortedModules () {
|
|
28
|
+
return getSortedModules;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function _bundleToString() {
|
|
32
|
+
const data = /*#__PURE__*/ _interop_require_default(require("@expo/metro/metro/lib/bundleToString"));
|
|
33
|
+
_bundleToString = function() {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
function _assert() {
|
|
39
|
+
const data = /*#__PURE__*/ _interop_require_default(require("assert"));
|
|
40
|
+
_assert = function() {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
function _path() {
|
|
46
|
+
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
47
|
+
_path = function() {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
const _filePath = require("../../utils/filePath");
|
|
53
|
+
const _debugId = require("../debugId");
|
|
54
|
+
const _exportPath = require("../exportPath");
|
|
55
|
+
const _sourceMap = require("../sourceMap");
|
|
56
|
+
function _interop_require_default(obj) {
|
|
57
|
+
return obj && obj.__esModule ? obj : {
|
|
58
|
+
default: obj
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Lazy-loaded to avoid pulling in metro-source-map at startup
|
|
62
|
+
let _buildHermesBundleAsync;
|
|
63
|
+
function getBuildHermesBundleAsync() {
|
|
64
|
+
if (!_buildHermesBundleAsync) {
|
|
65
|
+
_buildHermesBundleAsync = require('../exportHermes').buildHermesBundleAsync;
|
|
66
|
+
}
|
|
67
|
+
return _buildHermesBundleAsync;
|
|
68
|
+
}
|
|
69
|
+
let _baseJSBundleWithDependencies;
|
|
70
|
+
function getBaseJSBundleWithDependencies() {
|
|
71
|
+
if (!_baseJSBundleWithDependencies) {
|
|
72
|
+
_baseJSBundleWithDependencies = require('../fork/baseJSBundle').baseJSBundleWithDependencies;
|
|
73
|
+
}
|
|
74
|
+
return _baseJSBundleWithDependencies;
|
|
75
|
+
}
|
|
76
|
+
let _getBaseUrlOption;
|
|
77
|
+
function getBaseUrlOption(...args) {
|
|
78
|
+
if (!_getBaseUrlOption) {
|
|
79
|
+
_getBaseUrlOption = require('../fork/baseJSBundle').getBaseUrlOption;
|
|
80
|
+
}
|
|
81
|
+
return _getBaseUrlOption(...args);
|
|
82
|
+
}
|
|
83
|
+
let _getPlatformOption;
|
|
84
|
+
function getPlatformOption(...args) {
|
|
85
|
+
if (!_getPlatformOption) {
|
|
86
|
+
_getPlatformOption = require('../fork/baseJSBundle').getPlatformOption;
|
|
87
|
+
}
|
|
88
|
+
return _getPlatformOption(...args);
|
|
89
|
+
}
|
|
90
|
+
class Chunk {
|
|
91
|
+
name;
|
|
92
|
+
entries;
|
|
93
|
+
graph;
|
|
94
|
+
options;
|
|
95
|
+
strategy;
|
|
96
|
+
isAsync;
|
|
97
|
+
isVendor;
|
|
98
|
+
isEntry;
|
|
99
|
+
deps = new Set();
|
|
100
|
+
preModules = new Set();
|
|
101
|
+
// Chunks that are required to be loaded synchronously before this chunk.
|
|
102
|
+
// These are included in the HTML as <script> tags.
|
|
103
|
+
requiredChunks = new Set();
|
|
104
|
+
/** Whether this chunk owns an isolated module registry and must retain all of its dependencies.
|
|
105
|
+
* @remarks
|
|
106
|
+
* When a chunk is sealed, its `deps` and `preModules` shouldn't be altered, and it doesn't qualify
|
|
107
|
+
* for bundle/chunk splitting. This is the case for web workers, which must form a "closed" and
|
|
108
|
+
* self-sufficient entry bundle.
|
|
109
|
+
*/ sealed = false;
|
|
110
|
+
constructor(name, entries, graph, options, strategy, isAsync = false, isVendor = false, isEntry = false){
|
|
111
|
+
this.name = name;
|
|
112
|
+
this.entries = entries;
|
|
113
|
+
this.graph = graph;
|
|
114
|
+
this.options = options;
|
|
115
|
+
this.strategy = strategy;
|
|
116
|
+
this.isAsync = isAsync;
|
|
117
|
+
this.isVendor = isVendor;
|
|
118
|
+
this.isEntry = isEntry;
|
|
119
|
+
this.deps = new Set(entries);
|
|
120
|
+
}
|
|
121
|
+
seal() {
|
|
122
|
+
this.sealed = true;
|
|
123
|
+
}
|
|
124
|
+
getPlatform() {
|
|
125
|
+
(0, _assert().default)(this.graph.transformOptions.platform, "platform is required to be in graph's transformOptions");
|
|
126
|
+
return this.graph.transformOptions.platform;
|
|
127
|
+
}
|
|
128
|
+
getFilename(src) {
|
|
129
|
+
return !this.options.serializerOptions?.exporting ? this.name : (0, _exportPath.getExportPathForDependencyWithOptions)(this.name, {
|
|
130
|
+
platform: this.getPlatform(),
|
|
131
|
+
src,
|
|
132
|
+
serverRoot: this.options.serverRoot
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
getStableChunkSource(serializerConfig) {
|
|
136
|
+
return this.options.dev ? '' : this.serializeToCodeWithTemplates(serializerConfig, {
|
|
137
|
+
// Disable source maps when creating a sha to reduce the number of possible changes that could
|
|
138
|
+
// influence the cache hit.
|
|
139
|
+
serializerOptions: {
|
|
140
|
+
includeSourceMaps: false
|
|
141
|
+
},
|
|
142
|
+
sourceMapUrl: undefined,
|
|
143
|
+
debugId: undefined
|
|
144
|
+
}).code;
|
|
145
|
+
}
|
|
146
|
+
serializeToCodeWithTemplates(serializerConfig, options = {}) {
|
|
147
|
+
const entryFile = this.name;
|
|
148
|
+
// TODO: Disable all debugId steps when a dev server is enabled. This is an export-only feature.
|
|
149
|
+
const preModules = [
|
|
150
|
+
...(options.preModules ?? this.preModules).values()
|
|
151
|
+
];
|
|
152
|
+
const dependencies = [
|
|
153
|
+
...this.deps
|
|
154
|
+
];
|
|
155
|
+
const jsSplitBundle = getBaseJSBundleWithDependencies()(entryFile, preModules, dependencies, {
|
|
156
|
+
...this.options,
|
|
157
|
+
runBeforeMainModule: serializerConfig?.getModulesRunBeforeMainModule?.(_path().default.relative(this.options.projectRoot, entryFile)) ?? [],
|
|
158
|
+
runModule: this.options.runModule && !this.isVendor && (this.isEntry || !this.isAsync),
|
|
159
|
+
modulesOnly: this.options.modulesOnly || preModules.length === 0,
|
|
160
|
+
platform: this.getPlatform(),
|
|
161
|
+
baseUrl: getBaseUrlOption(this.graph, this.options),
|
|
162
|
+
splitChunks: !!this.options.serializerOptions?.splitChunks,
|
|
163
|
+
skipWrapping: true,
|
|
164
|
+
computedAsyncModulePaths: null,
|
|
165
|
+
...this.strategy.getStableSerializationOptions(this),
|
|
166
|
+
...options
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
code: (0, _bundleToString().default)(jsSplitBundle).code,
|
|
170
|
+
paths: jsSplitBundle.paths
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
hasAbsolutePath(absolutePath) {
|
|
174
|
+
for (const dep of this.deps){
|
|
175
|
+
if (dep.path === absolutePath) {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
_asyncTargets;
|
|
182
|
+
getAsyncChunkTargets(chunksByPath) {
|
|
183
|
+
return this._asyncTargets ??= this.strategy.getAsyncChunkTargets(this, chunksByPath);
|
|
184
|
+
}
|
|
185
|
+
getAdjustedSourceMapUrl(filename) {
|
|
186
|
+
// Metro really only accounts for development, so we'll use the defaults here.
|
|
187
|
+
if (this.options.dev) {
|
|
188
|
+
return this.options.sourceMapUrl ?? null;
|
|
189
|
+
}
|
|
190
|
+
if (this.options.serializerOptions?.includeSourceMaps !== true) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
if (this.options.inlineSourceMap || !this.options.sourceMapUrl) {
|
|
194
|
+
return this.options.sourceMapUrl ?? null;
|
|
195
|
+
}
|
|
196
|
+
const platform = this.getPlatform();
|
|
197
|
+
const isAbsolute = platform !== 'web';
|
|
198
|
+
const baseUrl = getBaseUrlOption(this.graph, this.options);
|
|
199
|
+
const isAbsoluteBaseUrl = !!baseUrl?.match(/https?:\/\//);
|
|
200
|
+
const pathname = (isAbsoluteBaseUrl ? '' : baseUrl.replace(/\/+$/, '')) + '/' + filename.replace(/^\/+$/, '') + '.map';
|
|
201
|
+
let adjustedSourceMapUrl = this.options.sourceMapUrl;
|
|
202
|
+
// Metro has lots of issues...
|
|
203
|
+
if (this.options.sourceMapUrl.startsWith('//localhost')) {
|
|
204
|
+
adjustedSourceMapUrl = 'http:' + this.options.sourceMapUrl;
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const parsed = new URL(pathname, isAbsoluteBaseUrl ? baseUrl : adjustedSourceMapUrl);
|
|
208
|
+
if (isAbsoluteBaseUrl || isAbsolute) {
|
|
209
|
+
return parsed.href;
|
|
210
|
+
}
|
|
211
|
+
return parsed.pathname;
|
|
212
|
+
} catch (error) {
|
|
213
|
+
// NOTE: export:embed that don't use baseUrl will use file paths instead of URLs.
|
|
214
|
+
if (!this.options.dev && isAbsolute) {
|
|
215
|
+
return adjustedSourceMapUrl;
|
|
216
|
+
}
|
|
217
|
+
console.error(`Failed to link source maps because the source map URL "${this.options.sourceMapUrl}" is corrupt:`, error);
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
serializeToCode(serializerConfig, { debugId, chunksByPath, filenamesByChunk, filename, preModules }) {
|
|
222
|
+
return this.serializeToCodeWithTemplates(serializerConfig, {
|
|
223
|
+
skipWrapping: false,
|
|
224
|
+
sourceMapUrl: this.getAdjustedSourceMapUrl(filename) ?? undefined,
|
|
225
|
+
debugId,
|
|
226
|
+
preModules,
|
|
227
|
+
...this.strategy.getSerializationOptions(this, chunksByPath, filenamesByChunk)
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
boolishTransformOption(name) {
|
|
231
|
+
const value = this.graph.transformOptions?.customTransformOptions?.[name];
|
|
232
|
+
return value === true || value === 'true' || value === '1';
|
|
233
|
+
}
|
|
234
|
+
async serializeToAssetsAsync(serializerConfig, chunksByPath, filenamesByChunk, { includeSourceMaps, unstable_beforeAssetSerializationPlugins }) {
|
|
235
|
+
const outputFile = filenamesByChunk.get(this);
|
|
236
|
+
(0, _assert().default)(outputFile, 'Precomputed filename missing for chunk: ' + this.name);
|
|
237
|
+
// We already use a stable hash for the output filename, so we'll reuse that for the debugId.
|
|
238
|
+
const debugId = (0, _debugId.stringToUUID)(_path().default.basename(outputFile, _path().default.extname(outputFile)));
|
|
239
|
+
let finalPreModules = [
|
|
240
|
+
...this.preModules
|
|
241
|
+
];
|
|
242
|
+
if (unstable_beforeAssetSerializationPlugins) {
|
|
243
|
+
for (const plugin of unstable_beforeAssetSerializationPlugins){
|
|
244
|
+
finalPreModules = plugin({
|
|
245
|
+
graph: this.graph,
|
|
246
|
+
premodules: finalPreModules,
|
|
247
|
+
debugId
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const jsCode = this.serializeToCode(serializerConfig, {
|
|
252
|
+
chunksByPath,
|
|
253
|
+
filenamesByChunk,
|
|
254
|
+
filename: outputFile,
|
|
255
|
+
debugId,
|
|
256
|
+
preModules: new Set(finalPreModules)
|
|
257
|
+
});
|
|
258
|
+
const relativeEntry = _path().default.relative(this.options.projectRoot, this.name);
|
|
259
|
+
const { modulePaths, ...chunkMetadata } = this.strategy.getMetadata(this, filenamesByChunk);
|
|
260
|
+
const jsAsset = {
|
|
261
|
+
filename: outputFile,
|
|
262
|
+
originFilename: relativeEntry,
|
|
263
|
+
type: 'js',
|
|
264
|
+
metadata: {
|
|
265
|
+
...chunkMetadata,
|
|
266
|
+
isAsync: this.isAsync,
|
|
267
|
+
requires: [
|
|
268
|
+
...this.requiredChunks.values()
|
|
269
|
+
].map((chunk)=>{
|
|
270
|
+
const filename = filenamesByChunk.get(chunk);
|
|
271
|
+
(0, _assert().default)(filename, 'Precomputed filename missing for required chunk: ' + chunk.name);
|
|
272
|
+
return filename;
|
|
273
|
+
}),
|
|
274
|
+
// Provide a list of module paths that can be used for matching chunks to routes.
|
|
275
|
+
// TODO: Move HTML serializing closer to this code so we can reduce passing this much data around.
|
|
276
|
+
modulePaths,
|
|
277
|
+
paths: jsCode.paths,
|
|
278
|
+
expoDomComponentReferences: collectOutputReferences(this.deps, 'expoDomComponentReference'),
|
|
279
|
+
reactClientReferences: collectOutputReferences(this.deps, 'reactClientReference'),
|
|
280
|
+
reactServerReferences: collectOutputReferences(this.deps, 'reactServerReference'),
|
|
281
|
+
loaderReferences: collectOutputReferences(this.deps, 'loaderReference')
|
|
282
|
+
},
|
|
283
|
+
source: jsCode.code
|
|
284
|
+
};
|
|
285
|
+
const assets = [
|
|
286
|
+
jsAsset
|
|
287
|
+
];
|
|
288
|
+
// debugId is passed into `sourceMapString` so the bundler-map path
|
|
289
|
+
// emits it inline rather than a JSON.parse + JSON.stringify
|
|
290
|
+
// roundtrip; the Hermes branch below has to splice into a finished
|
|
291
|
+
// JSON string because `buildHermesBundleAsync` is opaque.
|
|
292
|
+
// NOTE: skipped for inline source maps since they don't need
|
|
293
|
+
// disambiguation. We only emit `debugId` (Sentry also reads
|
|
294
|
+
// `debug_id`, but bun doesn't).
|
|
295
|
+
if (// Only include the source map if the `options.sourceMapUrl` option is provided and we are exporting a static build.
|
|
296
|
+
includeSourceMaps && !this.options.inlineSourceMap && this.options.sourceMapUrl) {
|
|
297
|
+
const modules = [
|
|
298
|
+
...finalPreModules,
|
|
299
|
+
...getSortedModules([
|
|
300
|
+
...this.deps
|
|
301
|
+
], {
|
|
302
|
+
createModuleId: this.options.createModuleId
|
|
303
|
+
})
|
|
304
|
+
].map((module1)=>{
|
|
305
|
+
// TODO: Make this user-configurable.
|
|
306
|
+
// Make all paths relative to the server root to prevent the entire user filesystem from being exposed.
|
|
307
|
+
if (_path().default.isAbsolute(module1.path)) {
|
|
308
|
+
return {
|
|
309
|
+
...module1,
|
|
310
|
+
path: '/' + (0, _filePath.toPosixPath)(_path().default.relative(this.options.serverRoot ?? this.options.projectRoot, module1.path))
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
return module1;
|
|
314
|
+
});
|
|
315
|
+
// TODO: We may not need to set `debugId` on the bundler sourcemap when
|
|
316
|
+
// Hermes is enabled, since we ship a separate `.hbc.map` for that case.
|
|
317
|
+
const sourceMap = (0, _sourceMap.sourceMapString)(modules, {
|
|
318
|
+
excludeSource: false,
|
|
319
|
+
...this.options,
|
|
320
|
+
debugId
|
|
321
|
+
});
|
|
322
|
+
assets.push({
|
|
323
|
+
filename: this.options.dev ? jsAsset.filename + '.map' : outputFile + '.map',
|
|
324
|
+
originFilename: jsAsset.originFilename,
|
|
325
|
+
type: 'map',
|
|
326
|
+
metadata: {},
|
|
327
|
+
source: sourceMap
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
if (this.boolishTransformOption('bytecode') && this.isHermesEnabled()) {
|
|
331
|
+
const adjustedSource = jsAsset.source.replace(/^\/\/# (sourceMappingURL)=(.*)$/gm, (...props)=>{
|
|
332
|
+
if (props[1] === 'sourceMappingURL') {
|
|
333
|
+
const mapName = props[2].replace(/\.js\.map$/, '.hbc.map');
|
|
334
|
+
return `//# ${props[1]}=` + mapName;
|
|
335
|
+
}
|
|
336
|
+
return '';
|
|
337
|
+
});
|
|
338
|
+
// TODO: Generate hbc for each chunk
|
|
339
|
+
const hermesBundleOutput = await getBuildHermesBundleAsync()({
|
|
340
|
+
projectRoot: this.options.projectRoot,
|
|
341
|
+
filename: this.name,
|
|
342
|
+
code: adjustedSource,
|
|
343
|
+
map: assets[1] ? assets[1].source : null,
|
|
344
|
+
// TODO: Maybe allow prod + no minify.
|
|
345
|
+
minify: true
|
|
346
|
+
});
|
|
347
|
+
if (hermesBundleOutput.hbc) {
|
|
348
|
+
// TODO: Unclear if we should add multiple assets, link the assets, or mutate the first asset.
|
|
349
|
+
// jsAsset.metadata.hbc = hermesBundleOutput.hbc;
|
|
350
|
+
// @ts-expect-error: TODO
|
|
351
|
+
jsAsset.source = hermesBundleOutput.hbc;
|
|
352
|
+
jsAsset.filename = jsAsset.filename.replace(/\.js$/, '.hbc');
|
|
353
|
+
// Replace mappings with hbc
|
|
354
|
+
if (jsAsset.metadata.paths) {
|
|
355
|
+
jsAsset.metadata.paths = Object.fromEntries(Object.entries(jsAsset.metadata.paths).map(([key, value])=>[
|
|
356
|
+
key,
|
|
357
|
+
Object.fromEntries(Object.entries(value).map(([key, value])=>{
|
|
358
|
+
(0, _assert().default)(value == null || typeof value === 'string', 'Hermes async paths must remain scalar.');
|
|
359
|
+
return [
|
|
360
|
+
key,
|
|
361
|
+
value ? value.replace(/\.js$/, '.hbc') : value
|
|
362
|
+
];
|
|
363
|
+
}))
|
|
364
|
+
]));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (assets[1] && hermesBundleOutput.sourcemap) {
|
|
368
|
+
assets[1].source = debugId ? (0, _sourceMap.appendDebugIdToSourceMap)(hermesBundleOutput.sourcemap, debugId) : hermesBundleOutput.sourcemap;
|
|
369
|
+
assets[1].filename = assets[1].filename.replace(/\.js\.map$/, '.hbc.map');
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return assets;
|
|
373
|
+
}
|
|
374
|
+
supportsBytecode() {
|
|
375
|
+
return this.getPlatform() !== 'web';
|
|
376
|
+
}
|
|
377
|
+
isHermesEnabled() {
|
|
378
|
+
// TODO: Revisit.
|
|
379
|
+
// TODO: There could be an issue with having the serializer for export:embed output hermes since the native scripts will
|
|
380
|
+
// also create hermes bytecode. We may need to disable in one of the two places.
|
|
381
|
+
return !this.options.dev && this.supportsBytecode() && this.graph.transformOptions.customTransformOptions?.engine === 'hermes';
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function getSortedModules(modules, { createModuleId }) {
|
|
385
|
+
// Assign IDs to modules in a consistent order
|
|
386
|
+
for (const module1 of modules){
|
|
387
|
+
createModuleId(module1.path);
|
|
388
|
+
}
|
|
389
|
+
// Sort by IDs
|
|
390
|
+
return modules.sort((a, b)=>createModuleId(a.path) - createModuleId(b.path));
|
|
391
|
+
}
|
|
392
|
+
function collectOutputReferences(modules, key) {
|
|
393
|
+
return [
|
|
394
|
+
...new Set([
|
|
395
|
+
...modules
|
|
396
|
+
].map((module1)=>{
|
|
397
|
+
return module1.output.map((output)=>{
|
|
398
|
+
// TODO: This is a mess. This needs to be properly typed
|
|
399
|
+
const data = output.data;
|
|
400
|
+
if (key in data && typeof data[key] === 'string') {
|
|
401
|
+
return data[key];
|
|
402
|
+
}
|
|
403
|
+
return undefined;
|
|
404
|
+
});
|
|
405
|
+
}).flat())
|
|
406
|
+
].filter((value)=>typeof value === 'string');
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
//# sourceMappingURL=Chunk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["serializer/chunking/Chunk.ts"],"sourcesContent":[null],"names":["Chunk","getBaseUrlOption","getPlatformOption","getSortedModules","_buildHermesBundleAsync","getBuildHermesBundleAsync","require","buildHermesBundleAsync","_baseJSBundleWithDependencies","getBaseJSBundleWithDependencies","baseJSBundleWithDependencies","_getBaseUrlOption","args","_getPlatformOption","deps","Set","preModules","requiredChunks","sealed","name","entries","graph","options","strategy","isAsync","isVendor","isEntry","seal","getPlatform","assert","transformOptions","platform","getFilename","src","serializerOptions","exporting","getExportPathForDependencyWithOptions","serverRoot","getStableChunkSource","serializerConfig","dev","serializeToCodeWithTemplates","includeSourceMaps","sourceMapUrl","undefined","debugId","code","entryFile","values","dependencies","jsSplitBundle","runBeforeMainModule","getModulesRunBeforeMainModule","path","relative","projectRoot","runModule","modulesOnly","length","baseUrl","splitChunks","skipWrapping","computedAsyncModulePaths","getStableSerializationOptions","bundleToString","paths","hasAbsolutePath","absolutePath","dep","_asyncTargets","getAsyncChunkTargets","chunksByPath","getAdjustedSourceMapUrl","filename","inlineSourceMap","isAbsolute","isAbsoluteBaseUrl","match","pathname","replace","adjustedSourceMapUrl","startsWith","parsed","URL","href","error","console","serializeToCode","filenamesByChunk","getSerializationOptions","boolishTransformOption","value","customTransformOptions","serializeToAssetsAsync","unstable_beforeAssetSerializationPlugins","outputFile","get","stringToUUID","basename","extname","finalPreModules","plugin","premodules","jsCode","relativeEntry","modulePaths","chunkMetadata","getMetadata","jsAsset","originFilename","type","metadata","requires","map","chunk","expoDomComponentReferences","collectOutputReferences","reactClientReferences","reactServerReferences","loaderReferences","source","assets","modules","createModuleId","module","toPosixPath","sourceMap","sourceMapString","excludeSource","push","isHermesEnabled","adjustedSource","props","mapName","hermesBundleOutput","minify","hbc","Object","fromEntries","key","sourcemap","appendDebugIdToSourceMap","supportsBytecode","engine","sort","a","b","output","data","flat","filter"],"mappings":";;;;;;;;;;;;;;;;;QAuDaA;eAAAA;;QAnBGC;eAAAA;;QAUAC;eAAAA;;QAsYAC;eAAAA;;;;gEAlbW;;;;;;;gEACR;;;;;;;gEACF;;;;;;0BAEW;yBACC;4BACyB;2BAGI;;;;;;AAO1D,8DAA8D;AAC9D,IAAIC;AACJ,SAASC;IACP,IAAI,CAACD,yBAAyB;QAC5BA,0BAA0BE,QAAQ,mBAAmBC,sBAAsB;IAC7E;IACA,OAAOH;AACT;AAEA,IAAII;AACJ,SAASC;IACP,IAAI,CAACD,+BAA+B;QAClCA,gCAAgCF,QAAQ,wBAAwBI,4BAA4B;IAC9F;IACA,OAAOF;AACT;AAEA,IAAIG;AACG,SAASV,iBACd,GAAGW,IAAwE;IAE3E,IAAI,CAACD,mBAAmB;QACtBA,oBAAoBL,QAAQ,wBAAwBL,gBAAgB;IACtE;IACA,OAAOU,qBAAqBC;AAC9B;AAEA,IAAIC;AACG,SAASX,kBACd,GAAGU,IAAyE;IAE5E,IAAI,CAACC,oBAAoB;QACvBA,qBAAqBP,QAAQ,wBAAwBJ,iBAAiB;IACxE;IACA,OAAOW,sBAAsBD;AAC/B;AAEO,MAAMZ;;;;;;;;;IACJc,OAAoB,IAAIC,MAAM;IAC9BC,aAA0B,IAAID,MAAM;IAE3C,yEAAyE;IACzE,mDAAmD;IAC5CE,iBAA6B,IAAIF,MAAM;IAE9C;;;;;GAKC,GACD,AAAOG,SAAS,MAAM;IAEtB,YACE,AAAOC,IAAY,EACnB,AAAOC,OAAiC,EACxC,AAAOC,KAAiC,EACxC,AAAOC,OAA8B,EACrC,AAAiBC,QAAgC,EACjD,AAAOC,UAAmB,KAAK,EAC/B,AAAOC,WA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gFAAgF;QAChF,OACE,CAAC,IAAI,CAAC5G,OAAO,CAACkB,GAAG,IACjB,IAAI,CAACsG,gBAAgB,MACrB,IAAI,CAACzH,KAAK,CAACS,gBAAgB,CAAC8D,sBAAsB,EAAEmD,WAAW;IAEnE;AACF;AAEO,SAAS5I,iBACduH,OAA8B,EAC9B,EACEC,cAAc,EAGf;IAED,8CAA8C;IAC9C,KAAK,MAAMC,WAAUF,QAAS;QAC5BC,eAAeC,QAAOvE,IAAI;IAC5B;IACA,cAAc;IACd,OAAOqE,QAAQsB,IAAI,CACjB,CAACC,GAAgBC,IAAmBvB,eAAesB,EAAE5F,IAAI,IAAIsE,eAAeuB,EAAE7F,IAAI;AAEtF;AAEA,SAAS+D,wBAAwBM,OAAyB,EAAEiB,GAAW;IACrE,OAAO;WACF,IAAI5H,IACL;eAAI2G;SAAQ,CACTT,GAAG,CAAC,CAACW;YACJ,OAAOA,QAAOuB,MAAM,CAAClC,GAAG,CAAC,CAACkC;gBACxB,wDAAwD;gBACxD,MAAMC,OAAOD,OAAOC,IAAI;gBACxB,IAAIT,OAAOS,QAAQ,OAAOA,IAAI,CAACT,IAAI,KAAK,UAAU;oBAChD,OAAOS,IAAI,CAACT,IAAI;gBAClB;gBACA,OAAO/F;YACT;QACF,GACCyG,IAAI;KAEV,CAACC,MAAM,CAAC,CAAC3D,QAA2B,OAAOA,UAAU;AACxD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SerializerConfigT } from '@expo/metro/metro-config';
|
|
2
|
+
import type { Module, ReadOnlyGraph, ResolvedDependency } from '@expo/metro/metro/DeltaBundler/types';
|
|
3
|
+
import type { ExpoSerializerOptions } from '../fork/baseJSBundle';
|
|
4
|
+
import type { ChunkingStrategy, SerialAsset } from '../serializerAssets';
|
|
5
|
+
import type { SerializerConfigOptions } from '../withExpoSerializers';
|
|
6
|
+
import { Chunk } from './Chunk';
|
|
7
|
+
export type SerializeChunkOptions = {
|
|
8
|
+
includeSourceMaps: boolean;
|
|
9
|
+
splitChunks: boolean;
|
|
10
|
+
chunkingStrategy: ChunkingStrategy;
|
|
11
|
+
} & SerializerConfigOptions;
|
|
12
|
+
export type ChunkingContext = {
|
|
13
|
+
serializerConfig: Partial<SerializerConfigT>;
|
|
14
|
+
serializeChunkOptions: SerializeChunkOptions;
|
|
15
|
+
entryFile: string;
|
|
16
|
+
preModules: readonly Module[];
|
|
17
|
+
graph: ReadOnlyGraph;
|
|
18
|
+
options: ExpoSerializerOptions;
|
|
19
|
+
};
|
|
20
|
+
export type ChunkSerializationOptions = Partial<Parameters<typeof import('../fork/baseJSBundle').baseJSBundleWithDependencies>[3]>;
|
|
21
|
+
type ChunkStrategySerializationOptions = Pick<ChunkSerializationOptions, 'computedAsyncModulePaths' | 'includeAsyncPaths' | 'includeChunkCompletion' | 'unstable_getAsyncDependencyPath'>;
|
|
22
|
+
export type ChunkingImplementation = {
|
|
23
|
+
serializeAsync(): Promise<SerialAsset[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Chunks referenced by emitted async URLs, used to calculate filename hashes.
|
|
26
|
+
* Must match the targets used by getSerializationOptions.
|
|
27
|
+
*/
|
|
28
|
+
getAsyncChunkTargets(chunk: Chunk, chunksByPath: Map<string, Chunk>): Set<Chunk>;
|
|
29
|
+
/**
|
|
30
|
+
* Options used before dependency filenames are known, including for filename hashing.
|
|
31
|
+
* Final serialization also uses these as defaults.
|
|
32
|
+
*/
|
|
33
|
+
getStableSerializationOptions(chunk: Chunk): ChunkStrategySerializationOptions;
|
|
34
|
+
getSerializationOptions(chunk: Chunk, chunksByPath: Map<string, Chunk>, filenamesByChunk: Map<Chunk, string>): ChunkStrategySerializationOptions;
|
|
35
|
+
getMetadata(chunk: Chunk, filenamesByChunk: Map<Chunk, string>): Pick<SerialAsset['metadata'], 'chunkingStrategy' | 'entryPaths' | 'entryChunks' | 'modulePaths'>;
|
|
36
|
+
};
|
|
37
|
+
export declare function createChunkCollector({ graph, options, preModules: runtimePremodules }: ChunkingContext, strategy: ChunkingImplementation, chunks: Set<Chunk>, shouldTraverseDependency: (dependency: ResolvedDependency) => boolean): (entryPath: string, preModules: readonly Module[], isAsync?: boolean, isEntry?: boolean) => Chunk | undefined;
|
|
38
|
+
export declare function createRuntimeChunk(entryChunk: Chunk, chunks: Set<Chunk>, strategy: ChunkingImplementation, requiredBy?: Iterable<Chunk>): void;
|
|
39
|
+
export declare function serializeChunksAsync(chunks: Set<Chunk>, { serializerConfig, serializeChunkOptions, options }: ChunkingContext): Promise<SerialAsset[]>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
createChunkCollector: null,
|
|
7
|
+
createRuntimeChunk: null,
|
|
8
|
+
serializeChunksAsync: null
|
|
9
|
+
});
|
|
10
|
+
function _export(target, all) {
|
|
11
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
_export(exports, {
|
|
17
|
+
get createChunkCollector () {
|
|
18
|
+
return createChunkCollector;
|
|
19
|
+
},
|
|
20
|
+
get createRuntimeChunk () {
|
|
21
|
+
return createRuntimeChunk;
|
|
22
|
+
},
|
|
23
|
+
get serializeChunksAsync () {
|
|
24
|
+
return serializeChunksAsync;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
function _isResolvedDependency() {
|
|
28
|
+
const data = require("@expo/metro/metro/lib/isResolvedDependency");
|
|
29
|
+
_isResolvedDependency = function() {
|
|
30
|
+
return data;
|
|
31
|
+
};
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
function _assert() {
|
|
35
|
+
const data = /*#__PURE__*/ _interop_require_default(require("assert"));
|
|
36
|
+
_assert = function() {
|
|
37
|
+
return data;
|
|
38
|
+
};
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
const _Chunk = require("./Chunk");
|
|
42
|
+
const _computeChunkFilenames = require("./computeChunkFilenames");
|
|
43
|
+
function _interop_require_default(obj) {
|
|
44
|
+
return obj && obj.__esModule ? obj : {
|
|
45
|
+
default: obj
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function createChunkCollector({ graph, options, preModules: runtimePremodules }, strategy, chunks, shouldTraverseDependency) {
|
|
49
|
+
const chunksByEntryPath = new Map();
|
|
50
|
+
return function collectChunk(entryPath, preModules, isAsync = false, isEntry = false) {
|
|
51
|
+
const existingChunk = chunksByEntryPath.get(entryPath);
|
|
52
|
+
if (existingChunk) return existingChunk;
|
|
53
|
+
const entryModule = graph.dependencies.get(entryPath);
|
|
54
|
+
if (!entryModule) return undefined;
|
|
55
|
+
const entryChunk = new _Chunk.Chunk(entryPath, new Set([
|
|
56
|
+
entryModule
|
|
57
|
+
]), graph, options, strategy, isAsync, false, isEntry);
|
|
58
|
+
entryChunk.preModules = new Set(preModules);
|
|
59
|
+
// Register before walking dependencies so circular imports reuse this chunk.
|
|
60
|
+
chunksByEntryPath.set(entryPath, entryChunk);
|
|
61
|
+
chunks.add(entryChunk);
|
|
62
|
+
function includeModule(entryModule) {
|
|
63
|
+
const splitChunks = entryChunk.options.serializerOptions?.splitChunks !== false;
|
|
64
|
+
for (const dependency of entryModule.dependencies.values()){
|
|
65
|
+
const asyncType = dependency.data.data.asyncType;
|
|
66
|
+
const isWorker = asyncType === 'worker';
|
|
67
|
+
if (!(0, _isResolvedDependency().isResolvedDependency)(dependency) || !shouldTraverseDependency(dependency)) {
|
|
68
|
+
continue;
|
|
69
|
+
} else if (asyncType && // Workers require standalone bundles even when ordinary chunk splitting is disabled.
|
|
70
|
+
(isWorker || splitChunks)) {
|
|
71
|
+
if (isWorker && options.includeAsyncPaths) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const asyncChunk = collectChunk(dependency.absolutePath, isWorker ? runtimePremodules : [], true, isWorker);
|
|
75
|
+
// Workers must be self-sufficient chunks.
|
|
76
|
+
if (isWorker) {
|
|
77
|
+
(0, _assert().default)(asyncChunk, `Worker chunk not found for: ${dependency.absolutePath}`);
|
|
78
|
+
asyncChunk.seal();
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
const module1 = graph.dependencies.get(dependency.absolutePath);
|
|
82
|
+
if (module1) {
|
|
83
|
+
// Prevent circular dependencies from creating infinite loops.
|
|
84
|
+
if (!entryChunk.deps.has(module1)) {
|
|
85
|
+
entryChunk.deps.add(module1);
|
|
86
|
+
includeModule(module1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
includeModule(entryModule);
|
|
93
|
+
return entryChunk;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function createRuntimeChunk(entryChunk, chunks, strategy, requiredBy = chunks) {
|
|
97
|
+
const runtimeChunk = new _Chunk.Chunk('/__expo-metro-runtime.js', new Set(), entryChunk.graph, entryChunk.options, strategy, false, true);
|
|
98
|
+
// All premodules (including metro-runtime) should load first
|
|
99
|
+
for (const preModule of entryChunk.preModules){
|
|
100
|
+
runtimeChunk.preModules.add(preModule);
|
|
101
|
+
}
|
|
102
|
+
entryChunk.preModules = new Set();
|
|
103
|
+
for (const chunk of requiredBy){
|
|
104
|
+
chunk.requiredChunks.add(runtimeChunk);
|
|
105
|
+
}
|
|
106
|
+
chunks.add(runtimeChunk);
|
|
107
|
+
}
|
|
108
|
+
function makeChunkByPathLookupMap(chunks) {
|
|
109
|
+
const chunkByPath = new Map();
|
|
110
|
+
// First, we populate chunks with entry module paths
|
|
111
|
+
for (const chunk of chunks){
|
|
112
|
+
for (const entry of chunk.entries){
|
|
113
|
+
if (!chunkByPath.has(entry.path)) {
|
|
114
|
+
chunkByPath.set(entry.path, chunk);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// We then populate the chunks' module paths, excluding sealed chunks...
|
|
119
|
+
for (const chunk of chunks){
|
|
120
|
+
if (!chunk.sealed) {
|
|
121
|
+
for (const module1 of chunk.deps){
|
|
122
|
+
if (!chunkByPath.has(module1.path)) {
|
|
123
|
+
chunkByPath.set(module1.path, chunk);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// ...then populate with missing paths from sealed chunks.
|
|
129
|
+
// This gives precedence for modules from unsealed chunks after entry modules
|
|
130
|
+
for (const chunk of chunks){
|
|
131
|
+
if (chunk.sealed) {
|
|
132
|
+
for (const module1 of chunk.deps){
|
|
133
|
+
if (!chunkByPath.has(module1.path)) {
|
|
134
|
+
chunkByPath.set(module1.path, chunk);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return chunkByPath;
|
|
140
|
+
}
|
|
141
|
+
async function serializeChunksAsync(chunks, { serializerConfig, serializeChunkOptions, options }) {
|
|
142
|
+
const chunksByPath = makeChunkByPathLookupMap(chunks);
|
|
143
|
+
const filenamesByChunk = (0, _computeChunkFilenames.precomputeChunkFilenames)({
|
|
144
|
+
chunks,
|
|
145
|
+
chunksByPath,
|
|
146
|
+
serializerConfig,
|
|
147
|
+
recomputeChunkNames: !!options.serializerOptions?.exporting
|
|
148
|
+
});
|
|
149
|
+
const assets = await Promise.all([
|
|
150
|
+
...chunks
|
|
151
|
+
].map((chunk)=>chunk.serializeToAssetsAsync(serializerConfig, chunksByPath, filenamesByChunk, serializeChunkOptions)));
|
|
152
|
+
return assets.flat();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//# sourceMappingURL=chunkingStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["serializer/chunking/chunkingStrategy.ts"],"sourcesContent":[null],"names":["createChunkCollector","createRuntimeChunk","serializeChunksAsync","graph","options","preModules","runtimePremodules","strategy","chunks","shouldTraverseDependency","chunksByEntryPath","Map","collectChunk","entryPath","isAsync","isEntry","existingChunk","get","entryModule","dependencies","undefined","entryChunk","Chunk","Set","set","add","includeModule","splitChunks","serializerOptions","dependency","values","asyncType","data","isWorker","isResolvedDependency","includeAsyncPaths","asyncChunk","absolutePath","assert","seal","module","deps","has","requiredBy","runtimeChunk","preModule","chunk","requiredChunks","makeChunkByPathLookupMap","chunkByPath","entry","entries","path","sealed","serializerConfig","serializeChunkOptions","chunksByPath","filenamesByChunk","precomputeChunkFilenames","recomputeChunkNames","exporting","assets","Promise","all","map","serializeToAssetsAsync","flat"],"mappings":";;;;;;;;;;;;;;;;QAsEgBA;eAAAA;;QA+EAC;eAAAA;;QA8DMC;eAAAA;;;;yBA5Me;;;;;;;gEAClB;;;;;;uBAMG;uCACmB;;;;;;AAuDlC,SAASF,qBACd,EAAEG,KAAK,EAAEC,OAAO,EAAEC,YAAYC,iBAAiB,EAAmB,EAClEC,QAAgC,EAChCC,MAAkB,EAClBC,wBAAqE;IAErE,MAAMC,oBAAoB,IAAIC;IAC9B,OAAO,SAASC,aACdC,SAAiB,EACjBR,UAA6B,EAC7BS,UAAmB,KAAK,EACxBC,UAAmB,KAAK;QAExB,MAAMC,gBAAgBN,kBAAkBO,GAAG,CAACJ;QAC5C,IAAIG,eAAe,OAAOA;QAC1B,MAAME,cAAcf,MAAMgB,YAAY,CAACF,GAAG,CAACJ;QAC3C,IAAI,CAACK,aAAa,OAAOE;QAEzB,MAAMC,aAAa,IAAIC,YAAK,CAC1BT,WACA,IAAIU,IAAI;YAACL;SAAY,GACrBf,OACAC,SACAG,UACAO,SACA,OACAC;QAGFM,WAAWhB,UAAU,GAAG,IAAIkB,IAAIlB;QAChC,6EAA6E;QAC7EK,kBAAkBc,GAAG,CAACX,WAAWQ;QACjCb,OAAOiB,GAAG,CAACJ;QAEX,SAASK,cAAcR,WAAgC;YACrD,MAAMS,cAAcN,WAAWjB,OAAO,CAACwB,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