@ox-content/napi 2.75.1 → 2.79.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 +2 -0
  2. package/index.js +69 -2
  3. package/package.json +10 -6
package/index.d.ts CHANGED
@@ -1405,6 +1405,8 @@ export interface JsThemeColors {
1405
1405
  border?: string
1406
1406
  /** Code block background color. */
1407
1407
  codeBackground?: string
1408
+ /** Code block gradient color at the top. */
1409
+ codeBackgroundTop?: string
1408
1410
  /** Code block text color. */
1409
1411
  codeText?: string
1410
1412
  }
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
- const { existsSync } = require("fs");
1
+ const { execSync } = require("child_process");
2
+ const { existsSync, readFileSync } = require("fs");
2
3
  const path = require("path");
3
4
 
4
5
  function getErrorCode(error) {
@@ -20,6 +21,60 @@ function formatLoadError(target, error) {
20
21
  return ` - ${target}${suffix}: ${getErrorMessage(error)}`;
21
22
  }
22
23
 
24
+ function isFileMusl(file) {
25
+ return file.includes("libc.musl-") || file.includes("ld-musl-");
26
+ }
27
+
28
+ function isMuslFromFilesystem() {
29
+ try {
30
+ return readFileSync("/usr/bin/ldd", "utf8").includes("musl");
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+
36
+ function isMuslFromReport() {
37
+ if (typeof process.report?.getReport !== "function") {
38
+ return null;
39
+ }
40
+
41
+ const report = process.report.getReport();
42
+ if (report.header?.glibcVersionRuntime) {
43
+ return false;
44
+ }
45
+ if (Array.isArray(report.sharedObjects)) {
46
+ return report.sharedObjects.some(isFileMusl);
47
+ }
48
+
49
+ return false;
50
+ }
51
+
52
+ function isMuslFromChildProcess() {
53
+ try {
54
+ return execSync("ldd --version", { encoding: "utf8" }).includes("musl");
55
+ } catch {
56
+ return false;
57
+ }
58
+ }
59
+
60
+ function isMusl() {
61
+ if (process.platform !== "linux") {
62
+ return false;
63
+ }
64
+
65
+ const filesystemResult = isMuslFromFilesystem();
66
+ if (filesystemResult !== null) {
67
+ return filesystemResult;
68
+ }
69
+
70
+ const reportResult = isMuslFromReport();
71
+ if (reportResult !== null) {
72
+ return reportResult;
73
+ }
74
+
75
+ return isMuslFromChildProcess();
76
+ }
77
+
23
78
  function loadBinding() {
24
79
  const loadErrors = [];
25
80
 
@@ -43,7 +98,9 @@ function loadBinding() {
43
98
  "darwin-arm64": "ox-content.darwin-arm64.node",
44
99
  "darwin-x64": "ox-content.darwin-x64.node",
45
100
  "linux-x64-gnu": "ox-content.linux-x64-gnu.node",
101
+ "linux-x64-musl": "ox-content.linux-x64-musl.node",
46
102
  "linux-arm64-gnu": "ox-content.linux-arm64-gnu.node",
103
+ "linux-arm64-musl": "ox-content.linux-arm64-musl.node",
47
104
  "win32-x64-msvc": "ox-content.win32-x64-msvc.node",
48
105
  };
49
106
 
@@ -51,7 +108,7 @@ function loadBinding() {
51
108
  if (platform === "darwin") {
52
109
  key = `darwin-${arch}`;
53
110
  } else if (platform === "linux") {
54
- key = `linux-${arch}-gnu`;
111
+ key = `linux-${arch}-${isMusl() ? "musl" : "gnu"}`;
55
112
  } else if (platform === "win32") {
56
113
  key = `win32-${arch}-msvc`;
57
114
  }
@@ -69,7 +126,9 @@ function loadBinding() {
69
126
  "darwin-arm64": "@ox-content/binding-darwin-arm64",
70
127
  "darwin-x64": "@ox-content/binding-darwin-x64",
71
128
  "linux-x64-gnu": "@ox-content/binding-linux-x64-gnu",
129
+ "linux-x64-musl": "@ox-content/binding-linux-x64-musl",
72
130
  "linux-arm64-gnu": "@ox-content/binding-linux-arm64-gnu",
131
+ "linux-arm64-musl": "@ox-content/binding-linux-arm64-musl",
73
132
  "win32-x64-msvc": "@ox-content/binding-win32-x64-msvc",
74
133
  };
75
134
 
@@ -112,6 +171,14 @@ module.exports.render = binding.render;
112
171
  module.exports.transform = binding.transform;
113
172
  module.exports.transformAsync = binding.transformAsync;
114
173
  module.exports.transformMdastRaw = binding.transformMdastRaw;
174
+ module.exports.sanitizeHtml = binding.sanitizeHtml;
175
+ module.exports.transformMediaEmbeds = binding.transformMediaEmbeds;
176
+ module.exports.transformPmEmbeds = binding.transformPmEmbeds;
177
+ module.exports.transformTabsEmbeds = binding.transformTabsEmbeds;
178
+ module.exports.transformYoutubeEmbeds = binding.transformYoutubeEmbeds;
179
+ module.exports.extractCodeBlocks = binding.extractCodeBlocks;
180
+ module.exports.lintCodeBlocks = binding.lintCodeBlocks;
181
+ module.exports.extractDocsTests = binding.extractDocsTests;
115
182
  module.exports.version = binding.version;
116
183
  module.exports.extractFileDocs = binding.extractFileDocs;
117
184
  module.exports.extractFileDocEntries = binding.extractFileDocEntries;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/napi",
3
- "version": "2.75.1",
3
+ "version": "2.79.0",
4
4
  "description": "Node.js bindings for Ox Content - High-performance Markdown parser",
5
5
  "keywords": [
6
6
  "markdown",
@@ -40,15 +40,19 @@
40
40
  "x86_64-apple-darwin",
41
41
  "aarch64-apple-darwin",
42
42
  "x86_64-unknown-linux-gnu",
43
+ "x86_64-unknown-linux-musl",
43
44
  "aarch64-unknown-linux-gnu",
45
+ "aarch64-unknown-linux-musl",
44
46
  "x86_64-pc-windows-msvc"
45
47
  ]
46
48
  },
47
49
  "optionalDependencies": {
48
- "@ox-content/binding-darwin-x64": "2.75.1",
49
- "@ox-content/binding-darwin-arm64": "2.75.1",
50
- "@ox-content/binding-linux-x64-gnu": "2.75.1",
51
- "@ox-content/binding-linux-arm64-gnu": "2.75.1",
52
- "@ox-content/binding-win32-x64-msvc": "2.75.1"
50
+ "@ox-content/binding-darwin-x64": "2.79.0",
51
+ "@ox-content/binding-darwin-arm64": "2.79.0",
52
+ "@ox-content/binding-linux-x64-gnu": "2.79.0",
53
+ "@ox-content/binding-linux-x64-musl": "2.79.0",
54
+ "@ox-content/binding-linux-arm64-gnu": "2.79.0",
55
+ "@ox-content/binding-linux-arm64-musl": "2.79.0",
56
+ "@ox-content/binding-win32-x64-msvc": "2.79.0"
53
57
  }
54
58
  }