@ray-js/api 1.4.22 → 1.4.24
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.
- package/lib/index.d.ts +5 -0
- package/lib/index.js +7 -1
- package/lib/nativeRouters/index.d.ts +1 -0
- package/lib/nativeRouters/index.js +1 -0
- package/lib/nativeRouters/scene.d.ts +34 -0
- package/lib/nativeRouters/scene.js +60 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +13 -0
- package/package.json +5 -5
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
@@ -34,4 +34,10 @@ export * from './cloud';
|
|
34
34
|
*/
|
35
35
|
export * from './viewAPI';
|
36
36
|
export * from './panel';
|
37
|
-
export * from './openGroupCreate';
|
37
|
+
export * from './openGroupCreate';
|
38
|
+
|
39
|
+
/**
|
40
|
+
* 新增跳转Native路由
|
41
|
+
* 1.4.23 openSceneCreate/openSceneEdit
|
42
|
+
*/
|
43
|
+
export * from './nativeRouters';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './scene';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './scene';
|
@@ -0,0 +1,34 @@
|
|
1
|
+
type OpenSceneCreateParams = {
|
2
|
+
devId?: string;
|
3
|
+
success?: () => void;
|
4
|
+
fail?: (err?: {
|
5
|
+
errorMsg: string;
|
6
|
+
errorCode: string | number;
|
7
|
+
innerError: {
|
8
|
+
errorCode: string | number;
|
9
|
+
errorMsg: string;
|
10
|
+
};
|
11
|
+
}) => void;
|
12
|
+
complete?: () => void;
|
13
|
+
} & {
|
14
|
+
[key: string]: string | boolean | number;
|
15
|
+
};
|
16
|
+
export declare function openSceneCreate(params: OpenSceneCreateParams): Promise<void>;
|
17
|
+
type OpenSceneEdit = {
|
18
|
+
devId?: string;
|
19
|
+
sceneId?: string;
|
20
|
+
success?: () => void;
|
21
|
+
fail?: (err?: {
|
22
|
+
errorMsg: string;
|
23
|
+
errorCode: string | number;
|
24
|
+
innerError: {
|
25
|
+
errorCode: string | number;
|
26
|
+
errorMsg: string;
|
27
|
+
};
|
28
|
+
}) => void;
|
29
|
+
complete?: () => void;
|
30
|
+
} & {
|
31
|
+
[key: string]: string | boolean | number;
|
32
|
+
};
|
33
|
+
export declare function openSceneEdit(params: OpenSceneEdit): Promise<void>;
|
34
|
+
export {};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2
|
+
const _excluded = ["success", "fail", "complete"],
|
3
|
+
_excluded2 = ["success", "fail", "complete"];
|
4
|
+
import { objectToUrlParams } from '../utils';
|
5
|
+
export function openSceneCreate(params) {
|
6
|
+
const {
|
7
|
+
success,
|
8
|
+
fail,
|
9
|
+
complete
|
10
|
+
} = params,
|
11
|
+
rest = _objectWithoutProperties(params, _excluded);
|
12
|
+
let paramsStr = '';
|
13
|
+
if (Object.keys(rest).length > 0) {
|
14
|
+
paramsStr = '?' + objectToUrlParams(rest);
|
15
|
+
}
|
16
|
+
return new Promise((resolve, reject) => {
|
17
|
+
ty.router({
|
18
|
+
url: 'tuyaSmart://createScene' + paramsStr,
|
19
|
+
success() {
|
20
|
+
success === null || success === void 0 ? void 0 : success();
|
21
|
+
resolve();
|
22
|
+
},
|
23
|
+
fail(err) {
|
24
|
+
fail === null || fail === void 0 ? void 0 : fail(err);
|
25
|
+
reject(err);
|
26
|
+
},
|
27
|
+
complete() {
|
28
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
29
|
+
}
|
30
|
+
});
|
31
|
+
});
|
32
|
+
}
|
33
|
+
export function openSceneEdit(params) {
|
34
|
+
const {
|
35
|
+
success,
|
36
|
+
fail,
|
37
|
+
complete
|
38
|
+
} = params,
|
39
|
+
rest = _objectWithoutProperties(params, _excluded2);
|
40
|
+
let paramsStr = '';
|
41
|
+
if (Object.keys(rest).length > 0) {
|
42
|
+
paramsStr = '?' + objectToUrlParams(rest);
|
43
|
+
}
|
44
|
+
return new Promise((resolve, reject) => {
|
45
|
+
ty.router({
|
46
|
+
url: 'tuyaSmart://editScene' + paramsStr,
|
47
|
+
success() {
|
48
|
+
success === null || success === void 0 ? void 0 : success();
|
49
|
+
resolve();
|
50
|
+
},
|
51
|
+
fail(err) {
|
52
|
+
fail === null || fail === void 0 ? void 0 : fail(err);
|
53
|
+
reject(err);
|
54
|
+
},
|
55
|
+
complete() {
|
56
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
57
|
+
}
|
58
|
+
});
|
59
|
+
});
|
60
|
+
}
|
package/lib/utils.d.ts
CHANGED
@@ -4,4 +4,5 @@ type Opts = {
|
|
4
4
|
};
|
5
5
|
export declare function factory(name: string, opts?: Opts): () => any;
|
6
6
|
export declare function factoryContants(name: string, opts?: Opts): any;
|
7
|
+
export declare function objectToUrlParams(obj: Record<string, string | number | boolean>): string;
|
7
8
|
export {};
|
package/lib/utils.js
CHANGED
@@ -25,4 +25,17 @@ export function factoryContants(name) {
|
|
25
25
|
return;
|
26
26
|
}
|
27
27
|
return inst[name];
|
28
|
+
}
|
29
|
+
export function objectToUrlParams(obj) {
|
30
|
+
const params = [];
|
31
|
+
for (const key in obj) {
|
32
|
+
// eslint-disable-next-line no-prototype-builtins
|
33
|
+
if (obj.hasOwnProperty(key)) {
|
34
|
+
const value = obj[key];
|
35
|
+
const encodedKey = encodeURIComponent(key);
|
36
|
+
const encodedValue = encodeURIComponent(value);
|
37
|
+
params.push("".concat(encodedKey, "=").concat(encodedValue));
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return params.join('&');
|
28
41
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/api",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.24",
|
4
4
|
"description": "Ray universal api",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -29,13 +29,13 @@
|
|
29
29
|
"watch": "ray start --type=component"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@ray-js/framework": "1.4.
|
33
|
-
"@ray-js/router": "1.4.
|
32
|
+
"@ray-js/framework": "^1.4.24",
|
33
|
+
"@ray-js/router": "^1.4.24",
|
34
34
|
"@ray-js/wechat": "^0.0.33",
|
35
35
|
"base64-browser": "^1.0.1"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
|
-
"@ray-js/cli": "1.4.
|
38
|
+
"@ray-js/cli": "^1.4.24",
|
39
39
|
"art-template": "^4.13.2",
|
40
40
|
"fs-extra": "^10.1.0",
|
41
41
|
"miniprogram-api-typings": "^3.12.0",
|
@@ -45,5 +45,5 @@
|
|
45
45
|
"access": "public",
|
46
46
|
"registry": "https://registry.npmjs.org"
|
47
47
|
},
|
48
|
-
"gitHead": "
|
48
|
+
"gitHead": "5f3689fa6a6843dbc27b9266777873ef876b5e11"
|
49
49
|
}
|