@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 +9 -4
- package/dist/browser.d.ts +7 -6
- package/dist/browser.js +7 -6
- package/dist/index.d.ts +7 -0
- package/dist/index.js +10 -0
- package/dist/settings.d.ts +1 -1
- package/dist/settings.js +1 -1
- package/package.json +1 -1
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
|
|
61
|
+
### Browser (WASM)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install @takazudo/mdx-formatter-wasm
|
|
65
|
+
```
|
|
62
66
|
|
|
63
67
|
```javascript
|
|
64
|
-
import {
|
|
68
|
+
import init, { format_with_defaults } from '@takazudo/mdx-formatter-wasm';
|
|
65
69
|
|
|
66
|
-
|
|
70
|
+
await init();
|
|
71
|
+
const formatted = format_with_defaults('# Hello\nWorld');
|
|
67
72
|
```
|
|
68
73
|
|
|
69
|
-
|
|
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
|
-
*
|
|
5
|
-
*
|
|
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
|
-
*
|
|
9
|
-
*
|
|
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 {
|
|
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
|
-
*
|
|
5
|
-
*
|
|
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
|
-
*
|
|
9
|
-
*
|
|
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 {
|
|
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,
|
package/dist/settings.d.ts
CHANGED
package/dist/settings.js
CHANGED