@dan-uni/dan-any 0.6.6 → 0.6.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/dist/index.js +11 -10
- package/dist/index.umd.min.js +11 -10
- package/dist/src/utils/dm-gen.d.ts +3 -1
- package/package.json +1 -1
- package/src/index.ts +6 -4
- package/src/utils/dm-gen.ts +6 -2
package/dist/index.js
CHANGED
|
@@ -300,9 +300,9 @@ class UniDM {
|
|
|
300
300
|
toDMID() {
|
|
301
301
|
return createDMID(this.content, this.senderID, this.ctime, this.extraStr);
|
|
302
302
|
}
|
|
303
|
-
isSameAs(dan) {
|
|
303
|
+
isSameAs(dan, options) {
|
|
304
304
|
if (4 === this.mode || 4 === dan.mode) return false;
|
|
305
|
-
if (this.extra.danuni?.merge || dan.extra.danuni?.merge) return false;
|
|
305
|
+
if (!options?.skipDanuniMerge && (this.extra.danuni?.merge || dan.extra.danuni?.merge)) return false;
|
|
306
306
|
const isSame = (k)=>this[k] === dan[k], checks = [
|
|
307
307
|
'SOID',
|
|
308
308
|
'content',
|
|
@@ -779,6 +779,7 @@ _ts_decorate([
|
|
|
779
779
|
Expose(),
|
|
780
780
|
_ts_metadata("design:type", Function),
|
|
781
781
|
_ts_metadata("design:paramtypes", [
|
|
782
|
+
Object,
|
|
782
783
|
Object
|
|
783
784
|
]),
|
|
784
785
|
_ts_metadata("design:returntype", Boolean)
|
|
@@ -1017,7 +1018,6 @@ class UniPool {
|
|
|
1017
1018
|
if (lifetime <= 0) return this;
|
|
1018
1019
|
const mergeContext = this.dans.reduce(([result, cache, mergeObj], danmaku)=>{
|
|
1019
1020
|
const key = [
|
|
1020
|
-
'SOID',
|
|
1021
1021
|
'content',
|
|
1022
1022
|
'mode',
|
|
1023
1023
|
'platform',
|
|
@@ -1025,14 +1025,16 @@ class UniPool {
|
|
|
1025
1025
|
].map((k)=>danmaku[k]).join('|');
|
|
1026
1026
|
const cached = cache[key];
|
|
1027
1027
|
const lastAppearTime = cached?.progress || 0;
|
|
1028
|
-
if (cached && danmaku.progress - lastAppearTime <= lifetime && danmaku.isSameAs(cached
|
|
1028
|
+
if (cached && danmaku.progress - lastAppearTime <= lifetime && danmaku.isSameAs(cached, {
|
|
1029
|
+
skipDanuniMerge: true
|
|
1030
|
+
})) {
|
|
1029
1031
|
const senders = mergeObj[key].senders;
|
|
1030
1032
|
senders.push(danmaku.senderID);
|
|
1031
1033
|
const extra = danmaku.extra;
|
|
1032
1034
|
extra.danuni = extra.danuni || {};
|
|
1033
1035
|
extra.danuni.merge = {
|
|
1034
1036
|
count: senders.length,
|
|
1035
|
-
duration: danmaku.progress - cached.progress,
|
|
1037
|
+
duration: Number.parseFloat((danmaku.progress - cached.progress).toFixed(3)),
|
|
1036
1038
|
senders,
|
|
1037
1039
|
taolu_count: senders.length,
|
|
1038
1040
|
taolu_senders: senders
|
|
@@ -1078,7 +1080,6 @@ class UniPool {
|
|
|
1078
1080
|
const [result, _cache, mergeObj] = mergeContext;
|
|
1079
1081
|
result.forEach((danmaku, i)=>{
|
|
1080
1082
|
const key = [
|
|
1081
|
-
'SOID',
|
|
1082
1083
|
'content',
|
|
1083
1084
|
'mode',
|
|
1084
1085
|
'platform',
|
|
@@ -1943,7 +1944,6 @@ class src_UniPool {
|
|
|
1943
1944
|
if (lifetime <= 0) return this;
|
|
1944
1945
|
const mergeContext = this.dans.reduce(([result, cache, mergeObj], danmaku)=>{
|
|
1945
1946
|
const key = [
|
|
1946
|
-
'SOID',
|
|
1947
1947
|
'content',
|
|
1948
1948
|
'mode',
|
|
1949
1949
|
'platform',
|
|
@@ -1951,14 +1951,16 @@ class src_UniPool {
|
|
|
1951
1951
|
].map((k)=>danmaku[k]).join('|');
|
|
1952
1952
|
const cached = cache[key];
|
|
1953
1953
|
const lastAppearTime = cached?.progress || 0;
|
|
1954
|
-
if (cached && danmaku.progress - lastAppearTime <= lifetime && danmaku.isSameAs(cached
|
|
1954
|
+
if (cached && danmaku.progress - lastAppearTime <= lifetime && danmaku.isSameAs(cached, {
|
|
1955
|
+
skipDanuniMerge: true
|
|
1956
|
+
})) {
|
|
1955
1957
|
const senders = mergeObj[key].senders;
|
|
1956
1958
|
senders.push(danmaku.senderID);
|
|
1957
1959
|
const extra = danmaku.extra;
|
|
1958
1960
|
extra.danuni = extra.danuni || {};
|
|
1959
1961
|
extra.danuni.merge = {
|
|
1960
1962
|
count: senders.length,
|
|
1961
|
-
duration: danmaku.progress - cached.progress,
|
|
1963
|
+
duration: Number.parseFloat((danmaku.progress - cached.progress).toFixed(3)),
|
|
1962
1964
|
senders,
|
|
1963
1965
|
taolu_count: senders.length,
|
|
1964
1966
|
taolu_senders: senders
|
|
@@ -2004,7 +2006,6 @@ class src_UniPool {
|
|
|
2004
2006
|
const [result, _cache, mergeObj] = mergeContext;
|
|
2005
2007
|
result.forEach((danmaku, i)=>{
|
|
2006
2008
|
const key = [
|
|
2007
|
-
'SOID',
|
|
2008
2009
|
'content',
|
|
2009
2010
|
'mode',
|
|
2010
2011
|
'platform',
|
package/dist/index.umd.min.js
CHANGED
|
@@ -23270,9 +23270,9 @@ and limitations under the License.
|
|
|
23270
23270
|
toDMID() {
|
|
23271
23271
|
return createDMID(this.content, this.senderID, this.ctime, this.extraStr);
|
|
23272
23272
|
}
|
|
23273
|
-
isSameAs(dan) {
|
|
23273
|
+
isSameAs(dan, options) {
|
|
23274
23274
|
if (4 === this.mode || 4 === dan.mode) return false;
|
|
23275
|
-
if (this.extra.danuni?.merge || dan.extra.danuni?.merge) return false;
|
|
23275
|
+
if (!options?.skipDanuniMerge && (this.extra.danuni?.merge || dan.extra.danuni?.merge)) return false;
|
|
23276
23276
|
const isSame = (k)=>this[k] === dan[k], checks = [
|
|
23277
23277
|
'SOID',
|
|
23278
23278
|
'content',
|
|
@@ -23749,6 +23749,7 @@ and limitations under the License.
|
|
|
23749
23749
|
Expose(),
|
|
23750
23750
|
_ts_metadata("design:type", Function),
|
|
23751
23751
|
_ts_metadata("design:paramtypes", [
|
|
23752
|
+
Object,
|
|
23752
23753
|
Object
|
|
23753
23754
|
]),
|
|
23754
23755
|
_ts_metadata("design:returntype", Boolean)
|
|
@@ -23988,7 +23989,6 @@ and limitations under the License.
|
|
|
23988
23989
|
if (lifetime <= 0) return this;
|
|
23989
23990
|
const mergeContext = this.dans.reduce(([result, cache, mergeObj], danmaku)=>{
|
|
23990
23991
|
const key = [
|
|
23991
|
-
'SOID',
|
|
23992
23992
|
'content',
|
|
23993
23993
|
'mode',
|
|
23994
23994
|
'platform',
|
|
@@ -23996,14 +23996,16 @@ and limitations under the License.
|
|
|
23996
23996
|
].map((k)=>danmaku[k]).join('|');
|
|
23997
23997
|
const cached = cache[key];
|
|
23998
23998
|
const lastAppearTime = cached?.progress || 0;
|
|
23999
|
-
if (cached && danmaku.progress - lastAppearTime <= lifetime && danmaku.isSameAs(cached
|
|
23999
|
+
if (cached && danmaku.progress - lastAppearTime <= lifetime && danmaku.isSameAs(cached, {
|
|
24000
|
+
skipDanuniMerge: true
|
|
24001
|
+
})) {
|
|
24000
24002
|
const senders = mergeObj[key].senders;
|
|
24001
24003
|
senders.push(danmaku.senderID);
|
|
24002
24004
|
const extra = danmaku.extra;
|
|
24003
24005
|
extra.danuni = extra.danuni || {};
|
|
24004
24006
|
extra.danuni.merge = {
|
|
24005
24007
|
count: senders.length,
|
|
24006
|
-
duration: danmaku.progress - cached.progress,
|
|
24008
|
+
duration: Number.parseFloat((danmaku.progress - cached.progress).toFixed(3)),
|
|
24007
24009
|
senders,
|
|
24008
24010
|
taolu_count: senders.length,
|
|
24009
24011
|
taolu_senders: senders
|
|
@@ -24049,7 +24051,6 @@ and limitations under the License.
|
|
|
24049
24051
|
const [result, _cache, mergeObj] = mergeContext;
|
|
24050
24052
|
result.forEach((danmaku, i)=>{
|
|
24051
24053
|
const key = [
|
|
24052
|
-
'SOID',
|
|
24053
24054
|
'content',
|
|
24054
24055
|
'mode',
|
|
24055
24056
|
'platform',
|
|
@@ -24919,7 +24920,6 @@ and limitations under the License.
|
|
|
24919
24920
|
if (lifetime <= 0) return this;
|
|
24920
24921
|
const mergeContext = this.dans.reduce(([result, cache, mergeObj], danmaku)=>{
|
|
24921
24922
|
const key = [
|
|
24922
|
-
'SOID',
|
|
24923
24923
|
'content',
|
|
24924
24924
|
'mode',
|
|
24925
24925
|
'platform',
|
|
@@ -24927,14 +24927,16 @@ and limitations under the License.
|
|
|
24927
24927
|
].map((k)=>danmaku[k]).join('|');
|
|
24928
24928
|
const cached = cache[key];
|
|
24929
24929
|
const lastAppearTime = cached?.progress || 0;
|
|
24930
|
-
if (cached && danmaku.progress - lastAppearTime <= lifetime && danmaku.isSameAs(cached
|
|
24930
|
+
if (cached && danmaku.progress - lastAppearTime <= lifetime && danmaku.isSameAs(cached, {
|
|
24931
|
+
skipDanuniMerge: true
|
|
24932
|
+
})) {
|
|
24931
24933
|
const senders = mergeObj[key].senders;
|
|
24932
24934
|
senders.push(danmaku.senderID);
|
|
24933
24935
|
const extra = danmaku.extra;
|
|
24934
24936
|
extra.danuni = extra.danuni || {};
|
|
24935
24937
|
extra.danuni.merge = {
|
|
24936
24938
|
count: senders.length,
|
|
24937
|
-
duration: danmaku.progress - cached.progress,
|
|
24939
|
+
duration: Number.parseFloat((danmaku.progress - cached.progress).toFixed(3)),
|
|
24938
24940
|
senders,
|
|
24939
24941
|
taolu_count: senders.length,
|
|
24940
24942
|
taolu_senders: senders
|
|
@@ -24980,7 +24982,6 @@ and limitations under the License.
|
|
|
24980
24982
|
const [result, _cache, mergeObj] = mergeContext;
|
|
24981
24983
|
result.forEach((danmaku, i)=>{
|
|
24982
24984
|
const key = [
|
|
24983
|
-
'SOID',
|
|
24984
24985
|
'content',
|
|
24985
24986
|
'mode',
|
|
24986
24987
|
'platform',
|
|
@@ -249,7 +249,9 @@ export declare class UniDM {
|
|
|
249
249
|
* @description 同一SOID下唯一
|
|
250
250
|
*/
|
|
251
251
|
toDMID(): string;
|
|
252
|
-
isSameAs(dan: UniDM
|
|
252
|
+
isSameAs(dan: UniDM, options?: {
|
|
253
|
+
skipDanuniMerge?: boolean;
|
|
254
|
+
}): boolean;
|
|
253
255
|
minify(): Partial<UniDMObj> & Pick<UniDMObj, "SOID">;
|
|
254
256
|
downgradeAdvcancedDan({ include, exclude, cleanExtra, }?: {
|
|
255
257
|
include?: (keyof Extra)[];
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -280,7 +280,7 @@ export class UniPool {
|
|
|
280
280
|
]
|
|
281
281
|
>(
|
|
282
282
|
([result, cache, mergeObj], danmaku) => {
|
|
283
|
-
const key = ['
|
|
283
|
+
const key = ['content', 'mode', 'platform', 'pool']
|
|
284
284
|
.map((k) => danmaku[k as keyof UniDM])
|
|
285
285
|
.join('|')
|
|
286
286
|
const cached = cache[key]
|
|
@@ -288,7 +288,7 @@ export class UniPool {
|
|
|
288
288
|
if (
|
|
289
289
|
cached &&
|
|
290
290
|
danmaku.progress - lastAppearTime <= lifetime &&
|
|
291
|
-
danmaku.isSameAs(cached)
|
|
291
|
+
danmaku.isSameAs(cached, { skipDanuniMerge: true })
|
|
292
292
|
) {
|
|
293
293
|
const senders = mergeObj[key].senders
|
|
294
294
|
senders.push(danmaku.senderID)
|
|
@@ -296,7 +296,9 @@ export class UniPool {
|
|
|
296
296
|
extra.danuni = extra.danuni || {}
|
|
297
297
|
extra.danuni.merge = {
|
|
298
298
|
count: senders.length,
|
|
299
|
-
duration:
|
|
299
|
+
duration: Number.parseFloat(
|
|
300
|
+
(danmaku.progress - cached.progress).toFixed(3),
|
|
301
|
+
),
|
|
300
302
|
senders,
|
|
301
303
|
taolu_count: senders.length,
|
|
302
304
|
taolu_senders: senders,
|
|
@@ -328,7 +330,7 @@ export class UniPool {
|
|
|
328
330
|
// 处理结果,删除senders<=1的merge字段
|
|
329
331
|
const [result, _cache, mergeObj] = mergeContext
|
|
330
332
|
result.forEach((danmaku, i) => {
|
|
331
|
-
const key = ['
|
|
333
|
+
const key = ['content', 'mode', 'platform', 'pool']
|
|
332
334
|
.map((k) => danmaku[k as keyof UniDM])
|
|
333
335
|
.join('|')
|
|
334
336
|
const extra = result[i].extra,
|
package/src/utils/dm-gen.ts
CHANGED
|
@@ -540,11 +540,15 @@ export class UniDM {
|
|
|
540
540
|
return createDMID(this.content, this.senderID, this.ctime, this.extraStr)
|
|
541
541
|
}
|
|
542
542
|
@Expose()
|
|
543
|
-
isSameAs(dan: UniDM): boolean {
|
|
543
|
+
isSameAs(dan: UniDM, options?: { skipDanuniMerge?: boolean }): boolean {
|
|
544
544
|
// 不支持比较高级弹幕
|
|
545
545
|
if (this.mode === Modes.Ext || dan.mode === Modes.Ext) return false
|
|
546
546
|
// 合并过视为不同,防止存在合并完成弹幕后再次合并造成计数错误
|
|
547
|
-
if (
|
|
547
|
+
if (
|
|
548
|
+
!options?.skipDanuniMerge &&
|
|
549
|
+
(this.extra.danuni?.merge || dan.extra.danuni?.merge)
|
|
550
|
+
)
|
|
551
|
+
return false
|
|
548
552
|
const isSame = (k: keyof UniDMObj) => this[k] === dan[k],
|
|
549
553
|
checks = (
|
|
550
554
|
[
|