New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@psdk/device-ble-taro

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@psdk/device-ble-taro - npm Package Compare versions

Comparing version 0.2.67 to 0.3.0

35

build/connected.js

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,15 +10,10 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaroBleConnectedDevice = void 0;
const frame_father_1 = require("@psdk/frame-father");
const await_timeout_1 = __importDefault(require("await-timeout"));
const taro_1 = __importDefault(require("@tarojs/taro"));
class TaroBleConnectedDevice {
import { ConnectionState } from "@psdk/frame-father";
import Timeout from 'await-timeout';
import Taro from "@tarojs/taro";
export class TaroBleConnectedDevice {
constructor(options) {
this.device = options.device;
this.scpair = options.scpair;
this._connectionState = frame_father_1.ConnectionState.CONNECTED;
this._connectionState = ConnectionState.CONNECTED;
this.dataOfRead = [];

@@ -34,3 +28,3 @@ this.doListen();

return;
taro_1.default.onBLECharacteristicValueChange((value) => __awaiter(this, void 0, void 0, function* () {
Taro.onBLECharacteristicValueChange((value) => __awaiter(this, void 0, void 0, function* () {
// this.dataOfRead.push(value)

@@ -41,6 +35,6 @@ if (this.notifyCallback) {

}));
taro_1.default.onBLEConnectionStateChange(value => {
this._connectionState = value.connected ? frame_father_1.ConnectionState.CONNECTED : frame_father_1.ConnectionState.DISCONNECTED;
Taro.onBLEConnectionStateChange(value => {
this._connectionState = value.connected ? ConnectionState.CONNECTED : ConnectionState.DISCONNECTED;
});
taro_1.default.notifyBLECharacteristicValueChange({
Taro.notifyBLECharacteristicValueChange({
deviceId: this.device.deviceId,

@@ -62,3 +56,3 @@ serviceId: this.scpair.service.uuid,

}
taro_1.default.readBLECharacteristicValue({
Taro.readBLECharacteristicValue({
deviceId: this.device.deviceId,

@@ -92,3 +86,3 @@ serviceId: this.scpair.service.uuid,

return new Promise((resolve, reject) => {
taro_1.default.closeBLEConnection({
Taro.closeBLEConnection({
deviceId: this.device.deviceId,

@@ -110,4 +104,4 @@ success: () => {

read(options) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
var _a;
if (this.dataOfRead.length > 0) {

@@ -125,3 +119,3 @@ this.dataOfRead.splice(0, this.dataOfRead.length);

if (this.dataOfRead.length == 0) {
yield await_timeout_1.default.set(100);
yield Timeout.set(100);
continue;

@@ -138,3 +132,3 @@ }

return new Promise((resolve, reject) => {
taro_1.default.writeBLECharacteristicValue({
Taro.writeBLECharacteristicValue({
deviceId: this.device.deviceId,

@@ -162,2 +156,1 @@ serviceId: this.scpair.service.uuid,

}
exports.TaroBleConnectedDevice = TaroBleConnectedDevice;

20

build/index.js

@@ -1,18 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./connected"), exports);
__exportStar(require("./provider"), exports);
export * from './connected';
export * from './provider';

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,13 +10,8 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaroBleBluetooth = void 0;
const device_bluetooth_traits_1 = require("@psdk/device-bluetooth-traits");
const frame_father_1 = require("@psdk/frame-father");
const await_timeout_1 = __importDefault(require("await-timeout"));
const connected_1 = require("./connected");
const taro_1 = __importDefault(require("@tarojs/taro"));
class TaroBleBluetooth extends device_bluetooth_traits_1.Jluetooth {
import { Jluetooth, JluetoothDevice, TBluetoothHelpers, } from "@psdk/device-bluetooth-traits";
import { ConnectionState } from "@psdk/frame-father";
import Timeout from 'await-timeout';
import { TaroBleConnectedDevice } from "./connected";
import Taro from "@tarojs/taro";
export class TaroBleBluetooth extends Jluetooth {
constructor(options) {

@@ -31,3 +25,3 @@ super();

return false;
return this.connectedDevice.connectionState() === frame_father_1.ConnectionState.CONNECTED;
return this.connectedDevice.connectionState() === ConnectionState.CONNECTED;
}

@@ -37,3 +31,3 @@ bluetoothAdapterState() {

return new Promise((resolve, reject) => {
taro_1.default.getBluetoothAdapterState({
Taro.getBluetoothAdapterState({
success: (r) => resolve(r),

@@ -47,4 +41,4 @@ // @ts-ignore

connect(device, options) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
var _a;
if (this.isConnected()) {

@@ -58,3 +52,3 @@ if (!((_a = options === null || options === void 0 ? void 0 : options.autoSwitchDevice) !== null && _a !== void 0 ? _a : false)) {

yield this.createBLEConnection({ deviceId: origin.deviceId, timeout: options === null || options === void 0 ? void 0 : options.timeout, });
yield await_timeout_1.default.set(500);
yield Timeout.set(500);
const services = yield this.getBLEDeviceServices({ deviceId: origin.deviceId });

@@ -68,3 +62,3 @@ const scpair = yield this.findSCPair({

}
this.connectedDevice = new connected_1.TaroBleConnectedDevice({
this.connectedDevice = new TaroBleConnectedDevice({
device: origin,

@@ -84,14 +78,14 @@ scpair,

yield this.closeBluetoothAdapter();
yield await_timeout_1.default.set(300);
yield Timeout.set(300);
yield this.openBluetoothAdapter();
const state = yield this.bluetoothAdapterState();
if (!state.available) {
yield await_timeout_1.default.set(500);
yield Timeout.set(500);
}
if (state.discovering) {
yield this.stopDiscovery();
yield await_timeout_1.default.set(500);
yield Timeout.set(500);
}
return new Promise((resolve, reject) => {
taro_1.default.startBluetoothDevicesDiscovery({
Taro.startBluetoothDevicesDiscovery({
// services: this.allowServices,

@@ -111,3 +105,3 @@ allowDuplicatesKey: false,

return new Promise((resolve, reject) => {
taro_1.default.stopBluetoothDevicesDiscovery({
Taro.stopBluetoothDevicesDiscovery({
success: (result) => resolve(result),

@@ -124,3 +118,3 @@ // @ts-ignore

return new Promise((resolve, reject) => {
taro_1.default.openBluetoothAdapter({
Taro.openBluetoothAdapter({
success: (ret) => {

@@ -142,3 +136,3 @@ if (ret.errMsg && ret.errMsg.indexOf('ok') == -1) {

return new Promise((resolve, reject) => {
taro_1.default.closeBluetoothAdapter({
Taro.closeBluetoothAdapter({
success: (ret) => {

@@ -158,3 +152,3 @@ if (ret.errMsg && ret.errMsg.indexOf('ok') == -1) {

onBluetoothDeviceFound() {
taro_1.default.onBluetoothDeviceFound((result) => __awaiter(this, void 0, void 0, function* () {
Taro.onBluetoothDeviceFound((result) => __awaiter(this, void 0, void 0, function* () {
const foundDevices = result.devices;

@@ -172,3 +166,3 @@ if (!foundDevices.length) {

})
.map(item => new device_bluetooth_traits_1.JluetoothDevice({
.map(item => new JluetoothDevice({
origin: item,

@@ -189,3 +183,3 @@ name: item.name || item.localName,

return new Promise((resolve, reject) => {
taro_1.default.createBLEConnection({
Taro.createBLEConnection({
deviceId: options.deviceId,

@@ -203,3 +197,3 @@ timeout: options.timeout,

return new Promise((resolve, reject) => {
taro_1.default.getBLEDeviceServices({
Taro.getBLEDeviceServices({
deviceId: options.deviceId,

@@ -222,3 +216,3 @@ success: (result) => {

return new Promise((resolve, reject) => {
taro_1.default.getBLEDeviceCharacteristics({
Taro.getBLEDeviceCharacteristics({
deviceId: options.deviceId,

@@ -248,3 +242,3 @@ serviceId: options.serviceId,

// });
taro_1.default.getLocation({
Taro.getLocation({
success: () => resolve(),

@@ -258,4 +252,4 @@ // @ts-ignore

findSCPair(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
// fill data

@@ -273,3 +267,3 @@ const _characteristicsMap = new Map();

for (const service of options.services) {
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, (_c = this.options) === null || _c === void 0 ? void 0 : _c.allowServices)) {
if (!TBluetoothHelpers.isAllowServices(service.uuid, (_c = this.options) === null || _c === void 0 ? void 0 : _c.allowServices)) {
continue;

@@ -301,3 +295,3 @@ }

for (const service of options.services) {
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, (_f = this.options) === null || _f === void 0 ? void 0 : _f.allowServices)) {
if (!TBluetoothHelpers.isAllowServices(service.uuid, (_f = this.options) === null || _f === void 0 ? void 0 : _f.allowServices)) {
continue;

@@ -324,3 +318,3 @@ }

for (const service of options.services) {
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, (_j = this.options) === null || _j === void 0 ? void 0 : _j.allowServices)) {
if (!TBluetoothHelpers.isAllowServices(service.uuid, (_j = this.options) === null || _j === void 0 ? void 0 : _j.allowServices)) {
continue;

@@ -350,3 +344,3 @@ }

for (const service of options.services) {
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, (_k = this.options) === null || _k === void 0 ? void 0 : _k.allowServices)) {
if (!TBluetoothHelpers.isAllowServices(service.uuid, (_k = this.options) === null || _k === void 0 ? void 0 : _k.allowServices)) {
continue;

@@ -371,2 +365,1 @@ }

}
exports.TaroBleBluetooth = TaroBleBluetooth;
{
"name": "@psdk/device-ble-taro",
"version": "0.2.67",
"version": "0.3.0",
"description": "psdk",

@@ -9,3 +9,3 @@ "main": "build/index.js",

"build": "tsc",
"package": "tsc && ncc build --source-map build/index.js -m -C -o dist && npx webpack",
"package": "tsc && ncc build --source-map build/index.js -m -C -o dist",
"test": "jest",

@@ -19,35 +19,16 @@ "docs": "npx typedoc --out dist/docs index.ts"

"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.17.12",
"@babel/plugin-proposal-decorators": "^7.17.12",
"@babel/plugin-proposal-export-namespace-from": "^7.17.12",
"@babel/plugin-proposal-function-sent": "^7.17.12",
"@babel/plugin-proposal-numeric-separator": "^7.16.7",
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
"@babel/plugin-proposal-throw-expressions": "^7.16.7",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-transform-modules-commonjs": "^7.18.0",
"@babel/plugin-transform-object-assign": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.18.0",
"@babel/preset-env": "^7.18.0",
"@babel/preset-typescript": "^7.17.12",
"@babel/register": "^7.17.7",
"@babel/runtime-corejs3": "^7.18.0",
"@tarojs/taro": "^3.5.1",
"@types/jest": "^27.5.1",
"@types/node": "^17.0.35",
"@vercel/ncc": "^0.33.4",
"babel-loader": "^8.2.5",
"buffer": "^6.0.3",
"jest": "^28.1.0",
"string_decoder": "^1.3.0",
"ts-jest": "^28.0.2",
"typedoc": "^0.22.15",
"typescript": "^4.6.4",
"webpack": "^5.72.1",
"webpack-cli": "^4.9.2"
"@babel/core": "^7.24.5",
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@tarojs/taro": "^3.6.29",
"@types/jest": "^29.5.12",
"@vercel/ncc": "^0.38.1",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"typedoc": "^0.25.13",
"typescript": "^5.4.5"
},
"dependencies": {
"@psdk/device-bluetooth-traits": "0.2.67",
"@psdk/frame-father": "0.2.67",
"@psdk/device-bluetooth-traits": "0.3.0",
"@psdk/frame-father": "0.3.0",
"await-timeout": "^1.1.1"

@@ -59,3 +40,3 @@ },

],
"gitHead": "1b469612990a3efbf1a3fe4296ed13e8c8865988"
"gitHead": "9796259a6a24ae7e334340f6c28d5ae9b3e45401"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc