@realfavicongenerator/check-favicon 0.4.18 → 0.5.0

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/README.md CHANGED
File without changes
@@ -59,14 +59,14 @@ const checkTouchIconTitle = (baseUrl_1, head_1, ...args_1) => __awaiter(void 0,
59
59
  exports.checkTouchIconTitle = checkTouchIconTitle;
60
60
  const checkTouchIconIcon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [baseUrl_2, head_2, ...args_2], void 0, function* (baseUrl, head, fetcher = helper_1.fetchFetcher) {
61
61
  const messages = [];
62
- let touchIcon = null;
62
+ let icon = null;
63
63
  if (!head) {
64
64
  messages.push({
65
65
  status: types_1.CheckerStatus.Error,
66
66
  id: types_1.MessageId.noHead,
67
67
  text: 'No <head> element'
68
68
  });
69
- return { messages, touchIcon };
69
+ return { messages, icon };
70
70
  }
71
71
  const iconMarkup = head.querySelectorAll("link[rel='apple-touch-icon']");
72
72
  if (iconMarkup.length === 0) {
@@ -75,7 +75,7 @@ const checkTouchIconIcon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [
75
75
  id: types_1.MessageId.noTouchIcon,
76
76
  text: 'No touch icon declared'
77
77
  });
78
- return { messages, touchIcon };
78
+ return { messages, icon };
79
79
  }
80
80
  messages.push({
81
81
  status: types_1.CheckerStatus.Ok,
@@ -97,7 +97,7 @@ const checkTouchIconIcon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [
97
97
  id: types_1.MessageId.noTouchIconHref,
98
98
  text: 'The touch icon has no href'
99
99
  });
100
- return { messages, touchIcon };
100
+ return { messages, icon };
101
101
  }
102
102
  const touchIconUrl = (0, helper_1.mergeUrlAndPath)(baseUrl, iconHref);
103
103
  const processor = {
@@ -158,8 +158,8 @@ const checkTouchIconIcon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [
158
158
  });
159
159
  }
160
160
  };
161
- touchIcon = yield (0, helper_1.checkIcon)(touchIconUrl, processor, fetcher, undefined);
162
- return { messages, touchIcon: touchIcon ? touchIcon.content : null };
161
+ icon = yield (0, helper_1.checkIcon)(touchIconUrl, processor, fetcher, undefined);
162
+ return { messages, icon };
163
163
  });
164
164
  exports.checkTouchIconIcon = checkTouchIconIcon;
165
165
  const getDuplicatedSizes = (sizes) => {
@@ -173,7 +173,7 @@ const checkTouchIcon = (baseUrl_3, head_3, ...args_3) => __awaiter(void 0, [base
173
173
  return {
174
174
  messages: [...titleReport.messages, ...iconReport.messages],
175
175
  appTitle: titleReport.appTitle,
176
- touchIcon: iconReport.touchIcon
176
+ icon: iconReport.icon
177
177
  };
178
178
  });
179
179
  exports.checkTouchIcon = checkTouchIcon;
@@ -58,8 +58,8 @@ const runCheckTouchIconTest = (headFragment_2, output_2, ...args_2) => __awaiter
58
58
  const filteredMessages = result.messages.map(m => ({ status: m.status, id: m.id }));
59
59
  expect({
60
60
  messages: filteredMessages,
61
- touchIcon: result.touchIcon
62
- }).toEqual(Object.assign(Object.assign({}, output), { touchIcon: output.touchIcon || null }));
61
+ icon: result.icon
62
+ }).toEqual(Object.assign(Object.assign({}, output), { icon: output.icon || null }));
63
63
  });
64
64
  test('checkTouchIcon - noHead', () => __awaiter(void 0, void 0, void 0, function* () {
65
65
  yield runCheckTouchIconTest(null, { messages: [{
@@ -83,7 +83,13 @@ test('checkTouchIcon - multipleTouchIcon - no size', () => __awaiter(void 0, voi
83
83
  }, {
84
84
  status: types_1.CheckerStatus.Error,
85
85
  id: types_1.MessageId.duplicatedTouchIconSizes,
86
- }] }, {
86
+ }], icon: {
87
+ content: null,
88
+ url: 'https://example.com/some-icon.png',
89
+ width: null,
90
+ height: null
91
+ },
92
+ }, {
87
93
  'https://example.com/some-icon.png': {
88
94
  status: 200,
89
95
  contentType: 'image/png',
@@ -106,7 +112,14 @@ test('checkTouchIcon - multipleTouchIcon - specific size', () => __awaiter(void
106
112
  }, {
107
113
  status: types_1.CheckerStatus.Error,
108
114
  id: types_1.MessageId.duplicatedTouchIconSizes,
109
- }] }, {
115
+ }],
116
+ icon: {
117
+ content: null,
118
+ url: 'https://example.com/some-icon.png',
119
+ width: null,
120
+ height: null
121
+ },
122
+ }, {
110
123
  'https://example.com/some-icon.png': {
111
124
  status: 200,
112
125
  contentType: 'image/png',
@@ -132,7 +145,12 @@ test('checkTouchIcon - Regular case', () => __awaiter(void 0, void 0, void 0, fu
132
145
  }, {
133
146
  status: types_1.CheckerStatus.Ok,
134
147
  id: types_1.MessageId.touchIconSquare
135
- }], touchIcon: (0, helper_1.bufferToDataUrl)(yield (0, helper_1.readableStreamToBuffer)(yield (0, helper_1.filePathToReadableStream)(testIcon)), 'image/png')
148
+ }], icon: {
149
+ content: (0, helper_1.bufferToDataUrl)(yield (0, helper_1.readableStreamToBuffer)(yield (0, helper_1.filePathToReadableStream)(testIcon)), 'image/png'),
150
+ url: 'https://example.com/some-other-icon.png',
151
+ width: 180,
152
+ height: 180,
153
+ }
136
154
  }, {
137
155
  'https://example.com/some-other-icon.png': {
138
156
  status: 200,
package/dist/types.d.ts CHANGED
@@ -118,7 +118,7 @@ export type TouchIconTitleReport = {
118
118
  };
119
119
  export type TouchIconIconReport = {
120
120
  messages: CheckerMessage[];
121
- touchIcon: string | null;
121
+ icon: CheckedIcon | null;
122
122
  };
123
123
  export type WebAppManifestReport = {
124
124
  messages: CheckerMessage[];
@@ -126,7 +126,7 @@ export type WebAppManifestReport = {
126
126
  shortName?: string;
127
127
  backgroundColor?: string;
128
128
  themeColor?: string;
129
- icon: string | null;
129
+ icon: CheckedIcon | null;
130
130
  };
131
131
  export type FaviconReport = {
132
132
  desktop: DesktopFaviconReport;
@@ -257,6 +257,6 @@ const checkWebAppManifestFile = (manifest, baseUrl, fetcher) => __awaiter(void 0
257
257
  }
258
258
  finally { if (e_1) throw e_1.error; }
259
259
  }
260
- return { messages, name, shortName, backgroundColor, themeColor, icon: icon ? icon.content : null };
260
+ return { messages, name, shortName, backgroundColor, themeColor, icon };
261
261
  });
262
262
  exports.checkWebAppManifestFile = checkWebAppManifestFile;
@@ -167,6 +167,11 @@ test('checkWebAppManifestFile - Everything is fine', () => __awaiter(void 0, voi
167
167
  shortName: 'Short!',
168
168
  backgroundColor: '#123456',
169
169
  themeColor: '#abcdef',
170
- icon: (0, helper_1.bufferToDataUrl)(yield (0, helper_1.readableStreamToBuffer)(yield (0, helper_1.filePathToReadableStream)(testIcon512)), 'image/png')
170
+ icon: {
171
+ content: (0, helper_1.bufferToDataUrl)(yield (0, helper_1.readableStreamToBuffer)(yield (0, helper_1.filePathToReadableStream)(testIcon512)), 'image/png'),
172
+ url: "https://example.com/icon-512.png",
173
+ width: 512,
174
+ height: 512,
175
+ },
171
176
  });
172
177
  }));
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/jest.config.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realfavicongenerator/check-favicon",
3
- "version": "0.4.18",
3
+ "version": "0.5.0",
4
4
  "description": "Check the favicon of a website",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,5 +40,5 @@
40
40
  "robots-parser": "^3.0.1",
41
41
  "sharp": "^0.32.6"
42
42
  },
43
- "gitHead": "6d09c58437b7cd0c00c61fe38c278e8c28099c0a"
43
+ "gitHead": "f0e219642ecea42c14a567ba6d64bf639871974c"
44
44
  }
package/src/check.ts CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
package/src/google.ts CHANGED
File without changes
File without changes
package/src/helper.ts CHANGED
File without changes
package/src/index.ts CHANGED
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  import { parse } from 'node-html-parser'
2
- import { CheckerMessage, CheckerStatus, FetchResponse, MessageId } from "./types";
2
+ import { CheckedIcon, CheckerMessage, CheckerStatus, FetchResponse, MessageId } from "./types";
3
3
  import { checkTouchIcon, checkTouchIconIcon, checkTouchIconTitle, getDuplicatedSizes } from "./touch-icon";
4
4
  import { testFetcher } from './test-helper';
5
5
  import { bufferToDataUrl, filePathToReadableStream, readableStreamToBuffer } from './helper';
@@ -7,7 +7,7 @@ import { bufferToDataUrl, filePathToReadableStream, readableStreamToBuffer } fro
7
7
  type TestOutput = {
8
8
  messages: Pick<CheckerMessage, 'id' | 'status'>[],
9
9
  appTitle?: string,
10
- touchIcon?: string | null
10
+ icon?: CheckedIcon | null,
11
11
  }
12
12
 
13
13
  const runCheckTouchIconTitleTest = async (
@@ -67,10 +67,10 @@ const runCheckTouchIconTest = async (
67
67
  const filteredMessages = result.messages.map(m => ({ status: m.status, id: m.id }));
68
68
  expect({
69
69
  messages: filteredMessages,
70
- touchIcon: result.touchIcon
70
+ icon: result.icon
71
71
  }).toEqual({
72
72
  ...output,
73
- touchIcon: output.touchIcon || null
73
+ icon: output.icon || null
74
74
  });
75
75
  }
76
76
 
@@ -98,7 +98,13 @@ test('checkTouchIcon - multipleTouchIcon - no size', async () => {
98
98
  }, {
99
99
  status: CheckerStatus.Error,
100
100
  id: MessageId.duplicatedTouchIconSizes,
101
- }]}, {
101
+ }], icon: {
102
+ content: null,
103
+ url: 'https://example.com/some-icon.png',
104
+ width: null,
105
+ height: null
106
+ },
107
+ }, {
102
108
  'https://example.com/some-icon.png': {
103
109
  status: 200,
104
110
  contentType: 'image/png',
@@ -122,7 +128,14 @@ test('checkTouchIcon - multipleTouchIcon - specific size', async () => {
122
128
  }, {
123
129
  status: CheckerStatus.Error,
124
130
  id: MessageId.duplicatedTouchIconSizes,
125
- }]}, {
131
+ }],
132
+ icon: {
133
+ content: null,
134
+ url: 'https://example.com/some-icon.png',
135
+ width: null,
136
+ height: null
137
+ },
138
+ }, {
126
139
  'https://example.com/some-icon.png': {
127
140
  status: 200,
128
141
  contentType: 'image/png',
@@ -150,7 +163,12 @@ test('checkTouchIcon - Regular case', async () => {
150
163
  },{
151
164
  status: CheckerStatus.Ok,
152
165
  id: MessageId.touchIconSquare
153
- }], touchIcon: bufferToDataUrl(await readableStreamToBuffer(await filePathToReadableStream(testIcon)), 'image/png')
166
+ }], icon: {
167
+ content: bufferToDataUrl(await readableStreamToBuffer(await filePathToReadableStream(testIcon)), 'image/png'),
168
+ url: 'https://example.com/some-other-icon.png',
169
+ width: 180,
170
+ height: 180,
171
+ }
154
172
  }, {
155
173
  'https://example.com/some-other-icon.png': {
156
174
  status: 200,
@@ -161,7 +179,6 @@ test('checkTouchIcon - Regular case', async () => {
161
179
  })
162
180
 
163
181
 
164
-
165
182
  test('getDuplicatedSizes', () => {
166
183
  // No duplicates
167
184
  expect(getDuplicatedSizes([])).toEqual([]);
package/src/touch-icon.ts CHANGED
@@ -59,7 +59,7 @@ export const checkTouchIconTitle = async (baseUrl: string, head: HTMLElement | n
59
59
 
60
60
  export const checkTouchIconIcon = async (baseUrl: string, head: HTMLElement | null, fetcher: Fetcher = fetchFetcher): Promise<TouchIconIconReport> => {
61
61
  const messages: CheckerMessage[] = [];
62
- let touchIcon: CheckIconOutput | null = null;
62
+ let icon: CheckIconOutput | null = null;
63
63
 
64
64
  if (!head) {
65
65
  messages.push({
@@ -68,7 +68,7 @@ export const checkTouchIconIcon = async (baseUrl: string, head: HTMLElement | nu
68
68
  text: 'No <head> element'
69
69
  });
70
70
 
71
- return { messages, touchIcon };
71
+ return { messages, icon };
72
72
  }
73
73
 
74
74
  const iconMarkup = head.querySelectorAll("link[rel='apple-touch-icon']");
@@ -79,7 +79,7 @@ export const checkTouchIconIcon = async (baseUrl: string, head: HTMLElement | nu
79
79
  text: 'No touch icon declared'
80
80
  });
81
81
 
82
- return { messages, touchIcon };
82
+ return { messages, icon };
83
83
  }
84
84
 
85
85
  messages.push({
@@ -105,7 +105,7 @@ export const checkTouchIconIcon = async (baseUrl: string, head: HTMLElement | nu
105
105
  text: 'The touch icon has no href'
106
106
  });
107
107
 
108
- return { messages, touchIcon };
108
+ return { messages, icon };
109
109
  }
110
110
 
111
111
  const touchIconUrl = mergeUrlAndPath(baseUrl, iconHref);
@@ -169,14 +169,14 @@ export const checkTouchIconIcon = async (baseUrl: string, head: HTMLElement | nu
169
169
  }
170
170
  }
171
171
 
172
- touchIcon = await checkIcon(
172
+ icon = await checkIcon(
173
173
  touchIconUrl,
174
174
  processor,
175
175
  fetcher,
176
176
  undefined
177
177
  );
178
178
 
179
- return { messages, touchIcon: touchIcon ? touchIcon.content : null };
179
+ return { messages, icon };
180
180
  }
181
181
 
182
182
  export const getDuplicatedSizes = (sizes: (string | undefined)[]): (string | undefined)[] => {
@@ -191,6 +191,6 @@ export const checkTouchIcon = async (baseUrl: string, head: HTMLElement | null,
191
191
  return {
192
192
  messages: [...titleReport.messages, ...iconReport.messages],
193
193
  appTitle: titleReport.appTitle,
194
- touchIcon: iconReport.touchIcon
194
+ icon: iconReport.icon
195
195
  }
196
196
  }
package/src/types.ts CHANGED
@@ -134,7 +134,7 @@ export type TouchIconTitleReport = {
134
134
 
135
135
  export type TouchIconIconReport = {
136
136
  messages: CheckerMessage[],
137
- touchIcon: string | null,
137
+ icon: CheckedIcon | null,
138
138
  }
139
139
 
140
140
  export type WebAppManifestReport = {
@@ -143,7 +143,7 @@ export type WebAppManifestReport = {
143
143
  shortName?: string,
144
144
  backgroundColor?: string,
145
145
  themeColor?: string,
146
- icon: string | null
146
+ icon: CheckedIcon | null
147
147
  }
148
148
 
149
149
  export type FaviconReport = {
@@ -191,6 +191,11 @@ test('checkWebAppManifestFile - Everything is fine', async () => {
191
191
  shortName: 'Short!',
192
192
  backgroundColor: '#123456',
193
193
  themeColor: '#abcdef',
194
- icon: bufferToDataUrl(await readableStreamToBuffer(await filePathToReadableStream(testIcon512)), 'image/png')
194
+ icon: {
195
+ content: bufferToDataUrl(await readableStreamToBuffer(await filePathToReadableStream(testIcon512)), 'image/png'),
196
+ url: "https://example.com/icon-512.png",
197
+ width: 512,
198
+ height: 512,
199
+ },
195
200
  });
196
201
  })
@@ -257,5 +257,5 @@ export const checkWebAppManifestFile = async (manifest: any, baseUrl: string, fe
257
257
  }
258
258
  }
259
259
 
260
- return { messages, name, shortName, backgroundColor, themeColor, icon: icon ? icon.content : null };
260
+ return { messages, name, shortName, backgroundColor, themeColor, icon };
261
261
  }
package/tsconfig.json CHANGED
File without changes