@ox-content/napi 1.0.0-alpha.0 → 1.1.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/index.d.ts +220 -171
- package/index.js +41 -41
- package/package.json +33 -33
package/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Takes an array of documents and returns a serialized search index as JSON.
|
|
7
7
|
*/
|
|
8
|
-
export declare function buildSearchIndex(documents: Array<JsSearchDocument>): string
|
|
8
|
+
export declare function buildSearchIndex(documents: Array<JsSearchDocument>): string;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Runs i18n checks on dictionaries against used translation keys.
|
|
@@ -13,21 +13,30 @@ export declare function buildSearchIndex(documents: Array<JsSearchDocument>): st
|
|
|
13
13
|
* `dict_dir` is the path to the i18n directory with locale subdirectories.
|
|
14
14
|
* `used_keys` is a list of translation keys found in source code.
|
|
15
15
|
*/
|
|
16
|
-
export declare function checkI18n(dictDir: string, usedKeys: Array<string>): I18NCheckResult
|
|
16
|
+
export declare function checkI18n(dictDir: string, usedKeys: Array<string>): I18NCheckResult;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Extracts searchable content from Markdown source.
|
|
20
20
|
*
|
|
21
21
|
* Parses the Markdown and extracts title, body text, headings, and code.
|
|
22
22
|
*/
|
|
23
|
-
export declare function extractSearchContent(
|
|
23
|
+
export declare function extractSearchContent(
|
|
24
|
+
source: string,
|
|
25
|
+
id: string,
|
|
26
|
+
url: string,
|
|
27
|
+
options?: JsParserOptions | undefined | null,
|
|
28
|
+
): JsSearchDocument;
|
|
24
29
|
|
|
25
30
|
/**
|
|
26
31
|
* Extracts translation keys from a TypeScript/JavaScript source string.
|
|
27
32
|
*
|
|
28
33
|
* Finds calls like `t('key')` and `$t('key')`.
|
|
29
34
|
*/
|
|
30
|
-
export declare function extractTranslationKeys(
|
|
35
|
+
export declare function extractTranslationKeys(
|
|
36
|
+
source: string,
|
|
37
|
+
filePath: string,
|
|
38
|
+
functionNames?: Array<string> | undefined | null,
|
|
39
|
+
): Array<I18NKeyUsage>;
|
|
31
40
|
|
|
32
41
|
/**
|
|
33
42
|
* Generates an OG image as SVG.
|
|
@@ -35,399 +44,414 @@ export declare function extractTranslationKeys(source: string, filePath: string,
|
|
|
35
44
|
* This function generates an SVG representation of an OG image
|
|
36
45
|
* that can be used for social media previews.
|
|
37
46
|
*/
|
|
38
|
-
export declare function generateOgImageSvg(
|
|
47
|
+
export declare function generateOgImageSvg(
|
|
48
|
+
data: JsOgImageData,
|
|
49
|
+
config?: JsOgImageConfig | undefined | null,
|
|
50
|
+
): string;
|
|
39
51
|
|
|
40
52
|
/** Generates SSG HTML page with navigation and search. */
|
|
41
|
-
export declare function generateSsgHtml(
|
|
53
|
+
export declare function generateSsgHtml(
|
|
54
|
+
pageData: JsSsgPageData,
|
|
55
|
+
navGroups: Array<JsSsgNavGroup>,
|
|
56
|
+
config: JsSsgConfig,
|
|
57
|
+
): string;
|
|
42
58
|
|
|
43
59
|
/** Result of i18n checking. */
|
|
44
60
|
export interface I18NCheckResult {
|
|
45
61
|
/** All diagnostics. */
|
|
46
|
-
diagnostics: Array<I18NDiagnostic
|
|
62
|
+
diagnostics: Array<I18NDiagnostic>;
|
|
47
63
|
/** Number of errors. */
|
|
48
|
-
errorCount: number
|
|
64
|
+
errorCount: number;
|
|
49
65
|
/** Number of warnings. */
|
|
50
|
-
warningCount: number
|
|
66
|
+
warningCount: number;
|
|
51
67
|
}
|
|
52
68
|
|
|
53
69
|
/** A single i18n diagnostic. */
|
|
54
70
|
export interface I18NDiagnostic {
|
|
55
71
|
/** Severity: "error", "warning", or "info". */
|
|
56
|
-
severity: string
|
|
72
|
+
severity: string;
|
|
57
73
|
/** Diagnostic message. */
|
|
58
|
-
message: string
|
|
74
|
+
message: string;
|
|
59
75
|
/** Related translation key, if any. */
|
|
60
|
-
key?: string
|
|
76
|
+
key?: string;
|
|
61
77
|
/** Related locale, if any. */
|
|
62
|
-
locale?: string
|
|
78
|
+
locale?: string;
|
|
63
79
|
}
|
|
64
80
|
|
|
65
81
|
/** A translation key usage found in source code. */
|
|
66
82
|
export interface I18NKeyUsage {
|
|
67
83
|
/** The translation key. */
|
|
68
|
-
key: string
|
|
84
|
+
key: string;
|
|
69
85
|
/** Source file path. */
|
|
70
|
-
filePath: string
|
|
86
|
+
filePath: string;
|
|
71
87
|
/** Line number. */
|
|
72
|
-
line: number
|
|
88
|
+
line: number;
|
|
73
89
|
/** Column number. */
|
|
74
|
-
column: number
|
|
90
|
+
column: number;
|
|
75
91
|
/** End column number. */
|
|
76
|
-
endColumn: number
|
|
92
|
+
endColumn: number;
|
|
77
93
|
}
|
|
78
94
|
|
|
79
95
|
/** Result of loading dictionaries. */
|
|
80
96
|
export interface I18NLoadResult {
|
|
81
97
|
/** Number of locales loaded. */
|
|
82
|
-
localeCount: number
|
|
98
|
+
localeCount: number;
|
|
83
99
|
/** All locale tags. */
|
|
84
|
-
locales: Array<string
|
|
100
|
+
locales: Array<string>;
|
|
85
101
|
/** Errors encountered during loading. */
|
|
86
|
-
errors: Array<string
|
|
102
|
+
errors: Array<string>;
|
|
87
103
|
}
|
|
88
104
|
|
|
89
105
|
/** Entry page configuration. */
|
|
90
106
|
export interface JsEntryPageConfig {
|
|
91
107
|
/** Hero section. */
|
|
92
|
-
hero?: JsHeroConfig
|
|
108
|
+
hero?: JsHeroConfig;
|
|
93
109
|
/** Feature cards. */
|
|
94
|
-
features?: Array<JsFeatureConfig
|
|
110
|
+
features?: Array<JsFeatureConfig>;
|
|
95
111
|
}
|
|
96
112
|
|
|
97
113
|
/** Feature card for entry page. */
|
|
98
114
|
export interface JsFeatureConfig {
|
|
99
115
|
/** Icon - supports: "mdi:icon-name" (Iconify), image URL, or emoji. */
|
|
100
|
-
icon?: string
|
|
116
|
+
icon?: string;
|
|
101
117
|
/** Feature title. */
|
|
102
|
-
title: string
|
|
118
|
+
title: string;
|
|
103
119
|
/** Feature description. */
|
|
104
|
-
details?: string
|
|
120
|
+
details?: string;
|
|
105
121
|
/** Optional link. */
|
|
106
|
-
link?: string
|
|
122
|
+
link?: string;
|
|
107
123
|
/** Link text. */
|
|
108
|
-
linkText?: string
|
|
124
|
+
linkText?: string;
|
|
109
125
|
}
|
|
110
126
|
|
|
111
127
|
/** Hero action for entry page. */
|
|
112
128
|
export interface JsHeroAction {
|
|
113
129
|
/** Button theme: "brand" or "alt". */
|
|
114
|
-
theme?: string
|
|
130
|
+
theme?: string;
|
|
115
131
|
/** Button text. */
|
|
116
|
-
text: string
|
|
132
|
+
text: string;
|
|
117
133
|
/** Link URL. */
|
|
118
|
-
link: string
|
|
134
|
+
link: string;
|
|
119
135
|
}
|
|
120
136
|
|
|
121
137
|
/** Hero section configuration for entry page. */
|
|
122
138
|
export interface JsHeroConfig {
|
|
123
139
|
/** Main title (large, gradient text). */
|
|
124
|
-
name?: string
|
|
140
|
+
name?: string;
|
|
125
141
|
/** Secondary text. */
|
|
126
|
-
text?: string
|
|
142
|
+
text?: string;
|
|
127
143
|
/** Tagline. */
|
|
128
|
-
tagline?: string
|
|
144
|
+
tagline?: string;
|
|
129
145
|
/** Hero image. */
|
|
130
|
-
image?: JsHeroImage
|
|
146
|
+
image?: JsHeroImage;
|
|
131
147
|
/** Action buttons. */
|
|
132
|
-
actions?: Array<JsHeroAction
|
|
148
|
+
actions?: Array<JsHeroAction>;
|
|
133
149
|
}
|
|
134
150
|
|
|
135
151
|
/** Hero image for entry page. */
|
|
136
152
|
export interface JsHeroImage {
|
|
137
153
|
/** Image source URL. */
|
|
138
|
-
src: string
|
|
154
|
+
src: string;
|
|
139
155
|
/** Alt text. */
|
|
140
|
-
alt?: string
|
|
156
|
+
alt?: string;
|
|
141
157
|
/** Image width. */
|
|
142
|
-
width?: number
|
|
158
|
+
width?: number;
|
|
143
159
|
/** Image height. */
|
|
144
|
-
height?: number
|
|
160
|
+
height?: number;
|
|
145
161
|
}
|
|
146
162
|
|
|
147
163
|
/** Locale information for the locale switcher. */
|
|
148
164
|
export interface JsLocaleInfo {
|
|
149
165
|
/** BCP 47 locale tag. */
|
|
150
|
-
code: string
|
|
166
|
+
code: string;
|
|
151
167
|
/** Display name. */
|
|
152
|
-
name: string
|
|
168
|
+
name: string;
|
|
153
169
|
/** Text direction. */
|
|
154
|
-
dir: string
|
|
170
|
+
dir: string;
|
|
155
171
|
}
|
|
156
172
|
|
|
157
173
|
/** OG image configuration for JavaScript. */
|
|
158
174
|
export interface JsOgImageConfig {
|
|
159
175
|
/** Image width in pixels. */
|
|
160
|
-
width?: number
|
|
176
|
+
width?: number;
|
|
161
177
|
/** Image height in pixels. */
|
|
162
|
-
height?: number
|
|
178
|
+
height?: number;
|
|
163
179
|
/** Background color (hex). */
|
|
164
|
-
backgroundColor?: string
|
|
180
|
+
backgroundColor?: string;
|
|
165
181
|
/** Text color (hex). */
|
|
166
|
-
textColor?: string
|
|
182
|
+
textColor?: string;
|
|
167
183
|
/** Title font size. */
|
|
168
|
-
titleFontSize?: number
|
|
184
|
+
titleFontSize?: number;
|
|
169
185
|
/** Description font size. */
|
|
170
|
-
descriptionFontSize?: number
|
|
186
|
+
descriptionFontSize?: number;
|
|
171
187
|
}
|
|
172
188
|
|
|
173
189
|
/** OG image data for JavaScript. */
|
|
174
190
|
export interface JsOgImageData {
|
|
175
191
|
/** Page title. */
|
|
176
|
-
title: string
|
|
192
|
+
title: string;
|
|
177
193
|
/** Page description. */
|
|
178
|
-
description?: string
|
|
194
|
+
description?: string;
|
|
179
195
|
/** Site name. */
|
|
180
|
-
siteName?: string
|
|
196
|
+
siteName?: string;
|
|
181
197
|
/** Author name. */
|
|
182
|
-
author?: string
|
|
198
|
+
author?: string;
|
|
183
199
|
}
|
|
184
200
|
|
|
185
201
|
/** Parser options for JavaScript. */
|
|
186
202
|
export interface JsParserOptions {
|
|
187
203
|
/** Enable GFM extensions. */
|
|
188
|
-
gfm?: boolean
|
|
204
|
+
gfm?: boolean;
|
|
189
205
|
/** Enable footnotes. */
|
|
190
|
-
footnotes?: boolean
|
|
206
|
+
footnotes?: boolean;
|
|
191
207
|
/** Enable task lists. */
|
|
192
|
-
taskLists?: boolean
|
|
208
|
+
taskLists?: boolean;
|
|
193
209
|
/** Enable tables. */
|
|
194
|
-
tables?: boolean
|
|
210
|
+
tables?: boolean;
|
|
195
211
|
/** Enable strikethrough. */
|
|
196
|
-
strikethrough?: boolean
|
|
212
|
+
strikethrough?: boolean;
|
|
197
213
|
/** Enable autolinks. */
|
|
198
|
-
autolinks?: boolean
|
|
214
|
+
autolinks?: boolean;
|
|
199
215
|
}
|
|
200
216
|
|
|
201
217
|
/** Search document for JavaScript. */
|
|
202
218
|
export interface JsSearchDocument {
|
|
203
219
|
/** Unique document identifier. */
|
|
204
|
-
id: string
|
|
220
|
+
id: string;
|
|
205
221
|
/** Document title. */
|
|
206
|
-
title: string
|
|
222
|
+
title: string;
|
|
207
223
|
/** Document URL. */
|
|
208
|
-
url: string
|
|
224
|
+
url: string;
|
|
209
225
|
/** Document body text. */
|
|
210
|
-
body: string
|
|
226
|
+
body: string;
|
|
211
227
|
/** Document headings. */
|
|
212
|
-
headings: Array<string
|
|
228
|
+
headings: Array<string>;
|
|
213
229
|
/** Code snippets. */
|
|
214
|
-
code: Array<string
|
|
230
|
+
code: Array<string>;
|
|
215
231
|
}
|
|
216
232
|
|
|
217
233
|
/** Search options for JavaScript. */
|
|
218
234
|
export interface JsSearchOptions {
|
|
219
235
|
/** Maximum number of results. */
|
|
220
|
-
limit?: number
|
|
236
|
+
limit?: number;
|
|
221
237
|
/** Enable prefix matching. */
|
|
222
|
-
prefix?: boolean
|
|
238
|
+
prefix?: boolean;
|
|
223
239
|
/** Enable fuzzy matching. */
|
|
224
|
-
fuzzy?: boolean
|
|
240
|
+
fuzzy?: boolean;
|
|
225
241
|
/** Minimum score threshold. */
|
|
226
|
-
threshold?: number
|
|
242
|
+
threshold?: number;
|
|
227
243
|
}
|
|
228
244
|
|
|
229
245
|
/** Search result for JavaScript. */
|
|
230
246
|
export interface JsSearchResult {
|
|
231
247
|
/** Document ID. */
|
|
232
|
-
id: string
|
|
248
|
+
id: string;
|
|
233
249
|
/** Document title. */
|
|
234
|
-
title: string
|
|
250
|
+
title: string;
|
|
235
251
|
/** Document URL. */
|
|
236
|
-
url: string
|
|
252
|
+
url: string;
|
|
237
253
|
/** Relevance score. */
|
|
238
|
-
score: number
|
|
254
|
+
score: number;
|
|
239
255
|
/** Matched terms. */
|
|
240
|
-
matches: Array<string
|
|
256
|
+
matches: Array<string>;
|
|
241
257
|
/** Content snippet. */
|
|
242
|
-
snippet: string
|
|
258
|
+
snippet: string;
|
|
243
259
|
}
|
|
244
260
|
|
|
245
261
|
/** Social links for JavaScript. */
|
|
246
262
|
export interface JsSocialLinks {
|
|
247
263
|
/** GitHub URL. */
|
|
248
|
-
github?: string
|
|
264
|
+
github?: string;
|
|
249
265
|
/** Twitter/X URL. */
|
|
250
|
-
twitter?: string
|
|
266
|
+
twitter?: string;
|
|
251
267
|
/** Discord URL. */
|
|
252
|
-
discord?: string
|
|
268
|
+
discord?: string;
|
|
253
269
|
}
|
|
254
270
|
|
|
255
271
|
/** SSG configuration. */
|
|
256
272
|
export interface JsSsgConfig {
|
|
257
273
|
/** Site name. */
|
|
258
|
-
siteName: string
|
|
274
|
+
siteName: string;
|
|
259
275
|
/** Base URL path. */
|
|
260
|
-
base: string
|
|
276
|
+
base: string;
|
|
261
277
|
/** OG image URL. */
|
|
262
|
-
ogImage?: string
|
|
278
|
+
ogImage?: string;
|
|
263
279
|
/** Theme configuration. */
|
|
264
|
-
theme?: JsThemeConfig
|
|
280
|
+
theme?: JsThemeConfig;
|
|
265
281
|
/** Current locale for this page. */
|
|
266
|
-
locale?: string
|
|
282
|
+
locale?: string;
|
|
267
283
|
/** Available locales for locale switcher. */
|
|
268
|
-
availableLocales?: Array<JsLocaleInfo
|
|
284
|
+
availableLocales?: Array<JsLocaleInfo>;
|
|
269
285
|
}
|
|
270
286
|
|
|
271
287
|
/** Navigation group for SSG. */
|
|
272
288
|
export interface JsSsgNavGroup {
|
|
273
289
|
/** Group title. */
|
|
274
|
-
title: string
|
|
290
|
+
title: string;
|
|
275
291
|
/** Navigation items. */
|
|
276
|
-
items: Array<JsSsgNavItem
|
|
292
|
+
items: Array<JsSsgNavItem>;
|
|
277
293
|
}
|
|
278
294
|
|
|
279
295
|
/** Navigation item for SSG. */
|
|
280
296
|
export interface JsSsgNavItem {
|
|
281
297
|
/** Display title. */
|
|
282
|
-
title: string
|
|
298
|
+
title: string;
|
|
283
299
|
/** URL path. */
|
|
284
|
-
path: string
|
|
300
|
+
path: string;
|
|
285
301
|
/** Full href. */
|
|
286
|
-
href: string
|
|
302
|
+
href: string;
|
|
287
303
|
}
|
|
288
304
|
|
|
289
305
|
/** Page data for SSG. */
|
|
290
306
|
export interface JsSsgPageData {
|
|
291
307
|
/** Page title. */
|
|
292
|
-
title: string
|
|
308
|
+
title: string;
|
|
293
309
|
/** Page description. */
|
|
294
|
-
description?: string
|
|
310
|
+
description?: string;
|
|
295
311
|
/** Page content HTML. */
|
|
296
|
-
content: string
|
|
312
|
+
content: string;
|
|
297
313
|
/** Table of contents entries. */
|
|
298
|
-
toc: Array<TocEntry
|
|
314
|
+
toc: Array<TocEntry>;
|
|
299
315
|
/** URL path. */
|
|
300
|
-
path: string
|
|
316
|
+
path: string;
|
|
301
317
|
/** Entry page configuration (if layout: entry). */
|
|
302
|
-
entryPage?: JsEntryPageConfig
|
|
318
|
+
entryPage?: JsEntryPageConfig;
|
|
303
319
|
}
|
|
304
320
|
|
|
305
321
|
/** Theme colors for JavaScript. */
|
|
306
322
|
export interface JsThemeColors {
|
|
307
323
|
/** Primary accent color. */
|
|
308
|
-
primary?: string
|
|
324
|
+
primary?: string;
|
|
309
325
|
/** Primary color on hover. */
|
|
310
|
-
primaryHover?: string
|
|
326
|
+
primaryHover?: string;
|
|
311
327
|
/** Background color. */
|
|
312
|
-
background?: string
|
|
328
|
+
background?: string;
|
|
313
329
|
/** Alternative background color. */
|
|
314
|
-
backgroundAlt?: string
|
|
330
|
+
backgroundAlt?: string;
|
|
315
331
|
/** Main text color. */
|
|
316
|
-
text?: string
|
|
332
|
+
text?: string;
|
|
317
333
|
/** Muted text color. */
|
|
318
|
-
textMuted?: string
|
|
334
|
+
textMuted?: string;
|
|
319
335
|
/** Border color. */
|
|
320
|
-
border?: string
|
|
336
|
+
border?: string;
|
|
321
337
|
/** Code block background color. */
|
|
322
|
-
codeBackground?: string
|
|
338
|
+
codeBackground?: string;
|
|
323
339
|
/** Code block text color. */
|
|
324
|
-
codeText?: string
|
|
340
|
+
codeText?: string;
|
|
325
341
|
}
|
|
326
342
|
|
|
327
343
|
/** Theme configuration for JavaScript. */
|
|
328
344
|
export interface JsThemeConfig {
|
|
329
345
|
/** Light mode colors. */
|
|
330
|
-
colors?: JsThemeColors
|
|
346
|
+
colors?: JsThemeColors;
|
|
331
347
|
/** Dark mode colors. */
|
|
332
|
-
darkColors?: JsThemeColors
|
|
348
|
+
darkColors?: JsThemeColors;
|
|
333
349
|
/** Font configuration. */
|
|
334
|
-
fonts?: JsThemeFonts
|
|
350
|
+
fonts?: JsThemeFonts;
|
|
335
351
|
/** Layout configuration. */
|
|
336
|
-
layout?: JsThemeLayout
|
|
352
|
+
layout?: JsThemeLayout;
|
|
337
353
|
/** Header configuration. */
|
|
338
|
-
header?: JsThemeHeader
|
|
354
|
+
header?: JsThemeHeader;
|
|
339
355
|
/** Footer configuration. */
|
|
340
|
-
footer?: JsThemeFooter
|
|
356
|
+
footer?: JsThemeFooter;
|
|
341
357
|
/** Social links configuration. */
|
|
342
|
-
socialLinks?: JsSocialLinks
|
|
358
|
+
socialLinks?: JsSocialLinks;
|
|
343
359
|
/** Embedded HTML content at specific positions. */
|
|
344
|
-
embed?: JsThemeEmbed
|
|
360
|
+
embed?: JsThemeEmbed;
|
|
345
361
|
/** Additional custom CSS. */
|
|
346
|
-
css?: string
|
|
362
|
+
css?: string;
|
|
347
363
|
/** Additional custom JavaScript. */
|
|
348
|
-
js?: string
|
|
364
|
+
js?: string;
|
|
349
365
|
}
|
|
350
366
|
|
|
351
367
|
/** Embedded HTML content for specific positions. */
|
|
352
368
|
export interface JsThemeEmbed {
|
|
353
369
|
/** Content to embed into `<head>`. */
|
|
354
|
-
head?: string
|
|
370
|
+
head?: string;
|
|
355
371
|
/** Content before header. */
|
|
356
|
-
headerBefore?: string
|
|
372
|
+
headerBefore?: string;
|
|
357
373
|
/** Content after header. */
|
|
358
|
-
headerAfter?: string
|
|
374
|
+
headerAfter?: string;
|
|
359
375
|
/** Content before sidebar navigation. */
|
|
360
|
-
sidebarBefore?: string
|
|
376
|
+
sidebarBefore?: string;
|
|
361
377
|
/** Content after sidebar navigation. */
|
|
362
|
-
sidebarAfter?: string
|
|
378
|
+
sidebarAfter?: string;
|
|
363
379
|
/** Content before main content. */
|
|
364
|
-
contentBefore?: string
|
|
380
|
+
contentBefore?: string;
|
|
365
381
|
/** Content after main content. */
|
|
366
|
-
contentAfter?: string
|
|
382
|
+
contentAfter?: string;
|
|
367
383
|
/** Content before footer. */
|
|
368
|
-
footerBefore?: string
|
|
384
|
+
footerBefore?: string;
|
|
369
385
|
/** Custom footer content. */
|
|
370
|
-
footer?: string
|
|
386
|
+
footer?: string;
|
|
371
387
|
}
|
|
372
388
|
|
|
373
389
|
/** Theme fonts for JavaScript. */
|
|
374
390
|
export interface JsThemeFonts {
|
|
375
391
|
/** Sans-serif font stack. */
|
|
376
|
-
sans?: string
|
|
392
|
+
sans?: string;
|
|
377
393
|
/** Monospace font stack. */
|
|
378
|
-
mono?: string
|
|
394
|
+
mono?: string;
|
|
379
395
|
}
|
|
380
396
|
|
|
381
397
|
/** Theme footer for JavaScript. */
|
|
382
398
|
export interface JsThemeFooter {
|
|
383
399
|
/** Footer message (supports HTML). */
|
|
384
|
-
message?: string
|
|
400
|
+
message?: string;
|
|
385
401
|
/** Copyright text (supports HTML). */
|
|
386
|
-
copyright?: string
|
|
402
|
+
copyright?: string;
|
|
387
403
|
}
|
|
388
404
|
|
|
389
405
|
/** Theme header for JavaScript. */
|
|
390
406
|
export interface JsThemeHeader {
|
|
391
407
|
/** Logo image URL. */
|
|
392
|
-
logo?: string
|
|
408
|
+
logo?: string;
|
|
393
409
|
/** Logo width in pixels. */
|
|
394
|
-
logoWidth?: number
|
|
410
|
+
logoWidth?: number;
|
|
395
411
|
/** Logo height in pixels. */
|
|
396
|
-
logoHeight?: number
|
|
412
|
+
logoHeight?: number;
|
|
397
413
|
}
|
|
398
414
|
|
|
399
415
|
/** Theme layout for JavaScript. */
|
|
400
416
|
export interface JsThemeLayout {
|
|
401
417
|
/** Sidebar width (CSS value). */
|
|
402
|
-
sidebarWidth?: string
|
|
418
|
+
sidebarWidth?: string;
|
|
403
419
|
/** Header height (CSS value). */
|
|
404
|
-
headerHeight?: string
|
|
420
|
+
headerHeight?: string;
|
|
405
421
|
/** Maximum content width (CSS value). */
|
|
406
|
-
maxContentWidth?: string
|
|
422
|
+
maxContentWidth?: string;
|
|
407
423
|
}
|
|
408
424
|
|
|
409
425
|
/** Transform options for JavaScript. */
|
|
410
426
|
export interface JsTransformOptions {
|
|
411
427
|
/** Enable GFM extensions. */
|
|
412
|
-
gfm?: boolean
|
|
428
|
+
gfm?: boolean;
|
|
413
429
|
/** Enable footnotes. */
|
|
414
|
-
footnotes?: boolean
|
|
430
|
+
footnotes?: boolean;
|
|
415
431
|
/** Enable task lists. */
|
|
416
|
-
taskLists?: boolean
|
|
432
|
+
taskLists?: boolean;
|
|
417
433
|
/** Enable tables. */
|
|
418
|
-
tables?: boolean
|
|
434
|
+
tables?: boolean;
|
|
419
435
|
/** Enable strikethrough. */
|
|
420
|
-
strikethrough?: boolean
|
|
436
|
+
strikethrough?: boolean;
|
|
421
437
|
/** Enable autolinks. */
|
|
422
|
-
autolinks?: boolean
|
|
438
|
+
autolinks?: boolean;
|
|
423
439
|
/** Maximum TOC depth (1-6). */
|
|
424
|
-
tocMaxDepth?: number
|
|
440
|
+
tocMaxDepth?: number;
|
|
425
441
|
/** Convert `.md` links to `.html` links for SSG output. */
|
|
426
|
-
convertMdLinks?: boolean
|
|
442
|
+
convertMdLinks?: boolean;
|
|
427
443
|
/** Base URL for absolute link conversion (e.g., "/" or "/docs/"). */
|
|
428
|
-
baseUrl?: string
|
|
444
|
+
baseUrl?: string;
|
|
429
445
|
/** Source file path for relative link resolution. */
|
|
430
|
-
sourcePath?: string
|
|
446
|
+
sourcePath?: string;
|
|
447
|
+
/** Enable line annotations for code blocks using fence meta. */
|
|
448
|
+
codeAnnotations?: boolean;
|
|
449
|
+
/** Fence meta key used to read code annotations. */
|
|
450
|
+
codeAnnotationMetaKey?: string;
|
|
451
|
+
/** Code annotation syntax mode. */
|
|
452
|
+
codeAnnotationSyntax?: string;
|
|
453
|
+
/** Enable line numbers for all code blocks by default. */
|
|
454
|
+
codeAnnotationDefaultLineNumbers?: boolean;
|
|
431
455
|
}
|
|
432
456
|
|
|
433
457
|
/**
|
|
@@ -436,7 +460,7 @@ export interface JsTransformOptions {
|
|
|
436
460
|
* The directory should contain locale subdirectories (e.g., `en/`, `ja/`)
|
|
437
461
|
* with JSON or YAML translation files.
|
|
438
462
|
*/
|
|
439
|
-
export declare function loadDictionaries(dir: string): I18NLoadResult
|
|
463
|
+
export declare function loadDictionaries(dir: string): I18NLoadResult;
|
|
440
464
|
|
|
441
465
|
/**
|
|
442
466
|
* Loads dictionaries from the given directory and returns a flat key-value map per locale.
|
|
@@ -444,24 +468,30 @@ export declare function loadDictionaries(dir: string): I18NLoadResult
|
|
|
444
468
|
* Each locale maps to a flat `{ "namespace.key": "value" }` structure.
|
|
445
469
|
* Supports both JSON and YAML dictionary files.
|
|
446
470
|
*/
|
|
447
|
-
export declare function loadDictionariesFlat(dir: string): Record<string, Record<string, string
|
|
471
|
+
export declare function loadDictionariesFlat(dir: string): Record<string, Record<string, string>>;
|
|
472
|
+
|
|
473
|
+
/** Restores code block metadata after JavaScript-side syntax highlighting. */
|
|
474
|
+
export declare function mergeHighlightedCodeBlocks(
|
|
475
|
+
originalHtml: string,
|
|
476
|
+
highlightedHtml: string,
|
|
477
|
+
): string;
|
|
448
478
|
|
|
449
479
|
/** Mermaid transform result. */
|
|
450
480
|
export interface MermaidTransformResult {
|
|
451
481
|
/** The transformed HTML with mermaid code blocks replaced by rendered SVGs. */
|
|
452
|
-
html: string
|
|
482
|
+
html: string;
|
|
453
483
|
/** Non-fatal errors encountered during rendering (per-diagram). */
|
|
454
|
-
errors: Array<string
|
|
484
|
+
errors: Array<string>;
|
|
455
485
|
}
|
|
456
486
|
|
|
457
487
|
/** Result of MF2 validation. */
|
|
458
488
|
export interface Mf2ValidateResult {
|
|
459
489
|
/** Whether the message is valid. */
|
|
460
|
-
valid: boolean
|
|
490
|
+
valid: boolean;
|
|
461
491
|
/** Validation errors. */
|
|
462
|
-
errors: Array<string
|
|
492
|
+
errors: Array<string>;
|
|
463
493
|
/** AST as JSON (if parsing succeeded). */
|
|
464
|
-
astJson?: string
|
|
494
|
+
astJson?: string;
|
|
465
495
|
}
|
|
466
496
|
|
|
467
497
|
/**
|
|
@@ -469,31 +499,40 @@ export interface Mf2ValidateResult {
|
|
|
469
499
|
*
|
|
470
500
|
* Returns the AST as a JSON string for zero-copy transfer to JavaScript.
|
|
471
501
|
*/
|
|
472
|
-
export declare function parse(
|
|
502
|
+
export declare function parse(
|
|
503
|
+
source: string,
|
|
504
|
+
options?: JsParserOptions | undefined | null,
|
|
505
|
+
): ParseResult;
|
|
473
506
|
|
|
474
507
|
/** Parses Markdown and renders to HTML. */
|
|
475
|
-
export declare function parseAndRender(
|
|
508
|
+
export declare function parseAndRender(
|
|
509
|
+
source: string,
|
|
510
|
+
options?: JsParserOptions | undefined | null,
|
|
511
|
+
): RenderResult;
|
|
476
512
|
|
|
477
513
|
/** Parses Markdown and renders to HTML asynchronously (runs on worker thread). */
|
|
478
|
-
export declare function parseAndRenderAsync(
|
|
514
|
+
export declare function parseAndRenderAsync(
|
|
515
|
+
source: string,
|
|
516
|
+
options?: JsParserOptions | undefined | null,
|
|
517
|
+
): Promise<unknown>;
|
|
479
518
|
|
|
480
519
|
/** Parse result containing the AST as JSON. */
|
|
481
520
|
export interface ParseResult {
|
|
482
521
|
/** The AST as a JSON string. */
|
|
483
|
-
ast: string
|
|
522
|
+
ast: string;
|
|
484
523
|
/** Parse errors, if any. */
|
|
485
|
-
errors: Array<string
|
|
524
|
+
errors: Array<string>;
|
|
486
525
|
}
|
|
487
526
|
|
|
488
527
|
/** Renders an AST (provided as JSON) to HTML. */
|
|
489
|
-
export declare function render(astJson: string): RenderResult
|
|
528
|
+
export declare function render(astJson: string): RenderResult;
|
|
490
529
|
|
|
491
530
|
/** Render result containing the HTML output. */
|
|
492
531
|
export interface RenderResult {
|
|
493
532
|
/** The rendered HTML. */
|
|
494
|
-
html: string
|
|
533
|
+
html: string;
|
|
495
534
|
/** Render errors, if any. */
|
|
496
|
-
errors: Array<string
|
|
535
|
+
errors: Array<string>;
|
|
497
536
|
}
|
|
498
537
|
|
|
499
538
|
/**
|
|
@@ -502,16 +541,20 @@ export interface RenderResult {
|
|
|
502
541
|
* Takes a JSON-serialized index, query string, and options.
|
|
503
542
|
* Returns an array of search results.
|
|
504
543
|
*/
|
|
505
|
-
export declare function searchIndex(
|
|
544
|
+
export declare function searchIndex(
|
|
545
|
+
indexJson: string,
|
|
546
|
+
query: string,
|
|
547
|
+
options?: JsSearchOptions | undefined | null,
|
|
548
|
+
): Array<JsSearchResult>;
|
|
506
549
|
|
|
507
550
|
/** Table of contents entry. */
|
|
508
551
|
export interface TocEntry {
|
|
509
552
|
/** Heading depth (1-6). */
|
|
510
|
-
depth: number
|
|
553
|
+
depth: number;
|
|
511
554
|
/** Heading text. */
|
|
512
|
-
text: string
|
|
555
|
+
text: string;
|
|
513
556
|
/** URL-friendly slug. */
|
|
514
|
-
slug: string
|
|
557
|
+
slug: string;
|
|
515
558
|
}
|
|
516
559
|
|
|
517
560
|
/**
|
|
@@ -519,10 +562,16 @@ export interface TocEntry {
|
|
|
519
562
|
*
|
|
520
563
|
* This is the main entry point for @ox-content/unplugin.
|
|
521
564
|
*/
|
|
522
|
-
export declare function transform(
|
|
565
|
+
export declare function transform(
|
|
566
|
+
source: string,
|
|
567
|
+
options?: JsTransformOptions | undefined | null,
|
|
568
|
+
): TransformResult;
|
|
523
569
|
|
|
524
570
|
/** Transforms Markdown source asynchronously (runs on worker thread). */
|
|
525
|
-
export declare function transformAsync(
|
|
571
|
+
export declare function transformAsync(
|
|
572
|
+
source: string,
|
|
573
|
+
options?: JsTransformOptions | undefined | null,
|
|
574
|
+
): Promise<unknown>;
|
|
526
575
|
|
|
527
576
|
/**
|
|
528
577
|
* Transforms mermaid code blocks in HTML to rendered SVG diagrams.
|
|
@@ -531,18 +580,18 @@ export declare function transformAsync(source: string, options?: JsTransformOpti
|
|
|
531
580
|
* renders each in parallel using the mmdc CLI, and replaces them with
|
|
532
581
|
* `<div class="ox-mermaid">...</div>`.
|
|
533
582
|
*/
|
|
534
|
-
export declare function transformMermaid(html: string, mmdcPath: string): MermaidTransformResult
|
|
583
|
+
export declare function transformMermaid(html: string, mmdcPath: string): MermaidTransformResult;
|
|
535
584
|
|
|
536
585
|
/** Transform result containing HTML, frontmatter, and TOC. */
|
|
537
586
|
export interface TransformResult {
|
|
538
587
|
/** The rendered HTML. */
|
|
539
|
-
html: string
|
|
588
|
+
html: string;
|
|
540
589
|
/** Parsed frontmatter as JSON string. */
|
|
541
|
-
frontmatter: string
|
|
590
|
+
frontmatter: string;
|
|
542
591
|
/** Table of contents entries. */
|
|
543
|
-
toc: Array<TocEntry
|
|
592
|
+
toc: Array<TocEntry>;
|
|
544
593
|
/** Parse/render errors, if any. */
|
|
545
|
-
errors: Array<string
|
|
594
|
+
errors: Array<string>;
|
|
546
595
|
}
|
|
547
596
|
|
|
548
597
|
/**
|
|
@@ -550,7 +599,7 @@ export interface TransformResult {
|
|
|
550
599
|
*
|
|
551
600
|
* Returns parsing and semantic validation results.
|
|
552
601
|
*/
|
|
553
|
-
export declare function validateMf2(message: string): Mf2ValidateResult
|
|
602
|
+
export declare function validateMf2(message: string): Mf2ValidateResult;
|
|
554
603
|
|
|
555
604
|
/** Returns the version of ox_content_napi. */
|
|
556
|
-
export declare function version(): string
|
|
605
|
+
export declare function version(): string;
|
package/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const { existsSync } = require("fs")
|
|
2
|
-
const path = require("path")
|
|
1
|
+
const { existsSync } = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
3
|
|
|
4
4
|
function loadBinding() {
|
|
5
5
|
// 1. Try loading the local binary (napi build output)
|
|
6
|
-
const napiOutput = path.join(__dirname, "ox-content.node")
|
|
6
|
+
const napiOutput = path.join(__dirname, "ox-content.node");
|
|
7
7
|
if (existsSync(napiOutput)) {
|
|
8
|
-
return require(napiOutput)
|
|
8
|
+
return require(napiOutput);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
// 1b. Legacy: index.node (napi-rs v2)
|
|
12
|
-
const localBinary = path.join(__dirname, "index.node")
|
|
12
|
+
const localBinary = path.join(__dirname, "index.node");
|
|
13
13
|
if (existsSync(localBinary)) {
|
|
14
|
-
return require(localBinary)
|
|
14
|
+
return require(localBinary);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// 2. Try platform-specific binary in same directory (CI build artifact)
|
|
18
|
-
const platform = process.platform
|
|
19
|
-
const arch = process.arch
|
|
18
|
+
const platform = process.platform;
|
|
19
|
+
const arch = process.arch;
|
|
20
20
|
|
|
21
21
|
const platforms = {
|
|
22
22
|
"darwin-arm64": "ox-content.darwin-arm64.node",
|
|
@@ -24,22 +24,22 @@ function loadBinding() {
|
|
|
24
24
|
"linux-x64-gnu": "ox-content.linux-x64-gnu.node",
|
|
25
25
|
"linux-arm64-gnu": "ox-content.linux-arm64-gnu.node",
|
|
26
26
|
"win32-x64-msvc": "ox-content.win32-x64-msvc.node",
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
|
|
29
|
-
let key
|
|
29
|
+
let key;
|
|
30
30
|
if (platform === "darwin") {
|
|
31
|
-
key = `darwin-${arch}
|
|
31
|
+
key = `darwin-${arch}`;
|
|
32
32
|
} else if (platform === "linux") {
|
|
33
|
-
key = `linux-${arch}-gnu
|
|
33
|
+
key = `linux-${arch}-gnu`;
|
|
34
34
|
} else if (platform === "win32") {
|
|
35
|
-
key = `win32-${arch}-msvc
|
|
35
|
+
key = `win32-${arch}-msvc`;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const binaryName = platforms[key]
|
|
38
|
+
const binaryName = platforms[key];
|
|
39
39
|
if (binaryName) {
|
|
40
|
-
const binaryPath = path.join(__dirname, binaryName)
|
|
40
|
+
const binaryPath = path.join(__dirname, binaryName);
|
|
41
41
|
if (existsSync(binaryPath)) {
|
|
42
|
-
return require(binaryPath)
|
|
42
|
+
return require(binaryPath);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -50,40 +50,40 @@ function loadBinding() {
|
|
|
50
50
|
"linux-x64-gnu": "@ox-content/binding-linux-x64-gnu",
|
|
51
51
|
"linux-arm64-gnu": "@ox-content/binding-linux-arm64-gnu",
|
|
52
52
|
"win32-x64-msvc": "@ox-content/binding-win32-x64-msvc",
|
|
53
|
-
}
|
|
53
|
+
};
|
|
54
54
|
|
|
55
|
-
const subPackage = subPackages[key]
|
|
55
|
+
const subPackage = subPackages[key];
|
|
56
56
|
if (subPackage) {
|
|
57
57
|
try {
|
|
58
|
-
return require(subPackage)
|
|
58
|
+
return require(subPackage);
|
|
59
59
|
} catch {}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
throw new Error(
|
|
63
63
|
`@ox-content/napi: No compatible binary found for ${platform}-${arch}. ` +
|
|
64
|
-
`
|
|
65
|
-
)
|
|
64
|
+
`If you're working from the repository, run 'nix develop -c vp run build:napi' from the repository root.`,
|
|
65
|
+
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const binding = loadBinding()
|
|
68
|
+
const binding = loadBinding();
|
|
69
69
|
|
|
70
70
|
// Export individual functions for ESM compatibility
|
|
71
|
-
module.exports = binding
|
|
72
|
-
module.exports.parse = binding.parse
|
|
73
|
-
module.exports.parseAndRender = binding.parseAndRender
|
|
74
|
-
module.exports.parseAndRenderAsync = binding.parseAndRenderAsync
|
|
75
|
-
module.exports.render = binding.render
|
|
76
|
-
module.exports.transform = binding.transform
|
|
77
|
-
module.exports.transformAsync = binding.transformAsync
|
|
78
|
-
module.exports.version = binding.version
|
|
79
|
-
module.exports.generateOgImageSvg = binding.generateOgImageSvg
|
|
80
|
-
module.exports.buildSearchIndex = binding.buildSearchIndex
|
|
81
|
-
module.exports.searchIndex = binding.searchIndex
|
|
82
|
-
module.exports.extractSearchContent = binding.extractSearchContent
|
|
83
|
-
module.exports.generateSsgHtml = binding.generateSsgHtml
|
|
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
|
|
71
|
+
module.exports = binding;
|
|
72
|
+
module.exports.parse = binding.parse;
|
|
73
|
+
module.exports.parseAndRender = binding.parseAndRender;
|
|
74
|
+
module.exports.parseAndRenderAsync = binding.parseAndRenderAsync;
|
|
75
|
+
module.exports.render = binding.render;
|
|
76
|
+
module.exports.transform = binding.transform;
|
|
77
|
+
module.exports.transformAsync = binding.transformAsync;
|
|
78
|
+
module.exports.version = binding.version;
|
|
79
|
+
module.exports.generateOgImageSvg = binding.generateOgImageSvg;
|
|
80
|
+
module.exports.buildSearchIndex = binding.buildSearchIndex;
|
|
81
|
+
module.exports.searchIndex = binding.searchIndex;
|
|
82
|
+
module.exports.extractSearchContent = binding.extractSearchContent;
|
|
83
|
+
module.exports.generateSsgHtml = binding.generateSsgHtml;
|
|
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,13 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ox-content/napi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Node.js bindings for Ox Content - High-performance Markdown parser",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"markdown",
|
|
7
|
+
"napi",
|
|
8
|
+
"oxc",
|
|
9
|
+
"parser",
|
|
10
|
+
"rust"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "ubugeeei",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/ubugeeei/ox-content.git",
|
|
17
|
+
"directory": "crates/ox_content_napi"
|
|
18
|
+
},
|
|
7
19
|
"files": [
|
|
8
20
|
"index.js",
|
|
9
21
|
"index.d.ts"
|
|
10
22
|
],
|
|
23
|
+
"main": "index.js",
|
|
24
|
+
"types": "index.d.ts",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"provenance": true
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "napi build --release",
|
|
31
|
+
"build:debug": "napi build"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@napi-rs/cli": "^3.5.1"
|
|
35
|
+
},
|
|
11
36
|
"napi": {
|
|
12
37
|
"binaryName": "ox-content",
|
|
13
38
|
"packageName": "@ox-content/binding",
|
|
@@ -19,36 +44,11 @@
|
|
|
19
44
|
"x86_64-pc-windows-msvc"
|
|
20
45
|
]
|
|
21
46
|
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "napi build --release",
|
|
24
|
-
"build:debug": "napi build"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@napi-rs/cli": "^3.5.1"
|
|
28
|
-
},
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "https://github.com/ubugeeei/ox-content.git",
|
|
32
|
-
"directory": "crates/ox_content_napi"
|
|
33
|
-
},
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"provenance": true,
|
|
36
|
-
"access": "public"
|
|
37
|
-
},
|
|
38
|
-
"keywords": [
|
|
39
|
-
"markdown",
|
|
40
|
-
"parser",
|
|
41
|
-
"napi",
|
|
42
|
-
"rust",
|
|
43
|
-
"oxc"
|
|
44
|
-
],
|
|
45
|
-
"author": "ubugeeei",
|
|
46
|
-
"license": "MIT",
|
|
47
47
|
"optionalDependencies": {
|
|
48
|
-
"@ox-content/binding-darwin-x64": "1.
|
|
49
|
-
"@ox-content/binding-darwin-arm64": "1.
|
|
50
|
-
"@ox-content/binding-linux-x64-gnu": "1.
|
|
51
|
-
"@ox-content/binding-linux-arm64-gnu": "1.
|
|
52
|
-
"@ox-content/binding-win32-x64-msvc": "1.
|
|
48
|
+
"@ox-content/binding-darwin-x64": "1.1.0",
|
|
49
|
+
"@ox-content/binding-darwin-arm64": "1.1.0",
|
|
50
|
+
"@ox-content/binding-linux-x64-gnu": "1.1.0",
|
|
51
|
+
"@ox-content/binding-linux-arm64-gnu": "1.1.0",
|
|
52
|
+
"@ox-content/binding-win32-x64-msvc": "1.1.0"
|
|
53
53
|
}
|
|
54
54
|
}
|