@takazudo/mdx-formatter 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -58,15 +58,20 @@ const formatted = await format('# Hello\nWorld');
58
58
  console.log(formatted); // '# Hello\n\nWorld'
59
59
  ```
60
60
 
61
- ### Browser / WebView
61
+ ### Browser (WASM)
62
+
63
+ ```bash
64
+ npm install @takazudo/mdx-formatter-wasm
65
+ ```
62
66
 
63
67
  ```javascript
64
- import { format } from '@takazudo/mdx-formatter/browser';
68
+ import init, { format_with_defaults } from '@takazudo/mdx-formatter-wasm';
65
69
 
66
- const formatted = await format('# Hello\nWorld');
70
+ await init();
71
+ const formatted = format_with_defaults('# Hello\nWorld');
67
72
  ```
68
73
 
69
- The browser export avoids Node.js `fs`/`path` dependencies. See [Browser Usage](https://takazudomodular.com/pj/mdx-formatter/docs/overview/browser-usage) for details.
74
+ See [Browser Usage](https://takazudomodular.com/pj/mdx-formatter/docs/overview/browser-usage) for details.
70
75
 
71
76
  ## Documentation
72
77
 
package/dist/browser.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * Browser-safe entry point for mdx-formatter.
3
3
  *
4
- * Note: In browser environments, use the WASM module directly instead.
5
- * This export is kept for API compatibility but requires the napi native
6
- * module to be available (Node.js only).
4
+ * This export provides only browser-safe utilities (no Node.js fs/path deps).
5
+ * For formatting in browser environments, use the WASM package instead:
7
6
  *
8
- * For true browser usage, see the WASM package at
9
- * `crates/mdx-formatter-wasm/` or the doc site playground.
7
+ * npm install @takazudo/mdx-formatter-wasm
8
+ *
9
+ * The WASM package provides format() and format_with_defaults() functions
10
+ * that work in any browser environment.
10
11
  */
11
- export { format, detectMdx } from './index.js';
12
+ export { detectMdx } from './detect-mdx.js';
12
13
  export type { FormatterSettings, DeepPartial } from './types.js';
package/dist/browser.js CHANGED
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Browser-safe entry point for mdx-formatter.
3
3
  *
4
- * Note: In browser environments, use the WASM module directly instead.
5
- * This export is kept for API compatibility but requires the napi native
6
- * module to be available (Node.js only).
4
+ * This export provides only browser-safe utilities (no Node.js fs/path deps).
5
+ * For formatting in browser environments, use the WASM package instead:
7
6
  *
8
- * For true browser usage, see the WASM package at
9
- * `crates/mdx-formatter-wasm/` or the doc site playground.
7
+ * npm install @takazudo/mdx-formatter-wasm
8
+ *
9
+ * The WASM package provides format() and format_with_defaults() functions
10
+ * that work in any browser environment.
10
11
  */
11
- export { format, detectMdx } from './index.js';
12
+ export { detectMdx } from './detect-mdx.js';
package/dist/index.d.ts CHANGED
@@ -9,6 +9,12 @@ export { detectMdx };
9
9
  * Format markdown/MDX content using the Rust formatter.
10
10
  */
11
11
  export declare function format(content: string, options?: FormatOptions): Promise<string>;
12
+ /**
13
+ * Synchronous format with default settings.
14
+ * API-compatible with @takazudo/mdx-formatter-wasm's format_with_defaults().
15
+ * Useful for mocking the WASM module in Node.js test environments.
16
+ */
17
+ export declare function formatSync(content: string): string;
12
18
  /**
13
19
  * Format a file and write it back if changed
14
20
  */
@@ -19,6 +25,7 @@ export declare function formatFile(filePath: string, options?: FormatOptions): P
19
25
  export declare function checkFile(filePath: string, options?: FormatOptions): Promise<boolean>;
20
26
  declare const _default: {
21
27
  format: typeof format;
28
+ formatSync: typeof formatSync;
22
29
  formatFile: typeof formatFile;
23
30
  checkFile: typeof checkFile;
24
31
  detectMdx: typeof detectMdx;
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import { promises as fs } from 'fs';
6
6
  import { loadConfig } from './load-config.js';
7
7
  import { detectMdx } from './detect-mdx.js';
8
8
  import { nativeFormat } from './rust-formatter.js';
9
+ import { formatterSettings } from './settings.js';
9
10
  export { detectMdx };
10
11
  /**
11
12
  * Format markdown/MDX content using the Rust formatter.
@@ -15,6 +16,14 @@ export async function format(content, options = {}) {
15
16
  const settingsJson = JSON.stringify(settings);
16
17
  return nativeFormat(content, settingsJson);
17
18
  }
19
+ /**
20
+ * Synchronous format with default settings.
21
+ * API-compatible with @takazudo/mdx-formatter-wasm's format_with_defaults().
22
+ * Useful for mocking the WASM module in Node.js test environments.
23
+ */
24
+ export function formatSync(content) {
25
+ return nativeFormat(content, JSON.stringify(formatterSettings));
26
+ }
18
27
  /**
19
28
  * Format a file and write it back if changed
20
29
  */
@@ -37,6 +46,7 @@ export async function checkFile(filePath, options = {}) {
37
46
  }
38
47
  export default {
39
48
  format,
49
+ formatSync,
40
50
  formatFile,
41
51
  checkFile,
42
52
  detectMdx,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Markdown Formatter Settings - 7 Core Rules
2
+ * Markdown Formatter Settings - 10 Rules
3
3
  * Each option can be toggled on/off independently
4
4
  */
5
5
  import type { FormatterSettings } from './types.js';
package/dist/settings.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Markdown Formatter Settings - 7 Core Rules
2
+ * Markdown Formatter Settings - 10 Rules
3
3
  * Each option can be toggled on/off independently
4
4
  */
5
5
  export const formatterSettings = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takazudo/mdx-formatter",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "AST-based markdown and MDX formatter with Japanese text support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",