From fec08800dd5186b055ece3619adb0013400e1c7f Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 18 Apr 2024 20:00:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(x-ios):=20=E4=BF=AE=E5=A4=8D=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=A5=E5=BF=97sourcemap=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-app-uts/src/plugins/ios/plugin.ts | 1 + packages/uni-uts-v1/src/index.ts | 6 ++++- packages/uni-uts-v1/src/stacktrace/index.ts | 23 +++++++++++++++++++ packages/uni-uts-v1/src/stacktrace/js.ts | 7 ++++-- packages/uni-uts-v1/src/stacktrace/kotlin.ts | 3 ++- 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/packages/uni-app-uts/src/plugins/ios/plugin.ts b/packages/uni-app-uts/src/plugins/ios/plugin.ts index ea88fbceff..39c8e5c4f3 100644 --- a/packages/uni-app-uts/src/plugins/ios/plugin.ts +++ b/packages/uni-app-uts/src/plugins/ios/plugin.ts @@ -75,6 +75,7 @@ export function uniAppIOSPlugin(): UniVitePlugin { process.env.UNI_APP_X_CACHE_DIR ? path.resolve( process.env.UNI_APP_X_CACHE_DIR, + 'sourcemap', APP_SERVICE_FILENAME_MAP ) : path.resolve( diff --git a/packages/uni-uts-v1/src/index.ts b/packages/uni-uts-v1/src/index.ts index 22234579af..19f3892ee5 100644 --- a/packages/uni-uts-v1/src/index.ts +++ b/packages/uni-uts-v1/src/index.ts @@ -62,7 +62,11 @@ export { parseInjectModules, parseExtApiProviders } from './utils' export * from './sourceMap' -export { parseUTSKotlinRuntimeStacktrace } from './stacktrace' +export { + parseUTSRuntimeStacktrace, + parseUTSKotlinRuntimeStacktrace, + parseUTSJavaScriptRuntimeStacktrace, +} from './stacktrace' export { compile as toKotlin } from './kotlin' export { compile as toSwift } from './swift' diff --git a/packages/uni-uts-v1/src/stacktrace/index.ts b/packages/uni-uts-v1/src/stacktrace/index.ts index 883675df0c..92ce6be1a3 100644 --- a/packages/uni-uts-v1/src/stacktrace/index.ts +++ b/packages/uni-uts-v1/src/stacktrace/index.ts @@ -1,4 +1,12 @@ import { relative } from '../utils' +import { + type GenerateJavaScriptRuntimeCodeFrameOptions, + parseUTSJavaScriptRuntimeStacktrace, +} from './js' +import { + type GenerateKotlinRuntimeCodeFrameOptions, + parseUTSKotlinRuntimeStacktrace, +} from './kotlin' export { parseUTSSwiftPluginStacktrace } from './swift' @@ -7,6 +15,21 @@ export { parseUTSKotlinRuntimeStacktrace, } from './kotlin' +export { parseUTSJavaScriptRuntimeStacktrace } from './js' + +export function parseUTSRuntimeStacktrace( + stacktrace: string, + options: + | GenerateKotlinRuntimeCodeFrameOptions + | GenerateJavaScriptRuntimeCodeFrameOptions +) { + if (options.language === 'kotlin') { + return parseUTSKotlinRuntimeStacktrace(stacktrace, options) + } else if (options.language === 'javascript') { + return parseUTSJavaScriptRuntimeStacktrace(stacktrace, options) + } +} + export function parseUTSSyntaxError(error: any, inputDir: string): string { if (error instanceof Error) { error = error.message diff --git a/packages/uni-uts-v1/src/stacktrace/js.ts b/packages/uni-uts-v1/src/stacktrace/js.ts index 8b31b7c631..979cb41012 100644 --- a/packages/uni-uts-v1/src/stacktrace/js.ts +++ b/packages/uni-uts-v1/src/stacktrace/js.ts @@ -9,8 +9,11 @@ import { splitRE, } from './utils' -interface GenerateJavaScriptRuntimeCodeFrameOptions - extends GenerateRuntimeCodeFrameOptions {} +export interface GenerateJavaScriptRuntimeCodeFrameOptions + extends GenerateRuntimeCodeFrameOptions { + language: 'javascript' +} + const JS_ERROR_RE = /\(\d+:\d+\)\s(.*)\s@([^\s]+\.js)\:(\d+)\:(\d+)/ const VUE_ERROR_RE = /@([^\s]+\.js)\:(\d+)\:(\d+)/ diff --git a/packages/uni-uts-v1/src/stacktrace/kotlin.ts b/packages/uni-uts-v1/src/stacktrace/kotlin.ts index 6800e72df9..e2d353e653 100644 --- a/packages/uni-uts-v1/src/stacktrace/kotlin.ts +++ b/packages/uni-uts-v1/src/stacktrace/kotlin.ts @@ -183,9 +183,10 @@ function parseFilenameByClassName(className: string) { return kotlinManifest.manifest[className.split('$')[0]] || 'index.kt' } -interface GenerateKotlinRuntimeCodeFrameOptions +export interface GenerateKotlinRuntimeCodeFrameOptions extends GenerateRuntimeCodeFrameOptions { appid: string + language: 'kotlin' } export function parseUTSKotlinRuntimeStacktrace( -- GitLab