glost 0.2.0 → 0.4.0
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/CHANGELOG.md +156 -0
- package/README.md +4 -4
- package/dist/cli/migrate.d.ts +8 -0
- package/dist/cli/migrate.d.ts.map +1 -0
- package/dist/cli/migrate.js +229 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/errors.d.ts +168 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +300 -0
- package/dist/errors.js.map +1 -0
- package/dist/guards.d.ts +1 -1
- package/dist/guards.d.ts.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/nodes.d.ts +1 -1
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -1
- package/dist/nodes.js.map +1 -1
- package/dist/types.d.ts +25 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/package.json +12 -2
- package/src/cli/migrate.ts +294 -0
- package/src/errors.ts +394 -0
- package/src/guards.ts +1 -1
- package/src/index.ts +9 -8
- package/src/nodes.ts +1 -2
- package/src/types.ts +25 -9
- package/src/utils.ts +2 -2
package/src/index.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// GLOST - Glossed Syntax Tree
|
|
2
2
|
// Extends nlcst for language learning with annotations
|
|
3
3
|
|
|
4
|
-
export * from "./types";
|
|
5
|
-
export * from "./nodes";
|
|
6
|
-
export * from "./utils";
|
|
7
|
-
export * from "./validators";
|
|
8
|
-
export * from "./guards";
|
|
9
|
-
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./nodes.js";
|
|
6
|
+
export * from "./utils.js";
|
|
7
|
+
export * from "./validators.js";
|
|
8
|
+
export * from "./guards.js";
|
|
9
|
+
export * from "./errors.js";
|
|
10
|
+
// export * from './example.js';
|
|
10
11
|
|
|
11
12
|
// Re-export utility types
|
|
12
|
-
export type { ParagraphLike } from "./utils";
|
|
13
|
+
export type { ParagraphLike } from "./utils.js";
|
|
13
14
|
|
|
14
15
|
// Re-export key utilities for transcription components
|
|
15
16
|
export {
|
|
@@ -65,4 +66,4 @@ export {
|
|
|
65
66
|
getLanguageFallback,
|
|
66
67
|
normalizeLanguageTag,
|
|
67
68
|
isValidLanguageTag,
|
|
68
|
-
} from "./utils";
|
|
69
|
+
} from "./utils.js";
|
package/src/nodes.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
GLOSTWord,
|
|
13
13
|
ScriptSystem,
|
|
14
14
|
TransliterationData,
|
|
15
|
-
} from "./types";
|
|
15
|
+
} from "./types.js";
|
|
16
16
|
|
|
17
17
|
// ============================================================================
|
|
18
18
|
// Options Interfaces
|
|
@@ -220,7 +220,6 @@ export function createSimpleWord(options: CreateSimpleWordOptions): GLOSTWord {
|
|
|
220
220
|
const transcription: TransliterationData = {
|
|
221
221
|
[system]: {
|
|
222
222
|
text: transliteration,
|
|
223
|
-
system: system as any,
|
|
224
223
|
syllables: [text],
|
|
225
224
|
},
|
|
226
225
|
};
|
package/src/types.ts
CHANGED
|
@@ -188,7 +188,7 @@ export type ExtendedMetadata = {
|
|
|
188
188
|
/** Quick translations in multiple languages */
|
|
189
189
|
translations?: QuickTranslations;
|
|
190
190
|
/** Difficulty level for learners */
|
|
191
|
-
difficulty?: "beginner" | "intermediate" | "advanced";
|
|
191
|
+
difficulty?: "beginner" | "intermediate" | "advanced" | 1 | 2 | 3 | 4 | 5 | string;
|
|
192
192
|
/** Frequency in common usage */
|
|
193
193
|
frequency?: "rare" | "uncommon" | "common" | "very-common";
|
|
194
194
|
/** Cultural notes */
|
|
@@ -203,15 +203,30 @@ export type ExtendedMetadata = {
|
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* Extras field for extending GLOST nodes
|
|
206
|
+
*
|
|
207
|
+
* This interface can be augmented by extension packages via declaration merging.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* // In an extension package
|
|
212
|
+
* declare module "glost" {
|
|
213
|
+
* interface GLOSTExtras {
|
|
214
|
+
* frequency?: {
|
|
215
|
+
* rank: number;
|
|
216
|
+
* category: "very-common" | "common" | "uncommon" | "rare";
|
|
217
|
+
* };
|
|
218
|
+
* }
|
|
219
|
+
* }
|
|
220
|
+
* ```
|
|
206
221
|
*/
|
|
207
|
-
export
|
|
222
|
+
export interface GLOSTExtras {
|
|
208
223
|
/** Quick translations */
|
|
209
224
|
translations?: QuickTranslations;
|
|
210
225
|
/** Extended metadata */
|
|
211
226
|
metadata?: ExtendedMetadata;
|
|
212
|
-
/** Custom extensions */
|
|
213
|
-
[key: string]:
|
|
214
|
-
}
|
|
227
|
+
/** Custom extensions - allows any string key with unknown value */
|
|
228
|
+
[key: string]: unknown;
|
|
229
|
+
}
|
|
215
230
|
|
|
216
231
|
// ============================================================================
|
|
217
232
|
// Transcription and Pronunciation Types
|
|
@@ -231,12 +246,13 @@ export type PronunciationVariant = {
|
|
|
231
246
|
|
|
232
247
|
/**
|
|
233
248
|
* Transcription information for a text segment
|
|
249
|
+
*
|
|
250
|
+
* Note: The transcription system is not stored in this object.
|
|
251
|
+
* It is the key in the TransliterationData record.
|
|
234
252
|
*/
|
|
235
253
|
export type TranscriptionInfo = {
|
|
236
254
|
/** The transcription text */
|
|
237
255
|
text: string;
|
|
238
|
-
/** The transcription system used */
|
|
239
|
-
system: TranscriptionSystem;
|
|
240
256
|
/** Pronunciation variants */
|
|
241
257
|
variants?: PronunciationVariant[];
|
|
242
258
|
/** Tone information (for tonal languages) */
|
|
@@ -284,7 +300,7 @@ export type LinguisticMetadata = {
|
|
|
284
300
|
/** @deprecated Use extras.translations instead */
|
|
285
301
|
fullDefinition?: string;
|
|
286
302
|
/** @deprecated Use metadata enrichment extensions instead */
|
|
287
|
-
difficulty?: "beginner" | "intermediate" | "advanced";
|
|
303
|
+
difficulty?: "beginner" | "intermediate" | "advanced" | 1 | 2 | 3 | 4 | 5 | string;
|
|
288
304
|
};
|
|
289
305
|
|
|
290
306
|
// ============================================================================
|
|
@@ -367,7 +383,7 @@ export type GLOSTWord = Omit<NlcstWord, "children"> & {
|
|
|
367
383
|
/** @deprecated Use extras.translations instead */
|
|
368
384
|
fullDefinition?: string;
|
|
369
385
|
/** @deprecated Use metadata enrichment extensions instead */
|
|
370
|
-
difficulty?: "beginner" | "intermediate" | "advanced";
|
|
386
|
+
difficulty?: "beginner" | "intermediate" | "advanced" | 1 | 2 | 3 | 4 | 5 | string;
|
|
371
387
|
/** Language code for this node */
|
|
372
388
|
lang?: LanguageCode;
|
|
373
389
|
/** Script system used */
|
package/src/utils.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
GLOSTSyllable,
|
|
14
14
|
GLOSTWord,
|
|
15
15
|
TranscriptionSystem,
|
|
16
|
-
} from "./types";
|
|
16
|
+
} from "./types.js";
|
|
17
17
|
|
|
18
18
|
// ============================================================================
|
|
19
19
|
// BCP-47 Language Tag Utilities
|
|
@@ -517,7 +517,7 @@ export function getWordPartOfSpeech(word: GLOSTWord): string {
|
|
|
517
517
|
/**
|
|
518
518
|
* Get word difficulty
|
|
519
519
|
*/
|
|
520
|
-
export function getWordDifficulty(word: GLOSTWord): string {
|
|
520
|
+
export function getWordDifficulty(word: GLOSTWord): string | number {
|
|
521
521
|
return word.difficulty ?? word.extras?.metadata?.difficulty ?? "";
|
|
522
522
|
}
|
|
523
523
|
|