提交 312fa934 编写于 作者: fxy060608's avatar fxy060608

wip(uts): Uts -> UTS

上级 7ea00805
{"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<XToast<unknown>>(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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line 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<XToast<unknown>>(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":[],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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
......@@ -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;
......
......@@ -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);
......
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()),
......
......@@ -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
)
......
......@@ -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']
) {
......
......@@ -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<ResolvedId | null> => {
const id = resolveUtsModule(
const id = resolveUTSModule(
source,
importer || process.env.UNI_INPUT_DIR
)
......
......@@ -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<UtsJSONObject> = CoroutineScope(Dispatchers.Default).async {
)}:59:67: error: unresolved reference: UTSJSONObject
open suspend fun testClassAsync(opts: AsyncOptions): Deferred<UTSJSONObject> = 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<UtsJSONObject> = CoroutineScope(Dispatchers.Default).async {
error: unresolved reference: UTSJSONObject
open suspend fun testClassAsync(opts: AsyncOptions): Deferred<UTSJSONObject> = CoroutineScope(Dispatchers.Default).async {
^
`)
})
......
......@@ -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.`
......
......@@ -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
......
......@@ -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"}]})
......
......@@ -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()
......
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,
......
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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
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,
......
......@@ -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,
......
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')
......
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<UtsResult> {
export function toKotlin(options: UTSOptions): Promise<UTSResult> {
const kotlinOptions = resolveOptions(options)
if (!kotlinOptions) {
return Promise.resolve({})
......@@ -63,7 +63,7 @@ export function toKotlin(options: UtsOptions): Promise<UtsResult> {
.then((res: string) => JSON.parse(res))
}
export function bundleKotlin(options: UtsBundleOptions): Promise<UtsResult> {
export function bundleKotlin(options: UTSBundleOptions): Promise<UTSResult> {
const bundleOptions = resolveOptions(options)
if (!bundleOptions) {
return Promise.resolve({})
......@@ -73,7 +73,7 @@ export function bundleKotlin(options: UtsBundleOptions): Promise<UtsResult> {
.then((res: string) => JSON.parse(res))
}
export function toSwift(options: UtsOptions): Promise<UtsResult> {
export function toSwift(options: UTSOptions): Promise<UTSResult> {
const swiftOptions = resolveOptions(options)
if (!swiftOptions) {
return Promise.resolve({})
......@@ -83,7 +83,7 @@ export function toSwift(options: UtsOptions): Promise<UtsResult> {
.then((res: string) => JSON.parse(res))
}
export function bundleSwift(options: UtsBundleOptions): Promise<UtsResult> {
export function bundleSwift(options: UTSBundleOptions): Promise<UTSResult> {
const bundleOptions = resolveOptions(options)
if (!bundleOptions) {
return Promise.resolve({})
......
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<UtsResult> {
if (target === UtsTarget.KOTLIN) {
target: UTSTarget,
opts: UTSBundleOptions
): Promise<UTSResult> {
if (target === UTSTarget.KOTLIN) {
return bundleKotlin(opts)
} else if (target === UtsTarget.SWIFT) {
} else if (target === UTSTarget.SWIFT) {
return bundleSwift(opts)
}
return Promise.resolve({})
......
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<string, string>
}
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 {}
......@@ -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'
......
......@@ -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
}
......
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
)
......
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(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册