diff --git a/packages/uni-cli-shared/src/messages/zh_CN.ts b/packages/uni-cli-shared/src/messages/zh_CN.ts index 64c59f8dd182754447458760b26ba21970aa19b9..c43e86db8af46f30b531ca3b81753352307a02d3 100644 --- a/packages/uni-cli-shared/src/messages/zh_CN.ts +++ b/packages/uni-cli-shared/src/messages/zh_CN.ts @@ -31,7 +31,7 @@ export default { 'uts.android.compiler.server': '项目使用了uts插件,正在安装 uts Android 运行扩展...', 'uts.ios.windows.tips': - 'iOS手机在windows上真机运行时uts插件代码修改需提交云端打包自定义基座才能生效', + 'iOS手机在windows上使用标准基座真机运行无法使用uts插件,如需使用uts插件请提交云端打包自定义基座', 'uts.ios.standard.tips': 'iOS手机在标准基座真机运行暂不支持uts插件,如需调用uts插件请使用自定义基座', } as const diff --git a/packages/uni-h5/dist/uni-h5.es.js b/packages/uni-h5/dist/uni-h5.es.js index 8535b80ddda498fff9f3eb80eb6b5868c1afa605..0d51275547d1fea55dcabc9fc4b4d02d4a26e7a1 100644 --- a/packages/uni-h5/dist/uni-h5.es.js +++ b/packages/uni-h5/dist/uni-h5.es.js @@ -67,7 +67,7 @@ function useI18n() { let locale; { { - locale = window.localStorage && localStorage[UNI_STORAGE_LOCALE] || __uniConfig.locale || navigator.language; + locale = navigator.cookieEnabled && window.localStorage && localStorage[UNI_STORAGE_LOCALE] || __uniConfig.locale || navigator.language; } } i18n = initVueI18n(locale); @@ -5086,7 +5086,7 @@ const setLocale = /* @__PURE__ */ defineSyncApi( if (oldLocale !== locale) { app.$vm.$locale = locale; { - window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale); + navigator.cookieEnabled && window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale); } UniServiceJSBridge.invokeOnCallback(API_ON_LOCALE_CHANGE, { locale }); return true; @@ -15622,7 +15622,7 @@ function setupApp(comp) { const route = usePageRoute(); const onLaunch = () => { injectAppHooks(instance2); - const { onLaunch: onLaunch2, onShow, onPageNotFound: onPageNotFound2 } = instance2; + const { onLaunch: onLaunch2, onShow, onPageNotFound: onPageNotFound2, onError: onError2 } = instance2; const path = route.path.slice(1); const launchOptions2 = initLaunchOptions({ path: path || __uniRoutes[0].meta.route, @@ -15642,6 +15642,11 @@ function setupApp(comp) { onPageNotFound2 && invokeArrayFns$1(onPageNotFound2, pageNotFoundOptions); } } + if (onError2) { + instance2.appContext.config.errorHandler = (err) => { + invokeArrayFns$1(onError2, err); + }; + } }; if (__UNI_FEATURE_PAGES__) { useRouter().isReady().then(onLaunch); @@ -17915,7 +17920,7 @@ const makePhoneCall = /* @__PURE__ */ defineAsyncApi( MakePhoneCallProtocol ); const UUID_KEY = "__DC_STAT_UUID"; -const storage = window.localStorage || window.sessionStorage || {}; +const storage = navigator.cookieEnabled && (window.localStorage || window.sessionStorage) || {}; let deviceId; function deviceId$1() { deviceId = deviceId || storage[UUID_KEY]; diff --git a/packages/uni-mp-weixin/dist/uni.compiler.js b/packages/uni-mp-weixin/dist/uni.compiler.js index d47b3e45330d467e6df4915ed28ad27b6a8d92af..b26a19b76ba05cea64889735f988902f18dd2a72 100644 --- a/packages/uni-mp-weixin/dist/uni.compiler.js +++ b/packages/uni-mp-weixin/dist/uni.compiler.js @@ -16,13 +16,13 @@ var uniad_app_json = function (appJson) { } if (!appJson.plugins['uni-ad']) { appJson.plugins['uni-ad'] = { - version: '1.0.1', + version: '1.1.1', provider: 'wxf72d316417b6767f', }; } if (!appJson.plugins['coral-adv']) { appJson.plugins['coral-adv'] = { - version: '1.0.9', + version: '1.0.15', provider: 'wx0e203209e27b1e66', }; } diff --git a/packages/uni-uts-v1/src/code.ts b/packages/uni-uts-v1/src/code.ts index c6732590a6ed7de62bc8e573652621d999f0edaf..d82780d116fd1f59d6b6c45953d9fd501bcab85b 100644 --- a/packages/uni-uts-v1/src/code.ts +++ b/packages/uni-uts-v1/src/code.ts @@ -1,7 +1,7 @@ import fs from 'fs' import path from 'path' -import { camelize, capitalize, isArray } from '@vue/shared' +import { camelize, capitalize, hasOwn, isArray } from '@vue/shared' import type { ArrowFunctionExpression, @@ -16,6 +16,7 @@ import type { Param, Span, TsFnParameter, + TsType, TsTypeAnnotation, VariableDeclaration, VariableDeclarationKind, @@ -470,17 +471,19 @@ function parseAst( switch (decl.type) { case 'FunctionDeclaration': decls.push( - genFunctionDeclaration(decl, resolveTypeReferenceName, false) + genFunctionDeclaration(types, decl, resolveTypeReferenceName, false) ) break case 'ClassDeclaration': - decls.push(genClassDeclaration(decl, resolveTypeReferenceName, false)) + decls.push( + genClassDeclaration(types, decl, resolveTypeReferenceName, false) + ) break case 'VariableDeclaration': const varDecl = genVariableDeclaration( + types, decl, - resolveTypeReferenceName, - types + resolveTypeReferenceName ) if (varDecl) { decls.push(varDecl) @@ -492,12 +495,14 @@ function parseAst( if (decl.type === 'ClassExpression') { if (decl.identifier) { // export default class test{} - decls.push(genClassDeclaration(decl, resolveTypeReferenceName, true)) + decls.push( + genClassDeclaration(types, decl, resolveTypeReferenceName, true) + ) } } else if (decl.type === 'FunctionExpression') { if (decl.identifier) { decls.push( - genFunctionDeclaration(decl, resolveTypeReferenceName, true) + genFunctionDeclaration(types, decl, resolveTypeReferenceName, true) ) } } @@ -571,47 +576,57 @@ function resolveIdentifierDefaultValue(ident: Expression) { return null } +function resolveType( + types: Types, + typeAnnotation: TsType, + resolveTypeReferenceName: ResolveTypeReferenceName +): string { + if (typeAnnotation.type === 'TsKeywordType') { + return typeAnnotation.kind + } else if (typeAnnotation.type === 'TsFunctionType') { + return 'UTSCallback' + } else if ( + typeAnnotation.type === 'TsTypeReference' && + typeAnnotation.typeName.type === 'Identifier' + ) { + if (hasOwn(types.fn, typeAnnotation.typeName.value)) { + return 'UTSCallback' + } + return resolveTypeReferenceName(typeAnnotation.typeName.value) + } else if (typeAnnotation.type === 'TsParenthesizedType') { + return resolveType( + types, + typeAnnotation.typeAnnotation, + resolveTypeReferenceName + ) + } else if (typeAnnotation.type === 'TsUnionType') { + for (const type of typeAnnotation.types) { + if (type.type === 'TsKeywordType') { + continue + } + return resolveType(types, type, resolveTypeReferenceName) + } + } + return '' +} + function resolveIdentifierType( + types: Types, ident: BindingIdentifier, resolveTypeReferenceName: ResolveTypeReferenceName ) { if (ident.typeAnnotation) { - const { typeAnnotation } = ident.typeAnnotation - if (typeAnnotation.type === 'TsKeywordType') { - return typeAnnotation.kind - } else if (typeAnnotation.type === 'TsFunctionType') { - return 'UTSCallback' - } else if ( - typeAnnotation.type === 'TsTypeReference' && - typeAnnotation.typeName.type === 'Identifier' - ) { - return resolveTypeReferenceName(typeAnnotation.typeName.value) - } else if (typeAnnotation.type === 'TsUnionType') { - if (typeAnnotation.types.length === 2) { - const [type1, type2] = typeAnnotation.types - if (type1.type === 'TsKeywordType' && type1.kind === 'null') { - if ( - type2.type === 'TsParenthesizedType' && - type2.typeAnnotation.type === 'TsFunctionType' - ) { - return 'UTSCallback' - } - } - if (type2.type === 'TsKeywordType' && type2.kind === 'null') { - if ( - type1.type === 'TsParenthesizedType' && - type1.typeAnnotation.type === 'TsFunctionType' - ) { - return 'UTSCallback' - } - } - } - } + return resolveType( + types, + ident.typeAnnotation.typeAnnotation, + resolveTypeReferenceName + ) } return '' } function resolveFunctionParams( + types: Types, params: Param[], resolveTypeReferenceName: ResolveTypeReferenceName ) { @@ -621,6 +636,7 @@ function resolveFunctionParams( result.push({ name: pat.value, type: resolveIdentifierType( + types, pat as BindingIdentifier, resolveTypeReferenceName ), @@ -630,6 +646,7 @@ function resolveFunctionParams( const param: Parameter = { name: pat.left.value, type: resolveIdentifierType( + types, pat.left as BindingIdentifier, resolveTypeReferenceName ), @@ -648,6 +665,7 @@ function resolveFunctionParams( } function genFunctionDeclaration( + types: Types, decl: FunctionDeclaration | FunctionExpression, resolveTypeReferenceName: ResolveTypeReferenceName, isDefault: boolean = false, @@ -656,13 +674,14 @@ function genFunctionDeclaration( return genProxyFunction( decl.identifier!.value, decl.async || isReturnPromise(decl.returnType), - resolveFunctionParams(decl.params, resolveTypeReferenceName), + resolveFunctionParams(types, decl.params, resolveTypeReferenceName), isDefault, isVar ) } function genClassDeclaration( + types: Types, decl: ClassDeclaration | ClassExpression, resolveTypeReferenceName: ResolveTypeReferenceName, isDefault: boolean = false @@ -679,6 +698,7 @@ function genClassDeclaration( decl.body.forEach((item) => { if (item.type === 'Constructor') { constructor.params = resolveFunctionParams( + types, item.params as Param[], resolveTypeReferenceName ) @@ -689,6 +709,7 @@ function genClassDeclaration( async: item.function.async || isReturnPromise(item.function.returnType), params: resolveFunctionParams( + types, item.function.params, resolveTypeReferenceName ), @@ -729,9 +750,9 @@ function genInitCode(expr: Expression) { } function genVariableDeclaration( + types: Types, decl: VariableDeclaration, - resolveTypeReferenceName: ResolveTypeReferenceName, - types: Types + resolveTypeReferenceName: ResolveTypeReferenceName ): VariableDeclaration | ProxyFunctionDeclaration | undefined { // 目前仅支持 const 的 boolean,number,string const lits = ['BooleanLiteral', 'NumericLiteral', 'StringLiteral'] @@ -775,6 +796,7 @@ function genVariableDeclaration( } } return genFunctionDeclaration( + types, createFunctionDeclaration(id.value, init, params), resolveTypeReferenceName, false, diff --git a/packages/uni-uts-v1/src/index.ts b/packages/uni-uts-v1/src/index.ts index 3a6fa7e7f9a5f9d7edfbd048b9ff700e94f45669..d9093ed69c3c267e7287d5ba2f61005f6b890264 100644 --- a/packages/uni-uts-v1/src/index.ts +++ b/packages/uni-uts-v1/src/index.ts @@ -212,7 +212,7 @@ export async function compile( // iOS windows 平台,标准基座不编译 if (utsPlatform === 'app-ios') { if (isWindows) { - process.env.UNI_UTS_TIPS = `iOS手机在windows上真机运行时uts插件代码修改需提交云端打包自定义基座才能生效` + process.env.UNI_UTS_ERRORS = `iOS手机在windows上使用标准基座真机运行无法使用uts插件,如需使用uts插件请提交云端打包自定义基座` return createResult(outputPluginDir, errMsg, code, deps, meta) } // ios 模拟器不支持 diff --git a/packages/uts-darwin-arm64/uts.darwin-arm64.node b/packages/uts-darwin-arm64/uts.darwin-arm64.node index dab1234a04c5799910a80e95e85d3621d61a4838..f43faf139dc8922fb61764c0e00c1c834fa72398 100755 Binary files a/packages/uts-darwin-arm64/uts.darwin-arm64.node and b/packages/uts-darwin-arm64/uts.darwin-arm64.node differ diff --git a/packages/uts-darwin-x64/uts.darwin-x64.node b/packages/uts-darwin-x64/uts.darwin-x64.node index 6b6762005950b1956defb8ad595c17d1e1117100..2f66db51d0ff4ae5e17a15c78b00c286fa3776d0 100755 Binary files a/packages/uts-darwin-x64/uts.darwin-x64.node and b/packages/uts-darwin-x64/uts.darwin-x64.node differ diff --git a/packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node b/packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node index 104992fc4f046b5e8b558d51b22ec89b920e6982..46cb05d270fa7b5adbe4c3f2dec95e1a475ff51a 100755 Binary files a/packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node and b/packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node differ diff --git a/packages/uts-linux-x64-musl/uts.linux-x64-musl.node b/packages/uts-linux-x64-musl/uts.linux-x64-musl.node index 357f4052cfa34adf8db36740da6e552bc9094b12..88a8510bb8e859d08dad760c4532af56efbda305 100755 Binary files a/packages/uts-linux-x64-musl/uts.linux-x64-musl.node and b/packages/uts-linux-x64-musl/uts.linux-x64-musl.node differ diff --git a/packages/vite-plugin-uni/src/cli/action.ts b/packages/vite-plugin-uni/src/cli/action.ts index 9158e5f05151114676658878502afcf7e38429fa..c3637e35b3f387c8de367f129178835f36472866 100644 --- a/packages/vite-plugin-uni/src/cli/action.ts +++ b/packages/vite-plugin-uni/src/cli/action.ts @@ -54,6 +54,9 @@ export async function runDev(options: CliOptions & ServerOptions) { isFirstEnd = false output('log', M['dev.watching.end']) printStartupDuration(createLogger(options.logLevel), false) + if (process.env.UNI_UTS_ERRORS) { + console.error(process.env.UNI_UTS_ERRORS) + } if (process.env.UNI_UTS_TIPS) { console.warn(process.env.UNI_UTS_TIPS) }