@ox-content/napi 2.9.0 → 2.10.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 +36 -1
  2. package/index.js +2 -0
  3. package/package.json +6 -6
package/index.d.ts CHANGED
@@ -475,6 +475,12 @@ export interface JsSourceDocTag {
475
475
  value: string
476
476
  }
477
477
 
478
+ /** Source preparation options for JavaScript. */
479
+ export interface JsSourceOptions {
480
+ /** Parse YAML frontmatter before returning the content payload. */
481
+ frontmatter?: boolean
482
+ }
483
+
478
484
  /** SSG configuration. */
479
485
  export interface JsSsgConfig {
480
486
  /** Site name. */
@@ -716,6 +722,8 @@ export interface JsTransformOptions {
716
722
  strikethrough?: boolean
717
723
  /** Enable autolinks. */
718
724
  autolinks?: boolean
725
+ /** Parse YAML frontmatter before transforming. */
726
+ frontmatter?: boolean
719
727
  /** Maximum TOC depth (1-6). */
720
728
  tocMaxDepth?: number
721
729
  /** Convert `.md` links to `.html` links for SSG output. */
@@ -781,7 +789,7 @@ export interface Mf2ValidateResult {
781
789
  /**
782
790
  * Parses Markdown source into an AST.
783
791
  *
784
- * Returns the AST as a JSON string for zero-copy transfer to JavaScript.
792
+ * Returns the AST as a JSON string for compatibility-oriented JavaScript consumers.
785
793
  */
786
794
  export declare function parse(source: string, options?: JsParserOptions | undefined | null): ParseResult
787
795
 
@@ -791,6 +799,9 @@ export declare function parseAndRender(source: string, options?: JsParserOptions
791
799
  /** Parses Markdown and renders to HTML asynchronously (runs on worker thread). */
792
800
  export declare function parseAndRenderAsync(source: string, options?: JsParserOptions | undefined | null): Promise<unknown>
793
801
 
802
+ /** Parses Markdown source into a raw mdast memory block for JavaScript-side deserialization. */
803
+ export declare function parseMdastRaw(source: string, options?: JsParserOptions | undefined | null): Uint8Array
804
+
794
805
  /** Parse result containing the AST as JSON. */
795
806
  export interface ParseResult {
796
807
  /** The AST as a JSON string. */
@@ -802,6 +813,22 @@ export interface ParseResult {
802
813
  /** Splits a search query into free-text terms and `@scope` prefixes. */
803
814
  export declare function parseScopedSearchQuery(query: string): JsScopedSearchQuery
804
815
 
816
+ /**
817
+ * Parses Markdown source into a transfer buffer identified by payload kind.
818
+ *
819
+ * Today `mdast` is the primary supported payload. Future payload kinds such as
820
+ * markdown-it token streams will share the same transfer envelope.
821
+ */
822
+ export declare function parseTransferRaw(source: string, kind: string, options?: JsParserOptions | undefined | null): Uint8Array
823
+
824
+ /**
825
+ * Splits Markdown source into content and frontmatter in a raw transfer buffer.
826
+ *
827
+ * This is used by JavaScript-side markdown-it and custom unified parser paths so
828
+ * frontmatter stripping can stay on the Rust side even when parsing continues in JS.
829
+ */
830
+ export declare function prepareSourceRaw(source: string, options?: JsSourceOptions | undefined | null): Uint8Array
831
+
805
832
  /** Renders an AST (provided as JSON) to HTML. */
806
833
  export declare function render(astJson: string): RenderResult
807
834
 
@@ -844,6 +871,14 @@ export declare function transform(source: string, options?: JsTransformOptions |
844
871
  /** Transforms Markdown source asynchronously (runs on worker thread). */
845
872
  export declare function transformAsync(source: string, options?: JsTransformOptions | undefined | null): Promise<unknown>
846
873
 
874
+ /**
875
+ * Transforms Markdown into a raw mdast transfer buffer.
876
+ *
877
+ * This keeps frontmatter parsing and mdast generation on the Rust side and
878
+ * transfers a single external memory block to JavaScript for deserialization.
879
+ */
880
+ export declare function transformMdastRaw(source: string, options?: JsTransformOptions | undefined | null): Uint8Array
881
+
847
882
  /**
848
883
  * Transforms mermaid code blocks in HTML to rendered SVG diagrams.
849
884
  *
package/index.js CHANGED
@@ -70,6 +70,8 @@ const binding = loadBinding();
70
70
  // Export individual functions for ESM compatibility
71
71
  module.exports = binding;
72
72
  module.exports.parse = binding.parse;
73
+ module.exports.parseTransferRaw = binding.parseTransferRaw;
74
+ module.exports.parseMdastRaw = binding.parseMdastRaw;
73
75
  module.exports.parseAndRender = binding.parseAndRender;
74
76
  module.exports.parseAndRenderAsync = binding.parseAndRenderAsync;
75
77
  module.exports.lintMarkdown = binding.lintMarkdown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/napi",
3
- "version": "2.9.0",
3
+ "version": "2.10.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.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"
48
+ "@ox-content/binding-darwin-x64": "2.10.0",
49
+ "@ox-content/binding-darwin-arm64": "2.10.0",
50
+ "@ox-content/binding-linux-x64-gnu": "2.10.0",
51
+ "@ox-content/binding-linux-arm64-gnu": "2.10.0",
52
+ "@ox-content/binding-win32-x64-msvc": "2.10.0"
53
53
  }
54
54
  }