@dan-uni/dan-any 1.2.2 → 1.2.7

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.
Files changed (50) hide show
  1. package/README.md +1 -0
  2. package/dist/browser/17.min.js +28 -18
  3. package/dist/browser/705.min.js +77 -0
  4. package/dist/browser/index.min.js +1 -1
  5. package/dist/browser/plugins/bili.min.js +1 -0
  6. package/dist/browser/plugins/index.min.js +1 -1
  7. package/dist/browser/src/index.d.ts +13 -5
  8. package/dist/browser/src/plugins/bili/history-danmaku-fast-forward.d.ts +18 -0
  9. package/dist/browser/src/plugins/bili/index.d.ts +2 -0
  10. package/dist/browser/src/plugins/index.d.ts +1 -1
  11. package/dist/node/17.js +28 -18
  12. package/dist/node/705.js +77 -0
  13. package/dist/node/index.js +1 -1
  14. package/dist/node/plugins/bili.js +1 -0
  15. package/dist/node/plugins/index.js +1 -1
  16. package/dist/node/src/index.d.ts +13 -5
  17. package/dist/node/src/plugins/bili/history-danmaku-fast-forward.d.ts +18 -0
  18. package/dist/node/src/plugins/bili/index.d.ts +2 -0
  19. package/dist/node/src/plugins/index.d.ts +1 -1
  20. package/dist/umd/index.umd.min.js +44 -24
  21. package/dist/umd/plugins/{bili-dedupe.umd.min.js → bili.umd.min.js} +4644 -29
  22. package/dist/umd/plugins/index.umd.min.js +4646 -31
  23. package/dist/umd/src/index.d.ts +13 -5
  24. package/dist/umd/src/plugins/bili/history-danmaku-fast-forward.d.ts +18 -0
  25. package/dist/umd/src/plugins/bili/index.d.ts +2 -0
  26. package/dist/umd/src/plugins/index.d.ts +1 -1
  27. package/package.json +5 -3
  28. package/rslib.config.ts +1 -1
  29. package/src/index.ts +26 -32
  30. package/src/plugins/bili/README.md +87 -0
  31. package/src/plugins/bili/history-danmaku-fast-forward.ts +86 -0
  32. package/src/plugins/bili/index.test.ts +129 -0
  33. package/src/plugins/bili/index.ts +2 -0
  34. package/src/plugins/index.ts +1 -1
  35. package/src/plugins/stats/README.md +44 -0
  36. package/src/plugins/stats/index.test.ts +1 -1
  37. package/src/utils/dm-gen.ts +2 -2
  38. package/dist/browser/157.min.js +0 -30
  39. package/dist/browser/plugins/bili-dedupe.min.js +0 -1
  40. package/dist/node/157.js +0 -30
  41. package/dist/node/plugins/bili-dedupe.js +0 -1
  42. package/src/plugins/bili-dedupe/index.test.ts +0 -43
  43. /package/dist/browser/src/plugins/{bili-dedupe/index.d.ts → bili/dedupe.d.ts} +0 -0
  44. /package/dist/browser/src/plugins/{bili-dedupe → bili}/index.test.d.ts +0 -0
  45. /package/dist/node/src/plugins/{bili-dedupe/index.d.ts → bili/dedupe.d.ts} +0 -0
  46. /package/dist/node/src/plugins/{bili-dedupe → bili}/index.test.d.ts +0 -0
  47. /package/dist/umd/plugins/{bili-dedupe.umd.min.js.LICENSE.txt → bili.umd.min.js.LICENSE.txt} +0 -0
  48. /package/dist/umd/src/plugins/{bili-dedupe/index.d.ts → bili/dedupe.d.ts} +0 -0
  49. /package/dist/umd/src/plugins/{bili-dedupe → bili}/index.test.d.ts +0 -0
  50. /package/src/plugins/{bili-dedupe/index.ts → bili/dedupe.ts} +0 -0
@@ -14266,6 +14266,7 @@ and limitations under the License.
14266
14266
  UniDM: ()=>UniDM,
14267
14267
  UniDMTools: ()=>dm_gen_namespaceObject,
14268
14268
  UniPool: ()=>UniPool,
14269
+ DM_format: ()=>src_DM_format,
14269
14270
  UniIDTools: ()=>id_gen_namespaceObject
14270
14271
  });
14271
14272
  var id_gen_namespaceObject = {};
@@ -14754,10 +14755,13 @@ and limitations under the License.
14754
14755
  i += 7;
14755
14756
  let entityName, val;
14756
14757
  [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
14757
- if (-1 === val.indexOf("&")) entities[entityName] = {
14758
- regx: RegExp(`&${entityName};`, "g"),
14759
- val: val
14760
- };
14758
+ if (-1 === val.indexOf("&")) {
14759
+ const escaped = entityName.replace(/[.\-+*:]/g, '\\.');
14760
+ entities[entityName] = {
14761
+ regx: RegExp(`&${escaped};`, "g"),
14762
+ val: val
14763
+ };
14764
+ }
14761
14765
  } else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
14762
14766
  i += 8;
14763
14767
  const { index } = this.readElementExp(xmlData, i + 1);
@@ -15107,11 +15111,11 @@ and limitations under the License.
15107
15111
  },
15108
15112
  num_dec: {
15109
15113
  regex: /&#([0-9]{1,7});/g,
15110
- val: (_, str)=>String.fromCodePoint(Number.parseInt(str, 10))
15114
+ val: (_, str)=>fromCodePoint(str, 10, "&#")
15111
15115
  },
15112
15116
  num_hex: {
15113
15117
  regex: /&#x([0-9a-fA-F]{1,6});/g,
15114
- val: (_, str)=>String.fromCodePoint(Number.parseInt(str, 16))
15118
+ val: (_, str)=>fromCodePoint(str, 16, "&#x")
15115
15119
  }
15116
15120
  };
15117
15121
  this.addExternalEntities = addExternalEntities;
@@ -15140,8 +15144,9 @@ and limitations under the License.
15140
15144
  const entKeys = Object.keys(externalEntities);
15141
15145
  for(let i = 0; i < entKeys.length; i++){
15142
15146
  const ent = entKeys[i];
15147
+ const escaped = ent.replace(/[.\-+*:]/g, '\\.');
15143
15148
  this.lastEntities[ent] = {
15144
- regex: new RegExp("&" + ent + ";", "g"),
15149
+ regex: new RegExp("&" + escaped + ";", "g"),
15145
15150
  val: externalEntities[ent]
15146
15151
  };
15147
15152
  }
@@ -15487,6 +15492,11 @@ and limitations under the License.
15487
15492
  if (isExist(val)) return val;
15488
15493
  return '';
15489
15494
  }
15495
+ function fromCodePoint(str, base, prefix) {
15496
+ const codePoint = Number.parseInt(str, base);
15497
+ if (codePoint >= 0 && codePoint <= 0x10FFFF) return String.fromCodePoint(codePoint);
15498
+ return prefix + str + ";";
15499
+ }
15490
15500
  const node2json_METADATA_SYMBOL = XmlNode.getMetaDataSymbol();
15491
15501
  function prettify(node, options) {
15492
15502
  return node2json_compress(node, options);
@@ -21043,7 +21053,7 @@ and limitations under the License.
21043
21053
  function timestamp_timestampMs(timestamp) {
21044
21054
  return 1000 * Number(timestamp.seconds) + Math.round(timestamp.nanos / 1000000);
21045
21055
  }
21046
- var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.2","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
21056
+ var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.7","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
21047
21057
  const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
21048
21058
  const decimalToHex = (n)=>color_pad(n.toString(16));
21049
21059
  const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
@@ -23528,7 +23538,7 @@ and limitations under the License.
23528
23538
  if (this.attr.length > 0) result.attr = this.attr;
23529
23539
  if (void 0 !== this.platform) result.platform = this.platform;
23530
23540
  if (this.extraStr && '{}' !== this.extraStr) result.extraStr = this.extraStr;
23531
- if (void 0 !== this.DMID) result.DMID = this.DMID;
23541
+ if (void 0 !== this.DMID && this.options.dmid) result.DMID = this.DMID;
23532
23542
  return result;
23533
23543
  }
23534
23544
  downgradeAdvcancedDan({ include, exclude, cleanExtra = false } = {}) {
@@ -23644,7 +23654,7 @@ and limitations under the License.
23644
23654
  }) ? args.midHash : id_gen_UniID.fromBili({
23645
23655
  midHash: args.midHash
23646
23656
  });
23647
- let mode = 0;
23657
+ let mode;
23648
23658
  const pool = args.pool;
23649
23659
  const extra = {
23650
23660
  bili: {
@@ -24482,6 +24492,19 @@ and limitations under the License.
24482
24492
  meassage: 'Converted by DanUni!',
24483
24493
  version: `JS/TS ${package_namespaceObject.UU} (v${package_namespaceObject.rE})`
24484
24494
  };
24495
+ var src_DM_format = /*#__PURE__*/ function(DM_format) {
24496
+ DM_format["DanuniJson"] = "danuni.json";
24497
+ DM_format["DanuniPbBin"] = "danuni.pb.bin";
24498
+ DM_format["BiliXml"] = "bili.xml";
24499
+ DM_format["BiliPbBin"] = "bili.pb.bin";
24500
+ DM_format["BiliCmdPbBin"] = "bili.cmd.pb.bin";
24501
+ DM_format["BiliUpJson"] = "bili.up.json";
24502
+ DM_format["DplayerJson"] = "dplayer.json";
24503
+ DM_format["ArtplayerJson"] = "artplayer.json";
24504
+ DM_format["DdplayJson"] = "ddplay.json";
24505
+ DM_format["CommonAss"] = "common.ass";
24506
+ return DM_format;
24507
+ }({});
24485
24508
  class UniPool {
24486
24509
  constructor(dans, options = {}, info = {
24487
24510
  fromConverted: false
@@ -24492,10 +24515,7 @@ and limitations under the License.
24492
24515
  if (false !== options.dedupe) options.dedupe = true;
24493
24516
  if (this.options.dedupe) this.dedupe();
24494
24517
  }
24495
- async pipe(fn) {
24496
- return fn(this);
24497
- }
24498
- pipeSync(fn) {
24518
+ pipe(fn) {
24499
24519
  return fn(this);
24500
24520
  }
24501
24521
  get shared() {
@@ -24707,23 +24727,23 @@ and limitations under the License.
24707
24727
  try {
24708
24728
  if (Array.isArray(json) && json.every((d)=>d.SOID)) return {
24709
24729
  pool: new UniPool(json, options),
24710
- fmt: 'danuni.json'
24730
+ fmt: "danuni.json"
24711
24731
  };
24712
24732
  if (json.danmuku && json.danmuku.every((d)=>d.text)) return {
24713
24733
  pool: this.fromArtplayer(json, json.danuni?.data ?? '', void 0, options),
24714
- fmt: 'artplayer.json'
24734
+ fmt: "artplayer.json"
24715
24735
  };
24716
24736
  if (json.count && json.comments && Array.isArray(json.comments) && json.comments.every((d)=>d.m)) return {
24717
24737
  pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
24718
- fmt: 'ddplay.json'
24738
+ fmt: "ddplay.json"
24719
24739
  };
24720
24740
  else if (0 == json.code && json.data && Array.isArray(json.data) && json.data.every((d)=>Array.isArray(d))) return {
24721
24741
  pool: this.fromDplayer(json, json.danuni?.data ?? '', void 0, options),
24722
- fmt: 'dplayer.json'
24742
+ fmt: "dplayer.json"
24723
24743
  };
24724
24744
  else if (0 == json.code && '0' == json.message && json.data && json.data.page && json.data.result && Array.isArray(json.data.result) && json.data.result.every((d)=>d.id && d.oid)) return {
24725
24745
  pool: this.fromBiliUp(json, options),
24726
- fmt: 'bili.up.json'
24746
+ fmt: "bili.up.json"
24727
24747
  };
24728
24748
  } catch {}
24729
24749
  };
@@ -24742,13 +24762,13 @@ and limitations under the License.
24742
24762
  const xml = xmlParser.parse(file);
24743
24763
  if (xml?.i?.d) return {
24744
24764
  pool: this.fromBiliXML(file, options),
24745
- fmt: 'bili.xml'
24765
+ fmt: "bili.xml"
24746
24766
  };
24747
24767
  } catch {}
24748
24768
  try {
24749
24769
  return {
24750
24770
  pool: this.fromASS(file, options),
24751
- fmt: 'common.ass'
24771
+ fmt: "common.ass"
24752
24772
  };
24753
24773
  } catch {}
24754
24774
  }
@@ -24760,19 +24780,19 @@ and limitations under the License.
24760
24780
  try {
24761
24781
  return {
24762
24782
  pool: this.fromPb(file),
24763
- fmt: 'danuni.pb.bin'
24783
+ fmt: "danuni.pb.bin"
24764
24784
  };
24765
24785
  } catch {}
24766
24786
  try {
24767
24787
  return {
24768
24788
  pool: this.fromBiliGrpc(file),
24769
- fmt: 'bili.pb.bin'
24789
+ fmt: "bili.pb.bin"
24770
24790
  };
24771
24791
  } catch {}
24772
24792
  try {
24773
24793
  return {
24774
24794
  pool: this.fromBiliCommandGrpc(file),
24775
- fmt: 'bili.cmd.pb.bin'
24795
+ fmt: "bili.cmd.pb.bin"
24776
24796
  };
24777
24797
  } catch {}
24778
24798
  }