@ezuikit/player-theme 3.1.8-beta.1 → 3.1.8-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.
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- * @ezuikit/player-theme v3.1.8-beta.1
3
- * Copyright (c) 2026-09-29 20:25:53 Ezviz-OpenBiz
2
+ * @ezuikit/player-theme v3.1.8-beta.2
3
+ * Copyright (c) 2026-10-10 15:37:05 Ezviz-OpenBiz
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import EventEmitter from 'eventemitter3';
@@ -443,20 +443,22 @@ function _set_prototype_of$z(o, p) {
443
443
  /**
444
444
  * 销毁控件
445
445
  */ _proto.destroy = function destroy() {
446
- var _this___options, _this_$container_remove, _this_$container;
446
+ var _this___options, _this_$container, _this_$container_remove, _this_$container1;
447
447
  if (this._camelCaseName) {
448
448
  this.emit("Control." + this._camelCaseName + "Destroy");
449
449
  }
450
- if (((_this___options = this.__options) == null ? void 0 : _this___options.controlType) !== 'block') this.$container.removeEventListener('dblclick', this._onDBlClick);
450
+ // 用可选链与下面的 click 解绑保持一致:destroy() 之后 $container 会被置空,
451
+ // 重复 destroy(例如主题卸载控件后调用方又手动销毁一次)不应抛错
452
+ if (((_this___options = this.__options) == null ? void 0 : _this___options.controlType) !== 'block') (_this_$container = this.$container) == null ? void 0 : _this_$container.removeEventListener('dblclick', this._onDBlClick);
451
453
  // 移除 click 监听
452
454
  if (this._onClickHandler) {
453
- var _this_$container1;
454
- (_this_$container1 = this.$container) == null ? void 0 : _this_$container1.removeEventListener('click', this._onClickHandler);
455
+ var _this_$container2;
456
+ (_this_$container2 = this.$container) == null ? void 0 : _this_$container2.removeEventListener('click', this._onClickHandler);
455
457
  this._onClickHandler = null;
456
458
  }
457
459
  this._active = false;
458
460
  this.removeAllListeners();
459
- (_this_$container = this.$container) == null ? void 0 : (_this_$container_remove = _this_$container.remove) == null ? void 0 : _this_$container_remove.call(_this_$container);
461
+ (_this_$container1 = this.$container) == null ? void 0 : (_this_$container_remove = _this_$container1.remove) == null ? void 0 : _this_$container_remove.call(_this_$container1);
460
462
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
461
463
  this.$container = null;
462
464
  };
@@ -566,6 +568,45 @@ function _set_prototype_of$z(o, p) {
566
568
  * ```
567
569
  */ Control.supportedPlayTypes = [].concat(PLAY_TYPES);
568
570
 
571
+ /**
572
+ * HTML 转义
573
+ *
574
+ * 控件大量使用「模板字符串拼 HTML + innerHTML」的写法,只要拼进去的值来自
575
+ * 播放地址、接口返回或多语言配置,就存在注入风险。能改用 `textContent` /
576
+ * `createElement` 的地方应优先改用 DOM API;确实需要拼字符串时,所有外部
577
+ * 数据都必须先过这个函数。
578
+ *
579
+ * 同时覆盖两种语境:
580
+ * - 文本内容:`<span>${escapeHtml(v)}</span>`
581
+ * - 属性值:`<span title="${escapeHtml(v)}">`
582
+ *
583
+ * @remarks 用一次 `replace` 扫描完成,不存在「先转 `&` 再转其他」导致的二次转义。
584
+ */ /** 需要转义的字符与对应实体 */ var HTML_ESCAPE_MAP = {
585
+ '&': '&amp;',
586
+ '<': '&lt;',
587
+ '>': '&gt;',
588
+ '"': '&quot;',
589
+ "'": '&#39;'
590
+ };
591
+ /**
592
+ * 转义 HTML 中有特殊含义的字符
593
+ *
594
+ * @param value - 任意值,`null` / `undefined` 归一成空字符串
595
+ * @returns 可安全拼进 HTML 文本或双引号属性值的字符串
596
+ * @since 3.1.8
597
+ * @example
598
+ * ```ts
599
+ * escapeHtml('x" onerror="alert(1)'); // 'x&quot; onerror=&quot;alert(1)'
600
+ * escapeHtml('<img src=x>'); // '&lt;img src=x&gt;'
601
+ * escapeHtml(undefined); // ''
602
+ * ```
603
+ */ function escapeHtml(value) {
604
+ if (value === null || value === undefined) return '';
605
+ return String(value).replace(/[&<>"']/g, function(char) {
606
+ return HTML_ESCAPE_MAP[char];
607
+ });
608
+ }
609
+
569
610
  function _extends$y() {
570
611
  _extends$y = Object.assign || function assign(target) {
571
612
  for(var i = 1; i < arguments.length; i++){
@@ -621,11 +662,13 @@ var LOADING_DEFAULT_OPTIONS = {};
621
662
  this.$container.innerHTML = this._options.render();
622
663
  } else {
623
664
  var _this_locale;
624
- this.$container.innerHTML = '\n <span class="' + PREFIX_CLASS + "-loading-dot " + PREFIX_CLASS + '-loading-dot-load">\n <i class="' + PREFIX_CLASS + '-loading-dot-item"></i>\n <i class="' + PREFIX_CLASS + '-loading-dot-item"></i>\n <i class="' + PREFIX_CLASS + '-loading-dot-item"></i>\n <i class="' + PREFIX_CLASS + '-loading-dot-item"></i>\n </span>\n <div class="' + PREFIX_CLASS + '-loading-text">' + (((_this_locale = this.locale) == null ? void 0 : _this_locale.LOADING) || 'loading...') + "</div>\n ";
665
+ this.$container.innerHTML = '\n <span class="' + PREFIX_CLASS + "-loading-dot " + PREFIX_CLASS + '-loading-dot-load">\n <i class="' + PREFIX_CLASS + '-loading-dot-item"></i>\n <i class="' + PREFIX_CLASS + '-loading-dot-item"></i>\n <i class="' + PREFIX_CLASS + '-loading-dot-item"></i>\n <i class="' + PREFIX_CLASS + '-loading-dot-item"></i>\n </span>\n <div class="' + PREFIX_CLASS + '-loading-text">' + escapeHtml(((_this_locale = this.locale) == null ? void 0 : _this_locale.LOADING) || 'loading...') + "</div>\n ";
625
666
  }
626
667
  };
627
668
  /**
628
669
  * 动画展示
670
+ *
671
+ * @remarks `html` 会原样写入 `innerHTML`,**不做转义**,仅接受可信内容。
629
672
  * @param html 自定义动画内容, 如果不存在则使用默认动画
630
673
  */ _proto.show = function show(html) {
631
674
  if (html) this.$container.innerHTML = html;
@@ -714,16 +757,21 @@ var POSTER_OPTIONS = {
714
757
  * 设置封面 这里不对 poster 进行缓存,如果有值优先使用,如果没有值优先使用 初始化传入的值
715
758
  * @param {string} poster 封面地址或 base64 数据
716
759
  */ _proto.setPoster = function setPoster(poster) {
717
- var // eslint-disable-next-line @typescript-eslint/unbound-method
718
- // prettier-ignore
719
- _this_$container_querySelector;
720
760
  poster = poster != null ? poster : this._options.poster;
721
- if (poster === '') {
722
- this.$container.innerHTML = '';
761
+ // 空值一律清空。原先只判 `=== ''`,poster 为 undefined 时会渲染出
762
+ // `<img src="undefined">`,浏览器会去请求 ./undefined 再触发 error 回调
763
+ if (!poster) {
764
+ this.$container.replaceChildren();
723
765
  return;
724
766
  }
725
- this.$container.innerHTML = '<img class="' + PREFIX_CLASS + '-poster-img" src="' + poster + '" />';
726
- (_this_$container_querySelector = this.$container.querySelector("." + PREFIX_CLASS + "-poster-img")) == null ? void 0 : _this_$container_querySelector.addEventListener("error", this._imgLoadErrorEvent);
767
+ // 用 DOM API 而不是拼 innerHTML:封面地址可能来自远程模板接口或业务动态传入,
768
+ // 拼进 src="${poster}" 时 `x" onerror="...` 能闭合属性挂上事件处理器
769
+ var $img = document.createElement('img');
770
+ $img.className = "" + PREFIX_CLASS + "-poster-img";
771
+ $img.src = poster;
772
+ // eslint-disable-next-line @typescript-eslint/unbound-method
773
+ $img.addEventListener('error', this._imgLoadErrorEvent);
774
+ this.$container.replaceChildren($img);
727
775
  };
728
776
  /**
729
777
  * 展示封面 这里不对 poster 进行缓存, 如果有值优先使用, 如果没有值优先使用 初始化传入的值
@@ -817,7 +865,9 @@ var Icons = {
817
865
  var attrStr = '';
818
866
  if (attr) {
819
867
  Object.keys(attr).forEach(function(key) {
820
- if (!(attr[key] === undefined || attr[key] === null)) attrStr += key + '="' + attr[key] + '"';
868
+ // 属性值必须转义:所有控件的 title 都来自 options.locales,
869
+ // 不转义时 `x" onmouseover="alert(1)` 这样的文案可以闭合属性并挂上事件
870
+ if (!(attr[key] === undefined || attr[key] === null)) attrStr += key + '="' + escapeHtml(attr[key]) + '"';
821
871
  });
822
872
  }
823
873
  return '<span class="' + PREFIX_CLASS + "-icon " + PREFIX_CLASS + "-icon-" + type + '" ' + attrStr + ">" + svg + "</span>";
@@ -1072,7 +1122,8 @@ var MESSAGE_DEFAULT_OPTIONS = {};
1072
1122
  this._$toast = document.createElement('div');
1073
1123
  this._$toast.classList.add("" + PREFIX_CLASS + "-toast");
1074
1124
  }
1075
- this._$toast.innerHTML = '<div class="' + PREFIX_CLASS + '-toast-content">' + this._getIcon(type) + '<span class="' + PREFIX_CLASS + "-toast-msg " + PREFIX_CLASS + "-toast-" + type + '">' + (msg || '') + "</span></div>";
1125
+ // msg 是 EVENTS.message 的载荷,内核与接口的错误信息都走这个通道,必须转义
1126
+ this._$toast.innerHTML = '<div class="' + PREFIX_CLASS + '-toast-content">' + this._getIcon(type) + '<span class="' + PREFIX_CLASS + "-toast-msg " + PREFIX_CLASS + "-toast-" + type + '">' + escapeHtml(msg) + "</span></div>";
1076
1127
  this.options.rootContainer.appendChild(this._$toast);
1077
1128
  if (duration > 0) {
1078
1129
  this._toastTimer = setTimeout(function() {
@@ -1104,7 +1155,7 @@ var MESSAGE_DEFAULT_OPTIONS = {};
1104
1155
  //
1105
1156
  this.$container.innerHTML = this.options.render(msg, duration, type);
1106
1157
  } else {
1107
- this.$container.innerHTML = '<div class="' + PREFIX_CLASS + "-message-content " + PREFIX_CLASS + "-message-" + type + '">' + (msg || '') + "</div>";
1158
+ this.$container.innerHTML = '<div class="' + PREFIX_CLASS + "-message-content " + PREFIX_CLASS + "-message-" + type + '">' + escapeHtml(msg) + "</div>";
1108
1159
  }
1109
1160
  //
1110
1161
  this.$container.style.display = 'flex';
@@ -2011,9 +2062,9 @@ var VOLUME_DEFAULT_OPTIONS = {
2011
2062
  // 这里不要用 click 事件,因为拖动音量大小时鼠标移动到图标上会触发 click
2012
2063
  // prettier-ignore
2013
2064
  delegate(this.$container, "." + PREFIX_CLASS + "-control-volume", "mousedown", function() {
2014
- if (!_this.$container.classList.contains("" + PREFIX_CLASS + "-disabled")) {
2015
- _this._toggleMute();
2016
- }
2065
+ // 禁用判断交给 _toggleMute 里的 this.disabled(状态是权威来源,
2066
+ // class 只是它的呈现),避免两处各判一遍
2067
+ _this._toggleMute();
2017
2068
  });
2018
2069
  };
2019
2070
  _create_class$6(Volume, [
@@ -5385,11 +5436,14 @@ function _ts_generator$6(thisArg, body) {
5385
5436
  */ function getThemeDataByTemplate(theme, id) {
5386
5437
  return _async_to_generator$6(function() {
5387
5438
  var _theme_options_token_httpToken, _theme_options_token, // 中止上一个在途请求,并为本次请求创建可中止的信号(destroy 时会 abort)
5388
- _theme__templateAbortController, url, controller;
5439
+ _theme__templateAbortController, accessToken, url, controller;
5389
5440
  return _ts_generator$6(this, function(_state) {
5390
5441
  switch(_state.label){
5391
5442
  case 0:
5392
- url = theme.options.env.domain + "/api/service/media/template/getDetail?accessToken=" + (theme.options.accessToken || ((_theme_options_token = theme.options.token) == null ? void 0 : (_theme_options_token_httpToken = _theme_options_token.httpToken) == null ? void 0 : _theme_options_token_httpToken.url)) + "&id=" + id;
5443
+ accessToken = theme.options.accessToken || ((_theme_options_token = theme.options.token) == null ? void 0 : (_theme_options_token_httpToken = _theme_options_token.httpToken) == null ? void 0 : _theme_options_token_httpToken.url);
5444
+ // 查询参数逐个 encodeURIComponent,防止 `&` `#` `=` 等字符注入额外参数或截断 URL(SECURITY_AUDIT M1)
5445
+ // 不用 `new URL()`:env.domain 允许为空(同源相对路径)或带路径前缀,URL 构造会抛错或丢掉前缀
5446
+ url = theme.options.env.domain + "/api/service/media/template/getDetail?accessToken=" + encodeURIComponent(String(accessToken)) + "&id=" + encodeURIComponent(String(id));
5393
5447
  (_theme__templateAbortController = theme._templateAbortController) == null ? void 0 : _theme__templateAbortController.abort();
5394
5448
  controller = new AbortController();
5395
5449
  theme._templateAbortController = controller;
@@ -5717,7 +5771,9 @@ function _filterLeftRightControls(btnList) {
5717
5771
  ];
5718
5772
  // 渲染主题模板
5719
5773
  themeData = TEMPLATES[data];
5720
- if (!data) {
5774
+ // 修复:此前判的是 `!data`,而这个分支里 data 必然是非空字符串,告警永远不会发出,
5775
+ // 传了不存在的模板名只会静默返回 undefined。应当判查表结果。
5776
+ if (!themeData) {
5721
5777
  (_theme_logger = theme.logger) == null ? void 0 : _theme_logger.warn("Theme template " + data + " is not exist!");
5722
5778
  themeData = null;
5723
5779
  }
@@ -6408,7 +6464,9 @@ function _set_prototype_of$k(o, p) {
6408
6464
  this._ptzControl.updateOptions(options);
6409
6465
  }
6410
6466
  if (this._ptzControl1) {
6411
- this._ptzControl.updateOptions(options);
6467
+ // 修复:此前误写成 this._ptzControl,移动端扩展区域的云台拿不到新凭据,
6468
+ // 换 accessToken 或切设备后移动端云台会继续用旧值请求
6469
+ this._ptzControl1.updateOptions(options);
6412
6470
  }
6413
6471
  };
6414
6472
  _proto._onSpeedChange = function _onSpeedChange(speed) {
@@ -7630,7 +7688,13 @@ function _set_prototype_of$e(o, p) {
7630
7688
  controlType: 'button',
7631
7689
  classNameSuffix: 'rec-dropdown'
7632
7690
  })) || this;
7633
- _this._options = options;
7691
+ _this._options = Object.assign({
7692
+ list: [
7693
+ 'rec',
7694
+ 'cloudRec',
7695
+ 'cloudRecord'
7696
+ ]
7697
+ }, options || {});
7634
7698
  // H5 端不展示直播/回放切换按钮
7635
7699
  if (Utils.isMobile) {
7636
7700
  _this.$container.style.display = 'none';
@@ -7663,7 +7727,8 @@ function _set_prototype_of$e(o, p) {
7663
7727
  }
7664
7728
  };
7665
7729
  _proto._render = function _render() {
7666
- var _this_locale;
7730
+ var _this__options_list, _this_locale;
7731
+ if (((_this__options_list = this._options.list) == null ? void 0 : _this__options_list.length) === 0) ;
7667
7732
  this.$container.innerHTML = IconComponents.recDropdown({
7668
7733
  title: ((_this_locale = this.locale) == null ? void 0 : _this_locale.BTN_REC_DROPDOWN) || '回放'
7669
7734
  });
@@ -7686,8 +7751,8 @@ function _set_prototype_of$e(o, p) {
7686
7751
  // 打开时按控件在视口中的位置决定对齐方式。
7687
7752
  // 此时 picker 已把 $wrapperContent 设为 inline-flex(可测量宽度),
7688
7753
  // 而它内部的定位计算还在 requestAnimationFrame 里,改 placement 来得及生效。
7689
- // 移动端 placement 不生效(弹窗固定在窗口底部)
7690
- if (open && !Utils.isMobile) _this._adjustPlacement();
7754
+ // 移动端不适用的判断放在 _adjustPlacement 内部,避免两处各管一半
7755
+ if (open) _this._adjustPlacement();
7691
7756
  }
7692
7757
  });
7693
7758
  this._picker.innerHTML(this._getPanelHTML());
@@ -7733,7 +7798,7 @@ function _set_prototype_of$e(o, p) {
7733
7798
  var cloudRecLabel = ((_this_locale = this.locale) == null ? void 0 : _this_locale.REC_DROPDOWN_CLOUD_REC) || '云存储';
7734
7799
  var cloudRecordLabel = ((_this_locale1 = this.locale) == null ? void 0 : _this_locale1.REC_DROPDOWN_CLOUD_RECORD) || '云录制';
7735
7800
  var localRecLabel = ((_this_locale2 = this.locale) == null ? void 0 : _this_locale2.REC_DROPDOWN_LOCAL_REC) || '本地回放';
7736
- return '<div class="' + PREFIX_CLASS + '-rec-dropdown-panel">\n <ul class="' + PREFIX_CLASS + '-rec-dropdown-list">\n <li class="' + PREFIX_CLASS + '-rec-dropdown-item" data-type="cloudRec">\n <span>' + cloudRecLabel + '</span>\n </li>\n <li class="' + PREFIX_CLASS + '-rec-dropdown-item" data-type="cloudRecord">\n <span>' + cloudRecordLabel + '</span>\n </li>\n <li class="' + PREFIX_CLASS + '-rec-dropdown-item" data-type="rec">\n <span>' + localRecLabel + "</span>\n </li>\n </ul>\n </div>";
7801
+ return '<div class="' + PREFIX_CLASS + '-rec-dropdown-panel">\n <ul class="' + PREFIX_CLASS + '-rec-dropdown-list">\n ' + (this._options.list.includes('cloudRec') ? '<li class="' + PREFIX_CLASS + '-rec-dropdown-item" data-type="cloudRec">\n <span>' + cloudRecLabel + "</span>\n </li>" : '') + "\n " + (this._options.list.includes('cloudRecord') ? '<li class="' + PREFIX_CLASS + '-rec-dropdown-item" data-type="cloudRecord">\n <span>' + cloudRecordLabel + "</span>\n </li>" : '') + "\n " + (this._options.list.includes('rec') ? ' <li class="' + PREFIX_CLASS + '-rec-dropdown-item" data-type="rec">\n <span>' + localRecLabel + "</span>\n </li>" : '') + "\n </ul>\n </div>";
7737
7802
  };
7738
7803
  _proto._bindPanelEvents = function _bindPanelEvents() {
7739
7804
  var _this = this;
@@ -7754,6 +7819,9 @@ function _set_prototype_of$e(o, p) {
7754
7819
  };
7755
7820
  _proto._activeOption = function _activeOption(type) {
7756
7821
  var _this__picker;
7822
+ if (!this._options.list.includes(type)) {
7823
+ return;
7824
+ }
7757
7825
  if ((_this__picker = this._picker) == null ? void 0 : _this__picker.$body) {
7758
7826
  var items = this._picker.$body.querySelectorAll("." + PREFIX_CLASS + "-rec-dropdown-item");
7759
7827
  items.forEach(function(item) {
@@ -8078,8 +8146,9 @@ var SELECT_DEFAULT_OPTIONS = {
8078
8146
  label: 'label',
8079
8147
  value: 'value'
8080
8148
  },
8149
+ // label 可能来自内核下发的列表,内置实现必须转义
8081
8150
  renderLabel: function renderLabel(label) {
8082
- return "<span>" + (label || '') + "</span>";
8151
+ return "<span>" + escapeHtml(label) + "</span>";
8083
8152
  },
8084
8153
  onChange: function onChange() {},
8085
8154
  onOpenChange: function onOpenChange() {}
@@ -8194,9 +8263,11 @@ var SELECT_DEFAULT_OPTIONS = {
8194
8263
  var _this__options_fieldNames, _this__options_fieldNames1, _this_locale, _this__picker;
8195
8264
  var labelKey = (_ref = (_this__options_fieldNames = this._options.fieldNames) == null ? void 0 : _this__options_fieldNames.label) != null ? _ref : 'label';
8196
8265
  var valueKey = (_ref1 = (_this__options_fieldNames1 = this._options.fieldNames) == null ? void 0 : _this__options_fieldNames1.value) != null ? _ref1 : 'value';
8197
- (_this__picker = this._picker) == null ? void 0 : _this__picker.innerHTML('<div class="' + PREFIX_CLASS + '-select-panel">\n <ul class="' + PREFIX_CLASS + '-select-list">\n ' + list.map(function(item) {
8198
- return '\n <li class="' + PREFIX_CLASS + "-select-option " + (+item[valueKey] === _this.value ? "" + PREFIX_CLASS + "-active" : '') + '" data-value="' + item[valueKey] + '">\n <span>' + item[labelKey] + "</span>\n </li>\n ";
8199
- }).join('') + "\n </ul>\n " + (Utils.isMobile ? '<div class="' + PREFIX_CLASS + '-select-cancel">\n <span>' + (((_this_locale = this.locale) == null ? void 0 : _this_locale.cancel) || '取消') + "</span>\n </div>" : '') + "\n " + (Utils.isMobile ? '<span class="' + PREFIX_CLASS + '-select-close">' + IconComponents.close() + "</span>" : '') + "\n <div>");
8266
+ (_this__picker = this._picker) == null ? void 0 : _this__picker.innerHTML('<div class="' + PREFIX_CLASS + '-select-panel">\n <ul class="' + PREFIX_CLASS + '-select-list">\n ' + list.map(// 列表可能来自内核下发(如 setVideoLevelList 的清晰度列表),
8267
+ // data-value 与标签文本都要转义
8268
+ function(item) {
8269
+ return '\n <li class="' + PREFIX_CLASS + "-select-option " + (+item[valueKey] === _this.value ? "" + PREFIX_CLASS + "-active" : '') + '" data-value="' + escapeHtml(item[valueKey]) + '">\n <span>' + escapeHtml(item[labelKey]) + "</span>\n </li>\n ";
8270
+ }).join('') + "\n </ul>\n " + (Utils.isMobile ? '<div class="' + PREFIX_CLASS + '-select-cancel">\n <span>' + escapeHtml(((_this_locale = this.locale) == null ? void 0 : _this_locale.cancel) || '取消') + "</span>\n </div>" : '') + "\n " + (Utils.isMobile ? '<span class="' + PREFIX_CLASS + '-select-close">' + IconComponents.close() + "</span>" : '') + "\n <div>");
8200
8271
  this.list = list;
8201
8272
  this._activeOption();
8202
8273
  } else if ((list == null ? void 0 : list.length) === 0) {
@@ -8428,15 +8499,16 @@ function __filter(list, locale) {
8428
8499
  classNameSuffix: 'definition',
8429
8500
  renderLabel: function renderLabel(label, item, list) {
8430
8501
  var _list_;
8502
+ // 文案来自 options.locales,name / label 来自内核下发的清晰度列表,都要转义
8431
8503
  if ((item == null ? void 0 : item.level) === 'auto') {
8432
8504
  var _options_locales_options_language;
8433
8505
  var realItem = list.find(function(it) {
8434
8506
  return it.level === _assert_this_initialized$1(_this)._level;
8435
8507
  });
8436
- return "<span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((realItem == null ? void 0 : realItem.name) || '') + ")</span>";
8508
+ return "<span>" + escapeHtml(options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + escapeHtml((realItem == null ? void 0 : realItem.name) || '') + ")</span>";
8437
8509
  }
8438
8510
  // 如果 label 不存在,则不显示label,直接显示list的第一个label, 一般自定义清晰度列表可能会出现
8439
- return "<span>" + (label || ((_list_ = list[0]) == null ? void 0 : _list_.name) || '') + "</span>";
8511
+ return "<span>" + escapeHtml(label || ((_list_ = list[0]) == null ? void 0 : _list_.name) || '') + "</span>";
8440
8512
  },
8441
8513
  onChange: function onChange(value, item) {
8442
8514
  var _options_onChange;
@@ -8466,7 +8538,8 @@ function __filter(list, locale) {
8466
8538
  var realItem = _this.list.find(function(it) {
8467
8539
  return it.level === _this._level;
8468
8540
  });
8469
- _this.$container.querySelector("." + PREFIX_CLASS + "-select-btn").innerHTML = "\n <span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((realItem == null ? void 0 : realItem.name) || '') + ")</span>\n ";
8541
+ // 文案来自 options.locales,realItem.name 来自内核下发的清晰度列表,两者都要转义
8542
+ _this.$container.querySelector("." + PREFIX_CLASS + "-select-btn").innerHTML = "\n <span>" + escapeHtml(options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + escapeHtml((realItem == null ? void 0 : realItem.name) || '') + ")</span>\n ";
8470
8543
  } else {
8471
8544
  if (_this.value !== _this._level + '') _this.value = _this._level + '';
8472
8545
  }
@@ -8695,7 +8768,8 @@ function _set_prototype_of$8(o, p) {
8695
8768
  var isMobile1 = isMobile();
8696
8769
  if (isMobile1) {
8697
8770
  var _this_locale;
8698
- this.$container.innerHTML = '\n <span class="' + PREFIX_CLASS + '-mobile-date-filter" title="' + (((_this_locale = this.locale) == null ? void 0 : _this_locale.BTN_CALENDAR) || '') + '">\n <span class="' + PREFIX_CLASS + '-mobile-date-filter-value">' + this._getDateStr() + "</span>\n " + IconComponents.filter() + "\n <span>";
8771
+ // title 来自 options.locales,必须转义后再拼进属性
8772
+ this.$container.innerHTML = '\n <span class="' + PREFIX_CLASS + '-mobile-date-filter" title="' + escapeHtml(((_this_locale = this.locale) == null ? void 0 : _this_locale.BTN_CALENDAR) || '') + '">\n <span class="' + PREFIX_CLASS + '-mobile-date-filter-value">' + escapeHtml(this._getDateStr()) + "</span>\n " + IconComponents.filter() + "\n <span>";
8699
8773
  } else {
8700
8774
  var _this_locale1;
8701
8775
  this.$container.innerHTML = IconComponents.date({
@@ -8729,7 +8803,8 @@ function _set_prototype_of$8(o, p) {
8729
8803
  _this.options.onOk == null ? void 0 : _this.options.onOk.call(_this.options, date);
8730
8804
  _this.emit(EVENTS.control.dateChange, date);
8731
8805
  if (date && _this.$container.querySelector("." + PREFIX_CLASS + "-mobile-date-filter-value")) {
8732
- _this.$container.querySelector("." + PREFIX_CLASS + "-mobile-date-filter-value").innerHTML = _this._getDateStr();
8806
+ // 纯文本,用 textContent 避免把日期字符串交给 HTML 解析器
8807
+ _this.$container.querySelector("." + PREFIX_CLASS + "-mobile-date-filter-value").textContent = _this._getDateStr();
8733
8808
  }
8734
8809
  }
8735
8810
  },
@@ -8776,7 +8851,7 @@ function _set_prototype_of$8(o, p) {
8776
8851
  if (date && !change && this._value !== DateTime.format(date, 'YYYY-MM-DD')) {
8777
8852
  this._value = DateTime.format(date, 'YYYY-MM-DD');
8778
8853
  if (date && this.$container.querySelector("." + PREFIX_CLASS + "-mobile-date-filter-value")) {
8779
- this.$container.querySelector("." + PREFIX_CLASS + "-mobile-date-filter-value").innerHTML = this._getDateStr();
8854
+ this.$container.querySelector("." + PREFIX_CLASS + "-mobile-date-filter-value").textContent = this._getDateStr();
8780
8855
  }
8781
8856
  }
8782
8857
  };
@@ -8947,7 +9022,8 @@ function _set_prototype_of$7(o, p) {
8947
9022
  this._value = time;
8948
9023
  var valueEl = this.$container.querySelector("." + PREFIX_CLASS + "-mobile-date-filter-value");
8949
9024
  if (valueEl) {
8950
- valueEl.innerHTML = this._getTimeStr();
9025
+ // time 由调用方传入(setTime 是公开方法),只需纯文本,走 textContent
9026
+ valueEl.textContent = this._getTimeStr();
8951
9027
  }
8952
9028
  }
8953
9029
  };
@@ -9378,8 +9454,12 @@ function _set_prototype_of$5(o, p) {
9378
9454
  }
9379
9455
  this._progress.setCurrent(currentMs);
9380
9456
  };
9381
- /** 没有可用片段信息时退化为整个区间,避免进度条空转 */ _proto._fallbackToRange = function _fallbackToRange() {
9382
- if (!this._hasRange()) return;
9457
+ /**
9458
+ * 没有可用片段信息时退化为整个区间,避免进度条空转
9459
+ *
9460
+ * 两个调用方(`_syncCurrent` 开头、`_updateVisible` 的 `visible` 分支)都已经
9461
+ * 判过 `_hasRange()`,这里不再重复判断。
9462
+ */ _proto._fallbackToRange = function _fallbackToRange() {
9383
9463
  this._progress.setSegment(this._rangeBeginMs, this._rangeEndMs);
9384
9464
  };
9385
9465
  _proto._hasRange = function _hasRange() {
@@ -9453,7 +9533,12 @@ function _set_prototype_of$4(o, p) {
9453
9533
  var _proto = Device.prototype;
9454
9534
  _proto._render = function _render() {
9455
9535
  var _this___options_props_urlInfo, _this___options_props;
9456
- this.$container.innerHTML = '<span class="' + PREFIX_CLASS + "-text " + PREFIX_CLASS + '-text-device">' + this._splicingString(this.__options.deviceName, (_this___options_props = this.__options.props) == null ? void 0 : (_this___options_props_urlInfo = _this___options_props.urlInfo) == null ? void 0 : _this___options_props_urlInfo.deviceSerial) + "</span>";
9536
+ // deviceSerial 由播放地址解析而来(parseEzopenUrl 对它不做字符校验),
9537
+ // 这里只需要纯文本,用 textContent 从根上避免注入
9538
+ var $span = document.createElement('span');
9539
+ $span.className = PREFIX_CLASS + "-text " + PREFIX_CLASS + "-text-device";
9540
+ $span.textContent = this._splicingString(this.__options.deviceName, (_this___options_props = this.__options.props) == null ? void 0 : (_this___options_props_urlInfo = _this___options_props.urlInfo) == null ? void 0 : _this___options_props_urlInfo.deviceSerial);
9541
+ this.$container.replaceChildren($span);
9457
9542
  };
9458
9543
  /**
9459
9544
  * 更新设备序列号
@@ -9464,7 +9549,8 @@ function _set_prototype_of$4(o, p) {
9464
9549
  var $span = this.$container.querySelector("." + PREFIX_CLASS + "-text-device");
9465
9550
  var text = this._splicingString(deviceName, deviceSerial);
9466
9551
  $span == null ? void 0 : $span.setAttribute('title', text);
9467
- $span.innerHTML = text;
9552
+ // 设备信息来自 getDeviceInfo 事件(接口/内核数据),同样走 textContent
9553
+ $span.textContent = text;
9468
9554
  }
9469
9555
  };
9470
9556
  _proto._splicingString = function _splicingString(deviceName, deviceSerial) {
@@ -9860,7 +9946,11 @@ var _unmountedControls = function _unmountedControls(theme) {
9860
9946
  theme._footer.destroy();
9861
9947
  theme._footer = null;
9862
9948
  }
9949
+ // 移除 header / footer 动画暂停监听(挂在 theme 上,需显式解绑)
9950
+ // 修复:此前只置空引用没有解绑,changeTheme 每调用一次就漏一个监听器,
9951
+ // 且引用被清掉后 _renderTheme 里的兜底解绑也永远不会执行
9863
9952
  if (theme._onPauseTimingFunc) {
9953
+ theme.removeListener(CLEAR_TIMER_HEADER_FOOTER_ANIMATION, theme._onPauseTimingFunc);
9864
9954
  theme._onPauseTimingFunc = null;
9865
9955
  }
9866
9956
  // 移除首帧同步监听(挂在 theme 上,需显式解绑,避免 changeTheme 累积)
@@ -10274,10 +10364,8 @@ function _renderTheme(theme, data) {
10274
10364
  });
10275
10365
  // 当移动端 picker 控件打开时需要关闭动画(定时器)
10276
10366
  // 暂停 header footer 的动画(定时器)
10277
- if (theme._onPauseTimingFunc) {
10278
- theme.removeListener(CLEAR_TIMER_HEADER_FOOTER_ANIMATION, theme._onPauseTimingFunc);
10279
- theme._onPauseTimingFunc = null;
10280
- }
10367
+ // 旧监听的解绑统一在 _unmountedControls 里做(本函数开头已无条件调用过),
10368
+ // 这里不再重复判断
10281
10369
  theme._onPauseTimingFunc = function(open) {
10282
10370
  if (open) {
10283
10371
  var _theme__interactiveResult_clearTimeout, _theme__interactiveResult;
@@ -10671,6 +10759,17 @@ function _inherits(subClass, superClass) {
10671
10759
  });
10672
10760
  if (superClass) _set_prototype_of(subClass, superClass);
10673
10761
  }
10762
+ function _object_without_properties_loose(source, excluded) {
10763
+ if (source == null) return {};
10764
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
10765
+ for(i = 0; i < sourceKeys.length; i++){
10766
+ key = sourceKeys[i];
10767
+ if (excluded.indexOf(key) >= 0) continue;
10768
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
10769
+ target[key] = source[key];
10770
+ }
10771
+ return target;
10772
+ }
10674
10773
  function _set_prototype_of(o, p) {
10675
10774
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
10676
10775
  o.__proto__ = p;
@@ -11265,10 +11364,16 @@ var THEME_DEFAULT_OPTIONS = {
11265
11364
  // JSON 不能序列化dom节点, 不要使用 this.options.container, 请使用 this.container
11266
11365
  delete this.options.container;
11267
11366
  }
11367
+ // 凭据不进日志:这条 log 在生产产物里依然存在(strip 插件只剥离 console.*,
11368
+ // 不处理 logger 实例方法),直接打印 options 等于把 accessToken 暴露在控制台
11369
+ var _this_options = this.options; _this_options.accessToken; _this_options.token; var loggableOptions = _object_without_properties_loose(_this_options, [
11370
+ "accessToken",
11371
+ "token"
11372
+ ]);
11268
11373
  try {
11269
- this.logger.log('[options] \n', JSON.stringify(this.options));
11374
+ this.logger.log('[options] \n', JSON.stringify(loggableOptions));
11270
11375
  } catch (error) {
11271
- this.logger.log('[options] \n', this.options);
11376
+ this.logger.log('[options] \n', loggableOptions);
11272
11377
  }
11273
11378
  var language = this.options.language || 'zh';
11274
11379
  // 深拷贝内置语言包,避免与模块级 zh/en 常量共享引用(I18n 若对其做合并/修改会污染全局)
@@ -12341,6 +12446,6 @@ var THEME_DEFAULT_OPTIONS = {
12341
12446
  zh: zh,
12342
12447
  en: en
12343
12448
  };
12344
- /** 版本号 @since 0.0.1 */ Theme.THEME_VERSION = '3.1.8-beta.1';
12449
+ /** 版本号 @since 0.0.1 */ Theme.THEME_VERSION = '3.1.8-beta.2';
12345
12450
 
12346
12451
  export { CONTROL_INIT_EVENTS, Control, EVENTS, Fullscreen, Loading, Message, Play, Poster, Rec, Theme, Utils, Volume };