yjz-web-sdk 1.0.11-beta.1 → 1.0.11-beta.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.
@@ -1,6 +1,10 @@
1
- import { ChannelDataType } from "../core/data/WebrtcDataType.ts";
1
+ import { ChannelDataType } from "../core/data/WebrtcDataType";
2
2
  import { type Ref } from "vue";
3
- export default function useKeyboardControl(disabled: Ref<boolean>, emit: (event: 'channelEvent', payload: ChannelDataType, data: any) => void): {
3
+ export default function useKeyboardControl(imeInput: Ref<HTMLTextAreaElement | null>, disabled: Ref<boolean>, emit: (event: 'channelEvent', payload: ChannelDataType, data: any) => void): {
4
4
  startListening: () => void;
5
5
  stopListening: () => void;
6
+ onCompositionStart: (_e: CompositionEvent) => void;
7
+ onCompositionEnd: (e: CompositionEvent) => void;
8
+ onInput: (e: InputEvent) => void;
9
+ onKeyDown: (event: KeyboardEvent) => void;
6
10
  };
@@ -1,5 +1,5 @@
1
1
  import type { Ref } from 'vue';
2
- import { ChannelDataType } from "../core/data/WebrtcDataType.ts";
2
+ import { ChannelDataType } from "../core/data/WebrtcDataType";
3
3
  import type { Dimension } from "../components/RemotePlayer/index.ts";
4
4
  interface MouseTouchControlOptions {
5
5
  remoteVideoElement: Ref<HTMLVideoElement | null>;
@@ -8,14 +8,15 @@ interface MouseTouchControlOptions {
8
8
  videoAngle: Ref<number>;
9
9
  widthRadio: Ref<number>;
10
10
  isGroup: Ref<boolean>;
11
+ isMove: Ref<boolean>;
11
12
  emit: (event: 'channelEvent', payload: ChannelDataType, data: any) => void;
12
13
  }
13
14
  export default function useMouseTouchControl(options: MouseTouchControlOptions): {
14
- isPointerDown: any;
15
+ pointers: any;
15
16
  handleMouseDown: (event: PointerEvent) => void;
16
17
  handleMouseMove: (event: PointerEvent) => void;
17
- handleMouseEnter: (event: PointerEvent) => void;
18
18
  handleMouseUp: (event: PointerEvent) => void;
19
+ handleMouseEnter: (event: PointerEvent) => void;
19
20
  handleMouseLeave: (event: PointerEvent) => void;
20
21
  handleWheel: (e: WheelEvent) => void;
21
22
  };
@@ -14,3 +14,9 @@ export interface KeyEventData {
14
14
  * @returns 包含 androidKeyCode 和 metaState 的对象
15
15
  */
16
16
  export declare const getKeyEventData: (event: KeyboardEvent) => KeyEventData;
17
+ /**
18
+ * 判断当前按键是否属于功能键
19
+ * @param event - 浏览器 KeyboardEvent
20
+ * @returns true 表示是功能键
21
+ */
22
+ export declare const isFunctionKey: (event: KeyboardEvent) => boolean;
@@ -1,8 +1,8 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".vContainer[data-v-611728c2]{transition:transform .2s linear;transform-origin:center center;margin:0;overflow:hidden;transform:translateZ(0);will-change:transform}.flex[data-v-611728c2]{display:flex}.flex-1[data-v-611728c2]{flex:1 1 0}.items-center[data-v-611728c2]{align-items:center}.justify-center[data-v-611728c2]{justify-content:center}.video-control[data-v-611728c2]{width:100%;height:100%;display:block;-webkit-user-select:none;user-select:none;object-fit:cover;clip-path:inset(0 1px);-webkit-user-drag:none;touch-action:none;backface-visibility:hidden;-webkit-backface-visibility:hidden;transform:translateZ(0)}.circle-cursor[data-v-611728c2]{cursor:url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3ccircle%20cx='12'%20cy='12'%20r='12'%20fill='%23fff'%20opacity='.6'/%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='%23000'%20opacity='.6'/%3e%3c/svg%3e\") 12 12,auto}.triangle-cursor[data-v-611728c2]{cursor:url(\"data:image/svg+xml,%3csvg%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='22'%20height='22'%3e%3cpath%20d='M143.832313%205.834982H143.686438A108.676545%20108.676545%200%200%200%205.834982%20143.686438l34.499333-11.815839-34.499333%2011.815839%200.072938%200.218812%200.145874%200.437624%200.583498%201.750494%202.333993%206.71023%208.752474%2025.528047L49.232663%20269.867929a2254749.467572%202254749.467572%200%200%201%20223.917444%20652.351017l9.335972%2027.205605%202.552804%207.585476%200.729373%202.188119a72.572592%2072.572592%200%200%200%20126.181491%2040.844876%2072.134968%2072.134968%200%200%200%2014.076895-18.963693c3.282178-6.41848%205.689108-13.639271%208.023101-20.3495l0.072937-0.291749%2072.572592-209.329989%2047.409231-136.830334%2015.53564-44.710551%200.145874-0.364687%200.510561-0.145874%2045.002301-15.900327%20137.486769-48.649165c99.340573-35.228705%20202.984445-71.989094%20209.913487-74.906584l3.355115-1.312871c8.023101-3.136303%2022.391744-8.606599%2033.915834-20.130689a72.499655%2072.499655%200%200%200%200-102.549813L999.240712%20304.877823c-1.823432-1.969307-7.293728-7.731351-13.274585-11.961714a89.056417%2089.056417%200%200%200-27.205605-12.3264h-0.145874l-2.552805-0.875247L948.184617%20277.161657l-27.86204-9.263034-94.672588-31.800653A405018.007245%20405018.007245%200%200%201%20268.919745%2048.138604L178.039896%2017.504947%20152.657723%208.752473%20145.874556%206.637292%20144.196999%205.90792%20143.832313%205.834982z'%20fill='%23000000'%20opacity='.7'%3e%3c/path%3e%3c/svg%3e\") 1 1,auto}.default-cursor[data-v-611728c2]{cursor:default}.no-events[data-v-611728c2]{pointer-events:none!important}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".vContainer[data-v-9ec809c2]{transition:transform .2s linear;transform-origin:center center;margin:0;overflow:hidden;transform:translateZ(0);will-change:transform}.flex[data-v-9ec809c2]{display:flex}.flex-1[data-v-9ec809c2]{flex:1 1 0}.items-center[data-v-9ec809c2]{align-items:center}.justify-center[data-v-9ec809c2]{justify-content:center}.video-control[data-v-9ec809c2]{width:100%;height:100%;display:block;-webkit-user-select:none;user-select:none;object-fit:cover;clip-path:inset(0 1px);-webkit-user-drag:none;touch-action:none;backface-visibility:hidden;-webkit-backface-visibility:hidden;transform:translateZ(0)}.circle-cursor[data-v-9ec809c2]{cursor:url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3ccircle%20cx='12'%20cy='12'%20r='12'%20fill='%23fff'%20opacity='.6'/%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='%23000'%20opacity='.6'/%3e%3c/svg%3e\") 12 12,auto}.triangle-cursor[data-v-9ec809c2]{cursor:url(\"data:image/svg+xml,%3csvg%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='22'%20height='22'%3e%3cpath%20d='M143.832313%205.834982H143.686438A108.676545%20108.676545%200%200%200%205.834982%20143.686438l34.499333-11.815839-34.499333%2011.815839%200.072938%200.218812%200.145874%200.437624%200.583498%201.750494%202.333993%206.71023%208.752474%2025.528047L49.232663%20269.867929a2254749.467572%202254749.467572%200%200%201%20223.917444%20652.351017l9.335972%2027.205605%202.552804%207.585476%200.729373%202.188119a72.572592%2072.572592%200%200%200%20126.181491%2040.844876%2072.134968%2072.134968%200%200%200%2014.076895-18.963693c3.282178-6.41848%205.689108-13.639271%208.023101-20.3495l0.072937-0.291749%2072.572592-209.329989%2047.409231-136.830334%2015.53564-44.710551%200.145874-0.364687%200.510561-0.145874%2045.002301-15.900327%20137.486769-48.649165c99.340573-35.228705%20202.984445-71.989094%20209.913487-74.906584l3.355115-1.312871c8.023101-3.136303%2022.391744-8.606599%2033.915834-20.130689a72.499655%2072.499655%200%200%200%200-102.549813L999.240712%20304.877823c-1.823432-1.969307-7.293728-7.731351-13.274585-11.961714a89.056417%2089.056417%200%200%200-27.205605-12.3264h-0.145874l-2.552805-0.875247L948.184617%20277.161657l-27.86204-9.263034-94.672588-31.800653A405018.007245%20405018.007245%200%200%201%20268.919745%2048.138604L178.039896%2017.504947%20152.657723%208.752473%20145.874556%206.637292%20144.196999%205.90792%20143.832313%205.834982z'%20fill='%23000000'%20opacity='.7'%3e%3c/path%3e%3c/svg%3e\") 1 1,auto}.default-cursor[data-v-9ec809c2]{cursor:default}.no-events[data-v-9ec809c2]{pointer-events:none!important}.ime-input[data-v-9ec809c2]{position:absolute;opacity:0;right:0;bottom:0;width:1px;height:1px;border:none;outline:none;resize:none;z-index:-1}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- import { computed, onMounted, onUnmounted, ref, onBeforeUnmount, defineComponent, toRefs, createElementBlock, openBlock, createElementVNode, normalizeStyle, unref, normalizeClass } from "vue";
5
+ import { computed, onMounted, onUnmounted, ref, onBeforeUnmount, defineComponent, toRefs, createElementBlock, openBlock, createElementVNode, normalizeStyle, unref, createCommentVNode, normalizeClass } from "vue";
6
6
  function _mergeNamespaces(n, m) {
7
7
  for (var i = 0; i < m.length; i++) {
8
8
  const e = m[i];
@@ -4945,6 +4945,61 @@ const getKeyEventData = (event) => {
4945
4945
  meta
4946
4946
  };
4947
4947
  };
4948
+ const FunctionKeys = /* @__PURE__ */ new Set([
4949
+ // 方向键
4950
+ "ArrowUp",
4951
+ "ArrowDown",
4952
+ "ArrowLeft",
4953
+ "ArrowRight",
4954
+ // 编辑键
4955
+ "Backspace",
4956
+ "Delete",
4957
+ "Enter",
4958
+ "Tab",
4959
+ "Escape",
4960
+ "Space",
4961
+ // 修饰键
4962
+ "ShiftLeft",
4963
+ "ShiftRight",
4964
+ "ControlLeft",
4965
+ "ControlRight",
4966
+ "AltLeft",
4967
+ "AltRight",
4968
+ "MetaLeft",
4969
+ "MetaRight",
4970
+ // 锁定键
4971
+ "CapsLock",
4972
+ "NumLock",
4973
+ "ScrollLock",
4974
+ // 功能键
4975
+ "F1",
4976
+ "F2",
4977
+ "F3",
4978
+ "F4",
4979
+ "F5",
4980
+ "F6",
4981
+ "F7",
4982
+ "F8",
4983
+ "F9",
4984
+ "F10",
4985
+ "F11",
4986
+ "F12",
4987
+ // 系统键
4988
+ "Insert",
4989
+ "Home",
4990
+ "End",
4991
+ "PageUp",
4992
+ "PageDown",
4993
+ "PrintScreen",
4994
+ "Pause",
4995
+ "ContextMenu"
4996
+ ]);
4997
+ const isFunctionKey = (event) => {
4998
+ if (FunctionKeys.has(event.code)) {
4999
+ return true;
5000
+ }
5001
+ return event.ctrlKey || event.altKey || event.shiftKey || event.metaKey;
5002
+ };
4948
5003
  function transformCoordinate(viewWidth, viewHeight, cloudWidth, cloudHeight, viewAngle, streamAngle, inputX, inputY) {
4949
5004
  let realShortWidth;
4950
5005
  let short;
@@ -5179,6 +5234,13 @@ function useRemoteVideo(videoContainer, remoteVideoElement, videoAngle, emit) {
5179
5234
  stopPlay
5180
5235
  };
5181
5236
  }
5237
+ function getEventXY(event, rect) {
5238
+ if ("clientX" in event && "clientY" in event) {
5239
+ return [event.clientX - rect.left, event.clientY - rect.top];
5240
+ } else {
5241
+ return [0, 0];
5242
+ }
5243
+ }
5182
5244
  function useMouseTouchControl(options) {
5183
5245
  const {
5184
5246
  remoteVideoElement,
@@ -5187,20 +5249,15 @@ function useMouseTouchControl(options) {
5187
5249
  videoAngle,
5188
5250
  widthRadio,
5189
5251
  isGroup,
5252
+ isMove,
5190
5253
  emit
5191
5254
  } = options;
5192
- const isPointerDown = ref(false);
5193
- const bound = ref(0);
5194
- const pointerList = ref(new Array(20).fill(0));
5195
- const pointerDownTime = ref(new Array(10).fill(0));
5196
- const index2 = ref(0);
5197
- const groupIndex = ref(0);
5198
- const handlePointerEvent = (event, action) => {
5255
+ const pointers = ref(/* @__PURE__ */ new Map());
5256
+ const groupIndexCounter = ref(0);
5257
+ const handlePointerEvent = (event, action, pointerId) => {
5199
5258
  if (!remoteVideoElement.value) return;
5200
- const offsetTime = Math.trunc(event.timeStamp - pointerDownTime.value[0]);
5201
5259
  const rect = remoteVideoElement.value.getBoundingClientRect();
5202
- let x = event.clientX - rect.left;
5203
- let y = event.clientY - rect.top;
5260
+ let [x, y] = getEventXY(event, rect);
5204
5261
  const cloudWidth = cloudDeviceSize.value.width;
5205
5262
  const cloudHeight = cloudDeviceSize.value.height;
5206
5263
  const result = transformCoordinate(
@@ -5213,24 +5270,38 @@ function useMouseTouchControl(options) {
5213
5270
  x,
5214
5271
  y
5215
5272
  );
5216
- if (!result || result.length < 2) return;
5273
+ if (!result) return;
5217
5274
  x = result[0];
5218
5275
  y = result[1];
5219
- if (action === ActionType.ACTION_MOVE) {
5220
- const flipY = pointerList.value[10] - y;
5221
- const flipX = pointerList.value[0] - x;
5222
- if (Math.abs(flipY) < bound.value && Math.abs(flipX) < bound.value) return;
5223
- }
5224
- if (isGroup.value) {
5225
- if (action === ActionType.ACTION_DOWN) {
5226
- index2.value = 0;
5227
- groupIndex.value++;
5228
- } else if (action === ActionType.ACTION_UP || action === ActionType.ACTION_MOVE) {
5229
- index2.value++;
5276
+ let pointerState = pointers.value.get(pointerId);
5277
+ if (action === ActionType.ACTION_DOWN) {
5278
+ pointerState = {
5279
+ x,
5280
+ y,
5281
+ downTime: event.timeStamp,
5282
+ isDown: true,
5283
+ bound: Math.trunc(6 / widthRadio.value),
5284
+ index: 0,
5285
+ groupIndex: groupIndexCounter.value++
5286
+ };
5287
+ pointers.value.set(pointerId, pointerState);
5288
+ } else {
5289
+ if (!pointerState) return;
5290
+ if (action === ActionType.ACTION_MOVE) {
5291
+ let dx = x - pointerState.x;
5292
+ let dy = y - pointerState.y;
5293
+ if (isMove.value) {
5294
+ dy = 0;
5295
+ y = pointerState.y;
5296
+ }
5297
+ if (Math.abs(dx) < pointerState.bound && Math.abs(dy) < pointerState.bound) {
5298
+ return;
5299
+ }
5300
+ pointerState.x = x;
5301
+ pointerState.y = y;
5302
+ pointerState.index++;
5230
5303
  }
5231
5304
  }
5232
- pointerList.value[0] = x;
5233
- pointerList.value[10] = y;
5234
5305
  const [px, py] = valueToPercentage(
5235
5306
  rect.width,
5236
5307
  rect.height,
@@ -5241,24 +5312,40 @@ function useMouseTouchControl(options) {
5241
5312
  x,
5242
5313
  y
5243
5314
  );
5244
- const touchData = isGroup.value ? new TouchData(action, 0, px, py, offsetTime, "web", index2.value, groupIndex.value) : new TouchData(action, 0, px, py, offsetTime, "web");
5315
+ const offsetTime = Math.trunc(event.timeStamp - pointerState.downTime);
5316
+ const touchData = isGroup.value ? new TouchData(
5317
+ action,
5318
+ pointerId,
5319
+ px,
5320
+ py,
5321
+ offsetTime,
5322
+ "web",
5323
+ pointerState.index,
5324
+ pointerState.groupIndex
5325
+ ) : new TouchData(
5326
+ action,
5327
+ pointerId,
5328
+ px,
5329
+ py,
5330
+ offsetTime,
5331
+ "web"
5332
+ );
5245
5333
  emit("channelEvent", ChannelDataType.ClickData, touchData);
5334
+ if (action === ActionType.ACTION_UP) {
5335
+ pointers.value.delete(pointerId);
5336
+ }
5246
5337
  };
5247
5338
  const handleMouseDown = (event) => {
5248
- isPointerDown.value = true;
5249
- if (remoteVideoElement.value) {
5250
- remoteVideoElement.value.setPointerCapture(event.pointerId);
5251
- }
5252
- pointerDownTime.value[0] = event.timeStamp;
5253
- bound.value = Math.trunc(6 / widthRadio.value);
5254
- handlePointerEvent(event, ActionType.ACTION_DOWN);
5339
+ event.preventDefault();
5340
+ event.stopPropagation();
5341
+ if (remoteVideoElement.value) remoteVideoElement.value.setPointerCapture(event.pointerId);
5342
+ handlePointerEvent(event, ActionType.ACTION_DOWN, event.pointerId);
5255
5343
  };
5256
5344
  const handleMouseMove = (event) => {
5257
- if (!isPointerDown.value) return;
5258
- handlePointerEvent(event, ActionType.ACTION_MOVE);
5259
- if (!remoteVideoElement.value) {
5260
- return;
5261
- }
5345
+ event.preventDefault();
5346
+ event.stopPropagation();
5347
+ handlePointerEvent(event, ActionType.ACTION_MOVE, event.pointerId);
5348
+ if (!remoteVideoElement.value) return;
5262
5349
  const rect = remoteVideoElement.value.getBoundingClientRect();
5263
5350
  const { clientX: x, clientY: y } = event;
5264
5351
  if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) {
@@ -5266,31 +5353,25 @@ function useMouseTouchControl(options) {
5266
5353
  }
5267
5354
  };
5268
5355
  const handleMouseUp = (event) => {
5269
- if (!isPointerDown.value) return;
5270
- isPointerDown.value = false;
5271
- handlePointerEvent(event, ActionType.ACTION_UP);
5272
- if (remoteVideoElement.value) {
5273
- remoteVideoElement.value.releasePointerCapture(event.pointerId);
5274
- }
5356
+ event.preventDefault();
5357
+ event.stopPropagation();
5358
+ handlePointerEvent(event, ActionType.ACTION_UP, event.pointerId);
5359
+ if (remoteVideoElement.value) remoteVideoElement.value.releasePointerCapture(event.pointerId);
5275
5360
  };
5276
5361
  const handleMouseEnter = (event) => {
5277
- if (event.buttons === 1 && !isPointerDown.value) {
5278
- isPointerDown.value = true;
5279
- if (remoteVideoElement.value) {
5280
- remoteVideoElement.value.setPointerCapture(event.pointerId);
5281
- }
5282
- pointerDownTime.value[0] = event.timeStamp;
5283
- bound.value = Math.trunc(6 / widthRadio.value);
5284
- handlePointerEvent(event, ActionType.ACTION_DOWN);
5362
+ event.preventDefault();
5363
+ event.stopPropagation();
5364
+ if (event.buttons === 1 && !pointers.value.has(event.pointerId)) {
5365
+ if (remoteVideoElement.value) remoteVideoElement.value.setPointerCapture(event.pointerId);
5366
+ handlePointerEvent(event, ActionType.ACTION_DOWN, event.pointerId);
5285
5367
  }
5286
5368
  };
5287
5369
  const handleMouseLeave = (event) => {
5288
- if (isPointerDown.value) {
5289
- handlePointerEvent(event, ActionType.ACTION_UP);
5290
- isPointerDown.value = false;
5291
- if (remoteVideoElement.value) {
5292
- remoteVideoElement.value.releasePointerCapture(event.pointerId);
5293
- }
5370
+ event.preventDefault();
5371
+ event.stopPropagation();
5372
+ if (pointers.value.has(event.pointerId)) {
5373
+ handlePointerEvent(event, ActionType.ACTION_UP, event.pointerId);
5374
+ if (remoteVideoElement.value) remoteVideoElement.value.releasePointerCapture(event.pointerId);
5294
5375
  }
5295
5376
  };
5296
5377
  const handleWheel = (e) => {
@@ -5299,38 +5380,93 @@ function useMouseTouchControl(options) {
5299
5380
  emit("channelEvent", ChannelDataType.ActionWheel, wheelData);
5300
5381
  };
5301
5382
  return {
5302
- isPointerDown,
5383
+ pointers,
5303
5384
  handleMouseDown,
5304
5385
  handleMouseMove,
5305
- handleMouseEnter,
5306
5386
  handleMouseUp,
5387
+ handleMouseEnter,
5307
5388
  handleMouseLeave,
5308
5389
  handleWheel
5309
5390
  };
5310
5391
  }
5311
- function useKeyboardControl(disabled, emit) {
5312
- const listening = ref(false);
5392
+ function useKeyboardControl(imeInput, disabled, emit) {
5393
+ const isComposing = ref(false);
5313
5394
  const handleKeyDown = (e) => {
5314
5395
  const data = getKeyEventData(e);
5396
+ console.log("handleKeyDown===>handleKeyDown");
5315
5397
  emit("channelEvent", ChannelDataType.ActionInput, data);
5316
5398
  };
5399
+ function onCompositionStart(_e) {
5400
+ isComposing.value = true;
5401
+ }
5402
+ function onCompositionEnd(e) {
5403
+ isComposing.value = false;
5404
+ const text = e.data;
5405
+ if (text && text.length > 0) {
5406
+ console.log(`onCompositionEnd===>${text}`);
5407
+ emit("channelEvent", ChannelDataType.ActionChinese, new InputData(text));
5408
+ }
5409
+ clearInput();
5410
+ }
5317
5411
  const startListening = () => {
5318
5412
  if (!disabled) {
5319
5413
  return;
5320
5414
  }
5321
- listening.value = true;
5322
- document.addEventListener("keydown", handleKeyDown);
5415
+ if (imeInput.value) {
5416
+ focusIME();
5417
+ } else {
5418
+ document.addEventListener("keydown", handleKeyDown);
5419
+ }
5323
5420
  };
5324
5421
  const stopListening = () => {
5325
5422
  if (!disabled) {
5326
5423
  return;
5327
5424
  }
5328
- listening.value = false;
5329
- document.removeEventListener("keydown", handleKeyDown);
5425
+ if (imeInput.value) {
5426
+ blurIME();
5427
+ } else {
5428
+ document.removeEventListener("keydown", handleKeyDown);
5429
+ }
5430
+ };
5431
+ const onInput = (e) => {
5432
+ if (isComposing.value) return;
5433
+ const text = e.data;
5434
+ if (text && text.length > 0) {
5435
+ emit("channelEvent", ChannelDataType.ActionChinese, new InputData(text));
5436
+ console.log("onInput===>", text);
5437
+ }
5438
+ clearInput();
5439
+ };
5440
+ function onKeyDown(event) {
5441
+ if (isComposing.value) return;
5442
+ if (isFunctionKey(event)) {
5443
+ const data = getKeyEventData(event);
5444
+ if (data.keyCode === 50 && data.meta === 4096) return;
5445
+ emit("channelEvent", ChannelDataType.ActionInput, data);
5446
+ }
5447
+ }
5448
+ const clearInput = () => {
5449
+ if (imeInput.value) {
5450
+ imeInput.value.value = "";
5451
+ }
5452
+ };
5453
+ const focusIME = () => {
5454
+ requestAnimationFrame(() => {
5455
+ var _a;
5456
+ (_a = imeInput.value) == null ? void 0 : _a.focus();
5457
+ });
5458
+ };
5459
+ const blurIME = () => {
5460
+ var _a;
5461
+ (_a = imeInput.value) == null ? void 0 : _a.blur();
5330
5462
  };
5331
5463
  return {
5332
5464
  startListening,
5333
- stopListening
5465
+ stopListening,
5466
+ onCompositionStart,
5467
+ onCompositionEnd,
5468
+ onInput,
5469
+ onKeyDown
5334
5470
  };
5335
5471
  }
5336
5472
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -5342,15 +5478,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5342
5478
  cloudDeviceSize: { default: () => ({ width: 0, height: 0 }) },
5343
5479
  disabled: { type: Boolean, default: true },
5344
5480
  bgColor: { default: "transparent" },
5345
- isGroup: { type: Boolean, default: false }
5481
+ isGroup: { type: Boolean, default: false },
5482
+ isMove: { type: Boolean, default: false },
5483
+ isKeyMapping: { type: Boolean, default: false }
5346
5484
  },
5347
5485
  emits: ["channelEvent", "groupControlEvent", "loadedSuccess"],
5348
5486
  setup(__props, { expose: __expose, emit: __emit }) {
5349
5487
  const emit = __emit;
5350
5488
  const props = __props;
5351
- const { streamAngle, videoAngle, cursorType, cloudDeviceSize, disabled, bgColor, isGroup } = toRefs(props);
5489
+ const { streamAngle, videoAngle, cursorType, cloudDeviceSize, disabled, bgColor, isGroup, isMove, isKeyMapping } = toRefs(props);
5352
5490
  const videoContainer = ref(null);
5353
5491
  const remoteVideoElement = ref(null);
5492
+ const imeInput = ref(null);
5354
5493
  const cursorClass = useCursorStyle(cursorType);
5355
5494
  const {
5356
5495
  videoSize,
@@ -5374,12 +5513,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5374
5513
  videoAngle,
5375
5514
  widthRadio,
5376
5515
  isGroup,
5516
+ isMove,
5377
5517
  emit
5378
5518
  });
5379
5519
  const {
5380
5520
  startListening,
5381
- stopListening
5382
- } = useKeyboardControl(disabled, emit);
5521
+ stopListening,
5522
+ onCompositionStart,
5523
+ onCompositionEnd,
5524
+ onInput,
5525
+ onKeyDown
5526
+ } = useKeyboardControl(imeInput, disabled, emit);
5383
5527
  useResizeObserver(videoContainer, dimensions);
5384
5528
  const handleClick = () => {
5385
5529
  var _a;
@@ -5404,9 +5548,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5404
5548
  }, [
5405
5549
  createElementVNode("div", {
5406
5550
  ref: "keyboardArea",
5407
- onPointerenter: _cache[6] || (_cache[6] = //@ts-ignore
5551
+ onPointerenter: _cache[10] || (_cache[10] = //@ts-ignore
5408
5552
  (...args) => unref(startListening) && unref(startListening)(...args)),
5409
- onPointerleave: _cache[7] || (_cache[7] = //@ts-ignore
5553
+ onPointerleave: _cache[11] || (_cache[11] = //@ts-ignore
5410
5554
  (...args) => unref(stopListening) && unref(stopListening)(...args)),
5411
5555
  class: "vContainer",
5412
5556
  style: normalizeStyle([{ height: unref(videoSize).height + "px", width: unref(videoSize).width + "px", transform: `rotate(${unref(videoAngle)}deg)` }, { "position": "relative", "overflow": "hidden" }])
@@ -5432,7 +5576,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5432
5576
  playsinline: "",
5433
5577
  muted: "",
5434
5578
  disablePictureInPicture: true
5435
- }, null, 38)
5579
+ }, null, 38),
5580
+ unref(isKeyMapping) ? (openBlock(), createElementBlock("textarea", {
5581
+ key: 0,
5582
+ ref_key: "imeInput",
5583
+ ref: imeInput,
5584
+ class: "ime-input",
5585
+ autocomplete: "off",
5586
+ autocapitalize: "off",
5587
+ spellcheck: "false",
5588
+ onCompositionstart: _cache[6] || (_cache[6] = //@ts-ignore
5589
+ (...args) => unref(onCompositionStart) && unref(onCompositionStart)(...args)),
5590
+ onCompositionend: _cache[7] || (_cache[7] = //@ts-ignore
5591
+ (...args) => unref(onCompositionEnd) && unref(onCompositionEnd)(...args)),
5592
+ onInput: _cache[8] || (_cache[8] = //@ts-ignore
5593
+ (...args) => unref(onInput) && unref(onInput)(...args)),
5594
+ onKeydown: _cache[9] || (_cache[9] = //@ts-ignore
5595
+ (...args) => unref(onKeyDown) && unref(onKeyDown)(...args))
5596
+ }, null, 544)) : createCommentVNode("", true)
5436
5597
  ], 36)
5437
5598
  ], 512);
5438
5599
  };
@@ -5445,7 +5606,7 @@ const _export_sfc = (sfc, props) => {
5445
5606
  }
5446
5607
  return target;
5447
5608
  };
5448
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-611728c2"]]);
5609
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-9ec809c2"]]);
5449
5610
  class SdkController extends EventEmitter {
5450
5611
  constructor(config) {
5451
5612
  super();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yjz-web-sdk",
3
3
  "private": false,
4
- "version": "1.0.11-beta.1",
4
+ "version": "1.0.11-beta.2",
5
5
  "type": "module",
6
6
  "description": "针对于亚矩阵项目的云手机投屏和屏幕控制",
7
7
  "license": "Apache-2.0",