@xpadev-net/niconicomments 0.2.21 → 0.2.22

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.
@@ -1,154 +1,225 @@
1
- type inputFormatType = "niconicome"|"formatted"|"legacy"|"owner"|"v1"|"default";
1
+ type inputFormatType =
2
+ | "niconicome"
3
+ | "formatted"
4
+ | "legacy"
5
+ | "owner"
6
+ | "v1"
7
+ | "default";
2
8
  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
- }
9
+ useLegacy?: boolean;
10
+ formatted?: boolean;
11
+ format?: inputFormatType;
12
+ video?: HTMLVideoElement | undefined;
13
+ showCollision?: boolean;
14
+ showFPS?: boolean;
15
+ showCommentCount?: boolean;
16
+ drawAllImageOnLoad?: boolean;
17
+ debug?: boolean;
18
+ enableLegacyPiP?: boolean;
19
+ keepCA?: boolean;
20
+ };
15
21
  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
- }
22
+ useLegacy: boolean;
23
+ formatted: boolean;
24
+ format: inputFormatType;
25
+ video: HTMLVideoElement | undefined;
26
+ showCollision: boolean;
27
+ showFPS: boolean;
28
+ showCommentCount: boolean;
29
+ drawAllImageOnLoad: boolean;
30
+ debug: boolean;
31
+ enableLegacyPiP: boolean;
32
+ keepCA: boolean;
33
+ };
28
34
  type rawApiResponse = {
29
- [key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat
30
- }
35
+ [key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
36
+ };
31
37
  type apiPing = {
32
- "content": string
33
- }
38
+ content: string;
39
+ };
34
40
  type apiThread = {
35
- "resultcode": number,
36
- "thread": string,
37
- "server_time": number,
38
- "ticket": string,
39
- "revision": number
40
- }
41
+ resultcode: number;
42
+ thread: string;
43
+ server_time: number;
44
+ ticket: string;
45
+ revision: number;
46
+ };
41
47
  type apiLeaf = {
42
- "thread": string,
43
- "count": number
44
- }
48
+ thread: string;
49
+ count: number;
50
+ };
45
51
  type apiGlobalNumRes = {
46
- "thread": string,
47
- "num_res": number
48
- }
52
+ thread: string;
53
+ num_res: number;
54
+ };
49
55
  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
- }
56
+ thread: string;
57
+ no: number;
58
+ vpos: number;
59
+ date: number;
60
+ date_usec: number;
61
+ nicoru: number;
62
+ premium: number;
63
+ anonymity: number;
64
+ user_id: string;
65
+ mail: string;
66
+ content: string;
67
+ deleted: number;
68
+ };
63
69
  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
- }
70
+ id: number;
71
+ vpos: number;
72
+ content: string;
73
+ date: number;
74
+ date_usec: number;
75
+ owner: boolean;
76
+ premium: boolean;
77
+ mail: string[];
78
+ user_id: number;
79
+ layer: number;
80
+ };
75
81
  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
- }
82
+ id: number;
83
+ vpos: number;
84
+ content: string;
85
+ date: number;
86
+ date_usec: number;
87
+ owner: boolean;
88
+ premium: boolean;
89
+ mail: string[];
90
+ };
85
91
  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
- }
92
+ loc: commentLoc;
93
+ size: commentSize;
94
+ fontSize: number;
95
+ font: commentFont;
96
+ color: string;
97
+ full: boolean;
98
+ ender: boolean;
99
+ _live: boolean;
100
+ long: number;
101
+ invisible: boolean;
102
+ };
97
103
  type formattedCommentWithSize = formattedCommentWithFont & {
98
- "height": number,
99
- "width": number,
100
- "width_max": number,
101
- "width_min": number,
102
- "lineHeight": number
103
- }
104
+ height: number;
105
+ width: number;
106
+ width_max: number;
107
+ width_min: number;
108
+ lineHeight: number;
109
+ };
104
110
  type parsedComment = formattedCommentWithSize & {
105
- posY: number,
106
- image?: HTMLCanvasElement | boolean
107
- }
111
+ posY: number;
112
+ image?: HTMLCanvasElement | boolean;
113
+ };
114
+ type groupedResult = formattedCommentWithFont & {
115
+ index: number;
116
+ };
117
+ type groupedComments = {
118
+ [key in commentFont]: { [key: string]: groupedResult[] };
119
+ };
120
+ type commentFont = "defont" | "mincho" | "gothic";
121
+ type commentSize = "big" | "medium" | "small";
122
+ type commentLoc = "ue" | "naka" | "shita";
123
+ type collision = { [key in collisionPos]: collisionItem };
124
+ type collisionPos = "ue" | "shita" | "right" | "left";
125
+ type collisionItem = { [p: number]: number[] };
126
+ type nicoScript = {
127
+ reverse: nicoScriptReverse[];
128
+ ban: nicoScriptBan[];
129
+ default: nicoScriptDefault[];
130
+ replace: nicoScriptReplace[];
131
+ };
132
+ type nicoScriptReverse = {
133
+ target: nicoScriptReverseTarget;
134
+ start: number;
135
+ end: number;
136
+ };
137
+ type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
138
+ type nicoScriptReplace = {
139
+ start: number;
140
+ long: number | undefined;
141
+ keyword: string;
142
+ replace: string;
143
+ range: nicoScriptReplaceRange;
144
+ target: nicoScriptReplaceTarget;
145
+ condition: nicoScriptReplaceCondition;
146
+ color: string | undefined;
147
+ size: commentSize | undefined;
148
+ font: commentFont | undefined;
149
+ loc: commentLoc | undefined;
150
+ no: number;
151
+ };
152
+ type nicoScriptReplaceRange = "単" | "全";
153
+ type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
154
+ type nicoScriptReplaceCondition = "完全一致" | "部分一致";
155
+ type nicoScriptBan = {
156
+ start: number;
157
+ end: number;
158
+ };
159
+ type nicoScriptDefault = {
160
+ start: number;
161
+ long: number | undefined;
162
+ color: string | undefined;
163
+ size: commentSize | undefined;
164
+ font: commentFont | undefined;
165
+ loc: commentLoc | undefined;
166
+ };
108
167
  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
- }
168
+ width: number;
169
+ width_max: number;
170
+ width_min: number;
171
+ height: number;
172
+ resized: boolean;
173
+ fontSize: number;
174
+ lineHeight: number;
175
+ };
176
+ type parsedCommand = {
177
+ loc: commentLoc | undefined;
178
+ size: commentSize | undefined;
179
+ fontSize: number | undefined;
180
+ color: string | undefined;
181
+ font: commentFont | undefined;
182
+ full: boolean;
183
+ ender: boolean;
184
+ _live: boolean;
185
+ invisible: boolean;
186
+ long: number | undefined;
187
+ };
188
+ type typeFontSize = {
189
+ [key in commentSize]: {
190
+ default: number;
191
+ resized: number;
192
+ };
193
+ };
194
+ type typeDoubleResizeMaxWidth = {
195
+ [key in "full" | "normal"]: {
196
+ legacy: number;
197
+ default: number;
198
+ };
199
+ };
129
200
  type v1Thread = {
130
- "id": string,
131
- "fork": string,
132
- "commentCount": number,
133
- "comments": { [key: string]:v1Comment }
134
- }
201
+ id: string;
202
+ fork: string;
203
+ commentCount: number;
204
+ comments: { [key: string]: v1Comment };
205
+ };
135
206
  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
- }
207
+ id: string;
208
+ no: number;
209
+ vposMs: number;
210
+ body: string;
211
+ commands: string[];
212
+ userId: string;
213
+ isPremium: boolean;
214
+ score: number;
215
+ postedAt: string;
216
+ nicoruCount: number;
217
+ nicoruId: undefined;
218
+ source: string;
219
+ isMyPost: boolean;
220
+ };
150
221
  type ownerComment = {
151
- "time": string,
152
- "command": string,
153
- "comment": string
154
- }
222
+ time: string;
223
+ command: string;
224
+ comment: string;
225
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpadev-net/niconicomments",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
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/dts/types.d.ts",
@@ -8,9 +8,16 @@
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
9
  "build": "rollup -c rollup.config.js",
10
10
  "watch": "rollup -c rollup.config.js -w",
11
- "typedoc": "typedoc --entryPointStrategy Expand --options tsdoc.json --out ./docs/type/ ./src/",
11
+ "typedoc": "typedoc --entryPointStrategy Expand --out ./docs/type/ ./src/",
12
12
  "copy-dts": "npx copyfiles -u 2 src/@types/*.d.ts dist/dts",
13
- "prepublishOnly": "npm run copy-dts&&npm run build"
13
+ "prepublishOnly": "npm run copy-dts&&npm run build",
14
+ "check-types": "npx tsc --noEmit --jsx react",
15
+ "eslint": "eslint src/**/*.ts*",
16
+ "eslint:fix": "eslint src/**/*.ts* --fix",
17
+ "format": "prettier --write \"src/**/*.{tsx,ts,js,json,css,scss}\"",
18
+ "lint": "npm run eslint&&npm run check-types",
19
+ "lint:fix": "npm run format&&npm run eslint:fix&&npm run check-types",
20
+ "prepare": "husky install"
14
21
  },
15
22
  "repository": {
16
23
  "type": "git",
@@ -30,15 +37,24 @@
30
37
  "homepage": "https://xpadev.net/niconicomments/docs/",
31
38
  "license": "MIT",
32
39
  "devDependencies": {
33
- "@babel/preset-env": "^7.18.2",
40
+ "@babel/core": "^7.18.10",
41
+ "@babel/preset-env": "^7.18.10",
34
42
  "@rollup/plugin-babel": "^5.3.0",
43
+ "@rollup/plugin-commonjs": "^22.0.2",
44
+ "@rollup/plugin-json": "^4.1.0",
35
45
  "@rollup/plugin-node-resolve": "^13.3.0",
36
- "@rollup/plugin-typescript": "^8.3.3",
46
+ "@rollup/plugin-typescript": "^8.3.4",
47
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
48
+ "@typescript-eslint/parser": "^5.33.0",
37
49
  "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",
50
+ "eslint": "^8.21.0",
51
+ "eslint-config-prettier": "8.5.0",
52
+ "husky": "^8.0.0",
53
+ "lint-staged": "^13.0.3",
54
+ "prettier": "2.7.1",
55
+ "rollup": "^2.77.2",
56
+ "typedoc": "^0.23.10",
57
+ "typedoc-plugin-missing-exports": "^0.23.0",
42
58
  "typescript": "^4.7.4"
43
59
  }
44
60
  }