@xpadev-net/niconicomments 0.2.20 → 0.2.21

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.
@@ -0,0 +1,154 @@
1
+ type inputFormatType = "niconicome"|"formatted"|"legacy"|"owner"|"v1"|"default";
2
+ type InitOptions = {
3
+ useLegacy?: boolean,
4
+ formatted?: boolean,
5
+ format?: inputFormatType,
6
+ video?: HTMLVideoElement | null
7
+ showCollision?: boolean,
8
+ showFPS?: boolean,
9
+ showCommentCount?: boolean,
10
+ drawAllImageOnLoad?: boolean,
11
+ debug?: boolean,
12
+ enableLegacyPiP?: boolean,
13
+ keepCA?: boolean
14
+ }
15
+ type Options = {
16
+ useLegacy: boolean,
17
+ formatted: boolean,
18
+ format: inputFormatType,
19
+ video: HTMLVideoElement | null,
20
+ showCollision: boolean,
21
+ showFPS: boolean,
22
+ showCommentCount: boolean,
23
+ drawAllImageOnLoad: boolean,
24
+ debug: boolean,
25
+ enableLegacyPiP: boolean,
26
+ keepCA: boolean
27
+ }
28
+ type rawApiResponse = {
29
+ [key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat
30
+ }
31
+ type apiPing = {
32
+ "content": string
33
+ }
34
+ type apiThread = {
35
+ "resultcode": number,
36
+ "thread": string,
37
+ "server_time": number,
38
+ "ticket": string,
39
+ "revision": number
40
+ }
41
+ type apiLeaf = {
42
+ "thread": string,
43
+ "count": number
44
+ }
45
+ type apiGlobalNumRes = {
46
+ "thread": string,
47
+ "num_res": number
48
+ }
49
+ type apiChat = {
50
+ "thread": string,
51
+ "no": number,
52
+ "vpos": number,
53
+ "date": number,
54
+ "date_usec": number,
55
+ "nicoru": number,
56
+ "premium": number,
57
+ "anonymity": number,
58
+ "user_id": string,
59
+ "mail": string,
60
+ "content": string,
61
+ "deleted": number
62
+ }
63
+ type formattedComment = {
64
+ "id": number,
65
+ "vpos": number,
66
+ "content": string,
67
+ "date": number,
68
+ "date_usec": number,
69
+ "owner": boolean,
70
+ "premium": boolean,
71
+ "mail": string[],
72
+ "user_id": number,
73
+ "layer": number,
74
+ }
75
+ type formattedLegacyComment = {
76
+ "id": number,
77
+ "vpos": number,
78
+ "content": string,
79
+ "date": number,
80
+ "date_usec": number,
81
+ "owner": boolean,
82
+ "premium": boolean,
83
+ "mail": string[],
84
+ }
85
+ type formattedCommentWithFont = formattedComment & {
86
+ "loc": string,
87
+ "size": string,
88
+ "fontSize": number,
89
+ "font": string,
90
+ "color": string,
91
+ "full": boolean,
92
+ "ender": boolean,
93
+ "_live": boolean,
94
+ "long": number,
95
+ "invisible": boolean
96
+ }
97
+ type formattedCommentWithSize = formattedCommentWithFont & {
98
+ "height": number,
99
+ "width": number,
100
+ "width_max": number,
101
+ "width_min": number,
102
+ "lineHeight": number
103
+ }
104
+ type parsedComment = formattedCommentWithSize & {
105
+ posY: number,
106
+ image?: HTMLCanvasElement | boolean
107
+ }
108
+ type measureTextResult = {
109
+ "width": number,
110
+ "width_max": number,
111
+ "width_min": number,
112
+ "height": number,
113
+ "resized": boolean,
114
+ "fontSize": number,
115
+ "lineHeight": number
116
+ }
117
+ type T_fontSize = {
118
+ [key: string]: {
119
+ "default": number,
120
+ "resized": number
121
+ }
122
+ }
123
+ type T_doubleResizeMaxWidth = {
124
+ [key: string]: {
125
+ "legacy": number,
126
+ "default": number
127
+ }
128
+ }
129
+ type v1Thread = {
130
+ "id": string,
131
+ "fork": string,
132
+ "commentCount": number,
133
+ "comments": { [key: string]:v1Comment }
134
+ }
135
+ type v1Comment = {
136
+ "id": string,
137
+ "no": number,
138
+ "vposMs": number,
139
+ "body": string,
140
+ "commands": string[],
141
+ "userId": string,
142
+ "isPremium": boolean,
143
+ "score": number,
144
+ "postedAt": string,
145
+ "nicoruCount": number,
146
+ "nicoruId": null,
147
+ "source": string,
148
+ "isMyPost": boolean
149
+ }
150
+ type ownerComment = {
151
+ "time": string,
152
+ "command": string,
153
+ "comment": string
154
+ }
package/package.json CHANGED
@@ -1,42 +1,44 @@
1
- {
2
- "name": "@xpadev-net/niconicomments",
3
- "version": "0.2.20",
4
- "description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
5
- "main": "dist/bundle.js",
6
- "types": "dist/dts/main.d.ts",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "rollup -c rollup.config.js",
10
- "watch": "rollup -c rollup.config.js -w",
11
- "typedoc": "typedoc --options tsdoc.json --out ./docs/type/ ./src/main.ts",
12
- "tsc": "tsc --emitDeclarationOnly",
13
- "prepublishOnly": "npm run tsc&&npm run build"
14
- },
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/xpadev-net/niconicomments.git"
18
- },
19
- "keywords": [
20
- "niconico"
21
- ],
22
- "author": "xpadev(xpadev.net)",
23
- "bugs": {
24
- "url": "https://github.com/xpadev-net/niconicomments/issues"
25
- },
26
- "files": [
27
- "dist/bundle.js",
28
- "dist/dts/main.d.ts",
29
- "dist/dts/main.d.ts.map"
30
- ],
31
- "homepage": "https://xpadev.net/niconicomments/docs/",
32
- "license": "MIT",
33
- "devDependencies": {
34
- "@babel/preset-env": "^7.18.2",
35
- "@rollup/plugin-babel": "^5.3.0",
36
- "@rollup/plugin-typescript": "^8.3.2",
37
- "rollup": "^2.75.6",
38
- "typedoc": "^0.22.17",
39
- "typedoc-plugin-missing-exports": "^0.22.6",
40
- "typescript": "^4.7.3"
41
- }
42
- }
1
+ {
2
+ "name": "@xpadev-net/niconicomments",
3
+ "version": "0.2.21",
4
+ "description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
5
+ "main": "dist/bundle.js",
6
+ "types": "dist/dts/types.d.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "rollup -c rollup.config.js",
10
+ "watch": "rollup -c rollup.config.js -w",
11
+ "typedoc": "typedoc --entryPointStrategy Expand --options tsdoc.json --out ./docs/type/ ./src/",
12
+ "copy-dts": "npx copyfiles -u 2 src/@types/*.d.ts dist/dts",
13
+ "prepublishOnly": "npm run copy-dts&&npm run build"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/xpadev-net/niconicomments.git"
18
+ },
19
+ "keywords": [
20
+ "niconico"
21
+ ],
22
+ "author": "xpadev(xpadev.net)",
23
+ "bugs": {
24
+ "url": "https://github.com/xpadev-net/niconicomments/issues"
25
+ },
26
+ "files": [
27
+ "dist/bundle.js",
28
+ "dist/dts/types.d.ts"
29
+ ],
30
+ "homepage": "https://xpadev.net/niconicomments/docs/",
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "@babel/preset-env": "^7.18.2",
34
+ "@rollup/plugin-babel": "^5.3.0",
35
+ "@rollup/plugin-node-resolve": "^13.3.0",
36
+ "@rollup/plugin-typescript": "^8.3.3",
37
+ "copyfiles": "^2.4.1",
38
+ "rollup": "^2.75.7",
39
+ "rollup-plugin-dts": "^4.2.2",
40
+ "typedoc": "^0.22.18",
41
+ "typedoc-plugin-missing-exports": "^0.22.6",
42
+ "typescript": "^4.7.4"
43
+ }
44
+ }
@@ -1,156 +0,0 @@
1
- declare type InitOptions = {
2
- useLegacy?: boolean;
3
- formatted?: boolean;
4
- video?: HTMLVideoElement | null;
5
- showCollision?: boolean;
6
- showFPS?: boolean;
7
- showCommentCount?: boolean;
8
- drawAllImageOnLoad?: boolean;
9
- debug?: boolean;
10
- enableLegacyPiP?: boolean;
11
- keepCA?: boolean;
12
- };
13
- declare type rawApiResponse = {
14
- [key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
15
- };
16
- declare type apiPing = {
17
- "content": string;
18
- };
19
- declare type apiThread = {
20
- "resultcode": number;
21
- "thread": string;
22
- "server_time": number;
23
- "ticket": string;
24
- "revision": number;
25
- };
26
- declare type apiLeaf = {
27
- "thread": string;
28
- "count": number;
29
- };
30
- declare type apiGlobalNumRes = {
31
- "thread": string;
32
- "num_res": number;
33
- };
34
- declare type apiChat = {
35
- "thread": string;
36
- "no": number;
37
- "vpos": number;
38
- "date": number;
39
- "date_usec": number;
40
- "nicoru": number;
41
- "premium": number;
42
- "anonymity": number;
43
- "user_id": string;
44
- "mail": string;
45
- "content": string;
46
- "deleted": number;
47
- };
48
- declare type formattedComment = {
49
- "id": number;
50
- "vpos": number;
51
- "content": string;
52
- "date": number;
53
- "date_usec": number;
54
- "owner": boolean;
55
- "premium": boolean;
56
- "mail": string[];
57
- "user_id": number;
58
- "layer": number;
59
- };
60
- declare type formattedCommentWithFont = formattedComment & {
61
- "loc": string;
62
- "size": string;
63
- "fontSize": number;
64
- "font": string;
65
- "color": string;
66
- "full": boolean;
67
- "ender": boolean;
68
- "_live": boolean;
69
- "long": number;
70
- "invisible": boolean;
71
- };
72
- declare type formattedCommentWithSize = formattedCommentWithFont & {
73
- "height": number;
74
- "width": number;
75
- "width_max": number;
76
- "width_min": number;
77
- "lineHeight": number;
78
- };
79
- declare type parsedComment = formattedCommentWithSize & {
80
- posY: number;
81
- image?: HTMLCanvasElement | boolean;
82
- };
83
- declare type measureTextResult = {
84
- "width": number;
85
- "width_max": number;
86
- "width_min": number;
87
- "height": number;
88
- "resized": boolean;
89
- "fontSize": number;
90
- "lineHeight": number;
91
- };
92
- declare class NiconiComments {
93
- private canvas;
94
- private context;
95
- private readonly commentYPaddingTop;
96
- private readonly commentYMarginBottom;
97
- private readonly fontSize;
98
- private readonly lineHeight;
99
- private readonly doubleResizeMaxWidth;
100
- private video;
101
- private showCollision;
102
- showFPS: boolean;
103
- showCommentCount: boolean;
104
- enableLegacyPiP: boolean;
105
- private keepCA;
106
- private data;
107
- private timeline;
108
- private nicoScripts;
109
- private collision_right;
110
- private collision_left;
111
- private collision_ue;
112
- private collision_shita;
113
- private lastVpos;
114
- private useLegacy;
115
- private fpsCount;
116
- private fps;
117
- constructor(canvas: HTMLCanvasElement, data: (rawApiResponse | formattedComment)[], initOptions?: InitOptions);
118
- parseData(data: rawApiResponse[]): formattedComment[];
119
- preRendering(rawData: formattedComment[], drawAll: boolean): void;
120
- getFont(parsedData: formattedComment[]): formattedCommentWithFont[];
121
- getCommentSize(parsedData: formattedCommentWithFont[]): formattedCommentWithSize[];
122
- getCommentPos(parsedData: parsedComment[]): parsedComment[];
123
- sortComment(parsedData: parsedComment[]): parsedComment[];
124
- measureText(comment: {
125
- content: string;
126
- resized: boolean;
127
- ender: any;
128
- size: string;
129
- fontSize: number;
130
- tateresized: boolean;
131
- font: any;
132
- loc: string;
133
- full: any;
134
- yokoResized: boolean;
135
- lineHeight: number | undefined;
136
- }): measureTextResult;
137
- drawText(comment: parsedComment, vpos: number): void;
138
- getTextImage(i: number, preRendering?: boolean): void;
139
- parseCommand(comment: any): {
140
- loc: string | null;
141
- size: string | null;
142
- fontSize: number | null;
143
- color: any;
144
- font: string | null;
145
- full: boolean;
146
- ender: boolean;
147
- _live: boolean;
148
- invisible: boolean;
149
- long: any;
150
- };
151
- parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
152
- drawCanvas(vpos: number): void;
153
- clear(): void;
154
- }
155
- export default NiconiComments;
156
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,aAAK,WAAW,GAAG;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAaD,aAAK,cAAc,GAAG;IA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