@notatki/core 0.0.4 → 0.0.5
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/export/anki.d.ts +4 -4
- package/dist/export/anki.d.ts.map +1 -1
- package/dist/export/anki.js +2 -4
- package/dist/export/anki.js.map +1 -1
- package/dist/export/csv.d.ts +4 -4
- package/dist/export/csv.d.ts.map +1 -1
- package/dist/export/csv.js +21 -11
- package/dist/export/csv.js.map +1 -1
- package/dist/export/json.d.ts +4 -4
- package/dist/export/json.d.ts.map +1 -1
- package/dist/export/json.js +2 -4
- package/dist/export/json.js.map +1 -1
- package/package.json +4 -4
package/dist/export/anki.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NoteList } from "../note.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function exportAnki(col: NoteList): Promise<Buffer>;
|
|
3
|
+
export declare namespace exportAnki {
|
|
4
|
+
var ext: string;
|
|
5
|
+
}
|
|
6
6
|
//# sourceMappingURL=anki.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anki.d.ts","sourceRoot":"","sources":["../../src/export/anki.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,
|
|
1
|
+
{"version":3,"file":"anki.d.ts","sourceRoot":"","sources":["../../src/export/anki.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAsB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/D;yBAFqB,UAAU"}
|
package/dist/export/anki.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export async function exportAnki(col
|
|
2
|
-
if (signal.aborted) {
|
|
3
|
-
throw new Error("Aborted");
|
|
4
|
-
}
|
|
1
|
+
export async function exportAnki(col) {
|
|
5
2
|
return Buffer.of();
|
|
6
3
|
}
|
|
4
|
+
exportAnki.ext = "apkg";
|
|
7
5
|
//# sourceMappingURL=anki.js.map
|
package/dist/export/anki.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anki.js","sourceRoot":"","sources":["../../src/export/anki.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"anki.js","sourceRoot":"","sources":["../../src/export/anki.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAa;IAC5C,OAAO,MAAM,CAAC,EAAE,EAAE,CAAC;AACrB,CAAC;AAED,UAAU,CAAC,GAAG,GAAG,MAAM,CAAC","sourcesContent":["import type { NoteList } from \"../note.js\";\n\nexport async function exportAnki(col: NoteList): Promise<Buffer> {\n return Buffer.of();\n}\n\nexportAnki.ext = \"apkg\";\n"]}
|
package/dist/export/csv.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type NoteList } from "../note.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function exportCsv(col: NoteList): Promise<string>;
|
|
3
|
+
export declare namespace exportCsv {
|
|
4
|
+
var ext: string;
|
|
5
|
+
}
|
|
6
6
|
//# sourceMappingURL=csv.d.ts.map
|
package/dist/export/csv.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../src/export/csv.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,
|
|
1
|
+
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../src/export/csv.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAsB,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B9D;yBA1BqB,SAAS"}
|
package/dist/export/csv.js
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import { formatField } from "@notatki/format";
|
|
2
2
|
import {} from "../note.js";
|
|
3
|
-
export async function exportCsv(col
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export async function exportCsv(col) {
|
|
4
|
+
let width = 0;
|
|
5
|
+
for (const note of col) {
|
|
6
|
+
width = Math.max(width, note.type.fields.length);
|
|
6
7
|
}
|
|
7
8
|
const lines = [];
|
|
8
|
-
lines.push(
|
|
9
|
-
lines.push(
|
|
10
|
-
lines.push(
|
|
11
|
-
lines.push(
|
|
12
|
-
lines.push(
|
|
13
|
-
lines.push(
|
|
9
|
+
lines.push("#separator:semicolon");
|
|
10
|
+
lines.push("#html:true");
|
|
11
|
+
lines.push("#guid column:1");
|
|
12
|
+
lines.push("#notetype column:2");
|
|
13
|
+
lines.push("#deck column:3");
|
|
14
|
+
lines.push("#tags column:4");
|
|
14
15
|
for (const note of col) {
|
|
15
|
-
const fields =
|
|
16
|
-
|
|
16
|
+
const fields = new Array(width + 4).fill("");
|
|
17
|
+
let index = 0;
|
|
18
|
+
fields[index++] = note.id;
|
|
19
|
+
fields[index++] = note.type.name;
|
|
20
|
+
fields[index++] = note.deck;
|
|
21
|
+
fields[index++] = note.tags;
|
|
22
|
+
for (const field of note) {
|
|
23
|
+
fields[index++] = formatField(field.value);
|
|
24
|
+
}
|
|
25
|
+
lines.push(fields.map(escape).join(";"));
|
|
17
26
|
}
|
|
18
27
|
lines.push("");
|
|
19
28
|
return lines.join("\n");
|
|
20
29
|
}
|
|
30
|
+
exportCsv.ext = "txt";
|
|
21
31
|
function escape(value) {
|
|
22
32
|
if (value == null) {
|
|
23
33
|
return "";
|
package/dist/export/csv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../../src/export/csv.ts"],"names":[],"mappings":"A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IAAI,CAAC;QAC5B,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QAC5B,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,CAAC,GAAG,GAAG,KAAK,CAAC;AAEtB,SAAS,MAAM,CAAC,KAAoB;IAClC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACvE,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { formatField } from \"@notatki/format\";\nimport { type NoteList } from \"../note.js\";\n\nexport async function exportCsv(col: NoteList): Promise<string> {\n let width = 0;\n for (const note of col) {\n width = Math.max(width, note.type.fields.length);\n }\n const lines = [];\n lines.push(\"#separator:semicolon\");\n lines.push(\"#html:true\");\n lines.push(\"#guid column:1\");\n lines.push(\"#notetype column:2\");\n lines.push(\"#deck column:3\");\n lines.push(\"#tags column:4\");\n for (const note of col) {\n const fields = new Array(width + 4).fill(\"\");\n let index = 0;\n fields[index++] = note.id;\n fields[index++] = note.type.name;\n fields[index++] = note.deck;\n fields[index++] = note.tags;\n for (const field of note) {\n fields[index++] = formatField(field.value);\n }\n lines.push(fields.map(escape).join(\";\"));\n }\n lines.push(\"\");\n return lines.join(\"\\n\");\n}\n\nexportCsv.ext = \"txt\";\n\nfunction escape(value: string | null): string {\n if (value == null) {\n return \"\";\n }\n if (value.includes(\";\") || value.includes(\"\\n\") || value.includes('\"')) {\n return `\"${value.replaceAll('\"', '\"\"')}\"`;\n }\n return value;\n}\n"]}
|
package/dist/export/json.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export type JNote = {
|
|
|
24
24
|
tags: string[];
|
|
25
25
|
fields: Record<string, string>;
|
|
26
26
|
};
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export declare function exportJson(col: NoteList): Promise<string>;
|
|
28
|
+
export declare namespace exportJson {
|
|
29
|
+
var ext: string;
|
|
30
|
+
}
|
|
31
31
|
//# sourceMappingURL=json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/export/json.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IACJ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/export/json.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IACJ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF,wBAAsB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA2C/D;yBA3CqB,UAAU"}
|
package/dist/export/json.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { formatField } from "@notatki/format";
|
|
2
|
-
export async function exportJson(col
|
|
3
|
-
if (signal.aborted) {
|
|
4
|
-
throw new Error("Aborted");
|
|
5
|
-
}
|
|
2
|
+
export async function exportJson(col) {
|
|
6
3
|
const models = [];
|
|
7
4
|
const notes = [];
|
|
8
5
|
for (const model of col.types) {
|
|
@@ -38,4 +35,5 @@ export async function exportJson(col, { signal = new AbortController().signal }
|
|
|
38
35
|
}
|
|
39
36
|
return JSON.stringify({ models, notes }, null, 2);
|
|
40
37
|
}
|
|
38
|
+
exportJson.ext = "notatki.json";
|
|
41
39
|
//# sourceMappingURL=json.js.map
|
package/dist/export/json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/export/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/export/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA+B9C,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAa;IAC5C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAY,EAAE,CAAC;IAC1B,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAC3B,CAAC,EACC,IAAI,EAAE,EAAE;cACT,EAAE,EAAE,CAAC,CAAC;gBACL,IAAI;aACL,CAAC,CACH;YACD,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CACzB,CAAC,EACC,IAAI,EAAE,EAAE;YACR,KAAK,EACL,IAAI,GACL,EAAE,EAAE,CAAC,CAAC;gBACL,IAAI;gBACJ,KAAK;gBACL,IAAI;aACL,CAAC,CACH;YACD,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACvB,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;QACD,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,IAAI,CAAC,EAAE;YACb,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;YACpB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;YAC5B,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAwB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,UAAU,CAAC,GAAG,GAAG,cAAc,CAAC","sourcesContent":["import { formatField } from \"@notatki/format\";\nimport type { NoteList } from \"../note.js\";\n\nexport type JCollection = {\n models: JModel[];\n notes: JNote[];\n};\n\nexport type JModel = {\n id: number;\n name: string;\n cloze: boolean;\n fields: {\n name: string;\n }[];\n cards: {\n name: string;\n front: string;\n back: string;\n }[];\n styles: string;\n};\n\nexport type JNote = {\n guid: string;\n type: string;\n deck: string;\n tags: string[];\n fields: Record<string, string>;\n};\n\nexport async function exportJson(col: NoteList): Promise<string> {\n const models: JModel[] = [];\n const notes: JNote[] = [];\n for (const model of col.types) {\n models.push({\n id: model.id,\n name: model.name,\n cloze: model.cloze,\n fields: [...model.fields].map(\n ({\n name, //\n }) => ({\n name,\n }),\n ),\n cards: [...model.cards].map(\n ({\n name, //\n front,\n back,\n }) => ({\n name,\n front,\n back,\n }),\n ),\n styles: model.styles,\n });\n }\n for (const note of col) {\n const fields: Record<string, string> = {};\n for (const field of note) {\n fields[field.name] = formatField(field.value);\n }\n notes.push({\n guid: note.id,\n type: note.type.name,\n deck: note.deck,\n tags: note.tags.split(/\\s+/),\n fields,\n });\n }\n return JSON.stringify({ models, notes } satisfies JCollection, null, 2);\n}\n\nexportJson.ext = \"notatki.json\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notatki/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A collection of tools for creating and syncing Anki notes from simple text files.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anki",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@notatki/format": "^0.0.
|
|
23
|
-
"@notatki/parser": "^0.0.
|
|
22
|
+
"@notatki/format": "^0.0.5",
|
|
23
|
+
"@notatki/parser": "^0.0.5"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"compile": "rm -fr dist && tsc",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "24692ee3b3d3c149c4956a88825d095853038f6b"
|
|
34
34
|
}
|