ckplayer-plus 1.1.10 → 1.1.11

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.cjs CHANGED
@@ -210,7 +210,7 @@ var require_ckplayer = __commonJS({
210
210
  cdnFallback: true
211
211
  // getPath 失败时是否回退到 jsDelivr(内网可设 false,并配置 pluginPath)
212
212
  };
213
- var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.1.10/dist/";
213
+ var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.1.11/dist/";
214
214
  function ckplayerEmbed(videoObj) {
215
215
  var rightMenu = [
216
216
  {
@@ -408,11 +408,6 @@ var require_ckplayer = __commonJS({
408
408
  } else {
409
409
  return embed(obj2);
410
410
  }
411
- }, isUnreliablePluginBase = function(base) {
412
- if (!base || valType(base) != "string") {
413
- return true;
414
- }
415
- return /\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base);
416
411
  }, resolveAssetPath = function(folder, file) {
417
412
  var base = "";
418
413
  if (vars && vars["pluginPath"]) {
@@ -429,13 +424,14 @@ var require_ckplayer = __commonJS({
429
424
  }
430
425
  return base + folder + "/" + file;
431
426
  }
432
- var fromScript = getPath(folder) + file;
433
- if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1 && !isUnreliablePluginBase(getPath())) {
427
+ var scriptBase = getPath();
428
+ var fromScript = scriptBase ? getPath(folder) + file : "";
429
+ if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1 && !isUnreliablePluginBase(scriptBase)) {
434
430
  return fromScript;
435
431
  }
436
432
  var allowCdn = !vars || vars["cdnFallback"] !== false;
437
433
  var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
438
- if (!allowCdn || !cdn || cdn.indexOf("1.1.10") > -1) {
434
+ if (!allowCdn || !cdn || cdn.indexOf("1.1.11") > -1) {
439
435
  return folder + "/" + file;
440
436
  }
441
437
  if (cdn.slice(-1) !== "/") {
@@ -6454,8 +6450,8 @@ var require_ckplayer = __commonJS({
6454
6450
  removeScript();
6455
6451
  if (!isRetry && (!vars || vars["cdnFallback"] !== false)) {
6456
6452
  var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
6457
- var m = String(file).match(/\/(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
6458
- if (cdn && cdn.indexOf("1.1.10") === -1 && m) {
6453
+ var m = String(file).match(/(?:^|\/)(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
6454
+ if (cdn && cdn.indexOf("1.1.11") === -1 && m) {
6459
6455
  if (cdn.slice(-1) !== "/") {
6460
6456
  cdn += "/";
6461
6457
  }
@@ -6695,13 +6691,26 @@ var require_ckplayer = __commonJS({
6695
6691
  }
6696
6692
  }
6697
6693
  }
6694
+ function isUnreliablePluginBase(base) {
6695
+ if (!base || typeof base !== "string") {
6696
+ return true;
6697
+ }
6698
+ var b = base.replace(/\\/g, "/");
6699
+ if (/\/(?:assets|\.vite\/deps|_next\/static|chunks?|static\/js|webpack|@fs|@id|@vite)\/?$/i.test(b)) {
6700
+ return true;
6701
+ }
6702
+ if (/\/(?:src|app|pages|views|components)\/?$/i.test(b)) {
6703
+ return true;
6704
+ }
6705
+ if (/^https?:\/\/[^/?#]+\/?$/i.test(b)) {
6706
+ return true;
6707
+ }
6708
+ return false;
6709
+ }
6698
6710
  function getPath(siz) {
6699
6711
  if (typeof window !== "undefined" && window.ckplayerBasePath) {
6700
6712
  var base = window.ckplayerBasePath;
6701
- if (/\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base)) {
6702
- base = "";
6703
- }
6704
- if (base) {
6713
+ if (!isUnreliablePluginBase(base)) {
6705
6714
  if (base.slice(-1) !== "/") {
6706
6715
  base += "/";
6707
6716
  }
@@ -6711,12 +6720,17 @@ var require_ckplayer = __commonJS({
6711
6720
  return base;
6712
6721
  }
6713
6722
  }
6714
- var scriptList = document.scripts || [], thisPath = scriptList.length ? scriptList[scriptList.length - 1].src : "";
6723
+ var scriptList = document.scripts || [];
6724
+ var thisPath = "";
6715
6725
  for (var i = 0; i < scriptList.length; i++) {
6716
6726
  var scriptName = scriptList[i].getAttribute("name") || scriptList[i].getAttribute("data-name");
6717
- var src = scriptList[i].src.slice(scriptList[i].src.lastIndexOf("/") + 1, scriptList[i].src.lastIndexOf("."));
6718
- if (scriptName && (scriptName == "ckplayer" || scriptName == "ckplayer.min" || scriptName == "ckplayer-plus") || scriptList[i].src && (src == "ckplayer" || src == "ckplayer.min" || src.indexOf("ckplayer") === 0)) {
6719
- thisPath = scriptList[i].src;
6727
+ var srcFull = scriptList[i].src || "";
6728
+ if (!srcFull) {
6729
+ continue;
6730
+ }
6731
+ var src = srcFull.slice(srcFull.lastIndexOf("/") + 1, srcFull.lastIndexOf("."));
6732
+ if (scriptName && (scriptName == "ckplayer" || scriptName == "ckplayer.min" || scriptName == "ckplayer-plus") || (src == "ckplayer" || src == "ckplayer.min" || src.indexOf("ckplayer") === 0)) {
6733
+ thisPath = srcFull;
6720
6734
  break;
6721
6735
  }
6722
6736
  }
@@ -6726,6 +6740,9 @@ var require_ckplayer = __commonJS({
6726
6740
  } else if (thisPath && thisPath.lastIndexOf("/") > -1) {
6727
6741
  path = thisPath.substring(0, thisPath.lastIndexOf("/") + 1);
6728
6742
  }
6743
+ if (!path || isUnreliablePluginBase(path)) {
6744
+ return "";
6745
+ }
6729
6746
  if (!isUndefined(siz)) {
6730
6747
  path += siz + "/";
6731
6748
  }
@@ -7228,13 +7245,21 @@ var import_meta = {};
7228
7245
  try {
7229
7246
  if (typeof window !== "undefined" && !window.ckplayerBasePath) {
7230
7247
  base = new URL("./", import_meta.url).href;
7231
- if (/\/dist\/$/i.test(base) || /\/ckplayer-plus(?:@[^/]+)?\/(?:dist\/)?$/i.test(base) || /\/node_modules\/ckplayer-plus\/(?:dist\/)?$/i.test(base)) {
7248
+ normalized = String(base).replace(/\\/g, "/");
7249
+ trusted = /\/dist\/$/i.test(normalized) || /\/ckplayer-plus(?:@[^/]+)?\/(?:dist\/)?$/i.test(normalized) || /\/node_modules\/ckplayer-plus\/(?:dist\/)?$/i.test(normalized);
7250
+ untrusted = /\/(?:assets|\.vite\/deps|_next\/static|chunks?|src|app|pages|views|components|@fs|@id|@vite)\/?$/i.test(
7251
+ normalized
7252
+ );
7253
+ if (trusted && !untrusted) {
7232
7254
  window.ckplayerBasePath = base;
7233
7255
  }
7234
7256
  }
7235
7257
  } catch (e) {
7236
7258
  }
7237
7259
  var base;
7260
+ var normalized;
7261
+ var trusted;
7262
+ var untrusted;
7238
7263
  function guessPlug(url) {
7239
7264
  if (!url || typeof url !== "string") return "";
7240
7265
  var path = url.split("?")[0].split("#")[0].toLowerCase();
package/dist/index.js CHANGED
@@ -204,7 +204,7 @@ var require_ckplayer = __commonJS({
204
204
  cdnFallback: true
205
205
  // getPath 失败时是否回退到 jsDelivr(内网可设 false,并配置 pluginPath)
206
206
  };
207
- var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.1.10/dist/";
207
+ var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.1.11/dist/";
208
208
  function ckplayerEmbed(videoObj) {
209
209
  var rightMenu = [
210
210
  {
@@ -402,11 +402,6 @@ var require_ckplayer = __commonJS({
402
402
  } else {
403
403
  return embed(obj2);
404
404
  }
405
- }, isUnreliablePluginBase = function(base) {
406
- if (!base || valType(base) != "string") {
407
- return true;
408
- }
409
- return /\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base);
410
405
  }, resolveAssetPath = function(folder, file) {
411
406
  var base = "";
412
407
  if (vars && vars["pluginPath"]) {
@@ -423,13 +418,14 @@ var require_ckplayer = __commonJS({
423
418
  }
424
419
  return base + folder + "/" + file;
425
420
  }
426
- var fromScript = getPath(folder) + file;
427
- if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1 && !isUnreliablePluginBase(getPath())) {
421
+ var scriptBase = getPath();
422
+ var fromScript = scriptBase ? getPath(folder) + file : "";
423
+ if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1 && !isUnreliablePluginBase(scriptBase)) {
428
424
  return fromScript;
429
425
  }
430
426
  var allowCdn = !vars || vars["cdnFallback"] !== false;
431
427
  var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
432
- if (!allowCdn || !cdn || cdn.indexOf("1.1.10") > -1) {
428
+ if (!allowCdn || !cdn || cdn.indexOf("1.1.11") > -1) {
433
429
  return folder + "/" + file;
434
430
  }
435
431
  if (cdn.slice(-1) !== "/") {
@@ -6448,8 +6444,8 @@ var require_ckplayer = __commonJS({
6448
6444
  removeScript();
6449
6445
  if (!isRetry && (!vars || vars["cdnFallback"] !== false)) {
6450
6446
  var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
6451
- var m = String(file).match(/\/(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
6452
- if (cdn && cdn.indexOf("1.1.10") === -1 && m) {
6447
+ var m = String(file).match(/(?:^|\/)(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
6448
+ if (cdn && cdn.indexOf("1.1.11") === -1 && m) {
6453
6449
  if (cdn.slice(-1) !== "/") {
6454
6450
  cdn += "/";
6455
6451
  }
@@ -6689,13 +6685,26 @@ var require_ckplayer = __commonJS({
6689
6685
  }
6690
6686
  }
6691
6687
  }
6688
+ function isUnreliablePluginBase(base) {
6689
+ if (!base || typeof base !== "string") {
6690
+ return true;
6691
+ }
6692
+ var b = base.replace(/\\/g, "/");
6693
+ if (/\/(?:assets|\.vite\/deps|_next\/static|chunks?|static\/js|webpack|@fs|@id|@vite)\/?$/i.test(b)) {
6694
+ return true;
6695
+ }
6696
+ if (/\/(?:src|app|pages|views|components)\/?$/i.test(b)) {
6697
+ return true;
6698
+ }
6699
+ if (/^https?:\/\/[^/?#]+\/?$/i.test(b)) {
6700
+ return true;
6701
+ }
6702
+ return false;
6703
+ }
6692
6704
  function getPath(siz) {
6693
6705
  if (typeof window !== "undefined" && window.ckplayerBasePath) {
6694
6706
  var base = window.ckplayerBasePath;
6695
- if (/\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base)) {
6696
- base = "";
6697
- }
6698
- if (base) {
6707
+ if (!isUnreliablePluginBase(base)) {
6699
6708
  if (base.slice(-1) !== "/") {
6700
6709
  base += "/";
6701
6710
  }
@@ -6705,12 +6714,17 @@ var require_ckplayer = __commonJS({
6705
6714
  return base;
6706
6715
  }
6707
6716
  }
6708
- var scriptList = document.scripts || [], thisPath = scriptList.length ? scriptList[scriptList.length - 1].src : "";
6717
+ var scriptList = document.scripts || [];
6718
+ var thisPath = "";
6709
6719
  for (var i = 0; i < scriptList.length; i++) {
6710
6720
  var scriptName = scriptList[i].getAttribute("name") || scriptList[i].getAttribute("data-name");
6711
- var src = scriptList[i].src.slice(scriptList[i].src.lastIndexOf("/") + 1, scriptList[i].src.lastIndexOf("."));
6712
- if (scriptName && (scriptName == "ckplayer" || scriptName == "ckplayer.min" || scriptName == "ckplayer-plus") || scriptList[i].src && (src == "ckplayer" || src == "ckplayer.min" || src.indexOf("ckplayer") === 0)) {
6713
- thisPath = scriptList[i].src;
6721
+ var srcFull = scriptList[i].src || "";
6722
+ if (!srcFull) {
6723
+ continue;
6724
+ }
6725
+ var src = srcFull.slice(srcFull.lastIndexOf("/") + 1, srcFull.lastIndexOf("."));
6726
+ if (scriptName && (scriptName == "ckplayer" || scriptName == "ckplayer.min" || scriptName == "ckplayer-plus") || (src == "ckplayer" || src == "ckplayer.min" || src.indexOf("ckplayer") === 0)) {
6727
+ thisPath = srcFull;
6714
6728
  break;
6715
6729
  }
6716
6730
  }
@@ -6720,6 +6734,9 @@ var require_ckplayer = __commonJS({
6720
6734
  } else if (thisPath && thisPath.lastIndexOf("/") > -1) {
6721
6735
  path = thisPath.substring(0, thisPath.lastIndexOf("/") + 1);
6722
6736
  }
6737
+ if (!path || isUnreliablePluginBase(path)) {
6738
+ return "";
6739
+ }
6723
6740
  if (!isUndefined(siz)) {
6724
6741
  path += siz + "/";
6725
6742
  }
@@ -7215,13 +7232,21 @@ var import_meta = {};
7215
7232
  try {
7216
7233
  if (typeof window !== "undefined" && !window.ckplayerBasePath) {
7217
7234
  base = new URL("./", import_meta.url).href;
7218
- if (/\/dist\/$/i.test(base) || /\/ckplayer-plus(?:@[^/]+)?\/(?:dist\/)?$/i.test(base) || /\/node_modules\/ckplayer-plus\/(?:dist\/)?$/i.test(base)) {
7235
+ normalized = String(base).replace(/\\/g, "/");
7236
+ trusted = /\/dist\/$/i.test(normalized) || /\/ckplayer-plus(?:@[^/]+)?\/(?:dist\/)?$/i.test(normalized) || /\/node_modules\/ckplayer-plus\/(?:dist\/)?$/i.test(normalized);
7237
+ untrusted = /\/(?:assets|\.vite\/deps|_next\/static|chunks?|src|app|pages|views|components|@fs|@id|@vite)\/?$/i.test(
7238
+ normalized
7239
+ );
7240
+ if (trusted && !untrusted) {
7219
7241
  window.ckplayerBasePath = base;
7220
7242
  }
7221
7243
  }
7222
7244
  } catch (e) {
7223
7245
  }
7224
7246
  var base;
7247
+ var normalized;
7248
+ var trusted;
7249
+ var untrusted;
7225
7250
  function guessPlug(url) {
7226
7251
  if (!url || typeof url !== "string") return "";
7227
7252
  var path = url.split("?")[0].split("#")[0].toLowerCase();