@ox-content/napi 2.8.0 → 2.9.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 +186 -12
  2. package/index.js +18 -0
  3. package/package.json +6 -6
package/index.d.ts CHANGED
@@ -7,6 +7,12 @@
7
7
  */
8
8
  export declare function buildSearchIndex(documents: Array<JsSearchDocument>): string
9
9
 
10
+ /** Builds SSG navigation groups from markdown files. */
11
+ export declare function buildSsgNavItems(markdownFiles: Array<string>, srcDir: string, base: string, extension: string): Array<JsSsgNavGroup>
12
+
13
+ /** Builds SSG navigation groups from an explicit theme sidebar tree. */
14
+ export declare function buildSsgThemeNavItems(sidebar: Array<JsSsgSidebarItem>, base: string, extension: string): Array<JsSsgNavGroup>
15
+
10
16
  /**
11
17
  * Runs i18n checks on dictionaries against used translation keys.
12
18
  *
@@ -15,6 +21,12 @@ export declare function buildSearchIndex(documents: Array<JsSearchDocument>): st
15
21
  */
16
22
  export declare function checkI18n(dictDir: string, usedKeys: Array<string>): I18NCheckResult
17
23
 
24
+ /** Extracts shared CSS and JavaScript assets from generated SSG pages. */
25
+ export declare function externalizeSsgAssets(pages: Array<JsSsgGeneratedHtmlPage>, outDir: string, base: string): JsSsgExternalizedAssets
26
+
27
+ /** Extracts normalized documentation entries from a JavaScript/TypeScript file using Oxc. */
28
+ export declare function extractFileDocEntries(filePath: string, includePrivate?: boolean | undefined | null): Array<JsDocEntry>
29
+
18
30
  /** Extracts documented declarations from a JavaScript/TypeScript file using Oxc. */
19
31
  export declare function extractFileDocs(filePath: string, includePrivate?: boolean | undefined | null): Array<JsSourceDocItem>
20
32
 
@@ -25,6 +37,9 @@ export declare function extractFileDocs(filePath: string, includePrivate?: boole
25
37
  */
26
38
  export declare function extractSearchContent(source: string, id: string, url: string, options?: JsParserOptions | undefined | null): JsSearchDocument
27
39
 
40
+ /** Extracts a page title from frontmatter title or rendered HTML. */
41
+ export declare function extractSsgTitle(content: string, frontmatterTitle?: string | undefined | null): string
42
+
28
43
  /**
29
44
  * Extracts translation keys from a TypeScript/JavaScript source string.
30
45
  *
@@ -32,6 +47,18 @@ export declare function extractSearchContent(source: string, id: string, url: st
32
47
  */
33
48
  export declare function extractTranslationKeys(source: string, filePath: string, functionNames?: Array<string> | undefined | null): Array<I18NKeyUsage>
34
49
 
50
+ /** Formats a file or directory segment as an SSG title. */
51
+ export declare function formatSsgTitle(name: string): string
52
+
53
+ /** Generates TypeScript source code for documentation navigation metadata. */
54
+ export declare function generateDocsNavCode(navItems: Array<JsDocsNavItem>, exportName?: string | undefined | null): string
55
+
56
+ /** Generates sidebar navigation metadata from documentation file paths. */
57
+ export declare function generateDocsNavMetadata(files: Array<string>, basePath?: string | undefined | null): Array<JsDocsNavItem>
58
+
59
+ /** Generates the `virtual:ox-content/i18n` runtime module. */
60
+ export declare function generateI18nModule(dictDir: string, config: JsI18NRuntimeConfig): string
61
+
35
62
  /**
36
63
  * Generates an OG image as SVG.
37
64
  *
@@ -40,12 +67,30 @@ export declare function extractTranslationKeys(source: string, filePath: string,
40
67
  */
41
68
  export declare function generateOgImageSvg(data: JsOgImageData, config?: JsOgImageConfig | undefined | null): string
42
69
 
70
+ /** Generates the client-side search runtime module. */
71
+ export declare function generateSearchModule(optionsJson: string, indexPath: string): string
72
+
43
73
  /** Generates SSG HTML page with navigation and search. */
44
74
  export declare function generateSsgHtml(pageData: JsSsgPageData, navGroups: Array<JsSsgNavGroup>, config: JsSsgConfig): string
45
75
 
46
76
  /** Returns the last git commit timestamp for a file in milliseconds. */
47
77
  export declare function getGitLastUpdated(filePath: string, root?: string | undefined | null): number | null
48
78
 
79
+ /** Derives hierarchical search scopes from a document id or URL. */
80
+ export declare function getSearchDocumentScopes(id: string, url: string): Array<string>
81
+
82
+ /** Converts a markdown file path to an SSG href. */
83
+ export declare function getSsgHref(inputPath: string, srcDir: string, base: string, extension: string): string
84
+
85
+ /** Converts a markdown file path to its corresponding SSG HTML output path. */
86
+ export declare function getSsgOutputPath(inputPath: string, srcDir: string, outDir: string, extension: string): string
87
+
88
+ /** Resolves a page locale from an SSG URL path and configured locale codes. */
89
+ export declare function getSsgPageLocale(urlPath: string, defaultLocale: string, localeCodes: Array<string>): string | null
90
+
91
+ /** Converts a markdown file path to a relative SSG URL path. */
92
+ export declare function getSsgUrlPath(inputPath: string, srcDir: string): string
93
+
49
94
  /** Result of i18n checking. */
50
95
  export interface I18NCheckResult {
51
96
  /** All diagnostics. */
@@ -92,6 +137,44 @@ export interface I18NLoadResult {
92
137
  errors: Array<string>
93
138
  }
94
139
 
140
+ /** Normalized documentation entry used by generated API docs. */
141
+ export interface JsDocEntry {
142
+ name: string
143
+ kind: string
144
+ description: string
145
+ params?: Array<JsDocParam>
146
+ returns?: JsDocReturn
147
+ examples?: Array<string>
148
+ tags?: Record<string, string>
149
+ private: boolean
150
+ file: string
151
+ line: number
152
+ endLine: number
153
+ signature?: string
154
+ }
155
+
156
+ /** Normalized parameter documentation used by generated API docs. */
157
+ export interface JsDocParam {
158
+ name: string
159
+ type: string
160
+ description: string
161
+ optional?: boolean
162
+ default?: string
163
+ }
164
+
165
+ /** Normalized return documentation used by generated API docs. */
166
+ export interface JsDocReturn {
167
+ type: string
168
+ description: string
169
+ }
170
+
171
+ /** Navigation item emitted for generated documentation. */
172
+ export interface JsDocsNavItem {
173
+ title: string
174
+ path: string
175
+ children?: Array<JsDocsNavItem>
176
+ }
177
+
95
178
  /** Entry page configuration. */
96
179
  export interface JsEntryPageConfig {
97
180
  /** Hero section. */
@@ -164,6 +247,26 @@ export interface JsHeroNotice {
164
247
  body?: Array<string>
165
248
  }
166
249
 
250
+ /** Configuration for generated i18n runtime modules. */
251
+ export interface JsI18NRuntimeConfig {
252
+ /** Default locale tag. */
253
+ defaultLocale: string
254
+ /** Available locales. */
255
+ locales: Array<JsI18NRuntimeLocale>
256
+ /** Whether URLs should omit the default locale prefix. */
257
+ hideDefaultLocale: boolean
258
+ }
259
+
260
+ /** Locale metadata for generated i18n runtime modules. */
261
+ export interface JsI18NRuntimeLocale {
262
+ /** BCP 47 locale tag. */
263
+ code: string
264
+ /** Display name for this locale. */
265
+ name: string
266
+ /** Text direction. */
267
+ dir?: string
268
+ }
269
+
167
270
  /** Locale information for the locale switcher. */
168
271
  export interface JsLocaleInfo {
169
272
  /** BCP 47 locale tag. */
@@ -265,6 +368,14 @@ export interface JsParserOptions {
265
368
  autolinks?: boolean
266
369
  }
267
370
 
371
+ /** Search query split into free text and scope prefixes. */
372
+ export interface JsScopedSearchQuery {
373
+ /** Free-text terms after removing scope prefixes. */
374
+ text: string
375
+ /** Deduplicated lowercase scopes. */
376
+ scopes: Array<string>
377
+ }
378
+
268
379
  /** Search document for JavaScript. */
269
380
  export interface JsSearchDocument {
270
381
  /** Unique document identifier. */
@@ -309,18 +420,6 @@ export interface JsSearchResult {
309
420
  snippet: string
310
421
  }
311
422
 
312
- /** Social links for JavaScript. */
313
- export interface JsSocialLinks {
314
- /** GitHub URL. */
315
- github?: string
316
- /** Twitter/X URL. */
317
- twitter?: string
318
- /** Discord URL. */
319
- discord?: string
320
- /** Custom social links. */
321
- links?: Array<JsSocialLink>
322
- }
323
-
324
423
  /** Custom social link for JavaScript. */
325
424
  export interface JsSocialLink {
326
425
  /** Icon label. */
@@ -333,6 +432,18 @@ export interface JsSocialLink {
333
432
  ariaLabel?: string
334
433
  }
335
434
 
435
+ /** Social links for JavaScript. */
436
+ export interface JsSocialLinks {
437
+ /** GitHub URL. */
438
+ github?: string
439
+ /** Twitter/X URL. */
440
+ twitter?: string
441
+ /** Discord URL. */
442
+ discord?: string
443
+ /** Custom social links. */
444
+ links?: Array<JsSocialLink>
445
+ }
446
+
336
447
  /** Source documentation item extracted from a JS/TS file. */
337
448
  export interface JsSourceDocItem {
338
449
  name: string
@@ -380,6 +491,24 @@ export interface JsSsgConfig {
380
491
  availableLocales?: Array<JsLocaleInfo>
381
492
  }
382
493
 
494
+ /** Result of SSG shared asset extraction. */
495
+ export interface JsSsgExternalizedAssets {
496
+ /** HTML pages with inline assets replaced. */
497
+ pages: Array<JsSsgGeneratedHtmlPage>
498
+ /** Extracted shared assets. */
499
+ assets: Array<JsSsgSharedAsset>
500
+ }
501
+
502
+ /** Generated SSG HTML page for shared asset extraction. */
503
+ export interface JsSsgGeneratedHtmlPage {
504
+ /** Source Markdown path. */
505
+ inputPath: string
506
+ /** Output HTML path. */
507
+ outputPath: string
508
+ /** HTML content. */
509
+ html: string
510
+ }
511
+
383
512
  /** Navigation group for SSG. */
384
513
  export interface JsSsgNavGroup {
385
514
  /** Group title. */
@@ -419,6 +548,42 @@ export interface JsSsgPageData {
419
548
  entryPage?: JsEntryPageConfig
420
549
  }
421
550
 
551
+ /** Resolved SSG output and public route paths. */
552
+ export interface JsSsgRoutePaths {
553
+ /** HTML output file path. */
554
+ outputPath: string
555
+ /** Route path without extension. */
556
+ urlPath: string
557
+ /** Public HTML href. */
558
+ href: string
559
+ /** OG image output file path. */
560
+ ogImagePath: string
561
+ /** OG image public URL. */
562
+ ogImageUrl: string
563
+ }
564
+
565
+ /** Shared SSG asset extracted from generated pages. */
566
+ export interface JsSsgSharedAsset {
567
+ /** Output file path. */
568
+ outputPath: string
569
+ /** Public URL path used from HTML. */
570
+ publicPath: string
571
+ /** Asset content. */
572
+ content: string
573
+ }
574
+
575
+ /** Theme sidebar item for SSG navigation generation. */
576
+ export interface JsSsgSidebarItem {
577
+ /** Display text. */
578
+ text?: string
579
+ /** Link URL or route path. */
580
+ link?: string
581
+ /** Child sidebar items. */
582
+ items?: Array<JsSsgSidebarItem>
583
+ /** Whether this group is collapsed by default. */
584
+ collapsed?: boolean
585
+ }
586
+
422
587
  /** Theme colors for JavaScript. */
423
588
  export interface JsThemeColors {
424
589
  /** Primary accent color. */
@@ -589,6 +754,9 @@ export declare function loadDictionaries(dir: string): I18NLoadResult
589
754
  */
590
755
  export declare function loadDictionariesFlat(dir: string): Record<string, Record<string, string>>
591
756
 
757
+ /** Returns true when a document belongs to at least one requested search scope. */
758
+ export declare function matchesSearchScopes(id: string, url: string, scopes: Array<string>): boolean
759
+
592
760
  /** Restores code block metadata after JavaScript-side syntax highlighting. */
593
761
  export declare function mergeHighlightedCodeBlocks(originalHtml: string, highlightedHtml: string): string
594
762
 
@@ -631,6 +799,9 @@ export interface ParseResult {
631
799
  errors: Array<string>
632
800
  }
633
801
 
802
+ /** Splits a search query into free-text terms and `@scope` prefixes. */
803
+ export declare function parseScopedSearchQuery(query: string): JsScopedSearchQuery
804
+
634
805
  /** Renders an AST (provided as JSON) to HTML. */
635
806
  export declare function render(astJson: string): RenderResult
636
807
 
@@ -642,6 +813,9 @@ export interface RenderResult {
642
813
  errors: Array<string>
643
814
  }
644
815
 
816
+ /** Resolves all output and public route paths for an SSG page. */
817
+ export declare function resolveSsgRoutePaths(inputPath: string, srcDir: string, outDir: string, base: string, extension: string, siteUrl?: string | undefined | null): JsSsgRoutePaths
818
+
645
819
  /**
646
820
  * Searches a serialized index.
647
821
  *
package/index.js CHANGED
@@ -79,14 +79,32 @@ module.exports.transform = binding.transform;
79
79
  module.exports.transformAsync = binding.transformAsync;
80
80
  module.exports.version = binding.version;
81
81
  module.exports.extractFileDocs = binding.extractFileDocs;
82
+ module.exports.extractFileDocEntries = binding.extractFileDocEntries;
83
+ module.exports.generateDocsNavMetadata = binding.generateDocsNavMetadata;
84
+ module.exports.generateDocsNavCode = binding.generateDocsNavCode;
82
85
  module.exports.generateOgImageSvg = binding.generateOgImageSvg;
83
86
  module.exports.buildSearchIndex = binding.buildSearchIndex;
84
87
  module.exports.searchIndex = binding.searchIndex;
85
88
  module.exports.extractSearchContent = binding.extractSearchContent;
89
+ module.exports.parseScopedSearchQuery = binding.parseScopedSearchQuery;
90
+ module.exports.getSearchDocumentScopes = binding.getSearchDocumentScopes;
91
+ module.exports.matchesSearchScopes = binding.matchesSearchScopes;
92
+ module.exports.generateSearchModule = binding.generateSearchModule;
86
93
  module.exports.generateSsgHtml = binding.generateSsgHtml;
94
+ module.exports.resolveSsgRoutePaths = binding.resolveSsgRoutePaths;
95
+ module.exports.getSsgOutputPath = binding.getSsgOutputPath;
96
+ module.exports.getSsgUrlPath = binding.getSsgUrlPath;
97
+ module.exports.getSsgHref = binding.getSsgHref;
98
+ module.exports.getSsgPageLocale = binding.getSsgPageLocale;
99
+ module.exports.extractSsgTitle = binding.extractSsgTitle;
100
+ module.exports.formatSsgTitle = binding.formatSsgTitle;
101
+ module.exports.buildSsgNavItems = binding.buildSsgNavItems;
102
+ module.exports.buildSsgThemeNavItems = binding.buildSsgThemeNavItems;
103
+ module.exports.externalizeSsgAssets = binding.externalizeSsgAssets;
87
104
  module.exports.transformMermaid = binding.transformMermaid;
88
105
  module.exports.loadDictionaries = binding.loadDictionaries;
89
106
  module.exports.loadDictionariesFlat = binding.loadDictionariesFlat;
107
+ module.exports.generateI18nModule = binding.generateI18nModule;
90
108
  module.exports.validateMf2 = binding.validateMf2;
91
109
  module.exports.checkI18n = binding.checkI18n;
92
110
  module.exports.extractTranslationKeys = binding.extractTranslationKeys;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/napi",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "Node.js bindings for Ox Content - High-performance Markdown parser",
5
5
  "keywords": [
6
6
  "markdown",
@@ -45,10 +45,10 @@
45
45
  ]
46
46
  },
47
47
  "optionalDependencies": {
48
- "@ox-content/binding-darwin-x64": "2.8.0",
49
- "@ox-content/binding-darwin-arm64": "2.8.0",
50
- "@ox-content/binding-linux-x64-gnu": "2.8.0",
51
- "@ox-content/binding-linux-arm64-gnu": "2.8.0",
52
- "@ox-content/binding-win32-x64-msvc": "2.8.0"
48
+ "@ox-content/binding-darwin-x64": "2.9.0",
49
+ "@ox-content/binding-darwin-arm64": "2.9.0",
50
+ "@ox-content/binding-linux-x64-gnu": "2.9.0",
51
+ "@ox-content/binding-linux-arm64-gnu": "2.9.0",
52
+ "@ox-content/binding-win32-x64-msvc": "2.9.0"
53
53
  }
54
54
  }