@expo/cli 54.1.0-canary-20251031-b135dff → 55.0.0-canary-20251118-8f7ee64

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 (36) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/api/rest/cache/ResponseCache.js +3 -1
  3. package/build/src/api/rest/cache/ResponseCache.js.map +1 -1
  4. package/build/src/export/exportStaticAsync.js +30 -2
  5. package/build/src/export/exportStaticAsync.js.map +1 -1
  6. package/build/src/export/saveAssets.js +10 -0
  7. package/build/src/export/saveAssets.js.map +1 -1
  8. package/build/src/start/platforms/android/AndroidDeviceManager.js +2 -7
  9. package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
  10. package/build/src/start/platforms/android/adb.js +0 -6
  11. package/build/src/start/platforms/android/adb.js.map +1 -1
  12. package/build/src/start/server/metro/MetroBundlerDevServer.js +41 -36
  13. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  14. package/build/src/start/server/metro/createServerRouteMiddleware.js +7 -29
  15. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  16. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +3 -1
  17. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
  18. package/build/src/start/server/metro/errors/FailedToResolveNativeOnlyModuleError.js +17 -0
  19. package/build/src/start/server/metro/errors/FailedToResolveNativeOnlyModuleError.js.map +1 -0
  20. package/build/src/start/server/metro/instantiateMetro.js +14 -10
  21. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  22. package/build/src/start/server/metro/resolveLoader.js +65 -0
  23. package/build/src/start/server/metro/resolveLoader.js.map +1 -0
  24. package/build/src/start/server/metro/withMetroMultiPlatform.js +6 -24
  25. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  26. package/build/src/utils/env.js +0 -3
  27. package/build/src/utils/env.js.map +1 -1
  28. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  29. package/build/src/utils/telemetry/utils/context.js +1 -1
  30. package/package.json +20 -22
  31. package/build/src/start/server/metro/createExpoMetroResolver.js +0 -265
  32. package/build/src/start/server/metro/createExpoMetroResolver.js.map +0 -1
  33. package/build/src/start/server/metro/createJResolver.js +0 -201
  34. package/build/src/start/server/metro/createJResolver.js.map +0 -1
  35. package/build/src/start/server/metro/formatFileCandidates.js +0 -84
  36. package/build/src/start/server/metro/formatFileCandidates.js.map +0 -1
@@ -1,265 +0,0 @@
1
- /**
2
- * Copyright © 2023 650 Industries.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */ "use strict";
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- function _export(target, all) {
11
- for(var name in all)Object.defineProperty(target, name, {
12
- enumerable: true,
13
- get: all[name]
14
- });
15
- }
16
- _export(exports, {
17
- FailedToResolvePathError: function() {
18
- return FailedToResolvePathError;
19
- },
20
- createFastResolver: function() {
21
- return createFastResolver;
22
- }
23
- });
24
- function _fs() {
25
- const data = /*#__PURE__*/ _interop_require_default(require("fs"));
26
- _fs = function() {
27
- return data;
28
- };
29
- return data;
30
- }
31
- function _path() {
32
- const data = /*#__PURE__*/ _interop_require_default(require("path"));
33
- _path = function() {
34
- return data;
35
- };
36
- return data;
37
- }
38
- const _createJResolver = /*#__PURE__*/ _interop_require_default(require("./createJResolver"));
39
- const _externals = require("./externals");
40
- const _formatFileCandidates = require("./formatFileCandidates");
41
- const _metroOptions = require("../middleware/metroOptions");
42
- function _interop_require_default(obj) {
43
- return obj && obj.__esModule ? obj : {
44
- default: obj
45
- };
46
- }
47
- class FailedToResolvePathError extends Error {
48
- constructor(...args){
49
- super(...args), // Added to ensure the error is matched by our tooling.
50
- // TODO: Test that this matches `isFailedToResolvePathError`
51
- this.candidates = {};
52
- }
53
- }
54
- class ShimModuleError extends Error {
55
- }
56
- const debug = require('debug')('expo:metro:resolve');
57
- const realpathFS = process.platform !== 'win32' && _fs().default.realpathSync && typeof _fs().default.realpathSync.native === 'function' ? _fs().default.realpathSync.native : _fs().default.realpathSync;
58
- function realpathSync(x) {
59
- try {
60
- return realpathFS(x);
61
- } catch (realpathErr) {
62
- if (realpathErr.code !== 'ENOENT') {
63
- throw realpathErr;
64
- }
65
- }
66
- return x;
67
- }
68
- function createFastResolver({ preserveSymlinks, blockList }) {
69
- debug('Creating with settings:', {
70
- preserveSymlinks,
71
- blockList
72
- });
73
- const cachedExtensions = new Map();
74
- function getAdjustedExtensions({ metroSourceExtensions, platform, isNative }) {
75
- const key = JSON.stringify({
76
- metroSourceExtensions,
77
- platform,
78
- isNative
79
- });
80
- if (cachedExtensions.has(key)) {
81
- return cachedExtensions.get(key);
82
- }
83
- let output = metroSourceExtensions;
84
- if (platform) {
85
- const nextOutput = [];
86
- output.forEach((ext)=>{
87
- nextOutput.push(`${platform}.${ext}`);
88
- if (isNative) {
89
- nextOutput.push(`native.${ext}`);
90
- }
91
- nextOutput.push(ext);
92
- });
93
- output = nextOutput;
94
- }
95
- output = Array.from(new Set(output));
96
- // resolve expects these to start with a dot.
97
- output = output.map((ext)=>`.${ext}`);
98
- cachedExtensions.set(key, output);
99
- return output;
100
- }
101
- function fastResolve(context, moduleName, platform) {
102
- var _context_customResolverOptions;
103
- const environment = (_context_customResolverOptions = context.customResolverOptions) == null ? void 0 : _context_customResolverOptions.environment;
104
- const isServer = (0, _metroOptions.isServerEnvironment)(environment);
105
- const extensions = getAdjustedExtensions({
106
- metroSourceExtensions: context.sourceExts,
107
- platform,
108
- isNative: context.preferNativePlatform
109
- });
110
- let fp;
111
- const conditions = context.unstable_enablePackageExports ? [
112
- ...new Set([
113
- 'default',
114
- context.isESMImport === true ? 'import' : 'require',
115
- ...context.unstable_conditionNames,
116
- ...platform != null ? context.unstable_conditionsByPlatform[platform] ?? [] : []
117
- ])
118
- ] : [];
119
- // NOTE(cedric): metro@0.81.0 ships with `fileSystemLookup`, while `metro@0.80.12` ships as unstable
120
- const fileSystemLookup = 'unstable_fileSystemLookup' in context ? context.unstable_fileSystemLookup : context.fileSystemLookup;
121
- if (!fileSystemLookup) {
122
- throw new Error('Metro API fileSystemLookup is required for fast resolver');
123
- }
124
- try {
125
- fp = (0, _createJResolver.default)(moduleName, {
126
- blockList,
127
- enablePackageExports: context.unstable_enablePackageExports,
128
- basedir: _path().default.dirname(context.originModulePath),
129
- paths: context.nodeModulesPaths.length ? context.nodeModulesPaths : undefined,
130
- extensions,
131
- conditions,
132
- realpathSync (file) {
133
- let metroRealPath = null;
134
- const res = fileSystemLookup(file);
135
- if (res == null ? void 0 : res.exists) {
136
- metroRealPath = res.realPath;
137
- }
138
- if (metroRealPath == null && preserveSymlinks) {
139
- return realpathSync(file);
140
- }
141
- return metroRealPath ?? file;
142
- },
143
- isDirectory (file) {
144
- const res = fileSystemLookup(file);
145
- return res.exists && res.type === 'd';
146
- },
147
- isFile (file) {
148
- const res = fileSystemLookup(file);
149
- return res.exists && res.type === 'f';
150
- },
151
- pathExists (file) {
152
- return fileSystemLookup(file).exists;
153
- },
154
- packageFilter (pkg) {
155
- // set the pkg.main to the first available field in context.mainFields
156
- for (const field of context.mainFields){
157
- if (pkg[field] && // object-inspect uses browser: {} in package.json
158
- typeof pkg[field] === 'string') {
159
- return {
160
- ...pkg,
161
- main: pkg[field]
162
- };
163
- }
164
- }
165
- return pkg;
166
- },
167
- // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and
168
- // the app doesn't finish without it.
169
- preserveSymlinks,
170
- readPackageSync (readFileSync, pkgFile) {
171
- return context.getPackage(pkgFile) ?? JSON.parse(_fs().default.readFileSync(pkgFile, 'utf8'));
172
- },
173
- includeCoreModules: isServer,
174
- pathFilter: // Disable `browser` field for server environments.
175
- isServer ? undefined : (pkg, _resolvedPath, relativePathIn)=>{
176
- let relativePath = relativePathIn;
177
- if (relativePath[0] !== '.') {
178
- relativePath = `./${relativePath}`;
179
- }
180
- const replacements = pkg.browser;
181
- if (replacements === undefined) {
182
- return '';
183
- }
184
- // TODO: Probably use a better extension matching system here.
185
- // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`
186
- const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];
187
- if (mappedPath === false) {
188
- throw new ShimModuleError();
189
- }
190
- return mappedPath;
191
- }
192
- });
193
- } catch (error) {
194
- if (error instanceof ShimModuleError) {
195
- return {
196
- type: 'empty'
197
- };
198
- }
199
- if ('code' in error && error.code === 'MODULE_NOT_FOUND') {
200
- if ((0, _externals.isNodeExternal)(moduleName)) {
201
- // In this case, mock the file to use an empty module.
202
- return {
203
- type: 'empty'
204
- };
205
- }
206
- debug({
207
- moduleName,
208
- platform,
209
- conditions,
210
- isServer,
211
- preserveSymlinks
212
- }, context);
213
- throw new FailedToResolvePathError('The module could not be resolved because no file or module matched the pattern:\n' + ` ${(0, _formatFileCandidates.formatFileCandidates)({
214
- type: 'sourceFile',
215
- filePathPrefix: moduleName,
216
- candidateExts: extensions
217
- }, true)}\n\nFrom:\n ${context.originModulePath}\n`);
218
- }
219
- throw error;
220
- }
221
- if (context.sourceExts.some((ext)=>fp.endsWith(ext))) {
222
- return {
223
- type: 'sourceFile',
224
- filePath: fp
225
- };
226
- }
227
- if ((0, _externals.isNodeExternal)(fp)) {
228
- if (isServer) {
229
- return {
230
- type: 'sourceFile',
231
- filePath: fp
232
- };
233
- }
234
- // NOTE: This shouldn't happen, the module should throw.
235
- // Mock non-server built-in modules to empty.
236
- return {
237
- type: 'empty'
238
- };
239
- }
240
- // NOTE: platform extensions may not be supported on assets.
241
- if (platform === 'web') {
242
- // Skip multi-resolution on web/server bundles. Only consideration here is that
243
- // we may still need it in case the only image is a multi-resolution image.
244
- return {
245
- type: 'assetFiles',
246
- filePaths: [
247
- fp
248
- ]
249
- };
250
- }
251
- const dirPath = _path().default.dirname(fp);
252
- const extension = _path().default.extname(fp);
253
- const basename = _path().default.basename(fp, extension);
254
- return {
255
- type: 'assetFiles',
256
- // Support multi-resolution asset extensions...
257
- filePaths: context.resolveAsset(dirPath, basename, extension) ?? [
258
- fp
259
- ]
260
- };
261
- }
262
- return fastResolve;
263
- }
264
-
265
- //# sourceMappingURL=createExpoMetroResolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/createExpoMetroResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport type { Resolution, ResolutionContext } from '@expo/metro/metro-resolver';\nimport fs from 'fs';\nimport path from 'path';\n\nimport jestResolver from './createJResolver';\nimport { isNodeExternal } from './externals';\nimport { formatFileCandidates } from './formatFileCandidates';\nimport { isServerEnvironment } from '../middleware/metroOptions';\n\nexport class FailedToResolvePathError extends Error {\n // Added to ensure the error is matched by our tooling.\n // TODO: Test that this matches `isFailedToResolvePathError`\n candidates = {};\n}\n\nclass ShimModuleError extends Error {}\n\nconst debug = require('debug')('expo:metro:resolve') as typeof console.log;\n\nconst realpathFS =\n process.platform !== 'win32' && fs.realpathSync && typeof fs.realpathSync.native === 'function'\n ? fs.realpathSync.native\n : fs.realpathSync;\n\nfunction realpathSync(x: string) {\n try {\n return realpathFS(x);\n } catch (realpathErr: any) {\n if (realpathErr.code !== 'ENOENT') {\n throw realpathErr;\n }\n }\n return x;\n}\n\nexport function createFastResolver({\n preserveSymlinks,\n blockList,\n}: {\n preserveSymlinks: boolean;\n blockList: RegExp[];\n}) {\n debug('Creating with settings:', { preserveSymlinks, blockList });\n const cachedExtensions: Map<string, readonly string[]> = new Map();\n\n function getAdjustedExtensions({\n metroSourceExtensions,\n platform,\n isNative,\n }: {\n metroSourceExtensions: readonly string[];\n platform: string | null;\n isNative: boolean;\n }): readonly string[] {\n const key = JSON.stringify({ metroSourceExtensions, platform, isNative });\n if (cachedExtensions.has(key)) {\n return cachedExtensions.get(key)!;\n }\n\n let output = metroSourceExtensions;\n if (platform) {\n const nextOutput: string[] = [];\n\n output.forEach((ext) => {\n nextOutput.push(`${platform}.${ext}`);\n if (isNative) {\n nextOutput.push(`native.${ext}`);\n }\n nextOutput.push(ext);\n });\n\n output = nextOutput;\n }\n\n output = Array.from(new Set<string>(output));\n\n // resolve expects these to start with a dot.\n output = output.map((ext) => `.${ext}`);\n\n cachedExtensions.set(key, output);\n\n return output;\n }\n\n function fastResolve(\n context: Pick<\n ResolutionContext,\n | 'unstable_enablePackageExports'\n | 'customResolverOptions'\n | 'sourceExts'\n | 'preferNativePlatform'\n | 'originModulePath'\n | 'getPackage'\n | 'nodeModulesPaths'\n | 'mainFields'\n | 'resolveAsset'\n | 'unstable_conditionNames'\n | 'unstable_conditionsByPlatform'\n | 'fileSystemLookup'\n | 'isESMImport'\n >,\n moduleName: string,\n platform: string | null\n ): Resolution {\n const environment = context.customResolverOptions?.environment;\n const isServer = isServerEnvironment(environment);\n\n const extensions = getAdjustedExtensions({\n metroSourceExtensions: context.sourceExts,\n platform,\n isNative: context.preferNativePlatform,\n }) as string[];\n\n let fp: string;\n\n const conditions = context.unstable_enablePackageExports\n ? [\n ...new Set([\n 'default',\n context.isESMImport === true ? 'import' : 'require',\n ...context.unstable_conditionNames,\n ...(platform != null ? (context.unstable_conditionsByPlatform[platform] ?? []) : []),\n ]),\n ]\n : [];\n\n // NOTE(cedric): metro@0.81.0 ships with `fileSystemLookup`, while `metro@0.80.12` ships as unstable\n const fileSystemLookup = (\n 'unstable_fileSystemLookup' in context\n ? context.unstable_fileSystemLookup\n : context.fileSystemLookup\n ) as ResolutionContext['fileSystemLookup'] | undefined;\n\n if (!fileSystemLookup) {\n throw new Error('Metro API fileSystemLookup is required for fast resolver');\n }\n\n try {\n fp = jestResolver(moduleName, {\n blockList,\n enablePackageExports: context.unstable_enablePackageExports,\n basedir: path.dirname(context.originModulePath),\n paths: context.nodeModulesPaths.length ? (context.nodeModulesPaths as string[]) : undefined,\n extensions,\n conditions,\n realpathSync(file: string): string {\n let metroRealPath: string | null = null;\n\n const res = fileSystemLookup(file);\n if (res?.exists) {\n metroRealPath = res.realPath;\n }\n\n if (metroRealPath == null && preserveSymlinks) {\n return realpathSync(file);\n }\n return metroRealPath ?? file;\n },\n isDirectory(file: string): boolean {\n const res = fileSystemLookup(file);\n return res.exists && res.type === 'd';\n },\n isFile(file: string): boolean {\n const res = fileSystemLookup(file);\n return res.exists && res.type === 'f';\n },\n pathExists(file: string): boolean {\n return fileSystemLookup(file).exists;\n },\n packageFilter(pkg) {\n // set the pkg.main to the first available field in context.mainFields\n for (const field of context.mainFields) {\n if (\n pkg[field] &&\n // object-inspect uses browser: {} in package.json\n typeof pkg[field] === 'string'\n ) {\n return {\n ...pkg,\n main: pkg[field],\n };\n }\n }\n return pkg;\n },\n // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and\n // the app doesn't finish without it.\n preserveSymlinks,\n readPackageSync(readFileSync, pkgFile) {\n return context.getPackage(pkgFile) ?? JSON.parse(fs.readFileSync(pkgFile, 'utf8'));\n },\n includeCoreModules: isServer,\n\n pathFilter:\n // Disable `browser` field for server environments.\n isServer\n ? undefined\n : // Enable `browser` field support\n (pkg: any, _resolvedPath: string, relativePathIn: string): string => {\n let relativePath = relativePathIn;\n if (relativePath[0] !== '.') {\n relativePath = `./${relativePath}`;\n }\n\n const replacements = pkg.browser;\n if (replacements === undefined) {\n return '';\n }\n\n // TODO: Probably use a better extension matching system here.\n // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`\n const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];\n if (mappedPath === false) {\n throw new ShimModuleError();\n }\n return mappedPath;\n },\n });\n } catch (error: any) {\n if (error instanceof ShimModuleError) {\n return {\n type: 'empty',\n };\n }\n\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n if (isNodeExternal(moduleName)) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n\n debug({ moduleName, platform, conditions, isServer, preserveSymlinks }, context);\n\n throw new FailedToResolvePathError(\n 'The module could not be resolved because no file or module matched the pattern:\\n' +\n ` ${formatFileCandidates(\n {\n type: 'sourceFile',\n filePathPrefix: moduleName,\n candidateExts: extensions,\n },\n true\n )}\\n\\nFrom:\\n ${context.originModulePath}\\n`\n );\n }\n throw error;\n }\n\n if (context.sourceExts.some((ext) => fp.endsWith(ext))) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n\n if (isNodeExternal(fp)) {\n if (isServer) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n }\n // NOTE: This shouldn't happen, the module should throw.\n // Mock non-server built-in modules to empty.\n return {\n type: 'empty',\n };\n }\n\n // NOTE: platform extensions may not be supported on assets.\n\n if (platform === 'web') {\n // Skip multi-resolution on web/server bundles. Only consideration here is that\n // we may still need it in case the only image is a multi-resolution image.\n return {\n type: 'assetFiles',\n filePaths: [fp],\n };\n }\n\n const dirPath = path.dirname(fp);\n const extension = path.extname(fp);\n const basename = path.basename(fp, extension);\n return {\n type: 'assetFiles',\n // Support multi-resolution asset extensions...\n filePaths: context.resolveAsset(dirPath, basename, extension) ?? [fp],\n };\n }\n\n return fastResolve;\n}\n"],"names":["FailedToResolvePathError","createFastResolver","Error","candidates","ShimModuleError","debug","require","realpathFS","process","platform","fs","realpathSync","native","x","realpathErr","code","preserveSymlinks","blockList","cachedExtensions","Map","getAdjustedExtensions","metroSourceExtensions","isNative","key","JSON","stringify","has","get","output","nextOutput","forEach","ext","push","Array","from","Set","map","set","fastResolve","context","moduleName","environment","customResolverOptions","isServer","isServerEnvironment","extensions","sourceExts","preferNativePlatform","fp","conditions","unstable_enablePackageExports","isESMImport","unstable_conditionNames","unstable_conditionsByPlatform","fileSystemLookup","unstable_fileSystemLookup","jestResolver","enablePackageExports","basedir","path","dirname","originModulePath","paths","nodeModulesPaths","length","undefined","file","metroRealPath","res","exists","realPath","isDirectory","type","isFile","pathExists","packageFilter","pkg","field","mainFields","main","readPackageSync","readFileSync","pkgFile","getPackage","parse","includeCoreModules","pathFilter","_resolvedPath","relativePathIn","relativePath","replacements","browser","mappedPath","error","isNodeExternal","formatFileCandidates","filePathPrefix","candidateExts","some","endsWith","filePath","filePaths","dirPath","extension","extname","basename","resolveAsset"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAUYA,wBAAwB;eAAxBA;;IA0BGC,kBAAkB;eAAlBA;;;;gEAlCD;;;;;;;gEACE;;;;;;wEAEQ;2BACM;sCACM;8BACD;;;;;;AAE7B,MAAMD,iCAAiCE;;QAAvC,gBACL,uDAAuD;QACvD,4DAA4D;aAC5DC,aAAa,CAAC;;AAChB;AAEA,MAAMC,wBAAwBF;AAAO;AAErC,MAAMG,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,aACJC,QAAQC,QAAQ,KAAK,WAAWC,aAAE,CAACC,YAAY,IAAI,OAAOD,aAAE,CAACC,YAAY,CAACC,MAAM,KAAK,aACjFF,aAAE,CAACC,YAAY,CAACC,MAAM,GACtBF,aAAE,CAACC,YAAY;AAErB,SAASA,aAAaE,CAAS;IAC7B,IAAI;QACF,OAAON,WAAWM;IACpB,EAAE,OAAOC,aAAkB;QACzB,IAAIA,YAAYC,IAAI,KAAK,UAAU;YACjC,MAAMD;QACR;IACF;IACA,OAAOD;AACT;AAEO,SAASZ,mBAAmB,EACjCe,gBAAgB,EAChBC,SAAS,EAIV;IACCZ,MAAM,2BAA2B;QAAEW;QAAkBC;IAAU;IAC/D,MAAMC,mBAAmD,IAAIC;IAE7D,SAASC,sBAAsB,EAC7BC,qBAAqB,EACrBZ,QAAQ,EACRa,QAAQ,EAKT;QACC,MAAMC,MAAMC,KAAKC,SAAS,CAAC;YAAEJ;YAAuBZ;YAAUa;QAAS;QACvE,IAAIJ,iBAAiBQ,GAAG,CAACH,MAAM;YAC7B,OAAOL,iBAAiBS,GAAG,CAACJ;QAC9B;QAEA,IAAIK,SAASP;QACb,IAAIZ,UAAU;YACZ,MAAMoB,aAAuB,EAAE;YAE/BD,OAAOE,OAAO,CAAC,CAACC;gBACdF,WAAW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a,OAAO;YACtB,+EAA+E;YAC/E,2EAA2E;YAC3E,OAAO;gBACL+D,MAAM;gBACN6B,WAAW;oBAACrD;iBAAG;YACjB;QACF;QAEA,MAAMsD,UAAU3C,eAAI,CAACC,OAAO,CAACZ;QAC7B,MAAMuD,YAAY5C,eAAI,CAAC6C,OAAO,CAACxD;QAC/B,MAAMyD,WAAW9C,eAAI,CAAC8C,QAAQ,CAACzD,IAAIuD;QACnC,OAAO;YACL/B,MAAM;YACN,+CAA+C;YAC/C6B,WAAW9D,QAAQmE,YAAY,CAACJ,SAASG,UAAUF,cAAc;gBAACvD;aAAG;QACvE;IACF;IAEA,OAAOV;AACT"}
@@ -1,201 +0,0 @@
1
- /**
2
- * Copyright © 2023 650 Industries.
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- * Fork of the jest resolver but with additional settings for Metro and pnp removed.
9
- * https://github.com/jestjs/jest/blob/d1a2ed7fea4bdc19836274cd810c8360e3ab62f3/packages/jest-resolve/src/defaultResolver.ts#L1
10
- */ "use strict";
11
- Object.defineProperty(exports, "__esModule", {
12
- value: true
13
- });
14
- Object.defineProperty(exports, "default", {
15
- enumerable: true,
16
- get: function() {
17
- return _default;
18
- }
19
- });
20
- function _assert() {
21
- const data = /*#__PURE__*/ _interop_require_default(require("assert"));
22
- _assert = function() {
23
- return data;
24
- };
25
- return data;
26
- }
27
- function _path() {
28
- const data = require("path");
29
- _path = function() {
30
- return data;
31
- };
32
- return data;
33
- }
34
- function _resolve() {
35
- const data = require("resolve");
36
- _resolve = function() {
37
- return data;
38
- };
39
- return data;
40
- }
41
- function _resolveexports() {
42
- const data = /*#__PURE__*/ _interop_require_wildcard(require("resolve.exports"));
43
- _resolveexports = function() {
44
- return data;
45
- };
46
- return data;
47
- }
48
- function _interop_require_default(obj) {
49
- return obj && obj.__esModule ? obj : {
50
- default: obj
51
- };
52
- }
53
- function _getRequireWildcardCache(nodeInterop) {
54
- if (typeof WeakMap !== "function") return null;
55
- var cacheBabelInterop = new WeakMap();
56
- var cacheNodeInterop = new WeakMap();
57
- return (_getRequireWildcardCache = function(nodeInterop) {
58
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
59
- })(nodeInterop);
60
- }
61
- function _interop_require_wildcard(obj, nodeInterop) {
62
- if (!nodeInterop && obj && obj.__esModule) {
63
- return obj;
64
- }
65
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
66
- return {
67
- default: obj
68
- };
69
- }
70
- var cache = _getRequireWildcardCache(nodeInterop);
71
- if (cache && cache.has(obj)) {
72
- return cache.get(obj);
73
- }
74
- var newObj = {
75
- __proto__: null
76
- };
77
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
78
- for(var key in obj){
79
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
80
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
81
- if (desc && (desc.get || desc.set)) {
82
- Object.defineProperty(newObj, key, desc);
83
- } else {
84
- newObj[key] = obj[key];
85
- }
86
- }
87
- }
88
- newObj.default = obj;
89
- if (cache) {
90
- cache.set(obj, newObj);
91
- }
92
- return newObj;
93
- }
94
- const defaultResolver = (path, { enablePackageExports, blockList = [], ...options })=>{
95
- // @ts-expect-error
96
- const resolveOptions = {
97
- ...options,
98
- preserveSymlinks: options.preserveSymlinks,
99
- defaultResolver
100
- };
101
- // resolveSync dereferences symlinks to ensure we don't create a separate
102
- // module instance depending on how it was referenced.
103
- const result = (0, _resolve().sync)(enablePackageExports ? getPathInModule(path, resolveOptions) : path, {
104
- ...resolveOptions,
105
- preserveSymlinks: !options.preserveSymlinks
106
- });
107
- return result;
108
- };
109
- const _default = defaultResolver;
110
- /*
111
- * helper functions
112
- */ function getPathInModule(path, options) {
113
- if (shouldIgnoreRequestForExports(path)) {
114
- return path;
115
- }
116
- const segments = path.split('/');
117
- let moduleName = segments.shift();
118
- if (!moduleName) {
119
- return path;
120
- }
121
- if (moduleName.startsWith('@')) {
122
- moduleName = `${moduleName}/${segments.shift()}`;
123
- }
124
- // self-reference
125
- const closestPackageJson = findClosestPackageJson(options.basedir, options);
126
- if (closestPackageJson) {
127
- const pkg = options.readPackageSync(options.readFileSync, closestPackageJson);
128
- (0, _assert().default)(pkg, 'package.json should be read by `readPackageSync`');
129
- // Added support for the package.json "imports" field (#-prefixed paths)
130
- if (path.startsWith('#')) {
131
- const resolved = _resolveexports().imports(pkg, path, createResolveOptions(options.conditions));
132
- if (resolved) {
133
- // TODO: Should we attempt to resolve every path in the array?
134
- return (0, _path().resolve)((0, _path().dirname)(closestPackageJson), resolved[0]);
135
- }
136
- // NOTE: resolve.imports would have thrown by this point.
137
- return path;
138
- }
139
- if (pkg.name === moduleName) {
140
- const resolved = _resolveexports().exports(pkg, segments.join('/') || '.', createResolveOptions(options.conditions));
141
- if (resolved) {
142
- return (0, _path().resolve)((0, _path().dirname)(closestPackageJson), resolved[0]);
143
- }
144
- if (pkg.exports) {
145
- throw new Error("`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Report an issue: https://github.com/expo/expo/issues");
146
- }
147
- }
148
- }
149
- let packageJsonPath = '';
150
- try {
151
- packageJsonPath = (0, _resolve().sync)(`${moduleName}/package.json`, options);
152
- } catch {
153
- // ignore if package.json cannot be found
154
- }
155
- if (!packageJsonPath) {
156
- return path;
157
- }
158
- const pkg = options.readPackageSync(options.readFileSync, packageJsonPath);
159
- (0, _assert().default)(pkg, 'package.json should be read by `readPackageSync`');
160
- const resolved = _resolveexports().exports(pkg, segments.join('/') || '.', createResolveOptions(options.conditions));
161
- if (resolved) {
162
- return (0, _path().resolve)((0, _path().dirname)(packageJsonPath), resolved[0]);
163
- }
164
- if (pkg.exports) {
165
- throw new Error("`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Report an issue: https://github.com/expo/expo/issues");
166
- }
167
- return path;
168
- }
169
- function createResolveOptions(conditions) {
170
- return conditions ? {
171
- conditions,
172
- unsafe: true
173
- } : {
174
- browser: false,
175
- require: true
176
- };
177
- }
178
- // if it's a relative import or an absolute path, imports/exports are ignored
179
- const shouldIgnoreRequestForExports = (path)=>path.startsWith('.') || (0, _path().isAbsolute)(path);
180
- // adapted from
181
- // https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js
182
- function findClosestPackageJson(start, options) {
183
- let dir = (0, _path().resolve)('.', start);
184
- if (!options.isDirectory(dir)) {
185
- dir = (0, _path().dirname)(dir);
186
- }
187
- while(true){
188
- const pkgJsonFile = (0, _path().resolve)(dir, './package.json');
189
- const hasPackageJson = options.pathExists(pkgJsonFile);
190
- if (hasPackageJson) {
191
- return pkgJsonFile;
192
- }
193
- const prevDir = dir;
194
- dir = (0, _path().dirname)(dir);
195
- if (prevDir === dir) {
196
- return undefined;
197
- }
198
- }
199
- }
200
-
201
- //# sourceMappingURL=createJResolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/createJResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Fork of the jest resolver but with additional settings for Metro and pnp removed.\n * https://github.com/jestjs/jest/blob/d1a2ed7fea4bdc19836274cd810c8360e3ab62f3/packages/jest-resolve/src/defaultResolver.ts#L1\n */\nimport type { JSONObject as PackageJSON } from '@expo/json-file';\nimport type { CustomResolutionContext } from '@expo/metro/metro-resolver';\nimport assert from 'assert';\nimport { dirname, isAbsolute, resolve as pathResolve } from 'path';\nimport { sync as resolveSync, SyncOpts as UpstreamResolveOptions } from 'resolve';\nimport * as resolve from 'resolve.exports';\n\n/**\n * Allows transforming parsed `package.json` contents.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param file - Path to `package.json` file.\n * @param dir - Directory that contains the `package.json`.\n *\n * @returns Transformed `package.json` contents.\n */\ntype PackageFilter = (pkg: PackageJSON, file: string, dir: string) => PackageJSON;\n\n/**\n * Allows transforming a path within a package.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param path - Path being resolved.\n * @param relativePath - Path relative from the `package.json` location.\n *\n * @returns Relative path that will be joined from the `package.json` location.\n */\ntype PathFilter = (pkg: PackageJSON, path: string, relativePath: string) => string;\n\n// TODO(@kitten): This probably has overlap with an @expo/metro type\ntype ResolverOptions = {\n /** Directory to begin resolving from. */\n basedir: string;\n /** List of export conditions. */\n conditions?: string[];\n /** Instance of default resolver. */\n defaultResolver: typeof defaultResolver;\n /** List of file extensions to search in order. */\n extensions?: string[];\n /**\n * List of directory names to be looked up for modules recursively.\n *\n * @defaultValue\n * The default is `['node_modules']`.\n */\n moduleDirectory?: string[];\n /**\n * List of `require.paths` to use if nothing is found in `node_modules`.\n *\n * @defaultValue\n * The default is `undefined`.\n */\n paths?: string[];\n /** Allows transforming parsed `package.json` contents. */\n packageFilter?: PackageFilter;\n /** Allows transforms a path within a package. */\n pathFilter?: PathFilter;\n /** Current root directory. */\n rootDir?: string;\n\n enablePackageExports?: boolean;\n\n blockList: RegExp[];\n\n getPackageForModule: CustomResolutionContext['getPackageForModule'];\n} & Pick<\n UpstreamResolveOptions,\n | 'readPackageSync'\n | 'realpathSync'\n | 'moduleDirectory'\n | 'extensions'\n | 'preserveSymlinks'\n | 'includeCoreModules'\n>;\n\ntype UpstreamResolveOptionsWithConditions = UpstreamResolveOptions &\n ResolverOptions & {\n pathExists: (file: string) => boolean;\n };\n\nconst defaultResolver = (\n path: string,\n {\n enablePackageExports,\n blockList = [],\n ...options\n }: Omit<ResolverOptions, 'defaultResolver' | 'getPackageForModule'> & {\n isDirectory: (file: string) => boolean;\n isFile: (file: string) => boolean;\n pathExists: (file: string) => boolean;\n }\n): string => {\n // @ts-expect-error\n const resolveOptions: UpstreamResolveOptionsWithConditions = {\n ...options,\n preserveSymlinks: options.preserveSymlinks,\n defaultResolver,\n };\n\n // resolveSync dereferences symlinks to ensure we don't create a separate\n // module instance depending on how it was referenced.\n const result = resolveSync(enablePackageExports ? getPathInModule(path, resolveOptions) : path, {\n ...resolveOptions,\n preserveSymlinks: !options.preserveSymlinks,\n });\n\n return result;\n};\n\nexport default defaultResolver;\n\n/*\n * helper functions\n */\n\nfunction getPathInModule(path: string, options: UpstreamResolveOptionsWithConditions): string {\n if (shouldIgnoreRequestForExports(path)) {\n return path;\n }\n\n const segments = path.split('/');\n\n let moduleName = segments.shift();\n\n if (!moduleName) {\n return path;\n }\n\n if (moduleName.startsWith('@')) {\n moduleName = `${moduleName}/${segments.shift()}`;\n }\n\n // self-reference\n const closestPackageJson = findClosestPackageJson(options.basedir, options);\n if (closestPackageJson) {\n const pkg = options.readPackageSync!(options.readFileSync!, closestPackageJson);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n // Added support for the package.json \"imports\" field (#-prefixed paths)\n if (path.startsWith('#')) {\n const resolved = resolve.imports(pkg, path, createResolveOptions(options.conditions));\n if (resolved) {\n // TODO: Should we attempt to resolve every path in the array?\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n // NOTE: resolve.imports would have thrown by this point.\n return path;\n }\n\n if (pkg.name === moduleName) {\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Report an issue: https://github.com/expo/expo/issues\"\n );\n }\n }\n }\n\n let packageJsonPath = '';\n\n try {\n packageJsonPath = resolveSync(`${moduleName}/package.json`, options);\n } catch {\n // ignore if package.json cannot be found\n }\n\n if (!packageJsonPath) {\n return path;\n }\n\n const pkg = options.readPackageSync!(options.readFileSync!, packageJsonPath);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(packageJsonPath), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Report an issue: https://github.com/expo/expo/issues\"\n );\n }\n\n return path;\n}\n\nfunction createResolveOptions(conditions: string[] | undefined): resolve.Options {\n return conditions\n ? { conditions, unsafe: true }\n : // no conditions were passed - let's assume this is Jest internal and it should be `require`\n { browser: false, require: true };\n}\n\n// if it's a relative import or an absolute path, imports/exports are ignored\nconst shouldIgnoreRequestForExports = (path: string) => path.startsWith('.') || isAbsolute(path);\n\n// adapted from\n// https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js\nfunction findClosestPackageJson(\n start: string,\n options: UpstreamResolveOptionsWithConditions\n): string | undefined {\n let dir = pathResolve('.', start);\n if (!options.isDirectory!(dir)) {\n dir = dirname(dir);\n }\n\n while (true) {\n const pkgJsonFile = pathResolve(dir, './package.json');\n const hasPackageJson = options.pathExists!(pkgJsonFile);\n\n if (hasPackageJson) {\n return pkgJsonFile;\n }\n\n const prevDir = dir;\n dir = dirname(dir);\n\n if (prevDir === dir) {\n return undefined;\n }\n }\n}\n"],"names":["defaultResolver","path","enablePackageExports","blockList","options","resolveOptions","preserveSymlinks","result","resolveSync","getPathInModule","shouldIgnoreRequestForExports","segments","split","moduleName","shift","startsWith","closestPackageJson","findClosestPackageJson","basedir","pkg","readPackageSync","readFileSync","assert","resolved","resolve","imports","createResolveOptions","conditions","pathResolve","dirname","name","exports","join","Error","packageJsonPath","unsafe","browser","require","isAbsolute","start","dir","isDirectory","pkgJsonFile","hasPackageJson","pathExists","prevDir","undefined"],"mappings":"AAAA;;;;;;;;;CASC;;;;+BA8GD;;;eAAA;;;;gEA3GmB;;;;;;;yBACyC;;;;;;;yBACY;;;;;;;iEAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;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AE7C,IAAIoC,MAAMZ,IAAAA,eAAW,EAAC,KAAKW;IAC3B,IAAI,CAACnC,QAAQqC,WAAW,CAAED,MAAM;QAC9BA,MAAMX,IAAAA,eAAO,EAACW;IAChB;IAEA,MAAO,KAAM;QACX,MAAME,cAAcd,IAAAA,eAAW,EAACY,KAAK;QACrC,MAAMG,iBAAiBvC,QAAQwC,UAAU,CAAEF;QAE3C,IAAIC,gBAAgB;YAClB,OAAOD;QACT;QAEA,MAAMG,UAAUL;QAChBA,MAAMX,IAAAA,eAAO,EAACW;QAEd,IAAIK,YAAYL,KAAK;YACnB,OAAOM;QACT;IACF;AACF"}
@@ -1,84 +0,0 @@
1
- /**
2
- * Copyright © 2022 650 Industries.
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- * A fork of my proposed Metro change https://github.com/facebook/metro/pull/1036/files
9
- */ "use strict";
10
- Object.defineProperty(exports, "__esModule", {
11
- value: true
12
- });
13
- Object.defineProperty(exports, "formatFileCandidates", {
14
- enumerable: true,
15
- get: function() {
16
- return formatFileCandidates;
17
- }
18
- });
19
- function _path() {
20
- const data = /*#__PURE__*/ _interop_require_default(require("path"));
21
- _path = function() {
22
- return data;
23
- };
24
- return data;
25
- }
26
- function _interop_require_default(obj) {
27
- return obj && obj.__esModule ? obj : {
28
- default: obj
29
- };
30
- }
31
- function groupExtensions(exts) {
32
- // Reverse the extensions and split into parts
33
- const extParts = exts.map((ext)=>ext.split('.').reverse());
34
- // Find the maximum depth of extension parts
35
- const maxDepth = Math.max(...extParts.map((parts)=>parts.length));
36
- // Initialize groups based on the max depth
37
- const groups = Array.from({
38
- length: maxDepth
39
- }, ()=>new Set());
40
- extParts.forEach((parts)=>{
41
- parts.forEach((part, i)=>{
42
- // Add parts to the corresponding group based on their depth
43
- groups[i].add(part);
44
- });
45
- });
46
- // Cycle groups and remove duplicates that appear forwards
47
- groups.forEach((group, index)=>{
48
- // Remove duplicates that appear forwards
49
- // NOTE: This doesn't support extensions like `.native.native.js`
50
- groups.forEach((otherGroup, otherIndex)=>{
51
- if (index < otherIndex) {
52
- otherGroup.forEach((part)=>group.delete(part));
53
- }
54
- });
55
- });
56
- // Convert sets back to arrays and reverse groups to correct order
57
- return groups.map((group)=>Array.from(group)).reverse();
58
- }
59
- function createMatcherPatternForExtensions(exts) {
60
- let formatted = '';
61
- if (exts.length) {
62
- // Apply grouping function
63
- const groups = groupExtensions(exts);
64
- formatted += groups.map((group, index)=>{
65
- return index < groups.length - 1 ? `(${group.map((ext)=>`.${ext}`).join('|')})?` : `.(${group.join('|')})`;
66
- }).join('');
67
- }
68
- return formatted;
69
- }
70
- function formatFileCandidates(candidates, allowIndex = false) {
71
- if (candidates.type === 'asset') {
72
- return candidates.name;
73
- }
74
- let formatted = candidates.filePathPrefix;
75
- if (allowIndex) {
76
- formatted += `(${_path().default.sep}index)?`;
77
- }
78
- const extensions = candidates.candidateExts// Drop additional dots, the first character if it is a dot, and remove empty strings.
79
- .map((ext)=>ext.replace(/\.+/g, '.').replace(/^\./g, '')).filter(Boolean);
80
- formatted += createMatcherPatternForExtensions(extensions);
81
- return formatted;
82
- }
83
-
84
- //# sourceMappingURL=formatFileCandidates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/formatFileCandidates.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * A fork of my proposed Metro change https://github.com/facebook/metro/pull/1036/files\n */\n\nimport type { FileCandidates } from '@expo/metro/metro-resolver';\nimport path from 'path';\n\nfunction groupExtensions(exts: readonly string[]): string[][] {\n // Reverse the extensions and split into parts\n const extParts = exts.map((ext) => ext.split('.').reverse());\n\n // Find the maximum depth of extension parts\n const maxDepth = Math.max(...extParts.map((parts) => parts.length));\n\n // Initialize groups based on the max depth\n const groups = Array.from({ length: maxDepth }, () => new Set<string>());\n\n extParts.forEach((parts) => {\n parts.forEach((part, i) => {\n // Add parts to the corresponding group based on their depth\n groups[i].add(part);\n });\n });\n\n // Cycle groups and remove duplicates that appear forwards\n groups.forEach((group, index) => {\n // Remove duplicates that appear forwards\n // NOTE: This doesn't support extensions like `.native.native.js`\n groups.forEach((otherGroup, otherIndex) => {\n if (index < otherIndex) {\n otherGroup.forEach((part) => group.delete(part));\n }\n });\n });\n\n // Convert sets back to arrays and reverse groups to correct order\n return groups.map((group) => Array.from(group)).reverse();\n}\n\nfunction createMatcherPatternForExtensions(exts: readonly string[]): string {\n let formatted = '';\n\n if (exts.length) {\n // Apply grouping function\n const groups = groupExtensions(exts);\n\n formatted += groups\n .map((group, index) => {\n return index < groups.length - 1\n ? `(${group.map((ext) => `.${ext}`).join('|')})?`\n : `.(${group.join('|')})`;\n })\n .join('');\n }\n\n return formatted;\n}\n\nexport function formatFileCandidates(\n candidates: FileCandidates,\n allowIndex: boolean = false\n): string {\n if (candidates.type === 'asset') {\n return candidates.name;\n }\n\n let formatted = candidates.filePathPrefix;\n\n if (allowIndex) {\n formatted += `(${path.sep}index)?`;\n }\n\n const extensions = candidates.candidateExts\n // Drop additional dots, the first character if it is a dot, and remove empty strings.\n .map((ext) => ext.replace(/\\.+/g, '.').replace(/^\\./g, ''))\n .filter(Boolean);\n\n formatted += createMatcherPatternForExtensions(extensions);\n\n return formatted;\n}\n"],"names":["formatFileCandidates","groupExtensions","exts","extParts","map","ext","split","reverse","maxDepth","Math","max","parts","length","groups","Array","from","Set","forEach","part","i","add","group","index","otherGroup","otherIndex","delete","createMatcherPatternForExtensions","formatted","join","candidates","allowIndex","type","name","filePathPrefix","path","sep","extensions","candidateExts","replace","filter","Boolean"],"mappings":"AAAA;;;;;;;;CAQC;;;;+BAwDeA;;;eAAAA;;;;gEArDC;;;;;;;;;;;AAEjB,SAASC,gBAAgBC,IAAuB;IAC9C,8CAA8C;IAC9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