@xpadev-net/niconicomments 0.2.68 → 0.2.69
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/bundle.d.ts +263 -71
- package/dist/bundle.js +26 -21
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -961,41 +961,6 @@ export type DefaultCommand = {
|
|
|
961
961
|
font?: CommentFont;
|
|
962
962
|
loc?: CommentLoc;
|
|
963
963
|
};
|
|
964
|
-
export interface IRenderer {
|
|
965
|
-
readonly canvas: HTMLCanvasElement;
|
|
966
|
-
readonly video?: HTMLVideoElement;
|
|
967
|
-
destroy(): void;
|
|
968
|
-
drawVideo(enableLegacyPip: boolean): void;
|
|
969
|
-
getFont(): string;
|
|
970
|
-
getFillStyle(): string | CanvasGradient | CanvasPattern;
|
|
971
|
-
setScale(scale: number, arg1?: number): void;
|
|
972
|
-
fillRect(x: number, y: number, width: number, height: number): void;
|
|
973
|
-
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
974
|
-
fillText(text: string, x: number, y: number): void;
|
|
975
|
-
strokeText(text: string, x: number, y: number): void;
|
|
976
|
-
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
977
|
-
clearRect(x: number, y: number, width: number, height: number): void;
|
|
978
|
-
setFont(font: string): void;
|
|
979
|
-
setFillStyle(color: string): void;
|
|
980
|
-
setStrokeStyle(color: string): void;
|
|
981
|
-
setLineWidth(width: number): void;
|
|
982
|
-
setGlobalAlpha(alpha: number): void;
|
|
983
|
-
setSize(width: number, height: number): void;
|
|
984
|
-
getSize(): {
|
|
985
|
-
width: number;
|
|
986
|
-
height: number;
|
|
987
|
-
};
|
|
988
|
-
measureText(text: string): TextMetrics;
|
|
989
|
-
beginPath(): void;
|
|
990
|
-
closePath(): void;
|
|
991
|
-
moveTo(x: number, y: number): void;
|
|
992
|
-
lineTo(x: number, y: number): void;
|
|
993
|
-
stroke(): void;
|
|
994
|
-
save(): void;
|
|
995
|
-
restore(): void;
|
|
996
|
-
getCanvas(): IRenderer;
|
|
997
|
-
drawImage(image: IRenderer, x: number, y: number, width?: number, height?: number): void;
|
|
998
|
-
}
|
|
999
964
|
declare class BaseComment implements IComment {
|
|
1000
965
|
protected readonly renderer: IRenderer;
|
|
1001
966
|
protected cacheKey: string;
|
|
@@ -1575,42 +1540,105 @@ export declare const ZV1Thread: ObjectSchema<{
|
|
|
1575
1540
|
}>;
|
|
1576
1541
|
export type V1Thread = Output<typeof ZV1Thread>;
|
|
1577
1542
|
export type v1Thread = V1Thread;
|
|
1578
|
-
export
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
declare const
|
|
1543
|
+
export declare const ZXml2jsChatItem: ObjectSchema<{
|
|
1544
|
+
_: StringSchema<string>;
|
|
1545
|
+
$: ObjectSchema<{
|
|
1546
|
+
no: OptionalSchema<StringSchema<string>, undefined, string | undefined>;
|
|
1547
|
+
vpos: StringSchema<string>;
|
|
1548
|
+
date: OptionalSchema<StringSchema<string>, "0", string>;
|
|
1549
|
+
date_usec: OptionalSchema<StringSchema<string>, "0", string>;
|
|
1550
|
+
user_id: OptionalSchema<StringSchema<string>, undefined, string | undefined>;
|
|
1551
|
+
owner: OptionalSchema<StringSchema<string>, "", string>;
|
|
1552
|
+
premium: OptionalSchema<StringSchema<string>, "", string>;
|
|
1553
|
+
mail: OptionalSchema<StringSchema<string>, "", string>;
|
|
1554
|
+
}, undefined, {
|
|
1555
|
+
owner: string;
|
|
1556
|
+
vpos: string;
|
|
1557
|
+
date: string;
|
|
1558
|
+
date_usec: string;
|
|
1559
|
+
premium: string;
|
|
1560
|
+
mail: string;
|
|
1561
|
+
user_id?: string | undefined;
|
|
1562
|
+
no?: string | undefined;
|
|
1563
|
+
}>;
|
|
1564
|
+
}, undefined, {
|
|
1565
|
+
_: string;
|
|
1566
|
+
$: {
|
|
1567
|
+
owner: string;
|
|
1568
|
+
vpos: string;
|
|
1569
|
+
date: string;
|
|
1570
|
+
date_usec: string;
|
|
1571
|
+
premium: string;
|
|
1572
|
+
mail: string;
|
|
1573
|
+
user_id?: string | undefined;
|
|
1574
|
+
no?: string | undefined;
|
|
1575
|
+
};
|
|
1576
|
+
}>;
|
|
1577
|
+
export type Xml2jsChatItem = Output<typeof ZXml2jsChatItem>;
|
|
1578
|
+
export declare const ZXml2jsChat: ObjectSchema<{
|
|
1579
|
+
chat: ArraySchema<ObjectSchema<{
|
|
1580
|
+
_: StringSchema<string>;
|
|
1581
|
+
$: ObjectSchema<{
|
|
1582
|
+
no: OptionalSchema<StringSchema<string>, undefined, string | undefined>;
|
|
1583
|
+
vpos: StringSchema<string>;
|
|
1584
|
+
date: OptionalSchema<StringSchema<string>, "0", string>;
|
|
1585
|
+
date_usec: OptionalSchema<StringSchema<string>, "0", string>;
|
|
1586
|
+
user_id: OptionalSchema<StringSchema<string>, undefined, string | undefined>;
|
|
1587
|
+
owner: OptionalSchema<StringSchema<string>, "", string>;
|
|
1588
|
+
premium: OptionalSchema<StringSchema<string>, "", string>;
|
|
1589
|
+
mail: OptionalSchema<StringSchema<string>, "", string>;
|
|
1590
|
+
}, undefined, {
|
|
1591
|
+
owner: string;
|
|
1592
|
+
vpos: string;
|
|
1593
|
+
date: string;
|
|
1594
|
+
date_usec: string;
|
|
1595
|
+
premium: string;
|
|
1596
|
+
mail: string;
|
|
1597
|
+
user_id?: string | undefined;
|
|
1598
|
+
no?: string | undefined;
|
|
1599
|
+
}>;
|
|
1600
|
+
}, undefined, {
|
|
1601
|
+
_: string;
|
|
1602
|
+
$: {
|
|
1603
|
+
owner: string;
|
|
1604
|
+
vpos: string;
|
|
1605
|
+
date: string;
|
|
1606
|
+
date_usec: string;
|
|
1607
|
+
premium: string;
|
|
1608
|
+
mail: string;
|
|
1609
|
+
user_id?: string | undefined;
|
|
1610
|
+
no?: string | undefined;
|
|
1611
|
+
};
|
|
1612
|
+
}>, {
|
|
1613
|
+
_: string;
|
|
1614
|
+
$: {
|
|
1615
|
+
owner: string;
|
|
1616
|
+
vpos: string;
|
|
1617
|
+
date: string;
|
|
1618
|
+
date_usec: string;
|
|
1619
|
+
premium: string;
|
|
1620
|
+
mail: string;
|
|
1621
|
+
user_id?: string | undefined;
|
|
1622
|
+
no?: string | undefined;
|
|
1623
|
+
};
|
|
1624
|
+
}[]>;
|
|
1625
|
+
}, undefined, {
|
|
1626
|
+
chat: {
|
|
1627
|
+
_: string;
|
|
1628
|
+
$: {
|
|
1629
|
+
owner: string;
|
|
1630
|
+
vpos: string;
|
|
1631
|
+
date: string;
|
|
1632
|
+
date_usec: string;
|
|
1633
|
+
premium: string;
|
|
1634
|
+
mail: string;
|
|
1635
|
+
user_id?: string | undefined;
|
|
1636
|
+
no?: string | undefined;
|
|
1637
|
+
};
|
|
1638
|
+
}[];
|
|
1639
|
+
}>;
|
|
1640
|
+
export type Xml2jsChat = Output<typeof ZXml2jsChat>;
|
|
1641
|
+
export declare const ZXml2jsPacket: ObjectSchema<{
|
|
1614
1642
|
packet: ObjectSchema<{
|
|
1615
1643
|
chat: ArraySchema<ObjectSchema<{
|
|
1616
1644
|
_: StringSchema<string>;
|
|
@@ -1691,6 +1719,41 @@ declare const ZXml2jsPacket: ObjectSchema<{
|
|
|
1691
1719
|
};
|
|
1692
1720
|
}>;
|
|
1693
1721
|
export type Xml2jsPacket = Output<typeof ZXml2jsPacket>;
|
|
1722
|
+
export interface IComment {
|
|
1723
|
+
comment: FormattedCommentWithSize;
|
|
1724
|
+
invisible: boolean;
|
|
1725
|
+
loc: CommentLoc;
|
|
1726
|
+
width: number;
|
|
1727
|
+
long: number;
|
|
1728
|
+
height: number;
|
|
1729
|
+
vpos: number;
|
|
1730
|
+
flash: boolean;
|
|
1731
|
+
posY: number;
|
|
1732
|
+
owner: boolean;
|
|
1733
|
+
layer: number;
|
|
1734
|
+
mail: string[];
|
|
1735
|
+
content: string;
|
|
1736
|
+
image?: IRenderer | null;
|
|
1737
|
+
draw: (vpos: number, showCollision: boolean, cursor?: Position) => void;
|
|
1738
|
+
isHovered: (cursor?: Position, posX?: number, posY?: number) => boolean;
|
|
1739
|
+
}
|
|
1740
|
+
export interface InputParser {
|
|
1741
|
+
key: string[];
|
|
1742
|
+
parse: (input: unknown) => FormattedComment[];
|
|
1743
|
+
}
|
|
1744
|
+
export interface IPluginConstructor {
|
|
1745
|
+
id: string;
|
|
1746
|
+
new (Canvas: IRenderer, comments: IComment[]): IPlugin;
|
|
1747
|
+
}
|
|
1748
|
+
export interface IPlugin {
|
|
1749
|
+
draw?: (vpos: number) => void;
|
|
1750
|
+
addComments?: (comments: IComment[]) => void;
|
|
1751
|
+
transformComments?: (comments: IComment[]) => IComment[];
|
|
1752
|
+
}
|
|
1753
|
+
export type IPluginList = {
|
|
1754
|
+
instance: IPlugin;
|
|
1755
|
+
canvas: IRenderer;
|
|
1756
|
+
}[];
|
|
1694
1757
|
export declare const ZInputFormatType: UnionSchema<(LiteralSchema<"XMLDocument", "XMLDocument"> | LiteralSchema<"niconicome", "niconicome"> | LiteralSchema<"xml2js", "xml2js"> | LiteralSchema<"formatted", "formatted"> | LiteralSchema<"legacy", "legacy"> | LiteralSchema<"legacyOwner", "legacyOwner"> | LiteralSchema<"owner", "owner"> | LiteralSchema<"v1", "v1"> | LiteralSchema<"empty", "empty"> | LiteralSchema<"default", "default">)[], "default" | "XMLDocument" | "niconicome" | "xml2js" | "formatted" | "legacy" | "legacyOwner" | "owner" | "v1" | "empty">;
|
|
1695
1758
|
export type InputFormatType = Output<typeof ZInputFormatType>;
|
|
1696
1759
|
export type InputFormat = XMLDocument | Xml2jsPacket | FormattedComment[] | FormattedLegacyComment[] | RawApiResponse[] | OwnerComment[] | V1Thread[] | string | undefined;
|
|
@@ -1713,6 +1776,41 @@ export type BaseOptions = {
|
|
|
1713
1776
|
export type Options = Partial<BaseOptions>;
|
|
1714
1777
|
export type inputFormatType = InputFormatType;
|
|
1715
1778
|
export type inputFormat = InputFormat;
|
|
1779
|
+
export interface IRenderer {
|
|
1780
|
+
readonly canvas: HTMLCanvasElement;
|
|
1781
|
+
readonly video?: HTMLVideoElement;
|
|
1782
|
+
destroy(): void;
|
|
1783
|
+
drawVideo(enableLegacyPip: boolean): void;
|
|
1784
|
+
getFont(): string;
|
|
1785
|
+
getFillStyle(): string | CanvasGradient | CanvasPattern;
|
|
1786
|
+
setScale(scale: number, arg1?: number): void;
|
|
1787
|
+
fillRect(x: number, y: number, width: number, height: number): void;
|
|
1788
|
+
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
1789
|
+
fillText(text: string, x: number, y: number): void;
|
|
1790
|
+
strokeText(text: string, x: number, y: number): void;
|
|
1791
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
1792
|
+
clearRect(x: number, y: number, width: number, height: number): void;
|
|
1793
|
+
setFont(font: string): void;
|
|
1794
|
+
setFillStyle(color: string): void;
|
|
1795
|
+
setStrokeStyle(color: string): void;
|
|
1796
|
+
setLineWidth(width: number): void;
|
|
1797
|
+
setGlobalAlpha(alpha: number): void;
|
|
1798
|
+
setSize(width: number, height: number): void;
|
|
1799
|
+
getSize(): {
|
|
1800
|
+
width: number;
|
|
1801
|
+
height: number;
|
|
1802
|
+
};
|
|
1803
|
+
measureText(text: string): TextMetrics;
|
|
1804
|
+
beginPath(): void;
|
|
1805
|
+
closePath(): void;
|
|
1806
|
+
moveTo(x: number, y: number): void;
|
|
1807
|
+
lineTo(x: number, y: number): void;
|
|
1808
|
+
stroke(): void;
|
|
1809
|
+
save(): void;
|
|
1810
|
+
restore(): void;
|
|
1811
|
+
getCanvas(): IRenderer;
|
|
1812
|
+
drawImage(image: IRenderer, x: number, y: number, width?: number, height?: number): void;
|
|
1813
|
+
}
|
|
1716
1814
|
export type FormattedCommentWithFont = {
|
|
1717
1815
|
id: number;
|
|
1718
1816
|
vpos: number;
|
|
@@ -2615,6 +2713,53 @@ declare const typeGuard: {
|
|
|
2615
2713
|
};
|
|
2616
2714
|
};
|
|
2617
2715
|
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
2716
|
+
xml2js: {
|
|
2717
|
+
packet: (i: unknown) => i is {
|
|
2718
|
+
packet: {
|
|
2719
|
+
chat: {
|
|
2720
|
+
_: string;
|
|
2721
|
+
$: {
|
|
2722
|
+
owner: string;
|
|
2723
|
+
vpos: string;
|
|
2724
|
+
date: string;
|
|
2725
|
+
date_usec: string;
|
|
2726
|
+
premium: string;
|
|
2727
|
+
mail: string;
|
|
2728
|
+
user_id?: string | undefined;
|
|
2729
|
+
no?: string | undefined;
|
|
2730
|
+
};
|
|
2731
|
+
}[];
|
|
2732
|
+
};
|
|
2733
|
+
};
|
|
2734
|
+
chat: (i: unknown) => i is {
|
|
2735
|
+
chat: {
|
|
2736
|
+
_: string;
|
|
2737
|
+
$: {
|
|
2738
|
+
owner: string;
|
|
2739
|
+
vpos: string;
|
|
2740
|
+
date: string;
|
|
2741
|
+
date_usec: string;
|
|
2742
|
+
premium: string;
|
|
2743
|
+
mail: string;
|
|
2744
|
+
user_id?: string | undefined;
|
|
2745
|
+
no?: string | undefined;
|
|
2746
|
+
};
|
|
2747
|
+
}[];
|
|
2748
|
+
};
|
|
2749
|
+
chatItem: (i: unknown) => i is {
|
|
2750
|
+
_: string;
|
|
2751
|
+
$: {
|
|
2752
|
+
owner: string;
|
|
2753
|
+
vpos: string;
|
|
2754
|
+
date: string;
|
|
2755
|
+
date_usec: string;
|
|
2756
|
+
premium: string;
|
|
2757
|
+
mail: string;
|
|
2758
|
+
user_id?: string | undefined;
|
|
2759
|
+
no?: string | undefined;
|
|
2760
|
+
};
|
|
2761
|
+
};
|
|
2762
|
+
};
|
|
2618
2763
|
legacyOwner: {
|
|
2619
2764
|
comments: (i: unknown) => i is string;
|
|
2620
2765
|
};
|
|
@@ -3013,6 +3158,53 @@ declare class NiconiComments {
|
|
|
3013
3158
|
};
|
|
3014
3159
|
};
|
|
3015
3160
|
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
3161
|
+
xml2js: {
|
|
3162
|
+
packet: (i: unknown) => i is {
|
|
3163
|
+
packet: {
|
|
3164
|
+
chat: {
|
|
3165
|
+
_: string;
|
|
3166
|
+
$: {
|
|
3167
|
+
owner: string;
|
|
3168
|
+
vpos: string;
|
|
3169
|
+
date: string;
|
|
3170
|
+
date_usec: string;
|
|
3171
|
+
premium: string;
|
|
3172
|
+
mail: string;
|
|
3173
|
+
user_id?: string | undefined;
|
|
3174
|
+
no?: string | undefined;
|
|
3175
|
+
};
|
|
3176
|
+
}[];
|
|
3177
|
+
};
|
|
3178
|
+
};
|
|
3179
|
+
chat: (i: unknown) => i is {
|
|
3180
|
+
chat: {
|
|
3181
|
+
_: string;
|
|
3182
|
+
$: {
|
|
3183
|
+
owner: string;
|
|
3184
|
+
vpos: string;
|
|
3185
|
+
date: string;
|
|
3186
|
+
date_usec: string;
|
|
3187
|
+
premium: string;
|
|
3188
|
+
mail: string;
|
|
3189
|
+
user_id?: string | undefined;
|
|
3190
|
+
no?: string | undefined;
|
|
3191
|
+
};
|
|
3192
|
+
}[];
|
|
3193
|
+
};
|
|
3194
|
+
chatItem: (i: unknown) => i is {
|
|
3195
|
+
_: string;
|
|
3196
|
+
$: {
|
|
3197
|
+
owner: string;
|
|
3198
|
+
vpos: string;
|
|
3199
|
+
date: string;
|
|
3200
|
+
date_usec: string;
|
|
3201
|
+
premium: string;
|
|
3202
|
+
mail: string;
|
|
3203
|
+
user_id?: string | undefined;
|
|
3204
|
+
no?: string | undefined;
|
|
3205
|
+
};
|
|
3206
|
+
};
|
|
3207
|
+
};
|
|
3016
3208
|
legacyOwner: {
|
|
3017
3209
|
comments: (i: unknown) => i is string;
|
|
3018
3210
|
};
|
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.2.
|
|
2
|
+
niconicomments.js v0.2.69
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -1509,6 +1509,26 @@
|
|
|
1509
1509
|
comments: array(ZV1Comment),
|
|
1510
1510
|
});
|
|
1511
1511
|
|
|
1512
|
+
const ZXml2jsChatItem = object({
|
|
1513
|
+
_: string(),
|
|
1514
|
+
$: object({
|
|
1515
|
+
no: optional(string()),
|
|
1516
|
+
vpos: string(),
|
|
1517
|
+
date: optional(string(), "0"),
|
|
1518
|
+
date_usec: optional(string(), "0"),
|
|
1519
|
+
user_id: optional(string()),
|
|
1520
|
+
owner: optional(string(), ""),
|
|
1521
|
+
premium: optional(string(), ""),
|
|
1522
|
+
mail: optional(string(), ""),
|
|
1523
|
+
}),
|
|
1524
|
+
});
|
|
1525
|
+
const ZXml2jsChat = object({
|
|
1526
|
+
chat: array(ZXml2jsChatItem),
|
|
1527
|
+
});
|
|
1528
|
+
const ZXml2jsPacket = object({
|
|
1529
|
+
packet: ZXml2jsChat,
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1512
1532
|
const ZInputFormatType = union([
|
|
1513
1533
|
literal("XMLDocument"),
|
|
1514
1534
|
literal("niconicome"),
|
|
@@ -1674,6 +1694,11 @@
|
|
|
1674
1694
|
}
|
|
1675
1695
|
return true;
|
|
1676
1696
|
},
|
|
1697
|
+
xml2js: {
|
|
1698
|
+
packet: (i) => is(ZXml2jsPacket, i),
|
|
1699
|
+
chat: (i) => is(ZXml2jsChat, i),
|
|
1700
|
+
chatItem: (i) => is(ZXml2jsChatItem, i),
|
|
1701
|
+
},
|
|
1677
1702
|
legacyOwner: {
|
|
1678
1703
|
comments: (i) => is(string([
|
|
1679
1704
|
custom((i) => {
|
|
@@ -4360,26 +4385,6 @@
|
|
|
4360
4385
|
};
|
|
4361
4386
|
const date2time = (date) => Math.floor(Date.parse(date) / 1000);
|
|
4362
4387
|
|
|
4363
|
-
const ZXml2jsChatItem = object({
|
|
4364
|
-
_: string(),
|
|
4365
|
-
$: object({
|
|
4366
|
-
no: optional(string()),
|
|
4367
|
-
vpos: string(),
|
|
4368
|
-
date: optional(string(), "0"),
|
|
4369
|
-
date_usec: optional(string(), "0"),
|
|
4370
|
-
user_id: optional(string()),
|
|
4371
|
-
owner: optional(string(), ""),
|
|
4372
|
-
premium: optional(string(), ""),
|
|
4373
|
-
mail: optional(string(), ""),
|
|
4374
|
-
}),
|
|
4375
|
-
});
|
|
4376
|
-
const ZXml2jsChat = object({
|
|
4377
|
-
chat: array(ZXml2jsChatItem),
|
|
4378
|
-
});
|
|
4379
|
-
const ZXml2jsPacket = object({
|
|
4380
|
-
packet: ZXml2jsChat,
|
|
4381
|
-
});
|
|
4382
|
-
|
|
4383
4388
|
const Xml2jsParser = {
|
|
4384
4389
|
key: ["xml2js"],
|
|
4385
4390
|
parse: (input) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.69",
|
|
4
4
|
"description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
|
|
5
5
|
"main": "dist/bundle.js",
|
|
6
6
|
"types": "dist/bundle.d.ts",
|