diff --git a/packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-android/index.kt.map b/packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-android/index.kt.map index 77f4a9b7429536047402527e410b8feca822aee7..292dc54faa712ae942f98066ae0f4d81759f2e50 100644 --- a/packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-android/index.kt.map +++ b/packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-android/index.kt.map @@ -1 +1 @@ -{"version":3,"sources":["uni_modules/test-uniplugin/static/logo.png","uni_modules/test-uniplugin/utssdk/app-android/index.uts","uni_modules/test-uniplugin/utssdk/app-android/interface.uts"],"sourcesContent":["import { UTSAndroid } from 'io.dcloud.uts'\nexport default UTSAndroid.getResourcePath('uni_modules/test-uniplugin/static/logo.png')\n ","import Log from 'android.util.Log'\nimport FrameLayout from 'android.widget.FrameLayout'\nimport View from 'android.view.View'\nimport { login } from 'login'\nimport { IUser } from './interface'\nimport logo from '../../static/logo.png'\n\nconst test = arrayOf(1, 2, 3)\n\ntype GetBatteryInfoOptions = {\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\nexport class User implements IUser {\n async login(name: string, pwd: string) {\n setTimeout(() => {\n console.log('timeout')\n }, 1000)\n login(name, pwd)\n for (let i = 0; i < 10; i++) {\n console.log(i)\n }\n Log.info(logo)\n\n console.log('def android')\n\n\n\n\n\n\n\n\n console.log('ndef ios')\n\n\n console.log('def android || def ios')\n\n\n\n\n const a = -3\n console.log(~a)\n new XToast>(getUniActivity())\n .setContentView(R.layout.toast_hint)\n .setDuration(1000)\n .setImageDrawable(android.R.id.icon, R.mipmap.ic_dialog_tip_finish)\n .setText(android.R.id.message, '点我消失')\n .show()\n }\n register(name: string, callback: () => void) {\n Log.info(logo as FrameLayout)\n }\n test(view: View) {\n console.log(new TestClass())\n }\n}\nfunction login(name: string, callback: () => void) { }\n\n@Suppress(\"DEPRECATION\")\nexport function register(name: string, callback: () => void) { }\nexport function offMemoryWarning(\n callback: null | ((level: number) => void) = null\n) { }\nclass TestClass {\n\n}\n","export interface IUser {\n register(name: string): void\n}\n"],"names":[],"mappings":";;;;;;AAAA;ACAA,OAAgB,gBAAkB,CAAA;AAClC,OAAwB,0BAA4B,CAAA;AACpD,OAAiB,iBAAmB,CAAA;AACpC;UCHiB;QACf,SAAS,MAAM,MAAM,GAAG,IAAI;;cFAf,WAAW,eAAe,CAAC;ACM1C,IAAM,OAAO,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAEC,WAAxB;IACH,SAAA,SAAQ,oBAA8B;IACtC,SAAA,MAAK,oBAA8B;IACnC,SAAA,UAAS,oBAA8B;AACzC;AACO,WAAM,OAAgB;IAC3B,iBAAM,MAAM,MAAM,MAAM,EAAE,KAAK,MAAM,8CAAE;QACrC,WAAW,KAAM;YACf,QAAQ,GAAG,CAAC;QACd;UAAG,IAAI;QACP,MAAM,MAAM;YACZ;YAAK,IAAI,IAAI,CAAC;YAAd,MAAgB,IAAI,EAAE;gBACpB,QAAQ,GAAG,CAAC;gBADU;;QAExB;QACA,IAAI,IAAI;QAER,QAAQ,GAAG,CAAC;QASZ,QAAQ,GAAG,CAAC;QAGZ,QAAQ,GAAG,CAAC;QAMZ,QAAQ,GAAG,CAAC,CADF,EAAE,KACE;QACV,OAAO,OAAO,CAAO,GAAG,kBACzB,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,EAClC,WAAW,CAAC,IAAI,EAChB,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,oBAAoB,EACjE,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,QAC9B,IAAI;IACT;IACA,aAAA,SAAS,MAAM,MAAM,EAAE,qBAAoB,EAAE;QAC3C,IAAI,IAAI,YAAS;IACnB;IACA,SAAA,KAAK,MAAM,IAAI,EAAE;QACf,QAAQ,GAAG,CAAC,AAAI;IAClB;AACF;AACA,IAAS,MAAM,MAAM,MAAM,EAAE,gBAAgB,IAAI,EAAE,CAAE;AAErD,CAAC,SAAS;AAAc,IACR,SAAS,MAAM,MAAM,EAAE,qBAAoB,EAAE,CAAE;AACxD,IAAS,iBACd,2BAA6C,IAAI,EACjD,CAAE;AACJ,WAAM;AAEN"} \ No newline at end of file +{"version":3,"sources":["uni_modules/test-uniplugin/static/logo.png","uni_modules/test-uniplugin/utssdk/app-android/index.uts","uni_modules/test-uniplugin/utssdk/app-android/utils.uts","uni_modules/test-uniplugin/utssdk/app-android/login.uts","uni_modules/test-uniplugin/utssdk/app-android/interface.uts"],"sourcesContent":["import { UTSAndroid } from 'io.dcloud.uts'\nexport default UTSAndroid.getResourcePath('uni_modules/test-uniplugin/static/logo.png')\n ","import Log from 'android.util.Log'\nimport FrameLayout from 'android.widget.FrameLayout'\nimport View from 'android.view.View'\nimport { login } from 'login'\nimport { IUser } from './interface'\nimport logo from '../../static/logo.png'\n\nconst test = arrayOf(1, 2, 3)\n\ntype GetBatteryInfoOptions = {\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\nexport class User implements IUser {\n async login(name: string, pwd: string) {\n setTimeout(() => {\n console.log('timeout')\n }, 1000)\n login(name, pwd)\n for (let i = 0; i < 10; i++) {\n console.log(i)\n }\n Log.info(logo)\n\n console.log('def android')\n\n\n\n\n\n\n\n\n console.log('ndef ios')\n\n\n console.log('def android || def ios')\n\n\n\n\n const a = -3\n console.log(~a)\n new XToast>(getUniActivity())\n .setContentView(R.layout.toast_hint)\n .setDuration(1000)\n .setImageDrawable(android.R.id.icon, R.mipmap.ic_dialog_tip_finish)\n .setText(android.R.id.message, '点我消失')\n .show()\n }\n register(name: string, callback: () => void) {\n Log.info(logo as FrameLayout)\n }\n test(view: View) {\n console.log(new TestClass())\n }\n}\nfunction login(name: string, callback: () => void) { }\n\n@Suppress(\"DEPRECATION\")\nexport function register(name: string, callback: () => void) { }\nexport function offMemoryWarning(\n callback: null | ((level: number) => void) = null\n) { }\nclass TestClass {\n\n}\n","export function test(){\n console.log('test')\n}\n","import { test } from \"./utils.uts\"\nexport function login(name: string, pwd: string) {\n console.log('login')\n test()\n return { name, pwd }\n}\n","export interface IUser {\n register(name: string): void\n}\n"],"names":[],"mappings":";;;;;;AAAA;ACAA,OAAgB,gBAAkB,CAAA;AAClC,OAAwB,0BAA4B,CAAA;AACpD,OAAiB,iBAAmB,CAAA;ACF7B,IAAS,OAAM;IAClB,QAAQ,GAAG,CAAC;AAChB;ACDO,IAAS,MAAM,MAAM,MAAM,EAAE,KAAK,MAAM,iBAAE;IAC/C,QAAQ,GAAG,CAAC;IACZ;IACA,OAAO;QAAE,IAAA,OAAA;QAAM,IAAA,MAAA;KAAK;AACtB;UCLiB;QACf,SAAS,MAAM,MAAM,GAAG,IAAI;;cJAf,WAAW,eAAe,CAAC;ACM1C,IAAM,QAAO,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAEC,WAAxB;IACH,SAAA,SAAQ,oBAA8B;IACtC,SAAA,MAAK,oBAA8B;IACnC,SAAA,UAAS,oBAA8B;AACzC;AACO,WAAM,OAAgB;IAC3B,iBAAM,MAAM,MAAM,MAAM,EAAE,KAAK,MAAM,8CAAE;QACrC,WAAW,KAAM;YACf,QAAQ,GAAG,CAAC;QACd;UAAG,IAAI;QACP,MAAM,MAAM;YACZ;YAAK,IAAI,IAAI,CAAC;YAAd,MAAgB,IAAI,EAAE;gBACpB,QAAQ,GAAG,CAAC;gBADU;;QAExB;QACA,IAAI,IAAI;QAER,QAAQ,GAAG,CAAC;QASZ,QAAQ,GAAG,CAAC;QAGZ,QAAQ,GAAG,CAAC;QAMZ,QAAQ,GAAG,CAAC,CADF,EAAE,KACE;QACV,OAAO,OAAO,CAAO,GAAG,kBACzB,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,EAClC,WAAW,CAAC,IAAI,EAChB,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,oBAAoB,EACjE,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,QAC9B,IAAI;IACT;IACA,aAAA,SAAS,MAAM,MAAM,EAAE,qBAAoB,EAAE;QAC3C,IAAI,IAAI,YAAS;IACnB;IACA,SAAA,KAAK,MAAM,IAAI,EAAE;QACf,QAAQ,GAAG,CAAC,AAAI;IAClB;AACF;AACA,UAAe,MAAM,MAAM,EAAE,gBAAgB,IAAI,EAAE,CAAE;AAErD,CAAC,SAAS;AAAc,IACR,SAAS,MAAM,MAAM,EAAE,qBAAoB,EAAE,CAAE;AACxD,IAAS,iBACd,2BAA6C,IAAI,EACjD,CAAE;AACJ,WAAM;AAEN"} \ No newline at end of file diff --git a/packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-uniplugin/utssdk/app-android/index.kt b/packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-uniplugin/utssdk/app-android/index.kt index 2cf903aa166e423e924b1793528410b4627fd072..79ade3b9dee5b547f6d85e7865a0e8908cfb1afa 100644 --- a/packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-uniplugin/utssdk/app-android/index.kt +++ b/packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-uniplugin/utssdk/app-android/index.kt @@ -8,12 +8,22 @@ import io.dcloud.uts.UTSAndroid; import android.util.Log; import android.widget.FrameLayout; import android.view.View; -import login.login; +fun test() { + console.log("test", " at uni_modules/test-uniplugin/utssdk/app-android/utils.uts:2"); +} +fun login(name: String, pwd: String): UTSJSONObject { + console.log("login", " at uni_modules/test-uniplugin/utssdk/app-android/login.uts:3"); + test(); + return object : UTSJSONObject() { + var name = name + var pwd = pwd + }; +} interface IUser { fun register(name: String): Unit; } val default = UTSAndroid.getResourcePath("uni_modules/test-uniplugin/static/logo.png"); -val test = arrayOf(1, 2, 3); +val test1 = arrayOf(1, 2, 3); open class GetBatteryInfoOptions : UTSJSONObject() { open var success: UTSCallback? = null; open var fail: UTSCallback? = null; diff --git a/packages/uni-app-plus/dist/uni.runtime.esm.js b/packages/uni-app-plus/dist/uni.runtime.esm.js index b7e027c81dce4e69b36abd932cff44846d1380fa..40fcfcafa8e8ebe22fa2ee1e429d8ff23b03d49b 100644 --- a/packages/uni-app-plus/dist/uni.runtime.esm.js +++ b/packages/uni-app-plus/dist/uni.runtime.esm.js @@ -14585,9 +14585,10 @@ const compressVideo = defineAsyncApi(API_COMPRESS_VIDEO, (options, { resolve, re const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; plus.zip.compressVideo(extend({}, options, { filename, - }), () => { + }), (videoInfo) => { resolve({ tempFilePath: filename, + size: videoInfo.size, }); }, reject); }, CompressVideoProtocol, CompressVideoOptions); diff --git a/packages/uni-app-vite/src/index.ts b/packages/uni-app-vite/src/index.ts index 123562b97a3d2194e6efbe0d73cf8bdde1359a07..2406ea48d723e5753e46ea59de3cfb81dac89117 100644 --- a/packages/uni-app-vite/src/index.ts +++ b/packages/uni-app-vite/src/index.ts @@ -1,14 +1,14 @@ import { initVuePlugins } from './vue' import { initNVuePlugins } from './nvue' import { uniAppPlugin } from './plugin' -import { uniUtsV1Plugin } from './plugins/uts' +import { uniUTSV1Plugin } from './plugins/uts' export default () => { return [ uniAppPlugin({ renderer: process.env.UNI_RENDERER, appService: process.env.UNI_RENDERER_NATIVE === 'appService', }), - uniUtsV1Plugin(), + uniUTSV1Plugin(), ...(process.env.UNI_COMPILER === 'nvue' ? initNVuePlugins() : initVuePlugins()), diff --git a/packages/uni-app-vite/src/plugins/uts.ts b/packages/uni-app-vite/src/plugins/uts.ts index cbace6e58e152efeb241ba450670e01ad08402db..599acc8371fc3cbc717abab437fc7dd3359e3cc2 100644 --- a/packages/uni-app-vite/src/plugins/uts.ts +++ b/packages/uni-app-vite/src/plugins/uts.ts @@ -2,7 +2,7 @@ import type { Plugin } from 'vite' import path from 'path' import { parseVueRequest, - resolveUtsAppModule, + resolveUTSAppModule, resolveUTSCompiler, } from '@dcloudio/uni-cli-shared' import { once } from '@dcloudio/uni-shared' @@ -21,7 +21,7 @@ const utsModuleCaches = new Map< meta?: any }> >() -export function uniUtsV1Plugin(): Plugin { +export function uniUTSV1Plugin(): Plugin { process.env.UNI_UTS_USING_ROLLUP = 'true' return { name: 'uni:uts', @@ -31,7 +31,7 @@ export function uniUtsV1Plugin(): Plugin { if (isUTSProxy(id)) { return id } - const module = resolveUtsAppModule( + const module = resolveUTSAppModule( id, importer ? path.dirname(importer) : process.env.UNI_INPUT_DIR ) diff --git a/packages/uni-cli-shared/src/uts.ts b/packages/uni-cli-shared/src/uts.ts index 4f4886145ab191e6df747fa8a3b4d24613604595..eba587457e388e45a998b985c8d27ddddc2ea7ef 100644 --- a/packages/uni-cli-shared/src/uts.ts +++ b/packages/uni-cli-shared/src/uts.ts @@ -14,7 +14,7 @@ import type { EasycomMatcher } from './easycom' * @param importer * @returns */ -export function resolveUtsAppModule(id: string, importer: string) { +export function resolveUTSAppModule(id: string, importer: string) { id = path.resolve(importer, id) if (id.includes('utssdk') || id.includes('uni_modules')) { const parts = normalizePath(id).split('/') @@ -28,10 +28,10 @@ export function resolveUtsAppModule(id: string, importer: string) { return path.resolve(id, basedir, p) } const extname = ['.uts'] - if (resolveUtsFile(resolvePlatformDir('app-android'), extname)) { + if (resolveUTSFile(resolvePlatformDir('app-android'), extname)) { return id } - if (resolveUtsFile(resolvePlatformDir('app-ios'), extname)) { + if (resolveUTSFile(resolvePlatformDir('app-ios'), extname)) { return id } } @@ -39,12 +39,12 @@ export function resolveUtsAppModule(id: string, importer: string) { } // 仅限 root/uni_modules/test-plugin | root/utssdk/test-plugin 格式 -export function resolveUtsModule(id: string, importer: string) { +export function resolveUTSModule(id: string, importer: string) { if ( process.env.UNI_PLATFORM === 'app' || process.env.UNI_PLATFORM === 'app-plus' ) { - return resolveUtsAppModule(id, importer) + return resolveUTSAppModule(id, importer) } id = path.resolve(importer, id) if (id.includes('utssdk') || id.includes('uni_modules')) { @@ -56,7 +56,7 @@ export function resolveUtsModule(id: string, importer: string) { return path.resolve(id, basedir, p) } - let index = resolveUtsFile( + let index = resolveUTSFile( resolvePlatformDir(process.env.UNI_UTS_PLATFORM) ) if (index) { @@ -70,7 +70,7 @@ export function resolveUtsModule(id: string, importer: string) { } } -function resolveUtsFile( +function resolveUTSFile( dir: string, extensions: string[] = ['.uts', '.ts', '.js'] ) { diff --git a/packages/uni-mp-vite/src/plugins/usingComponents.ts b/packages/uni-mp-vite/src/plugins/usingComponents.ts index 33b9096f0b47dc85878db71cd6d107bbd738d5ef..7e13ae3a5b46dedeed0296884a83df760321cec1 100644 --- a/packages/uni-mp-vite/src/plugins/usingComponents.ts +++ b/packages/uni-mp-vite/src/plugins/usingComponents.ts @@ -14,7 +14,7 @@ import { updateMiniProgramComponentsByScriptFilename, updateMiniProgramComponentsByTemplateFilename, withSourcemap, - resolveUtsModule, + resolveUTSModule, } from '@dcloudio/uni-cli-shared' import { virtualComponentPath, virtualPagePath } from './entry' import { CustomPluginOptions, ResolvedId } from 'rollup' @@ -60,7 +60,7 @@ export function uniUsingComponentsPlugin( skipSelf?: boolean } ): Promise => { - const id = resolveUtsModule( + const id = resolveUTSModule( source, importer || process.env.UNI_INPUT_DIR ) diff --git a/packages/uni-stacktracey/__tests__/uni-stacktracey.spec.ts b/packages/uni-stacktracey/__tests__/uni-stacktracey.spec.ts index df71f5ced23fa6c0e54c6f9c01fc2b3461c12315..38532c238720c894e0517f993ab11fe35c4bd2db 100644 --- a/packages/uni-stacktracey/__tests__/uni-stacktracey.spec.ts +++ b/packages/uni-stacktracey/__tests__/uni-stacktracey.spec.ts @@ -11,8 +11,8 @@ const utsErrorMsg = `Error: ${path.resolve( utsProjectDir, 'unpackage/dist/dev/app-plus/uni_modules/test-uts/app-android/index.kt' -)}:59:67: error: unresolved reference: UtsJSONObject -open suspend fun testClassAsync(opts: AsyncOptions): Deferred = CoroutineScope(Dispatchers.Default).async { +)}:59:67: error: unresolved reference: UTSJSONObject +open suspend fun testClassAsync(opts: AsyncOptions): Deferred = CoroutineScope(Dispatchers.Default).async { ^ ` @@ -59,8 +59,8 @@ at node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime. }).then((res: string) => { expect(res).toEqual(`Error: at uni_modules/test-uts/app-android/index.uts:82:52 -error: unresolved reference: UtsJSONObject -open suspend fun testClassAsync(opts: AsyncOptions): Deferred = CoroutineScope(Dispatchers.Default).async { +error: unresolved reference: UTSJSONObject +open suspend fun testClassAsync(opts: AsyncOptions): Deferred = CoroutineScope(Dispatchers.Default).async { ^ `) }) diff --git a/packages/uni-stacktracey/__tests__/uts.spec.ts b/packages/uni-stacktracey/__tests__/uts.spec.ts index 63b9341c8f934ddda2e0875e03a8772d3186f30e..902c7d9853df2108c6862d798dbf45119996b1e9 100644 --- a/packages/uni-stacktracey/__tests__/uts.spec.ts +++ b/packages/uni-stacktracey/__tests__/uts.spec.ts @@ -17,7 +17,7 @@ describe('code-frame-uts', () => { }) ).toMatchSnapshot() expect( - await generateCodeFrameWithKotlinStacktrace(androidUtssdkError, { + await generateCodeFrameWithKotlinStacktrace(androidUTSsdkError, { name: 'utssdk/test2', inputDir: '/Users/fxy/DCloud/test-uts', outputDir: path.resolve(utsProjectDir, 'unpackage/dist/dev/app-plus'), @@ -39,7 +39,7 @@ const androidUniModulesError = `e: uni_modules/test-uts1/utssdk/app-android/inde FAILURE: Build failed with an exception.` -const androidUtssdkError = `e: utssdk/test2/app-android/index.kt: (8, 12): The integer literal does not conform to the expected type String +const androidUTSsdkError = `e: utssdk/test2/app-android/index.kt: (8, 12): The integer literal does not conform to the expected type String FAILURE: Build failed with an exception.` diff --git a/packages/uni-stacktracey/src/index.ts b/packages/uni-stacktracey/src/index.ts index 70362ed4a7523dc44a9d7c588382d487df086a89..d0a4395f41656abb9bc96c602add877c6cef1ebf 100644 --- a/packages/uni-stacktracey/src/index.ts +++ b/packages/uni-stacktracey/src/index.ts @@ -417,7 +417,7 @@ export function uniStracktraceyPreset( } } -interface UtsStracktraceyPreset { +interface UTSStracktraceyPreset { /** * 源码根目录 */ @@ -432,7 +432,7 @@ interface UtsStracktraceyPreset { sourceMapRoot: string } export function utsStracktraceyPreset( - opts: UtsStracktraceyPreset + opts: UTSStracktraceyPreset ): StacktraceyPreset { const { inputRoot, outputRoot, sourceMapRoot } = opts diff --git a/packages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap b/packages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap index f020519d5db41f13b8c4053fbe310f1fe365e38a..9a05ae914997bb119b8ef28322536e2ebeb467e1 100644 --- a/packages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap +++ b/packages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap @@ -11,7 +11,7 @@ const is_uni_modules = false const pkg = initUTSPackageName(name, is_uni_modules) const cls = initUTSIndexClassName(name, is_uni_modules) -export const TestUtsComponent = {} +export const TestUTSComponent = {} export const onMemoryWarning = initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'onMemoryWarning', params: [{"name":"callback","type":"UTSCallback"}]}) export const offMemoryWarning = initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'offMemoryWarning', params: [{"name":"callback","type":"UTSCallback","default":"UTSNull"}]}) @@ -33,7 +33,7 @@ const cls = initUTSIndexClassName(name, is_uni_modules) const exports = { __esModule: true } -exports.TestUtsComponent = {} +exports.TestUTSComponent = {} exports.onMemoryWarning = initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'onMemoryWarning', params: [{"name":"callback","type":"UTSCallback"}]}) exports.offMemoryWarning = initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'offMemoryWarning', params: [{"name":"callback","type":"UTSCallback","default":"UTSNull"}]}) diff --git a/packages/uni-uts-v1/__tests__/code.spec.ts b/packages/uni-uts-v1/__tests__/code.spec.ts index 007b331177a16f81a35aa4bad8096edcfb0384a4..784c10ca91b08e1b79f1df5c8c9ff1c92ed7bab4 100644 --- a/packages/uni-uts-v1/__tests__/code.spec.ts +++ b/packages/uni-uts-v1/__tests__/code.spec.ts @@ -14,9 +14,9 @@ describe('code', () => { id: 'test-uts', is_uni_modules: false, name: 'test-uts', - namespace: 'uts.sdk.testUts', + namespace: 'uts.sdk.testUTS', extname: '.uts', - androidComponents: { TestUts: '' }, + androidComponents: { TestUTS: '' }, }) ).replace(ERR_MSG_PLACEHOLDER, '') ).toMatchSnapshot() @@ -28,11 +28,11 @@ describe('code', () => { id: 'test-uts', is_uni_modules: false, name: 'test-uts', - namespace: 'uts.sdk.testUts', + namespace: 'uts.sdk.testUTS', extname: '.uts', format: FORMATS.CJS, pluginRelativeDir: 'utssdk/test-uts', - androidComponents: { TestUts: '' }, + androidComponents: { TestUTS: '' }, }) ).replace(ERR_MSG_PLACEHOLDER, '') ).toMatchSnapshot() diff --git a/packages/uni-uts-v1/__tests__/sourceMap.spec.ts b/packages/uni-uts-v1/__tests__/sourceMap.spec.ts index e1799d37f90725aa8fdde732b71c8f3be405392d..367ec7d4e704fb248098cb7bf04ef3e805d3ba16 100644 --- a/packages/uni-uts-v1/__tests__/sourceMap.spec.ts +++ b/packages/uni-uts-v1/__tests__/sourceMap.spec.ts @@ -1,6 +1,6 @@ import { resolve } from 'path' import { - resolveUtsPluginSourceMapFile, + resolveUTSPluginSourceMapFile, generatedPositionFor, originalPositionFor, } from '../src' @@ -15,8 +15,8 @@ const utssdkPluginDir = 'utssdk/test-uts' const uniModulesPluginDir = 'uni_modules/test-uniplugin' describe('uts:sourceMap', () => { - test('resolveUtsPluginSourceMapFile with uni_modules uts=>kotlin', () => { - const sourceMapFile = resolveUtsPluginSourceMapFile( + test('resolveUTSPluginSourceMapFile with uni_modules uts=>kotlin', () => { + const sourceMapFile = resolveUTSPluginSourceMapFile( 'kotlin', resolve(inputDir, uniModulesPluginDir, 'utssdk/app-android/index.uts'), inputDir, @@ -24,7 +24,7 @@ describe('uts:sourceMap', () => { ) expect(sourceMapFile).toBeDefined() expect( - resolveUtsPluginSourceMapFile( + resolveUTSPluginSourceMapFile( 'kotlin', resolve(inputDir, uniModulesPluginDir, 'utssdk/index.uts'), inputDir, @@ -32,7 +32,7 @@ describe('uts:sourceMap', () => { ) ).toBe(sourceMapFile) expect( - resolveUtsPluginSourceMapFile( + resolveUTSPluginSourceMapFile( 'kotlin', resolve( inputDir, @@ -45,8 +45,8 @@ describe('uts:sourceMap', () => { ).toBe(sourceMapFile) }) - test('resolveUtsPluginSourceMapFile with uni_modules uts=>swift', () => { - const sourceMapFile = resolveUtsPluginSourceMapFile( + test('resolveUTSPluginSourceMapFile with uni_modules uts=>swift', () => { + const sourceMapFile = resolveUTSPluginSourceMapFile( 'swift', resolve(inputDir, uniModulesPluginDir, 'utssdk/app-ios/index.uts'), inputDir, @@ -55,8 +55,8 @@ describe('uts:sourceMap', () => { expect(sourceMapFile).toBeDefined() }) - test('resolveUtsPluginSourceMapFile with utssdk uts=>kotlin', () => { - const sourceMapFile = resolveUtsPluginSourceMapFile( + test('resolveUTSPluginSourceMapFile with utssdk uts=>kotlin', () => { + const sourceMapFile = resolveUTSPluginSourceMapFile( 'kotlin', resolve(inputDir, utssdkPluginDir, 'app-android/index.uts'), inputDir, @@ -64,8 +64,8 @@ describe('uts:sourceMap', () => { ) expect(sourceMapFile).toBeDefined() }) - test('resolveUtsPluginSourceMapFile with utssdk uts=>swift', () => { - const sourceMapFile = resolveUtsPluginSourceMapFile( + test('resolveUTSPluginSourceMapFile with utssdk uts=>swift', () => { + const sourceMapFile = resolveUTSPluginSourceMapFile( 'swift', resolve(inputDir, utssdkPluginDir, 'app-ios/index.uts'), inputDir, @@ -74,8 +74,8 @@ describe('uts:sourceMap', () => { expect(sourceMapFile).toBeDefined() }) - test('resolveUtsPluginSourceMapFile with uni_modules kt', () => { - const sourceMapFile = resolveUtsPluginSourceMapFile( + test('resolveUTSPluginSourceMapFile with uni_modules kt', () => { + const sourceMapFile = resolveUTSPluginSourceMapFile( 'kotlin', resolve(outputDir, uniModulesPluginDir, 'utssdk/app-android/index.kt'), inputDir, @@ -83,15 +83,15 @@ describe('uts:sourceMap', () => { ) expect(sourceMapFile).toBeDefined() }) - test('resolveUtsPluginSourceMapFile with uni_modules swift', () => { - const sourceMapFile = resolveUtsPluginSourceMapFile( + test('resolveUTSPluginSourceMapFile with uni_modules swift', () => { + const sourceMapFile = resolveUTSPluginSourceMapFile( 'swift', resolve(outputDir, uniModulesPluginDir, 'utssdk/app-ios/index.swift'), inputDir, outputDir ) expect(sourceMapFile).toBeDefined() - const sourceMapFile2 = resolveUtsPluginSourceMapFile( + const sourceMapFile2 = resolveUTSPluginSourceMapFile( 'swift', resolve(outputDir, uniModulesPluginDir, 'utssdk/app-ios/src/index.swift'), inputDir, @@ -99,8 +99,8 @@ describe('uts:sourceMap', () => { ) expect(sourceMapFile2).toBeDefined() }) - test('resolveUtsPluginSourceMapFile with utssdk kt', () => { - const sourceMapFile = resolveUtsPluginSourceMapFile( + test('resolveUTSPluginSourceMapFile with utssdk kt', () => { + const sourceMapFile = resolveUTSPluginSourceMapFile( 'kotlin', resolve(outputDir, utssdkPluginDir, 'app-android/index.kt'), inputDir, @@ -108,8 +108,8 @@ describe('uts:sourceMap', () => { ) expect(sourceMapFile).toBeDefined() }) - test('resolveUtsPluginSourceMapFile with utssdk swift', () => { - const sourceMapFile = resolveUtsPluginSourceMapFile( + test('resolveUTSPluginSourceMapFile with utssdk swift', () => { + const sourceMapFile = resolveUTSPluginSourceMapFile( 'swift', resolve(outputDir, utssdkPluginDir, 'app-ios/index.swift'), inputDir, @@ -123,7 +123,7 @@ describe('uts:sourceMap', () => { uniModulesPluginDir, 'utssdk/app-android/login.uts' ) - const sourceMapFile = resolveUtsPluginSourceMapFile( + const sourceMapFile = resolveUTSPluginSourceMapFile( 'kotlin', filename, inputDir, @@ -153,7 +153,7 @@ describe('uts:sourceMap', () => { uniModulesPluginDir, 'utssdk/app-android/index.kt' ) - const sourceMapFile = resolveUtsPluginSourceMapFile( + const sourceMapFile = resolveUTSPluginSourceMapFile( 'kotlin', filename, inputDir, @@ -175,7 +175,7 @@ describe('uts:sourceMap', () => { uniModulesPluginDir, 'utssdk/app-ios/src/index.kt' ) - const sourceMapFile = resolveUtsPluginSourceMapFile( + const sourceMapFile = resolveUTSPluginSourceMapFile( 'swift', filename, inputDir, diff --git a/packages/uni-uts-v1/__tests__/stacktrace.spec.ts b/packages/uni-uts-v1/__tests__/stacktrace.spec.ts index b2806827b58800b26e54e0c0c40bc7b3e270184a..fae5dcec038aa236f219178ffac9d31925cb4962 100644 --- a/packages/uni-uts-v1/__tests__/stacktrace.spec.ts +++ b/packages/uni-uts-v1/__tests__/stacktrace.spec.ts @@ -1,12 +1,12 @@ import path from 'path' -import { parseUtsSwiftPluginStacktrace } from '../src/stacktrace' -const stacktrace = `/uts-development-ios/dependences/buildFramework/template/xcode_ust_template/unimoduleTestUts1/src/index.swift:3:12: error: cannot convert return expression of type 'Int' to return type 'String' -/uts-development-ios/dependences/buildFramework/template/xcode_ust_template/unimoduleTestUts1/src/index.swift:6:12: error: cannot convert return expression of type 'Int' to return type 'String' +import { parseUTSSwiftPluginStacktrace } from '../src/stacktrace' +const stacktrace = `/uts-development-ios/dependences/buildFramework/template/xcode_ust_template/unimoduleTestUTS1/src/index.swift:3:12: error: cannot convert return expression of type 'Int' to return type 'String' +/uts-development-ios/dependences/buildFramework/template/xcode_ust_template/unimoduleTestUTS1/src/index.swift:6:12: error: cannot convert return expression of type 'Int' to return type 'String' ` describe('uts:stacktrace', () => { - test('parseUtsSwiftPluginStacktrace', async () => { - const codes = await parseUtsSwiftPluginStacktrace({ + test('parseUTSSwiftPluginStacktrace', async () => { + const codes = await parseUTSSwiftPluginStacktrace({ stacktrace, sourceMapFile: path.resolve( __dirname, diff --git a/packages/uni-uts-v1/src/index.ts b/packages/uni-uts-v1/src/index.ts index 206e1acfe853e689cc34fd9d84e1a32d6ea3edfd..6ee98072c5c14957213da76ed3f981224907487f 100644 --- a/packages/uni-uts-v1/src/index.ts +++ b/packages/uni-uts-v1/src/index.ts @@ -28,8 +28,8 @@ import { resolveIOSComponents, resolvePackage, } from './utils' -import { parseUtsSwiftPluginStacktrace } from './stacktrace' -import { resolveUtsPluginSourceMapFile } from './sourceMap' +import { parseUTSSwiftPluginStacktrace } from './stacktrace' +import { resolveUTSPluginSourceMapFile } from './sourceMap' import { isWindows } from './shared' import { generateCodeFrameWithKotlinStacktrace, @@ -311,9 +311,9 @@ export async function compile( errMsg = compileErrMsg(pkg.id) console.error( `error: ` + - (await parseUtsSwiftPluginStacktrace({ + (await parseUTSSwiftPluginStacktrace({ stacktrace: res.msg, - sourceMapFile: resolveUtsPluginSourceMapFile( + sourceMapFile: resolveUTSPluginSourceMapFile( 'swift', filename, inputDir, diff --git a/packages/uni-uts-v1/src/kotlin.ts b/packages/uni-uts-v1/src/kotlin.ts index 61914d9e4b8d60ab80161f934f28ae880eb83cc6..433e6e6dede081f0729704812deef03bb948e3ce 100644 --- a/packages/uni-uts-v1/src/kotlin.ts +++ b/packages/uni-uts-v1/src/kotlin.ts @@ -4,13 +4,13 @@ import path, { join } from 'path' import AdmZip from 'adm-zip' import { sync } from 'fast-glob' import { isArray } from '@vue/shared' -import type { UtsResult } from '@dcloudio/uts' +import type { UTSResult } from '@dcloudio/uts' import { get } from 'android-versions' import { normalizePath, parseJson, resolveSourceMapPath } from './shared' import { CompilerServer, genUTSPlatformResource, - getUtsCompiler, + getUTSCompiler, getCompilerServer, moveRootIndexSourceMap, resolveAndroidDir, @@ -88,7 +88,7 @@ export async function runKotlinProd( }) } -export type RunKotlinDevResult = UtsResult & { +export type RunKotlinDevResult = UTSResult & { type: 'kotlin' changed: string[] } @@ -300,7 +300,7 @@ export async function compile( filename: string, { inputDir, outputDir, sourceMap, components }: ToKotlinOptions ) { - const { bundle, UtsTarget } = getUtsCompiler() + const { bundle, UTSTarget } = getUTSCompiler() // let time = Date.now() const imports = [...DEFAULT_IMPORTS] const rClass = resolveAndroidResourceClass(filename) @@ -330,7 +330,7 @@ export async function compile( } } - const result = await bundle(UtsTarget.KOTLIN, { + const result = await bundle(UTSTarget.KOTLIN, { input, output: { isPlugin: true, diff --git a/packages/uni-uts-v1/src/sourceMap.ts b/packages/uni-uts-v1/src/sourceMap.ts index d22dd89a076cef4877111f648ba5e76beaa6f6ac..d8d692725de10dde2019d78e90892df488e8ff61 100644 --- a/packages/uni-uts-v1/src/sourceMap.ts +++ b/packages/uni-uts-v1/src/sourceMap.ts @@ -18,7 +18,7 @@ const PLATFORM_DIR = { swift: 'app-ios', } -export function resolveUtsPluginSourceMapFile( +export function resolveUTSPluginSourceMapFile( target: 'kotlin' | 'swift', filename: string, inputDir: string, @@ -44,6 +44,8 @@ export function resolveUtsPluginSourceMapFile( } return sourceMapFile } +// 兼容旧版本 +export const resolveUtsPluginSourceMapFile = resolveUTSPluginSourceMapFile function resolvePluginDir( inputDir: string, diff --git a/packages/uni-uts-v1/src/stacktrace.ts b/packages/uni-uts-v1/src/stacktrace.ts index d9907bb0facb46c96ec07b40e75866c95de35247..7ac4beb30822fcbc38844aff27b79c8329d492ee 100644 --- a/packages/uni-uts-v1/src/stacktrace.ts +++ b/packages/uni-uts-v1/src/stacktrace.ts @@ -1,27 +1,27 @@ import { originalPositionFor } from './sourceMap' const splitRE = /\r?\n/ -const uniModulesSwiftUtsRe = +const uniModulesSwiftUTSRe = /(.*)index.swift:([0-9]+):([0-9]+):\s+error:\s+(.*)/ -interface ParseUtsPluginStacktraceOptions { +interface ParseUTSPluginStacktraceOptions { stacktrace: string sourceRoot: string sourceMapFile: string } -export async function parseUtsSwiftPluginStacktrace({ +export async function parseUTSSwiftPluginStacktrace({ stacktrace, sourceRoot, sourceMapFile, -}: ParseUtsPluginStacktraceOptions) { +}: ParseUTSPluginStacktraceOptions) { const res: string[] = [] const lines = stacktrace.split(splitRE) for (let i = 0; i < lines.length; i++) { const line = lines[i] - const codes = await parseUtsStacktraceLine( + const codes = await parseUTSStacktraceLine( line, - uniModulesSwiftUtsRe, + uniModulesSwiftUTSRe, sourceMapFile, sourceRoot ) @@ -34,7 +34,7 @@ export async function parseUtsSwiftPluginStacktrace({ return res.join('\n') } -async function parseUtsStacktraceLine( +async function parseUTSStacktraceLine( lineStr: string, re: RegExp, sourceMapFile: string, diff --git a/packages/uni-uts-v1/src/swift.ts b/packages/uni-uts-v1/src/swift.ts index 7628db41bc087836fcb955331028433a0ef937b4..eb7c08c912a97317f032156ec9bcfc08cd49942a 100644 --- a/packages/uni-uts-v1/src/swift.ts +++ b/packages/uni-uts-v1/src/swift.ts @@ -4,7 +4,7 @@ import { genComponentsCode, genUTSPlatformResource, getCompilerServer, - getUtsCompiler, + getUTSCompiler, isColorSupported, moveRootIndexSourceMap, parseSwiftPackageWithPluginId, @@ -15,7 +15,7 @@ import { ToSwiftOptions, } from './utils' import { parseJson } from './shared' -import { UtsResult } from '@dcloudio/uts' +import { UTSResult } from '@dcloudio/uts' function parseSwiftPackage(filename: string) { const res = resolvePackage(filename) @@ -61,7 +61,7 @@ export async function runSwiftProd( }) } -export type RunSwiftDevResult = UtsResult & { +export type RunSwiftDevResult = UTSResult & { type: 'swift' code: number msg: string @@ -132,7 +132,7 @@ export async function runSwiftDev( isCli, type: is_uni_modules ? 1 : 2, pluginName: id, - utsPath: resolveCompilerUtsPath(inputDir, is_uni_modules), + utsPath: resolveCompilerUTSPath(inputDir, is_uni_modules), swiftPath: resolveCompilerSwiftPath(outputDir, is_uni_modules), }) result.code = code @@ -142,7 +142,7 @@ export async function runSwiftDev( return result } -function resolveCompilerUtsPath(projectPath: string, is_uni_modules: boolean) { +function resolveCompilerUTSPath(projectPath: string, is_uni_modules: boolean) { return path.resolve(projectPath, is_uni_modules ? 'uni_modules' : 'utssdk') } @@ -161,7 +161,7 @@ export async function compile( filename: string, { inputDir, outputDir, sourceMap, components }: ToSwiftOptions ) { - const { bundle, UtsTarget } = getUtsCompiler() + const { bundle, UTSTarget } = getUTSCompiler() // let time = Date.now() const componentsCode = genComponentsCode(filename, components) const { namespace, id: pluginId } = parseSwiftPackage(filename) @@ -185,7 +185,7 @@ export async function compile( return } } - const result = await bundle(UtsTarget.SWIFT, { + const result = await bundle(UTSTarget.SWIFT, { input, output: { isPlugin: true, diff --git a/packages/uni-uts-v1/src/utils.ts b/packages/uni-uts-v1/src/utils.ts index 48553bd7c94c54cf02bb54aaa8b22e389b248e64..6d2c5984b39312a55ae28dcc12b95700c7b0e640 100644 --- a/packages/uni-uts-v1/src/utils.ts +++ b/packages/uni-uts-v1/src/utils.ts @@ -1,6 +1,6 @@ import path, { basename, resolve } from 'path' import fs from 'fs-extra' -import type { parse, bundle, UtsTarget } from '@dcloudio/uts' +import type { parse, bundle, UTSTarget } from '@dcloudio/uts' import { camelize, capitalize, extend } from '@vue/shared' import glob from 'fast-glob' import { Module, ModuleItem } from '../types/types' @@ -28,10 +28,10 @@ export function resolveUTSSourceMapPath() { return resolveSourceMapPath() } -export function getUtsCompiler(): { +export function getUTSCompiler(): { parse: typeof parse bundle: typeof bundle - UtsTarget: typeof UtsTarget + UTSTarget: typeof UTSTarget } { // eslint-disable-next-line no-restricted-globals return require('@dcloudio/uts') diff --git a/packages/uts/src/api.ts b/packages/uts/src/api.ts index 09083aac30aa510909b48dcf636cfdad4aba334c..eb4770252139d6ef2f7dd287baea22afe7f12bc6 100644 --- a/packages/uts/src/api.ts +++ b/packages/uts/src/api.ts @@ -1,9 +1,9 @@ import { resolve } from 'path' import type { - UtsBundleOptions, - UtsOptions, - UtsParseOptions, - UtsResult, + UTSBundleOptions, + UTSOptions, + UTSParseOptions, + UTSResult, } from './types' import { normalizePath } from './utils' @@ -12,7 +12,7 @@ const bindings = !!bindingsOverride ? require(resolve(bindingsOverride)) : require('./binding').default -function resolveOptions(options: UtsOptions) { +function resolveOptions(options: UTSOptions) { const { input, output } = options if (!input?.root) { return @@ -46,14 +46,14 @@ function resolveOptions(options: UtsOptions) { return options } -export function parse(source: string, options: UtsParseOptions = {}) { +export function parse(source: string, options: UTSParseOptions = {}) { options.noColor = !!options.noColor return bindings .parse(source, toBuffer(options)) .then((res: string) => JSON.parse(res)) } -export function toKotlin(options: UtsOptions): Promise { +export function toKotlin(options: UTSOptions): Promise { const kotlinOptions = resolveOptions(options) if (!kotlinOptions) { return Promise.resolve({}) @@ -63,7 +63,7 @@ export function toKotlin(options: UtsOptions): Promise { .then((res: string) => JSON.parse(res)) } -export function bundleKotlin(options: UtsBundleOptions): Promise { +export function bundleKotlin(options: UTSBundleOptions): Promise { const bundleOptions = resolveOptions(options) if (!bundleOptions) { return Promise.resolve({}) @@ -73,7 +73,7 @@ export function bundleKotlin(options: UtsBundleOptions): Promise { .then((res: string) => JSON.parse(res)) } -export function toSwift(options: UtsOptions): Promise { +export function toSwift(options: UTSOptions): Promise { const swiftOptions = resolveOptions(options) if (!swiftOptions) { return Promise.resolve({}) @@ -83,7 +83,7 @@ export function toSwift(options: UtsOptions): Promise { .then((res: string) => JSON.parse(res)) } -export function bundleSwift(options: UtsBundleOptions): Promise { +export function bundleSwift(options: UTSBundleOptions): Promise { const bundleOptions = resolveOptions(options) if (!bundleOptions) { return Promise.resolve({}) diff --git a/packages/uts/src/index.ts b/packages/uts/src/index.ts index 300615241d33b626b7736ecbaf819d9de79d7fab..00687e211a2ddb7767fe80234dfea0bd85471dc1 100644 --- a/packages/uts/src/index.ts +++ b/packages/uts/src/index.ts @@ -1,13 +1,13 @@ import { bundleKotlin, bundleSwift } from './api' -import { UtsBundleOptions, UtsResult, UtsTarget } from './types' +import { UTSBundleOptions, UTSResult, UTSTarget } from './types' -export { UtsTarget, UtsResult } from './types' +export { UTSTarget, UTSResult } from './types' -export type UtsMode = 'dev' | 'build' +export type UTSMode = 'dev' | 'build' -export const UtsTargetExtNames = { - [UtsTarget.KOTLIN]: 'kt', - [UtsTarget.SWIFT]: 'swift', +export const UTSTargetExtNames = { + [UTSTarget.KOTLIN]: 'kt', + [UTSTarget.SWIFT]: 'swift', } as const export interface ToOptions { /** @@ -52,12 +52,12 @@ export interface ToOptions { export { parse, bundleKotlin, bundleSwift } from './api' export function bundle( - target: UtsTarget, - opts: UtsBundleOptions -): Promise { - if (target === UtsTarget.KOTLIN) { + target: UTSTarget, + opts: UTSBundleOptions +): Promise { + if (target === UTSTarget.KOTLIN) { return bundleKotlin(opts) - } else if (target === UtsTarget.SWIFT) { + } else if (target === UTSTarget.SWIFT) { return bundleSwift(opts) } return Promise.resolve({}) diff --git a/packages/uts/src/types.ts b/packages/uts/src/types.ts index 459ee26bcbb4350635e679afff0d95f33e038511..afca0e031992c9dec53837db58e9890927b7f29a 100644 --- a/packages/uts/src/types.ts +++ b/packages/uts/src/types.ts @@ -1,21 +1,21 @@ -export enum UtsTarget { +export enum UTSTarget { KOTLIN = 'kotlin', SWIFT = 'swift', } -export interface UtsParserConfig { +export interface UTSParserConfig { /** * Defaults to `false` */ allowImportWithoutSpecifiers?: boolean } -export type UtsParseOptions = UtsParserConfig & { +export type UTSParseOptions = UTSParserConfig & { filename?: string comments?: boolean noColor?: boolean } -export type UtsInputOptions = UtsParseOptions & { +export type UTSInputOptions = UTSParseOptions & { root: string pluginId: string filename: string @@ -24,7 +24,7 @@ export type UtsInputOptions = UtsParseOptions & { paths: Record } -export type UtsOutputOptions = { +export type UTSOutputOptions = { outDir: string package: string imports?: string[] @@ -35,16 +35,16 @@ export type UtsOutputOptions = { noColor?: boolean isPlugin?: boolean } -export interface UtsOptions { - input: UtsInputOptions - output: UtsOutputOptions +export interface UTSOptions { + input: UTSInputOptions + output: UTSOutputOptions } -export interface UtsResult { +export interface UTSResult { filename?: string deps?: string[] time?: number error?: Error } -export interface UtsBundleOptions extends UtsOptions {} +export interface UTSBundleOptions extends UTSOptions {} diff --git a/packages/vite-plugin-uni/src/cli/utils.ts b/packages/vite-plugin-uni/src/cli/utils.ts index 8796c1155aa8b0b17fe1e9efe15154deaa54c59d..23abda2e365ca0518305e084de9b9dee55177e8b 100644 --- a/packages/vite-plugin-uni/src/cli/utils.ts +++ b/packages/vite-plugin-uni/src/cli/utils.ts @@ -88,7 +88,7 @@ export function initEnv( : process.cwd() // TODO 待优化 - initUtsPlatform(options) + initUTSPlatform(options) if ( options.platform === 'quickapp-webview-huawei' || @@ -170,7 +170,7 @@ export function initEnv( console.log(M['compiling']) } -function initUtsPlatform(options: CliOptions) { +function initUTSPlatform(options: CliOptions) { if (options.platform === 'app-android') { process.env.UNI_UTS_PLATFORM = 'app-android' options.platform = 'app' diff --git a/packages/vite-plugin-uni/src/config/resolve.ts b/packages/vite-plugin-uni/src/config/resolve.ts index d4d7b920c728e049d8a6c8b2cfc3d8154c8b7a5f..88ba97004b3e6c7d590c08ca50f22bab0b145efb 100644 --- a/packages/vite-plugin-uni/src/config/resolve.ts +++ b/packages/vite-plugin-uni/src/config/resolve.ts @@ -5,13 +5,13 @@ import { extensions, normalizePath, requireResolve, - resolveUtsModule, - resolveUtsAppModule, + resolveUTSModule, + resolveUTSAppModule, } from '@dcloudio/uni-cli-shared' import { VitePluginUniResolvedOptions } from '..' -function resolveUtsModuleProxyFile(id: string, importer: string) { - const file = resolveUtsAppModule(id, importer) +function resolveUTSModuleProxyFile(id: string, importer: string) { + const file = resolveUTSAppModule(id, importer) if (file) { return file + '?uts-proxy' } @@ -23,8 +23,8 @@ export const customResolver: ResolverFunction = (updatedId, importer) => { : process.env.UNI_INPUT_DIR const utsModuleFile = process.env.UNI_PLATFORM === 'app' - ? resolveUtsModuleProxyFile(updatedId, utsImporter) - : resolveUtsModule(updatedId, utsImporter) + ? resolveUTSModuleProxyFile(updatedId, utsImporter) + : resolveUTSModule(updatedId, utsImporter) if (utsModuleFile) { return isWindows ? normalizePath(utsModuleFile) : utsModuleFile } diff --git a/packages/vite-plugin-uni/src/configResolved/plugins/resolveId.ts b/packages/vite-plugin-uni/src/configResolved/plugins/resolveId.ts index 181f6bcf1b3786e035644360e414f6d0e1bcd710..78150faa25f9f9b29a334648dfb64f3d2ab11472 100644 --- a/packages/vite-plugin-uni/src/configResolved/plugins/resolveId.ts +++ b/packages/vite-plugin-uni/src/configResolved/plugins/resolveId.ts @@ -1,7 +1,7 @@ import path from 'path' import debug from 'debug' import { Plugin } from 'vite' -import { resolveBuiltIn, resolveUtsModule } from '@dcloudio/uni-cli-shared' +import { resolveBuiltIn, resolveUTSModule } from '@dcloudio/uni-cli-shared' import { VitePluginUniResolvedOptions } from '../..' @@ -40,7 +40,7 @@ export function uniResolveIdPlugin( )) } if (process.env.UNI_PLATFORM !== 'app') { - return resolveUtsModule( + return resolveUTSModule( id, importer ? path.dirname(importer) : process.env.UNI_INPUT_DIR ) diff --git a/scripts/test.js b/scripts/test.js index bfa1a4d52a38c90888fb8ec1546ea4d12c69a6af..2f4d3cfc30cbaaca0ad50b9290a5c16c2ce7ad28 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -1,6 +1,6 @@ const fs = require('fs') const path = require('path') -const { parse, bundle, UtsTarget } = require('../packages/uts/dist') +const { parse, bundle, UTSTarget } = require('../packages/uts/dist') const projectDir = path.resolve(__dirname, '../packages/playground/uts') const outDir = path.resolve(projectDir, 'unpackage/dist/dev/app-plus') @@ -21,7 +21,7 @@ parse( }) async function testKotlin() { const start = Date.now() - await bundle(UtsTarget.KOTLIN, { + await bundle(UTSTarget.KOTLIN, { input: { root: projectDir, filename: path.resolve( @@ -60,7 +60,7 @@ async function testKotlin() { ) ) }) - await bundle(UtsTarget.KOTLIN, { + await bundle(UTSTarget.KOTLIN, { input: { root: projectDir, filename: path.resolve( @@ -89,7 +89,7 @@ async function testKotlin() { async function testKotlinComponent() { const start = Date.now() - await bundle(UtsTarget.KOTLIN, { + await bundle(UTSTarget.KOTLIN, { input: { root: projectDir, pluginId: 'animation-view', @@ -131,7 +131,7 @@ async function testKotlinComponent() { async function testSwift() { const start = Date.now() - await bundle(UtsTarget.SWIFT, { + await bundle(UTSTarget.SWIFT, { input: { root: projectDir, filename: path.resolve( @@ -161,7 +161,7 @@ async function testSwift() { ) ) }) - await bundle(UtsTarget.SWIFT, { + await bundle(UTSTarget.SWIFT, { input: { root: projectDir, filename: path.resolve( @@ -183,7 +183,7 @@ async function testSwift() { async function testSwiftComponent() { const start = Date.now() - await bundle(UtsTarget.SWIFT, { + await bundle(UTSTarget.SWIFT, { input: { root: projectDir, filename: path.resolve(