@xmaxai/sdk 1.0.0 → 1.0.2
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/CHANGELOG.md +10 -2
- package/README.md +9 -5
- package/dist/{chunk-M5QA6LWS.js → chunk-F567ONBH.js} +32 -190
- package/dist/chunk-F567ONBH.js.map +1 -0
- package/dist/{chunk-PLU2YVAS.js → chunk-TFGYBN3Q.js} +493 -136
- package/dist/chunk-TFGYBN3Q.js.map +1 -0
- package/dist/index.cjs +76 -294
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +376 -10
- package/dist/index.d.ts +376 -10
- package/dist/index.js +1003 -9
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +34 -277
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -3
- package/dist/react/index.d.ts +1 -3
- package/dist/react/index.js +6 -26
- package/dist/react/index.js.map +1 -1
- package/dist/{rtc-manager-gYDkADGw.d.cts → rtc-manager-DnQoznIg.d.cts} +2 -17
- package/dist/{rtc-manager-gYDkADGw.d.ts → rtc-manager-DnQoznIg.d.ts} +2 -17
- package/dist/video-file-stream-4TAGKL2Q.js +3 -0
- package/dist/{video-file-stream-UXJ6TNIB.js.map → video-file-stream-4TAGKL2Q.js.map} +1 -1
- package/package.json +1 -6
- package/dist/chunk-7X7QCO3O.js +0 -992
- package/dist/chunk-7X7QCO3O.js.map +0 -1
- package/dist/chunk-EGNRAZ5U.js +0 -432
- package/dist/chunk-EGNRAZ5U.js.map +0 -1
- package/dist/chunk-M5QA6LWS.js.map +0 -1
- package/dist/chunk-PLU2YVAS.js.map +0 -1
- package/dist/experimental/index.cjs +0 -3873
- package/dist/experimental/index.cjs.map +0 -1
- package/dist/experimental/index.d.cts +0 -2
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/index.js +0 -5
- package/dist/experimental/index.js.map +0 -1
- package/dist/index-BEgtCLkJ.d.cts +0 -346
- package/dist/index-D9wwNTfP.d.ts +0 -346
- package/dist/video-file-stream-UXJ6TNIB.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -13,12 +13,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
13
|
- 构建时区域开关 `XMAX_SDK_REGION`(`cn` | `global`),经 tsup 内联注入默认 `baseUrl`。
|
|
14
14
|
- `XMAX_OPEN_API_BASE_URLS` 常量与 `XmaxSdkRegion` 类型。
|
|
15
15
|
- `build:cn` / `build:global` / `publish:cn` / `publish:global` / `publish:all` 脚本及 `scripts/publish-sdk.mjs`。
|
|
16
|
+
- `connect` 支持可选的 `onError` / `onDisconnect`(与 Decart Overview 对齐;不传则行为与原先一致)。
|
|
16
17
|
|
|
17
18
|
### Changed
|
|
18
19
|
|
|
19
20
|
- `XMAX_OPEN_API_PRODUCTION_BASE_URL` 现按构建区域解析(默认 `cn`),不再硬编码单一地址。
|
|
21
|
+
- **根入口正式对外**:`createXmaxClient` / `models` 等从 `@xmaxai/sdk`(或 `@xmaxai/sdk-global`)直接导入,不再标 `@deprecated`。
|
|
22
|
+
- 移除 `@xmaxai/sdk/experimental` 子路径(发版前无外部依赖);Realtime API 仅通过根入口导出。
|
|
23
|
+
- 错误通过 `onError` 通知调用方处理。
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
### Removed
|
|
26
|
+
|
|
27
|
+
- Package export `./experimental` and `src/experimental` barrel.
|
|
28
|
+
- Deprecated aliases and no-ops: `mirrorInput`, `setMode` / `RealtimeSetModeOptions`, `preserveLocalInput`, `getContentRect`, `RTC_PUBLISH_FPS`, `waitForRtcOutboundBeforeStart`, `waitForPublishedInputFramesBeforeStart`, React `changeModel`.
|
|
29
|
+
|
|
30
|
+
## [1.0.2 ] - 2026-07-01
|
|
22
31
|
|
|
23
32
|
### Added
|
|
24
33
|
|
|
@@ -26,7 +35,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
26
35
|
- `XMAX_OPEN_API_PRODUCTION_BASE_URL` constant for explicit production API endpoint configuration.
|
|
27
36
|
- `@xmaxai/sdk/experimental` subpath for `createXmaxClient`, drag, and related APIs.
|
|
28
37
|
- Unit tests for RTC event builders, video size utilities, and HTTP client request handling.
|
|
29
|
-
- Inline SVG icons for built-in error toasts (no host static assets required).
|
|
30
38
|
|
|
31
39
|
### Changed
|
|
32
40
|
|
package/README.md
CHANGED
|
@@ -28,8 +28,8 @@ npm install @xmaxai/sdk-global
|
|
|
28
28
|
|
|
29
29
|
| 入口 | 说明 |
|
|
30
30
|
|------|------|
|
|
31
|
-
| `@xmaxai/sdk
|
|
32
|
-
| `@xmaxai/sdk` |
|
|
31
|
+
| `@xmaxai/sdk` | **推荐** — `createXmaxClient`、`models`,以及 HTTP Client / RTC 底层 API |
|
|
32
|
+
| `@xmaxai/sdk/react` | React bindings(可选) |
|
|
33
33
|
|
|
34
34
|
## 快速开始
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ npm install @xmaxai/sdk-global
|
|
|
38
38
|
`baseUrl` 已内置生产环境默认值,一般无需传入;仅在 staging / 私有部署时覆盖。
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
import { createXmaxClient, models } from "@xmaxai/sdk
|
|
41
|
+
import { createXmaxClient, models } from "@xmaxai/sdk";
|
|
42
42
|
|
|
43
43
|
const model = models.realtime("x2.0");
|
|
44
44
|
|
|
@@ -84,7 +84,8 @@ await realtimeClient.disconnect();
|
|
|
84
84
|
- `connect()` 自动完成:createSession → heartbeat → join RTC → 推流 →(`autoStart: true` 时)发送 start。
|
|
85
85
|
- `initialState.prompt` 传 `{ text: string }`;`initialState.image` 传参考图 URL。
|
|
86
86
|
- 宿主自行提供 `#video-input` / `#video-output` 容器元素。
|
|
87
|
-
-
|
|
87
|
+
- API/RTC 错误通过 `onError` 回调交给调用方处理。在 `createXmaxClient` 或 `connect` 任一处传入即可(`connect` 优先)。
|
|
88
|
+
- `onDisconnect` 仅在 session 成功建立后断开时触发;`connect()` 失败不会回调。
|
|
88
89
|
|
|
89
90
|
### 自定义 baseUrl(可选)
|
|
90
91
|
|
|
@@ -92,7 +93,7 @@ await realtimeClient.disconnect();
|
|
|
92
93
|
import {
|
|
93
94
|
createXmaxClient,
|
|
94
95
|
XMAX_OPEN_API_PRODUCTION_BASE_URL,
|
|
95
|
-
} from "@xmaxai/sdk
|
|
96
|
+
} from "@xmaxai/sdk";
|
|
96
97
|
|
|
97
98
|
const client = createXmaxClient({
|
|
98
99
|
apiKey: "<YOUR_XMAX_API_KEY>",
|
|
@@ -124,6 +125,9 @@ client.realtime.connect(stream, {
|
|
|
124
125
|
model: RealtimeModel, // models.realtime("x2.0")
|
|
125
126
|
localElement?: HTMLElement,
|
|
126
127
|
remoteElement?: HTMLElement,
|
|
128
|
+
onRemoteStream?: (stream: MediaStream) => void,
|
|
129
|
+
onError?: (message, error?) => void, // optional; overrides createXmaxClient.onError
|
|
130
|
+
onDisconnect?: (reason) => void, // "client" | "session_inactive" | "heartbeat_error"
|
|
127
131
|
mirror?: "auto" | boolean,
|
|
128
132
|
initialState?: {
|
|
129
133
|
prompt?: string | { text: string },
|
|
@@ -1,149 +1,14 @@
|
|
|
1
|
-
import { createSDKI18n, resolveApiErrorMessage, resolvePlaybackDrivenEncoderFps, mountCaptureVideo } from './chunk-
|
|
1
|
+
import { createSDKI18n, resolveApiErrorMessage, resolvePlaybackDrivenEncoderFps, mountCaptureVideo } from './chunk-TFGYBN3Q.js';
|
|
2
2
|
import COS from 'cos-js-sdk-v5';
|
|
3
3
|
import VERTC, { VideoSourceType, MediaType, StreamIndex, RoomProfileType, MirrorType, VideoCodecType, VideoRenderMode } from '@volcengine/rtc';
|
|
4
4
|
|
|
5
|
-
// src/shared/browser-toast.ts
|
|
6
|
-
var TOAST_ROOT_ID = "Xmax-sdk-toast-root";
|
|
7
|
-
var TOAST_DURATION_MS = 3e3;
|
|
8
|
-
var toastSeed = 0;
|
|
9
|
-
var timeoutMap = /* @__PURE__ */ new Map();
|
|
10
|
-
var elementMap = /* @__PURE__ */ new Map();
|
|
11
|
-
function ensureToastRoot() {
|
|
12
|
-
if (typeof document === "undefined") {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
let root = document.getElementById(TOAST_ROOT_ID);
|
|
16
|
-
if (root) {
|
|
17
|
-
return root;
|
|
18
|
-
}
|
|
19
|
-
root = document.createElement("div");
|
|
20
|
-
root.id = TOAST_ROOT_ID;
|
|
21
|
-
root.setAttribute("aria-live", "polite");
|
|
22
|
-
Object.assign(root.style, {
|
|
23
|
-
position: "fixed",
|
|
24
|
-
left: "50%",
|
|
25
|
-
top: "24px",
|
|
26
|
-
transform: "translateX(-50%)",
|
|
27
|
-
zIndex: "3000",
|
|
28
|
-
display: "flex",
|
|
29
|
-
flexDirection: "column",
|
|
30
|
-
alignItems: "center",
|
|
31
|
-
gap: "12px",
|
|
32
|
-
pointerEvents: "none"
|
|
33
|
-
});
|
|
34
|
-
document.body.appendChild(root);
|
|
35
|
-
return root;
|
|
36
|
-
}
|
|
37
|
-
function createIcon(type) {
|
|
38
|
-
const icon = document.createElement("span");
|
|
39
|
-
icon.setAttribute("aria-hidden", "true");
|
|
40
|
-
icon.innerHTML = type === "success" ? '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M10 3L4.5 8.5 2 6" stroke="#4ade80" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>' : '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><circle cx="6" cy="6" r="5" stroke="#f87171" stroke-width="1.5"/><path d="M4 4l4 4M8 4L4 8" stroke="#f87171" stroke-width="1.5" stroke-linecap="round"/></svg>';
|
|
41
|
-
Object.assign(icon.style, {
|
|
42
|
-
display: "inline-flex",
|
|
43
|
-
width: "12px",
|
|
44
|
-
height: "12px",
|
|
45
|
-
flexShrink: "0"
|
|
46
|
-
});
|
|
47
|
-
return icon;
|
|
48
|
-
}
|
|
49
|
-
function clearToastTimer(id) {
|
|
50
|
-
const timer = timeoutMap.get(id);
|
|
51
|
-
if (timer) {
|
|
52
|
-
window.clearTimeout(timer);
|
|
53
|
-
timeoutMap.delete(id);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function destroyToast(id) {
|
|
57
|
-
if (!id) {
|
|
58
|
-
timeoutMap.forEach((timer) => window.clearTimeout(timer));
|
|
59
|
-
timeoutMap.clear();
|
|
60
|
-
elementMap.forEach((element2) => element2.remove());
|
|
61
|
-
elementMap.clear();
|
|
62
|
-
const root2 = typeof document !== "undefined" ? document.getElementById(TOAST_ROOT_ID) : null;
|
|
63
|
-
root2?.remove();
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
clearToastTimer(id);
|
|
67
|
-
const element = elementMap.get(id);
|
|
68
|
-
element?.remove();
|
|
69
|
-
elementMap.delete(id);
|
|
70
|
-
const root = typeof document !== "undefined" ? document.getElementById(TOAST_ROOT_ID) : null;
|
|
71
|
-
if (root && !root.childElementCount) {
|
|
72
|
-
root.remove();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function showToast(type, message, options) {
|
|
76
|
-
const root = ensureToastRoot();
|
|
77
|
-
if (!root) {
|
|
78
|
-
return "";
|
|
79
|
-
}
|
|
80
|
-
const id = options?.key || `toast-${Date.now()}-${++toastSeed}`;
|
|
81
|
-
clearToastTimer(id);
|
|
82
|
-
elementMap.get(id)?.remove();
|
|
83
|
-
const isMobile = typeof window !== "undefined" && window.matchMedia("(max-width: 768px)").matches;
|
|
84
|
-
const textSize = isMobile ? "12px" : "14px";
|
|
85
|
-
const toast = document.createElement("div");
|
|
86
|
-
toast.setAttribute("role", "status");
|
|
87
|
-
Object.assign(toast.style, {
|
|
88
|
-
pointerEvents: "auto",
|
|
89
|
-
display: "flex",
|
|
90
|
-
alignItems: "center",
|
|
91
|
-
gap: "12px",
|
|
92
|
-
minWidth: "240px",
|
|
93
|
-
padding: "16px",
|
|
94
|
-
borderRadius: "12px",
|
|
95
|
-
border: "1px solid rgba(255, 255, 255, 0.20)",
|
|
96
|
-
background: "rgba(0, 0, 0, 0.80)",
|
|
97
|
-
boxShadow: "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",
|
|
98
|
-
fontFamily: "Rubik, ui-sans-serif, system-ui, sans-serif",
|
|
99
|
-
fontSize: textSize,
|
|
100
|
-
fontWeight: "400",
|
|
101
|
-
lineHeight: "14px"
|
|
102
|
-
});
|
|
103
|
-
const content = document.createElement("span");
|
|
104
|
-
content.textContent = message;
|
|
105
|
-
Object.assign(content.style, {
|
|
106
|
-
paddingRight: "0px",
|
|
107
|
-
textAlign: "center",
|
|
108
|
-
color: "#ffffff",
|
|
109
|
-
fontFamily: "Rubik, ui-sans-serif, system-ui, sans-serif",
|
|
110
|
-
fontSize: textSize,
|
|
111
|
-
fontWeight: "400",
|
|
112
|
-
lineHeight: "14px"
|
|
113
|
-
});
|
|
114
|
-
toast.appendChild(createIcon(type));
|
|
115
|
-
toast.appendChild(content);
|
|
116
|
-
root.appendChild(toast);
|
|
117
|
-
elementMap.set(id, toast);
|
|
118
|
-
const timer = window.setTimeout(() => {
|
|
119
|
-
destroyToast(id);
|
|
120
|
-
}, options?.duration ?? TOAST_DURATION_MS);
|
|
121
|
-
timeoutMap.set(id, timer);
|
|
122
|
-
return id;
|
|
123
|
-
}
|
|
124
|
-
var browserToast = {
|
|
125
|
-
success(message, options) {
|
|
126
|
-
return showToast("success", message, options);
|
|
127
|
-
},
|
|
128
|
-
error(message, options) {
|
|
129
|
-
return showToast("error", message, options);
|
|
130
|
-
},
|
|
131
|
-
destroy(id) {
|
|
132
|
-
destroyToast(id);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
5
|
// src/shared/error-utils.ts
|
|
137
6
|
function notifyError(error, notifier, fallbackMessage) {
|
|
138
7
|
const resolved = error instanceof Error ? error : Object.assign(new Error(fallbackMessage), { cause: error });
|
|
139
|
-
if (!resolved.__XmaxNotified) {
|
|
8
|
+
if (!resolved.__XmaxNotified && notifier) {
|
|
140
9
|
resolved.__XmaxNotified = true;
|
|
141
10
|
const message = resolved.message || fallbackMessage;
|
|
142
|
-
|
|
143
|
-
notifier(message, error);
|
|
144
|
-
} else if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
145
|
-
browserToast.error(message);
|
|
146
|
-
}
|
|
11
|
+
notifier(message, error);
|
|
147
12
|
}
|
|
148
13
|
return resolved;
|
|
149
14
|
}
|
|
@@ -215,7 +80,7 @@ var XmaxOpenClient = class {
|
|
|
215
80
|
}
|
|
216
81
|
throw notifyError(error, this.onError, message);
|
|
217
82
|
}
|
|
218
|
-
/** Stop heartbeat, abort in-flight API requests, and suppress error
|
|
83
|
+
/** Stop heartbeat, abort in-flight API requests, and suppress error notifications during teardown. */
|
|
219
84
|
beginTeardown() {
|
|
220
85
|
this.suppressErrorNotification = true;
|
|
221
86
|
this.stopHeartbeat();
|
|
@@ -271,7 +136,8 @@ var XmaxOpenClient = class {
|
|
|
271
136
|
return p.data;
|
|
272
137
|
}
|
|
273
138
|
const mappedMessage = resolveApiErrorMessage(p.code, this.i18n.locale);
|
|
274
|
-
const
|
|
139
|
+
const backendMessage = typeof p.message === "string" && p.message.trim() ? p.message.trim() : void 0;
|
|
140
|
+
const errorMessage = mappedMessage ?? backendMessage ?? this.i18n.t("errors.requestRetry");
|
|
275
141
|
throw new Error(errorMessage);
|
|
276
142
|
} catch (error) {
|
|
277
143
|
if (this.isAbortError(error)) {
|
|
@@ -423,6 +289,7 @@ function createStartRtcRoomEvent(input) {
|
|
|
423
289
|
const resolvedPrompt = input.prompt?.trim() ?? "";
|
|
424
290
|
const refImagePath = input.refImagePath?.trim() || input.refImage?.trim() || void 0;
|
|
425
291
|
const useRefImage = !!refImagePath;
|
|
292
|
+
const staticImagePath = input.staticImagePath?.trim() || void 0;
|
|
426
293
|
return {
|
|
427
294
|
event: "start",
|
|
428
295
|
user_id: input.userId?.trim() || void 0,
|
|
@@ -434,7 +301,9 @@ function createStartRtcRoomEvent(input) {
|
|
|
434
301
|
prompt: resolvedPrompt,
|
|
435
302
|
ref_image_path: useRefImage ? refImagePath : void 0,
|
|
436
303
|
ref_image: useRefImage ? refImagePath : void 0,
|
|
437
|
-
|
|
304
|
+
// Instant-only — omit when false/undefined so non-instant starts never carry leftover flags.
|
|
305
|
+
static_generate: input.staticGenerate === true ? true : void 0,
|
|
306
|
+
static_image_path: staticImagePath,
|
|
438
307
|
...input.extraParams ?? {}
|
|
439
308
|
}
|
|
440
309
|
};
|
|
@@ -714,7 +583,7 @@ var _RtcManager = class _RtcManager {
|
|
|
714
583
|
this.lastRemoteSei = null;
|
|
715
584
|
this.lastRemoteSeiUserId = null;
|
|
716
585
|
this.hasLoggedSeiSendFailure = false;
|
|
717
|
-
if (previousExpectedRemoteSei !== this.expectedRemoteSei && this.remoteVideoUserId) {
|
|
586
|
+
if (previousExpectedRemoteSei !== this.expectedRemoteSei && this.remoteVideoUserId && !this.preserveRemoteDom) {
|
|
718
587
|
this.pendingRemoteVideoUserId = this.remoteVideoUserId;
|
|
719
588
|
this.remoteVideoUserId = null;
|
|
720
589
|
}
|
|
@@ -1062,45 +931,6 @@ var _RtcManager = class _RtcManager {
|
|
|
1062
931
|
sentFrameRate: this.lastObservedSentFrameRate
|
|
1063
932
|
});
|
|
1064
933
|
}
|
|
1065
|
-
/** @deprecated Use {@link ensurePublishedInputBeforeStart}. */
|
|
1066
|
-
async waitForRtcOutboundBeforeStart(options) {
|
|
1067
|
-
const timeoutMs = options?.timeoutMs ?? PUBLISH_READY_TIMEOUT_MS;
|
|
1068
|
-
const publishAgeMs = this.publishStartedAtMs > 0 ? performance.now() - this.publishStartedAtMs : 0;
|
|
1069
|
-
const localFramesPromise = publishAgeMs >= PUBLISH_WARM_SKIP_MS ? Promise.resolve({ ready: true, frameCount: 0, elapsedMs: 0 }) : this.waitForPublishedInputFrames({
|
|
1070
|
-
minFrames: PUBLISH_START_MIN_FRAMES,
|
|
1071
|
-
timeoutMs: PUBLISH_START_FRAME_TIMEOUT_MS
|
|
1072
|
-
});
|
|
1073
|
-
const [, rtcReady] = await Promise.all([
|
|
1074
|
-
localFramesPromise,
|
|
1075
|
-
this.waitForLocalPublishReady({ timeoutMs })
|
|
1076
|
-
]);
|
|
1077
|
-
return rtcReady;
|
|
1078
|
-
}
|
|
1079
|
-
/** @deprecated Use {@link waitForRtcOutboundBeforeStart}. */
|
|
1080
|
-
async waitForPublishedInputFramesBeforeStart() {
|
|
1081
|
-
const waitOptions = this.resolveInputFrameWaitOptions();
|
|
1082
|
-
const waitTasks = [
|
|
1083
|
-
this.waitForLocalPublishReady({ timeoutMs: PUBLISH_READY_TIMEOUT_MS })
|
|
1084
|
-
];
|
|
1085
|
-
if (waitOptions) {
|
|
1086
|
-
waitTasks.push(
|
|
1087
|
-
this.waitForMinPublishDuration(waitOptions.minPublishMs),
|
|
1088
|
-
this.waitForPublishedInputFrames({
|
|
1089
|
-
minFrames: waitOptions.minFrames,
|
|
1090
|
-
timeoutMs: waitOptions.timeoutMs
|
|
1091
|
-
})
|
|
1092
|
-
);
|
|
1093
|
-
}
|
|
1094
|
-
const [rtcResult, ...rest] = await Promise.all(waitTasks);
|
|
1095
|
-
const rtcSend = rtcResult;
|
|
1096
|
-
const frameResult = waitOptions ? rest[1] : { ready: true, frameCount: 0, elapsedMs: 0 };
|
|
1097
|
-
return {
|
|
1098
|
-
...frameResult,
|
|
1099
|
-
rtcSendReady: rtcSend.ready,
|
|
1100
|
-
rtcSendReason: rtcSend.reason,
|
|
1101
|
-
rtcSendElapsedMs: rtcSend.elapsedSincePublishMs
|
|
1102
|
-
};
|
|
1103
|
-
}
|
|
1104
934
|
async waitForMinPublishDuration(minMs) {
|
|
1105
935
|
if (minMs <= 0 || this.publishStartedAtMs <= 0) {
|
|
1106
936
|
return;
|
|
@@ -2202,9 +2032,6 @@ function getFitContentRect(rect, targetSize, fitMode = "contain") {
|
|
|
2202
2032
|
height
|
|
2203
2033
|
};
|
|
2204
2034
|
}
|
|
2205
|
-
function getContentRect(rect, targetSize) {
|
|
2206
|
-
return getFitContentRect(rect, targetSize, "contain");
|
|
2207
|
-
}
|
|
2208
2035
|
function findDragMediaElement(dragSurface) {
|
|
2209
2036
|
const root = dragSurface.parentElement ?? dragSurface;
|
|
2210
2037
|
if (typeof root.querySelector !== "function") {
|
|
@@ -2370,6 +2197,7 @@ function drawNeon(ctx, segs, container, targetSize, dpr, fitMode, mirrored) {
|
|
|
2370
2197
|
}
|
|
2371
2198
|
var DragTrackController = class {
|
|
2372
2199
|
constructor(container, options) {
|
|
2200
|
+
this.strokeActive = false;
|
|
2373
2201
|
this.activePointers = /* @__PURE__ */ new Map();
|
|
2374
2202
|
this.lastTargetPoints = /* @__PURE__ */ new Map();
|
|
2375
2203
|
this.segQueue = [];
|
|
@@ -2379,6 +2207,8 @@ var DragTrackController = class {
|
|
|
2379
2207
|
this.resizeObserver = null;
|
|
2380
2208
|
this.container = container;
|
|
2381
2209
|
this.onTracks = options.onTracks;
|
|
2210
|
+
this.onStrokeStart = options.onStrokeStart;
|
|
2211
|
+
this.onStrokeEnd = options.onStrokeEnd;
|
|
2382
2212
|
this.targetSize = options.targetSize;
|
|
2383
2213
|
this.fitMode = options.fitMode ?? "cover";
|
|
2384
2214
|
this.mirrored = options.mirrored ?? false;
|
|
@@ -2549,11 +2379,17 @@ var DragTrackController = class {
|
|
|
2549
2379
|
this.flushTracks();
|
|
2550
2380
|
}, 30);
|
|
2551
2381
|
}
|
|
2552
|
-
finishStroke() {
|
|
2382
|
+
finishStroke(emitEnd = false) {
|
|
2383
|
+
const wasActive = this.strokeActive;
|
|
2384
|
+
this.strokeActive = false;
|
|
2553
2385
|
this.stopSampling();
|
|
2554
2386
|
this.stopDrawLoop();
|
|
2555
2387
|
this.segQueue.length = 0;
|
|
2556
2388
|
this.clearCanvas();
|
|
2389
|
+
if (emitEnd && wasActive && this.onStrokeEnd) {
|
|
2390
|
+
Promise.resolve(this.onStrokeEnd()).catch(() => {
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2557
2393
|
}
|
|
2558
2394
|
handlePointerDown(e) {
|
|
2559
2395
|
if (!this.enabled) {
|
|
@@ -2577,6 +2413,12 @@ var DragTrackController = class {
|
|
|
2577
2413
|
if (targetPoint) {
|
|
2578
2414
|
this.lastTargetPoints.set(e.pointerId, targetPoint);
|
|
2579
2415
|
}
|
|
2416
|
+
const strokeWasActive = this.strokeActive;
|
|
2417
|
+
this.strokeActive = true;
|
|
2418
|
+
if (!strokeWasActive && this.onStrokeStart) {
|
|
2419
|
+
Promise.resolve(this.onStrokeStart()).catch(() => {
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2580
2422
|
this.startDrawLoop();
|
|
2581
2423
|
this.startSampling();
|
|
2582
2424
|
}
|
|
@@ -2609,7 +2451,7 @@ var DragTrackController = class {
|
|
|
2609
2451
|
} catch {
|
|
2610
2452
|
}
|
|
2611
2453
|
if (this.activePointers.size === 0) {
|
|
2612
|
-
this.finishStroke();
|
|
2454
|
+
this.finishStroke(true);
|
|
2613
2455
|
}
|
|
2614
2456
|
}
|
|
2615
2457
|
handlePointerCancel(e) {
|
|
@@ -2619,7 +2461,7 @@ var DragTrackController = class {
|
|
|
2619
2461
|
this.activePointers.delete(e.pointerId);
|
|
2620
2462
|
this.lastTargetPoints.delete(e.pointerId);
|
|
2621
2463
|
if (this.activePointers.size === 0) {
|
|
2622
|
-
this.finishStroke();
|
|
2464
|
+
this.finishStroke(true);
|
|
2623
2465
|
}
|
|
2624
2466
|
}
|
|
2625
2467
|
};
|
|
@@ -2644,6 +2486,6 @@ var models = {
|
|
|
2644
2486
|
}
|
|
2645
2487
|
};
|
|
2646
2488
|
|
|
2647
|
-
export { ACTIVE_STATUS, PREVIEW_CONTAIN_ATTR, PREVIEW_COVER_ATTR, PREVIEW_OUTPUT_LAYOUT_ATTR, PREVIEW_UPLOAD_FIT_ATTR, PREVIEW_UPLOAD_LAYOUT_ATTR, PUBLISH_COLD_FRAME_TIMEOUT_MS, PUBLISH_COLD_MIN_FRAMES, PUBLISH_COLD_WARMUP_MS, PUBLISH_START_FRAME_TIMEOUT_MS, PUBLISH_START_MIN_FRAMES, PUBLISH_WARM_SKIP_MS, RtcManager, XMAX_OPEN_API_BASE_URLS, XMAX_OPEN_API_PRODUCTION_BASE_URL, XmaxOpenClient, applyUploadPreviewMediaLayout,
|
|
2648
|
-
//# sourceMappingURL=chunk-
|
|
2649
|
-
//# sourceMappingURL=chunk-
|
|
2489
|
+
export { ACTIVE_STATUS, PREVIEW_CONTAIN_ATTR, PREVIEW_COVER_ATTR, PREVIEW_OUTPUT_LAYOUT_ATTR, PREVIEW_UPLOAD_FIT_ATTR, PREVIEW_UPLOAD_LAYOUT_ATTR, PUBLISH_COLD_FRAME_TIMEOUT_MS, PUBLISH_COLD_MIN_FRAMES, PUBLISH_COLD_WARMUP_MS, PUBLISH_START_FRAME_TIMEOUT_MS, PUBLISH_START_MIN_FRAMES, PUBLISH_WARM_SKIP_MS, RtcManager, XMAX_OPEN_API_BASE_URLS, XMAX_OPEN_API_PRODUCTION_BASE_URL, XmaxOpenClient, applyUploadPreviewMediaLayout, classifyCameraAccessError, createDragTrackController, createNativeCameraStream, createStartRtcRoomEvent, createStopRtcRoomEvent, createTaskUid, createTracksRtcRoomEvent, getCameraEnvironmentIssue, getFitContentRect, isCameraAccessError, mapTargetPointToCanvas, mapViewportPointToCoordinateSpace, models, notifyError, observeUploadPreviewMediaLayout, openNativeCameraStream, requestCameraMediaStream, stabilizeCameraVideoTrack };
|
|
2490
|
+
//# sourceMappingURL=chunk-F567ONBH.js.map
|
|
2491
|
+
//# sourceMappingURL=chunk-F567ONBH.js.map
|