@dan-uni/dan-any 1.3.6 → 1.3.8

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/README.md CHANGED
@@ -31,6 +31,15 @@
31
31
  - [dan-any-plugin-detaolu](https://github.com/ani-uni/danuni/tree/master/packages/dan-any-plugin-detaolu): 基于pakku.js的弹幕过滤器
32
32
  - `src/plugins`下的插件 `bili`(B站弹幕相关) `stats`(统计相关),内部附有使用文档
33
33
 
34
+ ## 转换提示
35
+
36
+ 使用该库可以不失去任何关键信息地导入常见格式的弹幕,并已附加字段的形式保留部分弹幕格式专有的信息;但将弹幕转换为第三方格式时,由于其设计上无法封装附加信息,会导致不可避免的信息损失。
37
+ 如果需要以最为可靠的方式传送弹幕,请尽量使用 `danuni.json` / `danuni.binpb` 进行导出分发。
38
+
39
+ 由于设计上想尽可能多地保留原始信息,将弹幕转换为第三方格式的弹幕时,可能在非常用字段上与官方格式不完全相同,若有极强的兼容性需求,请手动开启对应转换函数的兼容性选项。
40
+
41
+ *致开发者: 若导入后检测到 `UniPool.info.fromConverted` 为true ,建议提示用户不要再对该弹幕文件再次进行转换,否则可能导致解析错误*
42
+
34
43
  ## 特殊字段提示
35
44
 
36
45
  ### ASS Raw 字段
@@ -11461,7 +11461,7 @@ __webpack_require__.d(platform_namespaceObject, {
11461
11461
  PlatformVideoSource: ()=>platform_PlatformVideoSource,
11462
11462
  PlatformVideoSources: ()=>PlatformVideoSources
11463
11463
  });
11464
- var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.6","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
11464
+ var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.8","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
11465
11465
  const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
11466
11466
  const decimalToHex = (n)=>color_pad(n.toString(16));
11467
11467
  const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
@@ -12976,9 +12976,6 @@ class UniPool {
12976
12976
  }
12977
12977
  return new UniPool(result, this.options, this.info);
12978
12978
  }
12979
- minify() {
12980
- return this.dans.map((d)=>d.minify());
12981
- }
12982
12979
  static import(file, options, mod) {
12983
12980
  const handlers = {
12984
12981
  ["danuni.json"]: (json)=>({
@@ -13187,6 +13184,9 @@ class UniPool {
13187
13184
  }
13188
13185
  }
13189
13186
  }
13187
+ minify() {
13188
+ return this.dans.map((d)=>d.minify());
13189
+ }
13190
13190
  static fromMin(json, options) {
13191
13191
  return new UniPool(json.map((d)=>UniDM.create(d, options)));
13192
13192
  }
@@ -13240,12 +13240,15 @@ class UniPool {
13240
13240
  }
13241
13241
  toBiliXML(options) {
13242
13242
  const genCID = (id)=>{
13243
- const UniID = id_gen_UniID.fromString(id);
13244
- if (UniID.domain === platform_PlatformVideoSource.Bilibili) {
13245
- const cid = UniID.id.replaceAll(`def_${platform_PlatformVideoSource.Bilibili}+`, '');
13246
- if (cid) return cid;
13243
+ if (!id) return options?.cid || id_gen_UniID.fromNull().toString();
13244
+ {
13245
+ const UniID = id_gen_UniID.fromString(id);
13246
+ if (UniID.domain === platform_PlatformVideoSource.Bilibili) {
13247
+ const cid = UniID.id.replaceAll(`def_${platform_PlatformVideoSource.Bilibili}+`, '');
13248
+ if (cid) return cid;
13249
+ }
13250
+ return options?.cid || id;
13247
13251
  }
13248
- return !options?.cid || id;
13249
13252
  };
13250
13253
  if (options?.avoidSenderIDWithAt) {
13251
13254
  const ok = this.dans.every((d)=>d.senderID.endsWith(`@${platform_PlatformVideoSource.Bilibili}`));
@@ -13261,7 +13264,7 @@ class UniPool {
13261
13264
  },
13262
13265
  i: {
13263
13266
  chatserver: 'chat.bilibili.com',
13264
- chatid: genCID(this.dans[0].SOID),
13267
+ chatid: genCID(this.dans[0]?.SOID),
13265
13268
  mission: 0,
13266
13269
  maxlimit: this.dans.length,
13267
13270
  state: 0,
@@ -13323,7 +13326,7 @@ class UniPool {
13323
13326
  code: 0,
13324
13327
  danuni: {
13325
13328
  ...DanUniConvertTipTemplate,
13326
- data: this.dans[0].SOID.split('@')[0]
13329
+ data: this.dans[0]?.SOID.split('@')[0]
13327
13330
  },
13328
13331
  data: this.dans.map((dan)=>{
13329
13332
  const d = dan.toDplayer();
@@ -13352,7 +13355,7 @@ class UniPool {
13352
13355
  return {
13353
13356
  danuni: {
13354
13357
  ...DanUniConvertTipTemplate,
13355
- data: this.dans[0].SOID.split('@')[0]
13358
+ data: this.dans[0]?.SOID.split('@')[0]
13356
13359
  },
13357
13360
  danmuku: this.dans.map((dan)=>{
13358
13361
  const d = dan.toArtplayer();
@@ -13383,7 +13386,7 @@ class UniPool {
13383
13386
  });
13384
13387
  }
13385
13388
  toDDPlay() {
13386
- const episodeId = this.dans[0].SOID.split('@')[0].replaceAll(`def_${platform_PlatformDanmakuOnlySource.DanDanPlay}+`, '');
13389
+ const episodeId = this.dans[0]?.SOID.split('@')[0].replaceAll(`def_${platform_PlatformDanmakuOnlySource.DanDanPlay}+`, '');
13387
13390
  return {
13388
13391
  danuni: {
13389
13392
  ...DanUniConvertTipTemplate,
@@ -214,7 +214,6 @@ export declare class UniPool {
214
214
  * @param lifetime 查重时间区段,单位秒 (默认为 0,表示不查重)
215
215
  */
216
216
  merge(lifetime?: number): UniPool;
217
- minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
218
217
  static import(file: unknown, options?: Options,
219
218
  /**
220
219
  * 加载指定解析模块,为空则全选,为字符串则视为文件名解析加载模块
@@ -225,6 +224,7 @@ export declare class UniPool {
225
224
  };
226
225
  convert2(format: DM_format, file_wrapper: true, continue_on_error?: boolean): File;
227
226
  convert2<T extends Convert2Format>(format: T, file_wrapper?: false, continue_on_error?: boolean): Convert2ResultMap[T];
227
+ minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
228
228
  static fromMin(json: DM_JSON_DanuniMin, options?: Options): UniPool;
229
229
  static fromPb(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
230
230
  /**
@@ -39,7 +39,7 @@ __webpack_require__.d(platform_namespaceObject, {
39
39
  PlatformVideoSource: ()=>platform_PlatformVideoSource,
40
40
  PlatformVideoSources: ()=>PlatformVideoSources
41
41
  });
42
- var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.6","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
42
+ var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.8","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
43
43
  const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
44
44
  const decimalToHex = (n)=>color_pad(n.toString(16));
45
45
  const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
@@ -1551,9 +1551,6 @@ class UniPool {
1551
1551
  }
1552
1552
  return new UniPool(result, this.options, this.info);
1553
1553
  }
1554
- minify() {
1555
- return this.dans.map((d)=>d.minify());
1556
- }
1557
1554
  static import(file, options, mod) {
1558
1555
  const handlers = {
1559
1556
  ["danuni.json"]: (json)=>({
@@ -1762,6 +1759,9 @@ class UniPool {
1762
1759
  }
1763
1760
  }
1764
1761
  }
1762
+ minify() {
1763
+ return this.dans.map((d)=>d.minify());
1764
+ }
1765
1765
  static fromMin(json, options) {
1766
1766
  return new UniPool(json.map((d)=>UniDM.create(d, options)));
1767
1767
  }
@@ -1815,12 +1815,15 @@ class UniPool {
1815
1815
  }
1816
1816
  toBiliXML(options) {
1817
1817
  const genCID = (id)=>{
1818
- const UniID = id_gen_UniID.fromString(id);
1819
- if (UniID.domain === platform_PlatformVideoSource.Bilibili) {
1820
- const cid = UniID.id.replaceAll(`def_${platform_PlatformVideoSource.Bilibili}+`, '');
1821
- if (cid) return cid;
1818
+ if (!id) return options?.cid || id_gen_UniID.fromNull().toString();
1819
+ {
1820
+ const UniID = id_gen_UniID.fromString(id);
1821
+ if (UniID.domain === platform_PlatformVideoSource.Bilibili) {
1822
+ const cid = UniID.id.replaceAll(`def_${platform_PlatformVideoSource.Bilibili}+`, '');
1823
+ if (cid) return cid;
1824
+ }
1825
+ return options?.cid || id;
1822
1826
  }
1823
- return !options?.cid || id;
1824
1827
  };
1825
1828
  if (options?.avoidSenderIDWithAt) {
1826
1829
  const ok = this.dans.every((d)=>d.senderID.endsWith(`@${platform_PlatformVideoSource.Bilibili}`));
@@ -1836,7 +1839,7 @@ class UniPool {
1836
1839
  },
1837
1840
  i: {
1838
1841
  chatserver: 'chat.bilibili.com',
1839
- chatid: genCID(this.dans[0].SOID),
1842
+ chatid: genCID(this.dans[0]?.SOID),
1840
1843
  mission: 0,
1841
1844
  maxlimit: this.dans.length,
1842
1845
  state: 0,
@@ -1898,7 +1901,7 @@ class UniPool {
1898
1901
  code: 0,
1899
1902
  danuni: {
1900
1903
  ...DanUniConvertTipTemplate,
1901
- data: this.dans[0].SOID.split('@')[0]
1904
+ data: this.dans[0]?.SOID.split('@')[0]
1902
1905
  },
1903
1906
  data: this.dans.map((dan)=>{
1904
1907
  const d = dan.toDplayer();
@@ -1927,7 +1930,7 @@ class UniPool {
1927
1930
  return {
1928
1931
  danuni: {
1929
1932
  ...DanUniConvertTipTemplate,
1930
- data: this.dans[0].SOID.split('@')[0]
1933
+ data: this.dans[0]?.SOID.split('@')[0]
1931
1934
  },
1932
1935
  danmuku: this.dans.map((dan)=>{
1933
1936
  const d = dan.toArtplayer();
@@ -1958,7 +1961,7 @@ class UniPool {
1958
1961
  });
1959
1962
  }
1960
1963
  toDDPlay() {
1961
- const episodeId = this.dans[0].SOID.split('@')[0].replaceAll(`def_${platform_PlatformDanmakuOnlySource.DanDanPlay}+`, '');
1964
+ const episodeId = this.dans[0]?.SOID.split('@')[0].replaceAll(`def_${platform_PlatformDanmakuOnlySource.DanDanPlay}+`, '');
1962
1965
  return {
1963
1966
  danuni: {
1964
1967
  ...DanUniConvertTipTemplate,
@@ -214,7 +214,6 @@ export declare class UniPool {
214
214
  * @param lifetime 查重时间区段,单位秒 (默认为 0,表示不查重)
215
215
  */
216
216
  merge(lifetime?: number): UniPool;
217
- minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
218
217
  static import(file: unknown, options?: Options,
219
218
  /**
220
219
  * 加载指定解析模块,为空则全选,为字符串则视为文件名解析加载模块
@@ -225,6 +224,7 @@ export declare class UniPool {
225
224
  };
226
225
  convert2(format: DM_format, file_wrapper: true, continue_on_error?: boolean): File;
227
226
  convert2<T extends Convert2Format>(format: T, file_wrapper?: false, continue_on_error?: boolean): Convert2ResultMap[T];
227
+ minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
228
228
  static fromMin(json: DM_JSON_DanuniMin, options?: Options): UniPool;
229
229
  static fromPb(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
230
230
  /**
@@ -21770,7 +21770,7 @@ and limitations under the License.
21770
21770
  function timestamp_timestampMs(timestamp) {
21771
21771
  return 1000 * Number(timestamp.seconds) + Math.round(timestamp.nanos / 1000000);
21772
21772
  }
21773
- var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.6","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
21773
+ var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.8","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
21774
21774
  const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
21775
21775
  const decimalToHex = (n)=>color_pad(n.toString(16));
21776
21776
  const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
@@ -25464,9 +25464,6 @@ and limitations under the License.
25464
25464
  }
25465
25465
  return new UniPool(result, this.options, this.info);
25466
25466
  }
25467
- minify() {
25468
- return this.dans.map((d)=>d.minify());
25469
- }
25470
25467
  static import(file, options, mod) {
25471
25468
  const handlers = {
25472
25469
  ["danuni.json"]: (json)=>({
@@ -25675,6 +25672,9 @@ and limitations under the License.
25675
25672
  }
25676
25673
  }
25677
25674
  }
25675
+ minify() {
25676
+ return this.dans.map((d)=>d.minify());
25677
+ }
25678
25678
  static fromMin(json, options) {
25679
25679
  return new UniPool(json.map((d)=>UniDM.create(d, options)));
25680
25680
  }
@@ -25728,12 +25728,15 @@ and limitations under the License.
25728
25728
  }
25729
25729
  toBiliXML(options) {
25730
25730
  const genCID = (id)=>{
25731
- const UniID = id_gen_UniID.fromString(id);
25732
- if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
25733
- const cid = UniID.id.replaceAll(`def_${platform.PlatformVideoSource.Bilibili}+`, '');
25734
- if (cid) return cid;
25731
+ if (!id) return options?.cid || id_gen_UniID.fromNull().toString();
25732
+ {
25733
+ const UniID = id_gen_UniID.fromString(id);
25734
+ if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
25735
+ const cid = UniID.id.replaceAll(`def_${platform.PlatformVideoSource.Bilibili}+`, '');
25736
+ if (cid) return cid;
25737
+ }
25738
+ return options?.cid || id;
25735
25739
  }
25736
- return !options?.cid || id;
25737
25740
  };
25738
25741
  if (options?.avoidSenderIDWithAt) {
25739
25742
  const ok = this.dans.every((d)=>d.senderID.endsWith(`@${platform.PlatformVideoSource.Bilibili}`));
@@ -25749,7 +25752,7 @@ and limitations under the License.
25749
25752
  },
25750
25753
  i: {
25751
25754
  chatserver: 'chat.bilibili.com',
25752
- chatid: genCID(this.dans[0].SOID),
25755
+ chatid: genCID(this.dans[0]?.SOID),
25753
25756
  mission: 0,
25754
25757
  maxlimit: this.dans.length,
25755
25758
  state: 0,
@@ -25811,7 +25814,7 @@ and limitations under the License.
25811
25814
  code: 0,
25812
25815
  danuni: {
25813
25816
  ...DanUniConvertTipTemplate,
25814
- data: this.dans[0].SOID.split('@')[0]
25817
+ data: this.dans[0]?.SOID.split('@')[0]
25815
25818
  },
25816
25819
  data: this.dans.map((dan)=>{
25817
25820
  const d = dan.toDplayer();
@@ -25840,7 +25843,7 @@ and limitations under the License.
25840
25843
  return {
25841
25844
  danuni: {
25842
25845
  ...DanUniConvertTipTemplate,
25843
- data: this.dans[0].SOID.split('@')[0]
25846
+ data: this.dans[0]?.SOID.split('@')[0]
25844
25847
  },
25845
25848
  danmuku: this.dans.map((dan)=>{
25846
25849
  const d = dan.toArtplayer();
@@ -25871,7 +25874,7 @@ and limitations under the License.
25871
25874
  });
25872
25875
  }
25873
25876
  toDDPlay() {
25874
- const episodeId = this.dans[0].SOID.split('@')[0].replaceAll(`def_${platform.PlatformDanmakuOnlySource.DanDanPlay}+`, '');
25877
+ const episodeId = this.dans[0]?.SOID.split('@')[0].replaceAll(`def_${platform.PlatformDanmakuOnlySource.DanDanPlay}+`, '');
25875
25878
  return {
25876
25879
  danuni: {
25877
25880
  ...DanUniConvertTipTemplate,
@@ -21060,7 +21060,7 @@
21060
21060
  function timestamp_timestampMs(timestamp) {
21061
21061
  return 1000 * Number(timestamp.seconds) + Math.round(timestamp.nanos / 1000000);
21062
21062
  }
21063
- var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.6","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
21063
+ var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.8","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
21064
21064
  const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
21065
21065
  const decimalToHex = (n)=>color_pad(n.toString(16));
21066
21066
  const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
@@ -24720,9 +24720,6 @@
24720
24720
  }
24721
24721
  return new UniPool(result, this.options, this.info);
24722
24722
  }
24723
- minify() {
24724
- return this.dans.map((d)=>d.minify());
24725
- }
24726
24723
  static import(file, options, mod) {
24727
24724
  const handlers = {
24728
24725
  ["danuni.json"]: (json)=>({
@@ -24931,6 +24928,9 @@
24931
24928
  }
24932
24929
  }
24933
24930
  }
24931
+ minify() {
24932
+ return this.dans.map((d)=>d.minify());
24933
+ }
24934
24934
  static fromMin(json, options) {
24935
24935
  return new UniPool(json.map((d)=>UniDM.create(d, options)));
24936
24936
  }
@@ -24984,12 +24984,15 @@
24984
24984
  }
24985
24985
  toBiliXML(options) {
24986
24986
  const genCID = (id)=>{
24987
- const UniID = id_gen_UniID.fromString(id);
24988
- if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
24989
- const cid = UniID.id.replaceAll(`def_${platform.PlatformVideoSource.Bilibili}+`, '');
24990
- if (cid) return cid;
24987
+ if (!id) return options?.cid || id_gen_UniID.fromNull().toString();
24988
+ {
24989
+ const UniID = id_gen_UniID.fromString(id);
24990
+ if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
24991
+ const cid = UniID.id.replaceAll(`def_${platform.PlatformVideoSource.Bilibili}+`, '');
24992
+ if (cid) return cid;
24993
+ }
24994
+ return options?.cid || id;
24991
24995
  }
24992
- return !options?.cid || id;
24993
24996
  };
24994
24997
  if (options?.avoidSenderIDWithAt) {
24995
24998
  const ok = this.dans.every((d)=>d.senderID.endsWith(`@${platform.PlatformVideoSource.Bilibili}`));
@@ -25005,7 +25008,7 @@
25005
25008
  },
25006
25009
  i: {
25007
25010
  chatserver: 'chat.bilibili.com',
25008
- chatid: genCID(this.dans[0].SOID),
25011
+ chatid: genCID(this.dans[0]?.SOID),
25009
25012
  mission: 0,
25010
25013
  maxlimit: this.dans.length,
25011
25014
  state: 0,
@@ -25067,7 +25070,7 @@
25067
25070
  code: 0,
25068
25071
  danuni: {
25069
25072
  ...DanUniConvertTipTemplate,
25070
- data: this.dans[0].SOID.split('@')[0]
25073
+ data: this.dans[0]?.SOID.split('@')[0]
25071
25074
  },
25072
25075
  data: this.dans.map((dan)=>{
25073
25076
  const d = dan.toDplayer();
@@ -25096,7 +25099,7 @@
25096
25099
  return {
25097
25100
  danuni: {
25098
25101
  ...DanUniConvertTipTemplate,
25099
- data: this.dans[0].SOID.split('@')[0]
25102
+ data: this.dans[0]?.SOID.split('@')[0]
25100
25103
  },
25101
25104
  danmuku: this.dans.map((dan)=>{
25102
25105
  const d = dan.toArtplayer();
@@ -25127,7 +25130,7 @@
25127
25130
  });
25128
25131
  }
25129
25132
  toDDPlay() {
25130
- const episodeId = this.dans[0].SOID.split('@')[0].replaceAll(`def_${platform.PlatformDanmakuOnlySource.DanDanPlay}+`, '');
25133
+ const episodeId = this.dans[0]?.SOID.split('@')[0].replaceAll(`def_${platform.PlatformDanmakuOnlySource.DanDanPlay}+`, '');
25131
25134
  return {
25132
25135
  danuni: {
25133
25136
  ...DanUniConvertTipTemplate,
@@ -21060,7 +21060,7 @@
21060
21060
  function timestamp_timestampMs(timestamp) {
21061
21061
  return 1000 * Number(timestamp.seconds) + Math.round(timestamp.nanos / 1000000);
21062
21062
  }
21063
- var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.6","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
21063
+ var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.3.8","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
21064
21064
  const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
21065
21065
  const decimalToHex = (n)=>color_pad(n.toString(16));
21066
21066
  const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
@@ -24720,9 +24720,6 @@
24720
24720
  }
24721
24721
  return new UniPool(result, this.options, this.info);
24722
24722
  }
24723
- minify() {
24724
- return this.dans.map((d)=>d.minify());
24725
- }
24726
24723
  static import(file, options, mod) {
24727
24724
  const handlers = {
24728
24725
  ["danuni.json"]: (json)=>({
@@ -24931,6 +24928,9 @@
24931
24928
  }
24932
24929
  }
24933
24930
  }
24931
+ minify() {
24932
+ return this.dans.map((d)=>d.minify());
24933
+ }
24934
24934
  static fromMin(json, options) {
24935
24935
  return new UniPool(json.map((d)=>UniDM.create(d, options)));
24936
24936
  }
@@ -24984,12 +24984,15 @@
24984
24984
  }
24985
24985
  toBiliXML(options) {
24986
24986
  const genCID = (id)=>{
24987
- const UniID = id_gen_UniID.fromString(id);
24988
- if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
24989
- const cid = UniID.id.replaceAll(`def_${platform.PlatformVideoSource.Bilibili}+`, '');
24990
- if (cid) return cid;
24987
+ if (!id) return options?.cid || id_gen_UniID.fromNull().toString();
24988
+ {
24989
+ const UniID = id_gen_UniID.fromString(id);
24990
+ if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
24991
+ const cid = UniID.id.replaceAll(`def_${platform.PlatformVideoSource.Bilibili}+`, '');
24992
+ if (cid) return cid;
24993
+ }
24994
+ return options?.cid || id;
24991
24995
  }
24992
- return !options?.cid || id;
24993
24996
  };
24994
24997
  if (options?.avoidSenderIDWithAt) {
24995
24998
  const ok = this.dans.every((d)=>d.senderID.endsWith(`@${platform.PlatformVideoSource.Bilibili}`));
@@ -25005,7 +25008,7 @@
25005
25008
  },
25006
25009
  i: {
25007
25010
  chatserver: 'chat.bilibili.com',
25008
- chatid: genCID(this.dans[0].SOID),
25011
+ chatid: genCID(this.dans[0]?.SOID),
25009
25012
  mission: 0,
25010
25013
  maxlimit: this.dans.length,
25011
25014
  state: 0,
@@ -25067,7 +25070,7 @@
25067
25070
  code: 0,
25068
25071
  danuni: {
25069
25072
  ...DanUniConvertTipTemplate,
25070
- data: this.dans[0].SOID.split('@')[0]
25073
+ data: this.dans[0]?.SOID.split('@')[0]
25071
25074
  },
25072
25075
  data: this.dans.map((dan)=>{
25073
25076
  const d = dan.toDplayer();
@@ -25096,7 +25099,7 @@
25096
25099
  return {
25097
25100
  danuni: {
25098
25101
  ...DanUniConvertTipTemplate,
25099
- data: this.dans[0].SOID.split('@')[0]
25102
+ data: this.dans[0]?.SOID.split('@')[0]
25100
25103
  },
25101
25104
  danmuku: this.dans.map((dan)=>{
25102
25105
  const d = dan.toArtplayer();
@@ -25127,7 +25130,7 @@
25127
25130
  });
25128
25131
  }
25129
25132
  toDDPlay() {
25130
- const episodeId = this.dans[0].SOID.split('@')[0].replaceAll(`def_${platform.PlatformDanmakuOnlySource.DanDanPlay}+`, '');
25133
+ const episodeId = this.dans[0]?.SOID.split('@')[0].replaceAll(`def_${platform.PlatformDanmakuOnlySource.DanDanPlay}+`, '');
25131
25134
  return {
25132
25135
  danuni: {
25133
25136
  ...DanUniConvertTipTemplate,
@@ -214,7 +214,6 @@ export declare class UniPool {
214
214
  * @param lifetime 查重时间区段,单位秒 (默认为 0,表示不查重)
215
215
  */
216
216
  merge(lifetime?: number): UniPool;
217
- minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
218
217
  static import(file: unknown, options?: Options,
219
218
  /**
220
219
  * 加载指定解析模块,为空则全选,为字符串则视为文件名解析加载模块
@@ -225,6 +224,7 @@ export declare class UniPool {
225
224
  };
226
225
  convert2(format: DM_format, file_wrapper: true, continue_on_error?: boolean): File;
227
226
  convert2<T extends Convert2Format>(format: T, file_wrapper?: false, continue_on_error?: boolean): Convert2ResultMap[T];
227
+ minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
228
228
  static fromMin(json: DM_JSON_DanuniMin, options?: Options): UniPool;
229
229
  static fromPb(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
230
230
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dan-uni/dan-any",
3
3
  "type": "module",
4
- "version": "1.3.6",
4
+ "version": "1.3.8",
5
5
  "description": "A danmaku transformer lib, supporting danmaku from different platforms.",
6
6
  "author": "rinne",
7
7
  "license": "LGPL-3.0-or-later",
package/src/index.ts CHANGED
@@ -463,9 +463,6 @@ export class UniPool {
463
463
  }
464
464
  return new UniPool(result, this.options, this.info)
465
465
  }
466
- minify() {
467
- return this.dans.map((d) => d.minify())
468
- }
469
466
  static import(
470
467
  file: unknown,
471
468
  options?: Options,
@@ -776,6 +773,9 @@ export class UniPool {
776
773
  }
777
774
  }
778
775
  }
776
+ minify() {
777
+ return this.dans.map((d) => d.minify())
778
+ }
779
779
  static fromMin(json: DM_JSON_DanuniMin, options?: Options) {
780
780
  return new UniPool(json.map((d: any) => UniDM.create(d, options)))
781
781
  }
@@ -865,17 +865,18 @@ export class UniPool {
865
865
  */
866
866
  avoidSenderIDWithAt?: boolean
867
867
  }): string {
868
- const genCID = (id: string) => {
869
- const UniID = ID.fromString(id)
870
- if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
871
- const cid = UniID.id.replaceAll(
872
- `def_${platform.PlatformVideoSource.Bilibili}+`,
873
- '',
874
- )
875
-
876
- if (cid) return cid
877
- }
878
- return !options?.cid || id
868
+ const genCID = (id?: string) => {
869
+ if (id) {
870
+ const UniID = ID.fromString(id)
871
+ if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
872
+ const cid = UniID.id.replaceAll(
873
+ `def_${platform.PlatformVideoSource.Bilibili}+`,
874
+ '',
875
+ )
876
+ if (cid) return cid
877
+ }
878
+ return options?.cid || id
879
+ } else return options?.cid || ID.fromNull().toString()
879
880
  }
880
881
  if (options?.avoidSenderIDWithAt) {
881
882
  const ok = this.dans.every((d) =>
@@ -892,7 +893,7 @@ export class UniPool {
892
893
  },
893
894
  i: {
894
895
  chatserver: 'chat.bilibili.com',
895
- chatid: genCID(this.dans[0].SOID),
896
+ chatid: genCID(this.dans[0]?.SOID),
896
897
  mission: 0,
897
898
  maxlimit: this.dans.length,
898
899
  state: 0,
@@ -995,7 +996,7 @@ export class UniPool {
995
996
  code: 0,
996
997
  danuni: {
997
998
  ...DanUniConvertTipTemplate,
998
- data: this.dans[0].SOID.split('@')[0],
999
+ data: this.dans[0]?.SOID.split('@')[0],
999
1000
  },
1000
1001
  data: this.dans.map((dan) => {
1001
1002
  const d = dan.toDplayer()
@@ -1032,7 +1033,7 @@ export class UniPool {
1032
1033
  return {
1033
1034
  danuni: {
1034
1035
  ...DanUniConvertTipTemplate,
1035
- data: this.dans[0].SOID.split('@')[0],
1036
+ data: this.dans[0]?.SOID.split('@')[0],
1036
1037
  },
1037
1038
  danmuku: this.dans.map((dan) => {
1038
1039
  const d = dan.toArtplayer()
@@ -1074,7 +1075,7 @@ export class UniPool {
1074
1075
  )
1075
1076
  }
1076
1077
  toDDPlay(): DM_JSON_DDPlay & { danuni?: DanUniConvertTip } {
1077
- const episodeId = this.dans[0].SOID.split('@')[0].replaceAll(
1078
+ const episodeId = this.dans[0]?.SOID.split('@')[0].replaceAll(
1078
1079
  `def_${platform.PlatformDanmakuOnlySource.DanDanPlay}+`,
1079
1080
  '',
1080
1081
  )