amis-rpc-design/node_modules/@react-native-community/cli-hermes/build/profileHermes/sourcemapUtils.js.map

1 line
5.7 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"version":3,"names":["getTempFilePath","filename","path","join","os","tmpdir","writeJsonSync","targetPath","data","json","JSON","stringify","e","CLIError","fs","writeFileSync","getSourcemapFromServer","port","logger","debug","DEBUG_SERVER_PORT","IP_ADDRESS","ip","address","PLATFORM","requestURL","fetch","undefined","generateSourcemap","sourceMapPath","sourceMapResult","error","findSourcemap","ctx","intermediateBuildPath","root","generatedBuildPath","existsSync"],"sources":["../../src/profileHermes/sourcemapUtils.ts"],"sourcesContent":["import {Config} from '@react-native-community/cli-types';\nimport {logger, CLIError, fetch} from '@react-native-community/cli-tools';\nimport fs from 'fs';\nimport path from 'path';\nimport os from 'os';\nimport {SourceMap} from 'hermes-profile-transformer';\nimport ip from 'ip';\n\nfunction getTempFilePath(filename: string) {\n return path.join(os.tmpdir(), filename);\n}\n\nfunction writeJsonSync(targetPath: string, data: any) {\n let json;\n try {\n json = JSON.stringify(data);\n } catch (e) {\n throw new CLIError(\n `Failed to serialize data to json before writing to ${targetPath}`,\n e as Error,\n );\n }\n\n try {\n fs.writeFileSync(targetPath, json, 'utf-8');\n } catch (e) {\n throw new CLIError(`Failed to write json to ${targetPath}`, e as Error);\n }\n}\n\nasync function getSourcemapFromServer(\n port?: string,\n): Promise<SourceMap | undefined> {\n logger.debug('Getting source maps from Metro packager server');\n const DEBUG_SERVER_PORT = port || '8081';\n const IP_ADDRESS = ip.address();\n const PLATFORM = 'android';\n\n const requestURL = `http://${IP_ADDRESS}:${DEBUG_SERVER_PORT}/index.map?platform=${PLATFORM}&dev=true`;\n try {\n const {data} = await fetch(requestURL);\n return data as SourceMap;\n } catch (e) {\n logger.debug(`Failed to fetch source map from \"${requestURL}\"`);\n return undefined;\n }\n}\n\n/**\n * Generate a sourcemap by fetching it from a running metro server\n */\nexport async function generateSourcemap(\n port?: string,\n): Promise<string | undefined> {\n // Fetch the source map to a temp directory\n const sourceMapPath = getTempFilePath('index.map');\n const sourceMapResult = await getSourcemapFromServer(port);\n\n if (sourceMapResult) {\n logger.debug('Using source maps from Metro packager server');\n writeJsonSync(sourceMapPath, sourceMapResult);\n logger.debug(\n `Successfully obtained the source map and stored it in ${sourceMapPath}`,\n );\n return sourceMapPath;\n } else {\n logger.error('Cannot obtain source maps from Metro packager server');\n return undefined;\n }\n}\n\n/**\n *\n * @param ctx\n */\nexport async function findSourcemap(\n ctx: Config,\n port?: string,\n): Promise<string | undefined> {\n const intermediateBuildPath = path.join(\n ctx.root,\n 'android',\n 'app',\n 'build',\n 'intermediates',\n 'sourcemaps',\n 'react',\n 'debug',\n 'index.android.bundle.packager.map',\n );\n\n const generatedBuildPath = path.join(\n ctx.root,\n 'android',\n 'app',\n 'build',\n 'generated',\n 'sourcemaps',\n 'react',\n 'debug',\n 'index.android.bundle.map',\n );\n\n if (fs.existsSync(generatedBuildPath)) {\n logger.debug(`Getting the source map from ${generateSourcemap}`);\n return generatedBuildPath;\n } else if (fs.existsSync(intermediateBuildPath)) {\n logger.debug(`Getting the source map from ${intermediateBuildPath}`);\n return intermediateBuildPath;\n } else {\n return generateSourcemap(port);\n }\n}\n"],"mappings":";;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAoB;AAEpB,SAASA,eAAe,CAACC,QAAgB,EAAE;EACzC,OAAOC,eAAI,CAACC,IAAI,CAACC,aAAE,CAACC,MAAM,EAAE,EAAEJ,QAAQ,CAAC;AACzC;AAEA,SAASK,aAAa,CAACC,UAAkB,EAAEC,IAAS,EAAE;EACpD,IAAIC,IAAI;EACR,IAAI;IACFA,IAAI,GAAGC,IAAI,CAACC,SAAS,CAACH,IAAI,CAAC;EAC7B,CAAC,CAAC,OAAOI,CAAC,EAAE;IACV,MAAM,KAAIC,oBAAQ,E