@dan-uni/dan-any 0.6.9 → 0.7.4

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.
@@ -23095,7 +23095,7 @@ and limitations under the License.
23095
23095
  return this.fromNull(domain);
23096
23096
  }
23097
23097
  }
23098
- function createDMID(content = '', senderID, ctime, extraStr, slice = 8) {
23098
+ function createDMID(content = '', senderID = id_gen_UniID.fromNull().toString(), ctime = new Date().toISOString(), extraStr, slice = 8) {
23099
23099
  return new ht('SHA3-256', 'TEXT').update(`${content}|${senderID}|${UniDM.transCtime(ctime).toISOString()}|${extraStr}`).getHash('HEX').slice(0, slice);
23100
23100
  }
23101
23101
  function _ts_decorate(decorators, target, key, desc) {
@@ -23137,7 +23137,7 @@ and limitations under the License.
23137
23137
  bits.unshift(!!(1 & number));
23138
23138
  number >>= 1;
23139
23139
  }while (number);
23140
- return bits.reverse();
23140
+ return bits.toReversed();
23141
23141
  };
23142
23142
  var dm_gen_DMAttr = /*#__PURE__*/ function(DMAttr) {
23143
23143
  DMAttr["Protect"] = "Protect";
@@ -23220,8 +23220,10 @@ and limitations under the License.
23220
23220
  return Pools;
23221
23221
  }({});
23222
23222
  class UniDM {
23223
- init() {
23223
+ init(options) {
23224
+ this.options = options || this.options;
23224
23225
  const def = new UniDM();
23226
+ if (void 0 === this.options.dmid || true === this.options.dmid) this.options.dmid = createDMID;
23225
23227
  if (!this.SOID) this.SOID = def.SOID;
23226
23228
  if (!this.progress) this.progress = def.progress;
23227
23229
  if (!this.mode) this.mode = def.mode;
@@ -23233,7 +23235,7 @@ and limitations under the License.
23233
23235
  if (!this.weight) this.weight = def.weight;
23234
23236
  if (!this.pool) this.pool = def.pool;
23235
23237
  if (!this.attr) this.attr = def.attr;
23236
- if (!this.DMID) this.DMID = this.toDMID();
23238
+ if (!this.DMID && false !== this.options.dmid) this.DMID = this.toDMID();
23237
23239
  this.progress = Number.parseFloat(this.progress.toFixed(3));
23238
23240
  if (this.extraStr) this.extraStr = dm_gen_JSON.stringify(cleanEmptyObjects(dm_gen_JSON.parse(this.extraStr)));
23239
23241
  if ('{}' === this.extraStr) this.extraStr = void 0;
@@ -23251,13 +23253,13 @@ and limitations under the License.
23251
23253
  async validate() {
23252
23254
  return validateOrReject(this);
23253
23255
  }
23254
- static create(pjson) {
23256
+ static create(pjson, options) {
23255
23257
  return pjson ? plainToInstance(UniDM, pjson.extra ? {
23256
23258
  ...pjson,
23257
23259
  extraStr: pjson.extra ? dm_gen_JSON.stringify(pjson.extra) : pjson.extraStr
23258
23260
  } : pjson, {
23259
23261
  excludeExtraneousValues: true
23260
- }).init() : new UniDM();
23262
+ }).init(options) : new UniDM();
23261
23263
  }
23262
23264
  get extra() {
23263
23265
  const extra = dm_gen_JSON.parse(this.extraStr || '{}');
@@ -23268,7 +23270,10 @@ and limitations under the License.
23268
23270
  return false;
23269
23271
  }
23270
23272
  toDMID() {
23271
- return createDMID(this.content, this.senderID, this.ctime, this.extraStr);
23273
+ if (false === this.options.dmid) return;
23274
+ if (true === this.options.dmid) return createDMID(this.content, this.senderID, this.ctime, this.extraStr);
23275
+ if ('number' == typeof this.options.dmid) return createDMID(this.content, this.senderID, this.ctime, this.extraStr, this.options.dmid);
23276
+ return this.options.dmid(this.content, this.senderID, this.ctime, this.extraStr);
23272
23277
  }
23273
23278
  isSameAs(dan, options) {
23274
23279
  if (4 === this.mode || 4 === dan.mode) return false;
@@ -23386,7 +23391,7 @@ and limitations under the License.
23386
23391
  }
23387
23392
  return mode;
23388
23393
  }
23389
- static fromBili(args, cid) {
23394
+ static fromBili(args, cid, options) {
23390
23395
  if (args.oid && !cid) cid = args.oid;
23391
23396
  const SOID = `def_${platform_PlatformVideoSource.Bilibili}+${id_gen_UniID.fromBili({
23392
23397
  cid
@@ -23429,7 +23434,7 @@ and limitations under the License.
23429
23434
  }
23430
23435
  return this.create({
23431
23436
  ...args,
23432
- SOID: SOID.toString(),
23437
+ SOID,
23433
23438
  mode,
23434
23439
  senderID: senderID.toString(),
23435
23440
  ctime: this.transCtime(args.ctime, 's'),
@@ -23438,7 +23443,7 @@ and limitations under the License.
23438
23443
  attr: DMAttrUtils.fromBin(args.attr, platform_PlatformVideoSource.Bilibili),
23439
23444
  platform: platform_PlatformVideoSource.Bilibili,
23440
23445
  extra
23441
- });
23446
+ }, options);
23442
23447
  }
23443
23448
  toBiliXML(options) {
23444
23449
  if (options?.skipBiliCommand && this.extra.bili?.command) return null;
@@ -23493,16 +23498,16 @@ and limitations under the License.
23493
23498
  ].join(',')
23494
23499
  };
23495
23500
  }
23496
- static fromBiliCommand(args, cid) {
23501
+ static fromBiliCommand(args, cid, options) {
23497
23502
  if (args.oid && !cid) cid = args.oid;
23498
- const SOID = id_gen_UniID.fromBili({
23503
+ const SOID = `def_${platform_PlatformVideoSource.Bilibili}+${id_gen_UniID.fromBili({
23499
23504
  cid
23500
- }), senderID = id_gen_UniID.fromBili({
23505
+ })}`, senderID = id_gen_UniID.fromBili({
23501
23506
  mid: args.mid
23502
23507
  });
23503
23508
  return this.create({
23504
23509
  ...args,
23505
- SOID: SOID.toString(),
23510
+ SOID,
23506
23511
  mode: 4,
23507
23512
  senderID: senderID.toString(),
23508
23513
  ctime: new Date(`${args.ctime} GMT+0800`),
@@ -23517,9 +23522,9 @@ and limitations under the License.
23517
23522
  command: args
23518
23523
  }
23519
23524
  }
23520
- });
23525
+ }, options);
23521
23526
  }
23522
- static fromDplayer(args, playerID, domain) {
23527
+ static fromDplayer(args, playerID, domain, options) {
23523
23528
  const SOID = id_gen_UniID.fromUnknown(playerID, domain), senderID = id_gen_UniID.fromUnknown(args.midHash, domain);
23524
23529
  return this.create({
23525
23530
  ...args,
@@ -23527,7 +23532,7 @@ and limitations under the License.
23527
23532
  mode: this.transMode(args.mode, 'dplayer'),
23528
23533
  senderID: senderID.toString(),
23529
23534
  platform: domain
23530
- });
23535
+ }, options);
23531
23536
  }
23532
23537
  toDplayer() {
23533
23538
  let mode = 0;
@@ -23541,7 +23546,7 @@ and limitations under the License.
23541
23546
  content: this.content
23542
23547
  };
23543
23548
  }
23544
- static fromArtplayer(args, playerID, domain) {
23549
+ static fromArtplayer(args, playerID, domain, options) {
23545
23550
  const SOID = id_gen_UniID.fromUnknown(playerID, domain), senderID = id_gen_UniID.fromUnknown('', domain);
23546
23551
  let extra = args.border ? {
23547
23552
  artplayer: {
@@ -23567,7 +23572,7 @@ and limitations under the License.
23567
23572
  senderID: senderID.toString(),
23568
23573
  platform: domain,
23569
23574
  extra
23570
- });
23575
+ }, options);
23571
23576
  }
23572
23577
  toArtplayer() {
23573
23578
  let mode = 0;
@@ -23581,7 +23586,7 @@ and limitations under the License.
23581
23586
  style: this.extra.artplayer?.style
23582
23587
  };
23583
23588
  }
23584
- static fromDDplay(args, episodeId, domain = platform_PlatformDanmakuOnlySource.DanDanPlay) {
23589
+ static fromDDplay(args, episodeId, domain = platform_PlatformDanmakuOnlySource.DanDanPlay, options) {
23585
23590
  const SOID = id_gen_UniID.fromUnknown(`def_${platform_PlatformDanmakuOnlySource.DanDanPlay}+${episodeId}`, domain);
23586
23591
  return this.create({
23587
23592
  ...args,
@@ -23591,7 +23596,7 @@ and limitations under the License.
23591
23596
  content: args.m,
23592
23597
  platform: domain,
23593
23598
  DMID: args.cid.toString()
23594
- });
23599
+ }, options);
23595
23600
  }
23596
23601
  toDDplay() {
23597
23602
  let mode = 1;
@@ -23618,6 +23623,9 @@ and limitations under the License.
23618
23623
  this.weight = 0;
23619
23624
  this.pool = 0;
23620
23625
  this.attr = [];
23626
+ this.options = {
23627
+ dmid: createDMID
23628
+ };
23621
23629
  }
23622
23630
  }
23623
23631
  _ts_decorate([
@@ -23720,7 +23728,9 @@ and limitations under the License.
23720
23728
  _ts_decorate([
23721
23729
  Expose(),
23722
23730
  _ts_metadata("design:type", Function),
23723
- _ts_metadata("design:paramtypes", []),
23731
+ _ts_metadata("design:paramtypes", [
23732
+ "undefined" == typeof Options ? Object : Options
23733
+ ]),
23724
23734
  _ts_metadata("design:returntype", void 0)
23725
23735
  ], UniDM.prototype, "init", null);
23726
23736
  _ts_decorate([
@@ -23944,8 +23954,8 @@ and limitations under the License.
23944
23954
  platform: s.platform.sort((a, b)=>b.count - a.count)[0].val
23945
23955
  };
23946
23956
  }
23947
- static create() {
23948
- return new UniPool([]);
23957
+ static create(options) {
23958
+ return new UniPool([], options);
23949
23959
  }
23950
23960
  assign(dans) {
23951
23961
  if (dans instanceof UniPool) return new UniPool([
@@ -23974,11 +23984,13 @@ and limitations under the License.
23974
23984
  }));
23975
23985
  }
23976
23986
  dedupe() {
23977
- const map = new Map();
23978
- this.dans.forEach((d)=>map.set(d.DMID || d.toDMID(), d));
23979
- this.dans = [
23980
- ...map.values()
23981
- ];
23987
+ if (false !== this.options.dmid) {
23988
+ const map = new Map();
23989
+ this.dans.forEach((d)=>map.set(d.DMID || d.toDMID(), d));
23990
+ this.dans = [
23991
+ ...map.values()
23992
+ ];
23993
+ }
23982
23994
  this.options.dedupe = false;
23983
23995
  }
23984
23996
  merge(lifetime = 0) {
@@ -24107,7 +24119,7 @@ and limitations under the License.
24107
24119
  }
24108
24120
  }
24109
24121
  }
24110
- static fromPb(bin) {
24122
+ static fromPb(bin, options) {
24111
24123
  const data = fromBinary(DanmakuReplySchema, new Uint8Array(bin));
24112
24124
  return new UniPool(data.danmakus.map((d)=>UniDM.create({
24113
24125
  ...d,
@@ -24115,7 +24127,7 @@ and limitations under the License.
24115
24127
  ctime: timestampDate(d.ctime || timestampNow()),
24116
24128
  pool: d.pool,
24117
24129
  attr: d.attr
24118
- })));
24130
+ }, options)), options);
24119
24131
  }
24120
24132
  toPb() {
24121
24133
  return toBinary(DanmakuReplySchema, create(DanmakuReplySchema, {
@@ -24137,7 +24149,7 @@ and limitations under the License.
24137
24149
  }))
24138
24150
  }));
24139
24151
  }
24140
- static fromBiliXML(xml) {
24152
+ static fromBiliXML(xml, options) {
24141
24153
  const parser = new XMLParser({
24142
24154
  ignoreAttributes: false
24143
24155
  }), oriData = parser.parse(xml), dans = oriData.i.d;
@@ -24154,8 +24166,8 @@ and limitations under the License.
24154
24166
  midHash: p_arr[6],
24155
24167
  id: BigInt(p_arr[7]),
24156
24168
  weight: Number.parseInt(p_arr[8])
24157
- }, BigInt(oriData.i.chatid));
24158
- }).filter((d)=>null !== d));
24169
+ }, BigInt(oriData.i.chatid), options);
24170
+ }).filter((d)=>null !== d), options);
24159
24171
  }
24160
24172
  toBiliXML() {
24161
24173
  const genCID = (id)=>{
@@ -24186,25 +24198,25 @@ and limitations under the License.
24186
24198
  }
24187
24199
  });
24188
24200
  }
24189
- static fromBiliGrpc(bin) {
24201
+ static fromBiliGrpc(bin, options) {
24190
24202
  const data = fromBinary(DmSegMobileReplySchema, new Uint8Array(bin)), json = data.elems;
24191
24203
  return new UniPool(json.map((d)=>UniDM.fromBili({
24192
24204
  ...d,
24193
24205
  progress: d.progress / 1000
24194
- })));
24206
+ }, d.oid, options)), options);
24195
24207
  }
24196
- static fromBiliCommandGrpc(bin) {
24208
+ static fromBiliCommandGrpc(bin, options) {
24197
24209
  const data = fromBinary(DmWebViewReplySchema, new Uint8Array(bin)), json = data.commandDms;
24198
- return new UniPool(json.map((d)=>UniDM.fromBiliCommand(d)));
24210
+ return new UniPool(json.map((d)=>UniDM.fromBiliCommand(d, d.oid, options)), options);
24199
24211
  }
24200
- static fromDplayer(json, playerID, domain = 'other') {
24212
+ static fromDplayer(json, playerID, domain = 'other', options) {
24201
24213
  return new UniPool(json.data.map((d)=>UniDM.fromDplayer({
24202
24214
  content: d[4],
24203
24215
  progress: d[0],
24204
24216
  mode: d[1],
24205
24217
  color: d[2],
24206
24218
  midHash: d[3]
24207
- }, playerID, domain)));
24219
+ }, playerID, domain, options)), options);
24208
24220
  }
24209
24221
  toDplayer() {
24210
24222
  return {
@@ -24221,14 +24233,14 @@ and limitations under the License.
24221
24233
  })
24222
24234
  };
24223
24235
  }
24224
- static fromArtplayer(json, playerID, domain = 'other') {
24236
+ static fromArtplayer(json, playerID, domain = 'other', options) {
24225
24237
  return new UniPool(json.map((d)=>UniDM.fromArtplayer({
24226
24238
  content: d.text,
24227
24239
  progress: d.time || 0,
24228
24240
  mode: d.mode || 0,
24229
24241
  color: Number((d.color || 'FFFFFF').replace('#', '0x')),
24230
24242
  style: d.style
24231
- }, playerID, domain)));
24243
+ }, playerID, domain, options)), options);
24232
24244
  }
24233
24245
  toArtplayer() {
24234
24246
  return this.dans.map((dan)=>{
@@ -24243,7 +24255,7 @@ and limitations under the License.
24243
24255
  };
24244
24256
  });
24245
24257
  }
24246
- static fromDDPlay(json, episodeId) {
24258
+ static fromDDPlay(json, episodeId, options) {
24247
24259
  return new UniPool(json.comments.map((d)=>{
24248
24260
  const p_arr = d.p.split(',');
24249
24261
  return UniDM.fromDDplay({
@@ -24253,8 +24265,8 @@ and limitations under the License.
24253
24265
  mode: Number.parseInt(p_arr[1]),
24254
24266
  progress: Number.parseFloat(p_arr[0]),
24255
24267
  uid: p_arr[3]
24256
- }, episodeId);
24257
- }));
24268
+ }, episodeId, void 0, options);
24269
+ }), options);
24258
24270
  }
24259
24271
  toDDplay() {
24260
24272
  return {
@@ -24600,7 +24612,7 @@ and limitations under the License.
24600
24612
  config,
24601
24613
  context
24602
24614
  }, rawText = JSON.stringify(raw1);
24603
- let compress = raw_Buffer.from('');
24615
+ let compress;
24604
24616
  compress = 'brotli' === compressType ? (0, lib.brotliCompressSync)(rawText) : (0, lib.gzipSync)(rawText);
24605
24617
  return `;RawCompressType: ${compressType}\n;RawBaseType: ${baseType}\n;Raw: ${'base64' === baseType ? compress.toString('base64') : fromUint16Array(base16384_lib.encode(compress))}`;
24606
24618
  }
@@ -24612,7 +24624,7 @@ and limitations under the License.
24612
24624
  if (!compressTypes.includes(compressType)) compressType = 'gzip';
24613
24625
  if (!baseTypes.includes(baseType)) baseType = 'base64';
24614
24626
  const text = lineRaw.replace(';Raw: ', '').trim(), buffer = 'base64' === baseType ? raw_Buffer.from(text, 'base64') : raw_Buffer.from(base16384_lib.decode(raw_Buffer.from(text, 'utf-8').toString('utf-8')));
24615
- let decompress = raw_Buffer.from('');
24627
+ let decompress;
24616
24628
  decompress = 'brotli' === compressType ? (0, lib.brotliDecompressSync)(buffer) : (0, lib.gunzipSync)(buffer);
24617
24629
  try {
24618
24630
  return JSON.parse(decompress.toString('utf-8'));
@@ -24875,8 +24887,8 @@ and limitations under the License.
24875
24887
  platform: s.platform.sort((a, b)=>b.count - a.count)[0].val
24876
24888
  };
24877
24889
  }
24878
- static create() {
24879
- return new src_UniPool([]);
24890
+ static create(options) {
24891
+ return new src_UniPool([], options);
24880
24892
  }
24881
24893
  assign(dans) {
24882
24894
  if (dans instanceof src_UniPool) return new src_UniPool([
@@ -24905,11 +24917,13 @@ and limitations under the License.
24905
24917
  }));
24906
24918
  }
24907
24919
  dedupe() {
24908
- const map = new Map();
24909
- this.dans.forEach((d)=>map.set(d.DMID || d.toDMID(), d));
24910
- this.dans = [
24911
- ...map.values()
24912
- ];
24920
+ if (false !== this.options.dmid) {
24921
+ const map = new Map();
24922
+ this.dans.forEach((d)=>map.set(d.DMID || d.toDMID(), d));
24923
+ this.dans = [
24924
+ ...map.values()
24925
+ ];
24926
+ }
24913
24927
  this.options.dedupe = false;
24914
24928
  }
24915
24929
  merge(lifetime = 0) {
@@ -25038,7 +25052,7 @@ and limitations under the License.
25038
25052
  }
25039
25053
  }
25040
25054
  }
25041
- static fromPb(bin) {
25055
+ static fromPb(bin, options) {
25042
25056
  const data = fromBinary(DanmakuReplySchema, new Uint8Array(bin));
25043
25057
  return new src_UniPool(data.danmakus.map((d)=>UniDM.create({
25044
25058
  ...d,
@@ -25046,7 +25060,7 @@ and limitations under the License.
25046
25060
  ctime: timestampDate(d.ctime || timestampNow()),
25047
25061
  pool: d.pool,
25048
25062
  attr: d.attr
25049
- })));
25063
+ }, options)), options);
25050
25064
  }
25051
25065
  toPb() {
25052
25066
  return toBinary(DanmakuReplySchema, create(DanmakuReplySchema, {
@@ -25068,7 +25082,7 @@ and limitations under the License.
25068
25082
  }))
25069
25083
  }));
25070
25084
  }
25071
- static fromBiliXML(xml) {
25085
+ static fromBiliXML(xml, options) {
25072
25086
  const parser = new XMLParser({
25073
25087
  ignoreAttributes: false
25074
25088
  }), oriData = parser.parse(xml), dans = oriData.i.d;
@@ -25085,8 +25099,8 @@ and limitations under the License.
25085
25099
  midHash: p_arr[6],
25086
25100
  id: BigInt(p_arr[7]),
25087
25101
  weight: Number.parseInt(p_arr[8])
25088
- }, BigInt(oriData.i.chatid));
25089
- }).filter((d)=>null !== d));
25102
+ }, BigInt(oriData.i.chatid), options);
25103
+ }).filter((d)=>null !== d), options);
25090
25104
  }
25091
25105
  toBiliXML() {
25092
25106
  const genCID = (id)=>{
@@ -25117,25 +25131,25 @@ and limitations under the License.
25117
25131
  }
25118
25132
  });
25119
25133
  }
25120
- static fromBiliGrpc(bin) {
25134
+ static fromBiliGrpc(bin, options) {
25121
25135
  const data = fromBinary(DmSegMobileReplySchema, new Uint8Array(bin)), json = data.elems;
25122
25136
  return new src_UniPool(json.map((d)=>UniDM.fromBili({
25123
25137
  ...d,
25124
25138
  progress: d.progress / 1000
25125
- })));
25139
+ }, d.oid, options)), options);
25126
25140
  }
25127
- static fromBiliCommandGrpc(bin) {
25141
+ static fromBiliCommandGrpc(bin, options) {
25128
25142
  const data = fromBinary(DmWebViewReplySchema, new Uint8Array(bin)), json = data.commandDms;
25129
- return new src_UniPool(json.map((d)=>UniDM.fromBiliCommand(d)));
25143
+ return new src_UniPool(json.map((d)=>UniDM.fromBiliCommand(d, d.oid, options)), options);
25130
25144
  }
25131
- static fromDplayer(json, playerID, domain = 'other') {
25145
+ static fromDplayer(json, playerID, domain = 'other', options) {
25132
25146
  return new src_UniPool(json.data.map((d)=>UniDM.fromDplayer({
25133
25147
  content: d[4],
25134
25148
  progress: d[0],
25135
25149
  mode: d[1],
25136
25150
  color: d[2],
25137
25151
  midHash: d[3]
25138
- }, playerID, domain)));
25152
+ }, playerID, domain, options)), options);
25139
25153
  }
25140
25154
  toDplayer() {
25141
25155
  return {
@@ -25152,14 +25166,14 @@ and limitations under the License.
25152
25166
  })
25153
25167
  };
25154
25168
  }
25155
- static fromArtplayer(json, playerID, domain = 'other') {
25169
+ static fromArtplayer(json, playerID, domain = 'other', options) {
25156
25170
  return new src_UniPool(json.map((d)=>UniDM.fromArtplayer({
25157
25171
  content: d.text,
25158
25172
  progress: d.time || 0,
25159
25173
  mode: d.mode || 0,
25160
25174
  color: Number((d.color || 'FFFFFF').replace('#', '0x')),
25161
25175
  style: d.style
25162
- }, playerID, domain)));
25176
+ }, playerID, domain, options)), options);
25163
25177
  }
25164
25178
  toArtplayer() {
25165
25179
  return this.dans.map((dan)=>{
@@ -25174,7 +25188,7 @@ and limitations under the License.
25174
25188
  };
25175
25189
  });
25176
25190
  }
25177
- static fromDDPlay(json, episodeId) {
25191
+ static fromDDPlay(json, episodeId, options) {
25178
25192
  return new src_UniPool(json.comments.map((d)=>{
25179
25193
  const p_arr = d.p.split(',');
25180
25194
  return UniDM.fromDDplay({
@@ -25184,8 +25198,8 @@ and limitations under the License.
25184
25198
  mode: Number.parseInt(p_arr[1]),
25185
25199
  progress: Number.parseFloat(p_arr[0]),
25186
25200
  uid: p_arr[3]
25187
- }, episodeId);
25188
- }));
25201
+ }, episodeId, void 0, options);
25202
+ }), options);
25189
25203
  }
25190
25204
  toDDplay() {
25191
25205
  return {
@@ -49,6 +49,7 @@ type UniPoolPipe = (that: UniPool) => Promise<UniPool>;
49
49
  type UniPoolPipeSync = (that: UniPool) => UniPool;
50
50
  interface Options {
51
51
  dedupe?: boolean;
52
+ dmid?: boolean | number | UniIDTools.DMIDGenerator;
52
53
  }
53
54
  export declare class UniPool {
54
55
  dans: UniDM[];
@@ -105,7 +106,7 @@ export declare class UniPool {
105
106
  pool: UniDMTools.Pools;
106
107
  platform: string | undefined;
107
108
  };
108
- static create(): UniPool;
109
+ static create(options?: Options): UniPool;
109
110
  /**
110
111
  * 合并弹幕/弹幕库
111
112
  */
@@ -125,23 +126,23 @@ export declare class UniPool {
125
126
  merge(lifetime?: number): UniPool;
126
127
  minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
127
128
  convert2(format: DM_format, continue_on_error?: boolean): string | Uint8Array<ArrayBufferLike> | UniDM[] | DM_JSON_Dplayer | DM_JSON_DDPlay | DM_JSON_Artplayer[];
128
- static fromPb(bin: Uint8Array | ArrayBuffer): UniPool;
129
+ static fromPb(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
129
130
  /**
130
131
  * 转为 protobuf 二进制
131
132
  */
132
133
  toPb(): Uint8Array<ArrayBufferLike>;
133
- static fromBiliXML(xml: string): UniPool;
134
+ static fromBiliXML(xml: string, options?: Options): UniPool;
134
135
  toBiliXML(): string;
135
- static fromBiliGrpc(bin: Uint8Array | ArrayBuffer): UniPool;
136
+ static fromBiliGrpc(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
136
137
  /**
137
138
  * @param bin 符合`DmWebViewReplySchema`(bili视频meta)的protobuf二进制
138
139
  */
139
- static fromBiliCommandGrpc(bin: Uint8Array | ArrayBuffer): UniPool;
140
- static fromDplayer(json: DM_JSON_Dplayer, playerID: string, domain?: string): UniPool;
140
+ static fromBiliCommandGrpc(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
141
+ static fromDplayer(json: DM_JSON_Dplayer, playerID: string, domain?: string, options?: Options): UniPool;
141
142
  toDplayer(): DM_JSON_Dplayer;
142
- static fromArtplayer(json: DM_JSON_Artplayer[], playerID: string, domain?: string): UniPool;
143
+ static fromArtplayer(json: DM_JSON_Artplayer[], playerID: string, domain?: string, options?: Options): UniPool;
143
144
  toArtplayer(): DM_JSON_Artplayer[];
144
- static fromDDPlay(json: DM_JSON_DDPlay, episodeId: string): UniPool;
145
+ static fromDDPlay(json: DM_JSON_DDPlay, episodeId: string, options?: Options): UniPool;
145
146
  toDDplay(): DM_JSON_DDPlay;
146
147
  static fromASS(ass: string): UniPool;
147
148
  toASS(options?: AssGenOptions): string;
@@ -1,5 +1,6 @@
1
1
  import type { DM_JSON_BiliCommandGrpc } from '..';
2
2
  import type { PlatformDanmakuSource } from './platform';
3
+ import { DMIDGenerator } from './id-gen';
3
4
  import { PlatformDanmakuOnlySource } from './platform';
4
5
  export declare enum DMAttr {
5
6
  Protect = "Protect",
@@ -165,6 +166,9 @@ export interface UniDMObj {
165
166
  extraStr: string;
166
167
  DMID: string;
167
168
  }
169
+ interface Options {
170
+ dmid?: boolean | number | DMIDGenerator;
171
+ }
168
172
  export declare class UniDM {
169
173
  /**
170
174
  * 资源ID
@@ -238,9 +242,10 @@ export declare class UniDM {
238
242
  */
239
243
  extraStr?: string;
240
244
  DMID?: string;
241
- init(): this;
245
+ private options;
246
+ init(options?: Options): this;
242
247
  validate(): Promise<void>;
243
- static create(pjson?: Partial<UniDMObj>): UniDM;
248
+ static create(pjson?: Partial<UniDMObj>, options?: Options): UniDM;
244
249
  get extra(): Extra;
245
250
  get isFrom3rdPlatform(): boolean;
246
251
  /**
@@ -248,7 +253,7 @@ export declare class UniDM {
248
253
  * @description sha3-256(content+senderID+ctime)截取前8位
249
254
  * @description 同一SOID下唯一
250
255
  */
251
- toDMID(): string;
256
+ toDMID(): string | undefined;
252
257
  isSameAs(dan: UniDM, options?: {
253
258
  skipDanuniMerge?: boolean;
254
259
  }): boolean;
@@ -267,19 +272,19 @@ export declare class UniDM {
267
272
  */
268
273
  static transCtime(oriCtime: ctime, tsUnit?: 'ms' | 's'): Date;
269
274
  static transMode(oriMode: number, fmt: 'bili' | 'dplayer' | 'artplayer' | 'ddplay'): Modes;
270
- static fromBili(args: DMBili, cid?: bigint): UniDM;
275
+ static fromBili(args: DMBili, cid?: bigint, options?: Options): UniDM;
271
276
  toBiliXML(options?: {
272
277
  skipBiliCommand: boolean;
273
278
  }): {
274
279
  '#text': string;
275
280
  '@_p': string;
276
281
  } | null;
277
- static fromBiliCommand(args: DMBiliCommand, cid?: bigint): UniDM;
278
- static fromDplayer(args: DMDplayer, playerID: string, domain: string): UniDM;
282
+ static fromBiliCommand(args: DMBiliCommand, cid?: bigint, options?: Options): UniDM;
283
+ static fromDplayer(args: DMDplayer, playerID: string, domain: string, options?: Options): UniDM;
279
284
  toDplayer(): DMDplayer;
280
- static fromArtplayer(args: DMArtplayer, playerID: string, domain: string): UniDM;
285
+ static fromArtplayer(args: DMArtplayer, playerID: string, domain: string, options?: Options): UniDM;
281
286
  toArtplayer(): DMArtplayer;
282
- static fromDDplay(args: DMDDplay, episodeId: string, domain?: PlatformDanmakuOnlySource): UniDM;
287
+ static fromDDplay(args: DMDDplay, episodeId: string, domain?: PlatformDanmakuOnlySource, options?: Options): UniDM;
283
288
  toDDplay(): DMDDplay;
284
289
  }
285
290
  export {};
@@ -46,4 +46,5 @@ export declare class UniID {
46
46
  */
47
47
  domain: PlatformSource | string): UniID;
48
48
  }
49
- export declare function createDMID(content: string | undefined, senderID: string, ctime: ctime, extraStr?: string, slice?: number): string;
49
+ export type DMIDGenerator = (content?: string, senderID?: string, ctime?: ctime, extraStr?: string, slice?: number) => string;
50
+ export declare function createDMID(content?: string, senderID?: string, ctime?: ctime, extraStr?: string, slice?: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dan-uni/dan-any",
3
- "version": "0.6.9",
3
+ "version": "0.7.4",
4
4
  "description": "A danmaku transformer lib, supporting danmaku from different platforms.",
5
5
  "keywords": [
6
6
  "bangumi",
@@ -44,7 +44,7 @@
44
44
  "reflect-metadata": "^0.2.2"
45
45
  },
46
46
  "devDependencies": {
47
- "@bufbuild/buf": "^1.55.1",
47
+ "@bufbuild/buf": "^1.56.0",
48
48
  "@bufbuild/protoc-gen-es": "^2.6.2",
49
49
  "@types/fs-extra": "^11.0.4",
50
50
  "@types/hh-mm-ss": "^1.2.3",