diff --git a/packages/uni-api/src/helpers/api/index.ts b/packages/uni-api/src/helpers/api/index.ts index 1c28260453a57e1a1efd35d99f7ed3759613e7a5..b43edda720537bc6fa15bb0c4101d795b7a79b47 100644 --- a/packages/uni-api/src/helpers/api/index.ts +++ b/packages/uni-api/src/helpers/api/index.ts @@ -63,12 +63,12 @@ function wrapperApi( } as unknown) as T } -export function createOnApi( +export function defineOnApi( name: string, fn: T, options?: ApiOptions ) { - return createApi( + return defineApi( API_TYPE_ON, name, fn, @@ -77,13 +77,13 @@ export function createOnApi( ) } -export function createTaskApi( +export function defineTaskApi( name: string, fn: T, protocol?: ApiProtocols, options?: ApiOptions ) { - return createApi( + return defineApi( API_TYPE_TASK, name, fn, @@ -92,13 +92,13 @@ export function createTaskApi( ) } -export function createSyncApi( +export function defineSyncApi( name: string, fn: T, protocol?: ApiProtocols, options?: ApiOptions ) { - return createApi( + return defineApi( API_TYPE_SYNC, name, fn, @@ -107,18 +107,18 @@ export function createSyncApi( ) } -export function createAsyncApi( +export function defineAsyncApi( name: string, fn: T, protocol?: ApiProtocols, options?: ApiOptions ) { return promisify( - createApi(API_TYPE_ASYNC, name, fn, __DEV__ ? protocol : undefined, options) + defineApi(API_TYPE_ASYNC, name, fn, __DEV__ ? protocol : undefined, options) ) } -function createApi( +function defineApi( type: API_TYPES, name: string, fn: T, diff --git a/packages/uni-api/src/index.ts b/packages/uni-api/src/index.ts index 76dcb5924fece9dc908558885867267b3e70e473..43f5ea4dfa343e7c3da4f4643ce452221c3adbad 100644 --- a/packages/uni-api/src/index.ts +++ b/packages/uni-api/src/index.ts @@ -23,10 +23,10 @@ export * from './protocols/media/getImageInfo' // helpers export { - createOnApi, - createTaskApi, - createSyncApi, - createAsyncApi, + defineOnApi, + defineTaskApi, + defineSyncApi, + defineAsyncApi, } from './helpers/api' export { handlePromise } from './helpers/api/promise' diff --git a/packages/uni-api/src/protocols/media/getImageInfo.ts b/packages/uni-api/src/protocols/media/getImageInfo.ts index e7150f128baddf87cc0b990f9959174e0706eb92..fcac89027c3907849e5d1444b3a0f21ab9d1b17b 100644 --- a/packages/uni-api/src/protocols/media/getImageInfo.ts +++ b/packages/uni-api/src/protocols/media/getImageInfo.ts @@ -1,9 +1,10 @@ +import { getRealPath } from '@dcloudio/uni-platform' import { ApiOptions, ApiProtocol } from '../type' export const GetImageInfoOptions: ApiOptions = { formatArgs: { src(src, params) { - params.src = (uni as any).getRealPath(src) + params.src = getRealPath(src) }, }, } diff --git a/packages/uni-api/src/service/base/base64.ts b/packages/uni-api/src/service/base/base64.ts index ce46fbc375503a915de19f9eebf7c5b1bf5524a7..6b3b26f58e85e679ac9139cfb8aa7ce047d3216c 100644 --- a/packages/uni-api/src/service/base/base64.ts +++ b/packages/uni-api/src/service/base/base64.ts @@ -1,14 +1,14 @@ // @ts-ignore import { encode, decode } from '../../helpers/base64-arraybuffer' -import { createSyncApi } from '../../helpers/api' +import { defineSyncApi } from '../../helpers/api' import { Base64ToArrayBufferProtocol, ArrayBufferToBase64Protocol, } from '../../protocols/base/base64' -export const base64ToArrayBuffer = createSyncApi< +export const base64ToArrayBuffer = defineSyncApi< typeof uni.base64ToArrayBuffer >( 'base64ToArrayBuffer', @@ -18,7 +18,7 @@ export const base64ToArrayBuffer = createSyncApi< Base64ToArrayBufferProtocol ) -export const arrayBufferToBase64 = createSyncApi< +export const arrayBufferToBase64 = defineSyncApi< typeof uni.arrayBufferToBase64 >( 'arrayBufferToBase64', diff --git a/packages/uni-api/src/service/base/interceptor.ts b/packages/uni-api/src/service/base/interceptor.ts index 59dda03c16be08e53a8c772b6772e08482222353..72d0cace61da4a724b0c39425c2be7911f435b11 100644 --- a/packages/uni-api/src/service/base/interceptor.ts +++ b/packages/uni-api/src/service/base/interceptor.ts @@ -8,7 +8,7 @@ import { HOOKS, } from '../../helpers/interceptor' -import { createSyncApi } from '../../helpers/api' +import { defineSyncApi } from '../../helpers/api' import { AddInterceptorProtocol, @@ -80,7 +80,7 @@ function removeHook(hooks: Function[] | undefined, hook: Function) { } } -export const addInterceptor = createSyncApi( +export const addInterceptor = defineSyncApi( 'addInterceptor', (method: string | Interceptor, interceptor: Interceptor | undefined) => { if (typeof method === 'string' && isPlainObject(interceptor)) { @@ -95,7 +95,7 @@ export const addInterceptor = createSyncApi( AddInterceptorProtocol ) -export const removeInterceptor = createSyncApi( +export const removeInterceptor = defineSyncApi( 'removeInterceptor', (method: string | Interceptor, interceptor: Interceptor | undefined) => { if (typeof method === 'string') { diff --git a/packages/uni-api/src/service/base/upx2px.ts b/packages/uni-api/src/service/base/upx2px.ts index d0574613ade0c782c3370f268ab6c5aa7a2272d9..76eda56e4dca26034735cd47cbb0db653597628b 100644 --- a/packages/uni-api/src/service/base/upx2px.ts +++ b/packages/uni-api/src/service/base/upx2px.ts @@ -1,5 +1,5 @@ import { getBaseSystemInfo } from '@dcloudio/uni-platform' -import { createSyncApi } from '../../helpers/api' +import { defineSyncApi } from '../../helpers/api' import { Upx2pxProtocol } from '../../protocols/base/upx2px' const EPS = 1e-4 @@ -15,7 +15,7 @@ function checkDeviceWidth() { isIOS = platform === 'ios' } -export const upx2px = createSyncApi( +export const upx2px = defineSyncApi( 'upx2px', (number, newDeviceWidth?: number) => { if (deviceWidth === 0) { diff --git a/packages/uni-api/src/service/ui/createIntersectionObserver.ts b/packages/uni-api/src/service/ui/createIntersectionObserver.ts index ed1c6e3f08291c134d929d29cb5616adff47c4f3..28f05ddaed0515ba7a0bf2e5149ffc3cba45e05e 100644 --- a/packages/uni-api/src/service/ui/createIntersectionObserver.ts +++ b/packages/uni-api/src/service/ui/createIntersectionObserver.ts @@ -2,7 +2,7 @@ import { extend } from '@vue/shared' import { ServiceJSBridge } from '@dcloudio/uni-core' -import { createSyncApi } from '../../helpers/api' +import { defineSyncApi } from '../../helpers/api' import { getCurrentPageVm } from '../utils' const defaultOptions = { @@ -120,7 +120,7 @@ class ServiceIntersectionObserver { } } -export const createIntersectionObserver = createSyncApi< +export const createIntersectionObserver = defineSyncApi< typeof uni.createIntersectionObserver >('createIntersectionObserver', (context?, options?) => { if (!context) { diff --git a/packages/uni-h5/dist/uni-h5.esm.js b/packages/uni-h5/dist/uni-h5.esm.js index 1579f9929a6cfe168444381efaa4b5b4d3c82baf..9978bc654aaf3afc82855e947cf52acd7e21207b 100644 --- a/packages/uni-h5/dist/uni-h5.esm.js +++ b/packages/uni-h5/dist/uni-h5.esm.js @@ -3319,7 +3319,7 @@ function addBase(filePath) { } return base + filePath; } -function getRealPath$1(filePath) { +function getRealPath(filePath) { if (__uniConfig.router.base === "./") { filePath = filePath.replace(/^\.\/static\//, "/static/"); } @@ -3395,7 +3395,7 @@ const _sfc_main$j = { return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0; }, realImagePath() { - return getRealPath$1(this.src); + return getRealPath(this.src); }, modeStyle() { let size = "auto"; @@ -7716,13 +7716,13 @@ function wrapperApi(fn, name, protocol, options) { return fn.apply(null, formatApiArgs(args)); }; } -function createSyncApi(name, fn, protocol, options) { - return createApi(API_TYPE_SYNC, name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options); +function defineSyncApi(name, fn, protocol, options) { + return defineApi(API_TYPE_SYNC, name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options); } -function createAsyncApi(name, fn, protocol, options) { - return promisify(createApi(API_TYPE_ASYNC, name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); +function defineAsyncApi(name, fn, protocol, options) { + return promisify(defineApi(API_TYPE_ASYNC, name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); } -function createApi(type, name, fn, protocol, options) { +function defineApi(type, name, fn, protocol, options) { switch (type) { case API_TYPE_ON: return wrapperApi(wrapperOnApi(name, fn), name, protocol); @@ -7748,10 +7748,10 @@ const ArrayBufferToBase64Protocol = [ required: true } ]; -const base64ToArrayBuffer = /* @__PURE__ */ createSyncApi("base64ToArrayBuffer", (base64) => { +const base64ToArrayBuffer = defineSyncApi("base64ToArrayBuffer", (base64) => { return decode(base64); }, Base64ToArrayBufferProtocol); -const arrayBufferToBase64 = /* @__PURE__ */ createSyncApi("arrayBufferToBase64", (arrayBuffer) => { +const arrayBufferToBase64 = defineSyncApi("arrayBufferToBase64", (arrayBuffer) => { return encode(arrayBuffer); }, ArrayBufferToBase64Protocol); const Upx2pxProtocol = [ @@ -7772,7 +7772,7 @@ function checkDeviceWidth() { deviceDPR = pixelRatio2; isIOS = platform === "ios"; } -const upx2px = /* @__PURE__ */ createSyncApi("upx2px", (number, newDeviceWidth) => { +const upx2px = defineSyncApi("upx2px", (number, newDeviceWidth) => { if (deviceWidth === 0) { checkDeviceWidth(); } @@ -7851,14 +7851,14 @@ function removeHook(hooks, hook) { hooks.splice(index2, 1); } } -const addInterceptor = /* @__PURE__ */ createSyncApi("addInterceptor", (method, interceptor) => { +const addInterceptor = defineSyncApi("addInterceptor", (method, interceptor) => { if (typeof method === "string" && isPlainObject(interceptor)) { mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); } else if (isPlainObject(method)) { mergeInterceptorHook(globalInterceptors, method); } }, AddInterceptorProtocol); -const removeInterceptor = /* @__PURE__ */ createSyncApi("removeInterceptor", (method, interceptor) => { +const removeInterceptor = defineSyncApi("removeInterceptor", (method, interceptor) => { if (typeof method === "string") { if (isPlainObject(interceptor)) { removeInterceptorHook(scopedInterceptors[method], interceptor); @@ -7946,7 +7946,7 @@ class ServiceIntersectionObserver { }, this._pageId); } } -const createIntersectionObserver = /* @__PURE__ */ createSyncApi("createIntersectionObserver", (context, options) => { +const createIntersectionObserver = defineSyncApi("createIntersectionObserver", (context, options) => { if (!context) { context = getCurrentPageVm(); } @@ -7984,7 +7984,7 @@ const OpenDocumentProtocol = { const GetImageInfoOptions = { formatArgs: { src(src, params) { - params.src = uni.getRealPath(src); + params.src = getRealPath(src); } } }; @@ -8002,16 +8002,16 @@ const SCHEMA_CSS = { "css.env": cssSupports("top:env(a)"), "css.constant": cssSupports("top:constant(a)") }; -const canIUse = /* @__PURE__ */ createSyncApi("canIUse", (schema) => { +const canIUse = defineSyncApi("canIUse", (schema) => { if (hasOwn$1(SCHEMA_CSS, schema)) { return SCHEMA_CSS[schema]; } return true; }, CanIUseProtocol); -const makePhoneCall = /* @__PURE__ */ createAsyncApi("makePhoneCall", (option) => { +const makePhoneCall = defineAsyncApi("makePhoneCall", (option) => { window.location.href = `tel:${option.phoneNumber}`; }, MakePhoneCallProtocol); -const getSystemInfoSync = /* @__PURE__ */ createSyncApi("getSystemInfoSync", () => { +const getSystemInfoSync = defineSyncApi("getSystemInfoSync", () => { const pixelRatio2 = window.devicePixelRatio; const screenFix = getScreenFix(); const landscape = isLandscape(screenFix); @@ -8111,16 +8111,16 @@ const getSystemInfoSync = /* @__PURE__ */ createSyncApi("getSystemInfoSync", () } }; }); -const getSystemInfo = /* @__PURE__ */ createAsyncApi("getSystemInfo", () => { +const getSystemInfo = defineAsyncApi("getSystemInfo", () => { return getSystemInfoSync(); }); -const openDocument = /* @__PURE__ */ createAsyncApi("openDocument", (option) => { +const openDocument = defineAsyncApi("openDocument", (option) => { window.open(option.filePath); }, OpenDocumentProtocol); function _getServiceAddress() { return window.location.protocol + "//" + window.location.host; } -const getImageInfo = /* @__PURE__ */ createAsyncApi("getImageInfo", ({src}, callback) => { +const getImageInfo = defineAsyncApi("getImageInfo", ({src}, callback) => { const img = new Image(); img.onload = function() { callback({ @@ -8137,9 +8137,9 @@ const getImageInfo = /* @__PURE__ */ createAsyncApi("getImageInfo", ({src}, call }; img.src = src; }, GetImageInfoProtocol, GetImageInfoOptions); -const navigateBack = /* @__PURE__ */ createAsyncApi("navigateBack", () => { +const navigateBack = defineAsyncApi("navigateBack", () => { }); -const navigateTo = /* @__PURE__ */ createAsyncApi("navigateTo", (options) => { +const navigateTo = defineAsyncApi("navigateTo", (options) => { const router = getApp().$router; router.push({ path: options.url, @@ -8147,14 +8147,11 @@ const navigateTo = /* @__PURE__ */ createAsyncApi("navigateTo", (options) => { state: createPageState("navigateTo") }); }); -const redirectTo = /* @__PURE__ */ createAsyncApi("redirectTo", () => { +const redirectTo = defineAsyncApi("redirectTo", () => { }); -const reLaunch = /* @__PURE__ */ createAsyncApi("reLaunch", () => { +const reLaunch = defineAsyncApi("reLaunch", () => { }); -const switchTab = /* @__PURE__ */ createAsyncApi("switchTab", () => { -}); -const getRealPath = /* @__PURE__ */ createSyncApi("getRealPath", (path) => { - return path; +const switchTab = defineAsyncApi("switchTab", () => { }); var api = /* @__PURE__ */ Object.freeze({ __proto__: null, @@ -8177,8 +8174,7 @@ var api = /* @__PURE__ */ Object.freeze({ navigateTo, redirectTo, reLaunch, - switchTab, - getRealPath + switchTab }); const uni$1 = api; const UniServiceJSBridge$1 = extend(ServiceJSBridge, { @@ -8464,7 +8460,7 @@ function usePageHeadButtons(navigationBar) { const fonts = Object.create(null); buttons.forEach((btn) => { if (btn.fontSrc && !btn.fontFamily) { - const fontSrc = getRealPath$1(btn.fontSrc); + const fontSrc = getRealPath(btn.fontSrc); let fontFamily = fonts[fontSrc]; if (!fontFamily) { fontFamily = `font${Date.now()}`; @@ -9268,4 +9264,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { ]); } _sfc_main.render = _sfc_render; -export {_sfc_main$1 as AsyncErrorComponent, _sfc_main as AsyncLoadingComponent, _sfc_main$p as Audio, _sfc_main$o as Canvas, _sfc_main$n as Checkbox, _sfc_main$m as CheckboxGroup, _sfc_main$l as Editor, _sfc_main$k as Form, index$1 as Icon, _sfc_main$j as Image, _sfc_main$i as Input, _sfc_main$h as Label, _sfc_main$g as MovableView, _sfc_main$f as Navigator, index as PageComponent, _sfc_main$e as Progress, _sfc_main$d as Radio, _sfc_main$c as RadioGroup, _sfc_main$b as ResizeSensor, _sfc_main$a as RichText, _sfc_main$9 as ScrollView, _sfc_main$8 as Slider, _sfc_main$7 as SwiperItem, _sfc_main$6 as Switch, _sfc_main$5 as Text, _sfc_main$4 as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, _sfc_main$3 as View, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, createIntersectionObserver, createSelectorQuery, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getImageInfo, getRealPath, getSystemInfo, getSystemInfoSync, makePhoneCall, navigateBack, navigateTo, openDocument, index$2 as plugin, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, switchTab, uni$1 as uni, upx2px}; +export {_sfc_main$1 as AsyncErrorComponent, _sfc_main as AsyncLoadingComponent, _sfc_main$p as Audio, _sfc_main$o as Canvas, _sfc_main$n as Checkbox, _sfc_main$m as CheckboxGroup, _sfc_main$l as Editor, _sfc_main$k as Form, index$1 as Icon, _sfc_main$j as Image, _sfc_main$i as Input, _sfc_main$h as Label, _sfc_main$g as MovableView, _sfc_main$f as Navigator, index as PageComponent, _sfc_main$e as Progress, _sfc_main$d as Radio, _sfc_main$c as RadioGroup, _sfc_main$b as ResizeSensor, _sfc_main$a as RichText, _sfc_main$9 as ScrollView, _sfc_main$8 as Slider, _sfc_main$7 as SwiperItem, _sfc_main$6 as Switch, _sfc_main$5 as Text, _sfc_main$4 as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, _sfc_main$3 as View, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, createIntersectionObserver, createSelectorQuery, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getImageInfo, getSystemInfo, getSystemInfoSync, makePhoneCall, navigateBack, navigateTo, openDocument, index$2 as plugin, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, switchTab, uni$1 as uni, upx2px}; diff --git a/packages/uni-h5/src/service/api/base/canIUse.ts b/packages/uni-h5/src/service/api/base/canIUse.ts index ea12323bb586b20bdf790836c1fa73c1b8b7c9df..6c06e750785032df968e991ec6a06c9bbe3b12a6 100644 --- a/packages/uni-h5/src/service/api/base/canIUse.ts +++ b/packages/uni-h5/src/service/api/base/canIUse.ts @@ -1,6 +1,6 @@ import { hasOwn } from '@vue/shared' -import { CanIUseProtocol, createSyncApi } from '@dcloudio/uni-api' +import { CanIUseProtocol, defineSyncApi } from '@dcloudio/uni-api' function cssSupports(css: string) { return window.CSS && window.CSS.supports && window.CSS.supports(css) @@ -12,7 +12,7 @@ const SCHEMA_CSS = { 'css.constant': cssSupports('top:constant(a)'), } -export const canIUse = createSyncApi( +export const canIUse = defineSyncApi( 'canIUse', (schema: string) => { if (hasOwn(SCHEMA_CSS, schema)) { diff --git a/packages/uni-h5/src/service/api/device/getSystemInfo.ts b/packages/uni-h5/src/service/api/device/getSystemInfo.ts index 6beb18c829ac3975e67a3933382afb4e5e5b5d82..8df61d8f88dc51789b00c6e99c82375f34323c0f 100644 --- a/packages/uni-h5/src/service/api/device/getSystemInfo.ts +++ b/packages/uni-h5/src/service/api/device/getSystemInfo.ts @@ -1,8 +1,8 @@ -import { createAsyncApi } from '@dcloudio/uni-api' +import { defineAsyncApi } from '@dcloudio/uni-api' import { getSystemInfoSync } from './getSystemInfoSync' -export const getSystemInfo = createAsyncApi( +export const getSystemInfo = defineAsyncApi( 'getSystemInfo', () => { return getSystemInfoSync() diff --git a/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts b/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts index 0c3c0899d94b777cff63f33ca40dff271a72bacb..5b0bd79f53c2b260f9e2147f357e34852e72dbb4 100644 --- a/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts +++ b/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts @@ -1,6 +1,6 @@ import safeAreaInsets from 'safe-area-insets' -import { createSyncApi } from '@dcloudio/uni-api' +import { defineSyncApi } from '@dcloudio/uni-api' import { getWindowOffset } from '@dcloudio/uni-core' @@ -18,7 +18,7 @@ import { /** * 获取系统信息-同步 */ -export const getSystemInfoSync = createSyncApi( +export const getSystemInfoSync = defineSyncApi( 'getSystemInfoSync', () => { const pixelRatio = window.devicePixelRatio diff --git a/packages/uni-h5/src/service/api/device/makePhoneCall.ts b/packages/uni-h5/src/service/api/device/makePhoneCall.ts index a0df5d4a82ee1140ced54ecea121027e009fe9e7..ddc73aedfee9d3155191b6a7a17c42111d6a0bcd 100644 --- a/packages/uni-h5/src/service/api/device/makePhoneCall.ts +++ b/packages/uni-h5/src/service/api/device/makePhoneCall.ts @@ -1,6 +1,6 @@ -import { createAsyncApi, MakePhoneCallProtocol } from '@dcloudio/uni-api' +import { defineAsyncApi, MakePhoneCallProtocol } from '@dcloudio/uni-api' -export const makePhoneCall = createAsyncApi( +export const makePhoneCall = defineAsyncApi( 'makePhoneCall', (option) => { window.location.href = `tel:${option.phoneNumber}` diff --git a/packages/uni-h5/src/service/api/file/openDocument.ts b/packages/uni-h5/src/service/api/file/openDocument.ts index 4bbcf4b7783b60bfce3a9afa02c6bdd2e861a345..c6ea15cecebe8bcaa5a64aa8d1d45fa6734a6e7d 100644 --- a/packages/uni-h5/src/service/api/file/openDocument.ts +++ b/packages/uni-h5/src/service/api/file/openDocument.ts @@ -1,6 +1,6 @@ -import { createAsyncApi, OpenDocumentProtocol } from '@dcloudio/uni-api' +import { defineAsyncApi, OpenDocumentProtocol } from '@dcloudio/uni-api' -export const openDocument = createAsyncApi( +export const openDocument = defineAsyncApi( 'openDocument', (option) => { window.open(option.filePath) diff --git a/packages/uni-h5/src/service/api/index.ts b/packages/uni-h5/src/service/api/index.ts index d2f68e125705c923ad16b5400ff6c09c75fbdeba..ecd4e619f9a0e589f5af5e50e78038f3b1263583 100644 --- a/packages/uni-h5/src/service/api/index.ts +++ b/packages/uni-h5/src/service/api/index.ts @@ -14,8 +14,6 @@ export * from './route/redirectTo' export * from './route/reLaunch' export * from './route/switchTab' -export * from './util/getRealPath' - export { upx2px, addInterceptor, diff --git a/packages/uni-h5/src/service/api/media/getImageInfo.ts b/packages/uni-h5/src/service/api/media/getImageInfo.ts index 24a1bbaf041e66c6a9125743fe4e58ce4b961a32..2fe59011204bb32d228996f614b804c996b2d022 100644 --- a/packages/uni-h5/src/service/api/media/getImageInfo.ts +++ b/packages/uni-h5/src/service/api/media/getImageInfo.ts @@ -1,5 +1,5 @@ import { - createAsyncApi, + defineAsyncApi, GetImageInfoOptions, GetImageInfoProtocol, } from '@dcloudio/uni-api' @@ -8,7 +8,7 @@ function _getServiceAddress() { return window.location.protocol + '//' + window.location.host } -export const getImageInfo = createAsyncApi( +export const getImageInfo = defineAsyncApi( 'getImageInfo', ({ src }, callback?: Function) => { const img = new Image() diff --git a/packages/uni-h5/src/service/api/route/navigateBack.ts b/packages/uni-h5/src/service/api/route/navigateBack.ts index 2c787e49ea416071a4517dfc94506b5cb414fc17..c1f5ca3f69c2487da14192ba195afa8f3ad63e55 100644 --- a/packages/uni-h5/src/service/api/route/navigateBack.ts +++ b/packages/uni-h5/src/service/api/route/navigateBack.ts @@ -1,6 +1,6 @@ -import { createAsyncApi } from '@dcloudio/uni-api' +import { defineAsyncApi } from '@dcloudio/uni-api' -export const navigateBack = createAsyncApi( +export const navigateBack = defineAsyncApi( 'navigateBack', () => {} ) diff --git a/packages/uni-h5/src/service/api/route/navigateTo.ts b/packages/uni-h5/src/service/api/route/navigateTo.ts index f53ce27bbb57bce5f3d5f5512791a4b8e97bb62e..6cb4a69ee6f7172b8f197702aa86d75402c6359e 100644 --- a/packages/uni-h5/src/service/api/route/navigateTo.ts +++ b/packages/uni-h5/src/service/api/route/navigateTo.ts @@ -1,8 +1,8 @@ import { Router } from 'vue-router' -import { createAsyncApi } from '@dcloudio/uni-api' +import { defineAsyncApi } from '@dcloudio/uni-api' import { createPageState } from '../../../framework/plugin/page' -export const navigateTo = createAsyncApi( +export const navigateTo = defineAsyncApi( 'navigateTo', (options) => { const router = getApp().$router as Router diff --git a/packages/uni-h5/src/service/api/route/reLaunch.ts b/packages/uni-h5/src/service/api/route/reLaunch.ts index 3b7bc20e67a35db5006392a8dd67ece6b1178cad..e1dfb06649b566740b3e3272429f84ae1bc6adec 100644 --- a/packages/uni-h5/src/service/api/route/reLaunch.ts +++ b/packages/uni-h5/src/service/api/route/reLaunch.ts @@ -1,3 +1,3 @@ -import { createAsyncApi } from '@dcloudio/uni-api' +import { defineAsyncApi } from '@dcloudio/uni-api' -export const reLaunch = createAsyncApi('reLaunch', () => {}) +export const reLaunch = defineAsyncApi('reLaunch', () => {}) diff --git a/packages/uni-h5/src/service/api/route/redirectTo.ts b/packages/uni-h5/src/service/api/route/redirectTo.ts index 86da2a4f808dcfbc1b193b217098434bfaa0338f..6f1ddfd101928162672d1ab6a164c8f542f25e16 100644 --- a/packages/uni-h5/src/service/api/route/redirectTo.ts +++ b/packages/uni-h5/src/service/api/route/redirectTo.ts @@ -1,3 +1,3 @@ -import { createAsyncApi } from '@dcloudio/uni-api' +import { defineAsyncApi } from '@dcloudio/uni-api' -export const redirectTo = createAsyncApi('redirectTo', () => {}) +export const redirectTo = defineAsyncApi('redirectTo', () => {}) diff --git a/packages/uni-h5/src/service/api/route/switchTab.ts b/packages/uni-h5/src/service/api/route/switchTab.ts index a56a78e4b351f7ffe41c26c4001e7e517486f2b4..6430d3a1be2d4c8d5ab8f1007117ded7cd4192ca 100644 --- a/packages/uni-h5/src/service/api/route/switchTab.ts +++ b/packages/uni-h5/src/service/api/route/switchTab.ts @@ -1,3 +1,3 @@ -import { createAsyncApi } from '@dcloudio/uni-api' +import { defineAsyncApi } from '@dcloudio/uni-api' -export const switchTab = createAsyncApi('switchTab', () => {}) +export const switchTab = defineAsyncApi('switchTab', () => {}) diff --git a/packages/uni-h5/src/service/api/util/getRealPath.ts b/packages/uni-h5/src/service/api/util/getRealPath.ts deleted file mode 100644 index fb63b9cb19a2541c1b2e4d3aec34dfa656e7b062..0000000000000000000000000000000000000000 --- a/packages/uni-h5/src/service/api/util/getRealPath.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { createSyncApi } from '@dcloudio/uni-api' - -export const getRealPath = createSyncApi('getRealPath', (path: string) => { - return path -}) diff --git a/packages/uni-mp-alipay/dist/uni.api.esm.js b/packages/uni-mp-alipay/dist/uni.api.esm.js index ab74fc0794600027782507f2ca4e6877b96df588..7420698846d218181ab87e9bc2e5de6f534e0629 100644 --- a/packages/uni-mp-alipay/dist/uni.api.esm.js +++ b/packages/uni-mp-alipay/dist/uni.api.esm.js @@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { return fn.apply(null, formatApiArgs(args)); }; } -function createSyncApi(name, fn, protocol, options) { - return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); +function defineSyncApi(name, fn, protocol, options) { + return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); } -function createApi(type, name, fn, protocol, options) { +function defineApi(type, name, fn, protocol, options) { switch (type) { case API_TYPE_ON: return wrapperApi(wrapperOnApi(name, fn), name, protocol); @@ -324,7 +324,7 @@ function checkDeviceWidth() { deviceDPR = pixelRatio; isIOS = platform === 'ios'; } -const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { +const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => { if (deviceWidth === 0) { checkDeviceWidth(); } @@ -506,7 +506,7 @@ function removeHook(hooks, hook) { hooks.splice(index, 1); } } -const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { +const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => { if (typeof method === 'string' && isPlainObject(interceptor)) { mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); } @@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => mergeInterceptorHook(globalInterceptors, method); } }, AddInterceptorProtocol); -const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { +const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => { if (typeof method === 'string') { if (isPlainObject(interceptor)) { removeInterceptorHook(scopedInterceptors[method], interceptor); diff --git a/packages/uni-mp-alipay/src/platform/index.ts b/packages/uni-mp-alipay/src/platform/index.ts index 90ad685efec6912344960b5117b8725bed0f7f1c..17d74c3d2193965c9205fca7b167bab75fcca34a 100644 --- a/packages/uni-mp-alipay/src/platform/index.ts +++ b/packages/uni-mp-alipay/src/platform/index.ts @@ -1,3 +1,5 @@ export function getBaseSystemInfo() { return my.getSystemInfoSync() } + +export function getRealPath() {} diff --git a/packages/uni-mp-baidu/dist/uni.api.esm.js b/packages/uni-mp-baidu/dist/uni.api.esm.js index 669ceff70d426aa8b1a2be7290b9b722e6da873b..5c61058f21e39f97218df0a8b6ffbdf0e33c3a9b 100644 --- a/packages/uni-mp-baidu/dist/uni.api.esm.js +++ b/packages/uni-mp-baidu/dist/uni.api.esm.js @@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { return fn.apply(null, formatApiArgs(args)); }; } -function createSyncApi(name, fn, protocol, options) { - return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); +function defineSyncApi(name, fn, protocol, options) { + return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); } -function createApi(type, name, fn, protocol, options) { +function defineApi(type, name, fn, protocol, options) { switch (type) { case API_TYPE_ON: return wrapperApi(wrapperOnApi(name, fn), name, protocol); @@ -324,7 +324,7 @@ function checkDeviceWidth() { deviceDPR = pixelRatio; isIOS = platform === 'ios'; } -const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { +const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => { if (deviceWidth === 0) { checkDeviceWidth(); } @@ -506,7 +506,7 @@ function removeHook(hooks, hook) { hooks.splice(index, 1); } } -const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { +const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => { if (typeof method === 'string' && isPlainObject(interceptor)) { mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); } @@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => mergeInterceptorHook(globalInterceptors, method); } }, AddInterceptorProtocol); -const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { +const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => { if (typeof method === 'string') { if (isPlainObject(interceptor)) { removeInterceptorHook(scopedInterceptors[method], interceptor); diff --git a/packages/uni-mp-baidu/src/platform/index.ts b/packages/uni-mp-baidu/src/platform/index.ts index 2cc117b7526904372d0fb9d1474dab939ecdf30d..83d36d2667aff52f899db9144b79f37edcc417ff 100644 --- a/packages/uni-mp-baidu/src/platform/index.ts +++ b/packages/uni-mp-baidu/src/platform/index.ts @@ -1,3 +1,4 @@ export function getBaseSystemInfo() { return swan.getSystemInfoSync() } +export function getRealPath() {} diff --git a/packages/uni-mp-qq/dist/uni.api.esm.js b/packages/uni-mp-qq/dist/uni.api.esm.js index 1051f5eaf194ede251c7fec2653d892c7b6f3177..ee900f0a03d6e87f97a403b9bc8afd77c55d5a90 100644 --- a/packages/uni-mp-qq/dist/uni.api.esm.js +++ b/packages/uni-mp-qq/dist/uni.api.esm.js @@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { return fn.apply(null, formatApiArgs(args)); }; } -function createSyncApi(name, fn, protocol, options) { - return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); +function defineSyncApi(name, fn, protocol, options) { + return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); } -function createApi(type, name, fn, protocol, options) { +function defineApi(type, name, fn, protocol, options) { switch (type) { case API_TYPE_ON: return wrapperApi(wrapperOnApi(name, fn), name, protocol); @@ -324,7 +324,7 @@ function checkDeviceWidth() { deviceDPR = pixelRatio; isIOS = platform === 'ios'; } -const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { +const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => { if (deviceWidth === 0) { checkDeviceWidth(); } @@ -506,7 +506,7 @@ function removeHook(hooks, hook) { hooks.splice(index, 1); } } -const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { +const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => { if (typeof method === 'string' && isPlainObject(interceptor)) { mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); } @@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => mergeInterceptorHook(globalInterceptors, method); } }, AddInterceptorProtocol); -const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { +const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => { if (typeof method === 'string') { if (isPlainObject(interceptor)) { removeInterceptorHook(scopedInterceptors[method], interceptor); diff --git a/packages/uni-mp-qq/src/platform/index.ts b/packages/uni-mp-qq/src/platform/index.ts index 17dbcd7d2ee3df1a72b4b4502288826a29efa729..3a7c0f2bdd82ed7e59d2f64f29d8eb94898eb019 100644 --- a/packages/uni-mp-qq/src/platform/index.ts +++ b/packages/uni-mp-qq/src/platform/index.ts @@ -1,3 +1,4 @@ export function getBaseSystemInfo() { return qq.getSystemInfoSync() } +export function getRealPath() {} diff --git a/packages/uni-mp-toutiao/dist/uni.api.esm.js b/packages/uni-mp-toutiao/dist/uni.api.esm.js index d6f7b9ec6c55bc74827a11db31bfdafde7995c2d..e0aedf590f05e3c71180e6d621cab40f6b6c5a5f 100644 --- a/packages/uni-mp-toutiao/dist/uni.api.esm.js +++ b/packages/uni-mp-toutiao/dist/uni.api.esm.js @@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { return fn.apply(null, formatApiArgs(args)); }; } -function createSyncApi(name, fn, protocol, options) { - return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); +function defineSyncApi(name, fn, protocol, options) { + return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); } -function createApi(type, name, fn, protocol, options) { +function defineApi(type, name, fn, protocol, options) { switch (type) { case API_TYPE_ON: return wrapperApi(wrapperOnApi(name, fn), name, protocol); @@ -324,7 +324,7 @@ function checkDeviceWidth() { deviceDPR = pixelRatio; isIOS = platform === 'ios'; } -const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { +const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => { if (deviceWidth === 0) { checkDeviceWidth(); } @@ -506,7 +506,7 @@ function removeHook(hooks, hook) { hooks.splice(index, 1); } } -const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { +const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => { if (typeof method === 'string' && isPlainObject(interceptor)) { mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); } @@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => mergeInterceptorHook(globalInterceptors, method); } }, AddInterceptorProtocol); -const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { +const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => { if (typeof method === 'string') { if (isPlainObject(interceptor)) { removeInterceptorHook(scopedInterceptors[method], interceptor); diff --git a/packages/uni-mp-toutiao/src/platform/index.ts b/packages/uni-mp-toutiao/src/platform/index.ts index 53a55c0accaa45f90ca55dfc7e0857f155665228..c0e5d97dc2bb16d204086c862ec9838e6e7b2614 100644 --- a/packages/uni-mp-toutiao/src/platform/index.ts +++ b/packages/uni-mp-toutiao/src/platform/index.ts @@ -1,3 +1,4 @@ export function getBaseSystemInfo() { return tt.getSystemInfoSync() } +export function getRealPath() {} diff --git a/packages/uni-mp-weixin/dist/uni.api.esm.js b/packages/uni-mp-weixin/dist/uni.api.esm.js index 61188fe2a141cf6968dcb641a070f0a855651a2e..c83959e427d9a807772e548e05978cb51ab370ea 100644 --- a/packages/uni-mp-weixin/dist/uni.api.esm.js +++ b/packages/uni-mp-weixin/dist/uni.api.esm.js @@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { return fn.apply(null, formatApiArgs(args)); }; } -function createSyncApi(name, fn, protocol, options) { - return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); +function defineSyncApi(name, fn, protocol, options) { + return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); } -function createApi(type, name, fn, protocol, options) { +function defineApi(type, name, fn, protocol, options) { switch (type) { case API_TYPE_ON: return wrapperApi(wrapperOnApi(name, fn), name, protocol); @@ -324,7 +324,7 @@ function checkDeviceWidth() { deviceDPR = pixelRatio; isIOS = platform === 'ios'; } -const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { +const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => { if (deviceWidth === 0) { checkDeviceWidth(); } @@ -506,7 +506,7 @@ function removeHook(hooks, hook) { hooks.splice(index, 1); } } -const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { +const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => { if (typeof method === 'string' && isPlainObject(interceptor)) { mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); } @@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => mergeInterceptorHook(globalInterceptors, method); } }, AddInterceptorProtocol); -const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { +const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => { if (typeof method === 'string') { if (isPlainObject(interceptor)) { removeInterceptorHook(scopedInterceptors[method], interceptor); diff --git a/packages/uni-mp-weixin/src/platform/index.ts b/packages/uni-mp-weixin/src/platform/index.ts index 80a7678ea423d13922b8bc156b5d9a230a4025df..62fc2536f26720ee25a5de1a2f1db4452dfe1bed 100644 --- a/packages/uni-mp-weixin/src/platform/index.ts +++ b/packages/uni-mp-weixin/src/platform/index.ts @@ -1,3 +1,4 @@ export function getBaseSystemInfo() { return wx.getSystemInfoSync() } +export function getRealPath() {} diff --git a/packages/uni-quickapp-webview/dist/uni.api.esm.js b/packages/uni-quickapp-webview/dist/uni.api.esm.js index d4339b3927032af3b04019a7e00ed1c897552395..4d2deebc0f4d8180a3b35ac382bfa3144facae3d 100644 --- a/packages/uni-quickapp-webview/dist/uni.api.esm.js +++ b/packages/uni-quickapp-webview/dist/uni.api.esm.js @@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { return fn.apply(null, formatApiArgs(args)); }; } -function createSyncApi(name, fn, protocol, options) { - return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); +function defineSyncApi(name, fn, protocol, options) { + return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); } -function createApi(type, name, fn, protocol, options) { +function defineApi(type, name, fn, protocol, options) { switch (type) { case API_TYPE_ON: return wrapperApi(wrapperOnApi(name, fn), name, protocol); @@ -324,7 +324,7 @@ function checkDeviceWidth() { deviceDPR = pixelRatio; isIOS = platform === 'ios'; } -const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { +const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => { if (deviceWidth === 0) { checkDeviceWidth(); } @@ -506,7 +506,7 @@ function removeHook(hooks, hook) { hooks.splice(index, 1); } } -const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { +const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => { if (typeof method === 'string' && isPlainObject(interceptor)) { mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); } @@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => mergeInterceptorHook(globalInterceptors, method); } }, AddInterceptorProtocol); -const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { +const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => { if (typeof method === 'string') { if (isPlainObject(interceptor)) { removeInterceptorHook(scopedInterceptors[method], interceptor); diff --git a/packages/uni-quickapp-webview/src/platform/index.ts b/packages/uni-quickapp-webview/src/platform/index.ts index 2d4565e6a779fb04f051e319595a1a9230534005..712a47d9a7ec80ce3741665750056e56446b2e19 100644 --- a/packages/uni-quickapp-webview/src/platform/index.ts +++ b/packages/uni-quickapp-webview/src/platform/index.ts @@ -1,3 +1,4 @@ export function getBaseSystemInfo() { return qa.getSystemInfoSync() } +export function getRealPath() {}