@realfavicongenerator/check-favicon 0.0.2 → 0.1.1
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/check.d.ts +3 -0
- package/dist/check.js +27 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/web-manifest.d.ts +1 -1
- package/dist/web-manifest.js +3 -3
- package/dist/web-manifest.test.js +1 -1
- package/package.json +2 -2
- package/src/check.ts +18 -0
- package/src/index.ts +2 -1
- package/src/web-manifest.test.ts +2 -2
- package/src/web-manifest.ts +1 -1
package/dist/check.d.ts
ADDED
package/dist/check.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.checkFavicon = void 0;
|
|
13
|
+
const desktop_1 = require("./desktop/desktop");
|
|
14
|
+
const helper_1 = require("./helper");
|
|
15
|
+
const touch_icon_1 = require("./touch-icon");
|
|
16
|
+
const web_manifest_1 = require("./web-manifest");
|
|
17
|
+
const checkFavicon = (baseUrl_1, head_1, ...args_1) => __awaiter(void 0, [baseUrl_1, head_1, ...args_1], void 0, function* (baseUrl, head, fetcher = helper_1.fetchFetcher) {
|
|
18
|
+
const desktop = yield (0, desktop_1.checkDesktopFavicon)(baseUrl, head, fetcher);
|
|
19
|
+
const touchIcon = yield (0, touch_icon_1.checkTouchIcon)(baseUrl, head, fetcher);
|
|
20
|
+
const webAppManifest = yield (0, web_manifest_1.checkWebAppManifest)(baseUrl, head, fetcher);
|
|
21
|
+
return {
|
|
22
|
+
desktop,
|
|
23
|
+
touchIcon,
|
|
24
|
+
webAppManifest
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
exports.checkFavicon = checkFavicon;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { CheckerStatus, MessageId, CheckerMessage, DesktopFaviconReport, TouchIconTitleReport, TouchIconIconReport, WebManifestReport, FaviconReport, TouchIconReport } from './types';
|
|
2
2
|
export { checkDesktopFavicon, checkSvgFavicon } from "./desktop/desktop";
|
|
3
3
|
export { checkTouchIcon } from "./touch-icon";
|
|
4
|
-
export {
|
|
4
|
+
export { checkWebAppManifest } from "./web-manifest";
|
|
5
|
+
export { checkFavicon } from "./check";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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; } });
|
|
@@ -10,4 +10,6 @@ Object.defineProperty(exports, "checkSvgFavicon", { enumerable: true, get: funct
|
|
|
10
10
|
var touch_icon_1 = require("./touch-icon");
|
|
11
11
|
Object.defineProperty(exports, "checkTouchIcon", { enumerable: true, get: function () { return touch_icon_1.checkTouchIcon; } });
|
|
12
12
|
var web_manifest_1 = require("./web-manifest");
|
|
13
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "checkWebAppManifest", { enumerable: true, get: function () { return web_manifest_1.checkWebAppManifest; } });
|
|
14
|
+
var check_1 = require("./check");
|
|
15
|
+
Object.defineProperty(exports, "checkFavicon", { enumerable: true, get: function () { return check_1.checkFavicon; } });
|
package/dist/web-manifest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { HTMLElement } from "node-html-parser";
|
|
2
2
|
import { Fetcher, WebManifestReport } from "./types";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const checkWebAppManifest: (baseUrl: string, head: HTMLElement | null, fetcher?: Fetcher) => Promise<WebManifestReport>;
|
|
4
4
|
export declare const checkWebManifestFile: (manifest: any, baseUrl: string, fetcher: Fetcher) => Promise<WebManifestReport>;
|
package/dist/web-manifest.js
CHANGED
|
@@ -16,10 +16,10 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
16
16
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.checkWebManifestFile = exports.
|
|
19
|
+
exports.checkWebManifestFile = exports.checkWebAppManifest = void 0;
|
|
20
20
|
const types_1 = require("./types");
|
|
21
21
|
const helper_1 = require("./helper");
|
|
22
|
-
const
|
|
22
|
+
const checkWebAppManifest = (baseUrl_1, head_1, ...args_1) => __awaiter(void 0, [baseUrl_1, head_1, ...args_1], void 0, function* (baseUrl, head, fetcher = helper_1.fetchFetcher) {
|
|
23
23
|
const messages = [];
|
|
24
24
|
let name = undefined;
|
|
25
25
|
let shortName = undefined;
|
|
@@ -85,7 +85,7 @@ const checkWebManifest = (baseUrl_1, head_1, ...args_1) => __awaiter(void 0, [ba
|
|
|
85
85
|
const manifestReport = yield (0, exports.checkWebManifestFile)(parsedManifest, manifestUrl, fetcher);
|
|
86
86
|
return Object.assign(Object.assign({}, manifestReport), { messages: messages.concat(manifestReport.messages) });
|
|
87
87
|
});
|
|
88
|
-
exports.
|
|
88
|
+
exports.checkWebAppManifest = checkWebAppManifest;
|
|
89
89
|
const readableStreamToJson = (stream) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
90
|
const reader = stream.getReader();
|
|
91
91
|
const decoder = new TextDecoder();
|
|
@@ -20,7 +20,7 @@ const helper_1 = require("./helper");
|
|
|
20
20
|
const filterOutput = (report) => (Object.assign(Object.assign({}, report), { messages: report.messages.map(m => ({ status: m.status, id: m.id })) }));
|
|
21
21
|
const runCheckTouchIconTitleTest = (headFragment_1, output_1, ...args_1) => __awaiter(void 0, [headFragment_1, output_1, ...args_1], void 0, function* (headFragment, output, fetchDatabase = {}) {
|
|
22
22
|
const root = headFragment ? (0, node_html_parser_1.default)(headFragment) : null;
|
|
23
|
-
const result = yield (0, web_manifest_1.
|
|
23
|
+
const result = yield (0, web_manifest_1.checkWebAppManifest)('https://example.com/', root, (0, test_helper_1.testFetcher)(fetchDatabase));
|
|
24
24
|
expect(filterOutput(result)).toEqual(Object.assign({ name: undefined, shortName: undefined, backgroundColor: undefined, themeColor: undefined, icon: null }, output));
|
|
25
25
|
});
|
|
26
26
|
test('checkWebManifest - noHead', () => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@realfavicongenerator/check-favicon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Check the favicon of a website",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"decode-ico": "^0.4.1",
|
|
38
38
|
"node-html-parser": "^6.1.13",
|
|
39
|
-
"sharp": "^0.
|
|
39
|
+
"sharp": "^0.32.6"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/check.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { checkDesktopFavicon } from "./desktop/desktop";
|
|
2
|
+
import { fetchFetcher } from "./helper";
|
|
3
|
+
import { checkTouchIcon } from "./touch-icon";
|
|
4
|
+
import { FaviconReport, Fetcher } from "./types";
|
|
5
|
+
import { HTMLElement } from 'node-html-parser'
|
|
6
|
+
import { checkWebAppManifest } from "./web-manifest";
|
|
7
|
+
|
|
8
|
+
export const checkFavicon = async (baseUrl: string, head: HTMLElement | null, fetcher: Fetcher = fetchFetcher): Promise<FaviconReport> => {
|
|
9
|
+
const desktop = await checkDesktopFavicon(baseUrl, head, fetcher);
|
|
10
|
+
const touchIcon = await checkTouchIcon(baseUrl, head, fetcher);
|
|
11
|
+
const webAppManifest = await checkWebAppManifest(baseUrl, head, fetcher);
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
desktop,
|
|
15
|
+
touchIcon,
|
|
16
|
+
webAppManifest
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -13,4 +13,5 @@ export {
|
|
|
13
13
|
|
|
14
14
|
export { checkDesktopFavicon, checkSvgFavicon } from "./desktop/desktop"
|
|
15
15
|
export { checkTouchIcon } from "./touch-icon"
|
|
16
|
-
export {
|
|
16
|
+
export { checkWebAppManifest } from "./web-manifest"
|
|
17
|
+
export { checkFavicon } from "./check"
|
package/src/web-manifest.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import parse from "node-html-parser";
|
|
2
2
|
import { CheckerMessage, CheckerStatus, FetchResponse, MessageId, WebManifestReport } from "./types";
|
|
3
|
-
import {
|
|
3
|
+
import { checkWebAppManifest, checkWebManifestFile } from "./web-manifest";
|
|
4
4
|
import { testFetcher } from "./test-helper";
|
|
5
5
|
import { bufferToDataUrl, filePathToReadableStream, readableStreamToBuffer } from "./helper";
|
|
6
6
|
|
|
@@ -24,7 +24,7 @@ const runCheckTouchIconTitleTest = async (
|
|
|
24
24
|
fetchDatabase: { [url: string]: FetchResponse } = {}
|
|
25
25
|
) => {
|
|
26
26
|
const root = headFragment ? parse(headFragment) : null;
|
|
27
|
-
const result = await
|
|
27
|
+
const result = await checkWebAppManifest('https://example.com/', root, testFetcher(fetchDatabase));
|
|
28
28
|
expect(filterOutput(result)).toEqual({
|
|
29
29
|
name: undefined,
|
|
30
30
|
shortName: undefined,
|
package/src/web-manifest.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { HTMLElement } from "node-html-parser";
|
|
|
2
2
|
import { CheckerMessage, CheckerStatus, Fetcher, MessageId, WebManifestReport } from "./types";
|
|
3
3
|
import { CheckIconProcessor, checkIcon, fetchFetcher, mergeUrlAndPath, pathToMimeType } from "./helper";
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const checkWebAppManifest = async (baseUrl: string, head: HTMLElement | null, fetcher: Fetcher = fetchFetcher): Promise<WebManifestReport> => {
|
|
6
6
|
const messages: CheckerMessage[] = [];
|
|
7
7
|
let name = undefined;
|
|
8
8
|
let shortName = undefined;
|