@dan-uni/dan-any 1.2.5 → 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.
- package/dist/browser/17.min.js +27 -14
- package/dist/browser/index.min.js +1 -1
- package/dist/browser/src/index.d.ts +12 -1
- package/dist/node/17.js +27 -14
- package/dist/node/index.js +1 -1
- package/dist/node/src/index.d.ts +12 -1
- package/dist/umd/index.umd.min.js +36 -18
- package/dist/umd/plugins/bili.umd.min.js +22 -18
- package/dist/umd/plugins/index.umd.min.js +22 -18
- package/dist/umd/src/index.d.ts +12 -1
- package/package.json +3 -3
- package/src/index.ts +25 -21
- package/src/utils/dm-gen.ts +2 -2
package/dist/browser/17.min.js
CHANGED
|
@@ -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.2.
|
|
11464
|
+
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"}');
|
|
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;
|
|
@@ -11776,7 +11776,7 @@ class UniDM {
|
|
|
11776
11776
|
if (this.attr.length > 0) result.attr = this.attr;
|
|
11777
11777
|
if (void 0 !== this.platform) result.platform = this.platform;
|
|
11778
11778
|
if (this.extraStr && '{}' !== this.extraStr) result.extraStr = this.extraStr;
|
|
11779
|
-
if (void 0 !== this.DMID) result.DMID = this.DMID;
|
|
11779
|
+
if (void 0 !== this.DMID && this.options.dmid) result.DMID = this.DMID;
|
|
11780
11780
|
return result;
|
|
11781
11781
|
}
|
|
11782
11782
|
downgradeAdvcancedDan({ include, exclude, cleanExtra = false } = {}) {
|
|
@@ -11892,7 +11892,7 @@ class UniDM {
|
|
|
11892
11892
|
}) ? args.midHash : id_gen_UniID.fromBili({
|
|
11893
11893
|
midHash: args.midHash
|
|
11894
11894
|
});
|
|
11895
|
-
let mode
|
|
11895
|
+
let mode;
|
|
11896
11896
|
const pool = args.pool;
|
|
11897
11897
|
const extra = {
|
|
11898
11898
|
bili: {
|
|
@@ -12729,6 +12729,19 @@ const DanUniConvertTipTemplate = {
|
|
|
12729
12729
|
meassage: 'Converted by DanUni!',
|
|
12730
12730
|
version: `JS/TS ${package_namespaceObject.UU} (v${package_namespaceObject.rE})`
|
|
12731
12731
|
};
|
|
12732
|
+
var src_DM_format = /*#__PURE__*/ function(DM_format) {
|
|
12733
|
+
DM_format["DanuniJson"] = "danuni.json";
|
|
12734
|
+
DM_format["DanuniPbBin"] = "danuni.pb.bin";
|
|
12735
|
+
DM_format["BiliXml"] = "bili.xml";
|
|
12736
|
+
DM_format["BiliPbBin"] = "bili.pb.bin";
|
|
12737
|
+
DM_format["BiliCmdPbBin"] = "bili.cmd.pb.bin";
|
|
12738
|
+
DM_format["BiliUpJson"] = "bili.up.json";
|
|
12739
|
+
DM_format["DplayerJson"] = "dplayer.json";
|
|
12740
|
+
DM_format["ArtplayerJson"] = "artplayer.json";
|
|
12741
|
+
DM_format["DdplayJson"] = "ddplay.json";
|
|
12742
|
+
DM_format["CommonAss"] = "common.ass";
|
|
12743
|
+
return DM_format;
|
|
12744
|
+
}({});
|
|
12732
12745
|
class UniPool {
|
|
12733
12746
|
constructor(dans, options = {}, info = {
|
|
12734
12747
|
fromConverted: false
|
|
@@ -12951,23 +12964,23 @@ class UniPool {
|
|
|
12951
12964
|
try {
|
|
12952
12965
|
if (Array.isArray(json) && json.every((d)=>d.SOID)) return {
|
|
12953
12966
|
pool: new UniPool(json, options),
|
|
12954
|
-
fmt:
|
|
12967
|
+
fmt: "danuni.json"
|
|
12955
12968
|
};
|
|
12956
12969
|
if (json.danmuku && json.danmuku.every((d)=>d.text)) return {
|
|
12957
12970
|
pool: this.fromArtplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
12958
|
-
fmt:
|
|
12971
|
+
fmt: "artplayer.json"
|
|
12959
12972
|
};
|
|
12960
12973
|
if (json.count && json.comments && Array.isArray(json.comments) && json.comments.every((d)=>d.m)) return {
|
|
12961
12974
|
pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
|
|
12962
|
-
fmt:
|
|
12975
|
+
fmt: "ddplay.json"
|
|
12963
12976
|
};
|
|
12964
12977
|
else if (0 == json.code && json.data && Array.isArray(json.data) && json.data.every((d)=>Array.isArray(d))) return {
|
|
12965
12978
|
pool: this.fromDplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
12966
|
-
fmt:
|
|
12979
|
+
fmt: "dplayer.json"
|
|
12967
12980
|
};
|
|
12968
12981
|
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 {
|
|
12969
12982
|
pool: this.fromBiliUp(json, options),
|
|
12970
|
-
fmt:
|
|
12983
|
+
fmt: "bili.up.json"
|
|
12971
12984
|
};
|
|
12972
12985
|
} catch {}
|
|
12973
12986
|
};
|
|
@@ -12986,13 +12999,13 @@ class UniPool {
|
|
|
12986
12999
|
const xml = xmlParser.parse(file);
|
|
12987
13000
|
if (xml?.i?.d) return {
|
|
12988
13001
|
pool: this.fromBiliXML(file, options),
|
|
12989
|
-
fmt:
|
|
13002
|
+
fmt: "bili.xml"
|
|
12990
13003
|
};
|
|
12991
13004
|
} catch {}
|
|
12992
13005
|
try {
|
|
12993
13006
|
return {
|
|
12994
13007
|
pool: this.fromASS(file, options),
|
|
12995
|
-
fmt:
|
|
13008
|
+
fmt: "common.ass"
|
|
12996
13009
|
};
|
|
12997
13010
|
} catch {}
|
|
12998
13011
|
}
|
|
@@ -13004,19 +13017,19 @@ class UniPool {
|
|
|
13004
13017
|
try {
|
|
13005
13018
|
return {
|
|
13006
13019
|
pool: this.fromPb(file),
|
|
13007
|
-
fmt:
|
|
13020
|
+
fmt: "danuni.pb.bin"
|
|
13008
13021
|
};
|
|
13009
13022
|
} catch {}
|
|
13010
13023
|
try {
|
|
13011
13024
|
return {
|
|
13012
13025
|
pool: this.fromBiliGrpc(file),
|
|
13013
|
-
fmt:
|
|
13026
|
+
fmt: "bili.pb.bin"
|
|
13014
13027
|
};
|
|
13015
13028
|
} catch {}
|
|
13016
13029
|
try {
|
|
13017
13030
|
return {
|
|
13018
13031
|
pool: this.fromBiliCommandGrpc(file),
|
|
13019
|
-
fmt:
|
|
13032
|
+
fmt: "bili.cmd.pb.bin"
|
|
13020
13033
|
};
|
|
13021
13034
|
} catch {}
|
|
13022
13035
|
}
|
|
@@ -13283,4 +13296,4 @@ class UniPool {
|
|
|
13283
13296
|
}, canvasCtx);
|
|
13284
13297
|
}
|
|
13285
13298
|
}
|
|
13286
|
-
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform };
|
|
13299
|
+
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform, src_DM_format as DM_format };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.min.js";
|
|
1
|
+
export { DM_format, UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.min.js";
|
|
@@ -116,7 +116,18 @@ export interface DM_JSON_DDPlay {
|
|
|
116
116
|
m: string;
|
|
117
117
|
}[];
|
|
118
118
|
}
|
|
119
|
-
export
|
|
119
|
+
export declare enum DM_format {
|
|
120
|
+
DanuniJson = "danuni.json",
|
|
121
|
+
DanuniPbBin = "danuni.pb.bin",
|
|
122
|
+
BiliXml = "bili.xml",
|
|
123
|
+
BiliPbBin = "bili.pb.bin",
|
|
124
|
+
BiliCmdPbBin = "bili.cmd.pb.bin",
|
|
125
|
+
BiliUpJson = "bili.up.json",
|
|
126
|
+
DplayerJson = "dplayer.json",
|
|
127
|
+
ArtplayerJson = "artplayer.json",
|
|
128
|
+
DdplayJson = "ddplay.json",
|
|
129
|
+
CommonAss = "common.ass"
|
|
130
|
+
}
|
|
120
131
|
type shareItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'>>;
|
|
121
132
|
type statItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'mode' | 'fontsize' | 'color' | 'senderID' | 'content' | 'weight' | 'pool' | 'platform'>>;
|
|
122
133
|
type Stats<T extends keyof statItems> = Map<statItems[T], number>;
|
package/dist/node/17.js
CHANGED
|
@@ -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.2.
|
|
42
|
+
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"}');
|
|
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;
|
|
@@ -353,7 +353,7 @@ class UniDM {
|
|
|
353
353
|
if (this.attr.length > 0) result.attr = this.attr;
|
|
354
354
|
if (void 0 !== this.platform) result.platform = this.platform;
|
|
355
355
|
if (this.extraStr && '{}' !== this.extraStr) result.extraStr = this.extraStr;
|
|
356
|
-
if (void 0 !== this.DMID) result.DMID = this.DMID;
|
|
356
|
+
if (void 0 !== this.DMID && this.options.dmid) result.DMID = this.DMID;
|
|
357
357
|
return result;
|
|
358
358
|
}
|
|
359
359
|
downgradeAdvcancedDan({ include, exclude, cleanExtra = false } = {}) {
|
|
@@ -469,7 +469,7 @@ class UniDM {
|
|
|
469
469
|
}) ? args.midHash : id_gen_UniID.fromBili({
|
|
470
470
|
midHash: args.midHash
|
|
471
471
|
});
|
|
472
|
-
let mode
|
|
472
|
+
let mode;
|
|
473
473
|
const pool = args.pool;
|
|
474
474
|
const extra = {
|
|
475
475
|
bili: {
|
|
@@ -1304,6 +1304,19 @@ const DanUniConvertTipTemplate = {
|
|
|
1304
1304
|
meassage: 'Converted by DanUni!',
|
|
1305
1305
|
version: `JS/TS ${package_namespaceObject.UU} (v${package_namespaceObject.rE})`
|
|
1306
1306
|
};
|
|
1307
|
+
var src_DM_format = /*#__PURE__*/ function(DM_format) {
|
|
1308
|
+
DM_format["DanuniJson"] = "danuni.json";
|
|
1309
|
+
DM_format["DanuniPbBin"] = "danuni.pb.bin";
|
|
1310
|
+
DM_format["BiliXml"] = "bili.xml";
|
|
1311
|
+
DM_format["BiliPbBin"] = "bili.pb.bin";
|
|
1312
|
+
DM_format["BiliCmdPbBin"] = "bili.cmd.pb.bin";
|
|
1313
|
+
DM_format["BiliUpJson"] = "bili.up.json";
|
|
1314
|
+
DM_format["DplayerJson"] = "dplayer.json";
|
|
1315
|
+
DM_format["ArtplayerJson"] = "artplayer.json";
|
|
1316
|
+
DM_format["DdplayJson"] = "ddplay.json";
|
|
1317
|
+
DM_format["CommonAss"] = "common.ass";
|
|
1318
|
+
return DM_format;
|
|
1319
|
+
}({});
|
|
1307
1320
|
class UniPool {
|
|
1308
1321
|
constructor(dans, options = {}, info = {
|
|
1309
1322
|
fromConverted: false
|
|
@@ -1526,23 +1539,23 @@ class UniPool {
|
|
|
1526
1539
|
try {
|
|
1527
1540
|
if (Array.isArray(json) && json.every((d)=>d.SOID)) return {
|
|
1528
1541
|
pool: new UniPool(json, options),
|
|
1529
|
-
fmt:
|
|
1542
|
+
fmt: "danuni.json"
|
|
1530
1543
|
};
|
|
1531
1544
|
if (json.danmuku && json.danmuku.every((d)=>d.text)) return {
|
|
1532
1545
|
pool: this.fromArtplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
1533
|
-
fmt:
|
|
1546
|
+
fmt: "artplayer.json"
|
|
1534
1547
|
};
|
|
1535
1548
|
if (json.count && json.comments && Array.isArray(json.comments) && json.comments.every((d)=>d.m)) return {
|
|
1536
1549
|
pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
|
|
1537
|
-
fmt:
|
|
1550
|
+
fmt: "ddplay.json"
|
|
1538
1551
|
};
|
|
1539
1552
|
else if (0 == json.code && json.data && Array.isArray(json.data) && json.data.every((d)=>Array.isArray(d))) return {
|
|
1540
1553
|
pool: this.fromDplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
1541
|
-
fmt:
|
|
1554
|
+
fmt: "dplayer.json"
|
|
1542
1555
|
};
|
|
1543
1556
|
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 {
|
|
1544
1557
|
pool: this.fromBiliUp(json, options),
|
|
1545
|
-
fmt:
|
|
1558
|
+
fmt: "bili.up.json"
|
|
1546
1559
|
};
|
|
1547
1560
|
} catch {}
|
|
1548
1561
|
};
|
|
@@ -1561,13 +1574,13 @@ class UniPool {
|
|
|
1561
1574
|
const xml = xmlParser.parse(file);
|
|
1562
1575
|
if (xml?.i?.d) return {
|
|
1563
1576
|
pool: this.fromBiliXML(file, options),
|
|
1564
|
-
fmt:
|
|
1577
|
+
fmt: "bili.xml"
|
|
1565
1578
|
};
|
|
1566
1579
|
} catch {}
|
|
1567
1580
|
try {
|
|
1568
1581
|
return {
|
|
1569
1582
|
pool: this.fromASS(file, options),
|
|
1570
|
-
fmt:
|
|
1583
|
+
fmt: "common.ass"
|
|
1571
1584
|
};
|
|
1572
1585
|
} catch {}
|
|
1573
1586
|
}
|
|
@@ -1579,19 +1592,19 @@ class UniPool {
|
|
|
1579
1592
|
try {
|
|
1580
1593
|
return {
|
|
1581
1594
|
pool: this.fromPb(file),
|
|
1582
|
-
fmt:
|
|
1595
|
+
fmt: "danuni.pb.bin"
|
|
1583
1596
|
};
|
|
1584
1597
|
} catch {}
|
|
1585
1598
|
try {
|
|
1586
1599
|
return {
|
|
1587
1600
|
pool: this.fromBiliGrpc(file),
|
|
1588
|
-
fmt:
|
|
1601
|
+
fmt: "bili.pb.bin"
|
|
1589
1602
|
};
|
|
1590
1603
|
} catch {}
|
|
1591
1604
|
try {
|
|
1592
1605
|
return {
|
|
1593
1606
|
pool: this.fromBiliCommandGrpc(file),
|
|
1594
|
-
fmt:
|
|
1607
|
+
fmt: "bili.cmd.pb.bin"
|
|
1595
1608
|
};
|
|
1596
1609
|
} catch {}
|
|
1597
1610
|
}
|
|
@@ -1858,4 +1871,4 @@ class UniPool {
|
|
|
1858
1871
|
}, canvasCtx);
|
|
1859
1872
|
}
|
|
1860
1873
|
}
|
|
1861
|
-
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform };
|
|
1874
|
+
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform, src_DM_format as DM_format };
|
package/dist/node/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.js";
|
|
1
|
+
export { DM_format, UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.js";
|
package/dist/node/src/index.d.ts
CHANGED
|
@@ -116,7 +116,18 @@ export interface DM_JSON_DDPlay {
|
|
|
116
116
|
m: string;
|
|
117
117
|
}[];
|
|
118
118
|
}
|
|
119
|
-
export
|
|
119
|
+
export declare enum DM_format {
|
|
120
|
+
DanuniJson = "danuni.json",
|
|
121
|
+
DanuniPbBin = "danuni.pb.bin",
|
|
122
|
+
BiliXml = "bili.xml",
|
|
123
|
+
BiliPbBin = "bili.pb.bin",
|
|
124
|
+
BiliCmdPbBin = "bili.cmd.pb.bin",
|
|
125
|
+
BiliUpJson = "bili.up.json",
|
|
126
|
+
DplayerJson = "dplayer.json",
|
|
127
|
+
ArtplayerJson = "artplayer.json",
|
|
128
|
+
DdplayJson = "ddplay.json",
|
|
129
|
+
CommonAss = "common.ass"
|
|
130
|
+
}
|
|
120
131
|
type shareItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'>>;
|
|
121
132
|
type statItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'mode' | 'fontsize' | 'color' | 'senderID' | 'content' | 'weight' | 'pool' | 'platform'>>;
|
|
122
133
|
type Stats<T extends keyof statItems> = Map<statItems[T], number>;
|
|
@@ -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("&"))
|
|
14758
|
-
|
|
14759
|
-
|
|
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);
|
|
@@ -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("&" +
|
|
15149
|
+
regex: new RegExp("&" + escaped + ";", "g"),
|
|
15145
15150
|
val: externalEntities[ent]
|
|
15146
15151
|
};
|
|
15147
15152
|
}
|
|
@@ -21048,7 +21053,7 @@ and limitations under the License.
|
|
|
21048
21053
|
function timestamp_timestampMs(timestamp) {
|
|
21049
21054
|
return 1000 * Number(timestamp.seconds) + Math.round(timestamp.nanos / 1000000);
|
|
21050
21055
|
}
|
|
21051
|
-
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.
|
|
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"}');
|
|
21052
21057
|
const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
|
|
21053
21058
|
const decimalToHex = (n)=>color_pad(n.toString(16));
|
|
21054
21059
|
const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
|
|
@@ -23533,7 +23538,7 @@ and limitations under the License.
|
|
|
23533
23538
|
if (this.attr.length > 0) result.attr = this.attr;
|
|
23534
23539
|
if (void 0 !== this.platform) result.platform = this.platform;
|
|
23535
23540
|
if (this.extraStr && '{}' !== this.extraStr) result.extraStr = this.extraStr;
|
|
23536
|
-
if (void 0 !== this.DMID) result.DMID = this.DMID;
|
|
23541
|
+
if (void 0 !== this.DMID && this.options.dmid) result.DMID = this.DMID;
|
|
23537
23542
|
return result;
|
|
23538
23543
|
}
|
|
23539
23544
|
downgradeAdvcancedDan({ include, exclude, cleanExtra = false } = {}) {
|
|
@@ -23649,7 +23654,7 @@ and limitations under the License.
|
|
|
23649
23654
|
}) ? args.midHash : id_gen_UniID.fromBili({
|
|
23650
23655
|
midHash: args.midHash
|
|
23651
23656
|
});
|
|
23652
|
-
let mode
|
|
23657
|
+
let mode;
|
|
23653
23658
|
const pool = args.pool;
|
|
23654
23659
|
const extra = {
|
|
23655
23660
|
bili: {
|
|
@@ -24487,6 +24492,19 @@ and limitations under the License.
|
|
|
24487
24492
|
meassage: 'Converted by DanUni!',
|
|
24488
24493
|
version: `JS/TS ${package_namespaceObject.UU} (v${package_namespaceObject.rE})`
|
|
24489
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
|
+
}({});
|
|
24490
24508
|
class UniPool {
|
|
24491
24509
|
constructor(dans, options = {}, info = {
|
|
24492
24510
|
fromConverted: false
|
|
@@ -24709,23 +24727,23 @@ and limitations under the License.
|
|
|
24709
24727
|
try {
|
|
24710
24728
|
if (Array.isArray(json) && json.every((d)=>d.SOID)) return {
|
|
24711
24729
|
pool: new UniPool(json, options),
|
|
24712
|
-
fmt:
|
|
24730
|
+
fmt: "danuni.json"
|
|
24713
24731
|
};
|
|
24714
24732
|
if (json.danmuku && json.danmuku.every((d)=>d.text)) return {
|
|
24715
24733
|
pool: this.fromArtplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
24716
|
-
fmt:
|
|
24734
|
+
fmt: "artplayer.json"
|
|
24717
24735
|
};
|
|
24718
24736
|
if (json.count && json.comments && Array.isArray(json.comments) && json.comments.every((d)=>d.m)) return {
|
|
24719
24737
|
pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
|
|
24720
|
-
fmt:
|
|
24738
|
+
fmt: "ddplay.json"
|
|
24721
24739
|
};
|
|
24722
24740
|
else if (0 == json.code && json.data && Array.isArray(json.data) && json.data.every((d)=>Array.isArray(d))) return {
|
|
24723
24741
|
pool: this.fromDplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
24724
|
-
fmt:
|
|
24742
|
+
fmt: "dplayer.json"
|
|
24725
24743
|
};
|
|
24726
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 {
|
|
24727
24745
|
pool: this.fromBiliUp(json, options),
|
|
24728
|
-
fmt:
|
|
24746
|
+
fmt: "bili.up.json"
|
|
24729
24747
|
};
|
|
24730
24748
|
} catch {}
|
|
24731
24749
|
};
|
|
@@ -24744,13 +24762,13 @@ and limitations under the License.
|
|
|
24744
24762
|
const xml = xmlParser.parse(file);
|
|
24745
24763
|
if (xml?.i?.d) return {
|
|
24746
24764
|
pool: this.fromBiliXML(file, options),
|
|
24747
|
-
fmt:
|
|
24765
|
+
fmt: "bili.xml"
|
|
24748
24766
|
};
|
|
24749
24767
|
} catch {}
|
|
24750
24768
|
try {
|
|
24751
24769
|
return {
|
|
24752
24770
|
pool: this.fromASS(file, options),
|
|
24753
|
-
fmt:
|
|
24771
|
+
fmt: "common.ass"
|
|
24754
24772
|
};
|
|
24755
24773
|
} catch {}
|
|
24756
24774
|
}
|
|
@@ -24762,19 +24780,19 @@ and limitations under the License.
|
|
|
24762
24780
|
try {
|
|
24763
24781
|
return {
|
|
24764
24782
|
pool: this.fromPb(file),
|
|
24765
|
-
fmt:
|
|
24783
|
+
fmt: "danuni.pb.bin"
|
|
24766
24784
|
};
|
|
24767
24785
|
} catch {}
|
|
24768
24786
|
try {
|
|
24769
24787
|
return {
|
|
24770
24788
|
pool: this.fromBiliGrpc(file),
|
|
24771
|
-
fmt:
|
|
24789
|
+
fmt: "bili.pb.bin"
|
|
24772
24790
|
};
|
|
24773
24791
|
} catch {}
|
|
24774
24792
|
try {
|
|
24775
24793
|
return {
|
|
24776
24794
|
pool: this.fromBiliCommandGrpc(file),
|
|
24777
|
-
fmt:
|
|
24795
|
+
fmt: "bili.cmd.pb.bin"
|
|
24778
24796
|
};
|
|
24779
24797
|
} catch {}
|
|
24780
24798
|
}
|
|
@@ -14045,10 +14045,13 @@
|
|
|
14045
14045
|
i += 7;
|
|
14046
14046
|
let entityName, val;
|
|
14047
14047
|
[entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
|
|
14048
|
-
if (-1 === val.indexOf("&"))
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14048
|
+
if (-1 === val.indexOf("&")) {
|
|
14049
|
+
const escaped = entityName.replace(/[.\-+*:]/g, '\\.');
|
|
14050
|
+
entities[entityName] = {
|
|
14051
|
+
regx: RegExp(`&${escaped};`, "g"),
|
|
14052
|
+
val: val
|
|
14053
|
+
};
|
|
14054
|
+
}
|
|
14052
14055
|
} else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
|
|
14053
14056
|
i += 8;
|
|
14054
14057
|
const { index } = this.readElementExp(xmlData, i + 1);
|
|
@@ -14431,8 +14434,9 @@
|
|
|
14431
14434
|
const entKeys = Object.keys(externalEntities);
|
|
14432
14435
|
for(let i = 0; i < entKeys.length; i++){
|
|
14433
14436
|
const ent = entKeys[i];
|
|
14437
|
+
const escaped = ent.replace(/[.\-+*:]/g, '\\.');
|
|
14434
14438
|
this.lastEntities[ent] = {
|
|
14435
|
-
regex: new RegExp("&" +
|
|
14439
|
+
regex: new RegExp("&" + escaped + ";", "g"),
|
|
14436
14440
|
val: externalEntities[ent]
|
|
14437
14441
|
};
|
|
14438
14442
|
}
|
|
@@ -20339,7 +20343,7 @@
|
|
|
20339
20343
|
function timestamp_timestampMs(timestamp) {
|
|
20340
20344
|
return 1000 * Number(timestamp.seconds) + Math.round(timestamp.nanos / 1000000);
|
|
20341
20345
|
}
|
|
20342
|
-
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.
|
|
20346
|
+
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"}');
|
|
20343
20347
|
const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
|
|
20344
20348
|
const decimalToHex = (n)=>color_pad(n.toString(16));
|
|
20345
20349
|
const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
|
|
@@ -22804,7 +22808,7 @@
|
|
|
22804
22808
|
if (this.attr.length > 0) result.attr = this.attr;
|
|
22805
22809
|
if (void 0 !== this.platform) result.platform = this.platform;
|
|
22806
22810
|
if (this.extraStr && '{}' !== this.extraStr) result.extraStr = this.extraStr;
|
|
22807
|
-
if (void 0 !== this.DMID) result.DMID = this.DMID;
|
|
22811
|
+
if (void 0 !== this.DMID && this.options.dmid) result.DMID = this.DMID;
|
|
22808
22812
|
return result;
|
|
22809
22813
|
}
|
|
22810
22814
|
downgradeAdvcancedDan({ include, exclude, cleanExtra = false } = {}) {
|
|
@@ -22920,7 +22924,7 @@
|
|
|
22920
22924
|
}) ? args.midHash : id_gen_UniID.fromBili({
|
|
22921
22925
|
midHash: args.midHash
|
|
22922
22926
|
});
|
|
22923
|
-
let mode
|
|
22927
|
+
let mode;
|
|
22924
22928
|
const pool = args.pool;
|
|
22925
22929
|
const extra = {
|
|
22926
22930
|
bili: {
|
|
@@ -23980,23 +23984,23 @@
|
|
|
23980
23984
|
try {
|
|
23981
23985
|
if (Array.isArray(json) && json.every((d)=>d.SOID)) return {
|
|
23982
23986
|
pool: new UniPool(json, options),
|
|
23983
|
-
fmt:
|
|
23987
|
+
fmt: "danuni.json"
|
|
23984
23988
|
};
|
|
23985
23989
|
if (json.danmuku && json.danmuku.every((d)=>d.text)) return {
|
|
23986
23990
|
pool: this.fromArtplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
23987
|
-
fmt:
|
|
23991
|
+
fmt: "artplayer.json"
|
|
23988
23992
|
};
|
|
23989
23993
|
if (json.count && json.comments && Array.isArray(json.comments) && json.comments.every((d)=>d.m)) return {
|
|
23990
23994
|
pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
|
|
23991
|
-
fmt:
|
|
23995
|
+
fmt: "ddplay.json"
|
|
23992
23996
|
};
|
|
23993
23997
|
else if (0 == json.code && json.data && Array.isArray(json.data) && json.data.every((d)=>Array.isArray(d))) return {
|
|
23994
23998
|
pool: this.fromDplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
23995
|
-
fmt:
|
|
23999
|
+
fmt: "dplayer.json"
|
|
23996
24000
|
};
|
|
23997
24001
|
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 {
|
|
23998
24002
|
pool: this.fromBiliUp(json, options),
|
|
23999
|
-
fmt:
|
|
24003
|
+
fmt: "bili.up.json"
|
|
24000
24004
|
};
|
|
24001
24005
|
} catch {}
|
|
24002
24006
|
};
|
|
@@ -24015,13 +24019,13 @@
|
|
|
24015
24019
|
const xml = xmlParser.parse(file);
|
|
24016
24020
|
if (xml?.i?.d) return {
|
|
24017
24021
|
pool: this.fromBiliXML(file, options),
|
|
24018
|
-
fmt:
|
|
24022
|
+
fmt: "bili.xml"
|
|
24019
24023
|
};
|
|
24020
24024
|
} catch {}
|
|
24021
24025
|
try {
|
|
24022
24026
|
return {
|
|
24023
24027
|
pool: this.fromASS(file, options),
|
|
24024
|
-
fmt:
|
|
24028
|
+
fmt: "common.ass"
|
|
24025
24029
|
};
|
|
24026
24030
|
} catch {}
|
|
24027
24031
|
}
|
|
@@ -24033,19 +24037,19 @@
|
|
|
24033
24037
|
try {
|
|
24034
24038
|
return {
|
|
24035
24039
|
pool: this.fromPb(file),
|
|
24036
|
-
fmt:
|
|
24040
|
+
fmt: "danuni.pb.bin"
|
|
24037
24041
|
};
|
|
24038
24042
|
} catch {}
|
|
24039
24043
|
try {
|
|
24040
24044
|
return {
|
|
24041
24045
|
pool: this.fromBiliGrpc(file),
|
|
24042
|
-
fmt:
|
|
24046
|
+
fmt: "bili.pb.bin"
|
|
24043
24047
|
};
|
|
24044
24048
|
} catch {}
|
|
24045
24049
|
try {
|
|
24046
24050
|
return {
|
|
24047
24051
|
pool: this.fromBiliCommandGrpc(file),
|
|
24048
|
-
fmt:
|
|
24052
|
+
fmt: "bili.cmd.pb.bin"
|
|
24049
24053
|
};
|
|
24050
24054
|
} catch {}
|
|
24051
24055
|
}
|
|
@@ -14045,10 +14045,13 @@
|
|
|
14045
14045
|
i += 7;
|
|
14046
14046
|
let entityName, val;
|
|
14047
14047
|
[entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
|
|
14048
|
-
if (-1 === val.indexOf("&"))
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14048
|
+
if (-1 === val.indexOf("&")) {
|
|
14049
|
+
const escaped = entityName.replace(/[.\-+*:]/g, '\\.');
|
|
14050
|
+
entities[entityName] = {
|
|
14051
|
+
regx: RegExp(`&${escaped};`, "g"),
|
|
14052
|
+
val: val
|
|
14053
|
+
};
|
|
14054
|
+
}
|
|
14052
14055
|
} else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
|
|
14053
14056
|
i += 8;
|
|
14054
14057
|
const { index } = this.readElementExp(xmlData, i + 1);
|
|
@@ -14431,8 +14434,9 @@
|
|
|
14431
14434
|
const entKeys = Object.keys(externalEntities);
|
|
14432
14435
|
for(let i = 0; i < entKeys.length; i++){
|
|
14433
14436
|
const ent = entKeys[i];
|
|
14437
|
+
const escaped = ent.replace(/[.\-+*:]/g, '\\.');
|
|
14434
14438
|
this.lastEntities[ent] = {
|
|
14435
|
-
regex: new RegExp("&" +
|
|
14439
|
+
regex: new RegExp("&" + escaped + ";", "g"),
|
|
14436
14440
|
val: externalEntities[ent]
|
|
14437
14441
|
};
|
|
14438
14442
|
}
|
|
@@ -20339,7 +20343,7 @@
|
|
|
20339
20343
|
function timestamp_timestampMs(timestamp) {
|
|
20340
20344
|
return 1000 * Number(timestamp.seconds) + Math.round(timestamp.nanos / 1000000);
|
|
20341
20345
|
}
|
|
20342
|
-
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.
|
|
20346
|
+
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"}');
|
|
20343
20347
|
const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
|
|
20344
20348
|
const decimalToHex = (n)=>color_pad(n.toString(16));
|
|
20345
20349
|
const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
|
|
@@ -22804,7 +22808,7 @@
|
|
|
22804
22808
|
if (this.attr.length > 0) result.attr = this.attr;
|
|
22805
22809
|
if (void 0 !== this.platform) result.platform = this.platform;
|
|
22806
22810
|
if (this.extraStr && '{}' !== this.extraStr) result.extraStr = this.extraStr;
|
|
22807
|
-
if (void 0 !== this.DMID) result.DMID = this.DMID;
|
|
22811
|
+
if (void 0 !== this.DMID && this.options.dmid) result.DMID = this.DMID;
|
|
22808
22812
|
return result;
|
|
22809
22813
|
}
|
|
22810
22814
|
downgradeAdvcancedDan({ include, exclude, cleanExtra = false } = {}) {
|
|
@@ -22920,7 +22924,7 @@
|
|
|
22920
22924
|
}) ? args.midHash : id_gen_UniID.fromBili({
|
|
22921
22925
|
midHash: args.midHash
|
|
22922
22926
|
});
|
|
22923
|
-
let mode
|
|
22927
|
+
let mode;
|
|
22924
22928
|
const pool = args.pool;
|
|
22925
22929
|
const extra = {
|
|
22926
22930
|
bili: {
|
|
@@ -23980,23 +23984,23 @@
|
|
|
23980
23984
|
try {
|
|
23981
23985
|
if (Array.isArray(json) && json.every((d)=>d.SOID)) return {
|
|
23982
23986
|
pool: new UniPool(json, options),
|
|
23983
|
-
fmt:
|
|
23987
|
+
fmt: "danuni.json"
|
|
23984
23988
|
};
|
|
23985
23989
|
if (json.danmuku && json.danmuku.every((d)=>d.text)) return {
|
|
23986
23990
|
pool: this.fromArtplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
23987
|
-
fmt:
|
|
23991
|
+
fmt: "artplayer.json"
|
|
23988
23992
|
};
|
|
23989
23993
|
if (json.count && json.comments && Array.isArray(json.comments) && json.comments.every((d)=>d.m)) return {
|
|
23990
23994
|
pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
|
|
23991
|
-
fmt:
|
|
23995
|
+
fmt: "ddplay.json"
|
|
23992
23996
|
};
|
|
23993
23997
|
else if (0 == json.code && json.data && Array.isArray(json.data) && json.data.every((d)=>Array.isArray(d))) return {
|
|
23994
23998
|
pool: this.fromDplayer(json, json.danuni?.data ?? '', void 0, options),
|
|
23995
|
-
fmt:
|
|
23999
|
+
fmt: "dplayer.json"
|
|
23996
24000
|
};
|
|
23997
24001
|
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 {
|
|
23998
24002
|
pool: this.fromBiliUp(json, options),
|
|
23999
|
-
fmt:
|
|
24003
|
+
fmt: "bili.up.json"
|
|
24000
24004
|
};
|
|
24001
24005
|
} catch {}
|
|
24002
24006
|
};
|
|
@@ -24015,13 +24019,13 @@
|
|
|
24015
24019
|
const xml = xmlParser.parse(file);
|
|
24016
24020
|
if (xml?.i?.d) return {
|
|
24017
24021
|
pool: this.fromBiliXML(file, options),
|
|
24018
|
-
fmt:
|
|
24022
|
+
fmt: "bili.xml"
|
|
24019
24023
|
};
|
|
24020
24024
|
} catch {}
|
|
24021
24025
|
try {
|
|
24022
24026
|
return {
|
|
24023
24027
|
pool: this.fromASS(file, options),
|
|
24024
|
-
fmt:
|
|
24028
|
+
fmt: "common.ass"
|
|
24025
24029
|
};
|
|
24026
24030
|
} catch {}
|
|
24027
24031
|
}
|
|
@@ -24033,19 +24037,19 @@
|
|
|
24033
24037
|
try {
|
|
24034
24038
|
return {
|
|
24035
24039
|
pool: this.fromPb(file),
|
|
24036
|
-
fmt:
|
|
24040
|
+
fmt: "danuni.pb.bin"
|
|
24037
24041
|
};
|
|
24038
24042
|
} catch {}
|
|
24039
24043
|
try {
|
|
24040
24044
|
return {
|
|
24041
24045
|
pool: this.fromBiliGrpc(file),
|
|
24042
|
-
fmt:
|
|
24046
|
+
fmt: "bili.pb.bin"
|
|
24043
24047
|
};
|
|
24044
24048
|
} catch {}
|
|
24045
24049
|
try {
|
|
24046
24050
|
return {
|
|
24047
24051
|
pool: this.fromBiliCommandGrpc(file),
|
|
24048
|
-
fmt:
|
|
24052
|
+
fmt: "bili.cmd.pb.bin"
|
|
24049
24053
|
};
|
|
24050
24054
|
} catch {}
|
|
24051
24055
|
}
|
package/dist/umd/src/index.d.ts
CHANGED
|
@@ -116,7 +116,18 @@ export interface DM_JSON_DDPlay {
|
|
|
116
116
|
m: string;
|
|
117
117
|
}[];
|
|
118
118
|
}
|
|
119
|
-
export
|
|
119
|
+
export declare enum DM_format {
|
|
120
|
+
DanuniJson = "danuni.json",
|
|
121
|
+
DanuniPbBin = "danuni.pb.bin",
|
|
122
|
+
BiliXml = "bili.xml",
|
|
123
|
+
BiliPbBin = "bili.pb.bin",
|
|
124
|
+
BiliCmdPbBin = "bili.cmd.pb.bin",
|
|
125
|
+
BiliUpJson = "bili.up.json",
|
|
126
|
+
DplayerJson = "dplayer.json",
|
|
127
|
+
ArtplayerJson = "artplayer.json",
|
|
128
|
+
DdplayJson = "ddplay.json",
|
|
129
|
+
CommonAss = "common.ass"
|
|
130
|
+
}
|
|
120
131
|
type shareItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'>>;
|
|
121
132
|
type statItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'mode' | 'fontsize' | 'color' | 'senderID' | 'content' | 'weight' | 'pool' | 'platform'>>;
|
|
122
133
|
type Stats<T extends keyof statItems> = Map<statItems[T], number>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dan-uni/dan-any",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.7",
|
|
5
5
|
"description": "A danmaku transformer lib, supporting danmaku from different platforms.",
|
|
6
6
|
"author": "rinne",
|
|
7
7
|
"license": "LGPL-3.0-or-later",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"base16384": "^1.0.0",
|
|
37
37
|
"class-transformer": "^0.5.1",
|
|
38
38
|
"class-validator": "^0.14.3",
|
|
39
|
-
"fast-xml-parser": "^5.3.
|
|
39
|
+
"fast-xml-parser": "^5.3.5",
|
|
40
40
|
"fs-extra": "^11.3.3",
|
|
41
41
|
"hh-mm-ss": "^1.2.0",
|
|
42
42
|
"json-bigint": "^1.0.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"reflect-metadata": "^0.2.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@bufbuild/buf": "^1.
|
|
48
|
+
"@bufbuild/buf": "^1.65.0",
|
|
49
49
|
"@bufbuild/protoc-gen-es": "^2.11.0",
|
|
50
50
|
"@types/fs-extra": "^11.0.4",
|
|
51
51
|
"@types/hh-mm-ss": "^1.2.3",
|
package/src/index.ts
CHANGED
|
@@ -151,17 +151,18 @@ export interface DM_JSON_DDPlay {
|
|
|
151
151
|
}[]
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
export
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
154
|
+
export enum DM_format {
|
|
155
|
+
DanuniJson = 'danuni.json',
|
|
156
|
+
DanuniPbBin = 'danuni.pb.bin',
|
|
157
|
+
BiliXml = 'bili.xml',
|
|
158
|
+
BiliPbBin = 'bili.pb.bin',
|
|
159
|
+
BiliCmdPbBin = 'bili.cmd.pb.bin',
|
|
160
|
+
BiliUpJson = 'bili.up.json',
|
|
161
|
+
DplayerJson = 'dplayer.json',
|
|
162
|
+
ArtplayerJson = 'artplayer.json',
|
|
163
|
+
DdplayJson = 'ddplay.json',
|
|
164
|
+
CommonAss = 'common.ass',
|
|
165
|
+
}
|
|
165
166
|
|
|
166
167
|
type shareItems = Partial<
|
|
167
168
|
Pick<
|
|
@@ -460,7 +461,7 @@ export class UniPool {
|
|
|
460
461
|
): { pool: UniPool; fmt: DM_format } | undefined => {
|
|
461
462
|
try {
|
|
462
463
|
if (Array.isArray(json) && json.every((d) => d.SOID)) {
|
|
463
|
-
return { pool: new UniPool(json, options), fmt:
|
|
464
|
+
return { pool: new UniPool(json, options), fmt: DM_format.DanuniJson }
|
|
464
465
|
} else if (json.danmuku && json.danmuku.every((d) => d.text)) {
|
|
465
466
|
return {
|
|
466
467
|
pool: this.fromArtplayer(
|
|
@@ -469,7 +470,7 @@ export class UniPool {
|
|
|
469
470
|
undefined,
|
|
470
471
|
options,
|
|
471
472
|
),
|
|
472
|
-
fmt:
|
|
473
|
+
fmt: DM_format.ArtplayerJson,
|
|
473
474
|
}
|
|
474
475
|
} else if (
|
|
475
476
|
json.count &&
|
|
@@ -479,7 +480,7 @@ export class UniPool {
|
|
|
479
480
|
) {
|
|
480
481
|
return {
|
|
481
482
|
pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
|
|
482
|
-
fmt:
|
|
483
|
+
fmt: DM_format.DdplayJson,
|
|
483
484
|
}
|
|
484
485
|
} else if (
|
|
485
486
|
json.code == 0 &&
|
|
@@ -494,7 +495,7 @@ export class UniPool {
|
|
|
494
495
|
undefined,
|
|
495
496
|
options,
|
|
496
497
|
),
|
|
497
|
-
fmt:
|
|
498
|
+
fmt: DM_format.DplayerJson,
|
|
498
499
|
}
|
|
499
500
|
} else if (
|
|
500
501
|
json.code == 0 &&
|
|
@@ -507,7 +508,7 @@ export class UniPool {
|
|
|
507
508
|
) {
|
|
508
509
|
return {
|
|
509
510
|
pool: this.fromBiliUp(json, options),
|
|
510
|
-
fmt:
|
|
511
|
+
fmt: DM_format.BiliUpJson,
|
|
511
512
|
}
|
|
512
513
|
}
|
|
513
514
|
} catch {}
|
|
@@ -529,10 +530,13 @@ export class UniPool {
|
|
|
529
530
|
const xmlParser = new XMLParser({ ignoreAttributes: false })
|
|
530
531
|
const xml = xmlParser.parse(file)
|
|
531
532
|
if (xml?.i?.d)
|
|
532
|
-
return {
|
|
533
|
+
return {
|
|
534
|
+
pool: this.fromBiliXML(file, options),
|
|
535
|
+
fmt: DM_format.BiliXml,
|
|
536
|
+
}
|
|
533
537
|
} catch {}
|
|
534
538
|
try {
|
|
535
|
-
return { pool: this.fromASS(file, options), fmt:
|
|
539
|
+
return { pool: this.fromASS(file, options), fmt: DM_format.CommonAss }
|
|
536
540
|
} catch {}
|
|
537
541
|
}
|
|
538
542
|
}
|
|
@@ -542,15 +546,15 @@ export class UniPool {
|
|
|
542
546
|
// pure-bin (pb)
|
|
543
547
|
if (mod.includes('bin')) {
|
|
544
548
|
try {
|
|
545
|
-
return { pool: this.fromPb(file), fmt:
|
|
549
|
+
return { pool: this.fromPb(file), fmt: DM_format.DanuniPbBin }
|
|
546
550
|
} catch {}
|
|
547
551
|
try {
|
|
548
|
-
return { pool: this.fromBiliGrpc(file), fmt:
|
|
552
|
+
return { pool: this.fromBiliGrpc(file), fmt: DM_format.BiliPbBin }
|
|
549
553
|
} catch {}
|
|
550
554
|
try {
|
|
551
555
|
return {
|
|
552
556
|
pool: this.fromBiliCommandGrpc(file),
|
|
553
|
-
fmt:
|
|
557
|
+
fmt: DM_format.BiliCmdPbBin,
|
|
554
558
|
}
|
|
555
559
|
} catch {}
|
|
556
560
|
}
|
package/src/utils/dm-gen.ts
CHANGED
|
@@ -626,7 +626,7 @@ export class UniDM {
|
|
|
626
626
|
if (this.attr.length > 0) result.attr = this.attr
|
|
627
627
|
if (this.platform !== undefined) result.platform = this.platform
|
|
628
628
|
if (this.extraStr && this.extraStr !== '{}') result.extraStr = this.extraStr
|
|
629
|
-
if (this.DMID !== undefined) result.DMID = this.DMID
|
|
629
|
+
if (this.DMID !== undefined && this.options.dmid) result.DMID = this.DMID
|
|
630
630
|
return result
|
|
631
631
|
}
|
|
632
632
|
@Expose()
|
|
@@ -791,7 +791,7 @@ export class UniDM {
|
|
|
791
791
|
const senderID = isEmail(args.midHash, { require_tld: false })
|
|
792
792
|
? args.midHash
|
|
793
793
|
: ID.fromBili({ midHash: args.midHash })
|
|
794
|
-
let mode
|
|
794
|
+
let mode: Modes
|
|
795
795
|
const pool = args.pool //暂时不做处理,兼容bili的pool格式
|
|
796
796
|
const extra: TExtra = {
|
|
797
797
|
bili: {
|