@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,26 +1,66 @@
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 { parsePageSections };
2
38
  import { assert } from './utils/assert.js';
3
39
  import { determineSectionUrlHash } from './utils/determineSectionUrlHash.js';
4
40
  import os from 'os';
5
41
  function parsePageSections() {
42
+ var _this = this;
6
43
  return {
7
44
  name: '@brillout/docpress:parsePageSections',
8
45
  enforce: 'pre',
9
- transform: async (code, id) => {
10
- if (!id.endsWith('+Page.mdx')) {
11
- return;
12
- }
13
- const codeNew = transform(code);
14
- return codeNew;
15
- },
46
+ transform: function (code, id) { return __awaiter(_this, void 0, void 0, function () {
47
+ var codeNew;
48
+ return __generator(this, function (_a) {
49
+ if (!id.endsWith('+Page.mdx')) {
50
+ return [2 /*return*/];
51
+ }
52
+ codeNew = transform(code);
53
+ return [2 /*return*/, codeNew];
54
+ });
55
+ }); },
16
56
  };
17
57
  }
18
58
  function transform(code) {
19
- const pageSections = [];
20
- let isCodeBlock = false;
21
- let codeNew = code
59
+ var pageSections = [];
60
+ var isCodeBlock = false;
61
+ var codeNew = code
22
62
  .split('\n')
23
- .map((line) => {
63
+ .map(function (line) {
24
64
  // Skip code blocks, e.g.
25
65
  // ~~~md
26
66
  // # Markdown Example
@@ -38,50 +78,51 @@ function transform(code) {
38
78
  || line.startsWith('<h2')
39
79
  */
40
80
  ) {
41
- const { pageSectionId, pageSectionLevel, pageSectionTitle, headingHtml } = parsePageSection(line);
42
- pageSections.push({ pageSectionId, pageSectionLevel, pageSectionTitle });
81
+ var _a = parsePageSection(line), pageSectionId = _a.pageSectionId, pageSectionLevel = _a.pageSectionLevel, pageSectionTitle = _a.pageSectionTitle, headingHtml = _a.headingHtml;
82
+ pageSections.push({ pageSectionId: pageSectionId, pageSectionLevel: pageSectionLevel, pageSectionTitle: pageSectionTitle });
43
83
  return headingHtml;
44
84
  }
45
85
  return line;
46
86
  })
47
87
  .join('\n');
48
- const exportCode = `export const pageSectionsExport = [${pageSections
49
- .map((pageSection) => JSON.stringify(pageSection))
50
- .join(', ')}];`;
51
- codeNew += `\n\n${exportCode}\n`;
88
+ var exportCode = "export const pageSectionsExport = [".concat(pageSections
89
+ .map(function (pageSection) { return JSON.stringify(pageSection); })
90
+ .join(', '), "];");
91
+ codeNew += "\n\n".concat(exportCode, "\n");
52
92
  return codeNew;
53
93
  }
54
94
  function parsePageSection(line) {
55
- const [lineBegin, ...lineWords] = line.split(' ');
56
- assert(lineBegin.split('#').join('') === '', { line, lineWords });
57
- const pageSectionLevel = lineBegin.length;
58
- const titleMdx = lineWords.join(' ');
59
- assert(!titleMdx.startsWith(' '), { line, lineWords });
60
- assert(titleMdx, { line, lineWords });
61
- let pageSectionTitle = titleMdx;
62
- let anchor = titleMdx;
95
+ var _a;
96
+ var _b = line.split(' '), lineBegin = _b[0], lineWords = _b.slice(1);
97
+ assert(lineBegin.split('#').join('') === '', { line: line, lineWords: lineWords });
98
+ var pageSectionLevel = lineBegin.length;
99
+ var titleMdx = lineWords.join(' ');
100
+ assert(!titleMdx.startsWith(' '), { line: line, lineWords: lineWords });
101
+ assert(titleMdx, { line: line, lineWords: lineWords });
102
+ var pageSectionTitle = titleMdx;
103
+ var anchor = titleMdx;
63
104
  {
64
105
  // Support custom anchor: `## Some Title{#custom-anchor}`
65
- const customAnchor = /(?<={#).*(?=})/g.exec(titleMdx)?.[0];
106
+ var customAnchor = (_a = /(?<={#).*(?=})/g.exec(titleMdx)) === null || _a === void 0 ? void 0 : _a[0];
66
107
  if (customAnchor) {
67
108
  anchor = customAnchor;
68
109
  pageSectionTitle = titleMdx.replace(/{#.*}/g, '');
69
110
  }
70
111
  }
71
- const pageSectionId = determineSectionUrlHash(anchor);
72
- const titleParsed = parseMarkdownMini(pageSectionTitle);
112
+ var pageSectionId = determineSectionUrlHash(anchor);
113
+ var titleParsed = parseMarkdownMini(pageSectionTitle);
73
114
  assert(pageSectionId === null || pageSectionId.length > 0);
74
- const headingId = pageSectionId === null ? '' : ` id="${pageSectionId}"`;
75
- const headingHtml = `<h${pageSectionLevel}${headingId}>${titleParsed}</h${pageSectionLevel}>`;
76
- const pageSection = { pageSectionLevel, pageSectionTitle, pageSectionId, headingHtml };
115
+ var headingId = pageSectionId === null ? '' : " id=\"".concat(pageSectionId, "\"");
116
+ var headingHtml = "<h".concat(pageSectionLevel).concat(headingId, ">").concat(titleParsed, "</h").concat(pageSectionLevel, ">");
117
+ var pageSection = { pageSectionLevel: pageSectionLevel, pageSectionTitle: pageSectionTitle, pageSectionId: pageSectionId, headingHtml: headingHtml };
77
118
  return pageSection;
78
119
  }
79
120
  function parseMarkdownMini(titleMarkdown) {
80
- const parts = [];
81
- let current;
82
- titleMarkdown.split('').forEach((letter) => {
121
+ var parts = [];
122
+ var current;
123
+ titleMarkdown.split('').forEach(function (letter) {
83
124
  if (letter === '`') {
84
- if (current?.nodeType === 'code') {
125
+ if ((current === null || current === void 0 ? void 0 : current.nodeType) === 'code') {
85
126
  // </code>
86
127
  parts.push(current);
87
128
  current = undefined;
@@ -104,25 +145,25 @@ function parseMarkdownMini(titleMarkdown) {
104
145
  if (current) {
105
146
  parts.push(current);
106
147
  }
107
- const titleHtml = parts
108
- .map((part) => {
148
+ var titleHtml = parts
149
+ .map(function (part) {
109
150
  if (part.nodeType === 'code') {
110
- return `<code>${serializeText(part.content)}</code>`;
151
+ return "<code>".concat(serializeText(part.content), "</code>");
111
152
  }
112
153
  else {
113
- assert(part.nodeType === 'text', { parts });
154
+ assert(part.nodeType === 'text', { parts: parts });
114
155
  return serializeText(part.content);
115
156
  }
116
157
  })
117
158
  .join('');
118
159
  return titleHtml;
119
160
  function serializeText(text) {
120
- let textEscaped = text.split("'").join("\\'");
161
+ var textEscaped = text.split("'").join("\\'");
121
162
  // https://github.com/brillout/docpress/pull/2
122
163
  if (isWindows()) {
123
164
  textEscaped = textEscaped.replace(/\r/, '');
124
165
  }
125
- return `{'${textEscaped}'}`;
166
+ return "{'".concat(textEscaped, "'}");
126
167
  }
127
168
  }
128
169
  function isWindows() {
@@ -3,19 +3,20 @@ export { usePageContext };
3
3
  export { usePageContextLegacy };
4
4
  import React, { useContext } from 'react';
5
5
  import { getGlobalObject } from '../utils/getGlobalObject';
6
- const globalObject = getGlobalObject('usePageContext.ts', {
6
+ var globalObject = getGlobalObject('usePageContext.ts', {
7
7
  Ctx: React.createContext(undefined),
8
8
  });
9
9
  function usePageContextLegacy() {
10
- const { Ctx } = globalObject;
11
- const pageContext = useContext(Ctx);
10
+ var Ctx = globalObject.Ctx;
11
+ var pageContext = useContext(Ctx);
12
12
  return pageContext.resolved;
13
13
  }
14
14
  function usePageContext() {
15
- const pageContext = useContext(globalObject.Ctx);
15
+ var pageContext = useContext(globalObject.Ctx);
16
16
  return pageContext;
17
17
  }
18
- function PageContextProvider({ pageContext, children, }) {
19
- const { Ctx } = globalObject;
18
+ function PageContextProvider(_a) {
19
+ var pageContext = _a.pageContext, children = _a.children;
20
+ var Ctx = globalObject.Ctx;
20
21
  return React.createElement(Ctx.Provider, { value: pageContext }, children);
21
22
  }
@@ -1,3 +1,23 @@
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 { resolvePageContext };
2
22
  import { assert } from './utils/assert';
3
23
  import { jsxToTextContent } from './utils/jsxToTextContent';
@@ -5,53 +25,51 @@ import pc from '@brillout/picocolors';
5
25
  import { parseMarkdownMini } from './parseMarkdownMini';
6
26
  import { determineNavItemsColumnLayout } from './determineNavItemsColumnLayout';
7
27
  function resolvePageContext(pageContext) {
8
- const config = pageContext.globalContext.config.docpress;
9
- const { urlPathname } = pageContext;
10
- const pageSections = pageContext.config.pageSectionsExport ?? [];
28
+ var _a;
29
+ var config = pageContext.globalContext.config.docpress;
30
+ var urlPathname = pageContext.urlPathname;
31
+ var pageSections = (_a = pageContext.config.pageSectionsExport) !== null && _a !== void 0 ? _a : [];
11
32
  {
12
- const { headings, headingsDetached } = config;
13
- assertHeadingsDefinition([...headings, ...headingsDetached]);
33
+ var headings = config.headings, headingsDetached = config.headingsDetached;
34
+ assertHeadingsDefinition(__spreadArray(__spreadArray([], headings, true), headingsDetached, true));
14
35
  }
15
- const ret = getHeadingsResolved(config);
16
- const { headingsDetachedResolved } = ret;
17
- let { headingsResolved } = ret;
18
- const { activeHeading, isDetachedPage, activeCategoryName } = getActiveHeading(headingsResolved, headingsDetachedResolved, urlPathname);
19
- const { documentTitle, isLandingPage, pageTitle } = getTitles(activeHeading, urlPathname, config);
20
- const pageSectionsResolved = getPageSectionsResolved(pageSections, activeHeading);
21
- const linksGlobal = [
22
- ...headingsResolved.map(headingToLinkData),
23
- ...headingsDetachedResolved.map(headingToLinkData),
24
- ];
25
- const linksPage = pageSectionsResolved.map(pageSectionToLinkData);
26
- const linksAll = [...linksPage, ...linksGlobal];
27
- let navItemsAll;
28
- let navItemsDetached;
36
+ var ret = getHeadingsResolved(config);
37
+ var headingsDetachedResolved = ret.headingsDetachedResolved;
38
+ var headingsResolved = ret.headingsResolved;
39
+ var _b = getActiveHeading(headingsResolved, headingsDetachedResolved, urlPathname), activeHeading = _b.activeHeading, isDetachedPage = _b.isDetachedPage, activeCategoryName = _b.activeCategoryName;
40
+ var _c = getTitles(activeHeading, urlPathname, config), documentTitle = _c.documentTitle, isLandingPage = _c.isLandingPage, pageTitle = _c.pageTitle;
41
+ var pageSectionsResolved = getPageSectionsResolved(pageSections, activeHeading);
42
+ var linksGlobal = __spreadArray(__spreadArray([], headingsResolved.map(headingToLinkData), true), headingsDetachedResolved.map(headingToLinkData), true);
43
+ var linksPage = pageSectionsResolved.map(pageSectionToLinkData);
44
+ var linksAll = __spreadArray(__spreadArray([], linksPage, true), linksGlobal, true);
45
+ var navItemsAll;
46
+ var navItemsDetached;
29
47
  {
30
- const navItemsPageSections = pageSectionsResolved
31
- .filter((pageSection) => pageSection.pageSectionLevel === 2)
48
+ var navItemsPageSections = pageSectionsResolved
49
+ .filter(function (pageSection) { return pageSection.pageSectionLevel === 2; })
32
50
  .map(pageSectionToNavItem);
33
51
  navItemsAll = headingsResolved.map(headingToNavItem);
34
52
  determineNavItemsColumnLayout(navItemsAll);
35
53
  if (isDetachedPage) {
36
- navItemsDetached = [headingToNavItem(activeHeading), ...navItemsPageSections];
54
+ navItemsDetached = __spreadArray([headingToNavItem(activeHeading)], navItemsPageSections, true);
37
55
  }
38
56
  else {
39
- const activeHeadingIndex = navItemsAll.findIndex((navItem) => navItem.url === urlPathname);
40
- assert(activeHeadingIndex >= 0);
41
- navItemsPageSections.forEach((navItem, i) => {
42
- navItemsAll.splice(activeHeadingIndex + 1 + i, 0, navItem);
57
+ var activeHeadingIndex_1 = navItemsAll.findIndex(function (navItem) { return navItem.url === urlPathname; });
58
+ assert(activeHeadingIndex_1 >= 0);
59
+ navItemsPageSections.forEach(function (navItem, i) {
60
+ navItemsAll.splice(activeHeadingIndex_1 + 1 + i, 0, navItem);
43
61
  });
44
62
  }
45
63
  }
46
- const resolved = {
47
- navItemsAll,
48
- navItemsDetached,
64
+ var resolved = {
65
+ navItemsAll: navItemsAll,
66
+ navItemsDetached: navItemsDetached,
49
67
  pageDesign: activeHeading.pageDesign,
50
- linksAll,
51
- isLandingPage,
52
- pageTitle,
53
- documentTitle,
54
- activeCategoryName,
68
+ linksAll: linksAll,
69
+ isLandingPage: isLandingPage,
70
+ pageTitle: pageTitle,
71
+ documentTitle: documentTitle,
72
+ activeCategoryName: activeCategoryName,
55
73
  };
56
74
  return resolved;
57
75
  }
@@ -91,24 +109,26 @@ function pageSectionToLinkData(pageSection) {
91
109
  };
92
110
  }
93
111
  function getTitles(activeHeading, urlPathname, config) {
94
- const isLandingPage = urlPathname === '/';
95
- const { title } = activeHeading;
96
- let pageTitle = isLandingPage ? null : title;
97
- let documentTitle = activeHeading.titleDocument || jsxToTextContent(parseMarkdownMini(title));
112
+ var isLandingPage = urlPathname === '/';
113
+ var title = activeHeading.title;
114
+ var pageTitle = isLandingPage ? null : title;
115
+ var documentTitle = activeHeading.titleDocument || jsxToTextContent(parseMarkdownMini(title));
98
116
  if (!isLandingPage) {
99
117
  documentTitle += ' | ' + config.name;
100
118
  }
101
119
  if (isLandingPage) {
102
120
  pageTitle = null;
103
121
  }
104
- return { documentTitle, isLandingPage, pageTitle };
122
+ return { documentTitle: documentTitle, isLandingPage: isLandingPage, pageTitle: pageTitle };
105
123
  }
106
124
  function getActiveHeading(headingsResolved, headingsDetachedResolved, urlPathname) {
107
- let activeHeading = null;
108
- let activeCategoryName = 'Miscellaneous';
109
- let headingCategory;
125
+ var _a;
126
+ var activeHeading = null;
127
+ var activeCategoryName = 'Miscellaneous';
128
+ var headingCategory;
110
129
  assert(urlPathname);
111
- for (const heading of headingsResolved) {
130
+ for (var _i = 0, headingsResolved_1 = headingsResolved; _i < headingsResolved_1.length; _i++) {
131
+ var heading = headingsResolved_1[_i];
112
132
  if (heading.level === 1) {
113
133
  headingCategory = heading.title;
114
134
  }
@@ -116,87 +136,79 @@ function getActiveHeading(headingsResolved, headingsDetachedResolved, urlPathnam
116
136
  activeHeading = heading;
117
137
  assert(headingCategory);
118
138
  activeCategoryName = headingCategory;
119
- assert(heading.level === 2, { pageUrl: urlPathname, heading });
139
+ assert(heading.level === 2, { pageUrl: urlPathname, heading: heading });
120
140
  break;
121
141
  }
122
142
  }
123
- const isDetachedPage = !activeHeading;
143
+ var isDetachedPage = !activeHeading;
124
144
  if (!activeHeading) {
125
- activeHeading = headingsDetachedResolved.find(({ url }) => urlPathname === url) ?? null;
145
+ activeHeading = (_a = headingsDetachedResolved.find(function (_a) {
146
+ var url = _a.url;
147
+ return urlPathname === url;
148
+ })) !== null && _a !== void 0 ? _a : null;
126
149
  }
127
150
  if (!activeHeading) {
128
151
  throw new Error([
129
- `URL ${pc.bold(urlPathname)} not found in following URLs:`,
130
- [...headingsResolved, ...headingsDetachedResolved]
131
- .filter(Boolean)
132
- .map((h) => h.url)
152
+ "URL ".concat(pc.bold(urlPathname), " not found in following URLs:"),
153
+ __spreadArray(__spreadArray([], headingsResolved, true), headingsDetachedResolved, true).filter(Boolean)
154
+ .map(function (h) { return h.url; })
133
155
  .sort()
134
- .map((url) => ` ${url}`)
156
+ .map(function (url) { return " ".concat(url); })
135
157
  .join('\n'),
136
158
  ].join('\n'));
137
159
  }
138
160
  if (activeHeading.category)
139
161
  activeCategoryName = activeHeading.category;
140
- return { activeHeading, isDetachedPage, activeCategoryName };
162
+ return { activeHeading: activeHeading, isDetachedPage: isDetachedPage, activeCategoryName: activeCategoryName };
141
163
  }
142
164
  function getPageSectionsResolved(pageSections, activeHeading) {
143
- const pageSectionsResolved = pageSections.map((pageSection) => {
144
- const { pageSectionTitle } = pageSection;
145
- const url = pageSection.pageSectionId === null ? null : '#' + pageSection.pageSectionId;
146
- const pageSectionResolved = {
147
- url,
165
+ var pageSectionsResolved = pageSections.map(function (pageSection) {
166
+ var _a;
167
+ var pageSectionTitle = pageSection.pageSectionTitle;
168
+ var url = pageSection.pageSectionId === null ? null : '#' + pageSection.pageSectionId;
169
+ var pageSectionResolved = {
170
+ url: url,
148
171
  title: pageSectionTitle,
149
- linkBreadcrumb: [activeHeading.title, ...(activeHeading.linkBreadcrumb ?? [])],
172
+ linkBreadcrumb: __spreadArray([activeHeading.title], ((_a = activeHeading.linkBreadcrumb) !== null && _a !== void 0 ? _a : []), true),
150
173
  titleInNav: pageSectionTitle,
151
174
  pageSectionLevel: pageSection.pageSectionLevel,
152
175
  };
153
176
  return pageSectionResolved;
154
177
  });
155
- if (activeHeading?.sectionTitles) {
156
- activeHeading.sectionTitles.forEach((sectionTitle) => {
157
- const pageSectionTitles = pageSections.map((h) => h.pageSectionTitle);
158
- assert(pageSectionTitles.includes(sectionTitle), { pageHeadingTitles: pageSectionTitles, sectionTitle });
178
+ if (activeHeading === null || activeHeading === void 0 ? void 0 : activeHeading.sectionTitles) {
179
+ activeHeading.sectionTitles.forEach(function (sectionTitle) {
180
+ var pageSectionTitles = pageSections.map(function (h) { return h.pageSectionTitle; });
181
+ assert(pageSectionTitles.includes(sectionTitle), { pageHeadingTitles: pageSectionTitles, sectionTitle: sectionTitle });
159
182
  });
160
183
  }
161
184
  return pageSectionsResolved;
162
185
  }
163
186
  function getHeadingsResolved(config) {
164
- const headingsWithoutBreadcrumb = config.headings.map((heading) => {
165
- const titleInNav = heading.titleInNav || heading.title;
166
- const headingResolved = {
167
- ...heading,
168
- titleInNav,
169
- };
187
+ var headingsWithoutBreadcrumb = config.headings.map(function (heading) {
188
+ var titleInNav = heading.titleInNav || heading.title;
189
+ var headingResolved = __assign(__assign({}, heading), { titleInNav: titleInNav });
170
190
  return headingResolved;
171
191
  });
172
- const headingsResolved = [];
173
- headingsWithoutBreadcrumb.forEach((heading) => {
174
- const linkBreadcrumb = getHeadingsBreadcrumb(heading, headingsResolved);
175
- headingsResolved.push({
176
- ...heading,
177
- linkBreadcrumb,
178
- });
192
+ var headingsResolved = [];
193
+ headingsWithoutBreadcrumb.forEach(function (heading) {
194
+ var linkBreadcrumb = getHeadingsBreadcrumb(heading, headingsResolved);
195
+ headingsResolved.push(__assign(__assign({}, heading), { linkBreadcrumb: linkBreadcrumb }));
179
196
  });
180
- const headingsDetachedResolved = config.headingsDetached.map((headingsDetached) => {
181
- const { url } = headingsDetached;
182
- assert(headingsResolved.find((heading) => heading.url === url) === undefined, `remove ${headingsDetached.url} from headingsDetached`);
183
- return {
184
- ...headingsDetached,
185
- level: 2,
186
- titleInNav: headingsDetached.title,
187
- linkBreadcrumb: null,
188
- };
197
+ var headingsDetachedResolved = config.headingsDetached.map(function (headingsDetached) {
198
+ var url = headingsDetached.url;
199
+ assert(headingsResolved.find(function (heading) { return heading.url === url; }) === undefined, "remove ".concat(headingsDetached.url, " from headingsDetached"));
200
+ return __assign(__assign({}, headingsDetached), { level: 2, titleInNav: headingsDetached.title, linkBreadcrumb: null });
189
201
  });
190
- return { headingsResolved, headingsDetachedResolved };
202
+ return { headingsResolved: headingsResolved, headingsDetachedResolved: headingsDetachedResolved };
191
203
  }
192
204
  function getHeadingsBreadcrumb(heading, headings) {
193
- const linkBreadcrumb = [];
194
- let levelCurrent = heading.level;
205
+ var linkBreadcrumb = [];
206
+ var levelCurrent = heading.level;
195
207
  headings
196
208
  .slice()
197
209
  .reverse()
198
- .forEach((parentCandidate) => {
199
- const isParent = parentCandidate.level < levelCurrent;
210
+ .forEach(function (parentCandidate) {
211
+ var isParent = parentCandidate.level < levelCurrent;
200
212
  if (isParent) {
201
213
  levelCurrent = parentCandidate.level;
202
214
  linkBreadcrumb.push(parentCandidate.title);
@@ -205,9 +217,9 @@ function getHeadingsBreadcrumb(heading, headings) {
205
217
  return linkBreadcrumb;
206
218
  }
207
219
  function assertHeadingsDefinition(headings) {
208
- headings.forEach((heading) => {
220
+ headings.forEach(function (heading) {
209
221
  if (heading.url) {
210
- const { url } = heading;
222
+ var url = heading.url;
211
223
  assert(url.startsWith('/'));
212
224
  }
213
225
  });
@@ -1,10 +1,22 @@
1
1
  // Let's eventually remove this. Telefunc is still using this as of 2024-12.
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  import React from 'react';
3
14
  import { assert } from '../assert';
4
15
  import { iconMechanicalArm, iconShield, iconTypescript, iconEngine } from './assets';
5
16
  export { Emoji };
6
- function Emoji({ name, style }) {
7
- const emoji =
17
+ function Emoji(_a) {
18
+ var name = _a.name, style = _a.style;
19
+ var emoji =
8
20
  // ***
9
21
  // U+26A0
10
22
  // https://emojipedia.org/warning/
@@ -153,26 +165,22 @@ function Emoji({ name, style }) {
153
165
  (name === 'left-right-arrow' && Unicode(0xFE0F)) ||
154
166
  (name === 'left-right-arrow' && Unicode(0xFE0F, { fontFamily: 'reset' })) ||
155
167
  ======================== */
156
- assert(emoji, { name });
168
+ assert(emoji, { name: name });
157
169
  return emoji;
158
170
  function Unicode(codePoint, styleAddendum) {
159
- const text = String.fromCodePoint(codePoint);
171
+ var text = String.fromCodePoint(codePoint);
160
172
  if (style || styleAddendum) {
161
- return React.createElement('span', { style: { ...style, ...styleAddendum } }, text);
173
+ return React.createElement('span', { style: __assign(__assign({}, style), styleAddendum) }, text);
162
174
  }
163
175
  else {
164
176
  return React.createElement(React.Fragment, null, text);
165
177
  }
166
178
  }
167
- function Img(imgSrc, width = '1.15em') {
168
- const props = {
179
+ function Img(imgSrc, width) {
180
+ if (width === void 0) { width = '1.15em'; }
181
+ var props = {
169
182
  src: imgSrc,
170
- style: {
171
- verticalAlign: 'text-top',
172
- fontSize: '1em',
173
- width,
174
- ...style,
175
- },
183
+ style: __assign({ verticalAlign: 'text-top', fontSize: '1em', width: width }, style),
176
184
  };
177
185
  return React.createElement('img', props);
178
186
  }
@@ -2,8 +2,8 @@ export { assert };
2
2
  export { assertUsage };
3
3
  export { assertWarning };
4
4
  import { getGlobalObject } from './getGlobalObject.js';
5
- const devModeKey = '__docpress_dev_mode';
6
- const globalObject = getGlobalObject('utils/assert.ts', {
5
+ var devModeKey = '__docpress_dev_mode';
6
+ var globalObject = getGlobalObject('utils/assert.ts', {
7
7
  alreadyLogged: new Set(),
8
8
  });
9
9
  if (isBrowser()) {
@@ -18,7 +18,7 @@ if (isBrowser()) {
18
18
  .join(' '));
19
19
  }
20
20
  if (isDevMode()) {
21
- window.onerror = (err) => {
21
+ window.onerror = function (err) {
22
22
  window.alert(err);
23
23
  window.onerror = null;
24
24
  };
@@ -27,25 +27,25 @@ function assert(condition, debugInfo) {
27
27
  if (condition) {
28
28
  return;
29
29
  }
30
- const hasDebugInfo = debugInfo !== undefined;
30
+ var hasDebugInfo = debugInfo !== undefined;
31
31
  if (hasDebugInfo) {
32
32
  console.log(debugInfo);
33
33
  if (typeof debugInfo === 'object') {
34
34
  debugInfo = JSON.stringify(debugInfo);
35
35
  }
36
36
  }
37
- let errMsg = '[DocPress] Bug. Contact DocPress maintainer.';
37
+ var errMsg = '[DocPress] Bug. Contact DocPress maintainer.';
38
38
  if (hasDebugInfo) {
39
39
  errMsg += ' Debug info: ' + String(debugInfo);
40
40
  }
41
- const err = new Error(errMsg);
41
+ var err = new Error(errMsg);
42
42
  throw err;
43
43
  }
44
44
  function assertUsage(condition, msg) {
45
45
  if (condition) {
46
46
  return;
47
47
  }
48
- const err = new Error('[DocPress][Wrong Usage] ' + msg);
48
+ var err = new Error('[DocPress][Wrong Usage] ' + msg);
49
49
  throw err;
50
50
  }
51
51
  function isBrowser() {
@@ -55,32 +55,34 @@ function isDevMode() {
55
55
  return isBrowser() && (!!window.localStorage[devModeKey] || isLocalhost());
56
56
  }
57
57
  function isLocalhost() {
58
- return window?.location?.port !== '';
58
+ var _a;
59
+ return ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.port) !== '';
59
60
  }
60
61
  function toggleDevMode() {
61
62
  if (isLocalhost())
62
63
  throw new Error('On localhost DEV MODE is always on.');
63
- const isEnabled = () => window.localStorage[devModeKey];
64
+ var isEnabled = function () { return window.localStorage[devModeKey]; };
64
65
  if (!isEnabled()) {
65
66
  window.localStorage[devModeKey] = 'true';
66
67
  }
67
68
  else {
68
69
  delete window.localStorage[devModeKey];
69
70
  }
70
- console.log(`DEV MODE ${isEnabled() ? 'enabled' : 'disabled'}`);
71
+ console.log("DEV MODE ".concat(isEnabled() ? 'enabled' : 'disabled'));
71
72
  }
72
- function assertWarning(condition, msg, { onlyOnce = true, showStackTrace } = {}) {
73
+ function assertWarning(condition, msg, _a) {
74
+ var _b = _a === void 0 ? {} : _a, _c = _b.onlyOnce, onlyOnce = _c === void 0 ? true : _c, showStackTrace = _b.showStackTrace;
73
75
  if (condition) {
74
76
  return;
75
77
  }
76
- const err = new Error(msg);
78
+ var err = new Error(msg);
77
79
  if (!import.meta.env.DEV) {
78
80
  throw err;
79
81
  }
80
82
  else {
81
83
  if (onlyOnce) {
82
- const { alreadyLogged } = globalObject;
83
- const key = onlyOnce === true ? msg : onlyOnce;
84
+ var alreadyLogged = globalObject.alreadyLogged;
85
+ var key = onlyOnce === true ? msg : onlyOnce;
84
86
  if (alreadyLogged.has(key))
85
87
  return;
86
88
  alreadyLogged.add(key);