twitter-snap 0.0.4 → 0.0.6
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/LICENSE +23 -0
- package/README.md +20 -40
- package/dist/cli.js +43 -15
- package/dist/cli.js.map +1 -1
- package/dist/core/satori.d.ts +12 -0
- package/dist/core/satori.d.ts.map +1 -0
- package/dist/core/satori.js +3 -0
- package/dist/core/satori.js.map +1 -0
- package/dist/core/twitterSnap.d.ts +17 -14
- package/dist/core/twitterSnap.d.ts.map +1 -1
- package/dist/core/twitterSnap.js +113 -100
- package/dist/core/twitterSnap.js.map +1 -1
- package/dist/style/normal.d.ts.map +1 -1
- package/dist/style/normal.js +111 -9
- package/dist/style/normal.js.map +1 -1
- package/dist/utils/example.d.ts +1 -6
- package/dist/utils/example.d.ts.map +1 -1
- package/dist/utils/example.js +51 -6
- package/dist/utils/example.js.map +1 -1
- package/docs/img/output.png +0 -0
- package/init.ps1 +13 -11
- package/package.json +4 -4
- package/test/test.ps1 +11 -0
- package/dist/assets/LICENSE_OFL.txt +0 -92
- package/dist/assets/README +0 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 yuki
|
|
4
|
+
|
|
5
|
+
<https://yuki0311.com/>
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,46 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# twitter-snap
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create beautiful Tweet images fast.
|
|
4
|
+
Fast, good design, Browser is not a dependency.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
```shell
|
|
7
|
+
npx twitter-snap https://twitter.com/elonmusk/status/1518623997054918657
|
|
8
|
+
```
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+

|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
```shell
|
|
13
|
+
Usage: twitter-snap [options] <string>
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
Arguments:
|
|
16
|
+
string tweet url or tweet id
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Builds the app for production to the `build` folder.\
|
|
25
|
-
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
26
|
-
|
|
27
|
-
The build is minified and the filenames include the hashes.\
|
|
28
|
-
Your app is ready to be deployed!
|
|
29
|
-
|
|
30
|
-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
31
|
-
|
|
32
|
-
### `npm run eject`
|
|
33
|
-
|
|
34
|
-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
|
35
|
-
|
|
36
|
-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
37
|
-
|
|
38
|
-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
|
39
|
-
|
|
40
|
-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
|
41
|
-
|
|
42
|
-
## Learn More
|
|
43
|
-
|
|
44
|
-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
45
|
-
|
|
46
|
-
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
18
|
+
Options:
|
|
19
|
+
-V, --version output the version number
|
|
20
|
+
-o, --output <path> output file path (default: "output.png")
|
|
21
|
+
-w, --width <number> image width (default: "600")
|
|
22
|
+
-h, --height <number> image height (default: "400")
|
|
23
|
+
--font <path> font path (default: "assets/NotoSansCJK-Regular.otf")
|
|
24
|
+
--bold-font <path> bold font path (default: "assets/NotoSansCJK-Bold.otf")
|
|
25
|
+
--help display help for command
|
|
26
|
+
```
|
package/dist/cli.js
CHANGED
|
@@ -39,38 +39,66 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
var twitterSnap_1 = require("./core/twitterSnap");
|
|
41
41
|
var commander_1 = require("commander");
|
|
42
|
-
var
|
|
42
|
+
var fs_1 = require("fs");
|
|
43
|
+
var version = "0.0.6";
|
|
43
44
|
var font = "assets/NotoSansCJKjp-Regular.otf";
|
|
44
45
|
var boldFont = "assets/NotoSansCJKjp-Bold.otf";
|
|
46
|
+
var emojiFont = "assets/twemoji/{code}.svg";
|
|
45
47
|
var program = new commander_1.Command();
|
|
46
48
|
program.name("twitter-snap").version(version);
|
|
47
49
|
program
|
|
48
50
|
.argument("<string>", "tweet url or tweet id")
|
|
49
51
|
.option("-o, --output <path>", "output file path", "output.png")
|
|
50
52
|
.option("-w, --width <number>", "image width", "600")
|
|
51
|
-
.option("-h, --height <number>", "image height"
|
|
53
|
+
.option("-h, --height <number>", "image height")
|
|
54
|
+
.option("-s, --style <string>", "style", "normal")
|
|
52
55
|
.option("--font <path>", "font path", font)
|
|
53
56
|
.option("--bold-font <path>", "bold font path", boldFont)
|
|
57
|
+
.option("--emoji-font <path>", "emoji font path", emojiFont)
|
|
54
58
|
.action(function (text, _a) {
|
|
55
|
-
var output = _a.output, width = _a.width, height = _a.height, font = _a.font, boldFont = _a.boldFont;
|
|
59
|
+
var output = _a.output, width = _a.width, height = _a.height, style = _a.style, font = _a.font, boldFont = _a.boldFont;
|
|
56
60
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
-
var id, twitterSnap, writer;
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
var id, twitterSnap, _b, _c, writer;
|
|
62
|
+
var _d, _e, _f;
|
|
63
|
+
return __generator(this, function (_g) {
|
|
64
|
+
switch (_g.label) {
|
|
60
65
|
case 0:
|
|
61
66
|
id = isNaN(text) ? text.split("/").pop() : text;
|
|
62
|
-
|
|
67
|
+
_b = twitterSnap_1.TwitterSnap.bind;
|
|
68
|
+
_d = {
|
|
63
69
|
width: parseInt(width),
|
|
64
|
-
height: parseInt(height)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
height: height ? parseInt(height) : undefined
|
|
71
|
+
};
|
|
72
|
+
_e = {
|
|
73
|
+
name: "Regular"
|
|
74
|
+
};
|
|
75
|
+
return [4 /*yield*/, fs_1.promises.readFile(font)];
|
|
69
76
|
case 1:
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
_c = [
|
|
78
|
+
(_e.data = _g.sent(),
|
|
79
|
+
_e.weight = 400,
|
|
80
|
+
_e.style = "normal",
|
|
81
|
+
_e)
|
|
82
|
+
];
|
|
83
|
+
_f = {
|
|
84
|
+
name: "Bold"
|
|
85
|
+
};
|
|
86
|
+
return [4 /*yield*/, fs_1.promises.readFile(boldFont)];
|
|
72
87
|
case 2:
|
|
73
|
-
_b.
|
|
88
|
+
twitterSnap = new (_b.apply(twitterSnap_1.TwitterSnap, [void 0, (_d.font = _c.concat([
|
|
89
|
+
(_f.data = _g.sent(),
|
|
90
|
+
_f.weight = 700,
|
|
91
|
+
_f.style = "normal",
|
|
92
|
+
_f)
|
|
93
|
+
]),
|
|
94
|
+
_d.emojiFont = emojiFont,
|
|
95
|
+
_d)]))();
|
|
96
|
+
return [4 /*yield*/, twitterSnap.render({ id: id, styleName: style })];
|
|
97
|
+
case 3:
|
|
98
|
+
writer = _g.sent();
|
|
99
|
+
return [4 /*yield*/, writer.save(output)];
|
|
100
|
+
case 4:
|
|
101
|
+
_g.sent();
|
|
74
102
|
process.exit(0);
|
|
75
103
|
return [2 /*return*/];
|
|
76
104
|
}
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAAiD;AACjD,uCAAoC;AAEpC,IAAM,OAAO,GAAG,OAAO,CAAC;AACxB,IAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,IAAM,QAAQ,GAAG,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAAiD;AACjD,uCAAoC;AACpC,yBAAoC;AAEpC,IAAM,OAAO,GAAG,OAAO,CAAC;AACxB,IAAM,IAAI,GAAG,kCAAkC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AAI,GAAE,SAAuB;4BAC7B,SAAM,GAAE,GAAG;4BACX,QAAK,GAAE,QAAQ;;;;wBAGf,IAAI,EAAE,MAAM;;oBACN,qBAAM,aAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAA;;oBAZjC,WAAW,GAAG,cAAI,yBAAW,YAGjC,OAAI;6BASA,OAAI,GAAE,SAA2B;gCACjC,SAAM,GAAE,GAAG;gCACX,QAAK,GAAE,QAAQ;;0BAElB;4BACD,YAAS,GAAE,SAAS;oCACpB;oBACa,qBAAM,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,IAAA,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAA;;oBAA3D,MAAM,GAAG,SAAkD;oBACjE,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,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
type Weight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
3
|
+
type FontStyle = "normal" | "italic";
|
|
4
|
+
export interface FontOptions {
|
|
5
|
+
data: Buffer | ArrayBuffer;
|
|
6
|
+
name: string;
|
|
7
|
+
weight?: Weight;
|
|
8
|
+
style?: FontStyle;
|
|
9
|
+
lang?: string;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=satori.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satori.d.ts","sourceRoot":"","sources":["../../src/core/satori.ts"],"names":[],"mappings":";AAAA,KAAK,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAClE,KAAK,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satori.js","sourceRoot":"","sources":["../../src/core/satori.ts"],"names":[],"mappings":""}
|
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SatoriOptions } from "satori";
|
|
3
3
|
import { Transformer } from "@napi-rs/image";
|
|
4
|
+
import { FontOptions } from "./satori";
|
|
5
|
+
import { TweetApiUtilsData } from "twitter-openapi-typescript";
|
|
4
6
|
export type StyleComponent = (props: {
|
|
5
|
-
|
|
6
|
-
id: string;
|
|
7
|
-
icon: string;
|
|
8
|
-
text: string;
|
|
7
|
+
data: TweetApiUtilsData;
|
|
9
8
|
}) => React.ReactElement;
|
|
10
9
|
type TwitterSnapParams = {
|
|
11
10
|
width: number;
|
|
12
|
-
height
|
|
13
|
-
font:
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
height?: number;
|
|
12
|
+
font: FontOptions[];
|
|
13
|
+
emojiFont: string;
|
|
14
|
+
};
|
|
15
|
+
type TwitterSnapRenderParams = {
|
|
16
|
+
id: string;
|
|
17
|
+
styleName?: string;
|
|
16
18
|
};
|
|
17
19
|
export declare class TwitterSnap {
|
|
18
20
|
width: number;
|
|
19
|
-
height: number;
|
|
21
|
+
height: number | undefined;
|
|
20
22
|
option: SatoriOptions;
|
|
23
|
+
static styles: {
|
|
24
|
+
[key: string]: StyleComponent;
|
|
25
|
+
};
|
|
21
26
|
constructor(param: TwitterSnapParams);
|
|
22
|
-
render: (id:
|
|
27
|
+
render: ({ id, styleName }: TwitterSnapRenderParams) => Promise<TwitterSnapWriter>;
|
|
23
28
|
}
|
|
24
29
|
type TwitterSnapWriterParams = {
|
|
25
30
|
width: number;
|
|
26
|
-
height: number;
|
|
31
|
+
height: number | undefined;
|
|
27
32
|
svg: string;
|
|
28
33
|
};
|
|
29
34
|
export declare class TwitterSnapWriter {
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
35
|
data: string;
|
|
33
36
|
_trasformer: Transformer | undefined;
|
|
34
37
|
constructor(param: TwitterSnapWriterParams);
|
|
35
|
-
|
|
38
|
+
trasformer: () => Promise<Transformer>;
|
|
36
39
|
save: (output: string) => Promise<void>;
|
|
37
40
|
svg: (output: string) => Promise<void>;
|
|
38
41
|
raw: (output: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twitterSnap.d.ts","sourceRoot":"","sources":["../../src/core/twitterSnap.ts"],"names":[],"mappings":";AAAA,OAAe,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"twitterSnap.d.ts","sourceRoot":"","sources":["../../src/core/twitterSnap.ts"],"names":[],"mappings":";AAAA,OAAe,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAkB,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE;IACnC,IAAI,EAAE,iBAAiB,CAAC;CACzB,KAAK,KAAK,CAAC,YAAY,CAAC;AAEzB,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,WAAW,EAAE,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terSnap = void 0;
|
|
|
40
40
|
var satori_1 = require("satori");
|
|
41
41
|
var image_1 = require("@napi-rs/image");
|
|
42
42
|
var normal_1 = require("./../style/normal");
|
|
43
|
-
var
|
|
43
|
+
var fs_1 = require("fs");
|
|
44
44
|
var twitter_openapi_typescript_1 = require("twitter-openapi-typescript");
|
|
45
45
|
var TwitterSnap = /** @class */ (function () {
|
|
46
46
|
function TwitterSnap(param) {
|
|
47
47
|
var _this = this;
|
|
48
|
-
this.render = function (
|
|
49
|
-
var
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
})];
|
|
74
|
-
}
|
|
48
|
+
this.render = function (_a) {
|
|
49
|
+
var id = _a.id, styleName = _a.styleName;
|
|
50
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
51
|
+
var client, tweet, style, svg;
|
|
52
|
+
return __generator(this, function (_b) {
|
|
53
|
+
switch (_b.label) {
|
|
54
|
+
case 0: return [4 /*yield*/, new twitter_openapi_typescript_1.TwitterOpenApi().getGuestClient()];
|
|
55
|
+
case 1:
|
|
56
|
+
client = _b.sent();
|
|
57
|
+
return [4 /*yield*/, client.getDefaultApi().getTweetResultByRestId({
|
|
58
|
+
tweetId: id,
|
|
59
|
+
})];
|
|
60
|
+
case 2:
|
|
61
|
+
tweet = _b.sent();
|
|
62
|
+
style = TwitterSnap.styles[styleName || "normal"];
|
|
63
|
+
return [4 /*yield*/, (0, satori_1.default)(style({ data: tweet.data }), this.option)];
|
|
64
|
+
case 3:
|
|
65
|
+
svg = _b.sent();
|
|
66
|
+
return [2 /*return*/, new TwitterSnapWriter({
|
|
67
|
+
width: this.width,
|
|
68
|
+
height: this.height,
|
|
69
|
+
svg: svg,
|
|
70
|
+
})];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
75
73
|
});
|
|
76
|
-
}
|
|
74
|
+
};
|
|
77
75
|
this.width = param.width;
|
|
78
76
|
this.height = param.height;
|
|
79
77
|
this.option = {
|
|
80
78
|
width: this.width,
|
|
81
79
|
height: this.height,
|
|
82
|
-
fonts:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
80
|
+
fonts: param.font,
|
|
81
|
+
loadAdditionalAsset: function (code, segment) { return __awaiter(_this, void 0, void 0, function () {
|
|
82
|
+
var base64Header, unicode, res;
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
switch (_a.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
if (!(code === "emoji")) return [3 /*break*/, 2];
|
|
87
|
+
base64Header = "data:image/svg+xml;base64,";
|
|
88
|
+
unicode = Array.from(segment)
|
|
89
|
+
.map(function (c) { return c.codePointAt(0).toString(16); })
|
|
90
|
+
.join("-");
|
|
91
|
+
return [4 /*yield*/, fs_1.promises.readFile(param.emojiFont.replace("{code}", unicode))];
|
|
92
|
+
case 1:
|
|
93
|
+
res = _a.sent();
|
|
94
|
+
return [2 /*return*/, "".concat(base64Header).concat(res.toString("base64"))];
|
|
95
|
+
case 2: return [2 /*return*/, ""];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}); },
|
|
98
99
|
};
|
|
99
100
|
}
|
|
101
|
+
TwitterSnap.styles = {
|
|
102
|
+
normal: normal_1.default,
|
|
103
|
+
};
|
|
100
104
|
return TwitterSnap;
|
|
101
105
|
}());
|
|
102
106
|
exports.TwitterSnap = TwitterSnap;
|
|
103
107
|
var TwitterSnapWriter = /** @class */ (function () {
|
|
104
108
|
function TwitterSnapWriter(param) {
|
|
105
109
|
var _this = this;
|
|
110
|
+
this.trasformer = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
111
|
+
var re, _a, x, y, width, height;
|
|
112
|
+
return __generator(this, function (_b) {
|
|
113
|
+
if (!this._trasformer) {
|
|
114
|
+
this._trasformer = image_1.Transformer.fromSvg(this.data);
|
|
115
|
+
re = new RegExp(/viewBox="(\d+) (\d+) (\d+) (\d+)"/);
|
|
116
|
+
_a = this.data.match(re).slice(1).map(Number), x = _a[0], y = _a[1], width = _a[2], height = _a[3];
|
|
117
|
+
this._trasformer.crop(x, y, width, height);
|
|
118
|
+
}
|
|
119
|
+
return [2 /*return*/, this._trasformer];
|
|
120
|
+
});
|
|
121
|
+
}); };
|
|
106
122
|
this.save = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
107
123
|
var ext, exts, method;
|
|
108
124
|
return __generator(this, function (_a) {
|
|
@@ -145,7 +161,7 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
145
161
|
this.svg = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
146
162
|
return __generator(this, function (_a) {
|
|
147
163
|
switch (_a.label) {
|
|
148
|
-
case 0: return [4 /*yield*/,
|
|
164
|
+
case 0: return [4 /*yield*/, fs_1.promises.writeFile(output, this.data)];
|
|
149
165
|
case 1:
|
|
150
166
|
_a.sent();
|
|
151
167
|
return [2 /*return*/];
|
|
@@ -155,7 +171,7 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
155
171
|
this.raw = function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
156
172
|
return __generator(this, function (_a) {
|
|
157
173
|
switch (_a.label) {
|
|
158
|
-
case 0: return [4 /*yield*/,
|
|
174
|
+
case 0: return [4 /*yield*/, fs_1.promises.writeFile(output, this.data)];
|
|
159
175
|
case 1:
|
|
160
176
|
_a.sent();
|
|
161
177
|
return [2 /*return*/];
|
|
@@ -166,11 +182,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
166
182
|
var data;
|
|
167
183
|
return __generator(this, function (_a) {
|
|
168
184
|
switch (_a.label) {
|
|
169
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
170
|
-
case 1:
|
|
171
|
-
data = _a.sent();
|
|
172
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
185
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
186
|
+
case 1: return [4 /*yield*/, (_a.sent()).jpeg()];
|
|
173
187
|
case 2:
|
|
188
|
+
data = _a.sent();
|
|
189
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
190
|
+
case 3:
|
|
174
191
|
_a.sent();
|
|
175
192
|
return [2 /*return*/];
|
|
176
193
|
}
|
|
@@ -180,11 +197,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
180
197
|
var data;
|
|
181
198
|
return __generator(this, function (_a) {
|
|
182
199
|
switch (_a.label) {
|
|
183
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
184
|
-
case 1:
|
|
185
|
-
data = _a.sent();
|
|
186
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
200
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
201
|
+
case 1: return [4 /*yield*/, (_a.sent()).png()];
|
|
187
202
|
case 2:
|
|
203
|
+
data = _a.sent();
|
|
204
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
205
|
+
case 3:
|
|
188
206
|
_a.sent();
|
|
189
207
|
return [2 /*return*/];
|
|
190
208
|
}
|
|
@@ -194,11 +212,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
194
212
|
var data;
|
|
195
213
|
return __generator(this, function (_a) {
|
|
196
214
|
switch (_a.label) {
|
|
197
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
198
|
-
case 1:
|
|
199
|
-
data = _a.sent();
|
|
200
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
215
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
216
|
+
case 1: return [4 /*yield*/, (_a.sent()).bmp()];
|
|
201
217
|
case 2:
|
|
218
|
+
data = _a.sent();
|
|
219
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
220
|
+
case 3:
|
|
202
221
|
_a.sent();
|
|
203
222
|
return [2 /*return*/];
|
|
204
223
|
}
|
|
@@ -208,11 +227,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
208
227
|
var data;
|
|
209
228
|
return __generator(this, function (_a) {
|
|
210
229
|
switch (_a.label) {
|
|
211
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
212
|
-
case 1:
|
|
213
|
-
data = _a.sent();
|
|
214
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
230
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
231
|
+
case 1: return [4 /*yield*/, (_a.sent()).ico()];
|
|
215
232
|
case 2:
|
|
233
|
+
data = _a.sent();
|
|
234
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
235
|
+
case 3:
|
|
216
236
|
_a.sent();
|
|
217
237
|
return [2 /*return*/];
|
|
218
238
|
}
|
|
@@ -222,11 +242,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
222
242
|
var data;
|
|
223
243
|
return __generator(this, function (_a) {
|
|
224
244
|
switch (_a.label) {
|
|
225
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
226
|
-
case 1:
|
|
227
|
-
data = _a.sent();
|
|
228
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
245
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
246
|
+
case 1: return [4 /*yield*/, (_a.sent()).tiff()];
|
|
229
247
|
case 2:
|
|
248
|
+
data = _a.sent();
|
|
249
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
250
|
+
case 3:
|
|
230
251
|
_a.sent();
|
|
231
252
|
return [2 /*return*/];
|
|
232
253
|
}
|
|
@@ -236,11 +257,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
236
257
|
var data;
|
|
237
258
|
return __generator(this, function (_a) {
|
|
238
259
|
switch (_a.label) {
|
|
239
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
240
|
-
case 1:
|
|
241
|
-
data = _a.sent();
|
|
242
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
260
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
261
|
+
case 1: return [4 /*yield*/, (_a.sent()).webp()];
|
|
243
262
|
case 2:
|
|
263
|
+
data = _a.sent();
|
|
264
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
265
|
+
case 3:
|
|
244
266
|
_a.sent();
|
|
245
267
|
return [2 /*return*/];
|
|
246
268
|
}
|
|
@@ -250,11 +272,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
250
272
|
var data;
|
|
251
273
|
return __generator(this, function (_a) {
|
|
252
274
|
switch (_a.label) {
|
|
253
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
254
|
-
case 1:
|
|
255
|
-
data = _a.sent();
|
|
256
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
275
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
276
|
+
case 1: return [4 /*yield*/, (_a.sent()).avif()];
|
|
257
277
|
case 2:
|
|
278
|
+
data = _a.sent();
|
|
279
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
280
|
+
case 3:
|
|
258
281
|
_a.sent();
|
|
259
282
|
return [2 /*return*/];
|
|
260
283
|
}
|
|
@@ -264,11 +287,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
264
287
|
var data;
|
|
265
288
|
return __generator(this, function (_a) {
|
|
266
289
|
switch (_a.label) {
|
|
267
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
268
|
-
case 1:
|
|
269
|
-
data = _a.sent();
|
|
270
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
290
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
291
|
+
case 1: return [4 /*yield*/, (_a.sent()).pnm()];
|
|
271
292
|
case 2:
|
|
293
|
+
data = _a.sent();
|
|
294
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
295
|
+
case 3:
|
|
272
296
|
_a.sent();
|
|
273
297
|
return [2 /*return*/];
|
|
274
298
|
}
|
|
@@ -278,11 +302,12 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
278
302
|
var data;
|
|
279
303
|
return __generator(this, function (_a) {
|
|
280
304
|
switch (_a.label) {
|
|
281
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
282
|
-
case 1:
|
|
283
|
-
data = _a.sent();
|
|
284
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
305
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
306
|
+
case 1: return [4 /*yield*/, (_a.sent()).tga()];
|
|
285
307
|
case 2:
|
|
308
|
+
data = _a.sent();
|
|
309
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
310
|
+
case 3:
|
|
286
311
|
_a.sent();
|
|
287
312
|
return [2 /*return*/];
|
|
288
313
|
}
|
|
@@ -292,31 +317,19 @@ var TwitterSnapWriter = /** @class */ (function () {
|
|
|
292
317
|
var data;
|
|
293
318
|
return __generator(this, function (_a) {
|
|
294
319
|
switch (_a.label) {
|
|
295
|
-
case 0: return [4 /*yield*/, this.trasformer
|
|
296
|
-
case 1:
|
|
297
|
-
data = _a.sent();
|
|
298
|
-
return [4 /*yield*/, fs.promises.writeFile(output, data)];
|
|
320
|
+
case 0: return [4 /*yield*/, this.trasformer()];
|
|
321
|
+
case 1: return [4 /*yield*/, (_a.sent()).farbfeld()];
|
|
299
322
|
case 2:
|
|
323
|
+
data = _a.sent();
|
|
324
|
+
return [4 /*yield*/, fs_1.promises.writeFile(output, data)];
|
|
325
|
+
case 3:
|
|
300
326
|
_a.sent();
|
|
301
327
|
return [2 /*return*/];
|
|
302
328
|
}
|
|
303
329
|
});
|
|
304
330
|
}); };
|
|
305
|
-
this.width = param.width;
|
|
306
|
-
this.height = param.height;
|
|
307
331
|
this.data = param.svg;
|
|
308
332
|
}
|
|
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
333
|
return TwitterSnapWriter;
|
|
321
334
|
}());
|
|
322
335
|
exports.TwitterSnapWriter = TwitterSnapWriter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twitterSnap.js","sourceRoot":"","sources":["../../src/core/twitterSnap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA+C;AAC/C,wCAA6C;AAC7C,4CAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"twitterSnap.js","sourceRoot":"","sources":["../../src/core/twitterSnap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA+C;AAC/C,wCAA6C;AAC7C,4CAAuC;AACvC,yBAAoC;AAEpC,yEAA+E;AAiB/E;IASE,qBAAY,KAAwB;QAApC,iBAsBC;QAED,WAAM,GAAG,UAAO,EAA0C;gBAAxC,EAAE,QAAA,EAAE,SAAS,eAAA;;;;;gCACd,qBAAM,IAAI,2CAAc,EAAE,CAAC,cAAc,EAAE,EAAA;;4BAApD,MAAM,GAAG,SAA2C;4BAC5C,qBAAM,MAAM,CAAC,aAA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E,IAAI,CAAC,EAAA;;wBAAhC,SAAgC,CAAC;;;;aAClC,CAAC;QA7FA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC;IACxB,CAAC;IA6FH,wBAAC;AAAD,CAAC,AAnGD,IAmGC;AAnGY,8CAAiB"}
|
|
@@ -1 +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,
|
|
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,cA4Lb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/style/normal.js
CHANGED
|
@@ -10,19 +10,125 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
13
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
23
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
24
|
var Normal = function (_a) {
|
|
16
|
-
var
|
|
17
|
-
|
|
25
|
+
var _b, _c, _d;
|
|
26
|
+
var data = _a.data;
|
|
27
|
+
var icon = data.user.legacy.profileImageUrlHttps;
|
|
28
|
+
var name = data.user.legacy.name;
|
|
29
|
+
var id = data.user.legacy.screenName;
|
|
30
|
+
var text = data.tweet.legacy.fullText;
|
|
31
|
+
var lang = data.tweet.legacy.lang;
|
|
32
|
+
var indices = [];
|
|
33
|
+
(_b = data.tweet.legacy.entities.media) === null || _b === void 0 ? void 0 : _b.forEach(function (m) {
|
|
34
|
+
return indices.push({
|
|
35
|
+
start: m.indices[0],
|
|
36
|
+
end: m.indices[1],
|
|
37
|
+
span: false,
|
|
38
|
+
fn: function (text) { return ((0, jsx_runtime_1.jsx)("img", { alt: "img", style: {
|
|
39
|
+
width: "100%",
|
|
40
|
+
borderRadius: "10px",
|
|
41
|
+
border: "1px solid #e6e6e6",
|
|
42
|
+
}, src: m.mediaUrlHttps }, m.indices[0])); },
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
__spreadArray(__spreadArray([], ((_c = data.tweet.legacy.entities.hashtags) !== null && _c !== void 0 ? _c : []), true), ((_d = data.tweet.legacy.entities.urls) !== null && _d !== void 0 ? _d : []), true).forEach(function (m) {
|
|
46
|
+
return indices.push({
|
|
47
|
+
start: m.indices[0],
|
|
48
|
+
end: m.indices[1],
|
|
49
|
+
span: true,
|
|
50
|
+
fn: function (text) { return ((0, jsx_runtime_1.jsx)("span", __assign({ style: {
|
|
51
|
+
color: "#1d9bf0",
|
|
52
|
+
} }, { children: text }), m.indices[0])); },
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
var textSplit = Array.from(text).reduce(function (acc, cur, i) {
|
|
56
|
+
var isStart = indices.some(function (_a) {
|
|
57
|
+
var start = _a.start;
|
|
58
|
+
return start === i;
|
|
59
|
+
});
|
|
60
|
+
var isEnd = indices.some(function (_a) {
|
|
61
|
+
var end = _a.end;
|
|
62
|
+
return end === i;
|
|
63
|
+
});
|
|
64
|
+
if (isEnd || i === 0 || cur === "\n") {
|
|
65
|
+
acc.push({
|
|
66
|
+
text: "",
|
|
67
|
+
span: cur !== "\n",
|
|
68
|
+
fn: function (text) { return (0, jsx_runtime_1.jsx)("span", { children: text }, i); },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
if (isStart) {
|
|
73
|
+
indices
|
|
74
|
+
.filter(function (_a) {
|
|
75
|
+
var start = _a.start;
|
|
76
|
+
return start === i;
|
|
77
|
+
})
|
|
78
|
+
.forEach(function (indice) {
|
|
79
|
+
acc.push({
|
|
80
|
+
text: "",
|
|
81
|
+
span: indice.span,
|
|
82
|
+
fn: indice.fn,
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
var last = acc.pop();
|
|
88
|
+
last.text += cur;
|
|
89
|
+
return __spreadArray(__spreadArray([], acc, true), [last], false);
|
|
90
|
+
}, []);
|
|
91
|
+
var textFlat = textSplit.reduce(function (acc, cur, i) {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
var prev = (_b = (_a = textSplit[i - 1]) === null || _a === void 0 ? void 0 : _a.span) !== null && _b !== void 0 ? _b : false;
|
|
94
|
+
if (cur.span || i === 0) {
|
|
95
|
+
if (prev) {
|
|
96
|
+
var last = acc.pop();
|
|
97
|
+
return __spreadArray(__spreadArray([], acc, true), [__spreadArray(__spreadArray([], last, true), [cur], false)], false);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return __spreadArray(__spreadArray([], acc, true), [[cur]], false);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return __spreadArray(__spreadArray([], acc, true), [[cur]], false);
|
|
105
|
+
}
|
|
106
|
+
}, []);
|
|
107
|
+
var textElement = textFlat.map(function (t, i) {
|
|
108
|
+
var span = t[0].span;
|
|
109
|
+
if (span) {
|
|
110
|
+
return ((0, jsx_runtime_1.jsx)("p", __assign({ style: {
|
|
111
|
+
fontSize: "17px",
|
|
112
|
+
margin: "0px",
|
|
113
|
+
marginTop: "12px",
|
|
114
|
+
whiteSpace: "pre-wrap",
|
|
115
|
+
wordBreak: "break-all",
|
|
116
|
+
} }, { children: t.map(function (t) { return t.fn(t.text); }) }), i));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return t[0].fn(t[0].text);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return ((0, jsx_runtime_1.jsx)("div", __assign({ lang: lang, style: {
|
|
18
123
|
display: "flex",
|
|
19
124
|
justifyContent: "center",
|
|
20
125
|
alignItems: "center",
|
|
21
126
|
width: "100%",
|
|
22
127
|
height: "100%",
|
|
128
|
+
padding: "20px",
|
|
23
129
|
background: "linear-gradient(-45deg, #0077F2ee 0%, #1DA1F2ee 50%,#4CFFE2ee 100%)",
|
|
24
130
|
} }, { children: (0, jsx_runtime_1.jsxs)("div", __assign({ style: {
|
|
25
|
-
width: "
|
|
131
|
+
width: "100%",
|
|
26
132
|
background: "white",
|
|
27
133
|
display: "flex",
|
|
28
134
|
flexDirection: "column",
|
|
@@ -42,15 +148,11 @@ var Normal = function (_a) {
|
|
|
42
148
|
fontSize: "15px",
|
|
43
149
|
fontWeight: "bold",
|
|
44
150
|
margin: "0px",
|
|
45
|
-
} }, { children: name })), (0, jsx_runtime_1.
|
|
151
|
+
} }, { children: name })), (0, jsx_runtime_1.jsxs)("p", __assign({ style: {
|
|
46
152
|
fontSize: "15px",
|
|
47
153
|
margin: "0px",
|
|
48
154
|
color: "#536471",
|
|
49
|
-
} }, { children: id }))] }))] })),
|
|
50
|
-
fontSize: "17px",
|
|
51
|
-
margin: "0px",
|
|
52
|
-
marginTop: "12px",
|
|
53
|
-
} }, { children: t }), key)); })] })) })));
|
|
155
|
+
} }, { children: ["@", id] }))] }))] })), textElement] })) })));
|
|
54
156
|
};
|
|
55
157
|
exports.default = Normal;
|
|
56
158
|
//# sourceMappingURL=normal.js.map
|
package/dist/style/normal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normal.js","sourceRoot":"","sources":["../../src/style/normal.tsx"],"names":[],"mappings":"
|
|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A,IAAI,IACH,EACJ,wCACE,KAAK,EAAE;wCACL,QAAQ,EAAE,MAAM;wCAChB,MAAM,EAAE,KAAK;wCACb,KAAK,EAAE,SAAS;qCACjB,sBAEC,EAAE,KACF,KACA,KACF,EACL,WAAW,KACR,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
package/dist/utils/example.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/utils/example.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/utils/example.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,OAAO,uEAOZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/utils/example.js
CHANGED
|
@@ -1,10 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
}
|
|
8
37
|
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var utils_1 = require("twitter-openapi-typescript/dist/src/utils");
|
|
40
|
+
var TweetResultByRestIdResponse_1 = require("twitter-openapi-typescript-generated/dist/models/TweetResultByRestIdResponse");
|
|
41
|
+
var example = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
+
var response, value, data;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
switch (_a.label) {
|
|
45
|
+
case 0: return [4 /*yield*/, fetch("./../sample/sample1.json").then(function (res) { return res.json(); })];
|
|
46
|
+
case 1:
|
|
47
|
+
response = _a.sent();
|
|
48
|
+
value = (0, TweetResultByRestIdResponse_1.TweetResultByRestIdResponseFromJSONTyped)(response, true);
|
|
49
|
+
data = (0, utils_1.buildTweetApiUtils)({ result: value.data.tweetResult });
|
|
50
|
+
return [2 /*return*/, data];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}); };
|
|
9
54
|
exports.default = example;
|
|
10
55
|
//# sourceMappingURL=example.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/utils/example.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/utils/example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAA+E;AAE/E,4HAAwI;AAExI,IAAM,OAAO,GAAG;;;;oBACgC,qBAAM,KAAK,CACvD,0BAA0B,CAC3B,CAAC,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,EAAA;;gBAFrB,QAAQ,GAAgC,SAEnB;gBACrB,KAAK,GAAG,IAAA,sEAAwC,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;gBACjE,IAAI,GAAG,IAAA,0BAAkB,EAAC,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;gBACpE,sBAAO,IAAK,EAAC;;;KACd,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
Binary file
|
package/init.ps1
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
aria2c -x4 https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKjp-hinted.zip
|
|
2
|
-
Expand-Archive NotoSansCJKjp-hinted.zip -DestinationPath ./
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
rm
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
rm
|
|
2
|
+
Expand-Archive NotoSansCJKjp-hinted.zip -DestinationPath ./tmp
|
|
3
|
+
mv tmp/NotoSansCJKjp-Bold.otf assets/NotoSansCJKjp-Bold.otf
|
|
4
|
+
mv tmp/NotoSansCJKjp-Regular.otf assets/NotoSansCJKjp-Regular.otf
|
|
5
|
+
rm tmp -r -fo
|
|
6
|
+
rm NotoSansCJKjp-hinted.zip -fo
|
|
7
|
+
|
|
8
|
+
aria2c -x4 https://github.com/twitter/twemoji/archive/refs/tags/v14.0.2.zip
|
|
9
|
+
Expand-Archive twemoji-14.0.2.zip -DestinationPath ./tmp
|
|
10
|
+
mv tmp/twemoji-14.0.2/assets/svg assets/twemoji
|
|
11
|
+
|
|
12
|
+
rm tmp -r -fo
|
|
13
|
+
rm twemoji-14.0.2.zip -fo
|
|
14
|
+
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twitter-snap",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"dev:cli": "npx tsx src/cli.ts
|
|
5
|
+
"dev:cli": "npx tsx src/cli.ts 1518623997054918657",
|
|
6
6
|
"dev:style": "react-scripts start",
|
|
7
|
-
"start": "node dist/cli.js
|
|
7
|
+
"start": "node dist/cli.js 1518623997054918657",
|
|
8
8
|
"build": "npx tsc && npx cpx2 assets/* dist/assets"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
|
-
"twitter-snap": "dist/
|
|
11
|
+
"twitter-snap": "dist/cli.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@napi-rs/image": "^1.7.0",
|
package/test/test.ps1
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
npx tsx src/cli.ts 1518623997054918657 -o test/temp/1518623997054918657.png # Text Tweet
|
|
2
|
+
npx tsx src/cli.ts 1593459801966538755 -o test/temp/1593459801966538755.png # Image
|
|
3
|
+
npx tsx src/cli.ts 1585341984679469056 -o test/temp/1585341984679469056.png # Video
|
|
4
|
+
npx tsx src/cli.ts 1720221949861765601 -o test/temp/1720221949861765601.png # quote Tweet
|
|
5
|
+
npx tsx src/cli.ts 1715932921851437311 -o test/temp/1715932921851437311.png # more than 4 images
|
|
6
|
+
npx tsx src/cli.ts 1718528553162342651 -o test/temp/1718528553162342651.png # thread
|
|
7
|
+
|
|
8
|
+
npx tsx src/cli.ts 1720758714788196849 -o test/temp/1720758714788196849.png # CJK 直
|
|
9
|
+
npx tsx src/cli.ts 1518623997054918657 -o test/temp/1518623997054918657.png # Surrogate Pair and Hashtag
|
|
10
|
+
npx tsx src/cli.ts 1720656134426726473 -o test/temp/1720656134426726473.png # Chinese
|
|
11
|
+
npx tsx src/cli.ts 1720655984522412366 -o test/temp/1720655984522412366.png # Korean
|
|
@@ -1,92 +0,0 @@
|
|
|
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.
|
package/dist/assets/README
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
This package is part of the noto project. Visit
|
|
2
|
-
google.com/get/noto for more information.
|
|
3
|
-
|
|
4
|
-
Built on 2017-10-24 from the following noto repository:
|
|
5
|
-
-----
|
|
6
|
-
Repo: noto-cjk
|
|
7
|
-
Tag: v2017-06-01-serif-cjk-1-1
|
|
8
|
-
Date: 2017-09-20 09:49:40 GMT
|
|
9
|
-
Commit: 32a5844539f2e348ed36b44e990f9b06d7fb89fe
|
|
10
|
-
|
|
11
|
-
Update serif CJK to 1.1.
|