@brillout/docpress 0.15.10-commit-ef0b9a0 → 0.15.10-commit-e9efbd3

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.
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  export { Warning };
2
13
  export { Advanced };
3
14
  export { Construction };
@@ -16,38 +27,39 @@ import React from 'react';
16
27
  import { assert } from '../utils/assert';
17
28
  import './Note.css';
18
29
  function Warning(props) {
19
- return React.createElement(NoteGeneric, { type: "warning", ...props });
30
+ return React.createElement(NoteGeneric, __assign({ type: "warning" }, props));
20
31
  }
21
32
  function Advanced(props) {
22
- return React.createElement(NoteGeneric, { type: "advanced", ...props });
33
+ return React.createElement(NoteGeneric, __assign({ type: "advanced" }, props));
23
34
  }
24
35
  function Construction(props) {
25
- return React.createElement(NoteGeneric, { type: "construction", ...props });
36
+ return React.createElement(NoteGeneric, __assign({ type: "construction" }, props));
26
37
  }
27
38
  function Contribution(props) {
28
- return React.createElement(NoteGeneric, { type: "contribution", ...props });
39
+ return React.createElement(NoteGeneric, __assign({ type: "contribution" }, props));
29
40
  }
30
41
  function Danger(props) {
31
- return React.createElement(NoteGeneric, { type: "danger", ...props });
42
+ return React.createElement(NoteGeneric, __assign({ type: "danger" }, props));
32
43
  }
33
44
  function NoteWithoutIcon(props) {
34
- return React.createElement(NoteGeneric, { icon: null, ...props });
45
+ return React.createElement(NoteGeneric, __assign({ icon: null }, props));
35
46
  }
36
47
  function NoteWithCustomIcon(props) {
37
- const { icon } = props;
48
+ var icon = props.icon;
38
49
  if (!icon)
39
- throw new Error(`<NoteWithCustomIcon icon={/*...*/}> property 'icon' is \`${icon}\` which is forbidden`);
40
- return React.createElement(NoteGeneric, { ...props });
50
+ throw new Error("<NoteWithCustomIcon icon={/*...*/}> property 'icon' is `".concat(icon, "` which is forbidden"));
51
+ return React.createElement(NoteGeneric, __assign({}, props));
41
52
  }
42
- function NoteGeneric({ type, icon, iconMargin, children, style, }) {
43
- assert(icon === null || icon || type, { icon, type });
44
- iconMargin ?? (iconMargin = 2);
45
- let className = 'custom-icon';
53
+ function NoteGeneric(_a) {
54
+ var type = _a.type, icon = _a.icon, iconMargin = _a.iconMargin, children = _a.children, style = _a.style;
55
+ assert(icon === null || icon || type, { icon: icon, type: type });
56
+ iconMargin !== null && iconMargin !== void 0 ? iconMargin : (iconMargin = 2);
57
+ var className = 'custom-icon';
46
58
  if (type) {
47
- className = `${className} type-${type}`;
59
+ className = "".concat(className, " type-").concat(type);
48
60
  }
49
61
  if (!icon && type) {
50
- let classColor = '';
62
+ var classColor = '';
51
63
  if (type === 'danger') {
52
64
  icon = '⛔';
53
65
  classColor = 'note-color-red';
@@ -70,13 +82,13 @@ function NoteGeneric({ type, icon, iconMargin, children, style, }) {
70
82
  }
71
83
  assert(icon);
72
84
  assert(classColor);
73
- className = `${className} ${classColor}`;
85
+ className = "".concat(className, " ").concat(classColor);
74
86
  }
75
87
  return (React.createElement("blockquote", { className: className, style: style },
76
88
  React.createElement("div", { style: { marginBottom: 20 } }),
77
89
  icon && (React.createElement(React.Fragment, null,
78
90
  React.createElement("span", { style: { fontFamily: 'emoji' } }, icon),
79
- React.createElement("span", { style: { width: iconMargin ?? undefined, display: 'inline-block' } }),
91
+ React.createElement("span", { style: { width: iconMargin !== null && iconMargin !== void 0 ? iconMargin : undefined, display: 'inline-block' } }),
80
92
  ' ')),
81
93
  React.createElement("div", { className: "blockquote-content" }, children),
82
94
  React.createElement("div", { style: { marginTop: 20 } })));
@@ -1,6 +1,17 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import React from 'react';
2
13
  import './P.css';
3
14
  export { P };
4
15
  function P(props) {
5
- return React.createElement("div", { ...props, className: 'paragraph' });
16
+ return React.createElement("div", __assign({}, props, { className: 'paragraph' }));
6
17
  }
@@ -2,19 +2,21 @@ export { RepoLink };
2
2
  export { getRepoHref };
3
3
  import React from 'react';
4
4
  import { usePageContext } from '../renderer/usePageContext';
5
- function RepoLink({ path, text }) {
5
+ function RepoLink(_a) {
6
+ var path = _a.path, text = _a.text;
6
7
  text = text || path;
7
- const href = getRepoHref(path);
8
+ var href = getRepoHref(path);
8
9
  return React.createElement("a", { href: href }, text);
9
10
  }
10
- function getRepoHref(path, editMode = false) {
11
- const pageContext = usePageContext();
11
+ function getRepoHref(path, editMode) {
12
+ if (editMode === void 0) { editMode = false; }
13
+ var pageContext = usePageContext();
12
14
  if (!path.startsWith('/')) {
13
15
  path = '/' + path;
14
16
  }
15
- const viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob';
16
- const { github } = pageContext.globalContext.config.docpress;
17
- let href = `${github}/${viewMode}/main${path}`;
17
+ var viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob';
18
+ var github = pageContext.globalContext.config.docpress.github;
19
+ var href = "".concat(github, "/").concat(viewMode, "/main").concat(path);
18
20
  if (editMode)
19
21
  href += '?plain=1';
20
22
  return href;
@@ -1,26 +1,47 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
1
21
  export { determineNavItemsColumnLayout };
2
22
  import { assert, assertUsage } from './utils/assert';
3
23
  function determineNavItemsColumnLayout(navItems) {
4
- const columnLayouts = getColumnEntries(navItems);
5
- columnLayouts.forEach((columnEntries) => {
6
- for (let numberOfColumns = columnEntries.length; numberOfColumns >= 1; numberOfColumns--) {
7
- const columnMapping = determineColumnLayout(columnEntries.map((columnEntry) => columnEntry.numberOfEntries), numberOfColumns);
8
- columnEntries.forEach((columnEntry, i) => {
24
+ var columnLayouts = getColumnEntries(navItems);
25
+ columnLayouts.forEach(function (columnEntries) {
26
+ var _loop_1 = function (numberOfColumns) {
27
+ var columnMapping = determineColumnLayout(columnEntries.map(function (columnEntry) { return columnEntry.numberOfEntries; }), numberOfColumns);
28
+ columnEntries.forEach(function (columnEntry, i) {
9
29
  var _a;
10
- (_a = columnEntry.navItemLeader).isColumnEntry ?? (_a.isColumnEntry = {});
30
+ var _b;
31
+ (_a = (_b = columnEntry.navItemLeader).isColumnEntry) !== null && _a !== void 0 ? _a : (_b.isColumnEntry = {});
11
32
  columnEntry.navItemLeader.isColumnEntry[numberOfColumns] = columnMapping[i];
12
33
  });
34
+ };
35
+ for (var numberOfColumns = columnEntries.length; numberOfColumns >= 1; numberOfColumns--) {
36
+ _loop_1(numberOfColumns);
13
37
  }
14
38
  });
15
39
  }
16
40
  function getColumnEntries(navItems) {
17
- const navItemsWithLength = navItems.map((navItem) => ({
18
- ...navItem,
19
- numberOfHeadings: navItem.level === 1 || navItem.level === 4 ? 0 : null,
20
- }));
21
- let navItemLevel1;
22
- let navItemLevel4;
23
- navItemsWithLength.forEach((navItem) => {
41
+ var navItemsWithLength = navItems.map(function (navItem) { return (__assign(__assign({}, navItem), { numberOfHeadings: navItem.level === 1 || navItem.level === 4 ? 0 : null })); });
42
+ var navItemLevel1;
43
+ var navItemLevel4;
44
+ navItemsWithLength.forEach(function (navItem) {
24
45
  if (navItem.level === 1) {
25
46
  navItemLevel1 = navItem;
26
47
  navItemLevel4 = undefined;
@@ -30,7 +51,7 @@ function getColumnEntries(navItems) {
30
51
  navItemLevel4 = navItem;
31
52
  return;
32
53
  }
33
- const bumpNavItemLength = (navItem) => {
54
+ var bumpNavItemLength = function (navItem) {
34
55
  assert(navItem.numberOfHeadings !== null);
35
56
  navItem.numberOfHeadings++;
36
57
  };
@@ -40,13 +61,13 @@ function getColumnEntries(navItems) {
40
61
  bumpNavItemLength(navItemLevel4);
41
62
  }
42
63
  });
43
- const columnLayouts = [];
44
- let columnEntries = [];
45
- let isFullWidthCategory;
46
- navItemsWithLength.forEach((navItem, i) => {
47
- let isFullWidthCategoryBegin = false;
64
+ var columnLayouts = [];
65
+ var columnEntries = [];
66
+ var isFullWidthCategory;
67
+ navItemsWithLength.forEach(function (navItem, i) {
68
+ var isFullWidthCategoryBegin = false;
48
69
  if (navItem.level === 1) {
49
- const isFullWidthCategoryPrevious = isFullWidthCategory;
70
+ var isFullWidthCategoryPrevious = isFullWidthCategory;
50
71
  isFullWidthCategory = !!navItem.menuModalFullWidth;
51
72
  if (isFullWidthCategory)
52
73
  isFullWidthCategoryBegin = true;
@@ -55,8 +76,8 @@ function getColumnEntries(navItems) {
55
76
  columnEntries = [];
56
77
  }
57
78
  }
58
- const navItemPrevious = navItemsWithLength[i - 1];
59
- const navItemNext = navItemsWithLength[i + 1];
79
+ var navItemPrevious = navItemsWithLength[i - 1];
80
+ var navItemNext = navItemsWithLength[i + 1];
60
81
  if (!isFullWidthCategory
61
82
  ? navItem.level === 1
62
83
  : (navItem.level === 4 && navItemPrevious.level !== 1) || isFullWidthCategoryBegin) {
@@ -66,7 +87,7 @@ function getColumnEntries(navItems) {
66
87
  else {
67
88
  assert(navItem.level === 1);
68
89
  }
69
- let { numberOfHeadings } = navItem;
90
+ var numberOfHeadings = navItem.numberOfHeadings;
70
91
  assert(numberOfHeadings !== null);
71
92
  if (isFullWidthCategoryBegin) {
72
93
  assert(navItem.level === 1);
@@ -85,15 +106,15 @@ function getColumnEntries(navItems) {
85
106
  }
86
107
  function determineColumnLayout(columnsUnmerged, numberOfColumns) {
87
108
  assert(numberOfColumns <= columnsUnmerged.length);
88
- const columnsMergingInit = columnsUnmerged.map((columnHeight, i) => ({
109
+ var columnsMergingInit = columnsUnmerged.map(function (columnHeight, i) { return ({
89
110
  columnIdsMerged: [i],
90
111
  heightTotal: columnHeight,
91
- }));
92
- const columnsMerged = mergeColumns(columnsMergingInit, numberOfColumns);
93
- const columnsIdMap = new Array(columnsUnmerged.length);
112
+ }); });
113
+ var columnsMerged = mergeColumns(columnsMergingInit, numberOfColumns);
114
+ var columnsIdMap = new Array(columnsUnmerged.length);
94
115
  assert(columnsMerged.length === numberOfColumns);
95
- columnsMerged.forEach((columnMerged, columnMergedId) => {
96
- columnMerged.columnIdsMerged.forEach((columnId) => {
116
+ columnsMerged.forEach(function (columnMerged, columnMergedId) {
117
+ columnMerged.columnIdsMerged.forEach(function (columnId) {
97
118
  columnsIdMap[columnId] = columnMergedId;
98
119
  });
99
120
  });
@@ -103,32 +124,25 @@ function determineColumnLayout(columnsUnmerged, numberOfColumns) {
103
124
  function mergeColumns(columnsMerging, numberOfColumns) {
104
125
  if (columnsMerging.length <= numberOfColumns)
105
126
  return columnsMerging;
106
- let mergeCandidate = null;
107
- for (let i = 0; i <= columnsMerging.length - 2; i++) {
108
- const column1 = columnsMerging[i + 0];
109
- const column2 = columnsMerging[i + 1];
110
- const heightTotal = column1.heightTotal + column2.heightTotal;
127
+ var mergeCandidate = null;
128
+ for (var i_1 = 0; i_1 <= columnsMerging.length - 2; i_1++) {
129
+ var column1 = columnsMerging[i_1 + 0];
130
+ var column2 = columnsMerging[i_1 + 1];
131
+ var heightTotal = column1.heightTotal + column2.heightTotal;
111
132
  if (!mergeCandidate || mergeCandidate.heightTotal > heightTotal) {
112
133
  mergeCandidate = {
113
- i,
114
- columnIdsMerged: [
115
- //
116
- ...column1.columnIdsMerged,
117
- ...column2.columnIdsMerged,
118
- ],
119
- heightTotal,
134
+ i: i_1,
135
+ columnIdsMerged: __spreadArray(__spreadArray([], column1.columnIdsMerged, true), column2.columnIdsMerged, true),
136
+ heightTotal: heightTotal,
120
137
  };
121
138
  }
122
139
  }
123
140
  assert(mergeCandidate);
124
- const { i } = mergeCandidate;
141
+ var i = mergeCandidate.i;
125
142
  assert(-1 < i && i < columnsMerging.length - 1);
126
- const columnsMergingMod = [
127
- //
128
- ...columnsMerging.slice(0, i),
129
- mergeCandidate,
130
- ...columnsMerging.slice(i + 2),
131
- ];
143
+ var columnsMergingMod = __spreadArray(__spreadArray(__spreadArray([], columnsMerging.slice(0, i), true), [
144
+ mergeCandidate
145
+ ], false), columnsMerging.slice(i + 2), true);
132
146
  assert(columnsMergingMod.length === columnsMerging.length - 1);
133
147
  return mergeColumns(columnsMergingMod, numberOfColumns);
134
148
  }
@@ -1,53 +1,140 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  export { detypePlugin };
2
38
  import module from 'node:module';
3
39
  // Cannot use `import { transform } from 'detype'` as it results in errors,
4
40
  // and the package has no default export. Using `module.createRequire` instead.
5
- const { transform } = module.createRequire(import.meta.url)('detype');
41
+ var transform = module.createRequire(import.meta.url)('detype').transform;
6
42
  function detypePlugin() {
43
+ var _this = this;
7
44
  return {
8
45
  name: '@brillout/docpress:detypePlugin',
9
46
  enforce: 'pre',
10
- transform: async (code, id) => {
11
- if (!id.endsWith('+Page.mdx')) {
12
- return;
13
- }
14
- const codeNew = await transformCode(code);
15
- return codeNew;
16
- },
47
+ transform: function (code, id) { return __awaiter(_this, void 0, void 0, function () {
48
+ var codeNew;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0:
52
+ if (!id.endsWith('+Page.mdx')) {
53
+ return [2 /*return*/];
54
+ }
55
+ return [4 /*yield*/, transformCode(code)];
56
+ case 1:
57
+ codeNew = _a.sent();
58
+ return [2 /*return*/, codeNew];
59
+ }
60
+ });
61
+ }); },
17
62
  };
18
63
  }
19
- const tsBlockRegex = /```(tsx?|vue)(\s+ts-only)?([\s\S]*?)```/g;
20
- async function transformCode(code) {
21
- let codeNew = `import { CodeSnippets, CodeSnippet } from '@brillout/docpress';\n`;
22
- let lastIndex = 0;
23
- const matches = [...code.matchAll(tsBlockRegex)];
24
- if (matches.length === 0) {
64
+ var codeBlockRE = /^([ \t]{0,3}>?[ \t]?)```(tsx?|vue)[^\n]*\n([\s\S]*?)```/gm;
65
+ var prettierOptions = {
66
+ semi: false,
67
+ singleQuote: true,
68
+ printWidth: 100,
69
+ };
70
+ function transformCode(code) {
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ var matches, codeNew, lastIndex, _i, matches_1, match, fullMatch, startsWith, lang, tsCode, tsOpeningCode, blockStart, blockEnd, jsCode, jsLang, jsOpeningCode, closing, jsCodeSnippet, tsCodeSnippet, codeSnippets;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ matches = Array.from(code.matchAll(codeBlockRE));
77
+ if (matches.length === 0) {
78
+ return [2 /*return*/, code];
79
+ }
80
+ codeNew = "import { CodeSnippets, CodeSnippet } from '@brillout/docpress';\n\n";
81
+ lastIndex = 0;
82
+ _i = 0, matches_1 = matches;
83
+ _a.label = 1;
84
+ case 1:
85
+ if (!(_i < matches_1.length)) return [3 /*break*/, 6];
86
+ match = matches_1[_i];
87
+ fullMatch = match[0], startsWith = match[1], lang = match[2], tsCode = match[3];
88
+ tsOpeningCode = fullMatch.split('\n')[0].slice(startsWith.length);
89
+ blockStart = match.index;
90
+ blockEnd = blockStart + fullMatch.length;
91
+ codeNew += code.slice(lastIndex, blockStart);
92
+ if (startsWith.length > 0) {
93
+ tsCode = stripStarts(tsCode, startsWith);
94
+ }
95
+ if (!tsOpeningCode.includes('ts-only')) return [3 /*break*/, 2];
96
+ codeNew += "".concat(startsWith, "<CodeSnippet language={'ts'} tsOnly={'true'}>\n").concat(fullMatch, "\n").concat(startsWith, "</CodeSnippet>");
97
+ return [3 /*break*/, 4];
98
+ case 2: return [4 /*yield*/, transform(tsCode.replaceAll('.ts', '.js'), "tsCode.".concat(lang), {
99
+ removeTsComments: true,
100
+ prettierOptions: prettierOptions,
101
+ })];
102
+ case 3:
103
+ jsCode = _a.sent();
104
+ jsLang = lang === 'vue' ? 'vue' : lang.replace('t', 'j') // ts => js | tsx => jsx
105
+ ;
106
+ jsOpeningCode = tsOpeningCode.replace(lang, jsLang);
107
+ closing = "```";
108
+ jsCodeSnippet = "<CodeSnippet language={'js'}>\n".concat(jsOpeningCode, "\n").concat(jsCode).concat(closing, "\n</CodeSnippet>");
109
+ tsCodeSnippet = "<CodeSnippet language={'ts'}>\n".concat(tsOpeningCode, "\n").concat(tsCode).concat(closing, "\n</CodeSnippet>");
110
+ codeSnippets = putBackStarts("<CodeSnippets>\n".concat(tsCodeSnippet, "\n").concat(jsCodeSnippet, "\n</CodeSnippets>"), startsWith);
111
+ codeNew += codeSnippets;
112
+ _a.label = 4;
113
+ case 4:
114
+ lastIndex = blockEnd;
115
+ _a.label = 5;
116
+ case 5:
117
+ _i++;
118
+ return [3 /*break*/, 1];
119
+ case 6:
120
+ codeNew += code.slice(lastIndex);
121
+ return [2 /*return*/, codeNew];
122
+ }
123
+ });
124
+ });
125
+ }
126
+ function stripStarts(code, startsWith) {
127
+ return code
128
+ .split('\n')
129
+ .map(function (line) { return line.slice(startsWith.length); })
130
+ .join('\n');
131
+ }
132
+ function putBackStarts(code, startsWith) {
133
+ if (!startsWith.length) {
25
134
  return code;
26
135
  }
27
- for (const match of matches) {
28
- const [tsCodeBlock, lang, tsOnly, tsCode] = match; // lang = ts | tsx | vue
29
- const type = lang === 'vue' ? 'vue' : lang.replace('t', 'j'); // ts => js | tsx => jsx
30
- const blockStart = match.index;
31
- const blockEnd = blockStart + tsCodeBlock.length;
32
- codeNew += code.slice(lastIndex, blockStart);
33
- if (tsOnly) {
34
- codeNew += `\n<CodeSnippet language={'ts'} tsOnly={'true'}>\n${tsCodeBlock}\n</CodeSnippet>\n`;
35
- }
36
- else {
37
- const jsCode = await transform(tsCode.trim().replaceAll('.ts', '.js'), `tsCode.${lang}`, {
38
- removeTsComments: true,
39
- prettierOptions: {
40
- semi: false,
41
- singleQuote: true,
42
- },
43
- });
44
- const jsCodeBlock = `\`\`\`${type}\n${jsCode}\`\`\``;
45
- const jsCodeSnippet = `\n<CodeSnippet language={'js'}>\n${jsCodeBlock}\n</CodeSnippet>\n`;
46
- const tsCodeSnippet = `\n<CodeSnippet language={'ts'}>\n${tsCodeBlock}\n</CodeSnippet>\n`;
47
- codeNew += `<CodeSnippets>${jsCodeSnippet}${tsCodeSnippet}</CodeSnippets>`;
48
- }
49
- lastIndex = blockEnd;
50
- }
51
- codeNew += code.slice(lastIndex);
52
- return codeNew;
136
+ return code
137
+ .split('\n')
138
+ .map(function (line) { return "".concat(startsWith).concat(line); })
139
+ .join('\n');
53
140
  }
@@ -1,11 +1,20 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
1
10
  export { parseMarkdownMini };
2
11
  import React from 'react';
3
12
  function parseMarkdownMini(markdown) {
4
- const parts = [];
5
- let current;
6
- markdown.split('').forEach((letter) => {
13
+ var parts = [];
14
+ var current;
15
+ markdown.split('').forEach(function (letter) {
7
16
  if (letter === '`') {
8
- if (current?.nodeType === 'code') {
17
+ if ((current === null || current === void 0 ? void 0 : current.nodeType) === 'code') {
9
18
  // </code>
10
19
  parts.push(current);
11
20
  current = undefined;
@@ -28,6 +37,9 @@ function parseMarkdownMini(markdown) {
28
37
  if (current) {
29
38
  parts.push(current);
30
39
  }
31
- const parsed = React.createElement(React.Fragment, {}, ...parts.map((part, i) => React.createElement(part.nodeType === 'code' ? 'code' : React.Fragment, { key: i }, part.content)));
40
+ var parsed = React.createElement.apply(React, __spreadArray([React.Fragment,
41
+ {}], parts.map(function (part, i) {
42
+ return React.createElement(part.nodeType === 'code' ? 'code' : React.Fragment, { key: i }, part.content);
43
+ }), false));
32
44
  return parsed;
33
45
  }