call-live-sdk1 0.0.35 → 0.0.36

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.
@@ -169789,6 +169789,41 @@ function debounce$2(func, wait2, options) {
169789
169789
  debounced.flush = flush3;
169790
169790
  return debounced;
169791
169791
  }
169792
+ const CountDown = ({ isLive }) => {
169793
+ const [timer, setTimer] = reactExports.useState("00:00:00");
169794
+ const timerIntervalRef = reactExports.useRef(null);
169795
+ const secondsRef = reactExports.useRef(0);
169796
+ const formatTime2 = (totalSeconds) => {
169797
+ const hours = Math.floor(totalSeconds / 3600);
169798
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
169799
+ const seconds = totalSeconds % 60;
169800
+ return [hours, minutes, seconds].map((v3) => v3 < 10 ? `0${v3}` : v3).join(":");
169801
+ };
169802
+ reactExports.useEffect(() => {
169803
+ if (isLive) {
169804
+ secondsRef.current = 0;
169805
+ setTimer("00:00:00");
169806
+ timerIntervalRef.current = setInterval(() => {
169807
+ secondsRef.current += 1;
169808
+ setTimer(formatTime2(secondsRef.current));
169809
+ }, 1e3);
169810
+ } else {
169811
+ if (timerIntervalRef.current) {
169812
+ clearInterval(timerIntervalRef.current);
169813
+ timerIntervalRef.current = null;
169814
+ }
169815
+ secondsRef.current = 0;
169816
+ setTimer("00:00:00");
169817
+ }
169818
+ return () => {
169819
+ if (timerIntervalRef.current) {
169820
+ clearInterval(timerIntervalRef.current);
169821
+ }
169822
+ };
169823
+ }, [isLive]);
169824
+ return isLive && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-16px text-#fff h-full flex items-center mr-3", children: timer });
169825
+ };
169826
+ const CountDown$1 = reactExports.memo(CountDown);
169792
169827
  const useLivePushCodeStore = create$c((set3, get4) => ({
169793
169828
  livePushCode: null,
169794
169829
  isLoading: false,
@@ -169862,41 +169897,6 @@ const useCommentChatUrlStore = create$c((set3) => ({
169862
169897
  }
169863
169898
  }
169864
169899
  }));
169865
- const CountDown = ({ isLive }) => {
169866
- const [timer, setTimer] = reactExports.useState("00:00:00");
169867
- const timerIntervalRef = reactExports.useRef(null);
169868
- const secondsRef = reactExports.useRef(0);
169869
- const formatTime2 = (totalSeconds) => {
169870
- const hours = Math.floor(totalSeconds / 3600);
169871
- const minutes = Math.floor(totalSeconds % 3600 / 60);
169872
- const seconds = totalSeconds % 60;
169873
- return [hours, minutes, seconds].map((v3) => v3 < 10 ? `0${v3}` : v3).join(":");
169874
- };
169875
- reactExports.useEffect(() => {
169876
- if (isLive) {
169877
- secondsRef.current = 0;
169878
- setTimer("00:00:00");
169879
- timerIntervalRef.current = setInterval(() => {
169880
- secondsRef.current += 1;
169881
- setTimer(formatTime2(secondsRef.current));
169882
- }, 1e3);
169883
- } else {
169884
- if (timerIntervalRef.current) {
169885
- clearInterval(timerIntervalRef.current);
169886
- timerIntervalRef.current = null;
169887
- }
169888
- secondsRef.current = 0;
169889
- setTimer("00:00:00");
169890
- }
169891
- return () => {
169892
- if (timerIntervalRef.current) {
169893
- clearInterval(timerIntervalRef.current);
169894
- }
169895
- };
169896
- }, [isLive]);
169897
- return isLive && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-16px text-#fff h-full flex items-center mr-3", children: timer });
169898
- };
169899
- const CountDown$1 = reactExports.memo(CountDown);
169900
169900
  const useActivityTypeStore = create$c((set3, get4) => ({
169901
169901
  activityType: {
169902
169902
  active_type: 0
@@ -188598,6 +188598,16 @@ const subscribeWithSelectorImpl = (fn2) => (set3, get4, api) => {
188598
188598
  return initialState;
188599
188599
  };
188600
188600
  const subscribeWithSelector = subscribeWithSelectorImpl;
188601
+ const useGuestStore = create$c()((set3, get4) => ({
188602
+ status: 0,
188603
+ deviceType: "pc",
188604
+ setDeviceType: (deviceType) => {
188605
+ set3({ deviceType });
188606
+ },
188607
+ setStatus: (status) => {
188608
+ set3({ status });
188609
+ }
188610
+ }));
188601
188611
  var VideoType = /* @__PURE__ */ ((VideoType2) => {
188602
188612
  VideoType2["CAMERA"] = "video";
188603
188613
  VideoType2["SCREEN"] = "screen";
@@ -188617,16 +188627,6 @@ var LayoutMode = /* @__PURE__ */ ((LayoutMode2) => {
188617
188627
  LayoutMode2["GRID"] = "grid";
188618
188628
  return LayoutMode2;
188619
188629
  })(LayoutMode || {});
188620
- const useGuestStore = create$c()((set3, get4) => ({
188621
- status: 0,
188622
- deviceType: "pc",
188623
- setDeviceType: (deviceType) => {
188624
- set3({ deviceType });
188625
- },
188626
- setStatus: (status) => {
188627
- set3({ status });
188628
- }
188629
- }));
188630
188630
  const updateRTCStorageConfig = async (params) => {
188631
188631
  return request("/bis/rtc/storage/config", {
188632
188632
  method: "POST",
@@ -211312,73 +211312,6 @@ class bh extends Va {
211312
211312
  }
211313
211313
  }
211314
211314
  t(bh, "type", "Vibrance"), t(bh, "defaults", { vibrance: 0 }), t(bh, "uniformLocations", ["uVibrance"]), tt.setClass(bh);
211315
- const useCallUserPagination = (config2) => {
211316
- const { gridCols } = config2;
211317
- const [currentPage, setCurrentPage] = reactExports.useState(1);
211318
- const { callUsers, setCallUsersCurrentPageRef, layoutMode } = useCallStore();
211319
- reactExports.useEffect(() => {
211320
- setCallUsersCurrentPageRef(currentPage);
211321
- }, [currentPage]);
211322
- reactExports.useEffect(() => {
211323
- setCurrentPage(1);
211324
- }, [layoutMode]);
211325
- const usersPerPage = reactExports.useMemo(() => {
211326
- return gridCols <= 1 ? 5 : 9;
211327
- }, [gridCols]);
211328
- const getTotalVideoCount = reactExports.useMemo(() => {
211329
- const videoList = callUsers.flatMap((item) => {
211330
- var _a2, _b, _c2;
211331
- if (item.waiting_mode_state === WaitingModeState.WAITING) {
211332
- return [];
211333
- }
211334
- if (item.isScreenEnabled) {
211335
- return [(_a2 = item.videoList) == null ? void 0 : _a2[1], (_b = item.videoList) == null ? void 0 : _b[0]];
211336
- }
211337
- return [(_c2 = item.videoList) == null ? void 0 : _c2[0]];
211338
- });
211339
- return videoList.length;
211340
- }, [callUsers]);
211341
- reactExports.useEffect(() => {
211342
- if (gridCols <= 1 && getTotalVideoCount <= 5) {
211343
- setCurrentPage(1);
211344
- }
211345
- }, [gridCols, getTotalVideoCount]);
211346
- const getTotalPages = reactExports.useMemo(() => {
211347
- return Math.ceil(getTotalVideoCount / usersPerPage) || 1;
211348
- }, [getTotalVideoCount, usersPerPage]);
211349
- const calculateOptimalGridCols = (userCount, defaultGridCols) => {
211350
- if (defaultGridCols <= 1)
211351
- return defaultGridCols;
211352
- if (userCount <= 1)
211353
- return 1;
211354
- if (userCount === 2)
211355
- return 2;
211356
- if (userCount <= 4)
211357
- return 2;
211358
- if (userCount <= 9)
211359
- return 3;
211360
- return 3;
211361
- };
211362
- const handlePrevPage = () => {
211363
- setCurrentPage((prev2) => Math.max(prev2 - 1, 1));
211364
- };
211365
- const handleNextPage = () => {
211366
- setCurrentPage((prev2) => Math.min(prev2 + 1, getTotalPages));
211367
- };
211368
- const goToPage = (pageNumber) => {
211369
- setCurrentPage(Math.min(Math.max(pageNumber, 1), getTotalPages));
211370
- };
211371
- return {
211372
- currentPage,
211373
- usersPerPage,
211374
- totalPages: getTotalPages,
211375
- totalVideoCount: getTotalVideoCount,
211376
- handlePrevPage,
211377
- handleNextPage,
211378
- goToPage,
211379
- calculateOptimalGridCols
211380
- };
211381
- };
211382
211315
  function _extends$y() {
211383
211316
  _extends$y = Object.assign ? Object.assign.bind() : function(target) {
211384
211317
  for (var i = 1; i < arguments.length; i++) {
@@ -211851,6 +211784,73 @@ const CallSingleColumnLayout = ({
211851
211784
  })]
211852
211785
  });
211853
211786
  };
211787
+ const useCallUserPagination = (config2) => {
211788
+ const { gridCols } = config2;
211789
+ const [currentPage, setCurrentPage] = reactExports.useState(1);
211790
+ const { callUsers, setCallUsersCurrentPageRef, layoutMode } = useCallStore();
211791
+ reactExports.useEffect(() => {
211792
+ setCallUsersCurrentPageRef(currentPage);
211793
+ }, [currentPage]);
211794
+ reactExports.useEffect(() => {
211795
+ setCurrentPage(1);
211796
+ }, [layoutMode]);
211797
+ const usersPerPage = reactExports.useMemo(() => {
211798
+ return gridCols <= 1 ? 5 : 9;
211799
+ }, [gridCols]);
211800
+ const getTotalVideoCount = reactExports.useMemo(() => {
211801
+ const videoList = callUsers.flatMap((item) => {
211802
+ var _a2, _b, _c2;
211803
+ if (item.waiting_mode_state === WaitingModeState.WAITING) {
211804
+ return [];
211805
+ }
211806
+ if (item.isScreenEnabled) {
211807
+ return [(_a2 = item.videoList) == null ? void 0 : _a2[1], (_b = item.videoList) == null ? void 0 : _b[0]];
211808
+ }
211809
+ return [(_c2 = item.videoList) == null ? void 0 : _c2[0]];
211810
+ });
211811
+ return videoList.length;
211812
+ }, [callUsers]);
211813
+ reactExports.useEffect(() => {
211814
+ if (gridCols <= 1 && getTotalVideoCount <= 5) {
211815
+ setCurrentPage(1);
211816
+ }
211817
+ }, [gridCols, getTotalVideoCount]);
211818
+ const getTotalPages = reactExports.useMemo(() => {
211819
+ return Math.ceil(getTotalVideoCount / usersPerPage) || 1;
211820
+ }, [getTotalVideoCount, usersPerPage]);
211821
+ const calculateOptimalGridCols = (userCount, defaultGridCols) => {
211822
+ if (defaultGridCols <= 1)
211823
+ return defaultGridCols;
211824
+ if (userCount <= 1)
211825
+ return 1;
211826
+ if (userCount === 2)
211827
+ return 2;
211828
+ if (userCount <= 4)
211829
+ return 2;
211830
+ if (userCount <= 9)
211831
+ return 3;
211832
+ return 3;
211833
+ };
211834
+ const handlePrevPage = () => {
211835
+ setCurrentPage((prev2) => Math.max(prev2 - 1, 1));
211836
+ };
211837
+ const handleNextPage = () => {
211838
+ setCurrentPage((prev2) => Math.min(prev2 + 1, getTotalPages));
211839
+ };
211840
+ const goToPage = (pageNumber) => {
211841
+ setCurrentPage(Math.min(Math.max(pageNumber, 1), getTotalPages));
211842
+ };
211843
+ return {
211844
+ currentPage,
211845
+ usersPerPage,
211846
+ totalPages: getTotalPages,
211847
+ totalVideoCount: getTotalVideoCount,
211848
+ handlePrevPage,
211849
+ handleNextPage,
211850
+ goToPage,
211851
+ calculateOptimalGridCols
211852
+ };
211853
+ };
211854
211854
  const useOnlineUsers = () => {
211855
211855
  const { callUsers, callConfig } = useCallStore();
211856
211856
  const [isLoading, setIsLoading] = reactExports.useState(false);
@@ -270454,87 +270454,6 @@ const SvgGuideO = reactExports.forwardRef((props, ref) => {
270454
270454
  reactExports.createElement(SvgIcon$6, null)
270455
270455
  );
270456
270456
  });
270457
- const useDrawingToolsStore = create$c((set3, get4) => ({
270458
- // 选中的工具
270459
- selectedTool: 0,
270460
- setSelectedTool: (tool) => set3({ selectedTool: tool }),
270461
- // 画笔设置
270462
- penSize: 2,
270463
- setPenSize: (size) => set3((state) => {
270464
- const newSize = typeof size === "function" ? size(state.penSize) : size;
270465
- return {
270466
- penSize: newSize
270467
- };
270468
- }),
270469
- penColor: "#ff5a5a",
270470
- setPenColor: (color) => set3((state) => {
270471
- const newColor = typeof color === "function" ? color(state.penColor) : color;
270472
- return {
270473
- penColor: newColor
270474
- };
270475
- }),
270476
- // 激光笔设置
270477
- laserPenSize: 2,
270478
- setLaserPenSize: (size) => set3((state) => {
270479
- const newSize = typeof size === "function" ? size(state.laserPenSize) : size;
270480
- return {
270481
- laserPenSize: newSize
270482
- };
270483
- }),
270484
- laserPenColor: "#ff5a5a",
270485
- setLaserPenColor: (color) => set3((state) => {
270486
- const newColor = typeof color === "function" ? color(state.laserPenColor) : color;
270487
- return {
270488
- laserPenColor: newColor
270489
- };
270490
- }),
270491
- // 形状设置
270492
- shapeSize: 2,
270493
- setShapeSize: (size) => set3((state) => {
270494
- const newSize = typeof size === "function" ? size(state.shapeSize) : size;
270495
- return {
270496
- shapeSize: newSize
270497
- };
270498
- }),
270499
- shapeType: "rect",
270500
- setShapeType: (type4) => set3((state) => {
270501
- const newType = typeof type4 === "function" ? type4(state.shapeType) : type4;
270502
- return {
270503
- shapeType: newType,
270504
- shapeTypeRef: { current: newType }
270505
- };
270506
- }),
270507
- shapeColor: "#ff5a5a",
270508
- setShapeColor: (color) => set3((state) => {
270509
- const newColor = typeof color === "function" ? color(state.shapeColor) : color;
270510
- return {
270511
- shapeColor: newColor
270512
- };
270513
- }),
270514
- // 文字设置
270515
- textSize: 16,
270516
- setTextSize: (size) => set3((state) => {
270517
- const newSize = typeof size === "function" ? size(state.textSize) : size;
270518
- return {
270519
- textSize: newSize
270520
- };
270521
- }),
270522
- textColor: "#ff5a5a",
270523
- setTextColor: (color) => set3((state) => {
270524
- const newColor = typeof color === "function" ? color(state.textColor) : color;
270525
- return {
270526
- textColor: newColor
270527
- };
270528
- }),
270529
- // 预览弹窗状态
270530
- isPreviewModalVisible: false,
270531
- setIsPreviewModalVisible: (visible) => set3({ isPreviewModalVisible: visible }),
270532
- // 绘图相关引用
270533
- downPoint: { current: null },
270534
- upPoint: { current: null },
270535
- currentShape: { current: null },
270536
- getter: () => get4()
270537
- }));
270538
270457
  const ShapeTypePicker = reactExports.memo(
270539
270458
  ({
270540
270459
  types: types2 = ["rect", "circle"],
@@ -270682,6 +270601,87 @@ const ToolOption = reactExports.memo(({
270682
270601
  });
270683
270602
  });
270684
270603
  ToolOption.displayName = "ToolOption";
270604
+ const useDrawingToolsStore = create$c((set3, get4) => ({
270605
+ // 选中的工具
270606
+ selectedTool: 0,
270607
+ setSelectedTool: (tool) => set3({ selectedTool: tool }),
270608
+ // 画笔设置
270609
+ penSize: 2,
270610
+ setPenSize: (size) => set3((state) => {
270611
+ const newSize = typeof size === "function" ? size(state.penSize) : size;
270612
+ return {
270613
+ penSize: newSize
270614
+ };
270615
+ }),
270616
+ penColor: "#ff5a5a",
270617
+ setPenColor: (color) => set3((state) => {
270618
+ const newColor = typeof color === "function" ? color(state.penColor) : color;
270619
+ return {
270620
+ penColor: newColor
270621
+ };
270622
+ }),
270623
+ // 激光笔设置
270624
+ laserPenSize: 2,
270625
+ setLaserPenSize: (size) => set3((state) => {
270626
+ const newSize = typeof size === "function" ? size(state.laserPenSize) : size;
270627
+ return {
270628
+ laserPenSize: newSize
270629
+ };
270630
+ }),
270631
+ laserPenColor: "#ff5a5a",
270632
+ setLaserPenColor: (color) => set3((state) => {
270633
+ const newColor = typeof color === "function" ? color(state.laserPenColor) : color;
270634
+ return {
270635
+ laserPenColor: newColor
270636
+ };
270637
+ }),
270638
+ // 形状设置
270639
+ shapeSize: 2,
270640
+ setShapeSize: (size) => set3((state) => {
270641
+ const newSize = typeof size === "function" ? size(state.shapeSize) : size;
270642
+ return {
270643
+ shapeSize: newSize
270644
+ };
270645
+ }),
270646
+ shapeType: "rect",
270647
+ setShapeType: (type4) => set3((state) => {
270648
+ const newType = typeof type4 === "function" ? type4(state.shapeType) : type4;
270649
+ return {
270650
+ shapeType: newType,
270651
+ shapeTypeRef: { current: newType }
270652
+ };
270653
+ }),
270654
+ shapeColor: "#ff5a5a",
270655
+ setShapeColor: (color) => set3((state) => {
270656
+ const newColor = typeof color === "function" ? color(state.shapeColor) : color;
270657
+ return {
270658
+ shapeColor: newColor
270659
+ };
270660
+ }),
270661
+ // 文字设置
270662
+ textSize: 16,
270663
+ setTextSize: (size) => set3((state) => {
270664
+ const newSize = typeof size === "function" ? size(state.textSize) : size;
270665
+ return {
270666
+ textSize: newSize
270667
+ };
270668
+ }),
270669
+ textColor: "#ff5a5a",
270670
+ setTextColor: (color) => set3((state) => {
270671
+ const newColor = typeof color === "function" ? color(state.textColor) : color;
270672
+ return {
270673
+ textColor: newColor
270674
+ };
270675
+ }),
270676
+ // 预览弹窗状态
270677
+ isPreviewModalVisible: false,
270678
+ setIsPreviewModalVisible: (visible) => set3({ isPreviewModalVisible: visible }),
270679
+ // 绘图相关引用
270680
+ downPoint: { current: null },
270681
+ upPoint: { current: null },
270682
+ currentShape: { current: null },
270683
+ getter: () => get4()
270684
+ }));
270685
270685
  const COLORS = ["#ff5a5a", "#ffbf48", "#3a9bff", "#58efb8", "#000000", "#808080", "#ffffff"];
270686
270686
  const LINE_SIZES = [2, 4, 6];
270687
270687
  const TEXT_SIZES = [16, 20, 24, 28, 32];
@@ -304994,22 +304994,55 @@ const PageIndicator = reactExports.memo(
304994
304994
  }
304995
304995
  );
304996
304996
  PageIndicator.displayName = "PageIndicator";
304997
+ const SDK_DEFAULT_CONFIG = {
304998
+ enabled: true,
304999
+ // SDK环境默认启用日志
305000
+ maxSize: 500,
305001
+ // SDK环境日志较少
305002
+ cleanupThreshold: 600,
305003
+ retainSize: 400,
305004
+ autoCleanupInterval: 3e4,
305005
+ // 30秒清理一次
305006
+ logToConsole: false,
305007
+ // SDK环境不输出到控制台
305008
+ levelFilter: "info"
305009
+ /* INFO */
305010
+ // SDK环境默认info级别
305011
+ };
304997
305012
  const DEFAULT_CONFIG = {
304998
305013
  enabled: false,
304999
305014
  // 开发环境默认启用
305000
305015
  maxSize: 1e3,
305016
+ // 最大缓存条目数量
305001
305017
  cleanupThreshold: 1200,
305018
+ // 触发清理的阈值
305002
305019
  retainSize: 800,
305020
+ // 清理后保留的条目数量
305003
305021
  autoCleanupInterval: 6e4,
305004
- // 60秒
305022
+ // 自动清理间隔时间(毫秒)
305005
305023
  logToConsole: true,
305024
+ // 是否输出日志到控制台
305006
305025
  levelFilter: "debug"
305007
305026
  /* DEBUG */
305027
+ // 日志级别过滤
305028
+ };
305029
+ const isSDKEnvironment = () => {
305030
+ if (typeof window === "undefined")
305031
+ return false;
305032
+ if (window.__CALL_SDK__ || window.__GUEST_SDK__) {
305033
+ return true;
305034
+ }
305035
+ const hasSDKConfig = Boolean(
305036
+ window.callConfig || window.guestConfig || document.querySelector("[data-sdk-embedded]")
305037
+ );
305038
+ return hasSDKConfig;
305008
305039
  };
305009
305040
  class LoggerManager {
305010
- constructor(config2 = {}) {
305041
+ constructor(config2 = {}, isSDK = false) {
305011
305042
  this.cleanupIntervalId = null;
305012
- this.config = { ...DEFAULT_CONFIG, ...config2 };
305043
+ this.isSDKMode = false;
305044
+ this.isSDKMode = isSDK;
305045
+ this.config = { ...isSDK ? SDK_DEFAULT_CONFIG : DEFAULT_CONFIG, ...config2 };
305013
305046
  this.initialize();
305014
305047
  }
305015
305048
  /**
@@ -305038,9 +305071,18 @@ class LoggerManager {
305038
305071
  * 执行日志清理
305039
305072
  */
305040
305073
  performCleanup() {
305041
- const cleaned = this.cleanupLogs(this.config.retainSize);
305042
- if (cleaned > 0 && this.config.logToConsole) {
305043
- console.log(`[Logger] 自动清理了 ${cleaned} 条旧日志,保留 ${this.config.retainSize} 条`);
305074
+ const logs = window.log;
305075
+ if (!logs || logs.length === 0)
305076
+ return;
305077
+ const originalLogs = logs.length;
305078
+ let cleanedCount = 0;
305079
+ if (logs.length > this.config.cleanupThreshold) {
305080
+ cleanedCount = this.cleanupLogs(this.config.retainSize);
305081
+ } else if (logs.length > this.config.maxSize) {
305082
+ cleanedCount = this.cleanupLogs(this.config.maxSize);
305083
+ }
305084
+ if (cleanedCount > 0 && this.config.logToConsole) {
305085
+ console.log(`[Logger] ${originalLogs} -> ${logs.length} 条 (清理 ${cleanedCount} 条)`);
305044
305086
  }
305045
305087
  }
305046
305088
  /**
@@ -305076,8 +305118,8 @@ class LoggerManager {
305076
305118
  return levelOrder[level] >= levelOrder[this.config.levelFilter];
305077
305119
  }
305078
305120
  /**
305079
- * 核心日志记录方法
305080
- */
305121
+ * 核心日志记录方法
305122
+ */
305081
305123
  logInternal(data2) {
305082
305124
  if (!this.shouldLog(
305083
305125
  data2.level || "info"
@@ -305093,13 +305135,7 @@ class LoggerManager {
305093
305135
  ...data2
305094
305136
  };
305095
305137
  window.log.push(logEntry);
305096
- if (window.log.length > this.config.cleanupThreshold) {
305097
- const beforeLength = window.log.length;
305098
- window.log = window.log.slice(-this.config.retainSize);
305099
- if (this.config.logToConsole) {
305100
- console.log(`[Logger] 清理日志: ${beforeLength} -> ${window.log.length}`);
305101
- }
305102
- }
305138
+ this.cleanupIfNeeded();
305103
305139
  if (this.config.logToConsole) {
305104
305140
  const prefix2 = `[${logEntry.component}] ${logEntry.event}`;
305105
305141
  const message2 = typeof logEntry.content === "string" ? logEntry.content : JSON.stringify(logEntry.content);
@@ -305119,6 +305155,20 @@ class LoggerManager {
305119
305155
  }
305120
305156
  }
305121
305157
  }
305158
+ /**
305159
+ * 检查并清理超出的日志(安全检查,确保内存安全)
305160
+ * 方案2优化:使用两级阈值检测
305161
+ */
305162
+ cleanupIfNeeded() {
305163
+ const logs = window.log;
305164
+ if (!logs || logs.length === 0)
305165
+ return;
305166
+ const safetyThreshold = this.config.maxSize * 1.5;
305167
+ if (logs.length > safetyThreshold) {
305168
+ console.warn(`[Logger] 内存安全警告:日志量(${logs.length})超过安全阈值(${safetyThreshold}),紧急清理`);
305169
+ this.cleanupLogs(this.config.maxSize);
305170
+ }
305171
+ }
305122
305172
  /**
305123
305173
  * 公共方法:记录调试日志
305124
305174
  */
@@ -305271,9 +305321,42 @@ class LoggerManager {
305271
305321
  clearInterval(this.cleanupIntervalId);
305272
305322
  this.cleanupIntervalId = null;
305273
305323
  }
305324
+ if (typeof window !== "undefined" && this.isSDKMode) {
305325
+ delete window.__CALL_SDK__;
305326
+ delete window.__GUEST_SDK__;
305327
+ }
305328
+ }
305329
+ /**
305330
+ * SDK专用:导出日志数据(用于诊断和调试)
305331
+ */
305332
+ exportLogs(count2 = 100) {
305333
+ if (!window.log)
305334
+ return [];
305335
+ const logs = window.log;
305336
+ return logs.slice(-count2).map((log2, index2) => ({
305337
+ ...log2,
305338
+ index: logs.length - count2 + index2
305339
+ }));
305340
+ }
305341
+ /**
305342
+ * SDK专用:获取SDK环境下的日志统计
305343
+ */
305344
+ getSDKStats() {
305345
+ if (!window.log)
305346
+ return { total: 0, errors: 0, warnings: 0 };
305347
+ const logs = window.log;
305348
+ const errors = logs.filter(
305349
+ (log2) => log2.level === "error" || log2.level === "critical"
305350
+ /* CRITICAL */
305351
+ ).length;
305352
+ const warnings = logs.filter(
305353
+ (log2) => log2.level === "warn"
305354
+ /* WARN */
305355
+ ).length;
305356
+ return { total: logs.length, errors, warnings };
305274
305357
  }
305275
305358
  }
305276
- const logger = new LoggerManager();
305359
+ const logger = new LoggerManager({}, isSDKEnvironment());
305277
305360
  const UserVideoContainer = reactExports.memo(({
305278
305361
  user,
305279
305362
  isSelected = false,
@@ -305281,16 +305364,6 @@ const UserVideoContainer = reactExports.memo(({
305281
305364
  className = "",
305282
305365
  videoId = ""
305283
305366
  }) => {
305284
- logger.info({
305285
- component: "UserVideoContainer",
305286
- event: "component_mounted",
305287
- content: "组件挂载",
305288
- extra: {
305289
- userId: user.rtc_userid,
305290
- videoId,
305291
- isSelected
305292
- }
305293
- });
305294
305367
  const {
305295
305368
  rtc,
305296
305369
  callConfig
@@ -305345,19 +305418,6 @@ const UserVideoContainer = reactExports.memo(({
305345
305418
  shouldMirror: +!noMirror
305346
305419
  });
305347
305420
  const isModeFit = user.rtc_userid === callConfig.drawing_board_id || (videoId == null ? void 0 : videoId.includes("screen")) || user.device === "pc" || videoId.includes("self");
305348
- logger.debug({
305349
- component: "UserVideoContainer",
305350
- event: "video_mode_calculated",
305351
- content: `isModeFit = ${isModeFit}`,
305352
- extra: {
305353
- userId: user.rtc_userid,
305354
- videoId,
305355
- isScreen: videoId == null ? void 0 : videoId.includes("screen"),
305356
- isSelf: videoId.includes("self"),
305357
- userDevice: user.device,
305358
- isDrawingBoard: user.rtc_userid === callConfig.drawing_board_id
305359
- }
305360
- });
305361
305421
  if (user.rtc_userid === callConfig.rtc_userid) {
305362
305422
  rtc.engine.setLocalVideoPlayer((videoId == null ? void 0 : videoId.includes("screen")) ? StreamIndex$1.STREAM_INDEX_SCREEN : StreamIndex$1.STREAM_INDEX_MAIN, {
305363
305423
  userId: user.rtc_userid,
@@ -306067,14 +306127,6 @@ const LiveWaitingRoom = ({
306067
306127
  const MobileLive = reactExports.memo(({
306068
306128
  className = ""
306069
306129
  }) => {
306070
- logger.info({
306071
- component: "MobileLive",
306072
- event: "component_mounted",
306073
- content: "进入MobileLive组件",
306074
- extra: {
306075
- userAgent: navigator.userAgent
306076
- }
306077
- });
306078
306130
  const {
306079
306131
  layoutMode,
306080
306132
  rtc,
@@ -306205,6 +306257,17 @@ const MobileLive = reactExports.memo(({
306205
306257
  window.callConfig = callConfig;
306206
306258
  window.rtc = rtc;
306207
306259
  }, [callUsers, callConfig, rtc]);
306260
+ reactExports.useEffect(() => {
306261
+ logger.info({
306262
+ component: "MobileLive",
306263
+ event: "component_mounted",
306264
+ content: "进入MobileLive组件",
306265
+ extra: {
306266
+ userAgent: navigator.userAgent,
306267
+ isMobile: isMobile$3
306268
+ }
306269
+ });
306270
+ }, []);
306208
306271
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ConfigProvider$1, {
306209
306272
  theme: {
306210
306273
  algorithm: theme.darkAlgorithm,
@@ -306345,6 +306408,7 @@ class CallLiveSdk {
306345
306408
  }
306346
306409
  });
306347
306410
  this.config = config2;
306411
+ this.initSDKLogger();
306348
306412
  useSdkStore.setState({
306349
306413
  callConfig: this.config
306350
306414
  });
@@ -306417,6 +306481,49 @@ class CallLiveSdk {
306417
306481
  this.root.unmount();
306418
306482
  this.root = null;
306419
306483
  }
306484
+ logger.info({
306485
+ component: "CallLiveSdk",
306486
+ event: "sdk_destroyed",
306487
+ content: "SDK已销毁并清理资源",
306488
+ extra: {
306489
+ liveId: this.config.liveId
306490
+ }
306491
+ });
306492
+ }
306493
+ /**
306494
+ * 初始化SDK日志系统
306495
+ */
306496
+ initSDKLogger() {
306497
+ window.__CALL_SDK__ = true;
306498
+ if (!window.log) {
306499
+ window.log = [];
306500
+ }
306501
+ logger.info({
306502
+ component: "CallLiveSdk",
306503
+ event: "sdk_initialized",
306504
+ content: "CallLiveSdk初始化完成",
306505
+ extra: {
306506
+ liveId: this.config.liveId,
306507
+ agentId: this.config.agentId,
306508
+ sdkVersion: "v1.0.0"
306509
+ // TODO: 从package.json获取
306510
+ }
306511
+ });
306512
+ window.addEventListener("error", (event) => {
306513
+ var _a2;
306514
+ logger.error({
306515
+ component: "SDK Error",
306516
+ event: "window_error",
306517
+ content: "捕获到window错误",
306518
+ extra: {
306519
+ message: event.message,
306520
+ filename: event.filename,
306521
+ lineno: event.lineno,
306522
+ colno: event.colno,
306523
+ error: (_a2 = event.error) == null ? void 0 : _a2.toString()
306524
+ }
306525
+ });
306526
+ });
306420
306527
  }
306421
306528
  }
306422
306529
  class GuestCallSdk {
@@ -306428,6 +306535,7 @@ class GuestCallSdk {
306428
306535
  }
306429
306536
  });
306430
306537
  this.config = config2;
306538
+ this.initSDKLogger();
306431
306539
  useSdkStore.setState({
306432
306540
  guestConfig: config2
306433
306541
  });
@@ -306468,6 +306576,66 @@ class GuestCallSdk {
306468
306576
  })
306469
306577
  }));
306470
306578
  }
306579
+ /**
306580
+ * 获取当前配置
306581
+ */
306582
+ getConfig() {
306583
+ return {
306584
+ ...this.config
306585
+ };
306586
+ }
306587
+ /**
306588
+ * 销毁SDK
306589
+ */
306590
+ destroy() {
306591
+ if (this.root) {
306592
+ this.root.unmount();
306593
+ this.root = null;
306594
+ }
306595
+ logger.info({
306596
+ component: "GuestCallSdk",
306597
+ event: "sdk_destroyed",
306598
+ content: "Guest SDK已销毁并清理资源",
306599
+ extra: {
306600
+ liveId: this.config.liveId
306601
+ }
306602
+ });
306603
+ }
306604
+ /**
306605
+ * 初始化SDK日志系统
306606
+ */
306607
+ initSDKLogger() {
306608
+ window.__GUEST_SDK__ = true;
306609
+ if (!window.log) {
306610
+ window.log = [];
306611
+ }
306612
+ logger.info({
306613
+ component: "GuestCallSdk",
306614
+ event: "sdk_initialized",
306615
+ content: "GuestCallSdk初始化完成",
306616
+ extra: {
306617
+ liveId: this.config.liveId,
306618
+ agentId: this.config.agentId,
306619
+ sdkVersion: "v1.0.0"
306620
+ // TODO: 从package.json获取
306621
+ }
306622
+ });
306623
+ window.addEventListener("error", (event) => {
306624
+ var _a2;
306625
+ logger.error({
306626
+ component: "SDK Error",
306627
+ event: "window_error",
306628
+ content: "捕获到window错误",
306629
+ extra: {
306630
+ message: event.message,
306631
+ filename: event.filename,
306632
+ lineno: event.lineno,
306633
+ colno: event.colno,
306634
+ error: (_a2 = event.error) == null ? void 0 : _a2.toString()
306635
+ }
306636
+ });
306637
+ });
306638
+ }
306471
306639
  }
306472
306640
  export {
306473
306641
  CallLiveSdk,