Skip to content

Commit c9e20f7

Browse files
committed
wip: name/title unicode
1 parent cbc207e commit c9e20f7

File tree

25 files changed

+99
-53
lines changed

25 files changed

+99
-53
lines changed

.vscode/agf-component-snippet

-18
This file was deleted.

.vscode/agf.code-snippets

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"React Component": {
3+
"prefix": "agf-component",
4+
"body": [
5+
"interface ${1:Component}Props {",
6+
"}",
7+
"",
8+
"export default function $1({}: $1Props) {",
9+
" return (",
10+
" <div>",
11+
" </div>",
12+
" )",
13+
"}"
14+
],
15+
"description": "Boilerplate for a React component",
16+
"isFileTemplate": true
17+
},
18+
"Main Header": {
19+
"prefix": "agf-header",
20+
"body": [
21+
"/* -------------------------------------------------------------------------- */",
22+
"/* $1 */",
23+
"/* -------------------------------------------------------------------------- */"
24+
],
25+
"description": "Inserts a main header comment block"
26+
},
27+
"Sub Header": {
28+
"prefix": "agf-subheader",
29+
"body": [
30+
"/* ------------------------------ $1 ------------------------------ */"
31+
],
32+
"description": "Inserts a sub header comment block"
33+
},
34+
"Line": {
35+
"prefix": "agf-line",
36+
"body": [
37+
"/* -------------------------------------------------------------------------- */"
38+
],
39+
"description": "Inserts a line comment"
40+
}
41+
}

resources/blob/cards/cyan/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"meta": {
1515
"title": "cyan",
16-
"created_at": "05/08/24",
16+
"created_at": "2024-04-27T23:00:58.966Z",
1717
"updated_at": "",
1818
"creator": {
1919
"card": "cyan",

resources/blob/cards/frieren/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"meta": {
1515
"title": "Frieren",
16-
"created_at": "05/08/24",
16+
"created_at": "2024-04-27T23:00:58.966Z",
1717
"updated_at": "",
1818
"creator": {
1919
"card": "cyan",

resources/blob/cards/kurisu/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Kurisu Makise, the Mind Behind the Science",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

resources/blob/cards/lucy/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Lucyna 'Lucy' Kushinada, Netrunner Extraordinaire",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

resources/blob/cards/mai/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Mai Sakurajima, the Enigmatic Bunny Girl",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

resources/blob/cards/miku/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Hatsune Miku, the Virtual Pop Icon",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

resources/blob/cards/rem/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"meta": {
1515
"title": "Rem: The Loyal Oni Maid",
16-
"created_at": "05/08/24",
16+
"created_at": "2024-04-27T23:00:58.966Z",
1717
"updated_at": "",
1818
"creator": {
1919
"card": "cyan",

resources/blob/cards/rias/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Rias Gremory, the Crimson-Haired Ruin Princess",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

resources/blob/cards/yuno/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Yuno Gasai, the Ultimate Yandere",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

scripts/blob/cards/cyan/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"meta": {
1515
"title": "cyan",
16-
"created_at": "05/08/24",
16+
"created_at": "2024-04-27T23:00:58.966Z",
1717
"updated_at": "",
1818
"creator": {
1919
"card": "cyan",

scripts/blob/cards/frieren/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"meta": {
1515
"title": "Frieren",
16-
"created_at": "05/08/24",
16+
"created_at": "2024-04-27T23:00:58.966Z",
1717
"updated_at": "",
1818
"creator": {
1919
"card": "cyan",

scripts/blob/cards/kurisu/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Kurisu Makise, the Mind Behind the Science",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

scripts/blob/cards/lucy/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Lucyna 'Lucy' Kushinada, Netrunner Extraordinaire",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

scripts/blob/cards/mai/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Mai Sakurajima, the Enigmatic Bunny Girl",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

scripts/blob/cards/miku/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Hatsune Miku, the Virtual Pop Icon",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

scripts/blob/cards/rem/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"meta": {
1515
"title": "Rem: The Loyal Oni Maid",
16-
"created_at": "05/08/24",
16+
"created_at": "2024-04-27T23:00:58.966Z",
1717
"updated_at": "",
1818
"creator": {
1919
"card": "cyan",

scripts/blob/cards/rias/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Rias Gremory, the Crimson-Haired Ruin Princess",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

scripts/blob/cards/yuno/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"meta": {
1818
"title": "Yuno Gasai, the Ultimate Yandere",
19-
"created_at": "4/25/24",
19+
"created_at": "2024-04-27T23:00:58.966Z",
2020
"updated_at": "",
2121
"creator": {
2222
"card": "cyan",

scripts/seed.sql

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ VALUES
55

66
INSERT INTO cards (dir_name)
77
VALUES
8-
('zephyr'),
9-
('eliza'),
10-
('astro'),
118
('mai'),
129
('lucy'),
1310
('yuno'),

src/main/lib/cards.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { config } from "@shared/config";
2-
import { CardBundleWithoutID, CardData, Result, cardSchema, cardTagsSchema } from "@shared/types";
2+
import { CardBundleWithoutID, CardData, Result, cardSchema, cardTagSchema } from "@shared/types";
33
import { deepFreeze, isValidFileName, toPathEscapedStr } from "@shared/utils";
44
import archiver from "archiver";
55
import { app, dialog } from "electron";
@@ -205,7 +205,7 @@ async function _sillyImport(filePath: string): Promise<Result<void, Error>> {
205205
if (ext !== ".json" && ext !== ".png") {
206206
return { kind: "err", error: new Error("Invalid file type for SillyTavern card. Must be .json or .png.") };
207207
}
208-
208+
// Read silly tavern data depending on if it's a .png or .json file
209209
const isPNG = ext === ".png";
210210
let data: string;
211211
if (isPNG) {
@@ -218,13 +218,15 @@ async function _sillyImport(filePath: string): Promise<Result<void, Error>> {
218218
data = await fsp.readFile(filePath, "utf8");
219219
}
220220

221+
// Parse SillyTavern card data
221222
const parseResult = sillyCardSchema.safeParse(JSON.parse(data));
222223
if (!parseResult.success) {
223224
const hrError = fromError(parseResult.error);
224225
return { kind: "err", error: new Error(`Invalid SillyTavern card: ${hrError}`) };
225226
}
226227
const sillyCard: SillyCardData = parseResult.data;
227228

229+
// Convert SillyTavern card to anime.gf format
228230
const agfCardRes = await _sillyCardToAGFCard(sillyCard);
229231
if (agfCardRes.kind === "err") {
230232
return agfCardRes;
@@ -237,6 +239,7 @@ async function _sillyImport(filePath: string): Promise<Result<void, Error>> {
237239
}
238240
const { dirName, dirPath } = cardDirRes.value;
239241

242+
// Create the anime.gf card in the cards directory
240243
try {
241244
await fsp.mkdir(dirPath);
242245
// Write .png file to avatar.png
@@ -249,7 +252,6 @@ async function _sillyImport(filePath: string): Promise<Result<void, Error>> {
249252
if (sillyCard.data.avatar && sillyCard.data.avatar === "none") {
250253
// download avatar from url
251254
const avatarPath = path.join(dirPath, "avatar.png");
252-
253255
const bufferRes = await downloadImageBuffer(sillyCard.data.avatar);
254256
if (bufferRes.kind === "err") {
255257
return bufferRes;
@@ -272,11 +274,14 @@ async function _sillyCardToAGFCard(sillyCard: SillyCardData): Promise<Result<Car
272274
const tags = sillyCard.data.tags
273275
.map((tag) => tag.toLowerCase().trim())
274276
.filter((tag) => {
275-
const res = cardTagsSchema.safeParse(tag);
277+
const res = cardTagSchema.safeParse(tag);
278+
console.log(`tag ${tag} is ${res.success ? "valid" : "invalid"}`);
276279
return res.success;
277280
})
278281
.slice(0, config.card.tagsMaxCount);
279282

283+
// Coerce name to /^[\p{L}\p{N}_ -]+$/u,
284+
280285
const agfCard: CardData = {
281286
spec: "anime.gf",
282287
spec_version: "1.0",
@@ -304,6 +309,12 @@ async function _sillyCardToAGFCard(sillyCard: SillyCardData): Promise<Result<Car
304309
}
305310
};
306311

312+
console.log(JSON.stringify(agfCard, null, 2));
313+
console.log("SillyCard", JSON.stringify(sillyCard, null, 2));
314+
console.log("cardcreator", sillyCard.data.creator);
315+
console.log("cardname", sillyCard.data.name);
316+
console.log("cardtags", tags);
317+
307318
const res = cardSchema.safeParse(agfCard);
308319
if (!res.success) {
309320
const hrError = fromError(res.error);

src/renderer/src/lib/card.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ async function importFromFileList(files: FileList): Promise<Result<void, Error>[
3535
}
3636

3737
const res = await window.api.blob.cards.import_(file.path);
38+
3839
results.push(res);
3940
}
4041

src/shared/config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const config = {
3838
descriptionMaxChars: 524288,
3939

4040
greetingMinChars: 1,
41-
greetingMaxChars: 2048,
41+
greetingMaxChars: 16384,
4242

4343
altGreetingsMinCount: 0,
4444
altGreetingsMaxCount: 64,
@@ -53,7 +53,7 @@ export const config = {
5353
taglineMaxChars: 256,
5454

5555
tagsMinCount: 0,
56-
tagsMaxCount: 16,
56+
tagsMaxCount: 32,
5757

5858
tagMinChars: 1,
5959
tagMaxChars: 32,

0 commit comments

Comments
 (0)