twitter-snap 0.0.1 → 0.0.2
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/assets/LICENSE_OFL.txt +92 -0
- package/dist/assets/NotoSansCJKjp-Bold.otf +0 -0
- package/dist/assets/NotoSansCJKjp-Regular.otf +0 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +80 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/twitterSnap.d.ts +51 -0
- package/dist/core/twitterSnap.d.ts.map +1 -0
- package/dist/core/twitterSnap.js +323 -0
- package/dist/core/twitterSnap.js.map +1 -0
- package/dist/style/normal.d.ts +4 -0
- package/dist/style/normal.d.ts.map +1 -0
- package/dist/style/normal.js +56 -0
- package/dist/style/normal.js.map +1 -0
- package/dist/utils/example.d.ts +8 -0
- package/dist/utils/example.d.ts.map +1 -0
- package/dist/utils/example.js +10 -0
- package/dist/utils/example.js.map +1 -0
- package/package.json +2 -2
- package/src/cli.ts +1 -1
- package/output.png +0 -0
- package/public/index.html +0 -15
- /package/{assets → dist/assets}/README +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
This Font Software is licensed under the SIL Open Font License,
|
|
2
|
+
Version 1.1.
|
|
3
|
+
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
PREAMBLE
|
|
12
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
13
|
+
development of collaborative font projects, to support the font
|
|
14
|
+
creation efforts of academic and linguistic communities, and to
|
|
15
|
+
provide a free and open framework in which fonts may be shared and
|
|
16
|
+
improved in partnership with others.
|
|
17
|
+
|
|
18
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
19
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
20
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
redistributed and/or sold with any software provided that any reserved
|
|
22
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
23
|
+
however, cannot be released under any other type of license. The
|
|
24
|
+
requirement for fonts to remain under this license does not apply to
|
|
25
|
+
any document created using the fonts or their derivatives.
|
|
26
|
+
|
|
27
|
+
DEFINITIONS
|
|
28
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
29
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
30
|
+
include source files, build scripts and documentation.
|
|
31
|
+
|
|
32
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
33
|
+
copyright statement(s).
|
|
34
|
+
|
|
35
|
+
"Original Version" refers to the collection of Font Software
|
|
36
|
+
components as distributed by the Copyright Holder(s).
|
|
37
|
+
|
|
38
|
+
"Modified Version" refers to any derivative made by adding to,
|
|
39
|
+
deleting, or substituting -- in part or in whole -- any of the
|
|
40
|
+
components of the Original Version, by changing formats or by porting
|
|
41
|
+
the Font Software to a new environment.
|
|
42
|
+
|
|
43
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
44
|
+
writer or other person who contributed to the Font Software.
|
|
45
|
+
|
|
46
|
+
PERMISSION & CONDITIONS
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
48
|
+
a copy of the Font Software, to use, study, copy, merge, embed,
|
|
49
|
+
modify, redistribute, and sell modified and unmodified copies of the
|
|
50
|
+
Font Software, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
1) Neither the Font Software nor any of its individual components, in
|
|
53
|
+
Original or Modified Versions, may be sold by itself.
|
|
54
|
+
|
|
55
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
56
|
+
redistributed and/or sold with any software, provided that each copy
|
|
57
|
+
contains the above copyright notice and this license. These can be
|
|
58
|
+
included either as stand-alone text files, human-readable headers or
|
|
59
|
+
in the appropriate machine-readable metadata fields within text or
|
|
60
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
61
|
+
|
|
62
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
63
|
+
Name(s) unless explicit written permission is granted by the
|
|
64
|
+
corresponding Copyright Holder. This restriction only applies to the
|
|
65
|
+
primary font name as presented to the users.
|
|
66
|
+
|
|
67
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
68
|
+
Software shall not be used to promote, endorse or advertise any
|
|
69
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
70
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
71
|
+
permission.
|
|
72
|
+
|
|
73
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
74
|
+
must be distributed entirely under this license, and must not be
|
|
75
|
+
distributed under any other license. The requirement for fonts to
|
|
76
|
+
remain under this license does not apply to any document created using
|
|
77
|
+
the Font Software.
|
|
78
|
+
|
|
79
|
+
TERMINATION
|
|
80
|
+
This license becomes null and void if any of the above conditions are
|
|
81
|
+
not met.
|
|
82
|
+
|
|
83
|
+
DISCLAIMER
|
|
84
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
87
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
88
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
89
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
90
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
92
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
Binary file
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
var twitterSnap_1 = require("./core/twitterSnap");
|
|
40
|
+
var commander_1 = require("commander");
|
|
41
|
+
var version = "0.0.2";
|
|
42
|
+
var font = "assets/NotoSansCJKjp-Regular.otf";
|
|
43
|
+
var boldFont = "assets/NotoSansCJKjp-Bold.otf";
|
|
44
|
+
var program = new commander_1.Command();
|
|
45
|
+
program.name("twitter-snap").version(version);
|
|
46
|
+
program
|
|
47
|
+
.argument("<string>", "tweet url or tweet id")
|
|
48
|
+
.option("-o, --output <path>", "output file path", "output.png")
|
|
49
|
+
.option("-w, --width <number>", "image width", "600")
|
|
50
|
+
.option("-h, --height <number>", "image height", "400")
|
|
51
|
+
.option("--font <path>", "font path", font)
|
|
52
|
+
.option("--bold-font <path>", "bold font path", boldFont)
|
|
53
|
+
.action(function (text, _a) {
|
|
54
|
+
var output = _a.output, width = _a.width, height = _a.height, font = _a.font, boldFont = _a.boldFont;
|
|
55
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var id, twitterSnap, writer;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
id = isNaN(text) ? text.split("/").pop() : text;
|
|
61
|
+
twitterSnap = new twitterSnap_1.TwitterSnap({
|
|
62
|
+
width: parseInt(width),
|
|
63
|
+
height: parseInt(height),
|
|
64
|
+
font: font,
|
|
65
|
+
boldFont: boldFont,
|
|
66
|
+
});
|
|
67
|
+
return [4 /*yield*/, twitterSnap.render(id)];
|
|
68
|
+
case 1:
|
|
69
|
+
writer = _b.sent();
|
|
70
|
+
return [4 /*yield*/, writer.save(output)];
|
|
71
|
+
case 2:
|
|
72
|
+
_b.sent();
|
|
73
|
+
process.exit(0);
|
|
74
|
+
return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
program.parse(process.argv);
|
|
80
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAiD;AACjD,uCAAoC;AAEpC,IAAM,OAAO,GAAG,OAAO,CAAC;AACxB,IAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,IAAM,QAAQ,GAAG,+BAA+B,CAAC;AAEjD,IAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9C,OAAO;KACJ,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;KAC7C,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,EAAE,YAAY,CAAC;KAC/D,MAAM,CAAC,sBAAsB,EAAE,aAAa,EAAE,KAAK,CAAC;KACpD,MAAM,CAAC,uBAAuB,EAAE,cAAc,EAAE,KAAK,CAAC;KACtD,MAAM,CAAC,eAAe,EAAE,WAAW,EAAE,IAAI,CAAC;KAC1C,MAAM,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,QAAQ,CAAC;KACxD,MAAM,CAAC,UAAO,IAAI,EAAE,EAAyC;QAAvC,MAAM,YAAA,EAAE,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAA,EAAE,QAAQ,cAAA;;;;;;oBACpD,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;oBAChD,WAAW,GAAG,IAAI,yBAAW,CAAC;wBAClC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC;wBACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;wBACxB,IAAI,EAAE,IAAI;wBACV,QAAQ,EAAE,QAAQ;qBACnB,CAAC,CAAC;oBACY,qBAAM,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,EAAA;;oBAArC,MAAM,GAAG,SAA4B;oBAC3C,qBAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAA;;oBAAzB,SAAyB,CAAC;oBAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;;;;CACjB,CAAC,CAAC;AACL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SatoriOptions } from "satori";
|
|
3
|
+
import { Transformer } from "@napi-rs/image";
|
|
4
|
+
export type StyleComponent = (props: {
|
|
5
|
+
name: string;
|
|
6
|
+
id: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
text: string;
|
|
9
|
+
}) => React.ReactElement;
|
|
10
|
+
type TwitterSnapParams = {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
font: string;
|
|
14
|
+
boldFont: string;
|
|
15
|
+
lang?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare class TwitterSnap {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
option: SatoriOptions;
|
|
21
|
+
constructor(param: TwitterSnapParams);
|
|
22
|
+
render: (id: string) => Promise<TwitterSnapWriter>;
|
|
23
|
+
}
|
|
24
|
+
type TwitterSnapWriterParams = {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
svg: string;
|
|
28
|
+
};
|
|
29
|
+
export declare class TwitterSnapWriter {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
data: string;
|
|
33
|
+
_trasformer: Transformer | undefined;
|
|
34
|
+
constructor(param: TwitterSnapWriterParams);
|
|
35
|
+
get trasformer(): Transformer;
|
|
36
|
+
save: (output: string) => Promise<void>;
|
|
37
|
+
svg: (output: string) => Promise<void>;
|
|
38
|
+
raw: (output: string) => Promise<void>;
|
|
39
|
+
jpeg: (output: string) => Promise<void>;
|
|
40
|
+
png: (output: string) => Promise<void>;
|
|
41
|
+
bmp: (output: string) => Promise<void>;
|
|
42
|
+
ico: (output: string) => Promise<void>;
|
|
43
|
+
tiff: (output: string) => Promise<void>;
|
|
44
|
+
webp: (output: string) => Promise<void>;
|
|
45
|
+
avif: (output: string) => Promise<void>;
|
|
46
|
+
pnm: (output: string) => Promise<void>;
|
|
47
|
+
tga: (output: string) => Promise<void>;
|
|
48
|
+
farbfeld: (output: string) => Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=twitterSnap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twitterSnap.d.ts","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WAAkB,MAAM,mBAGzB;IAEF,GAAG,WAAkB,MAAM,mBAGzB;IACF,IAAI,WAAkB,MAAM,mBAG1B;IACF,IAAI,WAAkB,MAAM,mBAG1B;IACF,IAAI,WAAkB,MAAM,mBAG1B;IACF,GAAG,WAAkB,MAAM,mBAGzB;IACF,GAAG,WAAkB,MAAM,mBAGzB;IACF,QAAQ,WAAkB,MAAM,mBAG9B;CACH"}
|
|
@@ -0,0 +1,323 @@
|
|
|
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.TwitterSnapWriter = exports.TwitterSnap = void 0;
|
|
40
|
+
var satori_1 = require("satori");
|
|
41
|
+
var image_1 = require("@napi-rs/image");
|
|
42
|
+
var normal_1 = require("./../style/normal");
|
|
43
|
+
var fs = require("fs");
|
|
44
|
+
var twitter_openapi_typescript_1 = require("twitter-openapi-typescript");
|
|
45
|
+
var TwitterSnap = /** @class */ (function () {
|
|
46
|
+
function TwitterSnap(param) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
this.render = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
49
|
+
var client, tweet, data, svg;
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0: return [4 /*yield*/, new twitter_openapi_typescript_1.TwitterOpenApi().getGuestClient()];
|
|
53
|
+
case 1:
|
|
54
|
+
client = _a.sent();
|
|
55
|
+
return [4 /*yield*/, client.getDefaultApi().getTweetResultByRestId({
|
|
56
|
+
tweetId: id,
|
|
57
|
+
})];
|
|
58
|
+
case 2:
|
|
59
|
+
tweet = _a.sent();
|
|
60
|
+
data = {
|
|
61
|
+
name: tweet.data.user.legacy.name,
|
|
62
|
+
id: tweet.data.user.legacy.screenName,
|
|
63
|
+
icon: tweet.data.user.legacy.profileImageUrlHttps,
|
|
64
|
+
text: tweet.data.tweet.legacy.fullText,
|
|
65
|
+
};
|
|
66
|
+
return [4 /*yield*/, (0, satori_1.default)((0, normal_1.default)(data), this.option)];
|
|
67
|
+
case 3:
|
|
68
|
+
svg = _a.sent();
|
|
69
|
+
return [2 /*return*/, new TwitterSnapWriter({
|
|
70
|
+
width: this.width,
|
|
71
|
+
height: this.height,
|
|
72
|
+
svg: svg,
|
|
73
|
+
})];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}); };
|
|
77
|
+
this.width = param.width;
|
|
78
|
+
this.height = param.height;
|
|
79
|
+
this.option = {
|
|
80
|
+
width: this.width,
|
|
81
|
+
height: this.height,
|
|
82
|
+
fonts: [
|
|
83
|
+
{
|
|
84
|
+
name: "Regular",
|
|
85
|
+
data: fs.readFileSync(param.font),
|
|
86
|
+
weight: 400,
|
|
87
|
+
style: "normal",
|
|
88
|
+
lang: param.lang,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "Bold",
|
|
92
|
+
data: fs.readFileSync(param.boldFont),
|
|
93
|
+
weight: 700,
|
|
94
|
+
style: "normal",
|
|
95
|
+
lang: param.lang,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return TwitterSnap;
|
|
101
|
+
}());
|
|
102
|
+
exports.TwitterSnap = TwitterSnap;
|
|
103
|
+
var TwitterSnapWriter = /** @class */ (function () {
|
|
104
|
+
function TwitterSnapWriter(param) {
|
|
105
|
+
var _this = this;
|
|
106
|
+
this.save = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
107
|
+
var ext, exts, method;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
ext = output.split(".").pop();
|
|
112
|
+
exts = {
|
|
113
|
+
raw: this.raw,
|
|
114
|
+
svg: this.svg,
|
|
115
|
+
png: this.png,
|
|
116
|
+
jpeg: this.jpeg,
|
|
117
|
+
jpg: this.jpeg,
|
|
118
|
+
jpe: this.jpeg,
|
|
119
|
+
bmp: this.bmp,
|
|
120
|
+
dib: this.bmp,
|
|
121
|
+
rle: this.bmp,
|
|
122
|
+
"2bp": this.bmp,
|
|
123
|
+
"2pbb": this.bmp,
|
|
124
|
+
ico: this.ico,
|
|
125
|
+
cur: this.ico,
|
|
126
|
+
tif: this.tiff,
|
|
127
|
+
webp: this.webp,
|
|
128
|
+
avif: this.avif,
|
|
129
|
+
pnm: this.pnm,
|
|
130
|
+
tga: this.tga,
|
|
131
|
+
tpic: this.tga,
|
|
132
|
+
ff: this.farbfeld,
|
|
133
|
+
};
|
|
134
|
+
method = exts[ext];
|
|
135
|
+
if (!method) {
|
|
136
|
+
throw new Error("Unsupported file format");
|
|
137
|
+
}
|
|
138
|
+
return [4 /*yield*/, method(output)];
|
|
139
|
+
case 1:
|
|
140
|
+
_a.sent();
|
|
141
|
+
return [2 /*return*/];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); };
|
|
145
|
+
this.svg = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
146
|
+
return __generator(this, function (_a) {
|
|
147
|
+
switch (_a.label) {
|
|
148
|
+
case 0: return [4 /*yield*/, fs.promises.writeFile(output, this.data)];
|
|
149
|
+
case 1:
|
|
150
|
+
_a.sent();
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}); };
|
|
155
|
+
this.raw = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0: return [4 /*yield*/, fs.promises.writeFile(output, this.data)];
|
|
159
|
+
case 1:
|
|
160
|
+
_a.sent();
|
|
161
|
+
return [2 /*return*/];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}); };
|
|
165
|
+
this.jpeg = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
166
|
+
var data;
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
switch (_a.label) {
|
|
169
|
+
case 0: return [4 /*yield*/, this.trasformer.jpeg()];
|
|
170
|
+
case 1:
|
|
171
|
+
data = _a.sent();
|
|
172
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
173
|
+
case 2:
|
|
174
|
+
_a.sent();
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}); };
|
|
179
|
+
this.png = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
180
|
+
var data;
|
|
181
|
+
return __generator(this, function (_a) {
|
|
182
|
+
switch (_a.label) {
|
|
183
|
+
case 0: return [4 /*yield*/, this.trasformer.png()];
|
|
184
|
+
case 1:
|
|
185
|
+
data = _a.sent();
|
|
186
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
187
|
+
case 2:
|
|
188
|
+
_a.sent();
|
|
189
|
+
return [2 /*return*/];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}); };
|
|
193
|
+
this.bmp = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
194
|
+
var data;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
switch (_a.label) {
|
|
197
|
+
case 0: return [4 /*yield*/, this.trasformer.bmp()];
|
|
198
|
+
case 1:
|
|
199
|
+
data = _a.sent();
|
|
200
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
201
|
+
case 2:
|
|
202
|
+
_a.sent();
|
|
203
|
+
return [2 /*return*/];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}); };
|
|
207
|
+
this.ico = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
208
|
+
var data;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0: return [4 /*yield*/, this.trasformer.ico()];
|
|
212
|
+
case 1:
|
|
213
|
+
data = _a.sent();
|
|
214
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
215
|
+
case 2:
|
|
216
|
+
_a.sent();
|
|
217
|
+
return [2 /*return*/];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}); };
|
|
221
|
+
this.tiff = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
222
|
+
var data;
|
|
223
|
+
return __generator(this, function (_a) {
|
|
224
|
+
switch (_a.label) {
|
|
225
|
+
case 0: return [4 /*yield*/, this.trasformer.tiff()];
|
|
226
|
+
case 1:
|
|
227
|
+
data = _a.sent();
|
|
228
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
229
|
+
case 2:
|
|
230
|
+
_a.sent();
|
|
231
|
+
return [2 /*return*/];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}); };
|
|
235
|
+
this.webp = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
236
|
+
var data;
|
|
237
|
+
return __generator(this, function (_a) {
|
|
238
|
+
switch (_a.label) {
|
|
239
|
+
case 0: return [4 /*yield*/, this.trasformer.webp()];
|
|
240
|
+
case 1:
|
|
241
|
+
data = _a.sent();
|
|
242
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
243
|
+
case 2:
|
|
244
|
+
_a.sent();
|
|
245
|
+
return [2 /*return*/];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}); };
|
|
249
|
+
this.avif = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
250
|
+
var data;
|
|
251
|
+
return __generator(this, function (_a) {
|
|
252
|
+
switch (_a.label) {
|
|
253
|
+
case 0: return [4 /*yield*/, this.trasformer.avif()];
|
|
254
|
+
case 1:
|
|
255
|
+
data = _a.sent();
|
|
256
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
257
|
+
case 2:
|
|
258
|
+
_a.sent();
|
|
259
|
+
return [2 /*return*/];
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}); };
|
|
263
|
+
this.pnm = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
264
|
+
var data;
|
|
265
|
+
return __generator(this, function (_a) {
|
|
266
|
+
switch (_a.label) {
|
|
267
|
+
case 0: return [4 /*yield*/, this.trasformer.pnm()];
|
|
268
|
+
case 1:
|
|
269
|
+
data = _a.sent();
|
|
270
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
271
|
+
case 2:
|
|
272
|
+
_a.sent();
|
|
273
|
+
return [2 /*return*/];
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}); };
|
|
277
|
+
this.tga = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
278
|
+
var data;
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0: return [4 /*yield*/, this.trasformer.tga()];
|
|
282
|
+
case 1:
|
|
283
|
+
data = _a.sent();
|
|
284
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
285
|
+
case 2:
|
|
286
|
+
_a.sent();
|
|
287
|
+
return [2 /*return*/];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}); };
|
|
291
|
+
this.farbfeld = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
292
|
+
var data;
|
|
293
|
+
return __generator(this, function (_a) {
|
|
294
|
+
switch (_a.label) {
|
|
295
|
+
case 0: return [4 /*yield*/, this.trasformer.farbfeld()];
|
|
296
|
+
case 1:
|
|
297
|
+
data = _a.sent();
|
|
298
|
+
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
299
|
+
case 2:
|
|
300
|
+
_a.sent();
|
|
301
|
+
return [2 /*return*/];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}); };
|
|
305
|
+
this.width = param.width;
|
|
306
|
+
this.height = param.height;
|
|
307
|
+
this.data = param.svg;
|
|
308
|
+
}
|
|
309
|
+
Object.defineProperty(TwitterSnapWriter.prototype, "trasformer", {
|
|
310
|
+
get: function () {
|
|
311
|
+
if (!this._trasformer) {
|
|
312
|
+
this._trasformer = image_1.Transformer.fromSvg(this.data);
|
|
313
|
+
this._trasformer.crop(0, 0, this.width, this.height);
|
|
314
|
+
}
|
|
315
|
+
return this._trasformer;
|
|
316
|
+
},
|
|
317
|
+
enumerable: false,
|
|
318
|
+
configurable: true
|
|
319
|
+
});
|
|
320
|
+
return TwitterSnapWriter;
|
|
321
|
+
}());
|
|
322
|
+
exports.TwitterSnapWriter = TwitterSnapWriter;
|
|
323
|
+
//# sourceMappingURL=twitterSnap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twitterSnap.js","sourceRoot":"","sources":["../../src/core/twitterSnap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA+C;AAC/C,wCAA6C;AAC7C,4CAAuC;AACvC,uBAAyB;AAEzB,yEAA4D;AAiB5D;IAKE,qBAAY,KAAwB;QAApC,iBAwBC;QAED,WAAM,GAAG,UAAO,EAAU;;;;4BACT,qBAAM,IAAI,2CAAc,EAAE,CAAC,cAAc,EAAE,EAAA;;wBAApD,MAAM,GAAG,SAA2C;wBAC5C,qBAAM,MAAM,CAAC,aAAa,EAAE,CAAC,sBAAsB,CAAC;gCAChE,OAAO,EAAE,EAAE;6BACZ,CAAC,EAAA;;wBAFI,KAAK,GAAG,SAEZ;wBACI,IAA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;QACF,aAAQ,GAAG,UAAO,MAAc;;;;4BACjB,qBAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAA;;wBAAvC,IAAI,GAAG,SAAgC;wBAC7C,qBAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,EAAA;;wBAAzC,SAAyC,CAAC;;;;aAC3C,CAAC;QA9FA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC;IACxB,CAAC;IAED,sBAAI,yCAAU;aAAd;YACE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBACrB,IAAI,CAAC,WAAW,GAAG,mBAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAClD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;aACtD;YACD,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;;;OAAA;IAoFH,wBAAC;AAAD,CAAC,AAtGD,IAsGC;AAtGY,8CAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normal.d.ts","sourceRoot":"","sources":["../../src/style/normal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,QAAA,MAAM,MAAM,EAAE,cA+Eb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
+
var Normal = function (_a) {
|
|
16
|
+
var name = _a.name, id = _a.id, icon = _a.icon, text = _a.text;
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)("div", __assign({ style: {
|
|
18
|
+
display: "flex",
|
|
19
|
+
justifyContent: "center",
|
|
20
|
+
alignItems: "center",
|
|
21
|
+
width: "100%",
|
|
22
|
+
height: "100%",
|
|
23
|
+
background: "linear-gradient(-45deg, #0077F2ee 0%, #1DA1F2ee 50%,#4CFFE2ee 100%)",
|
|
24
|
+
} }, { children: (0, jsx_runtime_1.jsxs)("div", __assign({ style: {
|
|
25
|
+
width: "550px",
|
|
26
|
+
background: "white",
|
|
27
|
+
display: "flex",
|
|
28
|
+
flexDirection: "column",
|
|
29
|
+
borderRadius: "10px",
|
|
30
|
+
padding: "12px",
|
|
31
|
+
} }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: {
|
|
32
|
+
display: "flex",
|
|
33
|
+
} }, { children: [(0, jsx_runtime_1.jsx)("img", { alt: "icon", style: {
|
|
34
|
+
width: "40px",
|
|
35
|
+
height: "40px",
|
|
36
|
+
borderRadius: "50%",
|
|
37
|
+
marginRight: "12px",
|
|
38
|
+
}, src: icon }), (0, jsx_runtime_1.jsxs)("div", __assign({ style: {
|
|
39
|
+
display: "flex",
|
|
40
|
+
flexDirection: "column",
|
|
41
|
+
} }, { children: [(0, jsx_runtime_1.jsx)("p", __assign({ style: {
|
|
42
|
+
fontSize: "15px",
|
|
43
|
+
fontWeight: "bold",
|
|
44
|
+
margin: "0px",
|
|
45
|
+
} }, { children: name })), (0, jsx_runtime_1.jsx)("p", __assign({ style: {
|
|
46
|
+
fontSize: "15px",
|
|
47
|
+
margin: "0px",
|
|
48
|
+
color: "#536471",
|
|
49
|
+
} }, { children: id }))] }))] })), text.split("\n").map(function (t, key) { return ((0, jsx_runtime_1.jsx)("p", __assign({ style: {
|
|
50
|
+
fontSize: "17px",
|
|
51
|
+
margin: "0px",
|
|
52
|
+
marginTop: "12px",
|
|
53
|
+
} }, { children: t }), key)); })] })) })));
|
|
54
|
+
};
|
|
55
|
+
exports.default = Normal;
|
|
56
|
+
//# sourceMappingURL=normal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normal.js","sourceRoot":"","sources":["../../src/style/normal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,IAAM,MAAM,GAAmB,UAAC,EAAwB;QAAtB,IAAI,UAAA,EAAE,EAAE,QAAA,EAAE,IAAI,UAAA,EAAE,IAAI,UAAA;IACpD,OAAO,CACL,yCACE,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,MAAM;YACd,UAAU,EACR,qEAAqE;SACxE,gBAED,0CACE,KAAK,EAAE;gBACL,KAAK,EAAE,OAAO;gBACd,UAAU,EAAE,OAAO;gBACnB,OAAO,EAAE,MAAM;gBACf,aAAa,EAAE,QAAQ;gBACvB,YAAY,EAAE,MAAM;gBACpB,OAAO,EAAE,MAAM;aAChB,iBAED,0CACE,KAAK,EAAE;wBACL,OAAO,EAAE,MAAM;qBAChB,iBAED,gCACE,GAAG,EAAC,MAAM,EACV,KAAK,EAAE;gCACL,KAAK,EAAE,MAAM;gCACb,MAAM,EAAE,MAAM;gCACd,YAAY,EAAE,KAAK;gCACnB,WAAW,EAAE,MAAM;6BACpB,EACD,GAAG,EAAE,IAAI,GACT,EACF,0CACE,KAAK,EAAE;gCACL,OAAO,EAAE,MAAM;gCACf,aAAa,EAAE,QAAQ;6BACxB,iBAED,uCACE,KAAK,EAAE;wCACL,QAAQ,EAAE,MAAM;wCAChB,UAAU,EAAE,MAAM;wCAClB,MAAM,EAAE,KAAK;qCACd,gBAEA,IAAI,IACH,EACJ,uCACE,KAAK,EAAE;wCACL,QAAQ,EAAE,MAAM;wCAChB,MAAM,EAAE,KAAK;wCACb,KAAK,EAAE,SAAS;qCACjB,gBAEA,EAAE,IACD,KACA,KACF,EACL,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAC,CAAC,EAAE,GAAG,IAAK,OAAA,CAChC,uCAEE,KAAK,EAAE;wBACL,QAAQ,EAAE,MAAM;wBAChB,MAAM,EAAE,KAAK;wBACb,SAAS,EAAE,MAAM;qBAClB,gBAEA,CAAC,KAPG,GAAG,CAQN,CACL,EAXiC,CAWjC,CAAC,KACE,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/utils/example.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO;;;;;CAKZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var example = {
|
|
4
|
+
name: "Twitter",
|
|
5
|
+
id: "@Twitter",
|
|
6
|
+
icon: "https://abs.twimg.com/icons/apple-touch-icon-192x192.png",
|
|
7
|
+
text: "aaaaa",
|
|
8
|
+
};
|
|
9
|
+
exports.default = example;
|
|
10
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/utils/example.ts"],"names":[],"mappings":";;AAAA,IAAM,OAAO,GAAG;IACd,IAAI,EAAE,SAAS;IACf,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,0DAA0D;IAChE,IAAI,EAAE,OAAO;CACd,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twitter-snap",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev:cli": "npx tsx src/cli.ts 1720560121485595093",
|
|
6
6
|
"dev:style": "react-scripts start",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build": "npx tsc && npx cpx2 assets/* dist/assets"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
|
-
"twitter-snap": "cli.js"
|
|
11
|
+
"twitter-snap": "src/cli.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@napi-rs/image": "^1.7.0",
|
package/src/cli.ts
CHANGED
package/output.png
DELETED
|
Binary file
|
package/public/index.html
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="ja">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
-
<title>Document</title>
|
|
9
|
-
</head>
|
|
10
|
-
|
|
11
|
-
<body style="margin: 0;">
|
|
12
|
-
<div id="root"></div>
|
|
13
|
-
</body>
|
|
14
|
-
|
|
15
|
-
</html>
|
|
File without changes
|