@realfavicongenerator/check-favicon 0.4.17 → 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 +0 -0
- package/dist/helper.d.ts +3 -1
- package/dist/helper.js +14 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/touch-icon.js +7 -7
- package/dist/touch-icon.test.js +23 -5
- package/dist/types.d.ts +2 -2
- package/dist/web-app-manifest.js +1 -1
- package/dist/web-app-manifest.test.js +6 -1
- package/fixtures/16x16.png +0 -0
- package/fixtures/180x180.png +0 -0
- package/fixtures/192x192.png +0 -0
- package/fixtures/32x32.png +0 -0
- package/fixtures/48x48.png +0 -0
- package/fixtures/512x512.png +0 -0
- package/fixtures/96x96.png +0 -0
- package/fixtures/happy-face.svg +0 -0
- package/fixtures/logo-transparent.png +0 -0
- package/fixtures/non-square.png +0 -0
- package/jest.config.js +0 -0
- package/package.json +2 -2
- package/src/check.ts +0 -0
- package/src/desktop/desktop.test.ts +0 -0
- package/src/desktop/desktop.ts +0 -0
- package/src/desktop/ico.ts +0 -0
- package/src/google.test.ts +0 -0
- package/src/google.ts +0 -0
- package/src/helper.test.ts +0 -0
- package/src/helper.ts +13 -1
- package/src/index.ts +1 -0
- package/src/test-helper.ts +0 -0
- package/src/touch-icon.test.ts +25 -8
- package/src/touch-icon.ts +7 -7
- package/src/types.ts +2 -2
- package/src/web-app-manifest.test.ts +6 -1
- package/src/web-app-manifest.ts +1 -1
- package/tsconfig.json +0 -0
package/README.md
CHANGED
|
File without changes
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Fetcher } from './types';
|
|
2
|
+
import { FaviconReport, Fetcher } from './types';
|
|
3
3
|
export declare const filePathToReadableStream: (path: string) => Promise<ReadableStream>;
|
|
4
4
|
export declare const filePathToString: (path: string) => Promise<string>;
|
|
5
5
|
export declare const stringToReadableStream: (str: string) => ReadableStream;
|
|
@@ -28,3 +28,5 @@ export declare const parseSizesAttribute: (sizes: string | undefined | null) =>
|
|
|
28
28
|
export declare const bufferToDataUrl: (buffer: Buffer, mimeType: string) => string;
|
|
29
29
|
export declare const filePathToDataUrl: (filePath: string) => Promise<string>;
|
|
30
30
|
export declare const fetchFetcher: Fetcher;
|
|
31
|
+
export declare const reportHasErrors: (report: FaviconReport) => boolean;
|
|
32
|
+
export declare const reportHasWarnings: (report: FaviconReport) => boolean;
|
package/dist/helper.js
CHANGED
|
@@ -12,8 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.fetchFetcher = exports.filePathToDataUrl = exports.bufferToDataUrl = exports.parseSizesAttribute = exports.mergeUrlAndPath = exports.checkIcon = exports.pathToMimeType = exports.readableStreamToBuffer = exports.readableStreamToString = exports.stringToReadableStream = exports.filePathToString = exports.filePathToReadableStream = void 0;
|
|
15
|
+
exports.reportHasWarnings = exports.reportHasErrors = exports.fetchFetcher = exports.filePathToDataUrl = exports.bufferToDataUrl = exports.parseSizesAttribute = exports.mergeUrlAndPath = exports.checkIcon = exports.pathToMimeType = exports.readableStreamToBuffer = exports.readableStreamToString = exports.stringToReadableStream = exports.filePathToString = exports.filePathToReadableStream = void 0;
|
|
16
16
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
|
+
const types_1 = require("./types");
|
|
17
18
|
const sharp_1 = __importDefault(require("sharp"));
|
|
18
19
|
const filePathToReadableStream = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
20
|
const file = yield promises_1.default.open(path, 'r');
|
|
@@ -210,3 +211,15 @@ const fetchFetcher = (url, contentType) => __awaiter(void 0, void 0, void 0, fun
|
|
|
210
211
|
};
|
|
211
212
|
});
|
|
212
213
|
exports.fetchFetcher = fetchFetcher;
|
|
214
|
+
const reportHasErrors = (report) => {
|
|
215
|
+
return report.desktop.messages.some(message => message.status === types_1.CheckerStatus.Error) ||
|
|
216
|
+
report.touchIcon.messages.some(message => message.status === types_1.CheckerStatus.Error) ||
|
|
217
|
+
report.webAppManifest.messages.some(message => message.status === types_1.CheckerStatus.Error);
|
|
218
|
+
};
|
|
219
|
+
exports.reportHasErrors = reportHasErrors;
|
|
220
|
+
const reportHasWarnings = (report) => {
|
|
221
|
+
return report.desktop.messages.some(message => message.status === types_1.CheckerStatus.Warning) ||
|
|
222
|
+
report.touchIcon.messages.some(message => message.status === types_1.CheckerStatus.Warning) ||
|
|
223
|
+
report.webAppManifest.messages.some(message => message.status === types_1.CheckerStatus.Warning);
|
|
224
|
+
};
|
|
225
|
+
exports.reportHasWarnings = reportHasWarnings;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { checkDesktopFavicon, checkSvgFavicon } from "./desktop/desktop";
|
|
|
3
3
|
export { checkTouchIcon } from "./touch-icon";
|
|
4
4
|
export { checkWebAppManifest } from "./web-app-manifest";
|
|
5
5
|
export { checkFavicon } from "./check";
|
|
6
|
+
export { reportHasErrors, reportHasWarnings } from "./helper";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkFavicon = exports.checkWebAppManifest = exports.checkTouchIcon = exports.checkSvgFavicon = exports.checkDesktopFavicon = exports.MessageId = exports.CheckerStatus = void 0;
|
|
3
|
+
exports.reportHasWarnings = exports.reportHasErrors = exports.checkFavicon = exports.checkWebAppManifest = exports.checkTouchIcon = exports.checkSvgFavicon = exports.checkDesktopFavicon = exports.MessageId = exports.CheckerStatus = void 0;
|
|
4
4
|
var types_1 = require("./types");
|
|
5
5
|
Object.defineProperty(exports, "CheckerStatus", { enumerable: true, get: function () { return types_1.CheckerStatus; } });
|
|
6
6
|
Object.defineProperty(exports, "MessageId", { enumerable: true, get: function () { return types_1.MessageId; } });
|
|
@@ -13,3 +13,6 @@ var web_app_manifest_1 = require("./web-app-manifest");
|
|
|
13
13
|
Object.defineProperty(exports, "checkWebAppManifest", { enumerable: true, get: function () { return web_app_manifest_1.checkWebAppManifest; } });
|
|
14
14
|
var check_1 = require("./check");
|
|
15
15
|
Object.defineProperty(exports, "checkFavicon", { enumerable: true, get: function () { return check_1.checkFavicon; } });
|
|
16
|
+
var helper_1 = require("./helper");
|
|
17
|
+
Object.defineProperty(exports, "reportHasErrors", { enumerable: true, get: function () { return helper_1.reportHasErrors; } });
|
|
18
|
+
Object.defineProperty(exports, "reportHasWarnings", { enumerable: true, get: function () { return helper_1.reportHasWarnings; } });
|
package/dist/touch-icon.js
CHANGED
|
@@ -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
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
162
|
-
return { messages,
|
|
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
|
-
|
|
176
|
+
icon: iconReport.icon
|
|
177
177
|
};
|
|
178
178
|
});
|
|
179
179
|
exports.checkTouchIcon = checkTouchIcon;
|
package/dist/touch-icon.test.js
CHANGED
|
@@ -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
|
-
|
|
62
|
-
}).toEqual(Object.assign(Object.assign({}, output), {
|
|
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
|
-
}],
|
|
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
|
-
|
|
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:
|
|
129
|
+
icon: CheckedIcon | null;
|
|
130
130
|
};
|
|
131
131
|
export type FaviconReport = {
|
|
132
132
|
desktop: DesktopFaviconReport;
|
package/dist/web-app-manifest.js
CHANGED
|
@@ -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
|
|
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:
|
|
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
|
}));
|
package/fixtures/16x16.png
CHANGED
|
File without changes
|
package/fixtures/180x180.png
CHANGED
|
File without changes
|
package/fixtures/192x192.png
CHANGED
|
File without changes
|
package/fixtures/32x32.png
CHANGED
|
File without changes
|
package/fixtures/48x48.png
CHANGED
|
File without changes
|
package/fixtures/512x512.png
CHANGED
|
File without changes
|
package/fixtures/96x96.png
CHANGED
|
File without changes
|
package/fixtures/happy-face.svg
CHANGED
|
File without changes
|
|
File without changes
|
package/fixtures/non-square.png
CHANGED
|
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.
|
|
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": "
|
|
43
|
+
"gitHead": "f0e219642ecea42c14a567ba6d64bf639871974c"
|
|
44
44
|
}
|
package/src/check.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/desktop/desktop.ts
CHANGED
|
File without changes
|
package/src/desktop/ico.ts
CHANGED
|
File without changes
|
package/src/google.test.ts
CHANGED
|
File without changes
|
package/src/google.ts
CHANGED
|
File without changes
|
package/src/helper.test.ts
CHANGED
|
File without changes
|
package/src/helper.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs/promises'
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { Fetcher } from './types';
|
|
3
|
+
import { CheckerStatus, FaviconReport, Fetcher } from './types';
|
|
4
4
|
import sharp, { FormatEnum } from 'sharp';
|
|
5
5
|
|
|
6
6
|
export const filePathToReadableStream = async (path: string): Promise<ReadableStream> => {
|
|
@@ -231,3 +231,15 @@ export const fetchFetcher: Fetcher = async (url, contentType) => {
|
|
|
231
231
|
readableStream: res.body
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
+
|
|
235
|
+
export const reportHasErrors = (report: FaviconReport): boolean => {
|
|
236
|
+
return report.desktop.messages.some(message => message.status === CheckerStatus.Error) ||
|
|
237
|
+
report.touchIcon.messages.some(message => message.status === CheckerStatus.Error) ||
|
|
238
|
+
report.webAppManifest.messages.some(message => message.status === CheckerStatus.Error);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export const reportHasWarnings = (report: FaviconReport): boolean => {
|
|
242
|
+
return report.desktop.messages.some(message => message.status === CheckerStatus.Warning) ||
|
|
243
|
+
report.touchIcon.messages.some(message => message.status === CheckerStatus.Warning) ||
|
|
244
|
+
report.webAppManifest.messages.some(message => message.status === CheckerStatus.Warning);
|
|
245
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { checkDesktopFavicon, checkSvgFavicon } from "./desktop/desktop"
|
|
|
15
15
|
export { checkTouchIcon } from "./touch-icon"
|
|
16
16
|
export { checkWebAppManifest } from "./web-app-manifest"
|
|
17
17
|
export { checkFavicon } from "./check"
|
|
18
|
+
export { reportHasErrors, reportHasWarnings } from "./helper"
|
package/src/test-helper.ts
CHANGED
|
File without changes
|
package/src/touch-icon.test.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
70
|
+
icon: result.icon
|
|
71
71
|
}).toEqual({
|
|
72
72
|
...output,
|
|
73
|
-
|
|
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
|
-
}],
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
172
|
+
icon = await checkIcon(
|
|
173
173
|
touchIconUrl,
|
|
174
174
|
processor,
|
|
175
175
|
fetcher,
|
|
176
176
|
undefined
|
|
177
177
|
);
|
|
178
178
|
|
|
179
|
-
return { messages,
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
})
|
package/src/web-app-manifest.ts
CHANGED
|
@@ -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
|
|
260
|
+
return { messages, name, shortName, backgroundColor, themeColor, icon };
|
|
261
261
|
}
|
package/tsconfig.json
CHANGED
|
File without changes
|