@ray-js/api 1.4.56 → 1.4.58

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"
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 openDeviceGWSubSearchConfigure(params?: GwIdParams): Promise<void>;
17
+ /**
18
+ * 打开网关面板配网子设备 - 配网帮助列表(新版)
19
+ * @param params { gwId?: string }
20
+ * @returns
21
+ */
22
+ export declare function openDeviceGWSubHelpList(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 openDeviceGWSubSearchConfigure(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 openDeviceGWSubHelpList(params) {
26
+ return nativeRouter('device_gw_sub_device_help_list', params);
27
+ }
@@ -2,3 +2,4 @@ export * from './device';
2
2
  export * from './outdoors';
3
3
  export * from './root';
4
4
  export * from './ipc';
5
+ export * from './gw';
@@ -1,4 +1,5 @@
1
1
  export * from './device';
2
2
  export * from './outdoors';
3
3
  export * from './root';
4
- export * from './ipc';
4
+ export * from './ipc';
5
+ export * from './gw';
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.56",
3
+ "version": "1.4.58",
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.56",
33
- "@ray-js/router": "1.4.56",
32
+ "@ray-js/framework": "1.4.58",
33
+ "@ray-js/router": "1.4.58",
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.56",
39
+ "@ray-js/cli": "1.4.58",
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": "2a104c2e420ad07aa99c0974bb493d2119e37202"
49
+ "gitHead": "cba39c78d2d33035b58707568234b4ca68b8a5c7"
50
50
  }