@ox-content/vite-plugin 0.17.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/dist/chunk.cjs +39 -49
- package/dist/github.cjs +323 -3
- package/dist/github.cjs.map +1 -0
- package/dist/github.mjs +2 -0
- package/dist/{github2.js → github2.mjs} +2 -3
- package/dist/github2.mjs.map +1 -0
- package/dist/index.cjs +626 -293
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -66
- package/dist/index.d.cts.map +1 -1
- package/dist/{index.d.ts → index.d.mts} +80 -67
- package/dist/index.d.mts.map +1 -0
- package/dist/{index.js → index.mjs} +638 -318
- package/dist/index.mjs.map +1 -0
- package/dist/mermaid.cjs +115 -3
- package/dist/mermaid.cjs.map +1 -0
- package/dist/{mermaid2.js → mermaid.mjs} +14 -6
- package/dist/mermaid.mjs.map +1 -0
- package/dist/mermaid2.mjs +2 -0
- package/dist/ogp.cjs +316 -3
- package/dist/ogp.cjs.map +1 -0
- package/dist/ogp.mjs +2 -0
- package/dist/{ogp2.js → ogp2.mjs} +2 -3
- package/dist/ogp2.mjs.map +1 -0
- package/dist/tabs.cjs +212 -3
- package/dist/tabs.cjs.map +1 -0
- package/dist/tabs.mjs +2 -0
- package/dist/{tabs2.js → tabs2.mjs} +2 -3
- package/dist/tabs2.mjs.map +1 -0
- package/dist/youtube.cjs +135 -3
- package/dist/youtube.cjs.map +1 -0
- package/dist/youtube.mjs +2 -0
- package/dist/{youtube2.js → youtube2.mjs} +2 -3
- package/dist/youtube2.mjs.map +1 -0
- package/package.json +61 -56
- package/dist/github.js +0 -3
- package/dist/github2.cjs +0 -313
- package/dist/github2.cjs.map +0 -1
- package/dist/github2.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mermaid.js +0 -3
- package/dist/mermaid2.cjs +0 -92
- package/dist/mermaid2.cjs.map +0 -1
- package/dist/mermaid2.js.map +0 -1
- package/dist/ogp.js +0 -3
- package/dist/ogp2.cjs +0 -306
- package/dist/ogp2.cjs.map +0 -1
- package/dist/ogp2.js.map +0 -1
- package/dist/tabs.js +0 -3
- package/dist/tabs2.cjs +0 -203
- package/dist/tabs2.cjs.map +0 -1
- package/dist/tabs2.js.map +0 -1
- package/dist/youtube.js +0 -3
- package/dist/youtube2.cjs +0 -127
- package/dist/youtube2.cjs.map +0 -1
- package/dist/youtube2.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
path
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_chunk = require("./chunk.cjs");
|
|
3
|
+
const require_mermaid = require("./mermaid.cjs");
|
|
4
|
+
const require_tabs = require("./tabs.cjs");
|
|
5
|
+
const require_youtube = require("./youtube.cjs");
|
|
6
|
+
const require_github = require("./github.cjs");
|
|
7
|
+
const require_ogp = require("./ogp.cjs");
|
|
8
|
+
let path = require("path");
|
|
9
|
+
path = require_chunk.__toESM(path);
|
|
9
10
|
let unified = require("unified");
|
|
10
11
|
let rehype_parse = require("rehype-parse");
|
|
11
12
|
rehype_parse = require_chunk.__toESM(rehype_parse);
|
|
@@ -15,13 +16,13 @@ let shiki = require("shiki");
|
|
|
15
16
|
let node_path = require("node:path");
|
|
16
17
|
let fs = require("fs");
|
|
17
18
|
fs = require_chunk.__toESM(fs);
|
|
19
|
+
let node_crypto = require("node:crypto");
|
|
18
20
|
let fs_promises = require("fs/promises");
|
|
19
21
|
fs_promises = require_chunk.__toESM(fs_promises);
|
|
20
22
|
let glob = require("glob");
|
|
21
23
|
let crypto = require("crypto");
|
|
22
24
|
crypto = require_chunk.__toESM(crypto);
|
|
23
25
|
let node_fs_promises = require("node:fs/promises");
|
|
24
|
-
|
|
25
26
|
//#region src/environment.ts
|
|
26
27
|
/**
|
|
27
28
|
* Creates the Markdown processing environment configuration.
|
|
@@ -68,7 +69,6 @@ function createMarkdownEnvironment(options) {
|
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
|
-
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/identity.js
|
|
74
74
|
var require_identity = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -119,7 +119,6 @@ var require_identity = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
119
119
|
exports.isScalar = isScalar;
|
|
120
120
|
exports.isSeq = isSeq;
|
|
121
121
|
}));
|
|
122
|
-
|
|
123
122
|
//#endregion
|
|
124
123
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/visit.js
|
|
125
124
|
var require_visit = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -310,7 +309,6 @@ var require_visit = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
310
309
|
exports.visit = visit;
|
|
311
310
|
exports.visitAsync = visitAsync;
|
|
312
311
|
}));
|
|
313
|
-
|
|
314
312
|
//#endregion
|
|
315
313
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/directives.js
|
|
316
314
|
var require_directives = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -476,7 +474,6 @@ var require_directives = /* @__PURE__ */ require_chunk.__commonJSMin(((exports)
|
|
|
476
474
|
Directives.defaultTags = { "!!": "tag:yaml.org,2002:" };
|
|
477
475
|
exports.Directives = Directives;
|
|
478
476
|
}));
|
|
479
|
-
|
|
480
477
|
//#endregion
|
|
481
478
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/anchors.js
|
|
482
479
|
var require_anchors = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -539,7 +536,6 @@ var require_anchors = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
539
536
|
exports.createNodeAnchors = createNodeAnchors;
|
|
540
537
|
exports.findNewAnchor = findNewAnchor;
|
|
541
538
|
}));
|
|
542
|
-
|
|
543
539
|
//#endregion
|
|
544
540
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/applyReviver.js
|
|
545
541
|
var require_applyReviver = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -580,7 +576,6 @@ var require_applyReviver = /* @__PURE__ */ require_chunk.__commonJSMin(((exports
|
|
|
580
576
|
}
|
|
581
577
|
exports.applyReviver = applyReviver;
|
|
582
578
|
}));
|
|
583
|
-
|
|
584
579
|
//#endregion
|
|
585
580
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/toJS.js
|
|
586
581
|
var require_toJS = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -618,7 +613,6 @@ var require_toJS = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
618
613
|
}
|
|
619
614
|
exports.toJS = toJS;
|
|
620
615
|
}));
|
|
621
|
-
|
|
622
616
|
//#endregion
|
|
623
617
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Node.js
|
|
624
618
|
var require_Node = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -653,7 +647,6 @@ var require_Node = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
653
647
|
};
|
|
654
648
|
exports.NodeBase = NodeBase;
|
|
655
649
|
}));
|
|
656
|
-
|
|
657
650
|
//#endregion
|
|
658
651
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Alias.js
|
|
659
652
|
var require_Alias = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -747,7 +740,6 @@ var require_Alias = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
747
740
|
}
|
|
748
741
|
exports.Alias = Alias;
|
|
749
742
|
}));
|
|
750
|
-
|
|
751
743
|
//#endregion
|
|
752
744
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Scalar.js
|
|
753
745
|
var require_Scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -775,7 +767,6 @@ var require_Scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
775
767
|
exports.Scalar = Scalar;
|
|
776
768
|
exports.isScalarValue = isScalarValue;
|
|
777
769
|
}));
|
|
778
|
-
|
|
779
770
|
//#endregion
|
|
780
771
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/createNode.js
|
|
781
772
|
var require_createNode = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -839,7 +830,6 @@ var require_createNode = /* @__PURE__ */ require_chunk.__commonJSMin(((exports)
|
|
|
839
830
|
}
|
|
840
831
|
exports.createNode = createNode;
|
|
841
832
|
}));
|
|
842
|
-
|
|
843
833
|
//#endregion
|
|
844
834
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Collection.js
|
|
845
835
|
var require_Collection = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -961,7 +951,6 @@ var require_Collection = /* @__PURE__ */ require_chunk.__commonJSMin(((exports)
|
|
|
961
951
|
exports.collectionFromPath = collectionFromPath;
|
|
962
952
|
exports.isEmptyPath = isEmptyPath;
|
|
963
953
|
}));
|
|
964
|
-
|
|
965
954
|
//#endregion
|
|
966
955
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyComment.js
|
|
967
956
|
var require_stringifyComment = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -982,7 +971,6 @@ var require_stringifyComment = /* @__PURE__ */ require_chunk.__commonJSMin(((exp
|
|
|
982
971
|
exports.lineComment = lineComment;
|
|
983
972
|
exports.stringifyComment = stringifyComment;
|
|
984
973
|
}));
|
|
985
|
-
|
|
986
974
|
//#endregion
|
|
987
975
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/foldFlowLines.js
|
|
988
976
|
var require_foldFlowLines = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1099,7 +1087,6 @@ var require_foldFlowLines = /* @__PURE__ */ require_chunk.__commonJSMin(((export
|
|
|
1099
1087
|
exports.FOLD_QUOTED = FOLD_QUOTED;
|
|
1100
1088
|
exports.foldFlowLines = foldFlowLines;
|
|
1101
1089
|
}));
|
|
1102
|
-
|
|
1103
1090
|
//#endregion
|
|
1104
1091
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyString.js
|
|
1105
1092
|
var require_stringifyString = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1324,7 +1311,6 @@ var require_stringifyString = /* @__PURE__ */ require_chunk.__commonJSMin(((expo
|
|
|
1324
1311
|
}
|
|
1325
1312
|
exports.stringifyString = stringifyString;
|
|
1326
1313
|
}));
|
|
1327
|
-
|
|
1328
1314
|
//#endregion
|
|
1329
1315
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringify.js
|
|
1330
1316
|
var require_stringify = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1432,7 +1418,6 @@ var require_stringify = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =
|
|
|
1432
1418
|
exports.createStringifyContext = createStringifyContext;
|
|
1433
1419
|
exports.stringify = stringify;
|
|
1434
1420
|
}));
|
|
1435
|
-
|
|
1436
1421
|
//#endregion
|
|
1437
1422
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyPair.js
|
|
1438
1423
|
var require_stringifyPair = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1530,7 +1515,6 @@ var require_stringifyPair = /* @__PURE__ */ require_chunk.__commonJSMin(((export
|
|
|
1530
1515
|
}
|
|
1531
1516
|
exports.stringifyPair = stringifyPair;
|
|
1532
1517
|
}));
|
|
1533
|
-
|
|
1534
1518
|
//#endregion
|
|
1535
1519
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/log.js
|
|
1536
1520
|
var require_log = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1545,7 +1529,6 @@ var require_log = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
1545
1529
|
exports.debug = debug;
|
|
1546
1530
|
exports.warn = warn;
|
|
1547
1531
|
}));
|
|
1548
|
-
|
|
1549
1532
|
//#endregion
|
|
1550
1533
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/merge.js
|
|
1551
1534
|
var require_merge = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1586,7 +1569,6 @@ var require_merge = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
1586
1569
|
exports.isMergeKey = isMergeKey;
|
|
1587
1570
|
exports.merge = merge;
|
|
1588
1571
|
}));
|
|
1589
|
-
|
|
1590
1572
|
//#endregion
|
|
1591
1573
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/addPairToJSMap.js
|
|
1592
1574
|
var require_addPairToJSMap = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1638,7 +1620,6 @@ var require_addPairToJSMap = /* @__PURE__ */ require_chunk.__commonJSMin(((expor
|
|
|
1638
1620
|
}
|
|
1639
1621
|
exports.addPairToJSMap = addPairToJSMap;
|
|
1640
1622
|
}));
|
|
1641
|
-
|
|
1642
1623
|
//#endregion
|
|
1643
1624
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Pair.js
|
|
1644
1625
|
var require_Pair = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1672,7 +1653,6 @@ var require_Pair = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
1672
1653
|
exports.Pair = Pair;
|
|
1673
1654
|
exports.createPair = createPair;
|
|
1674
1655
|
}));
|
|
1675
|
-
|
|
1676
1656
|
//#endregion
|
|
1677
1657
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyCollection.js
|
|
1678
1658
|
var require_stringifyCollection = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1787,7 +1767,6 @@ var require_stringifyCollection = /* @__PURE__ */ require_chunk.__commonJSMin(((
|
|
|
1787
1767
|
}
|
|
1788
1768
|
exports.stringifyCollection = stringifyCollection;
|
|
1789
1769
|
}));
|
|
1790
|
-
|
|
1791
1770
|
//#endregion
|
|
1792
1771
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/YAMLMap.js
|
|
1793
1772
|
var require_YAMLMap = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -1897,13 +1876,12 @@ var require_YAMLMap = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
1897
1876
|
exports.YAMLMap = YAMLMap;
|
|
1898
1877
|
exports.findPair = findPair;
|
|
1899
1878
|
}));
|
|
1900
|
-
|
|
1901
1879
|
//#endregion
|
|
1902
1880
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/map.js
|
|
1903
1881
|
var require_map = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
1904
1882
|
var identity = require_identity();
|
|
1905
1883
|
var YAMLMap = require_YAMLMap();
|
|
1906
|
-
|
|
1884
|
+
exports.map = {
|
|
1907
1885
|
collection: "map",
|
|
1908
1886
|
default: true,
|
|
1909
1887
|
nodeClass: YAMLMap.YAMLMap,
|
|
@@ -1914,9 +1892,7 @@ var require_map = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
1914
1892
|
},
|
|
1915
1893
|
createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx)
|
|
1916
1894
|
};
|
|
1917
|
-
exports.map = map;
|
|
1918
1895
|
}));
|
|
1919
|
-
|
|
1920
1896
|
//#endregion
|
|
1921
1897
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/YAMLSeq.js
|
|
1922
1898
|
var require_YAMLSeq = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2023,13 +1999,12 @@ var require_YAMLSeq = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
2023
1999
|
}
|
|
2024
2000
|
exports.YAMLSeq = YAMLSeq;
|
|
2025
2001
|
}));
|
|
2026
|
-
|
|
2027
2002
|
//#endregion
|
|
2028
2003
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/seq.js
|
|
2029
2004
|
var require_seq = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
2030
2005
|
var identity = require_identity();
|
|
2031
2006
|
var YAMLSeq = require_YAMLSeq();
|
|
2032
|
-
|
|
2007
|
+
exports.seq = {
|
|
2033
2008
|
collection: "seq",
|
|
2034
2009
|
default: true,
|
|
2035
2010
|
nodeClass: YAMLSeq.YAMLSeq,
|
|
@@ -2040,14 +2015,12 @@ var require_seq = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2040
2015
|
},
|
|
2041
2016
|
createNode: (schema, obj, ctx) => YAMLSeq.YAMLSeq.from(schema, obj, ctx)
|
|
2042
2017
|
};
|
|
2043
|
-
exports.seq = seq;
|
|
2044
2018
|
}));
|
|
2045
|
-
|
|
2046
2019
|
//#endregion
|
|
2047
2020
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/string.js
|
|
2048
2021
|
var require_string = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
2049
2022
|
var stringifyString = require_stringifyString();
|
|
2050
|
-
|
|
2023
|
+
exports.string = {
|
|
2051
2024
|
identify: (value) => typeof value === "string",
|
|
2052
2025
|
default: true,
|
|
2053
2026
|
tag: "tag:yaml.org,2002:str",
|
|
@@ -2057,9 +2030,7 @@ var require_string = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2057
2030
|
return stringifyString.stringifyString(item, ctx, onComment, onChompKeep);
|
|
2058
2031
|
}
|
|
2059
2032
|
};
|
|
2060
|
-
exports.string = string;
|
|
2061
2033
|
}));
|
|
2062
|
-
|
|
2063
2034
|
//#endregion
|
|
2064
2035
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/common/null.js
|
|
2065
2036
|
var require_null = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2075,7 +2046,6 @@ var require_null = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2075
2046
|
};
|
|
2076
2047
|
exports.nullTag = nullTag;
|
|
2077
2048
|
}));
|
|
2078
|
-
|
|
2079
2049
|
//#endregion
|
|
2080
2050
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/bool.js
|
|
2081
2051
|
var require_bool$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2095,7 +2065,6 @@ var require_bool$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2095
2065
|
};
|
|
2096
2066
|
exports.boolTag = boolTag;
|
|
2097
2067
|
}));
|
|
2098
|
-
|
|
2099
2068
|
//#endregion
|
|
2100
2069
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyNumber.js
|
|
2101
2070
|
var require_stringifyNumber = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2117,7 +2086,6 @@ var require_stringifyNumber = /* @__PURE__ */ require_chunk.__commonJSMin(((expo
|
|
|
2117
2086
|
}
|
|
2118
2087
|
exports.stringifyNumber = stringifyNumber;
|
|
2119
2088
|
}));
|
|
2120
|
-
|
|
2121
2089
|
//#endregion
|
|
2122
2090
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/float.js
|
|
2123
2091
|
var require_float$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2143,7 +2111,7 @@ var require_float$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
2143
2111
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
2144
2112
|
}
|
|
2145
2113
|
};
|
|
2146
|
-
|
|
2114
|
+
exports.float = {
|
|
2147
2115
|
identify: (value) => typeof value === "number",
|
|
2148
2116
|
default: true,
|
|
2149
2117
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -2156,11 +2124,9 @@ var require_float$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
2156
2124
|
},
|
|
2157
2125
|
stringify: stringifyNumber.stringifyNumber
|
|
2158
2126
|
};
|
|
2159
|
-
exports.float = float;
|
|
2160
2127
|
exports.floatExp = floatExp;
|
|
2161
2128
|
exports.floatNaN = floatNaN;
|
|
2162
2129
|
}));
|
|
2163
|
-
|
|
2164
2130
|
//#endregion
|
|
2165
2131
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/int.js
|
|
2166
2132
|
var require_int$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2202,7 +2168,6 @@ var require_int$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2202
2168
|
exports.intHex = intHex;
|
|
2203
2169
|
exports.intOct = intOct;
|
|
2204
2170
|
}));
|
|
2205
|
-
|
|
2206
2171
|
//#endregion
|
|
2207
2172
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/core/schema.js
|
|
2208
2173
|
var require_schema$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2213,7 +2178,7 @@ var require_schema$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
2213
2178
|
var bool = require_bool$1();
|
|
2214
2179
|
var float = require_float$1();
|
|
2215
2180
|
var int = require_int$1();
|
|
2216
|
-
|
|
2181
|
+
exports.schema = [
|
|
2217
2182
|
map.map,
|
|
2218
2183
|
seq.seq,
|
|
2219
2184
|
string.string,
|
|
@@ -2226,9 +2191,7 @@ var require_schema$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
2226
2191
|
float.floatExp,
|
|
2227
2192
|
float.float
|
|
2228
2193
|
];
|
|
2229
|
-
exports.schema = schema;
|
|
2230
2194
|
}));
|
|
2231
|
-
|
|
2232
2195
|
//#endregion
|
|
2233
2196
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/json/schema.js
|
|
2234
2197
|
var require_schema$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2281,7 +2244,7 @@ var require_schema$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
2281
2244
|
stringify: stringifyJSON
|
|
2282
2245
|
}
|
|
2283
2246
|
];
|
|
2284
|
-
|
|
2247
|
+
exports.schema = [map.map, seq.seq].concat(jsonScalars, {
|
|
2285
2248
|
default: true,
|
|
2286
2249
|
tag: "",
|
|
2287
2250
|
test: /^/,
|
|
@@ -2290,16 +2253,14 @@ var require_schema$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
2290
2253
|
return str;
|
|
2291
2254
|
}
|
|
2292
2255
|
});
|
|
2293
|
-
exports.schema = schema;
|
|
2294
2256
|
}));
|
|
2295
|
-
|
|
2296
2257
|
//#endregion
|
|
2297
2258
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/binary.js
|
|
2298
2259
|
var require_binary = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
2299
2260
|
var node_buffer = require("buffer");
|
|
2300
2261
|
var Scalar = require_Scalar();
|
|
2301
2262
|
var stringifyString = require_stringifyString();
|
|
2302
|
-
|
|
2263
|
+
exports.binary = {
|
|
2303
2264
|
identify: (value) => value instanceof Uint8Array,
|
|
2304
2265
|
default: false,
|
|
2305
2266
|
tag: "tag:yaml.org,2002:binary",
|
|
@@ -2340,9 +2301,7 @@ var require_binary = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2340
2301
|
}, ctx, onComment, onChompKeep);
|
|
2341
2302
|
}
|
|
2342
2303
|
};
|
|
2343
|
-
exports.binary = binary;
|
|
2344
2304
|
}));
|
|
2345
|
-
|
|
2346
2305
|
//#endregion
|
|
2347
2306
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/pairs.js
|
|
2348
2307
|
var require_pairs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2403,7 +2362,6 @@ var require_pairs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2403
2362
|
exports.pairs = pairs;
|
|
2404
2363
|
exports.resolvePairs = resolvePairs;
|
|
2405
2364
|
}));
|
|
2406
|
-
|
|
2407
2365
|
//#endregion
|
|
2408
2366
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/omap.js
|
|
2409
2367
|
var require_omap = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2467,7 +2425,6 @@ var require_omap = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2467
2425
|
exports.YAMLOMap = YAMLOMap;
|
|
2468
2426
|
exports.omap = omap;
|
|
2469
2427
|
}));
|
|
2470
|
-
|
|
2471
2428
|
//#endregion
|
|
2472
2429
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/bool.js
|
|
2473
2430
|
var require_bool = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2495,7 +2452,6 @@ var require_bool = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2495
2452
|
exports.falseTag = falseTag;
|
|
2496
2453
|
exports.trueTag = trueTag;
|
|
2497
2454
|
}));
|
|
2498
|
-
|
|
2499
2455
|
//#endregion
|
|
2500
2456
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/float.js
|
|
2501
2457
|
var require_float = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2521,7 +2477,7 @@ var require_float = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2521
2477
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
2522
2478
|
}
|
|
2523
2479
|
};
|
|
2524
|
-
|
|
2480
|
+
exports.float = {
|
|
2525
2481
|
identify: (value) => typeof value === "number",
|
|
2526
2482
|
default: true,
|
|
2527
2483
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -2537,11 +2493,9 @@ var require_float = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2537
2493
|
},
|
|
2538
2494
|
stringify: stringifyNumber.stringifyNumber
|
|
2539
2495
|
};
|
|
2540
|
-
exports.float = float;
|
|
2541
2496
|
exports.floatExp = floatExp;
|
|
2542
2497
|
exports.floatNaN = floatNaN;
|
|
2543
2498
|
}));
|
|
2544
|
-
|
|
2545
2499
|
//#endregion
|
|
2546
2500
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/int.js
|
|
2547
2501
|
var require_int = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2617,7 +2571,6 @@ var require_int = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2617
2571
|
exports.intHex = intHex;
|
|
2618
2572
|
exports.intOct = intOct;
|
|
2619
2573
|
}));
|
|
2620
|
-
|
|
2621
2574
|
//#endregion
|
|
2622
2575
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/set.js
|
|
2623
2576
|
var require_set = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2686,7 +2639,6 @@ var require_set = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2686
2639
|
exports.YAMLSet = YAMLSet;
|
|
2687
2640
|
exports.set = set;
|
|
2688
2641
|
}));
|
|
2689
|
-
|
|
2690
2642
|
//#endregion
|
|
2691
2643
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
|
|
2692
2644
|
var require_timestamp = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2770,7 +2722,6 @@ var require_timestamp = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =
|
|
|
2770
2722
|
exports.intTime = intTime;
|
|
2771
2723
|
exports.timestamp = timestamp;
|
|
2772
2724
|
}));
|
|
2773
|
-
|
|
2774
2725
|
//#endregion
|
|
2775
2726
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/schema.js
|
|
2776
2727
|
var require_schema = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2787,7 +2738,7 @@ var require_schema = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2787
2738
|
var pairs = require_pairs();
|
|
2788
2739
|
var set = require_set();
|
|
2789
2740
|
var timestamp = require_timestamp();
|
|
2790
|
-
|
|
2741
|
+
exports.schema = [
|
|
2791
2742
|
map.map,
|
|
2792
2743
|
seq.seq,
|
|
2793
2744
|
string.string,
|
|
@@ -2810,9 +2761,7 @@ var require_schema = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2810
2761
|
timestamp.floatTime,
|
|
2811
2762
|
timestamp.timestamp
|
|
2812
2763
|
];
|
|
2813
|
-
exports.schema = schema;
|
|
2814
2764
|
}));
|
|
2815
|
-
|
|
2816
2765
|
//#endregion
|
|
2817
2766
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/tags.js
|
|
2818
2767
|
var require_tags = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2897,7 +2846,6 @@ var require_tags = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2897
2846
|
exports.coreKnownTags = coreKnownTags;
|
|
2898
2847
|
exports.getTags = getTags;
|
|
2899
2848
|
}));
|
|
2900
|
-
|
|
2901
2849
|
//#endregion
|
|
2902
2850
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/schema/Schema.js
|
|
2903
2851
|
var require_Schema = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2907,7 +2855,7 @@ var require_Schema = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2907
2855
|
var string = require_string();
|
|
2908
2856
|
var tags = require_tags();
|
|
2909
2857
|
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
2910
|
-
|
|
2858
|
+
exports.Schema = class Schema {
|
|
2911
2859
|
constructor({ compat, customTags, merge, resolveKnownTags, schema, sortMapEntries, toStringDefaults }) {
|
|
2912
2860
|
this.compat = Array.isArray(compat) ? tags.getTags(compat, "compat") : compat ? tags.getTags(null, compat) : null;
|
|
2913
2861
|
this.name = typeof schema === "string" && schema || "core";
|
|
@@ -2925,9 +2873,7 @@ var require_Schema = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
2925
2873
|
return copy;
|
|
2926
2874
|
}
|
|
2927
2875
|
};
|
|
2928
|
-
exports.Schema = Schema;
|
|
2929
2876
|
}));
|
|
2930
|
-
|
|
2931
2877
|
//#endregion
|
|
2932
2878
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyDocument.js
|
|
2933
2879
|
var require_stringifyDocument = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -2989,7 +2935,6 @@ var require_stringifyDocument = /* @__PURE__ */ require_chunk.__commonJSMin(((ex
|
|
|
2989
2935
|
}
|
|
2990
2936
|
exports.stringifyDocument = stringifyDocument;
|
|
2991
2937
|
}));
|
|
2992
|
-
|
|
2993
2938
|
//#endregion
|
|
2994
2939
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/Document.js
|
|
2995
2940
|
var require_Document = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3271,7 +3216,6 @@ var require_Document = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
3271
3216
|
}
|
|
3272
3217
|
exports.Document = Document;
|
|
3273
3218
|
}));
|
|
3274
|
-
|
|
3275
3219
|
//#endregion
|
|
3276
3220
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/errors.js
|
|
3277
3221
|
var require_errors = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3325,7 +3269,6 @@ var require_errors = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
3325
3269
|
exports.YAMLWarning = YAMLWarning;
|
|
3326
3270
|
exports.prettifyError = prettifyError;
|
|
3327
3271
|
}));
|
|
3328
|
-
|
|
3329
3272
|
//#endregion
|
|
3330
3273
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-props.js
|
|
3331
3274
|
var require_resolve_props = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3433,7 +3376,6 @@ var require_resolve_props = /* @__PURE__ */ require_chunk.__commonJSMin(((export
|
|
|
3433
3376
|
}
|
|
3434
3377
|
exports.resolveProps = resolveProps;
|
|
3435
3378
|
}));
|
|
3436
|
-
|
|
3437
3379
|
//#endregion
|
|
3438
3380
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-contains-newline.js
|
|
3439
3381
|
var require_util_contains_newline = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3463,7 +3405,6 @@ var require_util_contains_newline = /* @__PURE__ */ require_chunk.__commonJSMin(
|
|
|
3463
3405
|
}
|
|
3464
3406
|
exports.containsNewline = containsNewline;
|
|
3465
3407
|
}));
|
|
3466
|
-
|
|
3467
3408
|
//#endregion
|
|
3468
3409
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-flow-indent-check.js
|
|
3469
3410
|
var require_util_flow_indent_check = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3476,7 +3417,6 @@ var require_util_flow_indent_check = /* @__PURE__ */ require_chunk.__commonJSMin
|
|
|
3476
3417
|
}
|
|
3477
3418
|
exports.flowIndentCheck = flowIndentCheck;
|
|
3478
3419
|
}));
|
|
3479
|
-
|
|
3480
3420
|
//#endregion
|
|
3481
3421
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-map-includes.js
|
|
3482
3422
|
var require_util_map_includes = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3489,7 +3429,6 @@ var require_util_map_includes = /* @__PURE__ */ require_chunk.__commonJSMin(((ex
|
|
|
3489
3429
|
}
|
|
3490
3430
|
exports.mapIncludes = mapIncludes;
|
|
3491
3431
|
}));
|
|
3492
|
-
|
|
3493
3432
|
//#endregion
|
|
3494
3433
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-map.js
|
|
3495
3434
|
var require_resolve_block_map = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3574,7 +3513,6 @@ var require_resolve_block_map = /* @__PURE__ */ require_chunk.__commonJSMin(((ex
|
|
|
3574
3513
|
}
|
|
3575
3514
|
exports.resolveBlockMap = resolveBlockMap;
|
|
3576
3515
|
}));
|
|
3577
|
-
|
|
3578
3516
|
//#endregion
|
|
3579
3517
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-seq.js
|
|
3580
3518
|
var require_resolve_block_seq = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3617,7 +3555,6 @@ var require_resolve_block_seq = /* @__PURE__ */ require_chunk.__commonJSMin(((ex
|
|
|
3617
3555
|
}
|
|
3618
3556
|
exports.resolveBlockSeq = resolveBlockSeq;
|
|
3619
3557
|
}));
|
|
3620
|
-
|
|
3621
3558
|
//#endregion
|
|
3622
3559
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-end.js
|
|
3623
3560
|
var require_resolve_end = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3656,7 +3593,6 @@ var require_resolve_end = /* @__PURE__ */ require_chunk.__commonJSMin(((exports)
|
|
|
3656
3593
|
}
|
|
3657
3594
|
exports.resolveEnd = resolveEnd;
|
|
3658
3595
|
}));
|
|
3659
|
-
|
|
3660
3596
|
//#endregion
|
|
3661
3597
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-flow-collection.js
|
|
3662
3598
|
var require_resolve_flow_collection = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3812,7 +3748,6 @@ var require_resolve_flow_collection = /* @__PURE__ */ require_chunk.__commonJSMi
|
|
|
3812
3748
|
}
|
|
3813
3749
|
exports.resolveFlowCollection = resolveFlowCollection;
|
|
3814
3750
|
}));
|
|
3815
|
-
|
|
3816
3751
|
//#endregion
|
|
3817
3752
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-collection.js
|
|
3818
3753
|
var require_compose_collection = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -3865,7 +3800,6 @@ var require_compose_collection = /* @__PURE__ */ require_chunk.__commonJSMin(((e
|
|
|
3865
3800
|
}
|
|
3866
3801
|
exports.composeCollection = composeCollection;
|
|
3867
3802
|
}));
|
|
3868
|
-
|
|
3869
3803
|
//#endregion
|
|
3870
3804
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-block-scalar.js
|
|
3871
3805
|
var require_resolve_block_scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4041,7 +3975,6 @@ var require_resolve_block_scalar = /* @__PURE__ */ require_chunk.__commonJSMin((
|
|
|
4041
3975
|
}
|
|
4042
3976
|
exports.resolveBlockScalar = resolveBlockScalar;
|
|
4043
3977
|
}));
|
|
4044
|
-
|
|
4045
3978
|
//#endregion
|
|
4046
3979
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/resolve-flow-scalar.js
|
|
4047
3980
|
var require_resolve_flow_scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4248,7 +4181,6 @@ var require_resolve_flow_scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((
|
|
|
4248
4181
|
}
|
|
4249
4182
|
exports.resolveFlowScalar = resolveFlowScalar;
|
|
4250
4183
|
}));
|
|
4251
|
-
|
|
4252
4184
|
//#endregion
|
|
4253
4185
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-scalar.js
|
|
4254
4186
|
var require_compose_scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4308,7 +4240,6 @@ var require_compose_scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((expor
|
|
|
4308
4240
|
}
|
|
4309
4241
|
exports.composeScalar = composeScalar;
|
|
4310
4242
|
}));
|
|
4311
|
-
|
|
4312
4243
|
//#endregion
|
|
4313
4244
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/util-empty-scalar-position.js
|
|
4314
4245
|
var require_util_empty_scalar_position = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4336,7 +4267,6 @@ var require_util_empty_scalar_position = /* @__PURE__ */ require_chunk.__commonJ
|
|
|
4336
4267
|
}
|
|
4337
4268
|
exports.emptyScalarPosition = emptyScalarPosition;
|
|
4338
4269
|
}));
|
|
4339
|
-
|
|
4340
4270
|
//#endregion
|
|
4341
4271
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-node.js
|
|
4342
4272
|
var require_compose_node = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4422,7 +4352,6 @@ var require_compose_node = /* @__PURE__ */ require_chunk.__commonJSMin(((exports
|
|
|
4422
4352
|
exports.composeEmptyNode = composeEmptyNode;
|
|
4423
4353
|
exports.composeNode = composeNode;
|
|
4424
4354
|
}));
|
|
4425
|
-
|
|
4426
4355
|
//#endregion
|
|
4427
4356
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/compose-doc.js
|
|
4428
4357
|
var require_compose_doc = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4465,7 +4394,6 @@ var require_compose_doc = /* @__PURE__ */ require_chunk.__commonJSMin(((exports)
|
|
|
4465
4394
|
}
|
|
4466
4395
|
exports.composeDoc = composeDoc;
|
|
4467
4396
|
}));
|
|
4468
|
-
|
|
4469
4397
|
//#endregion
|
|
4470
4398
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/compose/composer.js
|
|
4471
4399
|
var require_composer = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4664,7 +4592,6 @@ var require_composer = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
4664
4592
|
};
|
|
4665
4593
|
exports.Composer = Composer;
|
|
4666
4594
|
}));
|
|
4667
|
-
|
|
4668
4595
|
//#endregion
|
|
4669
4596
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-scalar.js
|
|
4670
4597
|
var require_cst_scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4932,7 +4859,6 @@ var require_cst_scalar = /* @__PURE__ */ require_chunk.__commonJSMin(((exports)
|
|
|
4932
4859
|
exports.resolveAsScalar = resolveAsScalar;
|
|
4933
4860
|
exports.setScalarValue = setScalarValue;
|
|
4934
4861
|
}));
|
|
4935
|
-
|
|
4936
4862
|
//#endregion
|
|
4937
4863
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-stringify.js
|
|
4938
4864
|
var require_cst_stringify = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -4984,7 +4910,6 @@ var require_cst_stringify = /* @__PURE__ */ require_chunk.__commonJSMin(((export
|
|
|
4984
4910
|
}
|
|
4985
4911
|
exports.stringify = stringify;
|
|
4986
4912
|
}));
|
|
4987
|
-
|
|
4988
4913
|
//#endregion
|
|
4989
4914
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst-visit.js
|
|
4990
4915
|
var require_cst_visit = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -5076,7 +5001,6 @@ var require_cst_visit = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =
|
|
|
5076
5001
|
}
|
|
5077
5002
|
exports.visit = visit;
|
|
5078
5003
|
}));
|
|
5079
|
-
|
|
5080
5004
|
//#endregion
|
|
5081
5005
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/cst.js
|
|
5082
5006
|
var require_cst = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -5156,7 +5080,6 @@ var require_cst = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
5156
5080
|
exports.prettyToken = prettyToken;
|
|
5157
5081
|
exports.tokenType = tokenType;
|
|
5158
5082
|
}));
|
|
5159
|
-
|
|
5160
5083
|
//#endregion
|
|
5161
5084
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/lexer.js
|
|
5162
5085
|
var require_lexer = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -5676,7 +5599,6 @@ var require_lexer = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
5676
5599
|
};
|
|
5677
5600
|
exports.Lexer = Lexer;
|
|
5678
5601
|
}));
|
|
5679
|
-
|
|
5680
5602
|
//#endregion
|
|
5681
5603
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/line-counter.js
|
|
5682
5604
|
var require_line_counter = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -5724,7 +5646,6 @@ var require_line_counter = /* @__PURE__ */ require_chunk.__commonJSMin(((exports
|
|
|
5724
5646
|
};
|
|
5725
5647
|
exports.LineCounter = LineCounter;
|
|
5726
5648
|
}));
|
|
5727
|
-
|
|
5728
5649
|
//#endregion
|
|
5729
5650
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/parse/parser.js
|
|
5730
5651
|
var require_parser = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -6581,7 +6502,6 @@ var require_parser = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
6581
6502
|
};
|
|
6582
6503
|
exports.Parser = Parser;
|
|
6583
6504
|
}));
|
|
6584
|
-
|
|
6585
6505
|
//#endregion
|
|
6586
6506
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/public-api.js
|
|
6587
6507
|
var require_public_api = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -6669,7 +6589,6 @@ var require_public_api = /* @__PURE__ */ require_chunk.__commonJSMin(((exports)
|
|
|
6669
6589
|
exports.parseDocument = parseDocument;
|
|
6670
6590
|
exports.stringify = stringify;
|
|
6671
6591
|
}));
|
|
6672
|
-
|
|
6673
6592
|
//#endregion
|
|
6674
6593
|
//#region ../../node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/index.js
|
|
6675
6594
|
var require_dist = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
@@ -6683,7 +6602,7 @@ var require_dist = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
6683
6602
|
var Scalar = require_Scalar();
|
|
6684
6603
|
var YAMLMap = require_YAMLMap();
|
|
6685
6604
|
var YAMLSeq = require_YAMLSeq();
|
|
6686
|
-
|
|
6605
|
+
require_cst();
|
|
6687
6606
|
var lexer = require_lexer();
|
|
6688
6607
|
var lineCounter = require_line_counter();
|
|
6689
6608
|
var parser = require_parser();
|
|
@@ -6718,7 +6637,6 @@ var require_dist = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
|
6718
6637
|
exports.visit = visit.visit;
|
|
6719
6638
|
exports.visitAsync = visit.visitAsync;
|
|
6720
6639
|
}));
|
|
6721
|
-
|
|
6722
6640
|
//#endregion
|
|
6723
6641
|
//#region src/highlight.ts
|
|
6724
6642
|
var import_dist = /* @__PURE__ */ require_chunk.__toESM(require_dist(), 1);
|
|
@@ -6751,15 +6669,23 @@ const BUILTIN_LANGS = [
|
|
|
6751
6669
|
"diff",
|
|
6752
6670
|
"toml"
|
|
6753
6671
|
];
|
|
6754
|
-
|
|
6672
|
+
const highlighterCache = /* @__PURE__ */ new Map();
|
|
6755
6673
|
/**
|
|
6756
6674
|
* Get or create the Shiki highlighter.
|
|
6757
6675
|
*/
|
|
6758
6676
|
async function getHighlighter(theme, customLangs = []) {
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
langs:
|
|
6677
|
+
const cacheKey = JSON.stringify({
|
|
6678
|
+
theme,
|
|
6679
|
+
langs: customLangs
|
|
6762
6680
|
});
|
|
6681
|
+
let highlighterPromise = highlighterCache.get(cacheKey);
|
|
6682
|
+
if (!highlighterPromise) {
|
|
6683
|
+
highlighterPromise = (0, shiki.createHighlighter)({
|
|
6684
|
+
themes: [theme],
|
|
6685
|
+
langs: [...BUILTIN_LANGS, ...customLangs]
|
|
6686
|
+
});
|
|
6687
|
+
highlighterCache.set(cacheKey, highlighterPromise);
|
|
6688
|
+
}
|
|
6763
6689
|
return highlighterPromise;
|
|
6764
6690
|
}
|
|
6765
6691
|
/**
|
|
@@ -6775,12 +6701,9 @@ function rehypeShikiHighlight(options) {
|
|
|
6775
6701
|
if (child.type === "element" && child.tagName === "pre") {
|
|
6776
6702
|
const codeElement = child.children.find((c) => c.type === "element" && c.tagName === "code");
|
|
6777
6703
|
if (codeElement) {
|
|
6778
|
-
const className = codeElement.properties?.className;
|
|
6779
6704
|
let lang = "text";
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
if (langClass && typeof langClass === "string") lang = langClass.replace("language-", "");
|
|
6783
|
-
}
|
|
6705
|
+
const langClass = normalizeClassName(codeElement.properties?.className).find((value) => value.startsWith("language-"));
|
|
6706
|
+
if (langClass) lang = langClass.replace("language-", "");
|
|
6784
6707
|
const codeText = getTextContent(codeElement);
|
|
6785
6708
|
try {
|
|
6786
6709
|
const highlighted = highlighter.codeToHtml(codeText, {
|
|
@@ -6788,7 +6711,12 @@ function rehypeShikiHighlight(options) {
|
|
|
6788
6711
|
theme
|
|
6789
6712
|
});
|
|
6790
6713
|
const parsed = (0, unified.unified)().use(rehype_parse.default, { fragment: true }).parse(highlighted);
|
|
6791
|
-
if (parsed.children[0]
|
|
6714
|
+
if (parsed.children[0]?.type === "element") {
|
|
6715
|
+
const highlightedPre = parsed.children[0];
|
|
6716
|
+
highlightedPre.properties ??= {};
|
|
6717
|
+
highlightedPre.properties["data-language"] = lang;
|
|
6718
|
+
node.children[i] = highlightedPre;
|
|
6719
|
+
}
|
|
6792
6720
|
} catch {}
|
|
6793
6721
|
}
|
|
6794
6722
|
} else if (child.type === "element") await visit(child);
|
|
@@ -6808,6 +6736,11 @@ function getTextContent(node) {
|
|
|
6808
6736
|
}
|
|
6809
6737
|
return text;
|
|
6810
6738
|
}
|
|
6739
|
+
function normalizeClassName(className) {
|
|
6740
|
+
if (Array.isArray(className)) return className.filter((value) => typeof value === "string");
|
|
6741
|
+
if (typeof className === "string" && className) return className.split(/\s+/).filter(Boolean);
|
|
6742
|
+
return [];
|
|
6743
|
+
}
|
|
6811
6744
|
/**
|
|
6812
6745
|
* Apply syntax highlighting to HTML using Shiki.
|
|
6813
6746
|
*/
|
|
@@ -6818,7 +6751,6 @@ async function highlightCode(html, theme = "github-dark", langs = []) {
|
|
|
6818
6751
|
}).use(rehype_stringify.default).process(html);
|
|
6819
6752
|
return String(result);
|
|
6820
6753
|
}
|
|
6821
|
-
|
|
6822
6754
|
//#endregion
|
|
6823
6755
|
//#region src/plugins/mermaid-protect.ts
|
|
6824
6756
|
/**
|
|
@@ -6871,7 +6803,6 @@ function restoreMermaidSvgs(html, svgs) {
|
|
|
6871
6803
|
for (const [placeholder, content] of svgs) result = result.replace(placeholder, content);
|
|
6872
6804
|
return result;
|
|
6873
6805
|
}
|
|
6874
|
-
|
|
6875
6806
|
//#endregion
|
|
6876
6807
|
//#region src/transform.ts
|
|
6877
6808
|
/**
|
|
@@ -6959,7 +6890,7 @@ async function loadNapiBindings() {
|
|
|
6959
6890
|
if (napiLoadAttempted) return napiBindings ?? null;
|
|
6960
6891
|
napiLoadAttempted = true;
|
|
6961
6892
|
try {
|
|
6962
|
-
const mod = await
|
|
6893
|
+
const mod = await require_mermaid.importNapiModule();
|
|
6963
6894
|
napiBindings = mod;
|
|
6964
6895
|
return mod;
|
|
6965
6896
|
} catch (error) {
|
|
@@ -6981,7 +6912,11 @@ async function transformMarkdown(source, filePath, options, ssgOptions) {
|
|
|
6981
6912
|
tocMaxDepth: options.tocMaxDepth,
|
|
6982
6913
|
convertMdLinks: ssgOptions?.convertMdLinks,
|
|
6983
6914
|
baseUrl: ssgOptions?.baseUrl,
|
|
6984
|
-
sourcePath: ssgOptions?.sourcePath ?? filePath
|
|
6915
|
+
sourcePath: ssgOptions?.sourcePath ?? filePath,
|
|
6916
|
+
codeAnnotations: options.codeAnnotations.enabled,
|
|
6917
|
+
codeAnnotationMetaKey: options.codeAnnotations.metaKey,
|
|
6918
|
+
codeAnnotationSyntax: options.codeAnnotations.notation,
|
|
6919
|
+
codeAnnotationDefaultLineNumbers: options.codeAnnotations.defaultLineNumbers
|
|
6985
6920
|
});
|
|
6986
6921
|
if (result.errors.length > 0) console.warn("[ox-content] Transform warnings:", result.errors);
|
|
6987
6922
|
let html = result.html;
|
|
@@ -6993,7 +6928,11 @@ async function transformMarkdown(source, filePath, options, ssgOptions) {
|
|
|
6993
6928
|
if (options.mermaid) html = await require_mermaid.transformMermaidStatic(html);
|
|
6994
6929
|
const { html: protectedHtml, svgs } = protectMermaidSvgs(html);
|
|
6995
6930
|
html = protectedHtml;
|
|
6996
|
-
if (options.highlight)
|
|
6931
|
+
if (options.highlight) {
|
|
6932
|
+
const originalHtml = html;
|
|
6933
|
+
const highlightedHtml = await highlightCode(html, options.highlightTheme, options.highlightLangs);
|
|
6934
|
+
html = napi.mergeHighlightedCodeBlocks(originalHtml, highlightedHtml);
|
|
6935
|
+
}
|
|
6997
6936
|
html = restoreMermaidSvgs(html, svgs);
|
|
6998
6937
|
return {
|
|
6999
6938
|
code: generateModuleCode(html, frontmatter, toc, filePath, options),
|
|
@@ -7089,7 +7028,6 @@ if (import.meta.hot) {
|
|
|
7089
7028
|
}
|
|
7090
7029
|
`;
|
|
7091
7030
|
}
|
|
7092
|
-
|
|
7093
7031
|
//#endregion
|
|
7094
7032
|
//#region src/nav-generator.ts
|
|
7095
7033
|
/**
|
|
@@ -7236,7 +7174,7 @@ function generateNavMetadata(docs, basePath = "/api") {
|
|
|
7236
7174
|
* @internal
|
|
7237
7175
|
*/
|
|
7238
7176
|
function getDocDisplayName(filePath) {
|
|
7239
|
-
const fileName = path
|
|
7177
|
+
const fileName = path.default.basename(filePath, path.default.extname(filePath));
|
|
7240
7178
|
if (fileName === "index" || fileName === "index-module") return "Overview";
|
|
7241
7179
|
return fileName.replace(/[-_]([a-z])/g, (_, char) => " " + char.toUpperCase()).replace(/^[a-z]/, (char) => char.toUpperCase());
|
|
7242
7180
|
}
|
|
@@ -7253,7 +7191,7 @@ function getDocDisplayName(filePath) {
|
|
|
7253
7191
|
* @internal
|
|
7254
7192
|
*/
|
|
7255
7193
|
function getDocFileName(filePath) {
|
|
7256
|
-
const fileName = path
|
|
7194
|
+
const fileName = path.default.basename(filePath, path.default.extname(filePath));
|
|
7257
7195
|
if (fileName === "index") return "index";
|
|
7258
7196
|
return fileName;
|
|
7259
7197
|
}
|
|
@@ -7328,7 +7266,6 @@ export interface NavItem {
|
|
|
7328
7266
|
export const ${exportName}: NavItem[] = ${JSON.stringify(navItems, null, 2)} as const;
|
|
7329
7267
|
`;
|
|
7330
7268
|
}
|
|
7331
|
-
|
|
7332
7269
|
//#endregion
|
|
7333
7270
|
//#region src/docs.ts
|
|
7334
7271
|
/**
|
|
@@ -7382,6 +7319,46 @@ export const ${exportName}: NavItem[] = ${JSON.stringify(navItems, null, 2)} as
|
|
|
7382
7319
|
* ```
|
|
7383
7320
|
*/
|
|
7384
7321
|
const DOCS_MANIFEST_FILE = ".ox-content-docs-manifest.json";
|
|
7322
|
+
const DOCS_DATA_FILE = "docs.json";
|
|
7323
|
+
function escapeHtml$3(str) {
|
|
7324
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7325
|
+
}
|
|
7326
|
+
function entryAnchor(name) {
|
|
7327
|
+
return name.toLowerCase();
|
|
7328
|
+
}
|
|
7329
|
+
function cleanSummaryText(text, maxLength = 120) {
|
|
7330
|
+
if (!text) return "";
|
|
7331
|
+
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
7332
|
+
if (collapsed.length <= maxLength) return collapsed;
|
|
7333
|
+
return `${collapsed.slice(0, maxLength - 1).trimEnd()}…`;
|
|
7334
|
+
}
|
|
7335
|
+
function renderInlineHtml(text) {
|
|
7336
|
+
let html = "";
|
|
7337
|
+
let lastIndex = 0;
|
|
7338
|
+
const tokenPattern = /`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)/g;
|
|
7339
|
+
let match;
|
|
7340
|
+
while ((match = tokenPattern.exec(text)) !== null) {
|
|
7341
|
+
html += escapeHtml$3(text.slice(lastIndex, match.index));
|
|
7342
|
+
if (match[1]) html += `<code>${escapeHtml$3(match[1])}</code>`;
|
|
7343
|
+
else if (match[2] && match[3]) html += `<a href="${escapeHtml$3(match[3])}">${escapeHtml$3(match[2])}</a>`;
|
|
7344
|
+
lastIndex = match.index + match[0].length;
|
|
7345
|
+
}
|
|
7346
|
+
html += escapeHtml$3(text.slice(lastIndex));
|
|
7347
|
+
return html.replace(/\n/g, "<br>");
|
|
7348
|
+
}
|
|
7349
|
+
function renderParagraphsHtml(text) {
|
|
7350
|
+
return text.split(/\n\s*\n/).map((paragraph) => paragraph.trim()).filter(Boolean).map((paragraph) => `<p>${renderInlineHtml(paragraph)}</p>`).join("\n");
|
|
7351
|
+
}
|
|
7352
|
+
function renderCodeBlockHtml(code, language = "typescript") {
|
|
7353
|
+
return `<pre><code class="language-${language}">${escapeHtml$3(code)}</code></pre>`;
|
|
7354
|
+
}
|
|
7355
|
+
function buildDocsData(docs) {
|
|
7356
|
+
return {
|
|
7357
|
+
version: 1,
|
|
7358
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7359
|
+
modules: docs
|
|
7360
|
+
};
|
|
7361
|
+
}
|
|
7385
7362
|
/**
|
|
7386
7363
|
* Regex pattern for matching JSDoc comment blocks.
|
|
7387
7364
|
*
|
|
@@ -7486,7 +7463,7 @@ async function findFiles(dir, options) {
|
|
|
7486
7463
|
return;
|
|
7487
7464
|
}
|
|
7488
7465
|
for (const entry of entries) {
|
|
7489
|
-
const fullPath = path
|
|
7466
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
7490
7467
|
if (entry.isDirectory()) {
|
|
7491
7468
|
if (!isExcluded(fullPath, options.exclude)) await walk(fullPath);
|
|
7492
7469
|
} else if (entry.isFile()) {
|
|
@@ -7742,7 +7719,7 @@ function generateMarkdown(docs, options) {
|
|
|
7742
7719
|
if (options.groupBy === "file") {
|
|
7743
7720
|
const docToFile = /* @__PURE__ */ new Map();
|
|
7744
7721
|
for (const doc of docs) {
|
|
7745
|
-
let fileName = path
|
|
7722
|
+
let fileName = path.basename(doc.file, path.extname(doc.file));
|
|
7746
7723
|
if (fileName === "index") fileName = "index-module";
|
|
7747
7724
|
docToFile.set(doc, fileName);
|
|
7748
7725
|
const markdown = generateFileMarkdown(doc, options, fileName, symbolMap);
|
|
@@ -7762,74 +7739,132 @@ function generateMarkdown(docs, options) {
|
|
|
7762
7739
|
return result;
|
|
7763
7740
|
}
|
|
7764
7741
|
function generateFileMarkdown(doc, options, currentFileName, symbolMap) {
|
|
7765
|
-
let md = `# ${path
|
|
7742
|
+
let md = `# ${path.basename(doc.file)}\n\n`;
|
|
7766
7743
|
if (options.githubUrl) {
|
|
7767
7744
|
const sourceLink = generateSourceLink(doc.file, options.githubUrl);
|
|
7768
7745
|
if (sourceLink) md += sourceLink + "\n\n";
|
|
7769
7746
|
}
|
|
7747
|
+
md += `> ${doc.entries.length} documented symbol${doc.entries.length === 1 ? "" : "s"}. `;
|
|
7748
|
+
md += "Skim the one-line surface first, then expand the accordions for details.\n\n";
|
|
7749
|
+
md += "## Overview\n\n";
|
|
7750
|
+
for (const entry of doc.entries) md += renderOverviewLine(entry, `#${entryAnchor(entry.name)}`);
|
|
7751
|
+
md += "\n## Reference\n\n";
|
|
7770
7752
|
for (const entry of doc.entries) md += generateEntryMarkdown(entry, options, currentFileName, symbolMap);
|
|
7771
7753
|
return md;
|
|
7772
7754
|
}
|
|
7755
|
+
function normalizeSignature(signature) {
|
|
7756
|
+
if (!signature) return;
|
|
7757
|
+
return signature.replace(/\s+/g, " ").replace(/^export\s+/, "").replace(/^async\s+function\s+/, "").replace(/^function\s+/, "").replace(/^class\s+/, "").trim();
|
|
7758
|
+
}
|
|
7759
|
+
function renderOverviewLine(entry, href) {
|
|
7760
|
+
const signature = normalizeSignature(entry.signature);
|
|
7761
|
+
const summary = cleanSummaryText(entry.description, 88);
|
|
7762
|
+
const parts = [`- [\`${entry.name}\`](${href})`, `\`${entry.kind}\``];
|
|
7763
|
+
if (signature) parts.push(`\`${signature}\``);
|
|
7764
|
+
if (summary) parts.push(`- ${summary}`);
|
|
7765
|
+
return `${parts.join(" ")}\n`;
|
|
7766
|
+
}
|
|
7767
|
+
function renderOverviewHtmlItem(entry, href) {
|
|
7768
|
+
const signature = normalizeSignature(entry.signature);
|
|
7769
|
+
const summary = cleanSummaryText(entry.description, 88);
|
|
7770
|
+
const fragments = [`<a href="${escapeHtml$3(href)}"><code>${escapeHtml$3(entry.name)}</code></a>`, `<span class="ox-api-module__kind">${escapeHtml$3(entry.kind)}</span>`];
|
|
7771
|
+
if (signature) fragments.push(`<code>${escapeHtml$3(signature)}</code>`);
|
|
7772
|
+
if (summary) fragments.push(`<span>${renderInlineHtml(summary)}</span>`);
|
|
7773
|
+
return `<li>${fragments.join("")}</li>`;
|
|
7774
|
+
}
|
|
7775
|
+
function renderParamsTableHtml(params) {
|
|
7776
|
+
return `<div class="ox-api-entry__section">
|
|
7777
|
+
<h4>Parameters</h4>
|
|
7778
|
+
<table>
|
|
7779
|
+
<thead>
|
|
7780
|
+
<tr><th>Name</th><th>Type</th><th>Description</th></tr>
|
|
7781
|
+
</thead>
|
|
7782
|
+
<tbody>
|
|
7783
|
+
${params.map((param) => {
|
|
7784
|
+
const flags = [param.optional ? "optional" : "", param.default ? `default: ${param.default}` : ""].filter(Boolean);
|
|
7785
|
+
const description = [param.description, flags.join(" · ")].filter(Boolean).join(" — ");
|
|
7786
|
+
return `<tr>
|
|
7787
|
+
<td><code>${escapeHtml$3(param.name)}</code></td>
|
|
7788
|
+
<td><code>${escapeHtml$3(param.type)}</code></td>
|
|
7789
|
+
<td>${renderInlineHtml(description)}</td>
|
|
7790
|
+
</tr>`;
|
|
7791
|
+
}).join("\n")}
|
|
7792
|
+
</tbody>
|
|
7793
|
+
</table>
|
|
7794
|
+
</div>`;
|
|
7795
|
+
}
|
|
7796
|
+
function renderTagListHtml(tags) {
|
|
7797
|
+
return `<div class="ox-api-entry__section">
|
|
7798
|
+
<h4>Tags</h4>
|
|
7799
|
+
<ul class="ox-api-entry__tags">${Object.entries(tags).map(([tag, value]) => `<li><span class="ox-api-entry__tag-name">@${escapeHtml$3(tag)}</span><span>${renderInlineHtml(value)}</span></li>`).join("")}</ul>
|
|
7800
|
+
</div>`;
|
|
7801
|
+
}
|
|
7773
7802
|
function generateEntryMarkdown(entry, options, currentFileName, symbolMap) {
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
}
|
|
7780
|
-
if (
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
md += entry.signature + "\n";
|
|
7787
|
-
md += "```\n\n";
|
|
7788
|
-
}
|
|
7789
|
-
if (entry.params && entry.params.length > 0) {
|
|
7790
|
-
md += "### Parameters\n\n";
|
|
7791
|
-
md += "| Name | Type | Description |\n";
|
|
7792
|
-
md += "|------|------|-------------|\n";
|
|
7793
|
-
for (const param of entry.params) md += `| \`${param.name}\` | \`${param.type}\` | ${param.description} |\n`;
|
|
7794
|
-
md += "\n";
|
|
7795
|
-
}
|
|
7796
|
-
if (entry.returns) {
|
|
7797
|
-
md += "### Returns\n\n";
|
|
7798
|
-
md += `\`${entry.returns.type}\` - ${entry.returns.description}\n\n`;
|
|
7799
|
-
}
|
|
7803
|
+
const processedDescription = entry.description && currentFileName && symbolMap ? convertSymbolLinks(entry.description, currentFileName, symbolMap) : entry.description;
|
|
7804
|
+
const summarySignature = normalizeSignature(entry.signature);
|
|
7805
|
+
const sourceHref = options?.githubUrl ? generateSourceHref(entry.file, options.githubUrl, entry.line) : void 0;
|
|
7806
|
+
let body = "";
|
|
7807
|
+
if (processedDescription) body += renderParagraphsHtml(processedDescription) + "\n";
|
|
7808
|
+
if (sourceHref) body += `<p class="ox-api-entry__source"><a href="${escapeHtml$3(sourceHref)}">View source</a></p>\n`;
|
|
7809
|
+
if (entry.signature) body += `<div class="ox-api-entry__section">\n<h4>Signature</h4>\n${renderCodeBlockHtml(entry.signature)}\n</div>\n`;
|
|
7810
|
+
if (entry.params && entry.params.length > 0) body += renderParamsTableHtml(entry.params) + "\n";
|
|
7811
|
+
if (entry.returns) body += `<div class="ox-api-entry__section">
|
|
7812
|
+
<h4>Returns</h4>
|
|
7813
|
+
<p><code>${escapeHtml$3(entry.returns.type)}</code>${entry.returns.description ? ` — ${renderInlineHtml(entry.returns.description)}` : ""}</p>
|
|
7814
|
+
</div>\n`;
|
|
7800
7815
|
if (entry.examples && entry.examples.length > 0) {
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
}
|
|
7808
|
-
|
|
7809
|
-
return
|
|
7816
|
+
const examplesHtml = entry.examples.map((example) => example.replace(/^```\w*\n?/, "").replace(/\n?```$/, "")).map((example) => renderCodeBlockHtml(example, "ts")).join("\n");
|
|
7817
|
+
body += `<div class="ox-api-entry__section">\n<h4>Examples</h4>\n${examplesHtml}\n</div>\n`;
|
|
7818
|
+
}
|
|
7819
|
+
if (entry.tags && Object.keys(entry.tags).length > 0) body += renderTagListHtml(entry.tags) + "\n";
|
|
7820
|
+
const summaryDescription = cleanSummaryText(processedDescription, summarySignature ? 80 : 120);
|
|
7821
|
+
const summaryParts = [`<span class="ox-api-entry__kind">${escapeHtml$3(entry.kind)}</span>`, `<code class="ox-api-entry__name">${escapeHtml$3(entry.name)}</code>`];
|
|
7822
|
+
if (summarySignature) summaryParts.push(`<code class="ox-api-entry__signature">${escapeHtml$3(summarySignature)}</code>`);
|
|
7823
|
+
if (summaryDescription) summaryParts.push(`<span class="ox-api-entry__description">${renderInlineHtml(summaryDescription)}</span>`);
|
|
7824
|
+
return `<details id="${entryAnchor(entry.name)}" class="ox-api-entry">
|
|
7825
|
+
<summary>${summaryParts.join("")}</summary>
|
|
7826
|
+
<div class="ox-api-entry__body">
|
|
7827
|
+
${body.trim()}
|
|
7828
|
+
</div>
|
|
7829
|
+
</details>
|
|
7830
|
+
|
|
7831
|
+
`;
|
|
7810
7832
|
}
|
|
7811
7833
|
function generateIndex(docs, docToFile) {
|
|
7812
7834
|
let md = "# API Documentation\n\n";
|
|
7813
7835
|
md += "Generated by [Ox Content](https://github.com/ubugeeei/ox-content)\n\n";
|
|
7836
|
+
md += "> Use search scopes like `@api transform` to limit results to the generated API reference.\n\n";
|
|
7814
7837
|
md += "## Modules\n\n";
|
|
7815
7838
|
for (const doc of docs) {
|
|
7816
|
-
const displayName = path
|
|
7839
|
+
const displayName = path.basename(doc.file, path.extname(doc.file));
|
|
7817
7840
|
let fileName = displayName;
|
|
7818
7841
|
if (docToFile && docToFile.has(doc)) fileName = docToFile.get(doc);
|
|
7819
7842
|
else if (fileName === "index") fileName = "index-module";
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7843
|
+
const countLabel = `${doc.entries.length} symbol${doc.entries.length === 1 ? "" : "s"}`;
|
|
7844
|
+
md += `<details class="ox-api-module">
|
|
7845
|
+
<summary>
|
|
7846
|
+
<span class="ox-api-module__title"><a href="./${fileName}.md">${escapeHtml$3(displayName)}</a></span>
|
|
7847
|
+
<span class="ox-api-module__count">${countLabel}</span>
|
|
7848
|
+
</summary>
|
|
7849
|
+
<div class="ox-api-module__body">
|
|
7850
|
+
<ul class="ox-api-module__list">
|
|
7851
|
+
`;
|
|
7852
|
+
for (const entry of doc.entries) md += ` ${renderOverviewHtmlItem(entry, `./${fileName}.md#${entryAnchor(entry.name)}`)}\n`;
|
|
7853
|
+
md += ` </ul>
|
|
7854
|
+
</div>
|
|
7855
|
+
</details>
|
|
7856
|
+
|
|
7857
|
+
`;
|
|
7827
7858
|
}
|
|
7828
7859
|
return md;
|
|
7829
7860
|
}
|
|
7830
7861
|
function generateCategoryMarkdown(kind, entries, options, symbolMap) {
|
|
7831
7862
|
const categoryFileName = `${kind}s`;
|
|
7832
7863
|
let md = `# ${kind.charAt(0).toUpperCase() + kind.slice(1)}s\n\n`;
|
|
7864
|
+
md += `> ${entries.length} documented ${kind}${entries.length === 1 ? "" : "s"} collected across modules.\n\n`;
|
|
7865
|
+
md += "## Overview\n\n";
|
|
7866
|
+
for (const entry of entries) md += renderOverviewLine(entry, `#${entryAnchor(entry.name)}`);
|
|
7867
|
+
md += "\n## Reference\n\n";
|
|
7833
7868
|
for (const entry of entries) md += generateEntryMarkdown(entry, options, categoryFileName, symbolMap);
|
|
7834
7869
|
return md;
|
|
7835
7870
|
}
|
|
@@ -7839,10 +7874,8 @@ function generateCategoryIndex(byKind) {
|
|
|
7839
7874
|
for (const [kind, entries] of byKind) {
|
|
7840
7875
|
const kindTitle = kind.charAt(0).toUpperCase() + kind.slice(1) + "s";
|
|
7841
7876
|
md += `## [${kindTitle}](./${kind}s.md)\n\n`;
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
md += `- **${entry.name}** - ${desc}...\n`;
|
|
7845
|
-
}
|
|
7877
|
+
md += `> ${entries.length} item${entries.length === 1 ? "" : "s"}.\n\n`;
|
|
7878
|
+
for (const entry of entries) md += renderOverviewLine(entry, `./${kind}s.md#${entryAnchor(entry.name)}`);
|
|
7846
7879
|
md += "\n";
|
|
7847
7880
|
}
|
|
7848
7881
|
return md;
|
|
@@ -7883,7 +7916,7 @@ function convertSymbolLinks(text, currentFileName, symbolMap) {
|
|
|
7883
7916
|
function buildSymbolMap(docs) {
|
|
7884
7917
|
const map = /* @__PURE__ */ new Map();
|
|
7885
7918
|
for (const doc of docs) {
|
|
7886
|
-
let fileName = path
|
|
7919
|
+
let fileName = path.basename(doc.file, path.extname(doc.file));
|
|
7887
7920
|
if (fileName === "index") fileName = "index-module";
|
|
7888
7921
|
for (const entry of doc.entries) map.set(entry.name, {
|
|
7889
7922
|
name: entry.name,
|
|
@@ -7900,7 +7933,8 @@ async function writeDocs(docs, outDir, extractedDocs, options) {
|
|
|
7900
7933
|
await fs.promises.mkdir(outDir, { recursive: true });
|
|
7901
7934
|
const generatedFiles = new Set(Object.keys(docs));
|
|
7902
7935
|
if (extractedDocs && options?.generateNav && options.groupBy === "file") generatedFiles.add("nav.ts");
|
|
7903
|
-
|
|
7936
|
+
if (extractedDocs) generatedFiles.add(DOCS_DATA_FILE);
|
|
7937
|
+
const manifestPath = path.join(outDir, DOCS_MANIFEST_FILE);
|
|
7904
7938
|
let previousFiles = [];
|
|
7905
7939
|
try {
|
|
7906
7940
|
previousFiles = JSON.parse(await fs.promises.readFile(manifestPath, "utf-8"));
|
|
@@ -7909,17 +7943,18 @@ async function writeDocs(docs, outDir, extractedDocs, options) {
|
|
|
7909
7943
|
}
|
|
7910
7944
|
for (const staleFile of previousFiles) {
|
|
7911
7945
|
if (generatedFiles.has(staleFile)) continue;
|
|
7912
|
-
await fs.promises.rm(path
|
|
7946
|
+
await fs.promises.rm(path.join(outDir, staleFile), { force: true });
|
|
7913
7947
|
}
|
|
7914
7948
|
for (const [fileName, content] of Object.entries(docs)) {
|
|
7915
|
-
const filePath = path
|
|
7949
|
+
const filePath = path.join(outDir, fileName);
|
|
7916
7950
|
await fs.promises.writeFile(filePath, content, "utf-8");
|
|
7917
7951
|
}
|
|
7918
7952
|
if (extractedDocs && options?.generateNav && options.groupBy === "file") {
|
|
7919
7953
|
const navCode = generateNavCode(generateNavMetadata(extractedDocs, "/api"), "apiNav");
|
|
7920
|
-
const navFilePath = path
|
|
7954
|
+
const navFilePath = path.join(outDir, "nav.ts");
|
|
7921
7955
|
await fs.promises.writeFile(navFilePath, navCode, "utf-8");
|
|
7922
7956
|
}
|
|
7957
|
+
if (extractedDocs) await fs.promises.writeFile(path.join(outDir, DOCS_DATA_FILE), JSON.stringify(buildDocsData(extractedDocs), null, 2), "utf-8");
|
|
7923
7958
|
await fs.promises.writeFile(manifestPath, JSON.stringify([...generatedFiles].sort(), null, 2), "utf-8");
|
|
7924
7959
|
}
|
|
7925
7960
|
/**
|
|
@@ -7931,10 +7966,13 @@ async function writeDocs(docs, outDir, extractedDocs, options) {
|
|
|
7931
7966
|
* @param filePath - Full path to the source file
|
|
7932
7967
|
* @param githubUrl - Base GitHub repository URL
|
|
7933
7968
|
* @param lineNumber - Optional line number to link to
|
|
7934
|
-
* @returns
|
|
7969
|
+
* @returns Absolute GitHub URL to source code
|
|
7935
7970
|
*/
|
|
7971
|
+
function generateSourceHref(filePath, githubUrl, lineNumber) {
|
|
7972
|
+
return `${githubUrl}/blob/main/${filePath.replace(/^.*?\/(npm|packages|crates|src)\//, "$1/")}${lineNumber ? `#L${lineNumber}` : ""}`;
|
|
7973
|
+
}
|
|
7936
7974
|
function generateSourceLink(filePath, githubUrl, lineNumber) {
|
|
7937
|
-
return `**[Source](${
|
|
7975
|
+
return `**[Source](${generateSourceHref(filePath, githubUrl, lineNumber)})**`;
|
|
7938
7976
|
}
|
|
7939
7977
|
function resolveDocsOptions(options) {
|
|
7940
7978
|
if (options === false) return false;
|
|
@@ -7957,7 +7995,6 @@ function resolveDocsOptions(options) {
|
|
|
7957
7995
|
generateNav: opts.generateNav ?? true
|
|
7958
7996
|
};
|
|
7959
7997
|
}
|
|
7960
|
-
|
|
7961
7998
|
//#endregion
|
|
7962
7999
|
//#region src/og-image/renderer.ts
|
|
7963
8000
|
/**
|
|
@@ -8002,10 +8039,10 @@ async function renderHtmlToPng(page, html, width, height, publicDir) {
|
|
|
8002
8039
|
await route.continue();
|
|
8003
8040
|
return;
|
|
8004
8041
|
}
|
|
8005
|
-
const filePath = path
|
|
8042
|
+
const filePath = path.join(publicDir, url.pathname);
|
|
8006
8043
|
try {
|
|
8007
8044
|
const body = await fs.readFile(filePath);
|
|
8008
|
-
const ext = path
|
|
8045
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
8009
8046
|
await route.fulfill({
|
|
8010
8047
|
body,
|
|
8011
8048
|
contentType: {
|
|
@@ -8040,7 +8077,6 @@ async function renderHtmlToPng(page, html, width, height, publicDir) {
|
|
|
8040
8077
|
});
|
|
8041
8078
|
return Buffer.from(screenshot);
|
|
8042
8079
|
}
|
|
8043
|
-
|
|
8044
8080
|
//#endregion
|
|
8045
8081
|
//#region src/og-image/browser.ts
|
|
8046
8082
|
/**
|
|
@@ -8086,7 +8122,6 @@ async function openBrowser() {
|
|
|
8086
8122
|
return null;
|
|
8087
8123
|
}
|
|
8088
8124
|
}
|
|
8089
|
-
|
|
8090
8125
|
//#endregion
|
|
8091
8126
|
//#region src/og-image/template.ts
|
|
8092
8127
|
/**
|
|
@@ -8116,7 +8151,6 @@ function getDefaultTemplate() {
|
|
|
8116
8151
|
</div>`;
|
|
8117
8152
|
};
|
|
8118
8153
|
}
|
|
8119
|
-
|
|
8120
8154
|
//#endregion
|
|
8121
8155
|
//#region src/og-image/cache.ts
|
|
8122
8156
|
/**
|
|
@@ -8142,7 +8176,7 @@ function computeCacheKey(templateSource, props, width, height) {
|
|
|
8142
8176
|
* Returns the cached file path if found, null otherwise.
|
|
8143
8177
|
*/
|
|
8144
8178
|
async function getCached(cacheDir, key) {
|
|
8145
|
-
const filePath = path
|
|
8179
|
+
const filePath = path.join(cacheDir, `${key}.png`);
|
|
8146
8180
|
try {
|
|
8147
8181
|
return await fs_promises.readFile(filePath);
|
|
8148
8182
|
} catch {
|
|
@@ -8154,12 +8188,11 @@ async function getCached(cacheDir, key) {
|
|
|
8154
8188
|
*/
|
|
8155
8189
|
async function writeCache(cacheDir, key, png) {
|
|
8156
8190
|
await fs_promises.mkdir(cacheDir, { recursive: true });
|
|
8157
|
-
const filePath = path
|
|
8191
|
+
const filePath = path.join(cacheDir, `${key}.png`);
|
|
8158
8192
|
await fs_promises.writeFile(filePath, png);
|
|
8159
8193
|
}
|
|
8160
|
-
|
|
8161
8194
|
//#endregion
|
|
8162
|
-
//#region \0@oxc-project+runtime@0.
|
|
8195
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/usingCtx.js
|
|
8163
8196
|
function _usingCtx() {
|
|
8164
8197
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
8165
8198
|
var n = Error();
|
|
@@ -8214,7 +8247,6 @@ function _usingCtx() {
|
|
|
8214
8247
|
}
|
|
8215
8248
|
};
|
|
8216
8249
|
}
|
|
8217
|
-
|
|
8218
8250
|
//#endregion
|
|
8219
8251
|
//#region src/og-image/index.ts
|
|
8220
8252
|
/**
|
|
@@ -8247,14 +8279,14 @@ function resolveOgImageOptions(options) {
|
|
|
8247
8279
|
*/
|
|
8248
8280
|
async function resolveTemplate(options, root) {
|
|
8249
8281
|
if (!options.template) return getDefaultTemplate();
|
|
8250
|
-
const templatePath = path
|
|
8282
|
+
const templatePath = path.resolve(root, options.template);
|
|
8251
8283
|
const fs = await import("fs/promises");
|
|
8252
8284
|
try {
|
|
8253
8285
|
await fs.access(templatePath);
|
|
8254
8286
|
} catch {
|
|
8255
8287
|
throw new Error(`[ox-content:og-image] Template file not found: ${templatePath}`);
|
|
8256
8288
|
}
|
|
8257
|
-
switch (path
|
|
8289
|
+
switch (path.extname(templatePath).toLowerCase()) {
|
|
8258
8290
|
case ".vue": return resolveVueTemplate(templatePath, options, root);
|
|
8259
8291
|
case ".svelte": return resolveSvelteTemplate(templatePath, root);
|
|
8260
8292
|
case ".tsx":
|
|
@@ -8268,9 +8300,9 @@ async function resolveTemplate(options, root) {
|
|
|
8268
8300
|
async function resolveTsTemplate(templatePath, options, root) {
|
|
8269
8301
|
const fs = await import("fs/promises");
|
|
8270
8302
|
const { rolldown } = await import("rolldown");
|
|
8271
|
-
const cacheDir = path
|
|
8303
|
+
const cacheDir = path.join(root, ".cache", "og-images");
|
|
8272
8304
|
await fs.mkdir(cacheDir, { recursive: true });
|
|
8273
|
-
const outfile = path
|
|
8305
|
+
const outfile = path.join(cacheDir, "_template.mjs");
|
|
8274
8306
|
const bundle = await rolldown({
|
|
8275
8307
|
input: templatePath,
|
|
8276
8308
|
platform: "node"
|
|
@@ -8293,9 +8325,9 @@ async function resolveTsTemplate(templatePath, options, root) {
|
|
|
8293
8325
|
async function resolveVueTemplate(templatePath, options, root) {
|
|
8294
8326
|
const fs = await import("fs/promises");
|
|
8295
8327
|
const { rolldown } = await import("rolldown");
|
|
8296
|
-
const cacheDir = path
|
|
8328
|
+
const cacheDir = path.join(root, ".cache", "og-images");
|
|
8297
8329
|
await fs.mkdir(cacheDir, { recursive: true });
|
|
8298
|
-
const outfile = path
|
|
8330
|
+
const outfile = path.join(cacheDir, "_template_vue.mjs");
|
|
8299
8331
|
const bundle = await rolldown({
|
|
8300
8332
|
input: templatePath,
|
|
8301
8333
|
platform: "node",
|
|
@@ -8391,9 +8423,9 @@ async function getVizejsPlugin() {
|
|
|
8391
8423
|
async function resolveSvelteTemplate(templatePath, root) {
|
|
8392
8424
|
const fs = await import("fs/promises");
|
|
8393
8425
|
const { rolldown } = await import("rolldown");
|
|
8394
|
-
const cacheDir = path
|
|
8426
|
+
const cacheDir = path.join(root, ".cache", "og-images");
|
|
8395
8427
|
await fs.mkdir(cacheDir, { recursive: true });
|
|
8396
|
-
const outfile = path
|
|
8428
|
+
const outfile = path.join(cacheDir, "_template_svelte.mjs");
|
|
8397
8429
|
const bundle = await rolldown({
|
|
8398
8430
|
input: templatePath,
|
|
8399
8431
|
platform: "node",
|
|
@@ -8449,9 +8481,9 @@ function createSvelteCompilerPlugin() {
|
|
|
8449
8481
|
async function resolveReactTemplate(templatePath, root) {
|
|
8450
8482
|
const fs = await import("fs/promises");
|
|
8451
8483
|
const { rolldown } = await import("rolldown");
|
|
8452
|
-
const cacheDir = path
|
|
8484
|
+
const cacheDir = path.join(root, ".cache", "og-images");
|
|
8453
8485
|
await fs.mkdir(cacheDir, { recursive: true });
|
|
8454
|
-
const outfile = path
|
|
8486
|
+
const outfile = path.join(cacheDir, "_template_react.mjs");
|
|
8455
8487
|
const bundle = await rolldown({
|
|
8456
8488
|
input: templatePath,
|
|
8457
8489
|
platform: "node",
|
|
@@ -8501,7 +8533,7 @@ async function resolveReactTemplate(templatePath, root) {
|
|
|
8501
8533
|
async function computeTemplateSource(options, root) {
|
|
8502
8534
|
if (!options.template) return "__default__";
|
|
8503
8535
|
const fs = await import("fs/promises");
|
|
8504
|
-
const templatePath = path
|
|
8536
|
+
const templatePath = path.resolve(root, options.template);
|
|
8505
8537
|
const content = await fs.readFile(templatePath, "utf-8");
|
|
8506
8538
|
return crypto.createHash("sha256").update(content).digest("hex");
|
|
8507
8539
|
}
|
|
@@ -8519,7 +8551,7 @@ async function generateOgImages(pages, options, root) {
|
|
|
8519
8551
|
if (pages.length === 0) return [];
|
|
8520
8552
|
const templateFn = await resolveTemplate(options, root);
|
|
8521
8553
|
const templateSource = await computeTemplateSource(options, root);
|
|
8522
|
-
const cacheDir = path
|
|
8554
|
+
const cacheDir = path.join(root, ".cache", "og-images");
|
|
8523
8555
|
if (options.cache) {
|
|
8524
8556
|
const allCached = await tryServeAllFromCache(pages, templateSource, options, cacheDir);
|
|
8525
8557
|
if (allCached) return allCached;
|
|
@@ -8531,7 +8563,7 @@ async function generateOgImages(pages, options, root) {
|
|
|
8531
8563
|
error: "Chromium not available"
|
|
8532
8564
|
}));
|
|
8533
8565
|
const results = [];
|
|
8534
|
-
const publicDir = path
|
|
8566
|
+
const publicDir = path.join(root, "public");
|
|
8535
8567
|
const concurrency = Math.max(1, options.concurrency);
|
|
8536
8568
|
for (let i = 0; i < pages.length; i += concurrency) {
|
|
8537
8569
|
const batch = pages.slice(i, i + concurrency);
|
|
@@ -8555,7 +8587,7 @@ async function tryServeAllFromCache(pages, templateSource, options, cacheDir) {
|
|
|
8555
8587
|
for (const entry of pages) {
|
|
8556
8588
|
const cached = await getCached(cacheDir, computeCacheKey(templateSource, entry.props, options.width, options.height));
|
|
8557
8589
|
if (!cached) return null;
|
|
8558
|
-
await fs.mkdir(path
|
|
8590
|
+
await fs.mkdir(path.dirname(entry.outputPath), { recursive: true });
|
|
8559
8591
|
await fs.writeFile(entry.outputPath, cached);
|
|
8560
8592
|
results.push({
|
|
8561
8593
|
outputPath: entry.outputPath,
|
|
@@ -8573,7 +8605,7 @@ async function renderSinglePage(entry, templateFn, templateSource, options, cach
|
|
|
8573
8605
|
if (options.cache) {
|
|
8574
8606
|
const cached = await getCached(cacheDir, computeCacheKey(templateSource, entry.props, options.width, options.height));
|
|
8575
8607
|
if (cached) {
|
|
8576
|
-
await fs.mkdir(path
|
|
8608
|
+
await fs.mkdir(path.dirname(entry.outputPath), { recursive: true });
|
|
8577
8609
|
await fs.writeFile(entry.outputPath, cached);
|
|
8578
8610
|
return {
|
|
8579
8611
|
outputPath: entry.outputPath,
|
|
@@ -8583,7 +8615,7 @@ async function renderSinglePage(entry, templateFn, templateSource, options, cach
|
|
|
8583
8615
|
}
|
|
8584
8616
|
const html = await templateFn(entry.props);
|
|
8585
8617
|
const png = await session.renderPage(html, options.width, options.height, publicDir);
|
|
8586
|
-
await fs.mkdir(path
|
|
8618
|
+
await fs.mkdir(path.dirname(entry.outputPath), { recursive: true });
|
|
8587
8619
|
await fs.writeFile(entry.outputPath, png);
|
|
8588
8620
|
if (options.cache) await writeCache(cacheDir, computeCacheKey(templateSource, entry.props, options.width, options.height), png);
|
|
8589
8621
|
return {
|
|
@@ -8598,7 +8630,6 @@ async function renderSinglePage(entry, templateFn, templateSource, options, cach
|
|
|
8598
8630
|
};
|
|
8599
8631
|
}
|
|
8600
8632
|
}
|
|
8601
|
-
|
|
8602
8633
|
//#endregion
|
|
8603
8634
|
//#region src/plugins/index.ts
|
|
8604
8635
|
/**
|
|
@@ -8608,28 +8639,27 @@ async function transformAllPlugins(html, options = {}) {
|
|
|
8608
8639
|
const { tabs = true, youtube = true, github = true, ogp = true, mermaid = true, githubToken } = options;
|
|
8609
8640
|
let result = html;
|
|
8610
8641
|
if (tabs) {
|
|
8611
|
-
const { transformTabs } = await Promise.resolve().then(() => require("./tabs.cjs"));
|
|
8642
|
+
const { transformTabs } = await Promise.resolve().then(() => require("./tabs.cjs")).then((n) => n.tabs_exports);
|
|
8612
8643
|
result = await transformTabs(result);
|
|
8613
8644
|
}
|
|
8614
8645
|
if (youtube) {
|
|
8615
|
-
const { transformYouTube } = await Promise.resolve().then(() => require("./youtube.cjs"));
|
|
8646
|
+
const { transformYouTube } = await Promise.resolve().then(() => require("./youtube.cjs")).then((n) => n.youtube_exports);
|
|
8616
8647
|
result = await transformYouTube(result);
|
|
8617
8648
|
}
|
|
8618
8649
|
if (github) {
|
|
8619
|
-
const { transformGitHub } = await Promise.resolve().then(() => require("./github.cjs"));
|
|
8650
|
+
const { transformGitHub } = await Promise.resolve().then(() => require("./github.cjs")).then((n) => n.github_exports);
|
|
8620
8651
|
result = await transformGitHub(result, void 0, { token: githubToken });
|
|
8621
8652
|
}
|
|
8622
8653
|
if (ogp) {
|
|
8623
|
-
const { transformOgp } = await Promise.resolve().then(() => require("./ogp.cjs"));
|
|
8654
|
+
const { transformOgp } = await Promise.resolve().then(() => require("./ogp.cjs")).then((n) => n.ogp_exports);
|
|
8624
8655
|
result = await transformOgp(result);
|
|
8625
8656
|
}
|
|
8626
8657
|
if (mermaid) {
|
|
8627
|
-
const { transformMermaidStatic } = await Promise.resolve().then(() => require("./mermaid.cjs"));
|
|
8658
|
+
const { transformMermaidStatic } = await Promise.resolve().then(() => require("./mermaid.cjs")).then((n) => n.mermaid_exports);
|
|
8628
8659
|
result = await transformMermaidStatic(result);
|
|
8629
8660
|
}
|
|
8630
8661
|
return result;
|
|
8631
8662
|
}
|
|
8632
|
-
|
|
8633
8663
|
//#endregion
|
|
8634
8664
|
//#region src/island/parse.ts
|
|
8635
8665
|
/**
|
|
@@ -8821,7 +8851,6 @@ initIslands((el, props) => {
|
|
|
8821
8851
|
});
|
|
8822
8852
|
`;
|
|
8823
8853
|
}
|
|
8824
|
-
|
|
8825
8854
|
//#endregion
|
|
8826
8855
|
//#region src/theme.ts
|
|
8827
8856
|
/**
|
|
@@ -9004,7 +9033,6 @@ function themeToNapi(theme) {
|
|
|
9004
9033
|
js: theme.js || void 0
|
|
9005
9034
|
};
|
|
9006
9035
|
}
|
|
9007
|
-
|
|
9008
9036
|
//#endregion
|
|
9009
9037
|
//#region src/ssg.ts
|
|
9010
9038
|
/**
|
|
@@ -9047,6 +9075,11 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9047
9075
|
--color-primary-hover: #ce5937;
|
|
9048
9076
|
--color-code-bg: #1e293b;
|
|
9049
9077
|
--color-code-text: #e2e8f0;
|
|
9078
|
+
--color-code-line-highlight: rgba(56, 189, 248, 0.16);
|
|
9079
|
+
--color-code-line-warning: rgba(245, 158, 11, 0.18);
|
|
9080
|
+
--color-code-line-warning-border: #f59e0b;
|
|
9081
|
+
--color-code-line-error: rgba(239, 68, 68, 0.18);
|
|
9082
|
+
--color-code-line-error-border: #ef4444;
|
|
9050
9083
|
}
|
|
9051
9084
|
[data-theme="dark"] {
|
|
9052
9085
|
--color-bg: #141414;
|
|
@@ -9058,6 +9091,11 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9058
9091
|
--color-primary-hover: #d4845f;
|
|
9059
9092
|
--color-code-bg: #1a1a1a;
|
|
9060
9093
|
--color-code-text: #e5e5e5;
|
|
9094
|
+
--color-code-line-highlight: rgba(14, 165, 233, 0.2);
|
|
9095
|
+
--color-code-line-warning: rgba(245, 158, 11, 0.2);
|
|
9096
|
+
--color-code-line-warning-border: #f59e0b;
|
|
9097
|
+
--color-code-line-error: rgba(239, 68, 68, 0.22);
|
|
9098
|
+
--color-code-line-error-border: #f87171;
|
|
9061
9099
|
}
|
|
9062
9100
|
@media (prefers-color-scheme: dark) {
|
|
9063
9101
|
:root:not([data-theme="light"]) {
|
|
@@ -9070,6 +9108,11 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9070
9108
|
--color-primary-hover: #d4845f;
|
|
9071
9109
|
--color-code-bg: #1a1a1a;
|
|
9072
9110
|
--color-code-text: #e5e5e5;
|
|
9111
|
+
--color-code-line-highlight: rgba(14, 165, 233, 0.2);
|
|
9112
|
+
--color-code-line-warning: rgba(245, 158, 11, 0.2);
|
|
9113
|
+
--color-code-line-warning-border: #f59e0b;
|
|
9114
|
+
--color-code-line-error: rgba(239, 68, 68, 0.22);
|
|
9115
|
+
--color-code-line-error-border: #f87171;
|
|
9073
9116
|
}
|
|
9074
9117
|
}
|
|
9075
9118
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
@@ -9370,6 +9413,25 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9370
9413
|
padding: 0;
|
|
9371
9414
|
font-size: 0.8125rem;
|
|
9372
9415
|
}
|
|
9416
|
+
.content pre.ox-code-block code {
|
|
9417
|
+
display: block;
|
|
9418
|
+
}
|
|
9419
|
+
.content pre.ox-code-block .line {
|
|
9420
|
+
display: block;
|
|
9421
|
+
margin: 0 -1.25rem;
|
|
9422
|
+
padding: 0 1.25rem;
|
|
9423
|
+
}
|
|
9424
|
+
.content pre.ox-code-block .ox-code-line--highlight {
|
|
9425
|
+
background: var(--color-code-line-highlight);
|
|
9426
|
+
}
|
|
9427
|
+
.content pre.ox-code-block .ox-code-line--warning {
|
|
9428
|
+
background: var(--color-code-line-warning);
|
|
9429
|
+
box-shadow: inset 3px 0 0 var(--color-code-line-warning-border);
|
|
9430
|
+
}
|
|
9431
|
+
.content pre.ox-code-block .ox-code-line--error {
|
|
9432
|
+
background: var(--color-code-line-error);
|
|
9433
|
+
box-shadow: inset 3px 0 0 var(--color-code-line-error-border);
|
|
9434
|
+
}
|
|
9373
9435
|
.content table {
|
|
9374
9436
|
width: 100%;
|
|
9375
9437
|
border-collapse: collapse;
|
|
@@ -9413,6 +9475,10 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9413
9475
|
overflow-x: auto;
|
|
9414
9476
|
-webkit-overflow-scrolling: touch;
|
|
9415
9477
|
}
|
|
9478
|
+
.content pre.ox-code-block .line {
|
|
9479
|
+
margin: 0 -0.75rem;
|
|
9480
|
+
padding: 0 0.75rem;
|
|
9481
|
+
}
|
|
9416
9482
|
.content code { font-size: 0.8125em; }
|
|
9417
9483
|
.content table {
|
|
9418
9484
|
display: block;
|
|
@@ -9586,6 +9652,39 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9586
9652
|
}
|
|
9587
9653
|
};
|
|
9588
9654
|
|
|
9655
|
+
const parseScopedQuery = (query) => {
|
|
9656
|
+
const scopes = [];
|
|
9657
|
+
const terms = [];
|
|
9658
|
+
for (const part of query.trim().split(/\\s+/).filter(Boolean)) {
|
|
9659
|
+
if (part.startsWith('@') && part.length > 1) {
|
|
9660
|
+
scopes.push(part.slice(1).toLowerCase());
|
|
9661
|
+
} else {
|
|
9662
|
+
terms.push(part);
|
|
9663
|
+
}
|
|
9664
|
+
}
|
|
9665
|
+
return { text: terms.join(' ').trim(), scopes: [...new Set(scopes)] };
|
|
9666
|
+
};
|
|
9667
|
+
|
|
9668
|
+
const getScopesForDoc = (doc) => {
|
|
9669
|
+
const source = (doc.id || doc.url || '').replace(/^\\/+/, '').toLowerCase();
|
|
9670
|
+
const segments = source.split('/').filter(Boolean);
|
|
9671
|
+
if (segments.length <= 1) return [];
|
|
9672
|
+
|
|
9673
|
+
const scopes = [];
|
|
9674
|
+
let current = '';
|
|
9675
|
+
for (const segment of segments.slice(0, -1)) {
|
|
9676
|
+
current = current ? current + '/' + segment : segment;
|
|
9677
|
+
scopes.push(current);
|
|
9678
|
+
}
|
|
9679
|
+
return scopes;
|
|
9680
|
+
};
|
|
9681
|
+
|
|
9682
|
+
const matchesScopes = (doc, scopes) => {
|
|
9683
|
+
if (!scopes.length) return true;
|
|
9684
|
+
const docScopes = new Set(getScopesForDoc(doc));
|
|
9685
|
+
return scopes.some((scope) => docScopes.has(scope));
|
|
9686
|
+
};
|
|
9687
|
+
|
|
9589
9688
|
// Tokenize query
|
|
9590
9689
|
const tokenize = (text) => {
|
|
9591
9690
|
const tokens = [];
|
|
@@ -9608,27 +9707,31 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9608
9707
|
|
|
9609
9708
|
// Perform search
|
|
9610
9709
|
const performSearch = async (query) => {
|
|
9611
|
-
if (!query.trim()) {
|
|
9612
|
-
searchResults.innerHTML = '';
|
|
9613
|
-
results = [];
|
|
9614
|
-
return;
|
|
9615
|
-
}
|
|
9616
9710
|
await loadSearchIndex();
|
|
9617
9711
|
if (!searchIndex) {
|
|
9618
9712
|
searchResults.innerHTML = '<div class="search-empty">Search index not available</div>';
|
|
9619
9713
|
return;
|
|
9620
9714
|
}
|
|
9621
9715
|
|
|
9622
|
-
const
|
|
9623
|
-
if (!
|
|
9716
|
+
const parsedQuery = parseScopedQuery(query);
|
|
9717
|
+
if (!parsedQuery.text && parsedQuery.scopes.length === 0) {
|
|
9624
9718
|
searchResults.innerHTML = '';
|
|
9625
9719
|
results = [];
|
|
9626
9720
|
return;
|
|
9627
9721
|
}
|
|
9628
9722
|
|
|
9723
|
+
const tokens = tokenize(parsedQuery.text);
|
|
9629
9724
|
const k1 = 1.2, b = 0.75;
|
|
9630
9725
|
const docScores = new Map();
|
|
9631
9726
|
|
|
9727
|
+
if (!tokens.length) {
|
|
9728
|
+
searchIndex.documents.forEach((doc, docIdx) => {
|
|
9729
|
+
if (matchesScopes(doc, parsedQuery.scopes)) {
|
|
9730
|
+
docScores.set(docIdx, { score: 0, matches: new Set() });
|
|
9731
|
+
}
|
|
9732
|
+
});
|
|
9733
|
+
}
|
|
9734
|
+
|
|
9632
9735
|
for (let i = 0; i < tokens.length; i++) {
|
|
9633
9736
|
const token = tokens[i];
|
|
9634
9737
|
const isLast = i === tokens.length - 1;
|
|
@@ -9647,6 +9750,7 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9647
9750
|
for (const posting of postings) {
|
|
9648
9751
|
const doc = searchIndex.documents[posting.doc_idx];
|
|
9649
9752
|
if (!doc) continue;
|
|
9753
|
+
if (!matchesScopes(doc, parsedQuery.scopes)) continue;
|
|
9650
9754
|
const boost = posting.field === 'Title' ? 10 : posting.field === 'Heading' ? 5 : 1;
|
|
9651
9755
|
const tf = posting.tf;
|
|
9652
9756
|
const docLen = doc.body.length;
|
|
@@ -9665,6 +9769,7 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9665
9769
|
results = Array.from(docScores.entries())
|
|
9666
9770
|
.map(([docIdx, data]) => {
|
|
9667
9771
|
const doc = searchIndex.documents[docIdx];
|
|
9772
|
+
const scopes = getScopesForDoc(doc);
|
|
9668
9773
|
let snippet = '';
|
|
9669
9774
|
if (doc.body) {
|
|
9670
9775
|
const bodyLower = doc.body.toLowerCase();
|
|
@@ -9673,15 +9778,15 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9673
9778
|
const pos = bodyLower.indexOf(match);
|
|
9674
9779
|
if (pos !== -1 && (firstPos === -1 || pos < firstPos)) firstPos = pos;
|
|
9675
9780
|
}
|
|
9676
|
-
const start = Math.max(0, firstPos - 50);
|
|
9781
|
+
const start = firstPos === -1 ? 0 : Math.max(0, firstPos - 50);
|
|
9677
9782
|
const end = Math.min(doc.body.length, start + 150);
|
|
9678
9783
|
snippet = doc.body.slice(start, end);
|
|
9679
9784
|
if (start > 0) snippet = '...' + snippet;
|
|
9680
9785
|
if (end < doc.body.length) snippet += '...';
|
|
9681
9786
|
}
|
|
9682
|
-
return { ...doc, score: data.score, snippet };
|
|
9787
|
+
return { ...doc, score: data.score, scopes, snippet };
|
|
9683
9788
|
})
|
|
9684
|
-
.sort((a, b) => b.score - a.score)
|
|
9789
|
+
.sort((a, b) => b.score - a.score || a.title.localeCompare(b.title))
|
|
9685
9790
|
.slice(0, 10);
|
|
9686
9791
|
|
|
9687
9792
|
selectedIndex = 0;
|
|
@@ -9695,7 +9800,7 @@ const DEFAULT_HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
9695
9800
|
}
|
|
9696
9801
|
searchResults.innerHTML = results.map((r, i) =>
|
|
9697
9802
|
'<a href="' + r.url + '" class="search-result' + (i === selectedIndex ? ' selected' : '') + '">' +
|
|
9698
|
-
'<div class="search-result-title">' + r.title + '</div>' +
|
|
9803
|
+
'<div class="search-result-title">' + r.title + (r.scopes?.length ? '<span class="search-result-scope">@' + r.scopes[0] + '</span>' : '') + '</div>' +
|
|
9699
9804
|
(r.snippet ? '<div class="search-result-snippet">' + r.snippet + '</div>' : '') +
|
|
9700
9805
|
'</a>'
|
|
9701
9806
|
).join('');
|
|
@@ -9826,7 +9931,7 @@ function generateBareHtmlPage(content, title) {
|
|
|
9826
9931
|
* Generates HTML page with navigation using Rust NAPI bindings.
|
|
9827
9932
|
*/
|
|
9828
9933
|
async function generateHtmlPage(pageData, navGroups, siteName, base, ogImage, theme) {
|
|
9829
|
-
const mod = await
|
|
9934
|
+
const mod = await require_mermaid.importNapiModule();
|
|
9830
9935
|
const tocForRust = pageData.toc.map((entry) => ({
|
|
9831
9936
|
depth: entry.depth,
|
|
9832
9937
|
text: entry.text,
|
|
@@ -9880,20 +9985,167 @@ async function generateHtmlPage(pageData, navGroups, siteName, base, ogImage, th
|
|
|
9880
9985
|
theme: themeForRust
|
|
9881
9986
|
});
|
|
9882
9987
|
}
|
|
9988
|
+
const SSG_STYLE_BLOCK_RE = /[ \t]*<!-- ox-content:styles:start -->\s*<style>([\s\S]*?)<\/style>\s*<!-- ox-content:styles:end -->/;
|
|
9989
|
+
const SSG_SCRIPT_BLOCK_RE = /[ \t]*<!-- ox-content:scripts:start -->\s*<script>([\s\S]*?)<\/script>\s*<!-- ox-content:scripts:end -->/;
|
|
9990
|
+
const FIRST_INLINE_STYLE_RE = /[ \t]*<style>([\s\S]*?)<\/style>/;
|
|
9991
|
+
const LAST_INLINE_BODY_SCRIPT_RE = /[ \t]*<script>([\s\S]*?)<\/script>\s*<\/body>/;
|
|
9992
|
+
const CSS_SECTION_RE = /\/\* ox-content:css:([a-z0-9-]+):start \*\/\s*([\s\S]*?)\s*\/\* ox-content:css:\1:end \*\//g;
|
|
9993
|
+
const SEARCH_CHUNK_RE = /\/\/ ox-content:search:start\s*([\s\S]*?)\s*\/\/ ox-content:search:end/;
|
|
9994
|
+
const SEARCH_CHUNK_PLACEHOLDER = "__OX_CONTENT_SEARCH_CHUNK__";
|
|
9995
|
+
const CORE_CSS_SECTION_NAMES = new Set(["base", "footer"]);
|
|
9996
|
+
const THEME_INLINE_CSS_MAX_BYTES = 2048;
|
|
9997
|
+
function createContentHash(content) {
|
|
9998
|
+
return (0, node_crypto.createHash)("sha256").update(content).digest("hex").slice(0, 10);
|
|
9999
|
+
}
|
|
10000
|
+
function sanitizeChunkLabel(label) {
|
|
10001
|
+
return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "asset";
|
|
10002
|
+
}
|
|
10003
|
+
function toPublicAssetPath(base, fileName) {
|
|
10004
|
+
return `${base.endsWith("/") ? base : `${base}/`}assets/${fileName}`;
|
|
10005
|
+
}
|
|
10006
|
+
function hasRelativeCssUrls(css) {
|
|
10007
|
+
let cursor = 0;
|
|
10008
|
+
while (cursor < css.length) {
|
|
10009
|
+
const urlIndex = css.indexOf("url(", cursor);
|
|
10010
|
+
if (urlIndex === -1) return false;
|
|
10011
|
+
let valueStart = urlIndex + 4;
|
|
10012
|
+
while (valueStart < css.length && /\s/.test(css[valueStart])) valueStart++;
|
|
10013
|
+
const quote = css[valueStart] === "\"" || css[valueStart] === "'" ? css[valueStart] : "";
|
|
10014
|
+
if (quote) valueStart++;
|
|
10015
|
+
let valueEnd = valueStart;
|
|
10016
|
+
while (valueEnd < css.length) {
|
|
10017
|
+
const char = css[valueEnd];
|
|
10018
|
+
if (quote) {
|
|
10019
|
+
if (char === "\\") {
|
|
10020
|
+
valueEnd += 2;
|
|
10021
|
+
continue;
|
|
10022
|
+
}
|
|
10023
|
+
if (char === quote) break;
|
|
10024
|
+
} else if (char === ")") break;
|
|
10025
|
+
valueEnd++;
|
|
10026
|
+
}
|
|
10027
|
+
const value = css.slice(valueStart, valueEnd).trim();
|
|
10028
|
+
if (value && !value.startsWith("data:") && !value.startsWith("http:") && !value.startsWith("https:") && !value.startsWith("//") && !value.startsWith("/") && !value.startsWith("#") && !value.startsWith("blob:") && !value.startsWith("var(")) return true;
|
|
10029
|
+
cursor = valueEnd + 1;
|
|
10030
|
+
}
|
|
10031
|
+
return false;
|
|
10032
|
+
}
|
|
10033
|
+
function createSharedAssetChunk(type, label, content, outDir, base) {
|
|
10034
|
+
const hash = createContentHash(content);
|
|
10035
|
+
const fileName = `ox-content-${sanitizeChunkLabel(label)}-${hash}.${type}`;
|
|
10036
|
+
return {
|
|
10037
|
+
outputPath: path.join(outDir, "assets", fileName),
|
|
10038
|
+
publicPath: toPublicAssetPath(base, fileName),
|
|
10039
|
+
content
|
|
10040
|
+
};
|
|
10041
|
+
}
|
|
10042
|
+
function extractCssSections(cssContent) {
|
|
10043
|
+
return Array.from(cssContent.matchAll(CSS_SECTION_RE)).map(([, name, content]) => ({
|
|
10044
|
+
name,
|
|
10045
|
+
content: content.trim()
|
|
10046
|
+
})).filter((section) => section.content.length > 0);
|
|
10047
|
+
}
|
|
10048
|
+
function getOrCreateSharedChunk(chunks, type, label, content, outDir, base) {
|
|
10049
|
+
let chunk = chunks.get(content);
|
|
10050
|
+
if (!chunk) {
|
|
10051
|
+
chunk = createSharedAssetChunk(type, label, content, outDir, base);
|
|
10052
|
+
chunks.set(content, chunk);
|
|
10053
|
+
}
|
|
10054
|
+
return chunk;
|
|
10055
|
+
}
|
|
10056
|
+
function buildStyleReplacement(cssContent, cssChunks, outDir, base) {
|
|
10057
|
+
const sections = extractCssSections(cssContent);
|
|
10058
|
+
const effectiveSections = sections.length > 0 ? sections : [{
|
|
10059
|
+
name: "css",
|
|
10060
|
+
content: cssContent.trim()
|
|
10061
|
+
}];
|
|
10062
|
+
const coreContent = effectiveSections.filter((section) => CORE_CSS_SECTION_NAMES.has(section.name)).map((section) => section.content).join("\n").trim();
|
|
10063
|
+
const fragments = [];
|
|
10064
|
+
if (coreContent) {
|
|
10065
|
+
const coreChunk = getOrCreateSharedChunk(cssChunks, "css", "core", coreContent, outDir, base);
|
|
10066
|
+
fragments.push(` <link rel="stylesheet" href="${coreChunk.publicPath}">`);
|
|
10067
|
+
}
|
|
10068
|
+
for (const section of effectiveSections) {
|
|
10069
|
+
if (CORE_CSS_SECTION_NAMES.has(section.name)) continue;
|
|
10070
|
+
if (section.name === "theme" && (hasRelativeCssUrls(section.content) || section.content.length <= THEME_INLINE_CSS_MAX_BYTES) || hasRelativeCssUrls(section.content)) {
|
|
10071
|
+
fragments.push(` <style>${section.content}</style>`);
|
|
10072
|
+
continue;
|
|
10073
|
+
}
|
|
10074
|
+
const chunk = getOrCreateSharedChunk(cssChunks, "css", section.name, section.content, outDir, base);
|
|
10075
|
+
fragments.push(` <link rel="stylesheet" href="${chunk.publicPath}">`);
|
|
10076
|
+
}
|
|
10077
|
+
return fragments.join("\n");
|
|
10078
|
+
}
|
|
10079
|
+
function buildScriptReplacement(jsContent, jsChunks, outDir, base) {
|
|
10080
|
+
const searchMatch = jsContent.match(SEARCH_CHUNK_RE);
|
|
10081
|
+
if (searchMatch && jsContent.includes(SEARCH_CHUNK_PLACEHOLDER)) {
|
|
10082
|
+
const searchContent = searchMatch[1].trim();
|
|
10083
|
+
if (searchContent) {
|
|
10084
|
+
const searchChunk = getOrCreateSharedChunk(jsChunks, "js", "search", searchContent, outDir, base);
|
|
10085
|
+
const coreContent = jsContent.replace(SEARCH_CHUNK_RE, "").replaceAll(SEARCH_CHUNK_PLACEHOLDER, searchChunk.publicPath).trim();
|
|
10086
|
+
if (coreContent) return ` <script defer src="${getOrCreateSharedChunk(jsChunks, "js", "core", coreContent, outDir, base).publicPath}"><\/script>`;
|
|
10087
|
+
}
|
|
10088
|
+
}
|
|
10089
|
+
const fallbackContent = jsContent.trim();
|
|
10090
|
+
if (!fallbackContent) return "";
|
|
10091
|
+
return ` <script defer src="${getOrCreateSharedChunk(jsChunks, "js", "js", fallbackContent, outDir, base).publicPath}"><\/script>`;
|
|
10092
|
+
}
|
|
10093
|
+
async function externalizeSharedPageAssets(pages, outDir, base) {
|
|
10094
|
+
const cssChunks = /* @__PURE__ */ new Map();
|
|
10095
|
+
const jsChunks = /* @__PURE__ */ new Map();
|
|
10096
|
+
const optimizedPages = pages.map((page) => {
|
|
10097
|
+
let html = page.html;
|
|
10098
|
+
const styleMatch = html.match(SSG_STYLE_BLOCK_RE);
|
|
10099
|
+
if (styleMatch) {
|
|
10100
|
+
const replacement = buildStyleReplacement(styleMatch[1], cssChunks, outDir, base);
|
|
10101
|
+
html = html.replace(SSG_STYLE_BLOCK_RE, replacement);
|
|
10102
|
+
} else {
|
|
10103
|
+
const inlineStyleMatch = html.match(FIRST_INLINE_STYLE_RE);
|
|
10104
|
+
if (inlineStyleMatch) {
|
|
10105
|
+
const replacement = buildStyleReplacement(inlineStyleMatch[1], cssChunks, outDir, base);
|
|
10106
|
+
html = html.replace(FIRST_INLINE_STYLE_RE, replacement);
|
|
10107
|
+
}
|
|
10108
|
+
}
|
|
10109
|
+
const scriptMatch = html.match(SSG_SCRIPT_BLOCK_RE);
|
|
10110
|
+
if (scriptMatch) {
|
|
10111
|
+
const replacement = buildScriptReplacement(scriptMatch[1], jsChunks, outDir, base);
|
|
10112
|
+
html = html.replace(SSG_SCRIPT_BLOCK_RE, replacement);
|
|
10113
|
+
} else {
|
|
10114
|
+
const inlineScriptMatch = html.match(LAST_INLINE_BODY_SCRIPT_RE);
|
|
10115
|
+
if (inlineScriptMatch) {
|
|
10116
|
+
const replacement = buildScriptReplacement(inlineScriptMatch[1], jsChunks, outDir, base);
|
|
10117
|
+
html = html.replace(LAST_INLINE_BODY_SCRIPT_RE, replacement ? `${replacement}\n</body>` : "</body>");
|
|
10118
|
+
}
|
|
10119
|
+
}
|
|
10120
|
+
return {
|
|
10121
|
+
...page,
|
|
10122
|
+
html
|
|
10123
|
+
};
|
|
10124
|
+
});
|
|
10125
|
+
const chunks = [...cssChunks.values(), ...jsChunks.values()];
|
|
10126
|
+
await Promise.all(chunks.map(async (chunk) => {
|
|
10127
|
+
await fs_promises.mkdir(path.dirname(chunk.outputPath), { recursive: true });
|
|
10128
|
+
await fs_promises.writeFile(chunk.outputPath, chunk.content, "utf-8");
|
|
10129
|
+
}));
|
|
10130
|
+
return {
|
|
10131
|
+
pages: optimizedPages,
|
|
10132
|
+
assets: chunks.map((chunk) => chunk.outputPath)
|
|
10133
|
+
};
|
|
10134
|
+
}
|
|
9883
10135
|
/**
|
|
9884
10136
|
* Converts a markdown file path to its corresponding HTML output path.
|
|
9885
10137
|
*/
|
|
9886
10138
|
function getOutputPath(inputPath, srcDir, outDir, extension) {
|
|
9887
|
-
const baseName = path
|
|
9888
|
-
if (baseName.endsWith(`index${extension}`)) return path
|
|
10139
|
+
const baseName = path.relative(srcDir, inputPath).replace(/\.(?:md|markdown)$/i, extension);
|
|
10140
|
+
if (baseName.endsWith(`index${extension}`)) return path.join(outDir, baseName);
|
|
9889
10141
|
const dirName = baseName.replace(new RegExp(`\\${extension}$`), "");
|
|
9890
|
-
return path
|
|
10142
|
+
return path.join(outDir, dirName, `index${extension}`);
|
|
9891
10143
|
}
|
|
9892
10144
|
/**
|
|
9893
10145
|
* Converts a markdown file path to a relative URL path.
|
|
9894
10146
|
*/
|
|
9895
10147
|
function getUrlPath$1(inputPath, srcDir) {
|
|
9896
|
-
const baseName = path
|
|
10148
|
+
const baseName = path.relative(srcDir, inputPath).replace(/\.(?:md|markdown)$/i, "");
|
|
9897
10149
|
if (baseName === "index" || baseName.endsWith("/index")) return baseName.replace(/\/?index$/, "") || "/";
|
|
9898
10150
|
return baseName;
|
|
9899
10151
|
}
|
|
@@ -9909,12 +10161,12 @@ function getHref(inputPath, srcDir, base, extension) {
|
|
|
9909
10161
|
* Gets the OG image output path for a given markdown file.
|
|
9910
10162
|
*/
|
|
9911
10163
|
function getOgImagePath(inputPath, srcDir, outDir) {
|
|
9912
|
-
const baseName = path
|
|
10164
|
+
const baseName = path.relative(srcDir, inputPath).replace(/\.(?:md|markdown)$/i, "");
|
|
9913
10165
|
if (baseName === "index" || baseName.endsWith("/index")) {
|
|
9914
10166
|
const dirPath = baseName.replace(/\/?index$/, "") || "";
|
|
9915
|
-
return path
|
|
10167
|
+
return path.join(outDir, dirPath, "og-image.png");
|
|
9916
10168
|
}
|
|
9917
|
-
return path
|
|
10169
|
+
return path.join(outDir, baseName, "og-image.png");
|
|
9918
10170
|
}
|
|
9919
10171
|
/**
|
|
9920
10172
|
* Gets the OG image URL for use in meta tags.
|
|
@@ -9932,9 +10184,9 @@ function getOgImageUrl(inputPath, srcDir, base, siteUrl) {
|
|
|
9932
10184
|
* Gets display title from file path.
|
|
9933
10185
|
*/
|
|
9934
10186
|
function getDisplayTitle(filePath) {
|
|
9935
|
-
const fileName = path
|
|
10187
|
+
const fileName = path.basename(filePath, path.extname(filePath));
|
|
9936
10188
|
if (fileName === "index") {
|
|
9937
|
-
const dirName = path
|
|
10189
|
+
const dirName = path.basename(path.dirname(filePath));
|
|
9938
10190
|
if (dirName && dirName !== ".") return formatTitle(dirName);
|
|
9939
10191
|
return "Home";
|
|
9940
10192
|
}
|
|
@@ -9950,7 +10202,7 @@ function formatTitle(name) {
|
|
|
9950
10202
|
* Collects all markdown files from the source directory.
|
|
9951
10203
|
*/
|
|
9952
10204
|
async function collectMarkdownFiles$1(srcDir) {
|
|
9953
|
-
return (await (0, glob.glob)(path
|
|
10205
|
+
return (await (0, glob.glob)(path.join(srcDir, "**/*.{md,markdown}"), {
|
|
9954
10206
|
nodir: true,
|
|
9955
10207
|
ignore: [
|
|
9956
10208
|
"**/node_modules/**",
|
|
@@ -9971,7 +10223,7 @@ function buildNavItems(markdownFiles, srcDir, base, extension) {
|
|
|
9971
10223
|
"api"
|
|
9972
10224
|
];
|
|
9973
10225
|
for (const file of markdownFiles) {
|
|
9974
|
-
const parts = path
|
|
10226
|
+
const parts = path.relative(srcDir, file).split(path.sep);
|
|
9975
10227
|
let groupKey = "";
|
|
9976
10228
|
if (parts.length > 1) groupKey = parts[0];
|
|
9977
10229
|
if (!groups.has(groupKey)) groups.set(groupKey, []);
|
|
@@ -10020,10 +10272,11 @@ async function buildSsg(options, root) {
|
|
|
10020
10272
|
files: [],
|
|
10021
10273
|
errors: []
|
|
10022
10274
|
};
|
|
10023
|
-
const srcDir = path
|
|
10024
|
-
const outDir = path
|
|
10275
|
+
const srcDir = path.resolve(root, options.srcDir);
|
|
10276
|
+
const outDir = path.resolve(root, options.outDir);
|
|
10025
10277
|
const base = options.base.endsWith("/") ? options.base : options.base + "/";
|
|
10026
10278
|
const generatedFiles = [];
|
|
10279
|
+
const generatedPages = [];
|
|
10027
10280
|
const errors = [];
|
|
10028
10281
|
if (ssgOptions.clean) try {
|
|
10029
10282
|
await fs_promises.rm(outDir, {
|
|
@@ -10035,7 +10288,7 @@ async function buildSsg(options, root) {
|
|
|
10035
10288
|
const navItems = buildNavItems(markdownFiles, srcDir, base, ssgOptions.extension);
|
|
10036
10289
|
let siteName = ssgOptions.siteName ?? "Documentation";
|
|
10037
10290
|
if (!ssgOptions.siteName) try {
|
|
10038
|
-
const pkgPath = path
|
|
10291
|
+
const pkgPath = path.join(root, "package.json");
|
|
10039
10292
|
const pkg = JSON.parse(await fs_promises.readFile(pkgPath, "utf-8"));
|
|
10040
10293
|
if (pkg.name) siteName = formatTitle(pkg.name);
|
|
10041
10294
|
} catch {}
|
|
@@ -10137,19 +10390,27 @@ async function buildSsg(options, root) {
|
|
|
10137
10390
|
entryPage
|
|
10138
10391
|
}, navItems, siteName, base, pageOgImage, ssgOptions.theme);
|
|
10139
10392
|
const outputPath = getOutputPath(inputPath, srcDir, outDir, ssgOptions.extension);
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10393
|
+
generatedPages.push({
|
|
10394
|
+
inputPath,
|
|
10395
|
+
outputPath,
|
|
10396
|
+
html
|
|
10397
|
+
});
|
|
10143
10398
|
} catch (err) {
|
|
10144
10399
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
10145
10400
|
errors.push(`Failed to generate HTML for ${pageResult.inputPath}: ${errorMessage}`);
|
|
10146
10401
|
}
|
|
10402
|
+
const optimizedOutput = await externalizeSharedPageAssets(generatedPages, outDir, base);
|
|
10403
|
+
generatedFiles.push(...optimizedOutput.assets);
|
|
10404
|
+
for (const page of optimizedOutput.pages) {
|
|
10405
|
+
await fs_promises.mkdir(path.dirname(page.outputPath), { recursive: true });
|
|
10406
|
+
await fs_promises.writeFile(page.outputPath, page.html, "utf-8");
|
|
10407
|
+
generatedFiles.push(page.outputPath);
|
|
10408
|
+
}
|
|
10147
10409
|
return {
|
|
10148
10410
|
files: generatedFiles,
|
|
10149
10411
|
errors
|
|
10150
10412
|
};
|
|
10151
10413
|
}
|
|
10152
|
-
|
|
10153
10414
|
//#endregion
|
|
10154
10415
|
//#region src/search.ts
|
|
10155
10416
|
/**
|
|
@@ -10160,7 +10421,7 @@ async function buildSsg(options, root) {
|
|
|
10160
10421
|
let oxContent$1 = null;
|
|
10161
10422
|
async function getOxContent() {
|
|
10162
10423
|
if (!oxContent$1) try {
|
|
10163
|
-
oxContent$1 = await
|
|
10424
|
+
oxContent$1 = await require_mermaid.importNapiModule();
|
|
10164
10425
|
} catch {
|
|
10165
10426
|
console.warn("[ox-content] Native bindings not available, search disabled");
|
|
10166
10427
|
return null;
|
|
@@ -10196,7 +10457,7 @@ async function collectMarkdownFiles(dir) {
|
|
|
10196
10457
|
try {
|
|
10197
10458
|
const entries = await fs_promises.readdir(currentDir, { withFileTypes: true });
|
|
10198
10459
|
for (const entry of entries) {
|
|
10199
|
-
const fullPath = path
|
|
10460
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
10200
10461
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") await walk(fullPath);
|
|
10201
10462
|
else if (entry.isFile() && entry.name.endsWith(".md")) files.push(fullPath);
|
|
10202
10463
|
}
|
|
@@ -10221,7 +10482,7 @@ async function buildSearchIndex(srcDir, base) {
|
|
|
10221
10482
|
const documents = [];
|
|
10222
10483
|
for (const file of files) try {
|
|
10223
10484
|
const content = await fs_promises.readFile(file, "utf-8");
|
|
10224
|
-
const relativePath = path
|
|
10485
|
+
const relativePath = path.relative(srcDir, file);
|
|
10225
10486
|
const url = base + relativePath.replace(/\.md$/, "").replace(/\\/g, "/");
|
|
10226
10487
|
const id = relativePath.replace(/\.md$/, "").replace(/\\/g, "/");
|
|
10227
10488
|
const extractSearchContent = napi.extractSearchContent;
|
|
@@ -10250,7 +10511,7 @@ async function buildSearchIndex(srcDir, base) {
|
|
|
10250
10511
|
* Writes the search index to a file.
|
|
10251
10512
|
*/
|
|
10252
10513
|
async function writeSearchIndex(indexJson, outDir) {
|
|
10253
|
-
const indexPath = path
|
|
10514
|
+
const indexPath = path.join(outDir, "search-index.json");
|
|
10254
10515
|
await fs_promises.mkdir(outDir, { recursive: true });
|
|
10255
10516
|
await fs_promises.writeFile(indexPath, indexJson, "utf-8");
|
|
10256
10517
|
}
|
|
@@ -10266,6 +10527,51 @@ const searchOptions = ${JSON.stringify(options)};
|
|
|
10266
10527
|
let searchIndex = null;
|
|
10267
10528
|
let indexPromise = null;
|
|
10268
10529
|
|
|
10530
|
+
function parseScopedQuery(query) {
|
|
10531
|
+
const scopes = [];
|
|
10532
|
+
const terms = [];
|
|
10533
|
+
|
|
10534
|
+
for (const part of query.trim().split(/\\s+/).filter(Boolean)) {
|
|
10535
|
+
if (part.startsWith('@') && part.length > 1) {
|
|
10536
|
+
scopes.push(part.slice(1).toLowerCase());
|
|
10537
|
+
} else {
|
|
10538
|
+
terms.push(part);
|
|
10539
|
+
}
|
|
10540
|
+
}
|
|
10541
|
+
|
|
10542
|
+
return {
|
|
10543
|
+
text: terms.join(' ').trim(),
|
|
10544
|
+
scopes: [...new Set(scopes)],
|
|
10545
|
+
};
|
|
10546
|
+
}
|
|
10547
|
+
|
|
10548
|
+
function getScopesForDoc(doc) {
|
|
10549
|
+
const source = (doc.id || doc.url || '').replace(/^\\/+/, '').toLowerCase();
|
|
10550
|
+
const segments = source.split('/').filter(Boolean);
|
|
10551
|
+
|
|
10552
|
+
if (segments.length <= 1) {
|
|
10553
|
+
return [];
|
|
10554
|
+
}
|
|
10555
|
+
|
|
10556
|
+
const scopes = [];
|
|
10557
|
+
let current = '';
|
|
10558
|
+
for (const segment of segments.slice(0, -1)) {
|
|
10559
|
+
current = current ? current + '/' + segment : segment;
|
|
10560
|
+
scopes.push(current);
|
|
10561
|
+
}
|
|
10562
|
+
|
|
10563
|
+
return scopes;
|
|
10564
|
+
}
|
|
10565
|
+
|
|
10566
|
+
function matchesScopes(doc, scopes) {
|
|
10567
|
+
if (!scopes.length) {
|
|
10568
|
+
return true;
|
|
10569
|
+
}
|
|
10570
|
+
|
|
10571
|
+
const docScopes = new Set(getScopesForDoc(doc));
|
|
10572
|
+
return scopes.some(scope => docScopes.has(scope));
|
|
10573
|
+
}
|
|
10574
|
+
|
|
10269
10575
|
// Tokenizer for queries
|
|
10270
10576
|
function tokenizeQuery(text) {
|
|
10271
10577
|
const tokens = [];
|
|
@@ -10333,22 +10639,32 @@ async function loadIndex() {
|
|
|
10333
10639
|
export async function search(query, options = {}) {
|
|
10334
10640
|
const index = await loadIndex();
|
|
10335
10641
|
|
|
10336
|
-
if (!index
|
|
10642
|
+
if (!index) {
|
|
10337
10643
|
return [];
|
|
10338
10644
|
}
|
|
10339
10645
|
|
|
10340
|
-
const
|
|
10341
|
-
const prefix = options.prefix ?? searchOptions.prefix;
|
|
10342
|
-
const tokens = tokenizeQuery(query);
|
|
10646
|
+
const parsedQuery = parseScopedQuery(query);
|
|
10343
10647
|
|
|
10344
|
-
if (
|
|
10648
|
+
if (!parsedQuery.text && parsedQuery.scopes.length === 0) {
|
|
10345
10649
|
return [];
|
|
10346
10650
|
}
|
|
10347
10651
|
|
|
10652
|
+
const limit = options.limit ?? searchOptions.limit;
|
|
10653
|
+
const prefix = options.prefix ?? searchOptions.prefix;
|
|
10654
|
+
const tokens = tokenizeQuery(parsedQuery.text);
|
|
10655
|
+
|
|
10348
10656
|
const k1 = 1.2;
|
|
10349
10657
|
const b = 0.75;
|
|
10350
10658
|
const docScores = new Map();
|
|
10351
10659
|
|
|
10660
|
+
if (tokens.length === 0) {
|
|
10661
|
+
index.documents.forEach((doc, docIdx) => {
|
|
10662
|
+
if (matchesScopes(doc, parsedQuery.scopes)) {
|
|
10663
|
+
docScores.set(docIdx, { score: 0, matches: new Set() });
|
|
10664
|
+
}
|
|
10665
|
+
});
|
|
10666
|
+
}
|
|
10667
|
+
|
|
10352
10668
|
for (let i = 0; i < tokens.length; i++) {
|
|
10353
10669
|
const token = tokens[i];
|
|
10354
10670
|
const isLast = i === tokens.length - 1;
|
|
@@ -10369,6 +10685,7 @@ export async function search(query, options = {}) {
|
|
|
10369
10685
|
for (const posting of postings) {
|
|
10370
10686
|
const doc = index.documents[posting.doc_idx];
|
|
10371
10687
|
if (!doc) continue;
|
|
10688
|
+
if (!matchesScopes(doc, parsedQuery.scopes)) continue;
|
|
10372
10689
|
|
|
10373
10690
|
const docLen = doc.body.length;
|
|
10374
10691
|
const tf = posting.tf;
|
|
@@ -10391,6 +10708,7 @@ export async function search(query, options = {}) {
|
|
|
10391
10708
|
.map(([docIdx, data]) => {
|
|
10392
10709
|
const doc = index.documents[docIdx];
|
|
10393
10710
|
const matches = Array.from(data.matches);
|
|
10711
|
+
const scopes = getScopesForDoc(doc);
|
|
10394
10712
|
|
|
10395
10713
|
// Generate snippet
|
|
10396
10714
|
let snippet = '';
|
|
@@ -10404,7 +10722,7 @@ export async function search(query, options = {}) {
|
|
|
10404
10722
|
}
|
|
10405
10723
|
}
|
|
10406
10724
|
|
|
10407
|
-
const start = Math.max(0, firstPos - 50);
|
|
10725
|
+
const start = firstPos === -1 ? 0 : Math.max(0, firstPos - 50);
|
|
10408
10726
|
const end = Math.min(doc.body.length, start + 150);
|
|
10409
10727
|
snippet = doc.body.slice(start, end);
|
|
10410
10728
|
if (start > 0) snippet = '...' + snippet;
|
|
@@ -10418,9 +10736,10 @@ export async function search(query, options = {}) {
|
|
|
10418
10736
|
score: data.score,
|
|
10419
10737
|
matches,
|
|
10420
10738
|
snippet,
|
|
10739
|
+
scopes,
|
|
10421
10740
|
};
|
|
10422
10741
|
})
|
|
10423
|
-
.sort((a, b) => b.score - a.score)
|
|
10742
|
+
.sort((a, b) => b.score - a.score || a.title.localeCompare(b.title))
|
|
10424
10743
|
.slice(0, limit);
|
|
10425
10744
|
|
|
10426
10745
|
return results;
|
|
@@ -10430,7 +10749,6 @@ export { searchOptions };
|
|
|
10430
10749
|
export default { search, searchOptions, loadIndex };
|
|
10431
10750
|
`;
|
|
10432
10751
|
}
|
|
10433
|
-
|
|
10434
10752
|
//#endregion
|
|
10435
10753
|
//#region src/dev-server.ts
|
|
10436
10754
|
/**
|
|
@@ -10495,12 +10813,12 @@ async function resolveMarkdownFile(url, srcDir) {
|
|
|
10495
10813
|
let relativePath;
|
|
10496
10814
|
if (pathname === "/") relativePath = "index.md";
|
|
10497
10815
|
else relativePath = pathname.slice(1) + ".md";
|
|
10498
|
-
const filePath = path
|
|
10816
|
+
const filePath = path.join(srcDir, relativePath);
|
|
10499
10817
|
try {
|
|
10500
10818
|
await fs_promises.access(filePath);
|
|
10501
10819
|
return filePath;
|
|
10502
10820
|
} catch {
|
|
10503
|
-
const indexPath = path
|
|
10821
|
+
const indexPath = path.join(srcDir, pathname === "/" ? "" : pathname.slice(1), "index.md");
|
|
10504
10822
|
try {
|
|
10505
10823
|
await fs_promises.access(indexPath);
|
|
10506
10824
|
return indexPath;
|
|
@@ -10544,7 +10862,7 @@ function invalidatePageCache(cache, filePath) {
|
|
|
10544
10862
|
async function resolveSiteName(options, root) {
|
|
10545
10863
|
if (options.ssg.siteName) return options.ssg.siteName;
|
|
10546
10864
|
try {
|
|
10547
|
-
const pkgPath = path
|
|
10865
|
+
const pkgPath = path.join(root, "package.json");
|
|
10548
10866
|
const pkg = JSON.parse(await fs_promises.readFile(pkgPath, "utf-8"));
|
|
10549
10867
|
if (pkg.name) return formatTitle(pkg.name);
|
|
10550
10868
|
} catch {}
|
|
@@ -10554,7 +10872,7 @@ async function resolveSiteName(options, root) {
|
|
|
10554
10872
|
* Render a single markdown page to full HTML.
|
|
10555
10873
|
*/
|
|
10556
10874
|
async function renderPage$1(filePath, options, navGroups, siteName, base, root) {
|
|
10557
|
-
const srcDir = path
|
|
10875
|
+
const srcDir = path.resolve(root, options.srcDir);
|
|
10558
10876
|
require_tabs.resetTabGroupCounter();
|
|
10559
10877
|
resetIslandCounter();
|
|
10560
10878
|
const result = await transformMarkdown(await fs_promises.readFile(filePath, "utf-8"), filePath, options, {
|
|
@@ -10599,7 +10917,7 @@ async function renderPage$1(filePath, options, navGroups, siteName, base, root)
|
|
|
10599
10917
|
* Create the dev server middleware for SSG page serving.
|
|
10600
10918
|
*/
|
|
10601
10919
|
function createDevServerMiddleware(options, root, cache) {
|
|
10602
|
-
const srcDir = path
|
|
10920
|
+
const srcDir = path.resolve(root, options.srcDir);
|
|
10603
10921
|
const base = options.base.endsWith("/") ? options.base : options.base + "/";
|
|
10604
10922
|
return async (req, res, next) => {
|
|
10605
10923
|
const url = req.url;
|
|
@@ -10631,7 +10949,6 @@ function createDevServerMiddleware(options, root, cache) {
|
|
|
10631
10949
|
}
|
|
10632
10950
|
};
|
|
10633
10951
|
}
|
|
10634
|
-
|
|
10635
10952
|
//#endregion
|
|
10636
10953
|
//#region src/og-viewer.ts
|
|
10637
10954
|
/**
|
|
@@ -10665,7 +10982,7 @@ function extractTitle(content, frontmatter) {
|
|
|
10665
10982
|
return match ? match[1].trim() : "";
|
|
10666
10983
|
}
|
|
10667
10984
|
function getUrlPath(filePath, srcDir) {
|
|
10668
|
-
let rel = path
|
|
10985
|
+
let rel = path.relative(srcDir, filePath).replace(/\\/g, "/");
|
|
10669
10986
|
rel = rel.replace(/\.md$/, "");
|
|
10670
10987
|
if (rel === "index") return "/";
|
|
10671
10988
|
if (rel.endsWith("/index")) rel = rel.slice(0, -6);
|
|
@@ -10705,7 +11022,7 @@ function validatePage(page, options) {
|
|
|
10705
11022
|
return warnings;
|
|
10706
11023
|
}
|
|
10707
11024
|
async function collectPages(options, root) {
|
|
10708
|
-
const srcDir = path
|
|
11025
|
+
const srcDir = path.resolve(root, options.srcDir);
|
|
10709
11026
|
const files = await (0, glob.glob)("**/*.md", {
|
|
10710
11027
|
cwd: srcDir,
|
|
10711
11028
|
absolute: true
|
|
@@ -10723,7 +11040,7 @@ async function collectPages(options, root) {
|
|
|
10723
11040
|
const urlPath = getUrlPath(file, srcDir);
|
|
10724
11041
|
const ogImageUrl = computeOgImageUrl(urlPath, options.base, options.ssg.siteUrl, generateOgImage, options.ssg.ogImage);
|
|
10725
11042
|
const page = {
|
|
10726
|
-
path: path
|
|
11043
|
+
path: path.relative(srcDir, file),
|
|
10727
11044
|
urlPath,
|
|
10728
11045
|
title,
|
|
10729
11046
|
description,
|
|
@@ -10978,7 +11295,6 @@ function createOgViewerPlugin(options) {
|
|
|
10978
11295
|
}
|
|
10979
11296
|
};
|
|
10980
11297
|
}
|
|
10981
|
-
|
|
10982
11298
|
//#endregion
|
|
10983
11299
|
//#region src/i18n.ts
|
|
10984
11300
|
/**
|
|
@@ -11039,13 +11355,13 @@ function createI18nPlugin(resolvedOptions) {
|
|
|
11039
11355
|
},
|
|
11040
11356
|
async buildStart() {
|
|
11041
11357
|
if (!i18nOptions || !i18nOptions.check) return;
|
|
11042
|
-
const dictDir = path
|
|
11358
|
+
const dictDir = path.resolve(root, i18nOptions.dir);
|
|
11043
11359
|
if (!fs.existsSync(dictDir)) {
|
|
11044
11360
|
console.warn(`[ox-content:i18n] Dictionary directory not found: ${dictDir}`);
|
|
11045
11361
|
return;
|
|
11046
11362
|
}
|
|
11047
11363
|
try {
|
|
11048
|
-
const { loadDictionaries, checkI18n, extractTranslationKeys } = await
|
|
11364
|
+
const { loadDictionaries, checkI18n, extractTranslationKeys } = await require_mermaid.importNapiModule();
|
|
11049
11365
|
const loadResult = loadDictionaries(dictDir);
|
|
11050
11366
|
if (loadResult.errors.length > 0) {
|
|
11051
11367
|
for (const error of loadResult.errors) console.warn(`[ox-content:i18n] ${error}`);
|
|
@@ -11061,7 +11377,7 @@ function createI18nPlugin(resolvedOptions) {
|
|
|
11061
11377
|
},
|
|
11062
11378
|
configureServer(server) {
|
|
11063
11379
|
if (!i18nOptions) return;
|
|
11064
|
-
const dictDir = path
|
|
11380
|
+
const dictDir = path.resolve(root, i18nOptions.dir);
|
|
11065
11381
|
if (fs.existsSync(dictDir)) {
|
|
11066
11382
|
server.watcher.add(dictDir);
|
|
11067
11383
|
server.watcher.on("change", (filePath) => {
|
|
@@ -11088,7 +11404,7 @@ function createI18nPlugin(resolvedOptions) {
|
|
|
11088
11404
|
* Generates the virtual module for i18n configuration.
|
|
11089
11405
|
*/
|
|
11090
11406
|
function generateI18nModule(options, root) {
|
|
11091
|
-
const dictDir = path
|
|
11407
|
+
const dictDir = path.resolve(root, options.dir);
|
|
11092
11408
|
const localesJson = JSON.stringify(options.locales);
|
|
11093
11409
|
const defaultLocale = JSON.stringify(options.defaultLocale);
|
|
11094
11410
|
let dictionariesCode = "{}";
|
|
@@ -11171,15 +11487,15 @@ function flattenObject(obj, prefix, result) {
|
|
|
11171
11487
|
function loadDictionariesFallback(options, dictDir) {
|
|
11172
11488
|
const dictData = {};
|
|
11173
11489
|
for (const locale of options.locales) {
|
|
11174
|
-
const localeDir = path
|
|
11490
|
+
const localeDir = path.join(dictDir, locale.code);
|
|
11175
11491
|
if (!fs.existsSync(localeDir)) continue;
|
|
11176
11492
|
const files = fs.readdirSync(localeDir);
|
|
11177
11493
|
const localeDict = {};
|
|
11178
11494
|
for (const file of files) {
|
|
11179
11495
|
if (!file.endsWith(".json")) continue;
|
|
11180
|
-
const filePath = path
|
|
11496
|
+
const filePath = path.join(localeDir, file);
|
|
11181
11497
|
const content = fs.readFileSync(filePath, "utf-8");
|
|
11182
|
-
const namespace = path
|
|
11498
|
+
const namespace = path.basename(file, ".json");
|
|
11183
11499
|
try {
|
|
11184
11500
|
flattenObject(JSON.parse(content), namespace, localeDict);
|
|
11185
11501
|
} catch {}
|
|
@@ -11192,13 +11508,13 @@ function loadDictionariesFallback(options, dictDir) {
|
|
|
11192
11508
|
* Collects translation keys from source files using NAPI extractTranslationKeys.
|
|
11193
11509
|
*/
|
|
11194
11510
|
function collectKeysFromSource(root, extractTranslationKeys, options) {
|
|
11195
|
-
const srcDir = path
|
|
11511
|
+
const srcDir = path.resolve(root, "src");
|
|
11196
11512
|
const keys = /* @__PURE__ */ new Set();
|
|
11197
11513
|
if (fs.existsSync(srcDir)) walkDir(srcDir, /\.(ts|tsx|js|jsx)$/, (filePath) => {
|
|
11198
11514
|
const usages = extractTranslationKeys(fs.readFileSync(filePath, "utf-8"), filePath, options.functionNames);
|
|
11199
11515
|
for (const usage of usages) keys.add(usage.key);
|
|
11200
11516
|
});
|
|
11201
|
-
const contentDir = path
|
|
11517
|
+
const contentDir = path.resolve(root, "content");
|
|
11202
11518
|
if (fs.existsSync(contentDir)) {
|
|
11203
11519
|
const tPattern = /\{\{t\(['"]([^'"]+)['"]\)\}\}/g;
|
|
11204
11520
|
walkDir(contentDir, /\.(md|mdx)$/, (filePath) => {
|
|
@@ -11216,14 +11532,13 @@ function collectKeysFromSource(root, extractTranslationKeys, options) {
|
|
|
11216
11532
|
function walkDir(dir, pattern, callback) {
|
|
11217
11533
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
11218
11534
|
for (const entry of entries) {
|
|
11219
|
-
const fullPath = path
|
|
11535
|
+
const fullPath = path.join(dir, entry.name);
|
|
11220
11536
|
if (entry.isDirectory()) {
|
|
11221
11537
|
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
11222
11538
|
walkDir(fullPath, pattern, callback);
|
|
11223
11539
|
} else if (pattern.test(entry.name)) callback(fullPath);
|
|
11224
11540
|
}
|
|
11225
11541
|
}
|
|
11226
|
-
|
|
11227
11542
|
//#endregion
|
|
11228
11543
|
//#region src/jsx-runtime.ts
|
|
11229
11544
|
/**
|
|
@@ -11413,7 +11728,6 @@ function when(condition, content) {
|
|
|
11413
11728
|
function each(items, render) {
|
|
11414
11729
|
return { __html: items.map((item, i) => render(item, i).__html).join("") };
|
|
11415
11730
|
}
|
|
11416
|
-
|
|
11417
11731
|
//#endregion
|
|
11418
11732
|
//#region src/page-context.ts
|
|
11419
11733
|
var page_context_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
@@ -11604,7 +11918,6 @@ var currentContext;
|
|
|
11604
11918
|
var init_page_context = require_chunk.__esmMin((() => {
|
|
11605
11919
|
currentContext = null;
|
|
11606
11920
|
}));
|
|
11607
|
-
|
|
11608
11921
|
//#endregion
|
|
11609
11922
|
//#region src/theme-renderer.ts
|
|
11610
11923
|
/**
|
|
@@ -11762,7 +12075,6 @@ function createTheme(config) {
|
|
|
11762
12075
|
return Layout({ children });
|
|
11763
12076
|
};
|
|
11764
12077
|
}
|
|
11765
|
-
|
|
11766
12078
|
//#endregion
|
|
11767
12079
|
//#region src/index.ts
|
|
11768
12080
|
/**
|
|
@@ -11797,8 +12109,8 @@ function oxContent(options = {}) {
|
|
|
11797
12109
|
async function regenerateDocs(root) {
|
|
11798
12110
|
const docsOptions = resolvedOptions.docs;
|
|
11799
12111
|
if (!docsOptions || !docsOptions.enabled) return 0;
|
|
11800
|
-
const srcDirs = docsOptions.src.map((src) => path
|
|
11801
|
-
const outDir = path
|
|
12112
|
+
const srcDirs = docsOptions.src.map((src) => path.resolve(root, src));
|
|
12113
|
+
const outDir = path.resolve(root, docsOptions.out);
|
|
11802
12114
|
const extracted = await extractDocs(srcDirs, docsOptions);
|
|
11803
12115
|
const generated = generateMarkdown(extracted, docsOptions);
|
|
11804
12116
|
await writeDocs(generated, outDir, extracted, docsOptions);
|
|
@@ -11867,7 +12179,7 @@ function oxContent(options = {}) {
|
|
|
11867
12179
|
const docsOptions = resolvedOptions.docs;
|
|
11868
12180
|
if (!docsOptions || !docsOptions.enabled) return;
|
|
11869
12181
|
const root = config?.root || process.cwd();
|
|
11870
|
-
const srcDirs = docsOptions.src.map((src) => path
|
|
12182
|
+
const srcDirs = docsOptions.src.map((src) => path.resolve(root, src));
|
|
11871
12183
|
for (const srcDir of srcDirs) devServer.watcher.add(srcDir);
|
|
11872
12184
|
devServer.watcher.on("all", async (event, file) => {
|
|
11873
12185
|
if (event !== "add" && event !== "change" && event !== "unlink") return;
|
|
@@ -11883,7 +12195,7 @@ function oxContent(options = {}) {
|
|
|
11883
12195
|
configureServer(devServer) {
|
|
11884
12196
|
if (!resolvedOptions.ssg.enabled) return;
|
|
11885
12197
|
const root = config?.root || process.cwd();
|
|
11886
|
-
const srcDir = path
|
|
12198
|
+
const srcDir = path.resolve(root, resolvedOptions.srcDir);
|
|
11887
12199
|
devServer.middlewares.use(createDevServerMiddleware(resolvedOptions, root, ssgDevCache));
|
|
11888
12200
|
devServer.watcher.on("add", (file) => {
|
|
11889
12201
|
if (file.startsWith(srcDir) && file.endsWith(".md")) {
|
|
@@ -11920,7 +12232,7 @@ function oxContent(options = {}) {
|
|
|
11920
12232
|
const root = config?.root || process.cwd();
|
|
11921
12233
|
try {
|
|
11922
12234
|
const result = await buildSsg(resolvedOptions, root);
|
|
11923
|
-
if (result.files.length > 0) console.log(`[ox-content] Generated ${result.files.length}
|
|
12235
|
+
if (result.files.length > 0) console.log(`[ox-content] Generated ${result.files.length} output files`);
|
|
11924
12236
|
if (result.errors.length > 0) for (const error of result.errors) console.warn(`[ox-content] ${error}`);
|
|
11925
12237
|
} catch (err) {
|
|
11926
12238
|
console.error("[ox-content] SSG build failed:", err);
|
|
@@ -11950,7 +12262,7 @@ function oxContent(options = {}) {
|
|
|
11950
12262
|
async buildStart() {
|
|
11951
12263
|
if (!resolvedOptions.search.enabled) return;
|
|
11952
12264
|
const root = config?.root || process.cwd();
|
|
11953
|
-
const srcDir = path
|
|
12265
|
+
const srcDir = path.resolve(root, resolvedOptions.srcDir);
|
|
11954
12266
|
try {
|
|
11955
12267
|
searchIndexJson = await buildSearchIndex(srcDir, resolvedOptions.base);
|
|
11956
12268
|
console.log("[ox-content] Search index built");
|
|
@@ -11961,10 +12273,10 @@ function oxContent(options = {}) {
|
|
|
11961
12273
|
async closeBundle() {
|
|
11962
12274
|
if (!resolvedOptions.search.enabled || !searchIndexJson) return;
|
|
11963
12275
|
const root = config?.root || process.cwd();
|
|
11964
|
-
const outDir = path
|
|
12276
|
+
const outDir = path.resolve(root, resolvedOptions.outDir);
|
|
11965
12277
|
try {
|
|
11966
12278
|
await writeSearchIndex(searchIndexJson, outDir);
|
|
11967
|
-
console.log("[ox-content] Search index written to", path
|
|
12279
|
+
console.log("[ox-content] Search index written to", path.join(outDir, "search-index.json"));
|
|
11968
12280
|
} catch (err) {
|
|
11969
12281
|
console.warn("[ox-content] Failed to write search index:", err);
|
|
11970
12282
|
}
|
|
@@ -11992,6 +12304,7 @@ function resolveOptions(options) {
|
|
|
11992
12304
|
highlight: options.highlight ?? false,
|
|
11993
12305
|
highlightTheme: options.highlightTheme ?? "github-dark",
|
|
11994
12306
|
highlightLangs: options.highlightLangs ?? [],
|
|
12307
|
+
codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),
|
|
11995
12308
|
mermaid: options.mermaid ?? false,
|
|
11996
12309
|
frontmatter: options.frontmatter ?? true,
|
|
11997
12310
|
toc: options.toc ?? true,
|
|
@@ -12005,12 +12318,32 @@ function resolveOptions(options) {
|
|
|
12005
12318
|
i18n: resolveI18nOptions(options.i18n)
|
|
12006
12319
|
};
|
|
12007
12320
|
}
|
|
12321
|
+
function resolveCodeAnnotationsOptions(options) {
|
|
12322
|
+
if (!options) return {
|
|
12323
|
+
enabled: false,
|
|
12324
|
+
notation: "attribute",
|
|
12325
|
+
metaKey: "annotate",
|
|
12326
|
+
defaultLineNumbers: false
|
|
12327
|
+
};
|
|
12328
|
+
if (options === true) return {
|
|
12329
|
+
enabled: true,
|
|
12330
|
+
notation: "attribute",
|
|
12331
|
+
metaKey: "annotate",
|
|
12332
|
+
defaultLineNumbers: false
|
|
12333
|
+
};
|
|
12334
|
+
return {
|
|
12335
|
+
enabled: true,
|
|
12336
|
+
notation: options.notation ?? "attribute",
|
|
12337
|
+
metaKey: options.metaKey ?? "annotate",
|
|
12338
|
+
defaultLineNumbers: options.defaultLineNumbers ?? false
|
|
12339
|
+
};
|
|
12340
|
+
}
|
|
12008
12341
|
/**
|
|
12009
12342
|
* Generates virtual module content.
|
|
12010
12343
|
*/
|
|
12011
|
-
function generateVirtualModule(path, options) {
|
|
12012
|
-
if (path === "config") return `export default ${JSON.stringify(options)};`;
|
|
12013
|
-
if (path === "runtime") return `
|
|
12344
|
+
function generateVirtualModule(path$2, options) {
|
|
12345
|
+
if (path$2 === "config") return `export default ${JSON.stringify(options)};`;
|
|
12346
|
+
if (path$2 === "runtime") return `
|
|
12014
12347
|
export function useMarkdown() {
|
|
12015
12348
|
return {
|
|
12016
12349
|
render: (content) => {
|
|
@@ -12022,7 +12355,6 @@ function generateVirtualModule(path, options) {
|
|
|
12022
12355
|
`;
|
|
12023
12356
|
return "export default {};";
|
|
12024
12357
|
}
|
|
12025
|
-
|
|
12026
12358
|
//#endregion
|
|
12027
12359
|
exports.DEFAULT_HTML_TEMPLATE = DEFAULT_HTML_TEMPLATE;
|
|
12028
12360
|
exports.DefaultTheme = DefaultTheme;
|
|
@@ -12085,4 +12417,5 @@ exports.useSiteConfig = useSiteConfig;
|
|
|
12085
12417
|
exports.when = when;
|
|
12086
12418
|
exports.writeDocs = writeDocs;
|
|
12087
12419
|
exports.writeSearchIndex = writeSearchIndex;
|
|
12420
|
+
|
|
12088
12421
|
//# sourceMappingURL=index.cjs.map
|