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

wip(uts): compiler

上级 21aec087
import { UIDevice } from 'UIKit'
type GetBatteryInfoOptions = {
name: string
pwd: number
success?: (res: UTSJSONObject) => void
fail?: (res: UTSJSONObject) => void
complete?: (res: UTSJSONObject) => void
......@@ -18,4 +20,15 @@ export default async function getBatteryInfo(options: GetBatteryInfoOptions) {
if (options.complete != null) {
options.complete!(res)
}
}
\ No newline at end of file
}
export function test1() {
console.log('test1')
}
class Test1 {}
export class Test {
constructor() {
new Test1()
}
}
import DCUTSPlugin;
import UIKit;
class GetBatteryInfoOptions : UTSJSONObject {
var name: String;
var pwd: NSNumber;
var success: UTSCallback?;
var fail: UTSCallback?;
var complete: UTSCallback?;
init(_ success: UTSCallback, _ fail: UTSCallback, _ complete: UTSCallback){
init(_ name: String, _ pwd: NSNumber, _ success: UTSCallback, _ fail: UTSCallback, _ complete: UTSCallback){
self.name = name;
self.pwd = pwd;
self.success = success;
self.fail = fail;
self.complete = complete;
}
}
class Test1 : NSObject {
}
class Test : NSObject {
init(){
Test1();
}
}
@objc(UTSSDKModulesTestUniPluginIndexSwift)
@objcMembers
class IndexSwift : NSObject {
......@@ -19,7 +30,14 @@ class IndexSwift : NSObject {
"level": UIDevice.current.batteryLevel * 100,
"isCharging": UIDevice.current.batteryState == UIDevice.BatteryState.charging
] as [String: Any];
if (options.success != nil) options.success!(res);
if (options.complete != nil) options.complete!(res);
if (options.success != nil) {
options.success!(res);
}
if (options.complete != nil) {
options.complete!(res);
}
}
static func test1() {
console.log("test1", " at uni_modules/test-uniplugin/app-ios/index.uts:26");
}
}
{"version":3,"sources":["/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-ios/index.uts"],"sourcesContent":["import { UIDevice } from 'UIKit'\n\ntype GetBatteryInfoOptions = {\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\n\nexport default async function getBatteryInfo(options: GetBatteryInfoOptions) {\n const res = {\n errMsg: 'getBatteryInfo:ok',\n level: UIDevice.current.batteryLevel * 100,\n isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,\n }\n if (options.success != null) {\n options.success!(res)\n }\n if (options.complete != null) {\n options.complete!(res)\n }\n}"],"names":[],"mappings":";AAAA;AAE6B,MAAxB,qBAAqB;IACxB,IAAA,OAAO,EAAC,WAA8B,EAAA;IACtC,IAAA,IAAI,EAAC,WAA8B,EAAA;IACnC,IAAA,QAAQ,EAAC,WAA8B,EAAA;WAFvC,OAAO,EAAC,WAA8B,IACtC,IAAI,EAAC,WAA8B,IACnC,QAAQ,EAAC,WAA8B;;;;;CACxC;;;;sBAE6B,cAAc,CAAC,EAAA,OAA8B,EAArB,qBAAqB,EAAE;QAC3E,IAAM,GAAG,GAAG;YACV,CAAA,MAAM,GAAE,mBAAmB;YAC3B,CAAA,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG;YAC1C,CAAA,UAAU,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,QAAQ;0BAC5E;QACD,IAAI,OAAO,CAAC,OAAO,IAAI,GAAI,EACzB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;QAEvB,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAI,EAC1B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;IAE1B"}
\ No newline at end of file
{"version":3,"sources":["/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-ios/index.uts"],"sourcesContent":["import { UIDevice } from 'UIKit'\n\ntype GetBatteryInfoOptions = {\n name: string\n pwd: number\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\n\nexport default async function getBatteryInfo(options: GetBatteryInfoOptions) {\n const res = {\n errMsg: 'getBatteryInfo:ok',\n level: UIDevice.current.batteryLevel * 100,\n isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,\n }\n if (options.success != null) {\n options.success!(res)\n }\n if (options.complete != null) {\n options.complete!(res)\n }\n}\n\nexport function test1() {\n console.log('test1')\n}\n\nclass Test1 {}\nexport class Test {\n constructor() {\n new Test1()\n }\n}\n"],"names":[],"mappings":";AAAA;AAE6B,MAAxB,qBAAqB;IACxB,IAAA,IAAI,EAAE,MAAM,CAAA;IACZ,IAAA,GAAG,EAAE,QAAM,CAAA;IACX,IAAA,OAAO,EAAC,WAA8B,EAAA;IACtC,IAAA,IAAI,EAAC,WAA8B,EAAA;IACnC,IAAA,QAAQ,EAAC,WAA8B,EAAA;WAJvC,IAAI,EAAE,MAAM,IACZ,GAAG,EAAE,QAAM,IACX,OAAO,EAAC,WAA8B,IACtC,IAAI,EAAC,WAA8B,IACnC,QAAQ,EAAC,WAA8B;;;;;;;CACxC;AAoBD,MAAM,KAAK;CAAG;AACP,MAAM,IAAI;IACf,MAAc;QACZ,AAAI,KAAK,EAAE;IACb;CACD;;;;sBAvB6B,cAAc,CAAC,EAAA,OAA8B,EAArB,qBAAqB,EAAE;QAC3E,IAAM,GAAG,GAAG;YACV,CAAA,MAAM,GAAE,mBAAmB;YAC3B,CAAA,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG;YAC1C,CAAA,UAAU,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,QAAQ;0BAC5E;QACD,IAAI,OAAO,CAAC,OAAO,IAAI,GAAI;YACzB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;;QAEvB,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAI;YAC1B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;;IAE1B;gBAEgB,KAAK,GAAG;QACtB,OAAO,CAAC,GAAG,CAAC,OAAO,wDAAC;IACtB"}
\ No newline at end of file
......@@ -43,7 +43,7 @@ declare namespace UniNamespace {
router?: {
strict: boolean
base: string
assets: string,
assets: string
routerBase: string
}
nvue?: {
......
......@@ -7,7 +7,8 @@ export type API_TYPE_STOP_LOCATION_UPDATE = typeof uni.stopLocationUpdate
export const API_OFF_LOCATION_CHANGE = 'offLocationChange'
export type API_TYPE_OFF_LOCATION_CHANGE = typeof uni.offLocationChange
export const API_OFF_LOCATION_CHANGE_ERROR = 'offLocationChangeError'
export type API_TYPE_OFF_LOCATION_CHANGE_ERROR = typeof uni.offLocationChangeError
export type API_TYPE_OFF_LOCATION_CHANGE_ERROR =
typeof uni.offLocationChangeError
export const API_ON_LOCATION_CHANGE_ERROR = 'onLocationChangeError'
export type API_TYPE_ON_LOCATION_CHANGE_ERROR = typeof uni.onLocationChangeError
......@@ -15,7 +16,7 @@ const coordTypes = ['wgs84', 'gcj02']
export const StartLocationUpdateProtocol: ApiProtocol<API_TYPE_START_LOCATION_UPDATE> =
{
type: String
type: String,
}
export const StartLocationUpdateOptions: ApiOptions<API_TYPE_START_LOCATION_UPDATE> =
......@@ -28,6 +29,6 @@ export const StartLocationUpdateOptions: ApiOptions<API_TYPE_START_LOCATION_UPDA
} else {
params.type = value
}
}
}
}
\ No newline at end of file
},
},
}
......@@ -11719,13 +11719,13 @@ const ChooseLocationProtocol = {
};
const API_GET_LOCATION = 'getLocation';
const coordTypes = ['wgs84', 'gcj02'];
const coordTypes$1 = ['wgs84', 'gcj02'];
const GetLocationOptions = {
formatArgs: {
type(value, params) {
value = (value || '').toLowerCase();
if (coordTypes.indexOf(value) === -1) {
params.type = coordTypes[0];
if (coordTypes$1.indexOf(value) === -1) {
params.type = coordTypes$1[0];
}
else {
params.type = value;
......@@ -12145,6 +12145,30 @@ const CloseSocketProtocol = {
reason: String,
};
const API_START_LOCATION_UPDATE = 'startLocationUpdate';
const API_ON_LOCATION_CHANGE = 'onLocationChange';
const API_STOP_LOCATION_UPDATE = 'stopLocationUpdate';
const API_OFF_LOCATION_CHANGE = 'offLocationChange';
const API_OFF_LOCATION_CHANGE_ERROR = 'offLocationChangeError';
const API_ON_LOCATION_CHANGE_ERROR = 'onLocationChangeError';
const coordTypes = ['wgs84', 'gcj02'];
const StartLocationUpdateProtocol = {
type: String,
};
const StartLocationUpdateOptions = {
formatArgs: {
type(value, params) {
value = (value || '').toLowerCase();
if (coordTypes.indexOf(value) === -1) {
params.type = coordTypes[0];
}
else {
params.type = value;
}
},
},
};
function encodeQueryString(url) {
if (!isString(url)) {
return url;
......@@ -16155,6 +16179,43 @@ const openLocation = defineAsyncApi(API_OPEN_LOCATION, (data, { resolve, reject
return resolve();
}, OpenLocationProtocol, OpenLocationOptions);
let watchId = 0;
/**
* 开始更新定位
*/
const startLocationUpdate = (defineAsyncApi(API_START_LOCATION_UPDATE, (_, { resolve, reject }) => {
if (plus.geolocation && watchId === 0) {
watchId = plus.geolocation.watchPosition((res) => {
UniServiceJSBridge.invokeOnCallback(API_ON_LOCATION_CHANGE, res.coords);
resolve();
}, (error) => {
reject(error.message);
}, {
coordsType: _ === null || _ === void 0 ? void 0 : _.type,
});
}
else {
UniServiceJSBridge.invokeOnCallback(API_ON_LOCATION_CHANGE_ERROR, 'onLocationChange:fail');
}
resolve();
}, StartLocationUpdateProtocol, StartLocationUpdateOptions));
const onLocationChange = (defineOnApi(API_ON_LOCATION_CHANGE, () => { }));
const stopLocationUpdate = (defineAsyncApi(API_STOP_LOCATION_UPDATE, (_, { resolve, reject }) => {
if (watchId) {
plus.geolocation.clearWatch(watchId);
watchId = 0;
resolve();
}
else {
reject('stopLocationUpdate:fail');
}
}));
const offLocationChange = (defineOffApi(API_OFF_LOCATION_CHANGE, () => {
stopLocationUpdate();
}));
const onLocationChangeError = (defineOnApi(API_ON_LOCATION_CHANGE_ERROR, () => { }));
const offLocationChangeError = (defineOnApi(API_OFF_LOCATION_CHANGE_ERROR, () => { }));
const showModal = defineAsyncApi(API_SHOW_MODAL, ({ title = '', content = '', showCancel = true, cancelText, cancelColor, confirmText, confirmColor, editable = false, placeholderText = '', } = {}, { resolve }) => {
const buttons = showCancel ? [cancelText, confirmText] : [confirmText];
const tip = editable ? placeholderText : buttons;
......@@ -19375,6 +19436,12 @@ var uni$1 = {
getLocation: getLocation,
chooseLocation: chooseLocation,
openLocation: openLocation,
startLocationUpdate: startLocationUpdate,
onLocationChange: onLocationChange,
stopLocationUpdate: stopLocationUpdate,
offLocationChange: offLocationChange,
onLocationChangeError: onLocationChangeError,
offLocationChangeError: offLocationChangeError,
showModal: showModal,
showActionSheet: showActionSheet,
showLoading: showLoading,
......
......@@ -15,43 +15,45 @@ import {
API_TYPE_OFF_LOCATION_CHANGE_ERROR,
API_OFF_LOCATION_CHANGE_ERROR,
API_TYPE_ON_LOCATION_CHANGE_ERROR,
API_ON_LOCATION_CHANGE_ERROR
API_ON_LOCATION_CHANGE_ERROR,
} from '@dcloudio/uni-api'
let watchId: number = 0;
let watchId: number = 0
/**
* 开始更新定位
*/
export const startLocationUpdate = <API_TYPE_START_LOCATION_UPDATE>defineAsyncApi(
API_START_LOCATION_UPDATE,
(_, { resolve, reject }) => {
if (plus.geolocation && watchId === 0) {
watchId = plus.geolocation.watchPosition(
(res) => {
UniServiceJSBridge.invokeOnCallback(
API_ON_LOCATION_CHANGE,
res.coords
)
resolve()
},
(error) => {
reject(error.message)
},
{
coordsType: _?.type,
}
)
} else {
UniServiceJSBridge.invokeOnCallback(
API_ON_LOCATION_CHANGE_ERROR,
'onLocationChange:fail'
)
}
resolve()
},
StartLocationUpdateProtocol,
StartLocationUpdateOptions
export const startLocationUpdate = <API_TYPE_START_LOCATION_UPDATE>(
defineAsyncApi(
API_START_LOCATION_UPDATE,
(_, { resolve, reject }) => {
if (plus.geolocation && watchId === 0) {
watchId = plus.geolocation.watchPosition(
(res) => {
UniServiceJSBridge.invokeOnCallback(
API_ON_LOCATION_CHANGE,
res.coords
)
resolve()
},
(error) => {
reject(error.message)
},
{
coordsType: _?.type,
}
)
} else {
UniServiceJSBridge.invokeOnCallback(
API_ON_LOCATION_CHANGE_ERROR,
'onLocationChange:fail'
)
}
resolve()
},
StartLocationUpdateProtocol,
StartLocationUpdateOptions
)
)
export const onLocationChange = <API_TYPE_ON_LOCATION_CHANGE>(
......
......@@ -2,7 +2,7 @@ import { SELECTED_COLOR, TABBAR_HEIGHT } from '@dcloudio/uni-shared'
const borderStyles = {
black: 'rgba(0,0,0,0.4)',
white: 'rgba(255,255,255,0.4)'
white: 'rgba(255,255,255,0.4)',
}
export function initTabBar(
entryPagePath: string,
......@@ -17,7 +17,9 @@ export function initTabBar(
) as UniApp.TabBarOptions
if (tabBar.borderStyle! in borderStyles) {
tabBar.borderStyle = (borderStyles[tabBar.borderStyle!] as UniNamespace.TabBarOptions['borderStyle'])
tabBar.borderStyle = borderStyles[
tabBar.borderStyle!
] as UniNamespace.TabBarOptions['borderStyle']
}
if (!tabBar.selectedColor) {
......
import { createElementVNode, defineComponent, createVNode, mergeProps, getCurrentInstance, provide, watch, onUnmounted, shallowRef, reactive, watchEffect, ref, inject, onBeforeUnmount, computed, Text as Text$1, isVNode, Fragment, onMounted, resolveComponent, parseClassList } from "vue";
import { createElementVNode, defineComponent, createVNode, mergeProps, getCurrentInstance, provide, watch, onUnmounted, shallowRef, reactive, watchEffect, ref, inject, onBeforeUnmount, computed, Text as Text$1, isVNode, Fragment, onMounted, Comment, resolveComponent, parseClassList } from "vue";
import { extend, hasOwn, isFunction, isPlainObject, isArray, isString } from "@vue/shared";
import { cacheStringFunction, PRIMARY_COLOR } from "@dcloudio/uni-shared";
const OPEN_TYPES = [
......@@ -2260,7 +2260,9 @@ var PickerView = defineComponent({
const state = useState(props2);
const trigger = useCustomEvent(rootRef, emit);
let columnVNodes = [];
const getItemIndex = (vnode) => Array.prototype.indexOf.call(columnVNodes, vnode);
const getItemIndex = (vnode) => {
return Array.prototype.indexOf.call(columnVNodes.filter((vnode2) => vnode2.type !== Comment), vnode);
};
const getPickerViewColumn = (columnInstance) => {
return computed({
get() {
......@@ -2302,7 +2304,7 @@ var PickerView = defineComponent({
preventGesture: true
}), [createVNode("view", {
"class": "uni-picker-view-wrapper"
}, [defaultSlots])]);
}, [columnVNodes])]);
};
},
styles: [{
......@@ -2345,14 +2347,15 @@ const isAndroid$1 = weex.config.env.platform.toLowerCase() === "android";
function getStyle(val) {
return extend({}, isString(val) ? parseStyleText(val) : val);
}
const props$2 = {
length: {
type: [Number, String],
default: 0
}
};
var PickerViewColumn = defineComponent({
name: "PickerViewColumn",
props: {
length: {
type: [Number, String],
default: 0
}
},
props: props$2,
data: () => ({
_isMounted: false
}),
......@@ -2373,37 +2376,10 @@ var PickerViewColumn = defineComponent({
indicatorHeight.value = getHeight(indicatorStyle.value);
let pickerViewHeight = ref(0);
pickerViewHeight.value = parseFloat(pickerViewProps2.height);
watch(() => props2.length, () => {
setTimeout(() => {
setCurrent(current.value, true, true);
}, 150);
});
let scrollToElementTime;
const setCurrent = (_current, animated = true, force) => {
if (current.value === _current && !force) {
return;
}
dom.scrollToElement(contentRef.value, {
offset: _current * indicatorHeight.value,
animated
});
current.value = _current;
if (animated) {
scrollToElementTime = Date.now();
}
};
const onScrollend = (event) => {
if (Date.now() - scrollToElementTime < 340) {
return;
}
const y = event.detail.contentOffset.y;
const _current = Math.round(y / indicatorHeight.value);
if (y % indicatorHeight.value) {
setCurrent(_current, true, true);
} else {
current.value = _current;
}
};
const {
setCurrent,
onScrollend
} = usePickerColumnScroll(props2, current, contentRef, indicatorHeight);
const checkMounted = () => {
let height_;
let indicatorHeight_;
......@@ -2563,6 +2539,50 @@ function getHeight(style) {
}
return value;
}
function usePickerColumnScroll(props2, current, contentRef, indicatorHeight) {
let scrollToElementTime;
watch(() => props2.length, () => {
setTimeout(() => {
setCurrent(current.value, true, true);
}, 150);
});
watch(() => current.value, (_current) => {
dom.scrollToElement(contentRef.value, {
offset: _current * indicatorHeight.value,
animated: true
});
scrollToElementTime = Date.now();
});
const setCurrent = (_current, animated = true, force) => {
if (current.value === _current && !force) {
return;
}
dom.scrollToElement(contentRef.value, {
offset: _current * indicatorHeight.value,
animated
});
current.value = _current;
if (animated) {
scrollToElementTime = Date.now();
}
};
const onScrollend = (event) => {
if (Date.now() - scrollToElementTime < 340) {
return;
}
const y = event.detail.contentOffset.y;
const _current = Math.round(y / indicatorHeight.value);
if (y % indicatorHeight.value) {
setCurrent(_current, true, true);
} else {
current.value = _current;
}
};
return {
setCurrent,
onScrollend
};
}
const mode = {
SELECTOR: "selector",
MULTISELECTOR: "multiSelector",
......
......@@ -11,7 +11,7 @@ const defaultRouter = {
mode: 'hash',
base: '/',
assets: 'assets',
routerBase: '/'
routerBase: '/',
}
const defaultAsync = {
......@@ -45,13 +45,13 @@ export function uniManifestJsonPlugin(): Plugin {
}
if (!router.base) {
router.base = '/'
}
}
/**
* ssr时base和访问域名不一致导致跳到错误链接,其实应该区分server和client的部署路径,后续有需求可以加上
*/
router.routerBase = new URL(router.base, 'http://localhost').pathname
const async = { ...defaultAsync, ...((h5 && h5.async) || {}) }
const networkTimeout = normalizeNetworkTimeout(manifest.networkTimeout)
......
......@@ -7001,12 +7001,12 @@ function createRouterOptions() {
};
}
function initHistory() {
let { base } = __uniConfig.router;
if (base === "/") {
base = "";
let { routerBase } = __uniConfig.router;
if (routerBase === "/") {
routerBase = "";
}
{
return vueRouter.createMemoryHistory(base);
return vueRouter.createMemoryHistory(routerBase);
}
}
var index$f = {
......@@ -10943,6 +10943,7 @@ const ICON_PATHS = {
none: "",
forward: "M11 7.844q-0.25-0.219-0.25-0.578t0.25-0.578q0.219-0.25 0.563-0.25t0.563 0.25l9.656 9.125q0.125 0.125 0.188 0.297t0.063 0.328q0 0.188-0.063 0.359t-0.188 0.297l-9.656 9.125q-0.219 0.25-0.563 0.25t-0.563-0.25q-0.25-0.219-0.25-0.578t0.25-0.609l9.063-8.594-9.063-8.594z",
back: ICON_PATH_BACK,
select: ICON_PATH_BACK,
share: "M26.563 24.844q0 0.125-0.109 0.234t-0.234 0.109h-17.938q-0.125 0-0.219-0.109t-0.094-0.234v-13.25q0-0.156 0.094-0.25t0.219-0.094h5.5v-1.531h-6q-0.531 0-0.906 0.391t-0.375 0.922v14.375q0 0.531 0.375 0.922t0.906 0.391h18.969q0.531 0 0.891-0.391t0.359-0.953v-5.156h-1.438v4.625zM29.813 10.969l-5.125-5.375-1.031 1.094 3.438 3.594-3.719 0.031q-2.313 0.188-4.344 1.125t-3.578 2.422-2.5 3.453-1.109 4.188l-0.031 0.25h1.469v-0.219q0.156-1.875 1-3.594t2.25-3.063 3.234-2.125 3.828-0.906l0.188-0.031 3.313-0.031-3.438 3.625 1.031 1.063 5.125-5.375-0.031-0.063 0.031-0.063z",
favorite: "M27.594 13.375q-0.063-0.188-0.219-0.313t-0.344-0.156l-7.094-0.969-3.219-6.406q-0.094-0.188-0.25-0.281t-0.375-0.094q-0.188 0-0.344 0.094t-0.25 0.281l-3.125 6.438-7.094 1.094q-0.188 0.031-0.344 0.156t-0.219 0.313q-0.031 0.188 0.016 0.375t0.172 0.313l5.156 4.969-1.156 7.063q-0.031 0.188 0.047 0.375t0.234 0.313q0.094 0.063 0.188 0.094t0.219 0.031q0.063 0 0.141-0.031t0.172-0.063l6.313-3.375 6.375 3.313q0.063 0.031 0.141 0.047t0.172 0.016q0.188 0 0.344-0.094t0.25-0.281q0.063-0.094 0.078-0.234t-0.016-0.234q0-0.031 0-0.063l-1.25-6.938 5.094-5.031q0.156-0.156 0.203-0.344t-0.016-0.375zM11.469 19.063q0.031-0.188-0.016-0.344t-0.172-0.281l-4.406-4.25 6.063-0.906q0.156-0.031 0.297-0.125t0.203-0.25l2.688-5.531 2.75 5.5q0.063 0.156 0.203 0.25t0.297 0.125l6.094 0.844-4.375 4.281q-0.125 0.125-0.172 0.297t-0.016 0.328l1.063 6.031-5.438-2.813q-0.156-0.094-0.328-0.078t-0.297 0.078l-5.438 2.875 1-6.031z",
home: "M23.719 16.5q-0.313 0-0.531 0.219t-0.219 0.5v7.063q0 0.219-0.172 0.391t-0.391 0.172h-12.344q-0.25 0-0.422-0.172t-0.172-0.391v-7.063q0-0.281-0.219-0.5t-0.531-0.219q-0.281 0-0.516 0.219t-0.234 0.5v7.063q0.031 0.844 0.625 1.453t1.438 0.609h12.375q0.844 0 1.453-0.609t0.609-1.453v-7.063q0-0.125-0.063-0.266t-0.156-0.234q-0.094-0.125-0.234-0.172t-0.297-0.047zM26.5 14.875l-8.813-8.813q-0.313-0.313-0.688-0.453t-0.781-0.141-0.781 0.141-0.656 0.422l-8.813 8.844q-0.188 0.219-0.188 0.516t0.219 0.484q0.094 0.125 0.234 0.172t0.297 0.047q0.125 0 0.25-0.047t0.25-0.141l8.781-8.781q0.156-0.156 0.406-0.156t0.406 0.156l8.813 8.781q0.219 0.188 0.516 0.188t0.516-0.219q0.188-0.188 0.203-0.484t-0.172-0.516z",
......@@ -11007,7 +11008,8 @@ function createButtonsTsx(btns) {
btnText,
btnIconPath,
badgeText,
iconStyle
iconStyle,
btnSelect
}, index2) => {
return vue.createVNode("div", {
"key": index2,
......@@ -11015,7 +11017,12 @@ function createButtonsTsx(btns) {
"style": btnStyle,
"onClick": onClick,
"badge-text": badgeText
}, [btnIconPath ? createSvgIconVNode(btnIconPath, iconStyle.color, iconStyle.fontSize) : vue.createVNode("i", {
}, [btnIconPath ? createSvgIconVNode(btnIconPath, iconStyle.color, iconStyle.fontSize) : btnSelect ? vue.createVNode("span", {
"style": iconStyle
}, [vue.createVNode("i", {
"class": "uni-btn-icon",
"innerHTML": btnText
}, null, 8, ["innerHTML"]), createSvgIconVNode(ICON_PATHS["select"], "#000", 14)], 4) : vue.createVNode("i", {
"class": "uni-btn-icon",
"style": iconStyle,
"innerHTML": btnText
......@@ -11218,7 +11225,8 @@ function usePageHeadButton(pageId, index2, btn, isTransparent) {
invokeHook(pageId, uniShared.ON_NAVIGATION_BAR_BUTTON_TAP, shared.extend({
index: index2
}, btn));
}
},
btnSelect: btn.select
};
}
function usePageHeadSearchInput({
......
此差异已折叠。
......@@ -15,44 +15,44 @@ import {
API_TYPE_OFF_LOCATION_CHANGE_ERROR,
API_OFF_LOCATION_CHANGE_ERROR,
API_TYPE_ON_LOCATION_CHANGE_ERROR,
API_ON_LOCATION_CHANGE_ERROR
API_ON_LOCATION_CHANGE_ERROR,
} from '@dcloudio/uni-api'
import {
translateGeo,
} from '../../../helpers/location'
import { translateGeo } from '../../../helpers/location'
let watchId: number = 0;
let watchId: number = 0
/**
* 开始更新定位
*/
export const startLocationUpdate = <API_TYPE_START_LOCATION_UPDATE>defineAsyncApi(
API_START_LOCATION_UPDATE,
(_, { resolve, reject }) => {
if (navigator.geolocation && watchId === 0) {
watchId = navigator.geolocation.watchPosition(
(res) => {
translateGeo(_?.type, res.coords)
.then((coords) => {
UniServiceJSBridge.invokeOnCallback(
API_ON_LOCATION_CHANGE,
coords
)
resolve()
})
.catch((error) => {
reject(error.message)
})
},
(error) => {
reject(error.message)
}
)
}
resolve()
},
StartLocationUpdateProtocol,
StartLocationUpdateOptions
export const startLocationUpdate = <API_TYPE_START_LOCATION_UPDATE>(
defineAsyncApi(
API_START_LOCATION_UPDATE,
(_, { resolve, reject }) => {
if (navigator.geolocation && watchId === 0) {
watchId = navigator.geolocation.watchPosition(
(res) => {
translateGeo(_?.type, res.coords)
.then((coords) => {
UniServiceJSBridge.invokeOnCallback(
API_ON_LOCATION_CHANGE,
coords
)
resolve()
})
.catch((error) => {
reject(error.message)
})
},
(error) => {
reject(error.message)
}
)
}
resolve()
},
StartLocationUpdateProtocol,
StartLocationUpdateOptions
)
)
export const onLocationChange = <API_TYPE_ON_LOCATION_CHANGE>(
......
......@@ -43,7 +43,7 @@ export function uniUtsV1Plugin(): Plugin {
process.env.UNI_UTS_PLATFORM === 'app-ios' ? 'swift' : 'kotlin'
)
const pkg = parsePackage(filename)
if (!pkg) {
if (!pkg.class) {
return
}
// 懒加载 uts 编译器
......@@ -52,8 +52,8 @@ export function uniUtsV1Plugin(): Plugin {
const ast = await parse(code, { noColor: isInHBuilderX() })
code = `
import { initUtsProxyClass, initUtsProxyFunction } from '@dcloudio/uni-app'
const pkg = '${pkg}'
const cls = 'IndexKt'
const pkg = '${pkg.package}'
const cls = '${pkg.class}'
${genProxyCode(ast)}
`
const res = await compile(id)
......
......@@ -22,9 +22,12 @@ import {
export function parseKotlinPackage(filename: string) {
const res = resolvePackage(filename)
if (!res) {
return ''
return { package: '', class: '' }
}
return {
package: 'uts.sdk.' + (res.is_uni_modules ? 'modules.' : '') + res.name,
class: 'IndexKt',
}
return 'uts.sdk.' + (res.is_uni_modules ? 'modules.' : '') + res.name
}
export async function compileKotlin(filename: string) {
......@@ -41,8 +44,9 @@ export async function compileKotlin(filename: string) {
filename,
},
output: {
isPlugin: true,
outDir: outputDir,
package: parseKotlinPackage(filename),
package: parseKotlinPackage(filename).package,
sourceMap: resolveSourceMapPath(),
extname: 'kt',
imports: [
......
......@@ -5,9 +5,19 @@ import { genUTSPlatformResource, getUtsCompiler, resolvePackage } from './utils'
export function parseSwiftPackage(filename: string) {
const res = resolvePackage(filename)
if (!res) {
return ''
return {
package: '',
namespace: '',
class: '',
}
}
const namespace =
'UTSSDK' + (res.is_uni_modules ? 'Modules' : '') + capitalize(res.name)
return {
package: '',
namespace,
class: namespace + 'IndexSwift',
}
return 'UTSSDK' + (res.is_uni_modules ? 'Modules' : '') + capitalize(res.name)
}
export async function compileSwift(filename: string) {
......@@ -28,8 +38,9 @@ export async function compileSwift(filename: string) {
filename,
},
output: {
isPlugin: true,
outDir: outputDir,
package: '',
package: parseSwiftPackage(filename).namespace,
sourceMap: resolveSourceMapPath(),
extname: 'swift',
imports: ['DCUTSPlugin'],
......
......@@ -52,13 +52,16 @@ export function genUTSPlatformResource(
})
}
// 生产模式下,需要将 kt 文件转移到 src 下
// 生产模式下,需要将生成的平台文件转移到 src 下
const srcDir = path.resolve(utsOutputDir, 'src')
if (!fs.existsSync(srcDir)) {
fs.mkdirSync(srcDir)
}
if (fs.existsSync(platformFile)) {
fs.moveSync(platformFile, path.resolve(utsOutputDir, 'src/index.kt'))
fs.moveSync(
platformFile,
path.resolve(utsOutputDir, 'src/index' + options.extname)
)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册