model-action-younuo 1.0.0 → 1.0.1
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/README.md +2 -2
- package/dist/modules/Action.d.ts +4 -4
- package/dist/modules/Action.js +5 -5
- package/dist/modules/Init.d.ts +5 -5
- package/dist/modules/Init.js +2 -2
- package/dist/modules/Path.d.ts +6 -6
- package/dist/modules/Path.js +10 -10
- package/package.json +2 -2
- package/src/modules/Action.ts +6 -6
- package/src/modules/Init.ts +5 -5
- package/src/modules/Path.ts +11 -11
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# model-action-younuo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
三维轻量化三维(iframe 内嵌)与外部页面的通信封装。
|
|
4
4
|
|
|
5
5
|
协议依据:[轻量化API接口协议-基线版本](https://docs.qq.com/doc/DTU9zRWRZZVVRU0FZ)
|
|
6
6
|
调用方法名尽量对齐 `model-action`,**发送的 fName / 字段以文档为准**。
|
|
@@ -81,6 +81,6 @@ await PathAction.pathShowHideRemove('remove') // → faceLine clear
|
|
|
81
81
|
```ts
|
|
82
82
|
// UE
|
|
83
83
|
import { FocusAction, InitAction } from 'model-action'
|
|
84
|
-
//
|
|
84
|
+
// 三维
|
|
85
85
|
import { FocusAction, InitAction } from 'model-action-younuo'
|
|
86
86
|
```
|
package/dist/modules/Action.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 三维轻量化 iframe postMessage 通信核心
|
|
3
3
|
* 调用风格对齐 UE 版 model-action 的 Action.sendParam
|
|
4
4
|
*/
|
|
5
5
|
export type RequiredSome<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
|
|
6
6
|
export interface SendParam {
|
|
7
7
|
cmd: string;
|
|
8
|
-
/**
|
|
8
|
+
/** 三维函数名;不传则用 cmd */
|
|
9
9
|
fName?: string;
|
|
10
10
|
data?: {
|
|
11
11
|
action?: string;
|
|
@@ -46,14 +46,14 @@ export declare class Action {
|
|
|
46
46
|
private static innerMessageHandlers;
|
|
47
47
|
static setOnLog(onLog?: (...args: any[]) => void): void;
|
|
48
48
|
static setConfig(partial: ModelBridgeConfig): void;
|
|
49
|
-
/**
|
|
49
|
+
/** 指定三维 iframe;不传则发送时取页面第一个 iframe */
|
|
50
50
|
static setIframe(iframe: HTMLIFrameElement | null): void;
|
|
51
51
|
static setTargetOrigin(origin: string): void;
|
|
52
52
|
static onLoadStatusChange(handler: (success: boolean) => void): () => boolean;
|
|
53
53
|
static onBuildEvent(handler: (info: any) => void): () => boolean;
|
|
54
54
|
static onFloorEvent(handler: (params: any) => void): () => boolean;
|
|
55
55
|
static onPoiEvent(handler: (params: any) => void): () => boolean;
|
|
56
|
-
/**
|
|
56
|
+
/** 订阅三维主动推送,返回取消订阅函数 */
|
|
57
57
|
static onInnerMessage(handler: (params: any) => void): () => boolean;
|
|
58
58
|
private static generateRequestId;
|
|
59
59
|
/** 应答配对:信封 requestId 优先,否则取 params.requestId */
|
package/dist/modules/Action.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 三维轻量化 iframe postMessage 通信核心
|
|
3
3
|
* 调用风格对齐 UE 版 model-action 的 Action.sendParam
|
|
4
4
|
*/
|
|
5
5
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
@@ -24,7 +24,7 @@ export class Action {
|
|
|
24
24
|
if (partial.onLog)
|
|
25
25
|
this.onLog = partial.onLog;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
27
|
+
/** 指定三维 iframe;不传则发送时取页面第一个 iframe */
|
|
28
28
|
static setIframe(iframe) {
|
|
29
29
|
this.iframe = iframe;
|
|
30
30
|
}
|
|
@@ -47,7 +47,7 @@ export class Action {
|
|
|
47
47
|
this.poiEventHandlers.add(handler);
|
|
48
48
|
return () => this.poiEventHandlers.delete(handler);
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
50
|
+
/** 订阅三维主动推送,返回取消订阅函数 */
|
|
51
51
|
static onInnerMessage(handler) {
|
|
52
52
|
this.innerMessageHandlers.add(handler);
|
|
53
53
|
return () => this.innerMessageHandlers.delete(handler);
|
|
@@ -120,7 +120,7 @@ export class Action {
|
|
|
120
120
|
clearTimeout(timeoutHandle);
|
|
121
121
|
this.pendingRequests.delete(requestId);
|
|
122
122
|
(_c = this.onLog) === null || _c === void 0 ? void 0 : _c.call(this, {
|
|
123
|
-
content:
|
|
123
|
+
content: `发送给三维失败: ${error}`,
|
|
124
124
|
operTime: Date.now(),
|
|
125
125
|
});
|
|
126
126
|
reject(error);
|
|
@@ -187,7 +187,7 @@ Action.onWindowMessage = (event) => {
|
|
|
187
187
|
if (!info || info.from !== 'inner')
|
|
188
188
|
return;
|
|
189
189
|
(_b = _a.onLog) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
190
|
-
content:
|
|
190
|
+
content: `收到三维消息: ${JSON.stringify(info)}`,
|
|
191
191
|
operTime: Date.now(),
|
|
192
192
|
});
|
|
193
193
|
const requestId = _a.resolveRequestId(info);
|
package/dist/modules/Init.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Action } from './Action';
|
|
5
5
|
export interface InitVideoOptions {
|
|
6
|
-
/**
|
|
6
|
+
/** 视频/三维容器;三维模式下从中查找 iframe */
|
|
7
7
|
container?: HTMLElement | null;
|
|
8
|
-
/**
|
|
8
|
+
/** 直接指定三维 iframe */
|
|
9
9
|
iframe?: HTMLIFrameElement | null;
|
|
10
10
|
/** iframe CSS 选择器(相对 document 或 container) */
|
|
11
11
|
iframeSelector?: string;
|
|
@@ -17,7 +17,7 @@ export interface InitVideoOptions {
|
|
|
17
17
|
onLoadStatus?: (success: boolean) => void;
|
|
18
18
|
/** 日志回调 */
|
|
19
19
|
onLog?: (data: any) => void;
|
|
20
|
-
/** Pixel Streaming
|
|
20
|
+
/** Pixel Streaming 专用字段(三维忽略,保留以便切换包时类型兼容) */
|
|
21
21
|
wsUrl?: string;
|
|
22
22
|
onPlaying?: () => void;
|
|
23
23
|
onQueueChange?: (seq: number) => void;
|
|
@@ -25,9 +25,9 @@ export interface InitVideoOptions {
|
|
|
25
25
|
}
|
|
26
26
|
export declare class InitAction extends Action {
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 初始化三维 iframe 通信。
|
|
29
29
|
* 与 UE 版同名:业务侧只需改 import 包名即可切换。
|
|
30
|
-
* @returns
|
|
30
|
+
* @returns 三维模式固定返回 null(无 peer-stream video)
|
|
31
31
|
*/
|
|
32
32
|
static initVideo(options?: InitVideoOptions): null;
|
|
33
33
|
/** 卸载监听(页面销毁时调用) */
|
package/dist/modules/Init.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import { Action } from './Action';
|
|
5
5
|
export class InitAction extends Action {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* 初始化三维 iframe 通信。
|
|
8
8
|
* 与 UE 版同名:业务侧只需改 import 包名即可切换。
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns 三维模式固定返回 null(无 peer-stream video)
|
|
10
10
|
*/
|
|
11
11
|
static initVideo(options = {}) {
|
|
12
12
|
var _a;
|
package/dist/modules/Path.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 轨迹 / 路径
|
|
3
|
-
*
|
|
3
|
+
* 发送命令:三维文档 faceLine(draw / clear / start)
|
|
4
4
|
*/
|
|
5
5
|
import { Action } from './Action';
|
|
6
|
-
/**
|
|
6
|
+
/** 三维轨迹点:[channelCode, similarity, time, imageUrl] */
|
|
7
7
|
export type FaceLinePoint = [string, string, string, string] | string[];
|
|
8
8
|
/** 路径点至少含 id(会映射为轨迹点 channelCode) */
|
|
9
9
|
export interface PathPoint {
|
|
@@ -15,7 +15,7 @@ export declare class PathAction extends Action {
|
|
|
15
15
|
/**
|
|
16
16
|
* 绘制轨迹 → faceLine action=draw
|
|
17
17
|
*
|
|
18
|
-
* @param points
|
|
18
|
+
* @param points 三维 FaceLinePoint[],或 { id }[] / string[]
|
|
19
19
|
* @param pathPublicUsedType Person/Car(或 person/car)→ 文档 type
|
|
20
20
|
*/
|
|
21
21
|
static pathAdd(points: Array<FaceLinePoint | PathPoint | string>, pathPublicUsedType?: PathPublicUsedType): Promise<any>;
|
|
@@ -31,11 +31,11 @@ export declare class PathAction extends Action {
|
|
|
31
31
|
* pause / stop:文档无对应命令,不发送
|
|
32
32
|
*/
|
|
33
33
|
static pathMove(action: 'start' | 'pause' | 'stop' | 'restart'): Promise<any>;
|
|
34
|
-
/**
|
|
34
|
+
/** 三维 faceLine 文档无此命令,保留方法名便于业务侧兼容 */
|
|
35
35
|
static pathUpdateMovingParam(): Promise<null>;
|
|
36
|
-
/**
|
|
36
|
+
/** 三维 faceLine 文档无此命令 */
|
|
37
37
|
static pathBeginEdit(): Promise<null>;
|
|
38
|
-
/**
|
|
38
|
+
/** 三维 faceLine 文档无此命令 */
|
|
39
39
|
static pathEndEdit(): Promise<null>;
|
|
40
40
|
}
|
|
41
41
|
/** @deprecated 请使用 PathAction;保留别名避免旧引用报错 */
|
package/dist/modules/Path.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 轨迹 / 路径
|
|
3
|
-
*
|
|
3
|
+
* 发送命令:三维文档 faceLine(draw / clear / start)
|
|
4
4
|
*/
|
|
5
5
|
import { Action } from './Action';
|
|
6
6
|
function toFaceLinePoints(points) {
|
|
@@ -18,7 +18,7 @@ export class PathAction extends Action {
|
|
|
18
18
|
/**
|
|
19
19
|
* 绘制轨迹 → faceLine action=draw
|
|
20
20
|
*
|
|
21
|
-
* @param points
|
|
21
|
+
* @param points 三维 FaceLinePoint[],或 { id }[] / string[]
|
|
22
22
|
* @param pathPublicUsedType Person/Car(或 person/car)→ 文档 type
|
|
23
23
|
*/
|
|
24
24
|
static pathAdd(points, pathPublicUsedType) {
|
|
@@ -41,7 +41,7 @@ export class PathAction extends Action {
|
|
|
41
41
|
action: 'clear',
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
console.warn('PathAction.pathShowHideRemove(show)
|
|
44
|
+
console.warn('PathAction.pathShowHideRemove(show):三维文档无对应 faceLine 命令,已忽略');
|
|
45
45
|
return Promise.resolve(null);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -56,22 +56,22 @@ export class PathAction extends Action {
|
|
|
56
56
|
action: 'start',
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
console.warn(`PathAction.pathMove(${action})
|
|
59
|
+
console.warn(`PathAction.pathMove(${action}):三维文档仅支持 faceLine action=start,已忽略`);
|
|
60
60
|
return Promise.resolve(null);
|
|
61
61
|
}
|
|
62
|
-
/**
|
|
62
|
+
/** 三维 faceLine 文档无此命令,保留方法名便于业务侧兼容 */
|
|
63
63
|
static pathUpdateMovingParam() {
|
|
64
|
-
console.warn('PathAction.pathUpdateMovingParam
|
|
64
|
+
console.warn('PathAction.pathUpdateMovingParam:三维文档无对应命令,已忽略');
|
|
65
65
|
return Promise.resolve(null);
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
67
|
+
/** 三维 faceLine 文档无此命令 */
|
|
68
68
|
static pathBeginEdit() {
|
|
69
|
-
console.warn('PathAction.pathBeginEdit
|
|
69
|
+
console.warn('PathAction.pathBeginEdit:三维文档无对应命令,已忽略');
|
|
70
70
|
return Promise.resolve(null);
|
|
71
71
|
}
|
|
72
|
-
/**
|
|
72
|
+
/** 三维 faceLine 文档无此命令 */
|
|
73
73
|
static pathEndEdit() {
|
|
74
|
-
console.warn('PathAction.pathEndEdit
|
|
74
|
+
console.warn('PathAction.pathEndEdit:三维文档无对应命令,已忽略');
|
|
75
75
|
return Promise.resolve(null);
|
|
76
76
|
}
|
|
77
77
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "model-action-younuo",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "三维轻量化 iframe 与外部通信 API(接口风格对齐 model-action)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
package/src/modules/Action.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 三维轻量化 iframe postMessage 通信核心
|
|
3
3
|
* 调用风格对齐 UE 版 model-action 的 Action.sendParam
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ export type RequiredSome<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T,
|
|
|
7
7
|
|
|
8
8
|
export interface SendParam {
|
|
9
9
|
cmd: string;
|
|
10
|
-
/**
|
|
10
|
+
/** 三维函数名;不传则用 cmd */
|
|
11
11
|
fName?: string;
|
|
12
12
|
data?: {
|
|
13
13
|
action?: string;
|
|
@@ -68,7 +68,7 @@ export class Action {
|
|
|
68
68
|
if (partial.onLog) this.onLog = partial.onLog;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/**
|
|
71
|
+
/** 指定三维 iframe;不传则发送时取页面第一个 iframe */
|
|
72
72
|
static setIframe(iframe: HTMLIFrameElement | null) {
|
|
73
73
|
this.iframe = iframe;
|
|
74
74
|
}
|
|
@@ -97,7 +97,7 @@ export class Action {
|
|
|
97
97
|
return () => this.poiEventHandlers.delete(handler);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
/**
|
|
100
|
+
/** 订阅三维主动推送,返回取消订阅函数 */
|
|
101
101
|
static onInnerMessage(handler: (params: any) => void) {
|
|
102
102
|
this.innerMessageHandlers.add(handler);
|
|
103
103
|
return () => this.innerMessageHandlers.delete(handler);
|
|
@@ -180,7 +180,7 @@ export class Action {
|
|
|
180
180
|
clearTimeout(timeoutHandle);
|
|
181
181
|
this.pendingRequests.delete(requestId);
|
|
182
182
|
this.onLog?.({
|
|
183
|
-
content:
|
|
183
|
+
content: `发送给三维失败: ${error}`,
|
|
184
184
|
operTime: Date.now(),
|
|
185
185
|
});
|
|
186
186
|
reject(error);
|
|
@@ -215,7 +215,7 @@ export class Action {
|
|
|
215
215
|
if (!info || info.from !== 'inner') return;
|
|
216
216
|
|
|
217
217
|
this.onLog?.({
|
|
218
|
-
content:
|
|
218
|
+
content: `收到三维消息: ${JSON.stringify(info)}`,
|
|
219
219
|
operTime: Date.now(),
|
|
220
220
|
});
|
|
221
221
|
|
package/src/modules/Init.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import { Action, ModelBridgeConfig } from './Action';
|
|
5
5
|
|
|
6
6
|
export interface InitVideoOptions {
|
|
7
|
-
/**
|
|
7
|
+
/** 视频/三维容器;三维模式下从中查找 iframe */
|
|
8
8
|
container?: HTMLElement | null;
|
|
9
|
-
/**
|
|
9
|
+
/** 直接指定三维 iframe */
|
|
10
10
|
iframe?: HTMLIFrameElement | null;
|
|
11
11
|
/** iframe CSS 选择器(相对 document 或 container) */
|
|
12
12
|
iframeSelector?: string;
|
|
@@ -18,7 +18,7 @@ export interface InitVideoOptions {
|
|
|
18
18
|
onLoadStatus?: (success: boolean) => void;
|
|
19
19
|
/** 日志回调 */
|
|
20
20
|
onLog?: (data: any) => void;
|
|
21
|
-
/** Pixel Streaming
|
|
21
|
+
/** Pixel Streaming 专用字段(三维忽略,保留以便切换包时类型兼容) */
|
|
22
22
|
wsUrl?: string;
|
|
23
23
|
onPlaying?: () => void;
|
|
24
24
|
onQueueChange?: (seq: number) => void;
|
|
@@ -27,9 +27,9 @@ export interface InitVideoOptions {
|
|
|
27
27
|
|
|
28
28
|
export class InitAction extends Action {
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* 初始化三维 iframe 通信。
|
|
31
31
|
* 与 UE 版同名:业务侧只需改 import 包名即可切换。
|
|
32
|
-
* @returns
|
|
32
|
+
* @returns 三维模式固定返回 null(无 peer-stream video)
|
|
33
33
|
*/
|
|
34
34
|
static initVideo(options: InitVideoOptions = {}): null {
|
|
35
35
|
Action.setOnLog(options.onLog);
|
package/src/modules/Path.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 轨迹 / 路径
|
|
3
|
-
*
|
|
3
|
+
* 发送命令:三维文档 faceLine(draw / clear / start)
|
|
4
4
|
*/
|
|
5
5
|
import { Action } from './Action';
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/** 三维轨迹点:[channelCode, similarity, time, imageUrl] */
|
|
8
8
|
export type FaceLinePoint = [string, string, string, string] | string[];
|
|
9
9
|
|
|
10
10
|
/** 路径点至少含 id(会映射为轨迹点 channelCode) */
|
|
@@ -28,7 +28,7 @@ export class PathAction extends Action {
|
|
|
28
28
|
/**
|
|
29
29
|
* 绘制轨迹 → faceLine action=draw
|
|
30
30
|
*
|
|
31
|
-
* @param points
|
|
31
|
+
* @param points 三维 FaceLinePoint[],或 { id }[] / string[]
|
|
32
32
|
* @param pathPublicUsedType Person/Car(或 person/car)→ 文档 type
|
|
33
33
|
*/
|
|
34
34
|
static pathAdd(
|
|
@@ -55,7 +55,7 @@ export class PathAction extends Action {
|
|
|
55
55
|
action: 'clear',
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
console.warn('PathAction.pathShowHideRemove(show)
|
|
58
|
+
console.warn('PathAction.pathShowHideRemove(show):三维文档无对应 faceLine 命令,已忽略');
|
|
59
59
|
return Promise.resolve(null);
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -72,26 +72,26 @@ export class PathAction extends Action {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
console.warn(
|
|
75
|
-
`PathAction.pathMove(${action})
|
|
75
|
+
`PathAction.pathMove(${action}):三维文档仅支持 faceLine action=start,已忽略`
|
|
76
76
|
);
|
|
77
77
|
return Promise.resolve(null);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
/**
|
|
80
|
+
/** 三维 faceLine 文档无此命令,保留方法名便于业务侧兼容 */
|
|
81
81
|
static pathUpdateMovingParam() {
|
|
82
|
-
console.warn('PathAction.pathUpdateMovingParam
|
|
82
|
+
console.warn('PathAction.pathUpdateMovingParam:三维文档无对应命令,已忽略');
|
|
83
83
|
return Promise.resolve(null);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/**
|
|
86
|
+
/** 三维 faceLine 文档无此命令 */
|
|
87
87
|
static pathBeginEdit() {
|
|
88
|
-
console.warn('PathAction.pathBeginEdit
|
|
88
|
+
console.warn('PathAction.pathBeginEdit:三维文档无对应命令,已忽略');
|
|
89
89
|
return Promise.resolve(null);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
/**
|
|
92
|
+
/** 三维 faceLine 文档无此命令 */
|
|
93
93
|
static pathEndEdit() {
|
|
94
|
-
console.warn('PathAction.pathEndEdit
|
|
94
|
+
console.warn('PathAction.pathEndEdit:三维文档无对应命令,已忽略');
|
|
95
95
|
return Promise.resolve(null);
|
|
96
96
|
}
|
|
97
97
|
}
|