@polyglot-bundles/content-shared 0.1.1 → 0.1.4
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/content-types.d.ts +47 -0
- package/dist/content-types.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +42 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +25 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base types for polyglot-bundles content packages.
|
|
3
|
+
*
|
|
4
|
+
* These types are extended by language-specific content packages.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Content type for MDX-based lessons
|
|
8
|
+
*/
|
|
9
|
+
export type LessonContent = {
|
|
10
|
+
id: string;
|
|
11
|
+
title: string;
|
|
12
|
+
content: string;
|
|
13
|
+
metadata?: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Audio content reference
|
|
17
|
+
*/
|
|
18
|
+
export type AudioContent = {
|
|
19
|
+
id: string;
|
|
20
|
+
url: string;
|
|
21
|
+
type: "pronunciation" | "sentence" | "dialogue" | "instruction";
|
|
22
|
+
language: string;
|
|
23
|
+
duration?: number;
|
|
24
|
+
speaker?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Phrase with multiple language representations
|
|
28
|
+
*/
|
|
29
|
+
export type BilingualPhrase = {
|
|
30
|
+
id: string;
|
|
31
|
+
source: string;
|
|
32
|
+
target: string;
|
|
33
|
+
sourceLanguage: string;
|
|
34
|
+
targetLanguage: string;
|
|
35
|
+
notes?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Flashcard for practice activities
|
|
39
|
+
*/
|
|
40
|
+
export type Flashcard = {
|
|
41
|
+
id: string;
|
|
42
|
+
front: string;
|
|
43
|
+
back: string;
|
|
44
|
+
example?: string;
|
|
45
|
+
category?: string;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=content-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../src/content-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,eAAe,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Shared types and utilities for polyglot-bundles content packages.
|
|
5
5
|
*/
|
|
6
|
-
export type { PuzzleItem, PuzzleCategory, LevelInfo } from './types';
|
|
6
|
+
export type { LocalizedString, PuzzleItem, PuzzleCategory, LevelInfo, PuzzleLanguageMeta, Character, CharacterVariant, AudioContent, } from './types';
|
|
7
|
+
export { getLocalized, getDefaultLanguage, localized, validateLocalizedString, validatePuzzleItem, } from './utils';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
function u(e, t) {
|
|
2
|
+
return typeof e == "string" ? e : e[t] || Object.values(e)[0] || "";
|
|
3
|
+
}
|
|
4
|
+
function g(e) {
|
|
5
|
+
if (typeof e == "string")
|
|
6
|
+
return "en";
|
|
7
|
+
const t = Object.keys(e);
|
|
8
|
+
return t.length > 0 ? t[0] : "en";
|
|
9
|
+
}
|
|
10
|
+
function s(e, t) {
|
|
11
|
+
return { [e]: t };
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
return typeof e == "string" ? e.length > 0 : Object.values(e).some(
|
|
15
|
+
(t) => typeof t == "string" && t.length > 0
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function i(e) {
|
|
19
|
+
const t = [];
|
|
20
|
+
if (typeof e != "object" || e === null)
|
|
21
|
+
return t.push({ field: "root", message: "Must be an object" }), t;
|
|
22
|
+
const n = e;
|
|
23
|
+
return r(n.targetWord) || t.push({ field: "targetWord", message: "Must be a non-empty string" }), r(n.targetLanguageClue) || t.push({
|
|
24
|
+
field: "targetLanguageClue",
|
|
25
|
+
message: "Must be a non-empty string"
|
|
26
|
+
}), r(n.uiLanguageClue) || t.push({
|
|
27
|
+
field: "uiLanguageClue",
|
|
28
|
+
message: "Must be a non-empty string"
|
|
29
|
+
}), t;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
g as getDefaultLanguage,
|
|
33
|
+
u as getLocalized,
|
|
34
|
+
s as localized,
|
|
35
|
+
r as validateLocalizedString,
|
|
36
|
+
i as validatePuzzleItem
|
|
37
|
+
};
|
|
2
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils.ts"],"sourcesContent":["/**\r\n * Utilities for polyglot-bundles content packages.\r\n *\r\n * Provides minimal, reusable helpers for content packages.\r\n */\r\n\r\nimport type { LocalizedString, PuzzleItem } from \"./types\";\r\n\r\n// ============================================================================\r\n// Localization Utilities\r\n// ============================================================================\r\n\r\n/**\r\n * Get a localized string value\r\n */\r\nexport function getLocalized(\r\n value: LocalizedString,\r\n lang: string\r\n): string {\r\n if (typeof value === \"string\") {\r\n return value;\r\n }\r\n return value[lang] || Object.values(value)[0] || \"\";\r\n}\r\n\r\n/**\r\n * Get the default language from a LocalizedString\r\n */\r\nexport function getDefaultLanguage(value: LocalizedString): string {\r\n if (typeof value === \"string\") {\r\n return \"en\";\r\n }\r\n const langs = Object.keys(value);\r\n return langs.length > 0 ? langs[0] : \"en\";\r\n}\r\n\r\n/**\r\n * Create a LocalizedString for a single language\r\n */\r\nexport function localized(lang: string, text: string): LocalizedString {\r\n return { [lang]: text };\r\n}\r\n\r\n// ============================================================================\r\n// Validation Utilities\r\n// ============================================================================\r\n\r\n/**\r\n * Validate a LocalizedString has at least one language\r\n */\r\nexport function validateLocalizedString(\r\n value: LocalizedString\r\n): boolean {\r\n if (typeof value === \"string\") {\r\n return value.length > 0;\r\n }\r\n return Object.values(value).some(\r\n (v) => typeof v === \"string\" && v.length > 0\r\n );\r\n}\r\n\r\n/**\r\n * Validate PuzzleItem\r\n */\r\nexport function validatePuzzleItem(\r\n item: unknown\r\n): { field: string; message: string }[] {\r\n const errors: { field: string; message: string }[] = [];\r\n\r\n if (typeof item !== \"object\" || item === null) {\r\n errors.push({ field: \"root\", message: \"Must be an object\" });\r\n return errors;\r\n }\r\n\r\n const puzzleItem = item as PuzzleItem;\r\n\r\n if (!validateLocalizedString(puzzleItem.targetWord)) {\r\n errors.push({ field: \"targetWord\", message: \"Must be a non-empty string\" });\r\n }\r\n\r\n if (!validateLocalizedString(puzzleItem.targetLanguageClue)) {\r\n errors.push({\r\n field: \"targetLanguageClue\",\r\n message: \"Must be a non-empty string\",\r\n });\r\n }\r\n\r\n if (!validateLocalizedString(puzzleItem.uiLanguageClue)) {\r\n errors.push({\r\n field: \"uiLanguageClue\",\r\n message: \"Must be a non-empty string\",\r\n });\r\n }\r\n\r\n return errors;\r\n}\r\n\r\n"],"names":["getLocalized","value","lang","getDefaultLanguage","langs","localized","text","validateLocalizedString","v","validatePuzzleItem","item","errors","puzzleItem"],"mappings":"AAeO,SAASA,EACdC,GACAC,GACQ;AACR,SAAI,OAAOD,KAAU,WACZA,IAEFA,EAAMC,CAAI,KAAK,OAAO,OAAOD,CAAK,EAAE,CAAC,KAAK;AACnD;AAKO,SAASE,EAAmBF,GAAgC;AACjE,MAAI,OAAOA,KAAU;AACnB,WAAO;AAET,QAAMG,IAAQ,OAAO,KAAKH,CAAK;AAC/B,SAAOG,EAAM,SAAS,IAAIA,EAAM,CAAC,IAAI;AACvC;AAKO,SAASC,EAAUH,GAAcI,GAA+B;AACrE,SAAO,EAAE,CAACJ,CAAI,GAAGI,EAAA;AACnB;AASO,SAASC,EACdN,GACS;AACT,SAAI,OAAOA,KAAU,WACZA,EAAM,SAAS,IAEjB,OAAO,OAAOA,CAAK,EAAE;AAAA,IAC1B,CAACO,MAAM,OAAOA,KAAM,YAAYA,EAAE,SAAS;AAAA,EAAA;AAE/C;AAKO,SAASC,EACdC,GACsC;AACtC,QAAMC,IAA+C,CAAA;AAErD,MAAI,OAAOD,KAAS,YAAYA,MAAS;AACvC,WAAAC,EAAO,KAAK,EAAE,OAAO,QAAQ,SAAS,qBAAqB,GACpDA;AAGT,QAAMC,IAAaF;AAEnB,SAAKH,EAAwBK,EAAW,UAAU,KAChDD,EAAO,KAAK,EAAE,OAAO,cAAc,SAAS,8BAA8B,GAGvEJ,EAAwBK,EAAW,kBAAkB,KACxDD,EAAO,KAAK;AAAA,IACV,OAAO;AAAA,IACP,SAAS;AAAA,EAAA,CACV,GAGEJ,EAAwBK,EAAW,cAAc,KACpDD,EAAO,KAAK;AAAA,IACV,OAAO;AAAA,IACP,SAAS;AAAA,EAAA,CACV,GAGIA;AACT;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared types for polyglot-bundles content packages.
|
|
3
|
+
*
|
|
4
|
+
* This package provides minimal, truly reusable types across all content packages.
|
|
5
|
+
* Types specific to lalia-prism (KubitId, Lesson, Syllabus, etc.) should stay there.
|
|
3
6
|
*/
|
|
4
7
|
export type LocalizedString = string | Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* PuzzleItem for puzzle content (crosswords, word search, etc.)
|
|
10
|
+
*/
|
|
5
11
|
export type PuzzleItem = {
|
|
6
12
|
targetWord: string;
|
|
7
13
|
targetLanguageClue: string;
|
|
8
14
|
uiLanguageClue: LocalizedString;
|
|
9
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* PuzzleCategory for organizing puzzles by level/theme
|
|
18
|
+
*/
|
|
10
19
|
export type PuzzleCategory = {
|
|
11
20
|
level: number;
|
|
12
21
|
category: string;
|
|
@@ -17,14 +26,47 @@ export type PuzzleCategory = {
|
|
|
17
26
|
src?: string;
|
|
18
27
|
disabled?: boolean;
|
|
19
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* LevelInfo for hierarchical puzzle content
|
|
31
|
+
*/
|
|
20
32
|
export type LevelInfo = {
|
|
21
33
|
level: number;
|
|
22
34
|
title: LocalizedString;
|
|
23
35
|
description: LocalizedString;
|
|
24
36
|
disabled?: boolean;
|
|
25
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* PuzzleLanguageMeta for language-level puzzle configuration
|
|
40
|
+
*/
|
|
26
41
|
export type PuzzleLanguageMeta = {
|
|
27
42
|
levels: LevelInfo[];
|
|
28
43
|
categories: PuzzleCategory[];
|
|
29
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Character with its variants and metadata
|
|
47
|
+
*/
|
|
48
|
+
export type Character = {
|
|
49
|
+
id: string;
|
|
50
|
+
character: string;
|
|
51
|
+
name: string;
|
|
52
|
+
transcription?: string;
|
|
53
|
+
frequency?: number;
|
|
54
|
+
variants?: CharacterVariant[];
|
|
55
|
+
};
|
|
56
|
+
export type CharacterVariant = {
|
|
57
|
+
type: "uppercase" | "lowercase" | "final" | "initial" | "medial";
|
|
58
|
+
value: string;
|
|
59
|
+
context?: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Audio content reference
|
|
63
|
+
*/
|
|
64
|
+
export type AudioContent = {
|
|
65
|
+
id: string;
|
|
66
|
+
url: string;
|
|
67
|
+
type: "pronunciation" | "sentence" | "dialogue" | "instruction";
|
|
68
|
+
language: string;
|
|
69
|
+
duration?: number;
|
|
70
|
+
speaker?: string;
|
|
71
|
+
};
|
|
30
72
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAM9D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,eAAe,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,WAAW,EAAE,eAAe,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,eAAe,CAAC;IACvB,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B,CAAC;AAMF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAMF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,eAAe,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LocalizedString } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Get a localized string value
|
|
4
|
+
*/
|
|
5
|
+
export declare function getLocalized(value: LocalizedString, lang: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Get the default language from a LocalizedString
|
|
8
|
+
*/
|
|
9
|
+
export declare function getDefaultLanguage(value: LocalizedString): string;
|
|
10
|
+
/**
|
|
11
|
+
* Create a LocalizedString for a single language
|
|
12
|
+
*/
|
|
13
|
+
export declare function localized(lang: string, text: string): LocalizedString;
|
|
14
|
+
/**
|
|
15
|
+
* Validate a LocalizedString has at least one language
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateLocalizedString(value: LocalizedString): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Validate PuzzleItem
|
|
20
|
+
*/
|
|
21
|
+
export declare function validatePuzzleItem(item: unknown): {
|
|
22
|
+
field: string;
|
|
23
|
+
message: string;
|
|
24
|
+
}[];
|
|
25
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,SAAS,CAAC;AAM3D;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,MAAM,GACX,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAMjE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAErE;AAMD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,eAAe,GACrB,OAAO,CAOT;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,GACZ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CA6BtC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polyglot-bundles/content-shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Shared types and utilities for polyglot-bundles content packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
8
14
|
"files": [
|
|
9
15
|
"dist"
|
|
10
16
|
],
|