@ox-content/napi 0.13.0 → 0.14.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 (3) hide show
  1. package/index.d.ts +108 -0
  2. package/index.js +5 -0
  3. package/package.json +6 -6
package/index.d.ts CHANGED
@@ -7,6 +7,14 @@
7
7
  */
8
8
  export declare function buildSearchIndex(documents: Array<JsSearchDocument>): string
9
9
 
10
+ /**
11
+ * Runs i18n checks on dictionaries against used translation keys.
12
+ *
13
+ * `dict_dir` is the path to the i18n directory with locale subdirectories.
14
+ * `used_keys` is a list of translation keys found in source code.
15
+ */
16
+ export declare function checkI18n(dictDir: string, usedKeys: Array<string>): I18NCheckResult
17
+
10
18
  /**
11
19
  * Extracts searchable content from Markdown source.
12
20
  *
@@ -14,6 +22,13 @@ export declare function buildSearchIndex(documents: Array<JsSearchDocument>): st
14
22
  */
15
23
  export declare function extractSearchContent(source: string, id: string, url: string, options?: JsParserOptions | undefined | null): JsSearchDocument
16
24
 
25
+ /**
26
+ * Extracts translation keys from a TypeScript/JavaScript source string.
27
+ *
28
+ * Finds calls like `t('key')` and `$t('key')`.
29
+ */
30
+ export declare function extractTranslationKeys(source: string, filePath: string, functionNames?: Array<string> | undefined | null): Array<I18NKeyUsage>
31
+
17
32
  /**
18
33
  * Generates an OG image as SVG.
19
34
  *
@@ -25,6 +40,52 @@ export declare function generateOgImageSvg(data: JsOgImageData, config?: JsOgIma
25
40
  /** Generates SSG HTML page with navigation and search. */
26
41
  export declare function generateSsgHtml(pageData: JsSsgPageData, navGroups: Array<JsSsgNavGroup>, config: JsSsgConfig): string
27
42
 
43
+ /** Result of i18n checking. */
44
+ export interface I18NCheckResult {
45
+ /** All diagnostics. */
46
+ diagnostics: Array<I18NDiagnostic>
47
+ /** Number of errors. */
48
+ errorCount: number
49
+ /** Number of warnings. */
50
+ warningCount: number
51
+ }
52
+
53
+ /** A single i18n diagnostic. */
54
+ export interface I18NDiagnostic {
55
+ /** Severity: "error", "warning", or "info". */
56
+ severity: string
57
+ /** Diagnostic message. */
58
+ message: string
59
+ /** Related translation key, if any. */
60
+ key?: string
61
+ /** Related locale, if any. */
62
+ locale?: string
63
+ }
64
+
65
+ /** A translation key usage found in source code. */
66
+ export interface I18NKeyUsage {
67
+ /** The translation key. */
68
+ key: string
69
+ /** Source file path. */
70
+ filePath: string
71
+ /** Line number. */
72
+ line: number
73
+ /** Column number. */
74
+ column: number
75
+ /** End column number. */
76
+ endColumn: number
77
+ }
78
+
79
+ /** Result of loading dictionaries. */
80
+ export interface I18NLoadResult {
81
+ /** Number of locales loaded. */
82
+ localeCount: number
83
+ /** All locale tags. */
84
+ locales: Array<string>
85
+ /** Errors encountered during loading. */
86
+ errors: Array<string>
87
+ }
88
+
28
89
  /** Entry page configuration. */
29
90
  export interface JsEntryPageConfig {
30
91
  /** Hero section. */
@@ -83,6 +144,16 @@ export interface JsHeroImage {
83
144
  height?: number
84
145
  }
85
146
 
147
+ /** Locale information for the locale switcher. */
148
+ export interface JsLocaleInfo {
149
+ /** BCP 47 locale tag. */
150
+ code: string
151
+ /** Display name. */
152
+ name: string
153
+ /** Text direction. */
154
+ dir: string
155
+ }
156
+
86
157
  /** OG image configuration for JavaScript. */
87
158
  export interface JsOgImageConfig {
88
159
  /** Image width in pixels. */
@@ -191,6 +262,10 @@ export interface JsSsgConfig {
191
262
  ogImage?: string
192
263
  /** Theme configuration. */
193
264
  theme?: JsThemeConfig
265
+ /** Current locale for this page. */
266
+ locale?: string
267
+ /** Available locales for locale switcher. */
268
+ availableLocales?: Array<JsLocaleInfo>
194
269
  }
195
270
 
196
271
  /** Navigation group for SSG. */
@@ -355,6 +430,22 @@ export interface JsTransformOptions {
355
430
  sourcePath?: string
356
431
  }
357
432
 
433
+ /**
434
+ * Loads dictionaries from the given directory.
435
+ *
436
+ * The directory should contain locale subdirectories (e.g., `en/`, `ja/`)
437
+ * with JSON or YAML translation files.
438
+ */
439
+ export declare function loadDictionaries(dir: string): I18NLoadResult
440
+
441
+ /**
442
+ * Loads dictionaries from the given directory and returns a flat key-value map per locale.
443
+ *
444
+ * Each locale maps to a flat `{ "namespace.key": "value" }` structure.
445
+ * Supports both JSON and YAML dictionary files.
446
+ */
447
+ export declare function loadDictionariesFlat(dir: string): Record<string, Record<string, string>>
448
+
358
449
  /** Mermaid transform result. */
359
450
  export interface MermaidTransformResult {
360
451
  /** The transformed HTML with mermaid code blocks replaced by rendered SVGs. */
@@ -363,6 +454,16 @@ export interface MermaidTransformResult {
363
454
  errors: Array<string>
364
455
  }
365
456
 
457
+ /** Result of MF2 validation. */
458
+ export interface Mf2ValidateResult {
459
+ /** Whether the message is valid. */
460
+ valid: boolean
461
+ /** Validation errors. */
462
+ errors: Array<string>
463
+ /** AST as JSON (if parsing succeeded). */
464
+ astJson?: string
465
+ }
466
+
366
467
  /**
367
468
  * Parses Markdown source into an AST.
368
469
  *
@@ -444,5 +545,12 @@ export interface TransformResult {
444
545
  errors: Array<string>
445
546
  }
446
547
 
548
+ /**
549
+ * Validates an MF2 message string.
550
+ *
551
+ * Returns parsing and semantic validation results.
552
+ */
553
+ export declare function validateMf2(message: string): Mf2ValidateResult
554
+
447
555
  /** Returns the version of ox_content_napi. */
448
556
  export declare function version(): string
package/index.js CHANGED
@@ -82,3 +82,8 @@ module.exports.searchIndex = binding.searchIndex
82
82
  module.exports.extractSearchContent = binding.extractSearchContent
83
83
  module.exports.generateSsgHtml = binding.generateSsgHtml
84
84
  module.exports.transformMermaid = binding.transformMermaid
85
+ module.exports.loadDictionaries = binding.loadDictionaries
86
+ module.exports.loadDictionariesFlat = binding.loadDictionariesFlat
87
+ module.exports.validateMf2 = binding.validateMf2
88
+ module.exports.checkI18n = binding.checkI18n
89
+ module.exports.extractTranslationKeys = binding.extractTranslationKeys
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/napi",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Node.js bindings for Ox Content - High-performance Markdown parser",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -45,10 +45,10 @@
45
45
  "author": "ubugeeei",
46
46
  "license": "MIT",
47
47
  "optionalDependencies": {
48
- "@ox-content/binding-darwin-x64": "0.13.0",
49
- "@ox-content/binding-darwin-arm64": "0.13.0",
50
- "@ox-content/binding-linux-x64-gnu": "0.13.0",
51
- "@ox-content/binding-linux-arm64-gnu": "0.13.0",
52
- "@ox-content/binding-win32-x64-msvc": "0.13.0"
48
+ "@ox-content/binding-darwin-x64": "0.14.0",
49
+ "@ox-content/binding-darwin-arm64": "0.14.0",
50
+ "@ox-content/binding-linux-x64-gnu": "0.14.0",
51
+ "@ox-content/binding-linux-arm64-gnu": "0.14.0",
52
+ "@ox-content/binding-win32-x64-msvc": "0.14.0"
53
53
  }
54
54
  }