@xmaxai/sdk 0.1.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/dist/index.d.cts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { S as SDKLocale, a as SDKI18n, b as XmaxOpenClient } from './rtc-manager-gYDkADGw.cjs';
2
2
  export { A as ACTIVE_STATUS, C as ClientOptions, c as CosSts, L as LocalPublishReadyResult, M as MEDIA_TIME_EPSILON_S, d as MEDIA_TIME_LOOP_JUMP_S, e as MOBILE_PUBLISH_MAX_WIDTH_PX, f as ModelExtra, P as PUBLISH_COLD_FRAME_TIMEOUT_MS, g as PUBLISH_COLD_MIN_FRAMES, h as PUBLISH_COLD_WARMUP_MS, i as PUBLISH_START_FRAME_TIMEOUT_MS, j as PUBLISH_START_MIN_FRAMES, k as PUBLISH_WARM_SKIP_MS, l as RTC_PUBLISH_FPS, m as RTC_PUBLISH_FPS_MOBILE, n as RTC_PUBLISH_FPS_WEB, o as RTC_PUBLISH_FRAME_INTERVAL_MS, p as RTC_PUBLISH_FRAME_INTERVAL_S, q as RemoteSeiReceivedPayload, r as ResolveRtcPublishFpsOptions, s as RtcJoinInfo, t as RtcLogEntry, u as RtcManager, R as RtcStateSnapshot, v as SDKMessages, w as Session, x as StsCredentials, U as UploadImageResult, y as UploadVideoResult, z as XMAX_OPEN_API_BASE_URLS, B as XMAX_OPEN_API_PRODUCTION_BASE_URL, D as XmaxLogEntry, E as XmaxSdkRegion, F as createSDKI18n, G as getDefaultMessages, H as isMobilePublishEnvironment, I as resolveRtcPublishFps, J as resolveRtcPublishFrameIntervalS } from './rtc-manager-gYDkADGw.cjs';
3
- export { D as DragTrackController, a as DragTrackControllerOptions, N as NativeCameraStream, O as OpenNativeCameraStreamOptions, R as RealtimeConnectOptions, b as RealtimeInitialState, c as RealtimeModel, d as RealtimePrewarmHandle, e as RealtimePromptState, f as RealtimeRestartOptions, g as RealtimeSession, h as RealtimeSetImageOptions, i as RealtimeSetInput, j as RealtimeSetModeOptions, k as RemoteViewHost, X as XmaxClient, l as XmaxClientFiles, m as XmaxClientOptions, n as XmaxRealtimeSession, o as createDragTrackController, p as createNativeCameraStream, q as createRemoteViewHost, r as createXmaxClient, s as getContentRect, t as mapTargetPointToCanvas, u as mapViewportPointToCoordinateSpace, v as models, w as observeDragSurfaceVideoSync, x as openNativeCameraStream, y as syncDragSurfaceToVideo } from './index-Dai62Sos.cjs';
3
+ export { D as DragTrackController, a as DragTrackControllerOptions, N as NativeCameraStream, O as OpenNativeCameraStreamOptions, R as RealtimeConnectOptions, b as RealtimeInitialState, c as RealtimeModel, d as RealtimePrewarmHandle, e as RealtimePromptState, f as RealtimeRestartOptions, g as RealtimeSession, h as RealtimeSetImageOptions, i as RealtimeSetInput, j as RealtimeSetModeOptions, k as RemoteViewHost, X as XmaxClient, l as XmaxClientFiles, m as XmaxClientOptions, n as XmaxRealtimeSession, o as createDragTrackController, p as createNativeCameraStream, q as createRemoteViewHost, r as createXmaxClient, s as getContentRect, t as mapTargetPointToCanvas, u as mapViewportPointToCoordinateSpace, v as models, w as observeDragSurfaceVideoSync, x as openNativeCameraStream, y as syncDragSurfaceToVideo } from './index-Dg1ElHAj.cjs';
4
4
 
5
5
  /**
6
6
  * Open API business error codes (46xxx) mapped to user-facing messages.
7
- * Source: Open API v1 error code tables. Codes not listed here fall back to a
8
- * generic retry message (see `errors.requestRetry`).
7
+ * Source: Open API v1 error code tables. Codes not listed here fall back to the
8
+ * backend `message` when present, otherwise a generic retry message for Open
9
+ * API endpoints (see `errors.requestRetry`).
9
10
  */
10
11
  type LocalizedMessage = Record<SDKLocale, string>;
11
12
  declare const API_ERROR_MESSAGES: Record<string, LocalizedMessage>;
@@ -24,6 +25,8 @@ type StartRtcRoomEvent = {
24
25
  ref_image_path?: string;
25
26
  ref_image?: string;
26
27
  static_generate?: boolean;
28
+ /** MoX instant — COS URL of the source still; preferred over under-bitrate RTC frames. */
29
+ static_image_path?: string;
27
30
  } & Record<string, unknown>;
28
31
  };
29
32
  type StopRtcRoomEvent = {
@@ -52,6 +55,8 @@ declare function createStartRtcRoomEvent(input: {
52
55
  refImage?: string;
53
56
  /** MoX instant — static image generation that follows drag tracks. */
54
57
  staticGenerate?: boolean;
58
+ /** MoX instant — COS URL of the source still (`static_image_path`). */
59
+ staticImagePath?: string;
55
60
  extraParams?: Record<string, unknown>;
56
61
  }): StartRtcRoomEvent;
57
62
  declare function createStopRtcRoomEvent(input: {
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { S as SDKLocale, a as SDKI18n, b as XmaxOpenClient } from './rtc-manager-gYDkADGw.js';
2
2
  export { A as ACTIVE_STATUS, C as ClientOptions, c as CosSts, L as LocalPublishReadyResult, M as MEDIA_TIME_EPSILON_S, d as MEDIA_TIME_LOOP_JUMP_S, e as MOBILE_PUBLISH_MAX_WIDTH_PX, f as ModelExtra, P as PUBLISH_COLD_FRAME_TIMEOUT_MS, g as PUBLISH_COLD_MIN_FRAMES, h as PUBLISH_COLD_WARMUP_MS, i as PUBLISH_START_FRAME_TIMEOUT_MS, j as PUBLISH_START_MIN_FRAMES, k as PUBLISH_WARM_SKIP_MS, l as RTC_PUBLISH_FPS, m as RTC_PUBLISH_FPS_MOBILE, n as RTC_PUBLISH_FPS_WEB, o as RTC_PUBLISH_FRAME_INTERVAL_MS, p as RTC_PUBLISH_FRAME_INTERVAL_S, q as RemoteSeiReceivedPayload, r as ResolveRtcPublishFpsOptions, s as RtcJoinInfo, t as RtcLogEntry, u as RtcManager, R as RtcStateSnapshot, v as SDKMessages, w as Session, x as StsCredentials, U as UploadImageResult, y as UploadVideoResult, z as XMAX_OPEN_API_BASE_URLS, B as XMAX_OPEN_API_PRODUCTION_BASE_URL, D as XmaxLogEntry, E as XmaxSdkRegion, F as createSDKI18n, G as getDefaultMessages, H as isMobilePublishEnvironment, I as resolveRtcPublishFps, J as resolveRtcPublishFrameIntervalS } from './rtc-manager-gYDkADGw.js';
3
- export { D as DragTrackController, a as DragTrackControllerOptions, N as NativeCameraStream, O as OpenNativeCameraStreamOptions, R as RealtimeConnectOptions, b as RealtimeInitialState, c as RealtimeModel, d as RealtimePrewarmHandle, e as RealtimePromptState, f as RealtimeRestartOptions, g as RealtimeSession, h as RealtimeSetImageOptions, i as RealtimeSetInput, j as RealtimeSetModeOptions, k as RemoteViewHost, X as XmaxClient, l as XmaxClientFiles, m as XmaxClientOptions, n as XmaxRealtimeSession, o as createDragTrackController, p as createNativeCameraStream, q as createRemoteViewHost, r as createXmaxClient, s as getContentRect, t as mapTargetPointToCanvas, u as mapViewportPointToCoordinateSpace, v as models, w as observeDragSurfaceVideoSync, x as openNativeCameraStream, y as syncDragSurfaceToVideo } from './index-BIUk_kvb.js';
3
+ export { D as DragTrackController, a as DragTrackControllerOptions, N as NativeCameraStream, O as OpenNativeCameraStreamOptions, R as RealtimeConnectOptions, b as RealtimeInitialState, c as RealtimeModel, d as RealtimePrewarmHandle, e as RealtimePromptState, f as RealtimeRestartOptions, g as RealtimeSession, h as RealtimeSetImageOptions, i as RealtimeSetInput, j as RealtimeSetModeOptions, k as RemoteViewHost, X as XmaxClient, l as XmaxClientFiles, m as XmaxClientOptions, n as XmaxRealtimeSession, o as createDragTrackController, p as createNativeCameraStream, q as createRemoteViewHost, r as createXmaxClient, s as getContentRect, t as mapTargetPointToCanvas, u as mapViewportPointToCoordinateSpace, v as models, w as observeDragSurfaceVideoSync, x as openNativeCameraStream, y as syncDragSurfaceToVideo } from './index-Cw8C8LbO.js';
4
4
 
5
5
  /**
6
6
  * Open API business error codes (46xxx) mapped to user-facing messages.
7
- * Source: Open API v1 error code tables. Codes not listed here fall back to a
8
- * generic retry message (see `errors.requestRetry`).
7
+ * Source: Open API v1 error code tables. Codes not listed here fall back to the
8
+ * backend `message` when present, otherwise a generic retry message for Open
9
+ * API endpoints (see `errors.requestRetry`).
9
10
  */
10
11
  type LocalizedMessage = Record<SDKLocale, string>;
11
12
  declare const API_ERROR_MESSAGES: Record<string, LocalizedMessage>;
@@ -24,6 +25,8 @@ type StartRtcRoomEvent = {
24
25
  ref_image_path?: string;
25
26
  ref_image?: string;
26
27
  static_generate?: boolean;
28
+ /** MoX instant — COS URL of the source still; preferred over under-bitrate RTC frames. */
29
+ static_image_path?: string;
27
30
  } & Record<string, unknown>;
28
31
  };
29
32
  type StopRtcRoomEvent = {
@@ -52,6 +55,8 @@ declare function createStartRtcRoomEvent(input: {
52
55
  refImage?: string;
53
56
  /** MoX instant — static image generation that follows drag tracks. */
54
57
  staticGenerate?: boolean;
58
+ /** MoX instant — COS URL of the source still (`static_image_path`). */
59
+ staticImagePath?: string;
55
60
  extraParams?: Record<string, unknown>;
56
61
  }): StartRtcRoomEvent;
57
62
  declare function createStopRtcRoomEvent(input: {
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- export { RealtimePrewarmHandle, RealtimeSession, createRemoteViewHost, createXmaxClient, observeDragSurfaceVideoSync, resolveRefImageUrl, syncDragSurfaceToVideo } from './chunk-74ZZWUPI.js';
2
- import { requestCameraMediaStream } from './chunk-67XSD3QJ.js';
3
- 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, getContentRect, isCameraAccessError, mapTargetPointToCanvas, mapViewportPointToCoordinateSpace, models, observeUploadPreviewMediaLayout, openNativeCameraStream, requestCameraMediaStream, stabilizeCameraVideoTrack } from './chunk-67XSD3QJ.js';
4
- import { computeCenterCropRect, drawSourceCenterCrop } from './chunk-EGNRAZ5U.js';
5
- export { createVideoFileStream } from './chunk-EGNRAZ5U.js';
6
- import { createSDKI18n, resolveUploadVideoSize, resolveRtcPublishFps, mountCaptureVideo } from './chunk-PLU2YVAS.js';
7
- export { API_ERROR_MESSAGES, DEFAULT_SESSION_TARGET_SIZE, MEDIA_TIME_EPSILON_S, MEDIA_TIME_LOOP_JUMP_S, MOBILE_PUBLISH_MAX_WIDTH_PX, PREVIEW_CONTAINER_ASPECT_RATIO, RTC_PUBLISH_FPS, RTC_PUBLISH_FPS_MOBILE, RTC_PUBLISH_FPS_WEB, RTC_PUBLISH_FRAME_INTERVAL_MS, RTC_PUBLISH_FRAME_INTERVAL_S, createSDKI18n, getDefaultMessages, isMobilePublishEnvironment, resolveAdaptiveRtcVideoSize, resolveApiErrorMessage, resolvePreviewAspectRatio, resolveRtcPublishFps, resolveRtcPublishFrameIntervalS, resolveSessionTargetSize, resolveUploadPublishSize, resolveUploadVideoSize } from './chunk-PLU2YVAS.js';
1
+ export { RealtimePrewarmHandle, RealtimeSession, createRemoteViewHost, createXmaxClient, observeDragSurfaceVideoSync, resolveRefImageUrl, syncDragSurfaceToVideo } from './chunk-VLJZ56PT.js';
2
+ import { requestCameraMediaStream } from './chunk-V4NR6CPP.js';
3
+ 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, getContentRect, isCameraAccessError, mapTargetPointToCanvas, mapViewportPointToCoordinateSpace, models, observeUploadPreviewMediaLayout, openNativeCameraStream, requestCameraMediaStream, stabilizeCameraVideoTrack } from './chunk-V4NR6CPP.js';
4
+ import { computeCenterCropRect, drawSourceCenterCrop } from './chunk-4YHBCQ2C.js';
5
+ export { createVideoFileStream } from './chunk-4YHBCQ2C.js';
6
+ import { createSDKI18n, resolveUploadVideoSize, resolveRtcPublishFps, mountCaptureVideo } from './chunk-LCPC56BK.js';
7
+ export { API_ERROR_MESSAGES, DEFAULT_SESSION_TARGET_SIZE, MEDIA_TIME_EPSILON_S, MEDIA_TIME_LOOP_JUMP_S, MOBILE_PUBLISH_MAX_WIDTH_PX, PREVIEW_CONTAINER_ASPECT_RATIO, RTC_PUBLISH_FPS, RTC_PUBLISH_FPS_MOBILE, RTC_PUBLISH_FPS_WEB, RTC_PUBLISH_FRAME_INTERVAL_MS, RTC_PUBLISH_FRAME_INTERVAL_S, createSDKI18n, getDefaultMessages, isMobilePublishEnvironment, resolveAdaptiveRtcVideoSize, resolveApiErrorMessage, resolvePreviewAspectRatio, resolveRtcPublishFps, resolveRtcPublishFrameIntervalS, resolveSessionTargetSize, resolveUploadPublishSize, resolveUploadVideoSize } from './chunk-LCPC56BK.js';
8
8
 
9
9
  // src/rtc/image-file-stream.ts
10
10
  function loadImageElement(url, crossOrigin) {
@@ -143,7 +143,7 @@ async function createMediaFileStream(fileOrUrl, options = {}) {
143
143
  return createImageFileStream(fileOrUrl, options);
144
144
  }
145
145
  if (isVideoMediaFile(fileOrUrl)) {
146
- const { createVideoFileStream: createVideoFileStream2 } = await import('./video-file-stream-UXJ6TNIB.js');
146
+ const { createVideoFileStream: createVideoFileStream2 } = await import('./video-file-stream-K7GQMIJ5.js');
147
147
  return createVideoFileStream2(fileOrUrl, options);
148
148
  }
149
149
  const i18n = options.i18n ?? createSDKI18n();
@@ -539,7 +539,8 @@ var XmaxOpenClient = class {
539
539
  return p.data;
540
540
  }
541
541
  const mappedMessage = resolveApiErrorMessage(p.code, this.i18n.locale);
542
- const errorMessage = mappedMessage ?? this.i18n.t("errors.requestRetry");
542
+ const backendMessage = typeof p.message === "string" && p.message.trim() ? p.message.trim() : void 0;
543
+ const errorMessage = mappedMessage ?? backendMessage ?? this.i18n.t("errors.requestRetry");
543
544
  throw new Error(errorMessage);
544
545
  } catch (error) {
545
546
  if (this.isAbortError(error)) {
@@ -691,6 +692,7 @@ function createStartRtcRoomEvent(input) {
691
692
  const resolvedPrompt = input.prompt?.trim() ?? "";
692
693
  const refImagePath = input.refImagePath?.trim() || input.refImage?.trim() || void 0;
693
694
  const useRefImage = !!refImagePath;
695
+ const staticImagePath = input.staticImagePath?.trim() || void 0;
694
696
  return {
695
697
  event: "start",
696
698
  user_id: input.userId?.trim() || void 0,
@@ -702,7 +704,9 @@ function createStartRtcRoomEvent(input) {
702
704
  prompt: resolvedPrompt,
703
705
  ref_image_path: useRefImage ? refImagePath : void 0,
704
706
  ref_image: useRefImage ? refImagePath : void 0,
705
- static_generate: input.staticGenerate === void 0 ? void 0 : input.staticGenerate,
707
+ // Instant-only omit when false/undefined so non-instant starts never carry leftover flags.
708
+ static_generate: input.staticGenerate === true ? true : void 0,
709
+ static_image_path: staticImagePath,
706
710
  ...input.extraParams ?? {}
707
711
  }
708
712
  };
@@ -1103,7 +1107,7 @@ var _RtcManager = class _RtcManager {
1103
1107
  this.lastRemoteSei = null;
1104
1108
  this.lastRemoteSeiUserId = null;
1105
1109
  this.hasLoggedSeiSendFailure = false;
1106
- if (previousExpectedRemoteSei !== this.expectedRemoteSei && this.remoteVideoUserId) {
1110
+ if (previousExpectedRemoteSei !== this.expectedRemoteSei && this.remoteVideoUserId && !this.preserveRemoteDom) {
1107
1111
  this.pendingRemoteVideoUserId = this.remoteVideoUserId;
1108
1112
  this.remoteVideoUserId = null;
1109
1113
  }
@@ -3935,6 +3939,7 @@ function drawNeon(ctx, segs, container, targetSize, dpr, fitMode, mirrored) {
3935
3939
  }
3936
3940
  var DragTrackController = class {
3937
3941
  constructor(container, options) {
3942
+ this.strokeActive = false;
3938
3943
  this.activePointers = /* @__PURE__ */ new Map();
3939
3944
  this.lastTargetPoints = /* @__PURE__ */ new Map();
3940
3945
  this.segQueue = [];
@@ -3944,11 +3949,12 @@ var DragTrackController = class {
3944
3949
  this.resizeObserver = null;
3945
3950
  this.container = container;
3946
3951
  this.onTracks = options.onTracks;
3952
+ this.onStrokeStart = options.onStrokeStart;
3953
+ this.onStrokeEnd = options.onStrokeEnd;
3947
3954
  this.targetSize = options.targetSize;
3948
3955
  this.fitMode = options.fitMode ?? "cover";
3949
3956
  this.mirrored = options.mirrored ?? false;
3950
3957
  this.enabled = options.enabled ?? true;
3951
- this.emitEmptyTracksWhenIdle = options.emitEmptyTracksWhenIdle ?? false;
3952
3958
  this.canvas = document.createElement("canvas");
3953
3959
  this.canvas.className = "Xmax-drag-track-canvas";
3954
3960
  this.canvas.style.cssText = "position:absolute;inset:0;z-index:21;width:100%;height:100%;pointer-events:none;";
@@ -3962,32 +3968,12 @@ var DragTrackController = class {
3962
3968
  this.bindResizeObserver();
3963
3969
  this.bindPointerEvents();
3964
3970
  this.applyInteractionStyle();
3965
- if (this.enabled && this.emitEmptyTracksWhenIdle) {
3966
- this.startSampling();
3967
- }
3968
3971
  }
3969
3972
  setEnabled(enabled) {
3970
3973
  this.enabled = enabled;
3971
3974
  this.applyInteractionStyle();
3972
3975
  if (!enabled) {
3973
- this.finishStroke({ stopIdleSampling: true });
3974
- return;
3975
- }
3976
- if (this.emitEmptyTracksWhenIdle && this.activePointers.size === 0) {
3977
- this.startSampling();
3978
- }
3979
- }
3980
- setEmitEmptyTracksWhenIdle(emitEmptyTracksWhenIdle) {
3981
- if (this.emitEmptyTracksWhenIdle === emitEmptyTracksWhenIdle) {
3982
- return;
3983
- }
3984
- this.emitEmptyTracksWhenIdle = emitEmptyTracksWhenIdle;
3985
- if (emitEmptyTracksWhenIdle && this.enabled && this.activePointers.size === 0) {
3986
- this.startSampling();
3987
- return;
3988
- }
3989
- if (!emitEmptyTracksWhenIdle && this.activePointers.size === 0) {
3990
- this.stopSampling();
3976
+ this.finishStroke();
3991
3977
  }
3992
3978
  }
3993
3979
  setTargetSize(targetSize) {
@@ -4000,7 +3986,7 @@ var DragTrackController = class {
4000
3986
  this.mirrored = mirrored;
4001
3987
  }
4002
3988
  destroy() {
4003
- this.finishStroke({ stopIdleSampling: true });
3989
+ this.finishStroke();
4004
3990
  this.unbindPointerEvents();
4005
3991
  this.unbindResizeObserver();
4006
3992
  this.canvas.remove();
@@ -4117,7 +4103,7 @@ var DragTrackController = class {
4117
4103
  return;
4118
4104
  }
4119
4105
  const tracks = this.collectCurrentTracks();
4120
- if (!tracks.length && !this.emitEmptyTracksWhenIdle) {
4106
+ if (!tracks.length) {
4121
4107
  return;
4122
4108
  }
4123
4109
  this.sampleInFlight = true;
@@ -4135,14 +4121,17 @@ var DragTrackController = class {
4135
4121
  this.flushTracks();
4136
4122
  }, 30);
4137
4123
  }
4138
- finishStroke(options) {
4139
- const stopIdleSampling = options?.stopIdleSampling ?? !this.emitEmptyTracksWhenIdle;
4140
- if (stopIdleSampling) {
4141
- this.stopSampling();
4142
- }
4124
+ finishStroke(emitEnd = false) {
4125
+ const wasActive = this.strokeActive;
4126
+ this.strokeActive = false;
4127
+ this.stopSampling();
4143
4128
  this.stopDrawLoop();
4144
4129
  this.segQueue.length = 0;
4145
4130
  this.clearCanvas();
4131
+ if (emitEnd && wasActive && this.onStrokeEnd) {
4132
+ Promise.resolve(this.onStrokeEnd()).catch(() => {
4133
+ });
4134
+ }
4146
4135
  }
4147
4136
  handlePointerDown(e) {
4148
4137
  if (!this.enabled) {
@@ -4166,6 +4155,12 @@ var DragTrackController = class {
4166
4155
  if (targetPoint) {
4167
4156
  this.lastTargetPoints.set(e.pointerId, targetPoint);
4168
4157
  }
4158
+ const strokeWasActive = this.strokeActive;
4159
+ this.strokeActive = true;
4160
+ if (!strokeWasActive && this.onStrokeStart) {
4161
+ Promise.resolve(this.onStrokeStart()).catch(() => {
4162
+ });
4163
+ }
4169
4164
  this.startDrawLoop();
4170
4165
  this.startSampling();
4171
4166
  }
@@ -4198,7 +4193,7 @@ var DragTrackController = class {
4198
4193
  } catch {
4199
4194
  }
4200
4195
  if (this.activePointers.size === 0) {
4201
- this.finishStroke();
4196
+ this.finishStroke(true);
4202
4197
  }
4203
4198
  }
4204
4199
  handlePointerCancel(e) {
@@ -4208,7 +4203,7 @@ var DragTrackController = class {
4208
4203
  this.activePointers.delete(e.pointerId);
4209
4204
  this.lastTargetPoints.delete(e.pointerId);
4210
4205
  if (this.activePointers.size === 0) {
4211
- this.finishStroke();
4206
+ this.finishStroke(true);
4212
4207
  }
4213
4208
  }
4214
4209
  };