Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
4 changes: 0 additions & 4 deletions .github/workflows/fe-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ jobs:
working-directory: ./fe
run: pnpm install

- name: Run linter
working-directory: ./fe
run: pnpm lint

- name: Build packages
working-directory: ./fe
run: pnpm --filter "@dimina/common" --filter "@dimina/compiler" build
Expand Down
2 changes: 1 addition & 1 deletion fe/packages/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"less": "^4.6.4",
"listr2": "^9.0.5",
"magic-string": "^0.30.21",
"oxc-parser": "^0.131.0",
"oxc-parser": "^0.132.0",
"oxc-walker": "^1.0.0",
"postcss": "^8.5.14",
"postcss-selector-parser": "^7.1.1",
Expand Down
64 changes: 44 additions & 20 deletions fe/packages/service/src/api/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,56 @@ export function invokeAPI(name, data, target = 'container') {
if (data === undefined || typeof data === 'string' || Array.isArray(data)) {
params = data
}
else {
if (isFunction(data)) {
params = {
success: callback.store(data, true),
}
else if (isFunction(data)) {
params = {
success: callback.store(data, true),
}
else {
const { success, fail, complete, keep, evtId, ...rest} = data
}
else if (Object.prototype.hasOwnProperty.call(data, 'success') || Object.prototype.hasOwnProperty.call(data, 'fail') || Object.prototype.hasOwnProperty.call(data, 'complete')) {
const { success, fail, complete, keep, evtId, ...rest} = data

params = rest
params = rest

if (isFunction(success)) {
params.success = callback.store(success, keep, evtId)
}
else {
params.success = success
}
if (isFunction(success)) {
params.success = callback.store(success, keep, evtId)
}
else {
params.success = success
}

if (isFunction(fail)) {
params.fail = callback.store(fail, keep, evtId)
}
if (isFunction(fail)) {
params.fail = callback.store(fail, keep, evtId)
}

if (isFunction(complete)) {
params.complete = callback.store(complete, keep, evtId)
}
if (isFunction(complete)) {
params.complete = callback.store(complete, keep, evtId)
}
}
else {
const { keep, evtId, ...rest } = data
if (!keep) {
params = { ...rest }
return new Promise((resolve) => {
params.success = callback.store((res) => resolve(res))
params.fail = callback.store((res) => resolve(res))
const msg = {
type: 'invokeAPI',
target,
body: {
name,
bridgeId: router.getPageInfo().id,
params,
},
}
if (target === 'container') {
message.invoke(msg)
}
else {
message.send(msg)
}
})
}
params = rest
}

const msg = {
Expand Down
12 changes: 6 additions & 6 deletions fe/packages/service/src/api/core/base/app-event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,47 @@ import { invokeAPI } from '@/api/common'
* https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html
*/
export function onError(opts) {
invokeAPI('onError', opts)
return invokeAPI('onError', opts)
}

/**
* 移除小程序错误事件的监听函数
* https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offError.html
*/
export function offError(opts) {
invokeAPI('offError', opts)
return invokeAPI('offError', opts)
}

/**
* 监听小程序切前台事件
* https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppShow.html
*/
export function onAppShow(opts) {
invokeAPI('onAppShow', opts)
return invokeAPI('onAppShow', opts)
}

/**
* 监听小程序切后台事件
* https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppHide.html
*/
export function onAppHide(opts) {
invokeAPI('onAppHide', opts)
return invokeAPI('onAppHide', opts)
}

/**
* 移除小程序切前台事件的监听函数
* https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppShow.html
*/
export function offAppShow(opts) {
invokeAPI('offAppShow', opts)
return invokeAPI('offAppShow', opts)
}

/**
* 移除小程序切后台事件的监听函数
* https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppHide.html
*/
export function offAppHide(opts) {
invokeAPI('offAppHide', opts)
return invokeAPI('offAppHide', opts)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions fe/packages/service/src/api/core/base/subpackage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { invokeAPI } from '@/api/common'
* https://developers.weixin.qq.com/miniprogram/dev/api/base/subpackage/wx.preDownloadSubpackage.html
*/
export function preDownloadSubpackage(opts) {
invokeAPI('preDownloadSubpackage', opts)
return invokeAPI('preDownloadSubpackage', opts)
}

/**
* 触发分包加载
* https://developers.weixin.qq.com/minigame/dev/api/base/subpackage/wx.loadSubpackage.html
*/
export function loadSubpackage(opts) {
invokeAPI('loadSubpackage', opts)
return invokeAPI('loadSubpackage', opts)
}
6 changes: 3 additions & 3 deletions fe/packages/service/src/api/core/base/system/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { invokeAPI } from '@/api/common'
* https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.openSystemBluetoothSetting.html
*/
export function openSystemBluetoothSetting(opts) {
invokeAPI('openSystemBluetoothSetting', opts)
return invokeAPI('openSystemBluetoothSetting', opts)
}

/**
Expand All @@ -21,7 +21,7 @@ export function getWindowInfo(opts) {
* https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.openAppAuthorizeSetting.html
*/
export function openAppAuthorizeSetting(opts) {
invokeAPI('openAppAuthorizeSetting', opts)
return invokeAPI('openAppAuthorizeSetting', opts)
}

/**
Expand All @@ -44,7 +44,7 @@ export function getSystemInfoSync() {
* https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getSystemInfoAsync.html
*/
export function getSystemInfoAsync(opts) {
invokeAPI('getSystemInfoAsync', opts)
return invokeAPI('getSystemInfoAsync', opts)
}

export function getAppBaseInfo() {
Expand Down
6 changes: 3 additions & 3 deletions fe/packages/service/src/api/core/camera/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class CameraContext {
}

takePhoto(data) {
invokeAPI('takePhoto', data)
return invokeAPI('takePhoto', data)
}

startRecord() {
invokeAPI('startRecord')
return invokeAPI('startRecord')
}

stopRecord() {
invokeAPI('stopRecord')
return invokeAPI('stopRecord')
}
}
4 changes: 2 additions & 2 deletions fe/packages/service/src/api/core/data-analysis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { invokeAPI } from '@/api/common'
* https://developers.weixin.qq.com/miniprogram/dev/api/data-analysis/wx.reportAnalytics.html
*/
export function reportAnalytics(...opts) {
invokeAPI('reportAnalytics', opts)
return invokeAPI('reportAnalytics', opts)
}

export function reportEvent(eventId, data) {
invokeAPI('reportAnalytics', { eventId, data })
return invokeAPI('reportAnalytics', { eventId, data })
}
26 changes: 13 additions & 13 deletions fe/packages/service/src/api/core/device/bluetooth-ble/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,55 @@ import { invokeAPI } from '@/api/common'
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.writeBLECharacteristicValue.html
*/
export function writeBLECharacteristicValue(opts) {
invokeAPI('writeBLECharacteristicValue', opts)
return invokeAPI('writeBLECharacteristicValue', opts)
}

/**
* 协商设置蓝牙低功耗的最大传输单元 (Maximum Transmission Unit, MTU)。需在 wx.createBLEConnection 调用成功后调用。
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.setBLEMTU.html
*/
export function setBLEMTU(opts) {
invokeAPI('setBLEMTU', opts)
return invokeAPI('setBLEMTU', opts)
}

/**
* 读取蓝牙低功耗设备特征值的二进制数据。注意:必须设备的特征支持 read 才可以成功调用。
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.readBLECharacteristicValue.html
*/
export function readBLECharacteristicValue(opts) {
invokeAPI('readBLECharacteristicValue', opts)
return invokeAPI('readBLECharacteristicValue', opts)
}

/**
* 监听蓝牙低功耗连接状态改变事件。包括开发者主动连接或断开连接,设备丢失,连接异常断开等等
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLEConnectionStateChange.html
*/
export function onBLEConnectionStateChange(opts) {
invokeAPI('onBLEConnectionStateChange', opts)
return invokeAPI('onBLEConnectionStateChange', opts)
}

/**
* 监听蓝牙低功耗设备的特征值变化事件。必须先调用 wx.notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification。
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLECharacteristicValueChange.html
*/
export function onBLECharacteristicValueChange(opts) {
invokeAPI('onBLECharacteristicValueChange', opts)
return invokeAPI('onBLECharacteristicValueChange', opts)
}

/**
* 移除蓝牙低功耗连接状态改变事件的监听函数。不传此参数则移除所有监听函数。
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html
*/
export function offBLEConnectionStateChange(opts) {
invokeAPI('offBLEConnectionStateChange', opts)
return invokeAPI('offBLEConnectionStateChange', opts)
}

/**
* 移除蓝牙低功耗设备的特征值变化事件的全部监听函数
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLECharacteristicValueChange.html
*/
export function offBLECharacteristicValueChange() {
invokeAPI('offBLECharacteristicValueChange')
return invokeAPI('offBLECharacteristicValueChange')
}

/**
Expand All @@ -62,31 +62,31 @@ export function offBLECharacteristicValueChange() {
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.notifyBLECharacteristicValueChange.html
*/
export function notifyBLECharacteristicValueChange(opts) {
invokeAPI('notifyBLECharacteristicValueChange', opts)
return invokeAPI('notifyBLECharacteristicValueChange', opts)
}

/**
* 获取蓝牙低功耗设备所有服务 (service)。
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceServices.html
*/
export function getBLEDeviceServices(opts) {
invokeAPI('getBLEDeviceServices', opts)
return invokeAPI('getBLEDeviceServices', opts)
}

/**
* 获取蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI)
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceRSSI.html
*/
export function getBLEDeviceRSSI(opts) {
invokeAPI('getBLEDeviceRSSI', opts)
return invokeAPI('getBLEDeviceRSSI', opts)
}

/**
* 获取蓝牙低功耗设备某个服务中所有特征 (characteristic)。
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceCharacteristics.html
*/
export function getBLEDeviceCharacteristics(opts) {
invokeAPI('getBLEDeviceCharacteristics', opts)
return invokeAPI('getBLEDeviceCharacteristics', opts)
}

/**
Expand All @@ -95,13 +95,13 @@ export function getBLEDeviceCharacteristics(opts) {
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.createBLEConnection.html
*/
export function createBLEConnection(opts) {
invokeAPI('createBLEConnection', opts)
return invokeAPI('createBLEConnection', opts)
}

/**
* 断开与蓝牙低功耗设备的连接。
* https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.closeBLEConnection.html
*/
export function closeBLEConnection(opts) {
invokeAPI('closeBLEConnection', opts)
return invokeAPI('closeBLEConnection', opts)
}
Loading
Loading