@ray-js/api 1.4.54 → 1.4.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/BaseKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('BaseKit');
4
5
  export const stopAccelerometer = factory('stopAccelerometer');
5
6
  export const startAccelerometer = factory('startAccelerometer');
6
7
  export const getAudioFileDuration = factory('getAudioFileDuration');
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/BizKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('BizKit');
4
5
  export const apiRequestByAtop = factory('apiRequestByAtop');
5
6
  export const event = factory('event');
6
7
  export const beginEvent = factory('beginEvent');
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/DeviceKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('DeviceKit');
4
5
  export const unregisterLeaveBeaconFenceEvent = factory('unregisterLeaveBeaconFenceEvent', {
5
6
  "namespace": "device"
6
7
  });
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/HomeKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('HomeKit');
4
5
  export const home = {
5
6
  getCurrentHomeInfo: factory('getCurrentHomeInfo', {
6
7
  "namespace": "home"
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/MapKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('MapKit');
4
5
 
5
6
  // ray 1.1.0 集成
6
7
  export const map = {
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/MiniKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('MiniKit');
4
5
  export const nativeDisabled = factory('nativeDisabled');
5
6
  export const nativeInovke = factory('nativeInovke');
6
7
  export const getPermissionConfig = factory('getPermissionConfig');
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/OutdoorKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('OutdoorKit');
4
5
  export const outdoor = {
5
6
  bindSlaveDevice: factory('bindSlaveDevice', {
6
7
  "namespace": "outdoor"
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/MapKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('P2PKit');
4
5
 
5
6
  // ray 1.4.0 集成
6
7
  export const p2p = {
@@ -1,6 +1,7 @@
1
1
  /// <reference path="../@types/PlayNetKit.d.ts" />
2
2
 
3
- import { factory } from './utils';
3
+ import { createFactory } from './utils';
4
+ const factory = createFactory('PlayNetKit');
4
5
  export const playnet = {
5
6
  autoConnectToAp: factory('autoConnectToAp', {
6
7
  "namespace": "playnet"
@@ -60,4 +60,28 @@ declare const getDevProperty: (params: IGetDevProperty) => Promise<string>;
60
60
  * @param {string} devId 设备Id
61
61
  */
62
62
  declare const saveDevProperty: (params: ISaveDevProperty) => Promise<boolean>;
63
- export { getDpsInfos, updateDpName, getGroupDpsInfos, updateGroupDpName, getWeatherQuality, getWeathers, saveCustomizePosition, getCustomizePosition, getDevProperty, saveDevProperty, };
63
+ export interface GetRemoteLocalRelationParams {
64
+ /**
65
+ * 遥控器设备id
66
+ */
67
+ devId: string;
68
+ /**
69
+ * 设备类型
70
+ * @default 0 // 缺省为0表示Zigbee
71
+ */
72
+ type: number;
73
+ }
74
+ export interface GetRemoteLocalRelationResponse {
75
+ locals: Array<{
76
+ categoryCode: string;
77
+ code: string;
78
+ localId: string;
79
+ }>;
80
+ }
81
+ /**
82
+ * 面板获取配网后分配的localIds
83
+ * @param params { devId: string, type: number }
84
+ * @returns
85
+ */
86
+ declare const getRemoteLocalRelation: (params: GetRemoteLocalRelationParams) => Promise<GetRemoteLocalRelationResponse>;
87
+ export { getDpsInfos, updateDpName, getGroupDpsInfos, updateGroupDpName, getWeatherQuality, getWeathers, saveCustomizePosition, getCustomizePosition, getDevProperty, saveDevProperty, getRemoteLocalRelation, };
@@ -134,4 +134,18 @@ const saveDevProperty = params => {
134
134
  data: _objectSpread({}, params)
135
135
  });
136
136
  };
137
- export { getDpsInfos, updateDpName, getGroupDpsInfos, updateGroupDpName, getWeatherQuality, getWeathers, saveCustomizePosition, getCustomizePosition, getDevProperty, saveDevProperty };
137
+ /**
138
+ * 面板获取配网后分配的localIds
139
+ * @param params { devId: string, type: number }
140
+ * @returns
141
+ */
142
+ const getRemoteLocalRelation = params => {
143
+ return requestCloud({
144
+ api: 'tuya.p.remote.local.relation.get',
145
+ data: _objectSpread({
146
+ type: 0
147
+ }, params),
148
+ version: '1.0'
149
+ });
150
+ };
151
+ export { getDpsInfos, updateDpName, getGroupDpsInfos, updateGroupDpName, getWeatherQuality, getWeathers, saveCustomizePosition, getCustomizePosition, getDevProperty, saveDevProperty, getRemoteLocalRelation };
package/lib/constants.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { decode } from 'base64-browser';
2
- const THING = decode('dHV5YQ==');
2
+ const THING = decode('dHV5YQ=='); // => 'tuya'
3
3
  export { THING };
@@ -0,0 +1,23 @@
1
+ import { ICommon } from './common';
2
+ type GwIdParams = {
3
+ gwId?: string;
4
+ } & ICommon;
5
+ /**
6
+ * 打开 ZigBee 网关面板配网子设备(旧版)
7
+ * @param params { gwId?: string }
8
+ * @returns
9
+ */
10
+ export declare function openPresentGatewayCategroy(params?: GwIdParams): Promise<void>;
11
+ /**
12
+ * 打开网关面板配网子设备 - 搜索配网(新版)
13
+ * @param params { gwId?: string }
14
+ * @returns
15
+ */
16
+ export declare function openDeviceOnlySearchConfigGwSub(params?: GwIdParams): Promise<void>;
17
+ /**
18
+ * 打开网关面板配网子设备 - 配网帮助列表(新版)
19
+ * @param params { gwId?: string }
20
+ * @returns
21
+ */
22
+ export declare function openDeviceGWSubDeviceHelpList(params?: GwIdParams): Promise<void>;
23
+ export {};
@@ -0,0 +1,27 @@
1
+ import { nativeRouter } from './common';
2
+ /**
3
+ * 打开 ZigBee 网关面板配网子设备(旧版)
4
+ * @param params { gwId?: string }
5
+ * @returns
6
+ */
7
+ export function openPresentGatewayCategroy(params) {
8
+ return nativeRouter('presentGatewayCategroy', params);
9
+ }
10
+
11
+ /**
12
+ * 打开网关面板配网子设备 - 搜索配网(新版)
13
+ * @param params { gwId?: string }
14
+ * @returns
15
+ */
16
+ export function openDeviceOnlySearchConfigGwSub(params) {
17
+ return nativeRouter('device_only_search_config_gw_sub', params);
18
+ }
19
+
20
+ /**
21
+ * 打开网关面板配网子设备 - 配网帮助列表(新版)
22
+ * @param params { gwId?: string }
23
+ * @returns
24
+ */
25
+ export function openDeviceGWSubDeviceHelpList(params) {
26
+ return nativeRouter('device_gw_sub_device_help_list', params);
27
+ }
package/lib/utils.d.ts CHANGED
@@ -3,8 +3,9 @@ type Opts = {
3
3
  deprecated?: boolean;
4
4
  namespace?: string;
5
5
  };
6
+ export declare function createFactory(kitName: string): (name: string, opts?: Opts) => () => any;
6
7
  export declare function factory(name: string, opts?: Opts): () => any;
7
- export declare function factoryContants(name: string, opts?: Opts): any;
8
+ export declare function factoryConstants(name: string, opts?: Opts): any;
8
9
  export declare const parseUrl: (url: string) => import("query-string").ParsedUrl;
9
10
  export declare const stringifyUrl: (object: UrlObject) => string;
10
11
  export {};
package/lib/utils.js CHANGED
@@ -1,29 +1,51 @@
1
- import { stringifyUrl as _stringifyUrl, parseUrl as _parseUrl } from 'query-string';
1
+ import { parseUrl as _parseUrl, stringifyUrl as _stringifyUrl } from 'query-string';
2
+ export function createFactory(kitName) {
3
+ return function (name) {
4
+ let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5
+ return function () {
6
+ var _inst$opts$namespace;
7
+ const methodName = "ty.".concat(opts.namespace ? opts.namespace + '.' : '').concat(name);
8
+ if (opts.deprecated) {
9
+ console.warn("\"".concat(methodName, "\" method has been deprecated."));
10
+ }
11
+ const inst = typeof ty === 'undefined' ? {} : ty;
12
+ const method = opts.namespace ? ((_inst$opts$namespace = inst[opts.namespace]) !== null && _inst$opts$namespace !== void 0 ? _inst$opts$namespace : {})[name] : inst[name];
13
+ if (!method) {
14
+ console.warn('tips:', "\"".concat(methodName, "\" method not exits."));
15
+ console.warn('tips:', "Please check kit \"".concat(kitName, "\" dependency is enabled."));
16
+ return;
17
+ }
18
+ // eslint-disable-next-line prefer-rest-params
19
+ return method.apply(this, arguments);
20
+ };
21
+ };
22
+ }
2
23
  export function factory(name) {
3
24
  let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4
25
  return function () {
5
- var _inst$opts$namespace;
26
+ var _inst$opts$namespace2;
27
+ const methodName = "ty.".concat(opts.namespace ? opts.namespace + '.' : '').concat(name);
6
28
  if (opts.deprecated) {
7
- console.warn("\u8BE5\u65B9\u6CD5 ".concat(name, " \u5DF2\u5F03\u7528"));
29
+ console.warn("\"".concat(methodName, "\" method has been deprecated."));
8
30
  }
9
31
  const inst = typeof ty === 'undefined' ? {} : ty;
10
- const method = opts.namespace ? ((_inst$opts$namespace = inst[opts.namespace]) !== null && _inst$opts$namespace !== void 0 ? _inst$opts$namespace : {})[name] : inst[name];
32
+ const method = opts.namespace ? ((_inst$opts$namespace2 = inst[opts.namespace]) !== null && _inst$opts$namespace2 !== void 0 ? _inst$opts$namespace2 : {})[name] : inst[name];
11
33
  if (!method) {
12
- console.warn("// TODO \u6682\u672A\u5B9E\u73B0\u65B9\u6CD5 ".concat(opts.namespace ? opts.namespace + '.' : '').concat(name));
34
+ console.warn('tips:', "\"".concat(methodName, "\" method not exits."));
13
35
  return;
14
36
  }
15
37
  // eslint-disable-next-line prefer-rest-params
16
38
  return method.apply(this, arguments);
17
39
  };
18
40
  }
19
- export function factoryContants(name) {
41
+ export function factoryConstants(name) {
20
42
  let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
21
43
  if (opts.deprecated) {
22
- console.warn("\u8BE5\u53D8\u91CF ".concat(name, " \u5DF2\u5F03\u7528"));
44
+ console.warn("\"ty.".concat(name, "\" constant has been deprecated."));
23
45
  }
24
46
  const inst = typeof ty === 'undefined' ? {} : ty;
25
47
  if (!inst[name]) {
26
- console.warn("// TODO \u6682\u672A\u5B9E\u73B0\u53D8\u91CF ".concat(name));
48
+ console.warn('tips', "\"ty.".concat(name, "\" constant not exits."));
27
49
  return;
28
50
  }
29
51
  return inst[name];
package/lib/viewAPI.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference path="../@types/api.d.ts" />
2
2
 
3
- import { factory, factoryContants } from './utils';
4
- export const env = factoryContants('env');
3
+ import { factory, factoryConstants } from './utils';
4
+ export const env = factoryConstants('env');
5
5
  export const createAnimation = factory('createAnimation');
6
6
  export const pageScrollTo = factory('pageScrollTo');
7
7
  export const createSelectorQuery = factory('createSelectorQuery');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/api",
3
- "version": "1.4.54",
3
+ "version": "1.4.57",
4
4
  "description": "Ray universal api",
5
5
  "keywords": [
6
6
  "ray"
@@ -29,14 +29,14 @@
29
29
  "watch": "ray start --type=component"
30
30
  },
31
31
  "dependencies": {
32
- "@ray-js/framework": "1.4.54",
33
- "@ray-js/router": "1.4.54",
32
+ "@ray-js/framework": "1.4.57",
33
+ "@ray-js/router": "1.4.57",
34
34
  "@ray-js/wechat": "^0.2.8",
35
35
  "base64-browser": "^1.0.1",
36
36
  "query-string": "^7.1.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@ray-js/cli": "1.4.54",
39
+ "@ray-js/cli": "1.4.57",
40
40
  "art-template": "^4.13.2",
41
41
  "fs-extra": "^10.1.0",
42
42
  "miniprogram-api-typings": "^3.12.2",
@@ -46,5 +46,5 @@
46
46
  "access": "public",
47
47
  "registry": "https://registry.npmjs.org"
48
48
  },
49
- "gitHead": "06c591f21809ed9d04e1d20ebc8d92e4d00643a6"
49
+ "gitHead": "fd1b5fa91e00c6b215fc941d3afd0708eeed6566"
50
50
  }