glost-core 0.5.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE +21 -0
  3. package/README.md +199 -0
  4. package/dist/__benchmarks__/document-creation.bench.d.ts +7 -0
  5. package/dist/__benchmarks__/document-creation.bench.d.ts.map +1 -0
  6. package/dist/__benchmarks__/document-creation.bench.js +71 -0
  7. package/dist/__benchmarks__/document-creation.bench.js.map +1 -0
  8. package/dist/__benchmarks__/traversal.bench.d.ts +7 -0
  9. package/dist/__benchmarks__/traversal.bench.d.ts.map +1 -0
  10. package/dist/__benchmarks__/traversal.bench.js +124 -0
  11. package/dist/__benchmarks__/traversal.bench.js.map +1 -0
  12. package/dist/cli/migrate.d.ts +8 -0
  13. package/dist/cli/migrate.d.ts.map +1 -0
  14. package/dist/cli/migrate.js +229 -0
  15. package/dist/cli/migrate.js.map +1 -0
  16. package/dist/errors.d.ts +168 -0
  17. package/dist/errors.d.ts.map +1 -0
  18. package/dist/errors.js +300 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/guards.d.ts +103 -0
  21. package/dist/guards.d.ts.map +1 -0
  22. package/dist/guards.js +264 -0
  23. package/dist/guards.js.map +1 -0
  24. package/dist/index.d.ts +9 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +25 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/nodes.d.ts +227 -0
  29. package/dist/nodes.d.ts.map +1 -0
  30. package/dist/nodes.js +243 -0
  31. package/dist/nodes.js.map +1 -0
  32. package/dist/types.d.ts +442 -0
  33. package/dist/types.d.ts.map +1 -0
  34. package/dist/types.js +51 -0
  35. package/dist/types.js.map +1 -0
  36. package/dist/utils.d.ts +247 -0
  37. package/dist/utils.d.ts.map +1 -0
  38. package/dist/utils.js +564 -0
  39. package/dist/utils.js.map +1 -0
  40. package/dist/validators.d.ts +1876 -0
  41. package/dist/validators.d.ts.map +1 -0
  42. package/dist/validators.js +302 -0
  43. package/dist/validators.js.map +1 -0
  44. package/package.json +73 -0
  45. package/src/__benchmarks__/document-creation.bench.ts +92 -0
  46. package/src/__benchmarks__/traversal.bench.ts +152 -0
  47. package/src/__tests__/README.md +20 -0
  48. package/src/__tests__/example.test.ts +43 -0
  49. package/src/__tests__/example.ts +186 -0
  50. package/src/__tests__/helpers.test.ts +178 -0
  51. package/src/__tests__/mock-data.ts +624 -0
  52. package/src/__tests__/performance.test.ts +317 -0
  53. package/src/__tests__/traversal.test.ts +170 -0
  54. package/src/cli/migrate.ts +294 -0
  55. package/src/errors.ts +394 -0
  56. package/src/guards.ts +341 -0
  57. package/src/index.ts +69 -0
  58. package/src/nodes.ts +409 -0
  59. package/src/types.ts +633 -0
  60. package/src/utils.ts +730 -0
  61. package/src/validators.ts +336 -0
  62. package/tsconfig.json +9 -0
@@ -0,0 +1,442 @@
1
+ import type { Literal as NlcstLiteral, Paragraph as NlcstParagraph, Punctuation as NlcstPunctuation, Root as NlcstRoot, Sentence as NlcstSentence, Source as NlcstSource, Symbol as NlcstSymbol, Text as NlcstText, WhiteSpace as NlcstWhiteSpace, Word as NlcstWord } from "nlcst";
2
+ /**
3
+ * Standard GLOST node type constants
4
+ *
5
+ * Use these constants instead of string literals for type checking to prevent
6
+ * typos and enable autocomplete.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { NODE_TYPES } from "glost";
11
+ *
12
+ * if (node.type === NODE_TYPES.WORD) {
13
+ * // Handle word node with autocomplete and type safety
14
+ * }
15
+ * ```
16
+ */
17
+ export declare const NODE_TYPES: {
18
+ /** Root document node */
19
+ readonly ROOT: "RootNode";
20
+ /** Paragraph node */
21
+ readonly PARAGRAPH: "ParagraphNode";
22
+ /** Sentence node */
23
+ readonly SENTENCE: "SentenceNode";
24
+ /** Word node */
25
+ readonly WORD: "WordNode";
26
+ /** Text node (leaf node containing actual text) */
27
+ readonly TEXT: "TextNode";
28
+ /** Whitespace node */
29
+ readonly WHITESPACE: "WhiteSpaceNode";
30
+ /** Punctuation node */
31
+ readonly PUNCTUATION: "PunctuationNode";
32
+ /** Symbol node */
33
+ readonly SYMBOL: "SymbolNode";
34
+ /** Source node */
35
+ readonly SOURCE: "SourceNode";
36
+ /** Clause node (created by transformers) */
37
+ readonly CLAUSE: "ClauseNode";
38
+ /** Phrase node (created by transformers) */
39
+ readonly PHRASE: "PhraseNode";
40
+ /** Syllable node */
41
+ readonly SYLLABLE: "SyllableNode";
42
+ /** Character node */
43
+ readonly CHARACTER: "CharacterNode";
44
+ };
45
+ /**
46
+ * Type representing any valid GLOST node type string
47
+ */
48
+ export type NodeType = typeof NODE_TYPES[keyof typeof NODE_TYPES];
49
+ /**
50
+ * Linguistic level of a text segment
51
+ */
52
+ export type LinguisticLevel = "character" | "syllable" | "word" | "phrase" | "sentence" | "paragraph";
53
+ /**
54
+ * Context for pronunciation variants
55
+ */
56
+ export type PronunciationContext = "formal" | "informal" | "historical" | "regional" | "dialectal";
57
+ /**
58
+ * Transcription system identifiers
59
+ */
60
+ export type TranscriptionSystem = "rtgs" | "aua" | "paiboon" | "romaji" | "furigana" | "ipa" | "pinyin" | "hangul" | string;
61
+ /**
62
+ * Language codes following BCP-47 format (RFC 5646)
63
+ * Format: language[-script][-region][-variant]
64
+ * Examples: th-TH, ja-JP, zh-CN, ko-KR, en-US, fr-FR, de-DE
65
+ */
66
+ export type LanguageCode = "th-TH" | "th" | "ja-JP" | "ja" | "zh-CN" | "zh-TW" | "zh-HK" | "zh" | "ko-KR" | "ko-KP" | "ko" | "en-US" | "en-GB" | "en-CA" | "en-AU" | "en" | "fr-FR" | "fr-CA" | "fr-BE" | "fr" | "de-DE" | "de-AT" | "de-CH" | "de" | "es-ES" | "es-MX" | "es-AR" | "es" | "it-IT" | "it-CH" | "it" | "pt-PT" | "pt-BR" | "pt" | "ru-RU" | "ru" | "ar-SA" | "ar-EG" | "ar" | "hi-IN" | "hi" | string;
67
+ /**
68
+ * Script system identifiers
69
+ */
70
+ export type ScriptSystem = "thai" | "hiragana" | "katakana" | "kanji" | "hanzi" | "hangul" | "latin" | "mixed" | string;
71
+ /**
72
+ * Quick translations in different languages using BCP-47 format
73
+ */
74
+ export type QuickTranslations = {
75
+ /** English translations */
76
+ "en-US"?: string;
77
+ "en-GB"?: string;
78
+ "en"?: string;
79
+ /** Thai translations */
80
+ "th-TH"?: string;
81
+ "th"?: string;
82
+ /** Japanese translations */
83
+ "ja-JP"?: string;
84
+ "ja"?: string;
85
+ /** Chinese translations */
86
+ "zh-CN"?: string;
87
+ "zh-TW"?: string;
88
+ "zh"?: string;
89
+ /** Korean translations */
90
+ "ko-KR"?: string;
91
+ "ko"?: string;
92
+ /** French translations */
93
+ "fr-FR"?: string;
94
+ "fr-CA"?: string;
95
+ "fr"?: string;
96
+ /** German translations */
97
+ "de-DE"?: string;
98
+ "de"?: string;
99
+ /** Spanish translations */
100
+ "es-ES"?: string;
101
+ "es-MX"?: string;
102
+ "es"?: string;
103
+ /** Custom language translations using BCP-47 format */
104
+ [lang: string]: string | undefined;
105
+ };
106
+ /**
107
+ * Extended metadata for enhanced functionality
108
+ */
109
+ export type ExtendedMetadata = {
110
+ /** Quick translations in multiple languages */
111
+ translations?: QuickTranslations;
112
+ /** Difficulty level for learners */
113
+ difficulty?: "beginner" | "intermediate" | "advanced" | 1 | 2 | 3 | 4 | 5 | string;
114
+ /** Frequency in common usage */
115
+ frequency?: "rare" | "uncommon" | "common" | "very-common";
116
+ /** Cultural notes */
117
+ culturalNotes?: string;
118
+ /** Related words or concepts */
119
+ related?: string[];
120
+ /** Example sentences */
121
+ examples?: string[];
122
+ /** Custom extensions */
123
+ [key: string]: any;
124
+ };
125
+ /**
126
+ * Extras field for extending GLOST nodes
127
+ *
128
+ * This interface can be augmented by extension packages via declaration merging.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * // In an extension package
133
+ * declare module "glost" {
134
+ * interface GLOSTExtras {
135
+ * frequency?: {
136
+ * rank: number;
137
+ * category: "very-common" | "common" | "uncommon" | "rare";
138
+ * };
139
+ * }
140
+ * }
141
+ * ```
142
+ */
143
+ export interface GLOSTExtras {
144
+ /** Quick translations */
145
+ translations?: QuickTranslations;
146
+ /** Extended metadata */
147
+ metadata?: ExtendedMetadata;
148
+ /** Custom extensions - allows any string key with unknown value */
149
+ [key: string]: unknown;
150
+ }
151
+ /**
152
+ * Pronunciation variant for a text segment
153
+ */
154
+ export type PronunciationVariant = {
155
+ /** The variant text in the transcription system */
156
+ text: string;
157
+ /** Context where this variant is used */
158
+ context: PronunciationContext;
159
+ /** Additional notes about this variant */
160
+ notes?: string;
161
+ };
162
+ /**
163
+ * Transcription information for a text segment
164
+ *
165
+ * Note: The transcription system is not stored in this object.
166
+ * It is the key in the TransliterationData record.
167
+ */
168
+ export type TranscriptionInfo = {
169
+ /** The transcription text */
170
+ text: string;
171
+ /** Pronunciation variants */
172
+ variants?: PronunciationVariant[];
173
+ /** Tone information (for tonal languages) */
174
+ tone?: number;
175
+ /** Syllable breakdown */
176
+ syllables?: string[];
177
+ /** Additional phonetic information */
178
+ phonetic?: string;
179
+ };
180
+ /**
181
+ * Complete transliteration data for a text segment
182
+ */
183
+ export type TransliterationData = {
184
+ /** Map of transcription systems to their data */
185
+ [system: string]: TranscriptionInfo;
186
+ };
187
+ /**
188
+ * Linguistic metadata for a text segment
189
+ */
190
+ export type LinguisticMetadata = {
191
+ /** @deprecated Use extras.translations instead */
192
+ meaning?: string;
193
+ /** Part of speech */
194
+ partOfSpeech: string;
195
+ /** Usage notes */
196
+ usage?: string;
197
+ /** Etymology information */
198
+ etymology?: string;
199
+ /** Example usage */
200
+ examples?: string[];
201
+ /** Frequency information */
202
+ frequency?: "high" | "medium" | "low";
203
+ /** Formality level */
204
+ formality?: "formal" | "neutral" | "informal";
205
+ /** Register (academic, colloquial, etc.) */
206
+ register?: string;
207
+ /** @deprecated Use extras.translations instead */
208
+ shortDefinition?: string;
209
+ /** @deprecated Use extras.translations instead */
210
+ fullDefinition?: string;
211
+ /** @deprecated Use metadata enrichment extensions instead */
212
+ difficulty?: "beginner" | "intermediate" | "advanced" | 1 | 2 | 3 | 4 | 5 | string;
213
+ };
214
+ /**
215
+ * Union type for all GLOST nodes
216
+ */
217
+ export type GLOSTNode = GLOSTWord | GLOSTSentence | GLOSTParagraph | GLOSTRoot | GLOSTText | GLOSTSymbol | GLOSTPunctuation | GLOSTWhiteSpace | GLOSTSource | GLOSTClause | GLOSTPhrase | GLOSTSyllable | GLOSTCharacter;
218
+ /**
219
+ * GLOST nodes that extend nlcst Literal (have a value property)
220
+ */
221
+ export type GLOSTLiteral = NlcstLiteral & {
222
+ /** Language code for this node */
223
+ lang?: LanguageCode;
224
+ /** Script system used */
225
+ script?: ScriptSystem;
226
+ /** Linguistic level of this segment */
227
+ level?: LinguisticLevel;
228
+ /** Extras field for extensions */
229
+ extras?: GLOSTExtras;
230
+ };
231
+ /**
232
+ * GLOST Punctuation node (extends nlcst PunctuationNode)
233
+ */
234
+ export type GLOSTPunctuation = NlcstPunctuation & {};
235
+ /**
236
+ * GLOST WhiteSpace node (extends nlcst WhiteSpaceNode)
237
+ */
238
+ export type GLOSTWhiteSpace = NlcstWhiteSpace & {};
239
+ /**
240
+ * GLOST Symbol node (extends nlcst SymbolNode)
241
+ */
242
+ export type GLOSTSymbol = NlcstSymbol & {};
243
+ /**
244
+ * GLOST Text node (extends nlcst TextNode)
245
+ */
246
+ export type GLOSTText = NlcstText & {};
247
+ /**
248
+ * GLOST Source node (extends nlcst SourceNode)
249
+ */
250
+ export type GLOSTSource = NlcstSource & {};
251
+ /**
252
+ * Extended word node with transcription support
253
+ * Extends nlcst WordNode and adds GLOST-specific properties
254
+ */
255
+ export type GLOSTWord = Omit<NlcstWord, "children"> & {
256
+ /** Transcription data (optional - can be added by extensions) */
257
+ transcription?: TransliterationData;
258
+ /** Linguistic metadata (optional - can be added by extensions) */
259
+ metadata?: LinguisticMetadata;
260
+ /** @deprecated Use extras.translations instead */
261
+ shortDefinition?: string;
262
+ /** @deprecated Use extras.translations instead */
263
+ fullDefinition?: string;
264
+ /** @deprecated Use metadata enrichment extensions instead */
265
+ difficulty?: "beginner" | "intermediate" | "advanced" | 1 | 2 | 3 | 4 | 5 | string;
266
+ /** Language code for this node */
267
+ lang?: LanguageCode;
268
+ /** Script system used */
269
+ script?: ScriptSystem;
270
+ /** Linguistic level of this segment */
271
+ level?: LinguisticLevel;
272
+ /** Extras field for extensions */
273
+ extras?: GLOSTExtras;
274
+ /** Children nodes - must contain at least one Text node */
275
+ children: GLOSTWordContent[];
276
+ };
277
+ /**
278
+ * Extended sentence node
279
+ * Extends nlcst SentenceNode and adds GLOST-specific properties
280
+ */
281
+ export type GLOSTSentence = Omit<NlcstSentence, "children"> & {
282
+ /** Language of the sentence */
283
+ lang: LanguageCode;
284
+ /** Script system used */
285
+ script: ScriptSystem;
286
+ /** Original text */
287
+ originalText: string;
288
+ /** Transcription data for the entire sentence */
289
+ transcription?: TransliterationData;
290
+ /** Extras field for extensions */
291
+ extras?: GLOSTExtras;
292
+ /** Children nodes - must be nlcst-compliant */
293
+ children: GLOSTSentenceContent[];
294
+ };
295
+ /**
296
+ * Extended paragraph node
297
+ */
298
+ export type GLOSTParagraph = Omit<NlcstParagraph, "children"> & {
299
+ /** Language of the paragraph */
300
+ lang?: LanguageCode;
301
+ /** Script system used */
302
+ script?: ScriptSystem;
303
+ /** Extras field for extensions */
304
+ extras?: GLOSTExtras;
305
+ /** Children nodes - must be nlcst-compliant */
306
+ children: GLOSTParagraphContent[];
307
+ };
308
+ /**
309
+ * Extended root node
310
+ */
311
+ export type GLOSTRoot = Omit<NlcstRoot, "children"> & {
312
+ /** Primary language of the document */
313
+ lang: LanguageCode;
314
+ /** Primary script system */
315
+ script: ScriptSystem;
316
+ /** Extras field for extensions */
317
+ extras?: GLOSTExtras;
318
+ /** Document metadata */
319
+ metadata?: {
320
+ title?: string;
321
+ author?: string;
322
+ date?: string;
323
+ description?: string;
324
+ };
325
+ /** Children nodes - must be nlcst-compliant */
326
+ children: GLOSTRootContent[];
327
+ };
328
+ /**
329
+ * Clause node - represents grammatical clauses within sentences
330
+ * Created by ClauseSegmenterExtension transformer
331
+ */
332
+ export type GLOSTClause = {
333
+ type: "ClauseNode";
334
+ /** Type of clause */
335
+ clauseType: "main" | "subordinate" | "relative" | "adverbial";
336
+ /** Children nodes - phrases, words, or punctuation */
337
+ children: (GLOSTPhrase | GLOSTWord | GLOSTPunctuation)[];
338
+ /** Language code for this clause */
339
+ lang?: LanguageCode;
340
+ /** Script system used */
341
+ script?: ScriptSystem;
342
+ /** Extras field for extensions */
343
+ extras?: GLOSTExtras & {
344
+ /** Whether this clause has been negated */
345
+ isNegated?: boolean;
346
+ /** Grammatical mood */
347
+ mood?: "declarative" | "interrogative" | "imperative" | "conditional";
348
+ /** Tense information */
349
+ tense?: string;
350
+ /** Original form before transformation */
351
+ originalForm?: string;
352
+ };
353
+ };
354
+ /**
355
+ * Phrase node - groups words into grammatical phrases
356
+ * Created by PhraseSegmenterExtension transformer
357
+ */
358
+ export type GLOSTPhrase = {
359
+ type: "PhraseNode";
360
+ /** Type of phrase */
361
+ phraseType: "noun" | "verb" | "prepositional" | "adjectival" | "adverbial";
362
+ /** Main word of the phrase (head) */
363
+ headWord?: string;
364
+ /** Children nodes - words or punctuation */
365
+ children: (GLOSTWord | GLOSTPunctuation)[];
366
+ /** Language code for this phrase */
367
+ lang?: LanguageCode;
368
+ /** Script system used */
369
+ script?: ScriptSystem;
370
+ /** Extras field for extensions */
371
+ extras?: GLOSTExtras & {
372
+ /** Grammatical role in the clause/sentence */
373
+ role?: "subject" | "object" | "complement" | "modifier";
374
+ };
375
+ };
376
+ /**
377
+ * Syllable node - represents phonological syllable structure
378
+ * Created by SyllableSegmenterExtension transformer (language-specific)
379
+ */
380
+ export type GLOSTSyllable = {
381
+ type: "SyllableNode";
382
+ /** Syllable structure information */
383
+ structure: {
384
+ /** Initial consonant(s) - Generic (e.g., "h" in "hello") */
385
+ onset?: string;
386
+ /** Vowel - Generic (e.g., "e" in "hello") */
387
+ nucleus: string;
388
+ /** Final consonant(s) - Generic (e.g., "l" in "hello") */
389
+ coda?: string;
390
+ /** Initial consonant (Thai: พยัญชนะต้น) */
391
+ Ci?: string;
392
+ /** Vowel (Thai: สระ) */
393
+ V?: string;
394
+ /** Final consonant (Thai: ตัวสะกด) */
395
+ Cf?: string;
396
+ /** Tone mark (Thai: วรรณยุกต์) */
397
+ T?: string;
398
+ };
399
+ /** Children nodes - individual characters */
400
+ children: GLOSTCharacter[];
401
+ /** Language code for this syllable */
402
+ lang?: LanguageCode;
403
+ /** Script system used */
404
+ script?: ScriptSystem;
405
+ /** Tone number (for tonal languages like Thai, Mandarin) */
406
+ tone?: number;
407
+ /** Stress level (for stress languages like English) */
408
+ stress?: "primary" | "secondary" | "unstressed";
409
+ /** Extras field for extensions */
410
+ extras?: GLOSTExtras;
411
+ };
412
+ /**
413
+ * Character node - represents individual characters with linguistic roles
414
+ * Created by SyllableSegmenterExtension or CharacterSegmenterExtension
415
+ */
416
+ export type GLOSTCharacter = {
417
+ type: "CharacterNode";
418
+ /** The character value (single character) */
419
+ value: string;
420
+ /** Linguistic role of the character */
421
+ role?: "consonant" | "vowel" | "tone" | "diacritic" | "modifier";
422
+ /** Placement in the syllable/word (renamed from 'position' to avoid conflict with unist Position) */
423
+ placement?: "initial" | "medial" | "final" | "above" | "below" | "before" | "after";
424
+ /** Language code for this character */
425
+ lang?: LanguageCode;
426
+ /** Script system used */
427
+ script?: ScriptSystem;
428
+ /** Extras field for extensions */
429
+ extras?: GLOSTExtras & {
430
+ /** Unicode code point (e.g., "U+0E04") */
431
+ unicode?: string;
432
+ /** Thai consonant class (high/mid/low) */
433
+ class?: "high" | "mid" | "low";
434
+ /** Phonological sound class */
435
+ soundClass?: string;
436
+ };
437
+ };
438
+ export type GLOSTRootContent = GLOSTParagraph | GLOSTSentence | GLOSTWord | GLOSTText | GLOSTSymbol | GLOSTPunctuation | GLOSTWhiteSpace | GLOSTSource;
439
+ export type GLOSTParagraphContent = GLOSTSentence | GLOSTPunctuation | GLOSTSymbol | GLOSTWhiteSpace | GLOSTSource;
440
+ export type GLOSTSentenceContent = GLOSTClause | GLOSTWord | GLOSTPunctuation | GLOSTSymbol | GLOSTWhiteSpace | GLOSTSource;
441
+ export type GLOSTWordContent = GLOSTSyllable | GLOSTText | GLOSTSymbol | GLOSTPunctuation | GLOSTWhiteSpace | GLOSTSource;
442
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,SAAS,IAAI,cAAc,EAAE,WAAW,IAAI,gBAAgB,EAAE,IAAI,IAAI,SAAS,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,IAAI,WAAW,EAAE,IAAI,IAAI,SAAS,EAAE,UAAU,IAAI,eAAe,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,OAAO,CAAC;AAMpR;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU;IACrB,yBAAyB;;IAEzB,qBAAqB;;IAErB,oBAAoB;;IAEpB,gBAAgB;;IAEhB,mDAAmD;;IAEnD,sBAAsB;;IAEtB,uBAAuB;;IAEvB,kBAAkB;;IAElB,kBAAkB;;IAElB,4CAA4C;;IAE5C,4CAA4C;;IAE5C,oBAAoB;;IAEpB,qBAAqB;;CAEb,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AASlE;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,WAAW,GACX,UAAU,GACV,MAAM,GACN,QAAQ,GACR,UAAU,GACV,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,GACR,UAAU,GACV,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a,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,GAAG,eAAe,GAAG,WAAW,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,51 @@
1
+ // ============================================================================
2
+ // Node Type Constants
3
+ // ============================================================================
4
+ /**
5
+ * Standard GLOST node type constants
6
+ *
7
+ * Use these constants instead of string literals for type checking to prevent
8
+ * typos and enable autocomplete.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { NODE_TYPES } from "glost";
13
+ *
14
+ * if (node.type === NODE_TYPES.WORD) {
15
+ * // Handle word node with autocomplete and type safety
16
+ * }
17
+ * ```
18
+ */
19
+ export const NODE_TYPES = {
20
+ /** Root document node */
21
+ ROOT: "RootNode",
22
+ /** Paragraph node */
23
+ PARAGRAPH: "ParagraphNode",
24
+ /** Sentence node */
25
+ SENTENCE: "SentenceNode",
26
+ /** Word node */
27
+ WORD: "WordNode",
28
+ /** Text node (leaf node containing actual text) */
29
+ TEXT: "TextNode",
30
+ /** Whitespace node */
31
+ WHITESPACE: "WhiteSpaceNode",
32
+ /** Punctuation node */
33
+ PUNCTUATION: "PunctuationNode",
34
+ /** Symbol node */
35
+ SYMBOL: "SymbolNode",
36
+ /** Source node */
37
+ SOURCE: "SourceNode",
38
+ /** Clause node (created by transformers) */
39
+ CLAUSE: "ClauseNode",
40
+ /** Phrase node (created by transformers) */
41
+ PHRASE: "PhraseNode",
42
+ /** Syllable node */
43
+ SYLLABLE: "SyllableNode",
44
+ /** Character node */
45
+ CHARACTER: "CharacterNode",
46
+ };
47
+ // ============================================================================
48
+ // Utility Types
49
+ // ============================================================================
50
+ // Type guards are now implemented in utils.ts using unist-util-is
51
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,yBAAyB;IACzB,IAAI,EAAE,UAAU;IAChB,qBAAqB;IACrB,SAAS,EAAE,eAAe;IAC1B,oBAAoB;IACpB,QAAQ,EAAE,cAAc;IACxB,gBAAgB;IAChB,IAAI,EAAE,UAAU;IAChB,mDAAmD;IACnD,IAAI,EAAE,UAAU;IAChB,sBAAsB;IACtB,UAAU,EAAE,gBAAgB;IAC5B,uBAAuB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,kBAAkB;IAClB,MAAM,EAAE,YAAY;IACpB,kBAAkB;IAClB,MAAM,EAAE,YAAY;IACpB,4CAA4C;IAC5C,MAAM,EAAE,YAAY;IACpB,4CAA4C;IAC5C,MAAM,EAAE,YAAY;IACpB,oBAAoB;IACpB,QAAQ,EAAE,cAAc;IACxB,qBAAqB;IACrB,SAAS,EAAE,eAAe;CAClB,CAAC;AAokBX,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,kEAAkE"}