@ffflorian/xkcdjs 3.3.8 → 3.4.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/dist/XKCD.d.ts +1 -1
- package/dist/XKCD.js +4 -4
- package/dist/XKCDAPI.d.ts +3 -3
- package/dist/XKCDAPI.js +2 -3
- package/dist/cli.js +34 -1
- package/package.json +10 -10
package/dist/XKCD.d.ts
CHANGED
package/dist/XKCD.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.XKCD = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_client_1 = require("@ffflorian/api-client");
|
|
5
5
|
const XKCDAPI_1 = require("./XKCDAPI");
|
|
6
6
|
class XKCD {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
this.options = Object.assign({ apiUrl: 'https://xkcd.com' }, options);
|
|
9
|
-
this.apiClient =
|
|
9
|
+
this.apiClient = new api_client_1.APIClient(this.options.apiUrl);
|
|
10
10
|
this.api = new XKCDAPI_1.XKCDAPI(this.apiClient, this.options);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Set a new API URL.
|
|
14
14
|
* @param url The new API URL.
|
|
15
15
|
*/
|
|
16
|
-
setApiUrl(
|
|
17
|
-
this.apiClient.
|
|
16
|
+
setApiUrl(newURL) {
|
|
17
|
+
this.apiClient.setBaseURL(newURL);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.XKCD = XKCD;
|
package/dist/XKCDAPI.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { APIClient } from '@ffflorian/api-client';
|
|
2
2
|
import type { ClientOptions, RequestOptions, XKCDResultWithData } from './Interfaces';
|
|
3
3
|
export declare class XKCDAPI {
|
|
4
|
-
protected readonly apiClient:
|
|
4
|
+
protected readonly apiClient: APIClient;
|
|
5
5
|
protected readonly options: ClientOptions;
|
|
6
6
|
private readonly JSON_INFO_FILE;
|
|
7
7
|
private readonly lowestIndex;
|
|
8
|
-
constructor(apiClient:
|
|
8
|
+
constructor(apiClient: APIClient, options: ClientOptions);
|
|
9
9
|
/**
|
|
10
10
|
* Get a comic by index.
|
|
11
11
|
* @param index Index number
|
package/dist/XKCDAPI.js
CHANGED
|
@@ -54,11 +54,10 @@ class XKCDAPI {
|
|
|
54
54
|
}
|
|
55
55
|
getImage(imageUrl) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const { data, headers } = yield this.apiClient.
|
|
57
|
+
const { data, headers } = yield this.apiClient.get(imageUrl, {
|
|
58
58
|
responseType: 'arraybuffer',
|
|
59
|
-
url: imageUrl,
|
|
60
59
|
});
|
|
61
|
-
const contentType = headers
|
|
60
|
+
const contentType = headers.get('content-type');
|
|
62
61
|
return {
|
|
63
62
|
data,
|
|
64
63
|
mimeType: contentType ? String(contentType) : undefined,
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
37
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
38
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,7 +45,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
46
|
const commander_1 = require("commander");
|
|
14
47
|
const fs_1 = require("fs");
|
|
15
|
-
const path = require("path");
|
|
48
|
+
const path = __importStar(require("path"));
|
|
16
49
|
const _1 = require("./");
|
|
17
50
|
function init() {
|
|
18
51
|
return __awaiter(this, arguments, void 0, function* (dir = '.') {
|
package/package.json
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
"author": "Florian Imdahl <git@ffflorian.de>",
|
|
3
3
|
"bin": "dist/cli.js",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"
|
|
6
|
-
"commander": "14.0.
|
|
5
|
+
"@ffflorian/api-client": "2.1.2",
|
|
6
|
+
"commander": "14.0.2"
|
|
7
7
|
},
|
|
8
8
|
"description": "An xkcd API client with a CLI.",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@types/node": "~24",
|
|
11
11
|
"http-status-codes": "2.3.0",
|
|
12
12
|
"nock": "14.0.10",
|
|
13
|
-
"rimraf": "6.0
|
|
13
|
+
"rimraf": "6.1.0",
|
|
14
14
|
"tsx": "4.20.6",
|
|
15
|
-
"typedoc": "0.28.
|
|
15
|
+
"typedoc": "0.28.14",
|
|
16
16
|
"typescript": "5.9.3",
|
|
17
|
-
"vitest": "
|
|
17
|
+
"vitest": "4.0.11"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">= 21"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"name": "@ffflorian/xkcdjs",
|
|
34
34
|
"repository": "https://github.com/ffflorian/api-clients/tree/main/packages/xkcdjs",
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build:ts": "tsc",
|
|
37
|
-
"build:docs": "typedoc --options ../../typedoc.json --out ../../docs/packages/xkcdjs src/index.ts",
|
|
36
|
+
"build:ts": "tsc -p tsconfig.build.json",
|
|
37
|
+
"build:docs": "typedoc --tsconfig tsconfig.build.json --options ../../typedoc.json --out ../../docs/packages/xkcdjs src/index.ts",
|
|
38
38
|
"clean": "rimraf dist",
|
|
39
39
|
"dist": "yarn clean && yarn build:ts",
|
|
40
40
|
"start": "tsx src/cli.ts",
|
|
41
41
|
"test": "vitest"
|
|
42
42
|
},
|
|
43
|
-
"version": "3.
|
|
44
|
-
"gitHead": "
|
|
43
|
+
"version": "3.4.0",
|
|
44
|
+
"gitHead": "b6392f3b78cc68d334526b7ebd5f1375511c769f"
|
|
45
45
|
}
|