twitter-snap 0.0.10 → 0.0.12

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.
Files changed (52) hide show
  1. package/.eslintrc.json +3 -3
  2. package/README.md +50 -20
  3. package/dist/app/api/twitter/route.d.ts +2 -2
  4. package/dist/app/api/twitter/route.js +18 -18
  5. package/dist/app/api/twitter/route.jsx +71 -0
  6. package/dist/app/api/twitter/route.jsx.map +1 -0
  7. package/dist/app/layout.d.ts +6 -6
  8. package/dist/app/layout.js +10 -10
  9. package/dist/app/layout.jsx +19 -0
  10. package/dist/app/layout.jsx.map +1 -0
  11. package/dist/app/page.d.ts +1 -1
  12. package/dist/app/page.js +22 -22
  13. package/dist/app/page.js.map +1 -1
  14. package/dist/app/page.jsx +56 -0
  15. package/dist/app/page.jsx.map +1 -0
  16. package/dist/cli.d.ts +2 -2
  17. package/dist/cli.js +37 -33
  18. package/dist/cli.js.map +1 -1
  19. package/dist/core/twitterSnap.d.mts +33 -0
  20. package/dist/core/twitterSnap.d.mts.map +1 -0
  21. package/dist/core/twitterSnap.d.ts +47 -32
  22. package/dist/core/twitterSnap.d.ts.map +1 -1
  23. package/dist/core/twitterSnap.js +61 -35
  24. package/dist/core/twitterSnap.js.map +1 -1
  25. package/dist/core/twitterSnap.mjs +102 -0
  26. package/dist/core/twitterSnap.mjs.map +1 -0
  27. package/dist/theme/normal.d.ts +3 -3
  28. package/dist/theme/normal.d.ts.map +1 -1
  29. package/dist/theme/normal.js +50 -211
  30. package/dist/theme/normal.js.map +1 -1
  31. package/dist/theme/normal.jsx +333 -0
  32. package/dist/theme/normal.jsx.map +1 -0
  33. package/dist/theme/normalComponent.d.ts +4 -0
  34. package/dist/theme/normalComponent.d.ts.map +1 -0
  35. package/dist/theme/normalComponent.js +256 -0
  36. package/dist/theme/normalComponent.js.map +1 -0
  37. package/dist/theme/normalUtils.d.ts +17 -0
  38. package/dist/theme/normalUtils.d.ts.map +1 -0
  39. package/dist/theme/normalUtils.js +111 -0
  40. package/dist/theme/normalUtils.js.map +1 -0
  41. package/dist/tsconfig.build.tsbuildinfo +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/dist/utils/cookies.d.ts +1 -1
  44. package/dist/utils/cookies.js +14 -14
  45. package/dist/utils/fonts.d.ts +4 -4
  46. package/dist/utils/fonts.js +12 -12
  47. package/dist/utils/fonts.js.map +1 -1
  48. package/{next.config.js → next.config.cjs} +2 -1
  49. package/package.json +12 -11
  50. package/test/test.ps1 +21 -11
  51. package/tsconfig.build.json +25 -0
  52. package/tsconfig.json +20 -5
package/.eslintrc.json CHANGED
@@ -1,3 +1,3 @@
1
- {
2
- "extends": "next/core-web-vitals"
3
- }
1
+ {
2
+ "extends": "next/core-web-vitals"
3
+ }
package/README.md CHANGED
@@ -4,7 +4,11 @@ Create beautiful Tweet images fast.
4
4
  Fast, good design, Browser is not a dependency.
5
5
 
6
6
  ```shell
7
- npx twitter-snap https://twitter.com/elonmusk/status/1518623997054918657
7
+ npx twitter-snap@latest https://twitter.com/elonmusk/status/15186239970549186570
8
+ ```
9
+
10
+ ```shell
11
+ npx twitter-snap 1518623997054918657
8
12
  ```
9
13
 
10
14
  ![image](./docs/img/output.png)
@@ -15,32 +19,58 @@ npx twitter-snap https://twitter.com/elonmusk/status/1518623997054918657
15
19
  Usage: twitter-snap [options] <string>
16
20
 
17
21
  Arguments:
18
- string tweet url or tweet id
22
+ string tweet url or tweet id
19
23
 
20
24
  Options:
21
- -V, --version output the version number
22
- -o, --output <path> output file path (default: "output.png")
23
- -w, --width <number> image width (default: "600")
24
- -h, --height <number> image height
25
- -t, --theme <string> theme (default: "normal")
26
- --fonts <path> font config file path .json
27
- --emoji <string> emoji type (twemoji,openmoji,blobmoji,noto,fluent,fluentFlat) (default: "twemoji")
28
- --cookies <path> net escape cookie file path .txt
29
- --help display help for command
25
+ -V, --version output the version number
26
+ -o, --output <path> output file path (default: "output.png")
27
+ -w, --width <number> image width (default: "600")
28
+ -h, --height <number> image height
29
+ -t, --theme <string> normal
30
+ --margin <number> margin
31
+ --fonts <path> font config file path .json
32
+ --emoji <string> emoji type (twemoji, openmoji, blobmoji, noto, fluent, fluentFlat) (default: "twemoji")
33
+ --cookies <path> net escape cookie file path .txt
34
+ --auto-photo if the tweet is not a video, save it as an image
35
+ --no-remove-temp no remove temp file
36
+ --help display help for command
37
+ ```
38
+
39
+ ## Output file type
40
+
41
+ ```shell
42
+ npx twitter-snap 1518623997054918657 -o output.png # output.png
43
+ npx twitter-snap 1518623997054918657 -o output.mp4 # Error
44
+ npx twitter-snap 1518623997054918657 -o output.mp4 --auto-photo # output.png
45
+
46
+ npx twitter-snap 1585341984679469056 -o output.png # output.png
47
+ npx twitter-snap 1585341984679469056 -o output.mp4 # output.mp4
48
+ npx twitter-snap 1585341984679469056 -o output.mp4 --auto-photo # output.mp4
30
49
  ```
31
50
 
32
- ### Font
51
+ ## Fonts
33
52
 
34
- You can specify the font by creating a font config file.
53
+ You can specify the font by creating a font config file. (path: `--fonts`)
35
54
 
36
55
  ```json
37
56
  [
38
- {
39
- "data": "./fonts/NotoSansJP-Regular.otf",
40
- "name": "Noto Sans JP",
41
- "weight": 400,
42
- "theme": "normal",
43
- "lang": "ja-JP"
44
- }
57
+ {
58
+ "data": "NotoSansJP-Regular.ttf",
59
+ "name": "Noto Sans JP",
60
+ "weight": 400,
61
+ "theme": "normal",
62
+ "lang": "ja-JP"
63
+ },
64
+ {
65
+ "data": "NotoSansJP-Bold.ttf",
66
+ "name": "Noto Sans JP",
67
+ "weight": 700,
68
+ "theme": "normal",
69
+ "lang": "ja-JP"
70
+ }
45
71
  ]
46
72
  ```
73
+
74
+ ## Dependence
75
+
76
+ - [ffmpeg](https://ffmpeg.org/) (for video)
@@ -1,3 +1,3 @@
1
- import { NextRequest } from "next/server";
2
- export declare function GET(req: NextRequest): Promise<Response>;
1
+ import { NextRequest } from "next/server";
2
+ export declare function GET(req: NextRequest): Promise<Response>;
3
3
  //# sourceMappingURL=route.d.ts.map
@@ -1,19 +1,19 @@
1
- import { TwitterOpenApi } from "twitter-openapi-typescript";
2
- const guest = new TwitterOpenApi().getGuestClient();
3
- export async function GET(req) {
4
- const { searchParams } = new URL(req.url);
5
- const id = searchParams.get("id");
6
- const client = await guest;
7
- if (!id) {
8
- return new Response("Missing id", { status: 400 });
9
- }
10
- const tweet = await client.getDefaultApi().getTweetResultByRestId({
11
- tweetId: id,
12
- });
13
- return new Response(JSON.stringify(tweet), {
14
- headers: {
15
- "content-type": "application/json",
16
- },
17
- });
18
- }
1
+ import { TwitterOpenApi } from "twitter-openapi-typescript";
2
+ const guest = new TwitterOpenApi().getGuestClient();
3
+ export async function GET(req) {
4
+ const { searchParams } = new URL(req.url);
5
+ const id = searchParams.get("id");
6
+ const client = await guest;
7
+ if (!id) {
8
+ return new Response("Missing id", { status: 400 });
9
+ }
10
+ const tweet = await client.getDefaultApi().getTweetResultByRestId({
11
+ tweetId: id,
12
+ });
13
+ return new Response(JSON.stringify(tweet), {
14
+ headers: {
15
+ "content-type": "application/json",
16
+ },
17
+ });
18
+ }
19
19
  //# sourceMappingURL=route.js.map
@@ -0,0 +1,71 @@
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.GET = void 0;
40
+ var twitter_openapi_typescript_1 = require("twitter-openapi-typescript");
41
+ var guest = new twitter_openapi_typescript_1.TwitterOpenApi().getGuestClient();
42
+ function GET(req) {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var searchParams, id, client, tweet;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0:
48
+ searchParams = new URL(req.url).searchParams;
49
+ id = searchParams.get("id");
50
+ return [4 /*yield*/, guest];
51
+ case 1:
52
+ client = _a.sent();
53
+ if (!id) {
54
+ return [2 /*return*/, new Response("Missing id", { status: 400 })];
55
+ }
56
+ return [4 /*yield*/, client.getDefaultApi().getTweetResultByRestId({
57
+ tweetId: id,
58
+ })];
59
+ case 2:
60
+ tweet = _a.sent();
61
+ return [2 /*return*/, new Response(JSON.stringify(tweet), {
62
+ headers: {
63
+ "content-type": "application/json",
64
+ },
65
+ })];
66
+ }
67
+ });
68
+ });
69
+ }
70
+ exports.GET = GET;
71
+ //# sourceMappingURL=route.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.jsx","sourceRoot":"","sources":["../../../../src/app/api/twitter/route.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yEAA4D;AAE5D,IAAM,KAAK,GAAG,IAAI,2CAAc,EAAE,CAAC,cAAc,EAAE,CAAC;AAEpD,SAAsB,GAAG,CAAC,GAAgB;;;;;;oBAChC,YAAY,GAAK,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,aAArB,CAAsB;oBACpC,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBACnB,qBAAM,KAAK,EAAA;;oBAApB,MAAM,GAAG,SAAW;oBAC1B,IAAI,CAAC,EAAE,EAAE;wBACP,sBAAO,IAAI,QAAQ,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAC;qBACpD;oBACa,qBAAM,MAAM,CAAC,aAAa,EAAE,CAAC,sBAAsB,CAAC;4BAChE,OAAO,EAAE,EAAE;yBACZ,CAAC,EAAA;;oBAFI,KAAK,GAAG,SAEZ;oBACF,sBAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;4BACzC,OAAO,EAAE;gCACP,cAAc,EAAE,kBAAkB;6BACnC;yBACF,CAAC,EAAC;;;;CACJ;AAfD,kBAeC"}
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
2
- import type { Metadata } from "next";
3
- export declare const metadata: Metadata;
4
- export default function RootLayout({ children, }: {
5
- children: React.ReactNode;
6
- }): import("react/jsx-runtime").JSX.Element;
1
+ /// <reference types="react" />
2
+ import type { Metadata } from "next";
3
+ export declare const metadata: Metadata;
4
+ export default function RootLayout({ children, }: {
5
+ children: React.ReactNode;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
7
  //# sourceMappingURL=layout.d.ts.map
@@ -1,11 +1,11 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Inter } from "next/font/google";
3
- const inter = Inter({ subsets: ["latin"] });
4
- export const metadata = {
5
- title: "Create Next App",
6
- description: "Generated by create next app",
7
- };
8
- export default function RootLayout({ children, }) {
9
- return (_jsx("html", { lang: "en", children: _jsx("body", { className: inter.className, style: { margin: 0 }, children: children }) }));
10
- }
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Inter } from "next/font/google";
3
+ const inter = Inter({ subsets: ["latin"] });
4
+ export const metadata = {
5
+ title: "Create Next App",
6
+ description: "Generated by create next app",
7
+ };
8
+ export default function RootLayout({ children, }) {
9
+ return (_jsx("html", { lang: "en", children: _jsx("body", { className: inter.className, style: { margin: 0 }, children: children }) }));
10
+ }
11
11
  //# sourceMappingURL=layout.js.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.metadata = void 0;
4
+ var google_1 = require("next/font/google");
5
+ var inter = (0, google_1.Inter)({ subsets: ["latin"] });
6
+ exports.metadata = {
7
+ title: "Create Next App",
8
+ description: "Generated by create next app",
9
+ };
10
+ function RootLayout(_a) {
11
+ var children = _a.children;
12
+ return (<html lang="en">
13
+ <body className={inter.className} style={{ margin: 0 }}>
14
+ {children}
15
+ </body>
16
+ </html>);
17
+ }
18
+ exports.default = RootLayout;
19
+ //# sourceMappingURL=layout.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.jsx","sourceRoot":"","sources":["../../src/app/layout.tsx"],"names":[],"mappings":";;;AACA,2CAAyC;AAEzC,IAAM,KAAK,GAAG,IAAA,cAAK,EAAC,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAE/B,QAAA,QAAQ,GAAa;IAChC,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,8BAA8B;CAC5C,CAAC;AAEF,SAAwB,UAAU,CAAC,EAIlC;QAHC,QAAQ,cAAA;IAIR,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CACb;MAAA,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CACrD;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAZD,6BAYC"}
@@ -1,2 +1,2 @@
1
- export default function Home(): import("react/jsx-runtime").JSX.Element;
1
+ export default function Home(): import("react/jsx-runtime").JSX.Element;
2
2
  //# sourceMappingURL=page.d.ts.map
package/dist/app/page.js CHANGED
@@ -1,23 +1,23 @@
1
- "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useEffect } from "react";
4
- import { useState } from "react";
5
- import Normal from "./../theme/normal";
6
- export default function Home() {
7
- const toAPi = (e) => `/api/twitter?id=${e}`;
8
- const toId = (e) => (isNaN(Number(e)) ? e.split("/").pop() : e);
9
- const [state, setState] = useState(null);
10
- const [id, setId] = useState("1518623997054918657");
11
- useEffect(() => {
12
- fetch(toAPi(toId(id)))
13
- .then((e) => e.json())
14
- .then((e) => setState(e.data));
15
- }, [id]);
16
- return (_jsxs(_Fragment, { children: [_jsx("input", { value: id, onChange: (e) => setId(e.target.value) }), state && (_jsx("div", { style: {
17
- width: "600px",
18
- display: "flex",
19
- justifyContent: "center",
20
- alignItems: "center",
21
- }, children: _jsx(Normal, { data: state }) }))] }));
22
- }
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect } from "react";
4
+ import { useState } from "react";
5
+ import NormalComponent from "./../theme/normalComponent";
6
+ export default function Home() {
7
+ const toAPi = (e) => `/api/twitter?id=${e}`;
8
+ const toId = (e) => (isNaN(Number(e)) ? e.split("/").pop() : e);
9
+ const [state, setState] = useState(null);
10
+ const [id, setId] = useState("1518623997054918657");
11
+ useEffect(() => {
12
+ fetch(toAPi(toId(id)))
13
+ .then((e) => e.json())
14
+ .then((e) => setState(e.data));
15
+ }, [id]);
16
+ return (_jsxs(_Fragment, { children: [_jsx("input", { value: id, onChange: (e) => setId(e.target.value) }), state && (_jsx("div", { style: {
17
+ width: "600px",
18
+ display: "flex",
19
+ justifyContent: "center",
20
+ alignItems: "center",
21
+ }, children: _jsx(NormalComponent, { data: state, video: false }) }))] }));
22
+ }
23
23
  //# sourceMappingURL=page.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/app/page.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAc,EAAO,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,MAAM,CAAC,OAAO,UAAU,IAAI;IAC1B,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,CAAC;IACpD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE,MAAM,CA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,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA2B,IAAI,CAAC,CAAC;IACnE,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;aACnB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACrB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACT,OAAO,CACL,8BACE,gBAAO,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAI,EAC3D,KAAK,IAAI,CACR,cACE,KAAK,EAAE;oBACL,KAAK,EAAE,OAAO;oBACd,OAAO,EAAE,MAAM;oBACf,cAAc,EAAE,QAAQ;oBACxB,UAAU,EAAE,QAAQ;iBACrB,YAED,KAAC,eAAe,IAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAI,GAC1C,CACP,IACA,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ "use client";
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 (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ var react_1 = __importStar(require("react"));
31
+ var react_2 = require("react");
32
+ var normal_1 = __importDefault(require("./../theme/normal"));
33
+ function Home() {
34
+ var toAPi = function (e) { return "/api/twitter?id=".concat(e); };
35
+ var toId = function (e) { return (isNaN(Number(e)) ? e.split("/").pop() : e); };
36
+ var _a = (0, react_2.useState)(null), state = _a[0], setState = _a[1];
37
+ var _b = (0, react_2.useState)("1518623997054918657"), id = _b[0], setId = _b[1];
38
+ (0, react_1.useEffect)(function () {
39
+ fetch(toAPi(toId(id)))
40
+ .then(function (e) { return e.json(); })
41
+ .then(function (e) { return setState(e.data); });
42
+ }, [id]);
43
+ return (<>
44
+ <input value={id} onChange={function (e) { return setId(e.target.value); }}/>
45
+ {state && (<div style={{
46
+ width: "600px",
47
+ display: "flex",
48
+ justifyContent: "center",
49
+ alignItems: "center",
50
+ }}>
51
+ <normal_1.default data={state}/>
52
+ </div>)}
53
+ </>);
54
+ }
55
+ exports.default = Home;
56
+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,EAArB,CAAqB,CAAC,EACzD;MAAA,CAAC,KAAK,IAAI,CACR,CAAC,GAAG,CACF,KAAK,CAAC,CAAC;gBACL,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,MAAM;gBACf,cAAc,EAAE,QAAQ;gBACxB,UAAU,EAAE,QAAQ;aACrB,CAAC,CAEF;UAAA,CAAC,gBAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EACtB;QAAA,EAAE,GAAG,CAAC,CACP,CACH;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC;AA7BD,uBA6BC"}
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ #!/usr/bin/env node
2
+ export {};
3
3
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.js CHANGED
@@ -1,34 +1,38 @@
1
- #!/usr/bin/env node
2
- import { TwitterSnap } from "./core/twitterSnap.js";
3
- import { Command } from "commander";
4
- import { promises as fs } from "fs";
5
- import { getClient } from "./utils/cookies.js";
6
- import { getFonts } from "./utils/fonts.js";
7
- const version = "0.0.10";
8
- const program = new Command();
9
- program.name("twitter-snap").version(version);
10
- program
11
- .argument("<string>", "tweet url or tweet id")
12
- .option("-o, --output <path>", "output file path", "output.png")
13
- .option("-w, --width <number>", "image width", "600")
14
- .option("-h, --height <number>", "image height")
15
- .option("-t, --theme <string>", "theme", "normal")
16
- .option("--fonts <path>", "font config file path .json")
17
- .option("--emoji <string>", "emoji type (twemoji,openmoji,blobmoji,noto,fluent,fluentFlat)", "twemoji")
18
- .option("--cookies <path>", "net escape cookie file path .txt")
19
- .action(async (text, { output, width, height, theme, fonts, emoji, cookies }) => {
20
- const id = isNaN(text) ? text.split("/").pop() : text;
21
- const twitterSnap = new TwitterSnap({
22
- width: parseInt(width),
23
- height: height ? parseInt(height) : undefined,
24
- client: cookies && getClient(cookies),
25
- fonts: fonts && getFonts(fonts),
26
- emoji: emoji,
27
- });
28
- const res = await twitterSnap.render({ id, themeName: theme });
29
- const png = Buffer.from(await res.arrayBuffer());
30
- await fs.writeFile(output, png);
31
- process.exit(0);
32
- });
33
- program.parse(process.argv);
1
+ #!/usr/bin/env node
2
+ import { TwitterSnap } from "./core/twitterSnap.js";
3
+ import { Command } from "commander";
4
+ import { getClient } from "./utils/cookies.js";
5
+ import { getFonts } from "./utils/fonts.js";
6
+ const version = "0.0.10";
7
+ const program = new Command();
8
+ program.name("twitter-snap").version(version);
9
+ const emoji = "(twemoji, openmoji, blobmoji, noto, fluent, fluentFlat)";
10
+ program
11
+ .argument("<string>", "tweet url or tweet id")
12
+ .option("-o, --output <path>", "output file path", "output.png")
13
+ .option("-w, --width <number>", "image width", "600")
14
+ .option("-h, --height <number>", "image height")
15
+ .option("-t, --theme <string>", Object.keys(TwitterSnap.themes).join())
16
+ .option("--margin <number>", "margin")
17
+ .option("--fonts <path>", "font config file path .json")
18
+ .option("--emoji <string>", `emoji type ${emoji}`, "twemoji")
19
+ .option("--cookies <path>", "net escape cookie file path .txt")
20
+ .option("--auto-photo", "if the tweet is not a video, save it as an image")
21
+ .option("--no-remove-temp", "no remove temp file")
22
+ .action(async (text, param) => {
23
+ const id = isNaN(text) ? text.split("/").pop() : text;
24
+ const twitterSnap = new TwitterSnap({
25
+ width: parseInt(param.width),
26
+ height: param.height ? parseInt(param.height) : undefined,
27
+ client: param.cookies ? await getClient(param.cookies) : undefined,
28
+ themeName: param.theme,
29
+ fonts: param.fonts ? await getFonts(param.fonts) : undefined,
30
+ emoji: param.emoji ? param.emoji : undefined,
31
+ autoPhoto: param.autoPhoto ? true : false,
32
+ removeTemp: param.removeTemp ? true : false,
33
+ });
34
+ await twitterSnap.render({ output: param.output, id });
35
+ process.exit(0);
36
+ });
37
+ program.parse(process.argv);
34
38
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAA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,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;QAC5C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QACzC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;KAC5C,CAAC,CAAC;IAEH,MAAM,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAEvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AACL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { ReactElement } from "react";
2
+ import { ImageResponse } from "@vercel/og";
3
+ import { ImageResponseOptions } from "@vercel/og/dist/types";
4
+ import { TwitterOpenApiClient, TweetApiUtilsData } from "twitter-openapi-typescript";
5
+ export type themeComponent = (props: {
6
+ data: TweetApiUtilsData;
7
+ }) => ReactElement;
8
+ type TwitterSnapParams = {
9
+ width: number;
10
+ height?: number;
11
+ client?: TwitterOpenApiClient | Promise<TwitterOpenApiClient>;
12
+ fonts?: ImageResponseOptions["fonts"];
13
+ emoji?: ImageResponseOptions["emoji"];
14
+ };
15
+ type TwitterSnapRenderParams = {
16
+ id: string;
17
+ themeName?: string;
18
+ };
19
+ export declare class TwitterSnap {
20
+ width: number;
21
+ height: number | undefined;
22
+ client: TwitterOpenApiClient | Promise<TwitterOpenApiClient>;
23
+ fonts: ImageResponseOptions["fonts"];
24
+ emoji: ImageResponseOptions["emoji"];
25
+ static themes: {
26
+ [key: string]: themeComponent;
27
+ };
28
+ constructor(param: TwitterSnapParams);
29
+ getClient: () => Promise<TwitterOpenApiClient>;
30
+ render: ({ id, themeName }: TwitterSnapRenderParams) => Promise<ImageResponse>;
31
+ }
32
+ export {};
33
+ //# sourceMappingURL=twitterSnap.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"twitterSnap.d.mts","sourceRoot":"","sources":["../../src/core/twitterSnap.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAEL,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE;IACnC,IAAI,EAAE,iBAAiB,CAAC;CACzB,KAAK,YAAY,CAAC;AAEnB,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9D,KAAK,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,WAAW;IACtB,KAAK,EAAG,MAAM,CAAC;IACf,MAAM,EAAG,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAG,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9D,KAAK,EAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACtC,KAAK,EAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAEtC,MAAM,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAE9C;gBAEU,KAAK,EAAE,iBAAiB;IAQpC,SAAS,sCAKP;IAEF,MAAM,sBAA6B,uBAAuB,4BAaxD;CACH"}
@@ -1,33 +1,48 @@
1
- import { ReactElement } from "react";
2
- import { ImageResponse } from "@vercel/og";
3
- import { ImageResponseOptions } from "@vercel/og/dist/types";
4
- import { TwitterOpenApiClient, TweetApiUtilsData } from "twitter-openapi-typescript";
5
- export type themeComponent = (props: {
6
- data: TweetApiUtilsData;
7
- }) => ReactElement;
8
- type TwitterSnapParams = {
9
- width: number;
10
- height?: number;
11
- client?: TwitterOpenApiClient | Promise<TwitterOpenApiClient>;
12
- fonts?: ImageResponseOptions["fonts"];
13
- emoji?: ImageResponseOptions["emoji"];
14
- };
15
- type TwitterSnapRenderParams = {
16
- id: string;
17
- themeName?: string;
18
- };
19
- export declare class TwitterSnap {
20
- width: number;
21
- height: number | undefined;
22
- client: TwitterOpenApiClient | Promise<TwitterOpenApiClient>;
23
- fonts: ImageResponseOptions["fonts"];
24
- emoji: ImageResponseOptions["emoji"];
25
- static themes: {
26
- [key: string]: themeComponent;
27
- };
28
- constructor(param: TwitterSnapParams);
29
- getClient: () => Promise<TwitterOpenApiClient>;
30
- render: ({ id, themeName }: TwitterSnapRenderParams) => Promise<ImageResponse>;
31
- }
32
- export {};
1
+ import { ReactElement } from "react";
2
+ import { ImageResponse } from "@vercel/og";
3
+ import { ImageResponseOptions } from "@vercel/og/dist/types";
4
+ import { TwitterOpenApiClient, TweetApiUtilsData } from "twitter-openapi-typescript";
5
+ export type ThemeComponent = (props: {
6
+ data: TweetApiUtilsData;
7
+ param: TwitterSnapParams;
8
+ video: boolean;
9
+ }) => {
10
+ writePhoto: (props: {
11
+ output: string;
12
+ data: ImageResponse;
13
+ }) => Promise<void>;
14
+ writeVideo: (props: {
15
+ output: string;
16
+ data: ImageResponse;
17
+ }) => Promise<void>;
18
+ element: ReactElement;
19
+ };
20
+ export type Component = (props: {
21
+ data: TweetApiUtilsData;
22
+ video: boolean;
23
+ }) => ReactElement;
24
+ export type TwitterSnapParams = {
25
+ width: number;
26
+ height?: number;
27
+ client?: TwitterOpenApiClient;
28
+ themeName?: string;
29
+ fonts?: ImageResponseOptions["fonts"];
30
+ emoji?: ImageResponseOptions["emoji"];
31
+ autoPhoto: boolean;
32
+ removeTemp: boolean;
33
+ };
34
+ type TwitterSnapRenderParams = {
35
+ output: string;
36
+ id: string;
37
+ };
38
+ export declare class TwitterSnap {
39
+ private param;
40
+ static themes: {
41
+ [key: string]: ThemeComponent;
42
+ };
43
+ constructor(param: TwitterSnapParams);
44
+ getClient: () => Promise<TwitterOpenApiClient>;
45
+ render: ({ output, id }: TwitterSnapRenderParams) => Promise<void>;
46
+ }
47
+ export {};
33
48
  //# sourceMappingURL=twitterSnap.d.ts.map