hermium 0.2.0 → 0.3.1
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/bin/hermium.mjs +103 -58
- package/dist/api.mjs +35 -0
- package/dist/public/assets/css/styles-o9LLzp-x.css +1 -0
- package/dist/public/assets/js/{ChatInputBlock-Bw7AL70H.js → ChatInputBlock-BgJMx5nW.js} +1 -1
- package/dist/public/assets/js/{MarkdownMessage-8d7Y6VL-.js → MarkdownMessage-Dd6VsKhk.js} +1 -1
- package/dist/public/assets/js/{base-ui-BvQbAt_1.js → base-ui-Ls-HE_Zl.js} +1 -1
- package/dist/public/assets/js/{chat._sessionId-BG6lVraH.js → chat._sessionId-Yif-J0_7.js} +1 -1
- package/dist/public/assets/js/{chat.index-D2zdMPTT.js → chat.index-QgwoSqOs.js} +1 -1
- package/dist/public/assets/js/{index-C0AK45FU.js → index-BDLsrzTe.js} +26 -26
- package/dist/public/assets/js/{index-Cx5En4FK.js → index-DRH0t4ti.js} +1 -1
- package/dist/public/assets/js/{memory-CeSRdTkW.js → memory-CHpNNtU2.js} +1 -1
- package/dist/public/assets/js/{router-8uDKazL-.js → router-B8BATVn7.js} +1 -1
- package/dist/public/assets/js/{settings-Bc3Y5zXO.js → settings-CRV3Pp8x.js} +1 -1
- package/dist/public/assets/js/{skills-DZv7sA_5.js → skills-C8G72gXr.js} +1 -1
- package/dist/public/assets/js/{usage-DXQsT9_b.js → usage-Bev8hqwh.js} +1 -1
- package/dist/server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +6 -0
- package/dist/server/_chunks/ssr-renderer.mjs +22 -0
- package/dist/server/_libs/bail.mjs +8 -0
- package/dist/server/_libs/base-ui__react.mjs +9858 -0
- package/dist/server/_libs/base-ui__utils.mjs +1106 -0
- package/dist/server/_libs/ccount.mjs +16 -0
- package/dist/server/_libs/character-entities.mjs +2130 -0
- package/dist/server/_libs/class-variance-authority.mjs +44 -0
- package/dist/server/_libs/clsx.mjs +16 -0
- package/dist/server/_libs/comma-separated-tokens.mjs +10 -0
- package/dist/server/_libs/cookie-es.mjs +1 -0
- package/dist/server/_libs/croner.mjs +1 -0
- package/dist/server/_libs/crossws.mjs +1 -0
- package/dist/server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/dist/server/_libs/devlop.mjs +8 -0
- package/dist/server/_libs/escape-string-regexp.mjs +9 -0
- package/dist/server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/dist/server/_libs/extend.mjs +97 -0
- package/dist/server/_libs/floating-ui__core.mjs +663 -0
- package/dist/server/_libs/floating-ui__dom.mjs +624 -0
- package/dist/server/_libs/floating-ui__react-dom.mjs +279 -0
- package/dist/server/_libs/floating-ui__utils.mjs +322 -0
- package/dist/server/_libs/h3.mjs +408 -0
- package/dist/server/_libs/hast-util-is-element.mjs +75 -0
- package/dist/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/dist/server/_libs/hast-util-to-text.mjs +305 -0
- package/dist/server/_libs/hast-util-whitespace.mjs +10 -0
- package/dist/server/_libs/highlight.js.mjs +14756 -0
- package/dist/server/_libs/hookable.mjs +1 -0
- package/dist/server/_libs/html-url-attributes.mjs +26 -0
- package/dist/server/_libs/inline-style-parser.mjs +142 -0
- package/dist/server/_libs/is-plain-obj.mjs +10 -0
- package/dist/server/_libs/isbot.mjs +21 -0
- package/dist/server/_libs/longest-streak.mjs +25 -0
- package/dist/server/_libs/lowlight.mjs +262 -0
- package/dist/server/_libs/markdown-table.mjs +142 -0
- package/dist/server/_libs/mdast-util-find-and-replace.mjs +109 -0
- package/dist/server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/dist/server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +156 -0
- package/dist/server/_libs/mdast-util-gfm-footnote.mjs +117 -0
- package/dist/server/_libs/mdast-util-gfm-strikethrough.mjs +54 -0
- package/dist/server/_libs/mdast-util-gfm-table.mjs +157 -0
- package/dist/server/_libs/mdast-util-gfm-task-list-item.mjs +77 -0
- package/dist/server/_libs/mdast-util-gfm.mjs +29 -0
- package/dist/server/_libs/mdast-util-phrasing.mjs +30 -0
- package/dist/server/_libs/mdast-util-to-hast.mjs +710 -0
- package/dist/server/_libs/mdast-util-to-markdown.mjs +798 -0
- package/dist/server/_libs/mdast-util-to-string.mjs +38 -0
- package/dist/server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/dist/server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +344 -0
- package/dist/server/_libs/micromark-extension-gfm-footnote+[...].mjs +279 -0
- package/dist/server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +98 -0
- package/dist/server/_libs/micromark-extension-gfm-table.mjs +491 -0
- package/dist/server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +1 -0
- package/dist/server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +77 -0
- package/dist/server/_libs/micromark-extension-gfm.mjs +18 -0
- package/dist/server/_libs/micromark-factory-destination.mjs +94 -0
- package/dist/server/_libs/micromark-factory-label.mjs +63 -0
- package/dist/server/_libs/micromark-factory-space.mjs +24 -0
- package/dist/server/_libs/micromark-factory-title.mjs +65 -0
- package/dist/server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/dist/server/_libs/micromark-util-character.mjs +44 -0
- package/dist/server/_libs/micromark-util-chunked.mjs +36 -0
- package/dist/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/dist/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/dist/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/dist/server/_libs/micromark-util-decode-string.mjs +21 -0
- package/dist/server/_libs/micromark-util-encode.mjs +1 -0
- package/dist/server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/dist/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/dist/server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/dist/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/dist/server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/dist/server/_libs/micromark.mjs +906 -0
- package/dist/server/_libs/ocache.mjs +1 -0
- package/dist/server/_libs/ohash.mjs +1 -0
- package/dist/server/_libs/property-information.mjs +1209 -0
- package/dist/server/_libs/react-dom.mjs +10779 -0
- package/dist/server/_libs/react-markdown.mjs +147 -0
- package/dist/server/_libs/react.mjs +513 -0
- package/dist/server/_libs/rehype-highlight.mjs +94 -0
- package/dist/server/_libs/remark-gfm.mjs +20 -0
- package/dist/server/_libs/remark-parse.mjs +19 -0
- package/dist/server/_libs/remark-rehype.mjs +21 -0
- package/dist/server/_libs/reselect.mjs +1 -0
- package/dist/server/_libs/rou3.mjs +8 -0
- package/dist/server/_libs/seroval-plugins.mjs +1 -0
- package/dist/server/_libs/seroval.mjs +1 -0
- package/dist/server/_libs/space-separated-tokens.mjs +6 -0
- package/dist/server/_libs/srvx.mjs +781 -0
- package/dist/server/_libs/style-to-js.mjs +72 -0
- package/dist/server/_libs/style-to-object.mjs +38 -0
- package/dist/server/_libs/tabler__icons-react.mjs +140 -0
- package/dist/server/_libs/tailwind-merge.mjs +3255 -0
- package/dist/server/_libs/tanstack__history.mjs +29 -0
- package/dist/server/_libs/tanstack__react-router.mjs +1120 -0
- package/dist/server/_libs/tanstack__react-store.mjs +2 -0
- package/dist/server/_libs/tanstack__router-core.mjs +3594 -0
- package/dist/server/_libs/tanstack__store.mjs +1 -0
- package/dist/server/_libs/trim-lines.mjs +41 -0
- package/dist/server/_libs/trough.mjs +85 -0
- package/dist/server/_libs/ufo.mjs +54 -0
- package/dist/server/_libs/unctx.mjs +1 -0
- package/dist/server/_libs/ungap__structured-clone.mjs +224 -0
- package/dist/server/_libs/unified.mjs +661 -0
- package/dist/server/_libs/unist-util-find-after.mjs +41 -0
- package/dist/server/_libs/unist-util-is.mjs +100 -0
- package/dist/server/_libs/unist-util-position.mjs +27 -0
- package/dist/server/_libs/unist-util-stringify-position.mjs +27 -0
- package/dist/server/_libs/unist-util-visit-parents.mjs +83 -0
- package/dist/server/_libs/unist-util-visit.mjs +24 -0
- package/dist/server/_libs/unstorage.mjs +1 -0
- package/dist/server/_libs/use-sync-external-store.mjs +139 -0
- package/dist/server/_libs/vfile-message.mjs +138 -0
- package/dist/server/_libs/vfile.mjs +467 -0
- package/dist/server/_libs/zustand.mjs +43 -0
- package/dist/server/_libs/zwitch.mjs +1 -0
- package/dist/server/_ssr/ChatInputBlock-Bu2-iop_.mjs +220 -0
- package/dist/server/_ssr/MarkdownMessage-CNS7OSKN.mjs +68 -0
- package/dist/server/_ssr/chat._sessionId-P02iSfut.mjs +477 -0
- package/dist/server/_ssr/chat.index-BYB_48NC.mjs +64 -0
- package/dist/server/_ssr/index-C1mT_2d8.mjs +4890 -0
- package/dist/server/_ssr/index-DFV9_oCk.mjs +43 -0
- package/dist/server/_ssr/memory-CW_fSOG9.mjs +257 -0
- package/dist/server/_ssr/router-CUAfx91O.mjs +2035 -0
- package/dist/server/_ssr/settings-DoXurzvn.mjs +10 -0
- package/dist/server/_ssr/skills-Cs7A5ZwO.mjs +422 -0
- package/dist/server/_ssr/theme-BK4-7E2h.mjs +42 -0
- package/dist/server/_ssr/usage-Bs2-LXGz.mjs +298 -0
- package/dist/server/_tanstack-start-manifest_v-C7Upe2TI.mjs +4 -0
- package/dist/server/index.mjs +506 -0
- package/dist/server/public/assets/css/index-Dfs9RUU9.css +1 -0
- package/dist/server/public/assets/css/styles-o9LLzp-x.css +1 -0
- package/dist/server/public/assets/js/ChatInputBlock-BgJMx5nW.js +1 -0
- package/dist/server/public/assets/js/MarkdownMessage-Dd6VsKhk.js +1 -0
- package/dist/server/public/assets/js/base-ui-Ls-HE_Zl.js +1 -0
- package/dist/server/public/assets/js/chat._sessionId-Yif-J0_7.js +1 -0
- package/dist/server/public/assets/js/chat.index-QgwoSqOs.js +1 -0
- package/dist/server/public/assets/js/index-BDLsrzTe.js +60 -0
- package/dist/server/public/assets/js/index-DRH0t4ti.js +1 -0
- package/dist/server/public/assets/js/memory-CHpNNtU2.js +3 -0
- package/dist/server/public/assets/js/router-B8BATVn7.js +1 -0
- package/dist/server/public/assets/js/settings-CRV3Pp8x.js +1 -0
- package/dist/server/public/assets/js/skills-C8G72gXr.js +1 -0
- package/dist/server/public/assets/js/theme-CPkdkpaj.js +1 -0
- package/dist/server/public/assets/js/usage-Bev8hqwh.js +1 -0
- package/dist/server/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/server/public/favicon.ico +0 -0
- package/dist/server/public/logo.png +0 -0
- package/dist/server/public/manifest.json +25 -0
- package/dist/server/public/robots.txt +3 -0
- package/package.json +4 -3
- package/dist/public/assets/css/styles-B8p6jk5Z.css +0 -1
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { s as stringify } from "./comma-separated-tokens.mjs";
|
|
2
|
+
import { o as ok } from "./devlop.mjs";
|
|
3
|
+
import { s as svg, a as html, f as find, h as hastToReact } from "./property-information.mjs";
|
|
4
|
+
import { s as stringify$1 } from "./space-separated-tokens.mjs";
|
|
5
|
+
import { s as styleToJs } from "./style-to-js.mjs";
|
|
6
|
+
import { w as whitespace } from "./hast-util-whitespace.mjs";
|
|
7
|
+
import { n as name } from "./estree-util-is-identifier-name.mjs";
|
|
8
|
+
import { V as VFileMessage } from "./vfile-message.mjs";
|
|
9
|
+
import { a as pointStart } from "./unist-util-position.mjs";
|
|
10
|
+
const own = {}.hasOwnProperty;
|
|
11
|
+
const emptyMap = /* @__PURE__ */ new Map();
|
|
12
|
+
const cap = /[A-Z]/g;
|
|
13
|
+
const tableElements = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr"]);
|
|
14
|
+
const tableCellElement = /* @__PURE__ */ new Set(["td", "th"]);
|
|
15
|
+
const docs = "https://github.com/syntax-tree/hast-util-to-jsx-runtime";
|
|
16
|
+
function toJsxRuntime(tree, options) {
|
|
17
|
+
if (!options || options.Fragment === void 0) {
|
|
18
|
+
throw new TypeError("Expected `Fragment` in options");
|
|
19
|
+
}
|
|
20
|
+
const filePath = options.filePath || void 0;
|
|
21
|
+
let create;
|
|
22
|
+
if (options.development) {
|
|
23
|
+
if (typeof options.jsxDEV !== "function") {
|
|
24
|
+
throw new TypeError(
|
|
25
|
+
"Expected `jsxDEV` in options when `development: true`"
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
create = developmentCreate(filePath, options.jsxDEV);
|
|
29
|
+
} else {
|
|
30
|
+
if (typeof options.jsx !== "function") {
|
|
31
|
+
throw new TypeError("Expected `jsx` in production options");
|
|
32
|
+
}
|
|
33
|
+
if (typeof options.jsxs !== "function") {
|
|
34
|
+
throw new TypeError("Expected `jsxs` in production options");
|
|
35
|
+
}
|
|
36
|
+
create = productionCreate(filePath, options.jsx, options.jsxs);
|
|
37
|
+
}
|
|
38
|
+
const state = {
|
|
39
|
+
Fragment: options.Fragment,
|
|
40
|
+
ancestors: [],
|
|
41
|
+
components: options.components || {},
|
|
42
|
+
create,
|
|
43
|
+
elementAttributeNameCase: options.elementAttributeNameCase || "react",
|
|
44
|
+
evaluater: options.createEvaluater ? options.createEvaluater() : void 0,
|
|
45
|
+
filePath,
|
|
46
|
+
ignoreInvalidStyle: options.ignoreInvalidStyle || false,
|
|
47
|
+
passKeys: options.passKeys !== false,
|
|
48
|
+
passNode: options.passNode || false,
|
|
49
|
+
schema: options.space === "svg" ? svg : html,
|
|
50
|
+
stylePropertyNameCase: options.stylePropertyNameCase || "dom",
|
|
51
|
+
tableCellAlignToStyle: options.tableCellAlignToStyle !== false
|
|
52
|
+
};
|
|
53
|
+
const result = one(state, tree, void 0);
|
|
54
|
+
if (result && typeof result !== "string") {
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
return state.create(
|
|
58
|
+
tree,
|
|
59
|
+
state.Fragment,
|
|
60
|
+
{ children: result || void 0 },
|
|
61
|
+
void 0
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function one(state, node, key) {
|
|
65
|
+
if (node.type === "element") {
|
|
66
|
+
return element(state, node, key);
|
|
67
|
+
}
|
|
68
|
+
if (node.type === "mdxFlowExpression" || node.type === "mdxTextExpression") {
|
|
69
|
+
return mdxExpression(state, node);
|
|
70
|
+
}
|
|
71
|
+
if (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") {
|
|
72
|
+
return mdxJsxElement(state, node, key);
|
|
73
|
+
}
|
|
74
|
+
if (node.type === "mdxjsEsm") {
|
|
75
|
+
return mdxEsm(state, node);
|
|
76
|
+
}
|
|
77
|
+
if (node.type === "root") {
|
|
78
|
+
return root(state, node, key);
|
|
79
|
+
}
|
|
80
|
+
if (node.type === "text") {
|
|
81
|
+
return text(state, node);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function element(state, node, key) {
|
|
85
|
+
const parentSchema = state.schema;
|
|
86
|
+
let schema = parentSchema;
|
|
87
|
+
if (node.tagName.toLowerCase() === "svg" && parentSchema.space === "html") {
|
|
88
|
+
schema = svg;
|
|
89
|
+
state.schema = schema;
|
|
90
|
+
}
|
|
91
|
+
state.ancestors.push(node);
|
|
92
|
+
const type = findComponentFromName(state, node.tagName, false);
|
|
93
|
+
const props = createElementProps(state, node);
|
|
94
|
+
let children = createChildren(state, node);
|
|
95
|
+
if (tableElements.has(node.tagName)) {
|
|
96
|
+
children = children.filter(function(child) {
|
|
97
|
+
return typeof child === "string" ? !whitespace(child) : true;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
addNode(state, props, type, node);
|
|
101
|
+
addChildren(props, children);
|
|
102
|
+
state.ancestors.pop();
|
|
103
|
+
state.schema = parentSchema;
|
|
104
|
+
return state.create(node, type, props, key);
|
|
105
|
+
}
|
|
106
|
+
function mdxExpression(state, node) {
|
|
107
|
+
if (node.data && node.data.estree && state.evaluater) {
|
|
108
|
+
const program = node.data.estree;
|
|
109
|
+
const expression = program.body[0];
|
|
110
|
+
ok(expression.type === "ExpressionStatement");
|
|
111
|
+
return (
|
|
112
|
+
/** @type {Child | undefined} */
|
|
113
|
+
state.evaluater.evaluateExpression(expression.expression)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
crashEstree(state, node.position);
|
|
117
|
+
}
|
|
118
|
+
function mdxEsm(state, node) {
|
|
119
|
+
if (node.data && node.data.estree && state.evaluater) {
|
|
120
|
+
return (
|
|
121
|
+
/** @type {Child | undefined} */
|
|
122
|
+
state.evaluater.evaluateProgram(node.data.estree)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
crashEstree(state, node.position);
|
|
126
|
+
}
|
|
127
|
+
function mdxJsxElement(state, node, key) {
|
|
128
|
+
const parentSchema = state.schema;
|
|
129
|
+
let schema = parentSchema;
|
|
130
|
+
if (node.name === "svg" && parentSchema.space === "html") {
|
|
131
|
+
schema = svg;
|
|
132
|
+
state.schema = schema;
|
|
133
|
+
}
|
|
134
|
+
state.ancestors.push(node);
|
|
135
|
+
const type = node.name === null ? state.Fragment : findComponentFromName(state, node.name, true);
|
|
136
|
+
const props = createJsxElementProps(state, node);
|
|
137
|
+
const children = createChildren(state, node);
|
|
138
|
+
addNode(state, props, type, node);
|
|
139
|
+
addChildren(props, children);
|
|
140
|
+
state.ancestors.pop();
|
|
141
|
+
state.schema = parentSchema;
|
|
142
|
+
return state.create(node, type, props, key);
|
|
143
|
+
}
|
|
144
|
+
function root(state, node, key) {
|
|
145
|
+
const props = {};
|
|
146
|
+
addChildren(props, createChildren(state, node));
|
|
147
|
+
return state.create(node, state.Fragment, props, key);
|
|
148
|
+
}
|
|
149
|
+
function text(_, node) {
|
|
150
|
+
return node.value;
|
|
151
|
+
}
|
|
152
|
+
function addNode(state, props, type, node) {
|
|
153
|
+
if (typeof type !== "string" && type !== state.Fragment && state.passNode) {
|
|
154
|
+
props.node = node;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function addChildren(props, children) {
|
|
158
|
+
if (children.length > 0) {
|
|
159
|
+
const value = children.length > 1 ? children : children[0];
|
|
160
|
+
if (value) {
|
|
161
|
+
props.children = value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function productionCreate(_, jsx, jsxs) {
|
|
166
|
+
return create;
|
|
167
|
+
function create(_2, type, props, key) {
|
|
168
|
+
const isStaticChildren = Array.isArray(props.children);
|
|
169
|
+
const fn = isStaticChildren ? jsxs : jsx;
|
|
170
|
+
return key ? fn(type, props, key) : fn(type, props);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function developmentCreate(filePath, jsxDEV) {
|
|
174
|
+
return create;
|
|
175
|
+
function create(node, type, props, key) {
|
|
176
|
+
const isStaticChildren = Array.isArray(props.children);
|
|
177
|
+
const point = pointStart(node);
|
|
178
|
+
return jsxDEV(
|
|
179
|
+
type,
|
|
180
|
+
props,
|
|
181
|
+
key,
|
|
182
|
+
isStaticChildren,
|
|
183
|
+
{
|
|
184
|
+
columnNumber: point ? point.column - 1 : void 0,
|
|
185
|
+
fileName: filePath,
|
|
186
|
+
lineNumber: point ? point.line : void 0
|
|
187
|
+
},
|
|
188
|
+
void 0
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function createElementProps(state, node) {
|
|
193
|
+
const props = {};
|
|
194
|
+
let alignValue;
|
|
195
|
+
let prop;
|
|
196
|
+
for (prop in node.properties) {
|
|
197
|
+
if (prop !== "children" && own.call(node.properties, prop)) {
|
|
198
|
+
const result = createProperty(state, prop, node.properties[prop]);
|
|
199
|
+
if (result) {
|
|
200
|
+
const [key, value] = result;
|
|
201
|
+
if (state.tableCellAlignToStyle && key === "align" && typeof value === "string" && tableCellElement.has(node.tagName)) {
|
|
202
|
+
alignValue = value;
|
|
203
|
+
} else {
|
|
204
|
+
props[key] = value;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (alignValue) {
|
|
210
|
+
const style = (
|
|
211
|
+
/** @type {Style} */
|
|
212
|
+
props.style || (props.style = {})
|
|
213
|
+
);
|
|
214
|
+
style[state.stylePropertyNameCase === "css" ? "text-align" : "textAlign"] = alignValue;
|
|
215
|
+
}
|
|
216
|
+
return props;
|
|
217
|
+
}
|
|
218
|
+
function createJsxElementProps(state, node) {
|
|
219
|
+
const props = {};
|
|
220
|
+
for (const attribute of node.attributes) {
|
|
221
|
+
if (attribute.type === "mdxJsxExpressionAttribute") {
|
|
222
|
+
if (attribute.data && attribute.data.estree && state.evaluater) {
|
|
223
|
+
const program = attribute.data.estree;
|
|
224
|
+
const expression = program.body[0];
|
|
225
|
+
ok(expression.type === "ExpressionStatement");
|
|
226
|
+
const objectExpression = expression.expression;
|
|
227
|
+
ok(objectExpression.type === "ObjectExpression");
|
|
228
|
+
const property = objectExpression.properties[0];
|
|
229
|
+
ok(property.type === "SpreadElement");
|
|
230
|
+
Object.assign(
|
|
231
|
+
props,
|
|
232
|
+
state.evaluater.evaluateExpression(property.argument)
|
|
233
|
+
);
|
|
234
|
+
} else {
|
|
235
|
+
crashEstree(state, node.position);
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
const name2 = attribute.name;
|
|
239
|
+
let value;
|
|
240
|
+
if (attribute.value && typeof attribute.value === "object") {
|
|
241
|
+
if (attribute.value.data && attribute.value.data.estree && state.evaluater) {
|
|
242
|
+
const program = attribute.value.data.estree;
|
|
243
|
+
const expression = program.body[0];
|
|
244
|
+
ok(expression.type === "ExpressionStatement");
|
|
245
|
+
value = state.evaluater.evaluateExpression(expression.expression);
|
|
246
|
+
} else {
|
|
247
|
+
crashEstree(state, node.position);
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
value = attribute.value === null ? true : attribute.value;
|
|
251
|
+
}
|
|
252
|
+
props[name2] = /** @type {Props[keyof Props]} */
|
|
253
|
+
value;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return props;
|
|
257
|
+
}
|
|
258
|
+
function createChildren(state, node) {
|
|
259
|
+
const children = [];
|
|
260
|
+
let index = -1;
|
|
261
|
+
const countsByName = state.passKeys ? /* @__PURE__ */ new Map() : emptyMap;
|
|
262
|
+
while (++index < node.children.length) {
|
|
263
|
+
const child = node.children[index];
|
|
264
|
+
let key;
|
|
265
|
+
if (state.passKeys) {
|
|
266
|
+
const name2 = child.type === "element" ? child.tagName : child.type === "mdxJsxFlowElement" || child.type === "mdxJsxTextElement" ? child.name : void 0;
|
|
267
|
+
if (name2) {
|
|
268
|
+
const count = countsByName.get(name2) || 0;
|
|
269
|
+
key = name2 + "-" + count;
|
|
270
|
+
countsByName.set(name2, count + 1);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const result = one(state, child, key);
|
|
274
|
+
if (result !== void 0) children.push(result);
|
|
275
|
+
}
|
|
276
|
+
return children;
|
|
277
|
+
}
|
|
278
|
+
function createProperty(state, prop, value) {
|
|
279
|
+
const info = find(state.schema, prop);
|
|
280
|
+
if (value === null || value === void 0 || typeof value === "number" && Number.isNaN(value)) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (Array.isArray(value)) {
|
|
284
|
+
value = info.commaSeparated ? stringify(value) : stringify$1(value);
|
|
285
|
+
}
|
|
286
|
+
if (info.property === "style") {
|
|
287
|
+
let styleObject = typeof value === "object" ? value : parseStyle(state, String(value));
|
|
288
|
+
if (state.stylePropertyNameCase === "css") {
|
|
289
|
+
styleObject = transformStylesToCssCasing(styleObject);
|
|
290
|
+
}
|
|
291
|
+
return ["style", styleObject];
|
|
292
|
+
}
|
|
293
|
+
return [
|
|
294
|
+
state.elementAttributeNameCase === "react" && info.space ? hastToReact[info.property] || info.property : info.attribute,
|
|
295
|
+
value
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
function parseStyle(state, value) {
|
|
299
|
+
try {
|
|
300
|
+
return styleToJs(value, { reactCompat: true });
|
|
301
|
+
} catch (error) {
|
|
302
|
+
if (state.ignoreInvalidStyle) {
|
|
303
|
+
return {};
|
|
304
|
+
}
|
|
305
|
+
const cause = (
|
|
306
|
+
/** @type {Error} */
|
|
307
|
+
error
|
|
308
|
+
);
|
|
309
|
+
const message = new VFileMessage("Cannot parse `style` attribute", {
|
|
310
|
+
ancestors: state.ancestors,
|
|
311
|
+
cause,
|
|
312
|
+
ruleId: "style",
|
|
313
|
+
source: "hast-util-to-jsx-runtime"
|
|
314
|
+
});
|
|
315
|
+
message.file = state.filePath || void 0;
|
|
316
|
+
message.url = docs + "#cannot-parse-style-attribute";
|
|
317
|
+
throw message;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function findComponentFromName(state, name$1, allowExpression) {
|
|
321
|
+
let result;
|
|
322
|
+
if (!allowExpression) {
|
|
323
|
+
result = { type: "Literal", value: name$1 };
|
|
324
|
+
} else if (name$1.includes(".")) {
|
|
325
|
+
const identifiers = name$1.split(".");
|
|
326
|
+
let index = -1;
|
|
327
|
+
let node;
|
|
328
|
+
while (++index < identifiers.length) {
|
|
329
|
+
const prop = name(identifiers[index]) ? { type: "Identifier", name: identifiers[index] } : { type: "Literal", value: identifiers[index] };
|
|
330
|
+
node = node ? {
|
|
331
|
+
type: "MemberExpression",
|
|
332
|
+
object: node,
|
|
333
|
+
property: prop,
|
|
334
|
+
computed: Boolean(index && prop.type === "Literal"),
|
|
335
|
+
optional: false
|
|
336
|
+
} : prop;
|
|
337
|
+
}
|
|
338
|
+
result = node;
|
|
339
|
+
} else {
|
|
340
|
+
result = name(name$1) && !/^[a-z]/.test(name$1) ? { type: "Identifier", name: name$1 } : { type: "Literal", value: name$1 };
|
|
341
|
+
}
|
|
342
|
+
if (result.type === "Literal") {
|
|
343
|
+
const name2 = (
|
|
344
|
+
/** @type {string | number} */
|
|
345
|
+
result.value
|
|
346
|
+
);
|
|
347
|
+
return own.call(state.components, name2) ? state.components[name2] : name2;
|
|
348
|
+
}
|
|
349
|
+
if (state.evaluater) {
|
|
350
|
+
return state.evaluater.evaluateExpression(result);
|
|
351
|
+
}
|
|
352
|
+
crashEstree(state);
|
|
353
|
+
}
|
|
354
|
+
function crashEstree(state, place) {
|
|
355
|
+
const message = new VFileMessage(
|
|
356
|
+
"Cannot handle MDX estrees without `createEvaluater`",
|
|
357
|
+
{
|
|
358
|
+
ancestors: state.ancestors,
|
|
359
|
+
place,
|
|
360
|
+
ruleId: "mdx-estree",
|
|
361
|
+
source: "hast-util-to-jsx-runtime"
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
message.file = state.filePath || void 0;
|
|
365
|
+
message.url = docs + "#cannot-handle-mdx-estrees-without-createevaluater";
|
|
366
|
+
throw message;
|
|
367
|
+
}
|
|
368
|
+
function transformStylesToCssCasing(domCasing) {
|
|
369
|
+
const cssCasing = {};
|
|
370
|
+
let from;
|
|
371
|
+
for (from in domCasing) {
|
|
372
|
+
if (own.call(domCasing, from)) {
|
|
373
|
+
cssCasing[transformStyleToCssCasing(from)] = domCasing[from];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return cssCasing;
|
|
377
|
+
}
|
|
378
|
+
function transformStyleToCssCasing(from) {
|
|
379
|
+
let to = from.replace(cap, toDash);
|
|
380
|
+
if (to.slice(0, 3) === "ms-") to = "-" + to;
|
|
381
|
+
return to;
|
|
382
|
+
}
|
|
383
|
+
function toDash($0) {
|
|
384
|
+
return "-" + $0.toLowerCase();
|
|
385
|
+
}
|
|
386
|
+
export {
|
|
387
|
+
toJsxRuntime as t
|
|
388
|
+
};
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { c as convertElement } from "./hast-util-is-element.mjs";
|
|
2
|
+
import { f as findAfter } from "./unist-util-find-after.mjs";
|
|
3
|
+
const searchLineFeeds = /\n/g;
|
|
4
|
+
const searchTabOrSpaces = /[\t ]+/g;
|
|
5
|
+
const br = convertElement("br");
|
|
6
|
+
const cell = convertElement(isCell);
|
|
7
|
+
const p = convertElement("p");
|
|
8
|
+
const row = convertElement("tr");
|
|
9
|
+
const notRendered = convertElement([
|
|
10
|
+
// List from: <https://html.spec.whatwg.org/multipage/rendering.html#hidden-elements>
|
|
11
|
+
"datalist",
|
|
12
|
+
"head",
|
|
13
|
+
"noembed",
|
|
14
|
+
"noframes",
|
|
15
|
+
"noscript",
|
|
16
|
+
// Act as if we support scripting.
|
|
17
|
+
"rp",
|
|
18
|
+
"script",
|
|
19
|
+
"style",
|
|
20
|
+
"template",
|
|
21
|
+
"title",
|
|
22
|
+
// Hidden attribute.
|
|
23
|
+
hidden,
|
|
24
|
+
// From: <https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3>
|
|
25
|
+
closedDialog
|
|
26
|
+
]);
|
|
27
|
+
const blockOrCaption = convertElement([
|
|
28
|
+
"address",
|
|
29
|
+
// Flow content
|
|
30
|
+
"article",
|
|
31
|
+
// Sections and headings
|
|
32
|
+
"aside",
|
|
33
|
+
// Sections and headings
|
|
34
|
+
"blockquote",
|
|
35
|
+
// Flow content
|
|
36
|
+
"body",
|
|
37
|
+
// Page
|
|
38
|
+
"caption",
|
|
39
|
+
// `table-caption`
|
|
40
|
+
"center",
|
|
41
|
+
// Flow content (legacy)
|
|
42
|
+
"dd",
|
|
43
|
+
// Lists
|
|
44
|
+
"dialog",
|
|
45
|
+
// Flow content
|
|
46
|
+
"dir",
|
|
47
|
+
// Lists (legacy)
|
|
48
|
+
"dl",
|
|
49
|
+
// Lists
|
|
50
|
+
"dt",
|
|
51
|
+
// Lists
|
|
52
|
+
"div",
|
|
53
|
+
// Flow content
|
|
54
|
+
"figure",
|
|
55
|
+
// Flow content
|
|
56
|
+
"figcaption",
|
|
57
|
+
// Flow content
|
|
58
|
+
"footer",
|
|
59
|
+
// Flow content
|
|
60
|
+
"form,",
|
|
61
|
+
// Flow content
|
|
62
|
+
"h1",
|
|
63
|
+
// Sections and headings
|
|
64
|
+
"h2",
|
|
65
|
+
// Sections and headings
|
|
66
|
+
"h3",
|
|
67
|
+
// Sections and headings
|
|
68
|
+
"h4",
|
|
69
|
+
// Sections and headings
|
|
70
|
+
"h5",
|
|
71
|
+
// Sections and headings
|
|
72
|
+
"h6",
|
|
73
|
+
// Sections and headings
|
|
74
|
+
"header",
|
|
75
|
+
// Flow content
|
|
76
|
+
"hgroup",
|
|
77
|
+
// Sections and headings
|
|
78
|
+
"hr",
|
|
79
|
+
// Flow content
|
|
80
|
+
"html",
|
|
81
|
+
// Page
|
|
82
|
+
"legend",
|
|
83
|
+
// Flow content
|
|
84
|
+
"li",
|
|
85
|
+
// Lists (as `display: list-item`)
|
|
86
|
+
"listing",
|
|
87
|
+
// Flow content (legacy)
|
|
88
|
+
"main",
|
|
89
|
+
// Flow content
|
|
90
|
+
"menu",
|
|
91
|
+
// Lists
|
|
92
|
+
"nav",
|
|
93
|
+
// Sections and headings
|
|
94
|
+
"ol",
|
|
95
|
+
// Lists
|
|
96
|
+
"p",
|
|
97
|
+
// Flow content
|
|
98
|
+
"plaintext",
|
|
99
|
+
// Flow content (legacy)
|
|
100
|
+
"pre",
|
|
101
|
+
// Flow content
|
|
102
|
+
"section",
|
|
103
|
+
// Sections and headings
|
|
104
|
+
"ul",
|
|
105
|
+
// Lists
|
|
106
|
+
"xmp"
|
|
107
|
+
// Flow content (legacy)
|
|
108
|
+
]);
|
|
109
|
+
function toText(tree, options) {
|
|
110
|
+
const options_ = options || {};
|
|
111
|
+
const children = "children" in tree ? tree.children : [];
|
|
112
|
+
const block = blockOrCaption(tree);
|
|
113
|
+
const whitespace = inferWhitespace(tree, {
|
|
114
|
+
whitespace: options_.whitespace || "normal"
|
|
115
|
+
});
|
|
116
|
+
const results = [];
|
|
117
|
+
if (tree.type === "text" || tree.type === "comment") {
|
|
118
|
+
results.push(
|
|
119
|
+
...collectText(tree, {
|
|
120
|
+
breakBefore: true,
|
|
121
|
+
breakAfter: true
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
let index = -1;
|
|
126
|
+
while (++index < children.length) {
|
|
127
|
+
results.push(
|
|
128
|
+
...renderedTextCollection(
|
|
129
|
+
children[index],
|
|
130
|
+
// @ts-expect-error: `tree` is a parent if we’re here.
|
|
131
|
+
tree,
|
|
132
|
+
{
|
|
133
|
+
whitespace,
|
|
134
|
+
breakBefore: index ? void 0 : block,
|
|
135
|
+
breakAfter: index < children.length - 1 ? br(children[index + 1]) : block
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
const result = [];
|
|
141
|
+
let count;
|
|
142
|
+
index = -1;
|
|
143
|
+
while (++index < results.length) {
|
|
144
|
+
const value = results[index];
|
|
145
|
+
if (typeof value === "number") {
|
|
146
|
+
if (count !== void 0 && value > count) count = value;
|
|
147
|
+
} else if (value) {
|
|
148
|
+
if (count !== void 0 && count > -1) {
|
|
149
|
+
result.push("\n".repeat(count) || " ");
|
|
150
|
+
}
|
|
151
|
+
count = -1;
|
|
152
|
+
result.push(value);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return result.join("");
|
|
156
|
+
}
|
|
157
|
+
function renderedTextCollection(node, parent, info) {
|
|
158
|
+
if (node.type === "element") {
|
|
159
|
+
return collectElement(node, parent, info);
|
|
160
|
+
}
|
|
161
|
+
if (node.type === "text") {
|
|
162
|
+
return info.whitespace === "normal" ? collectText(node, info) : collectPreText(node);
|
|
163
|
+
}
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
function collectElement(node, parent, info) {
|
|
167
|
+
const whitespace = inferWhitespace(node, info);
|
|
168
|
+
const children = node.children || [];
|
|
169
|
+
let index = -1;
|
|
170
|
+
let items = [];
|
|
171
|
+
if (notRendered(node)) {
|
|
172
|
+
return items;
|
|
173
|
+
}
|
|
174
|
+
let prefix;
|
|
175
|
+
let suffix;
|
|
176
|
+
if (br(node)) {
|
|
177
|
+
suffix = "\n";
|
|
178
|
+
} else if (row(node) && // @ts-expect-error: something up with types of parents.
|
|
179
|
+
findAfter(parent, node, row)) {
|
|
180
|
+
suffix = "\n";
|
|
181
|
+
} else if (p(node)) {
|
|
182
|
+
prefix = 2;
|
|
183
|
+
suffix = 2;
|
|
184
|
+
} else if (blockOrCaption(node)) {
|
|
185
|
+
prefix = 1;
|
|
186
|
+
suffix = 1;
|
|
187
|
+
}
|
|
188
|
+
while (++index < children.length) {
|
|
189
|
+
items = items.concat(
|
|
190
|
+
renderedTextCollection(children[index], node, {
|
|
191
|
+
whitespace,
|
|
192
|
+
breakBefore: index ? void 0 : prefix,
|
|
193
|
+
breakAfter: index < children.length - 1 ? br(children[index + 1]) : suffix
|
|
194
|
+
})
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
if (cell(node) && // @ts-expect-error: something up with types of parents.
|
|
198
|
+
findAfter(parent, node, cell)) {
|
|
199
|
+
items.push(" ");
|
|
200
|
+
}
|
|
201
|
+
if (prefix) items.unshift(prefix);
|
|
202
|
+
if (suffix) items.push(suffix);
|
|
203
|
+
return items;
|
|
204
|
+
}
|
|
205
|
+
function collectText(node, info) {
|
|
206
|
+
const value = String(node.value);
|
|
207
|
+
const lines = [];
|
|
208
|
+
const result = [];
|
|
209
|
+
let start = 0;
|
|
210
|
+
while (start <= value.length) {
|
|
211
|
+
searchLineFeeds.lastIndex = start;
|
|
212
|
+
const match = searchLineFeeds.exec(value);
|
|
213
|
+
const end = match && "index" in match ? match.index : value.length;
|
|
214
|
+
lines.push(
|
|
215
|
+
// Any sequence of collapsible spaces and tabs immediately preceding or
|
|
216
|
+
// following a segment break is removed.
|
|
217
|
+
trimAndCollapseSpacesAndTabs(
|
|
218
|
+
// […] ignoring bidi formatting characters (characters with the
|
|
219
|
+
// Bidi_Control property [UAX9]: ALM, LTR, RTL, LRE-RLO, LRI-PDI) as if
|
|
220
|
+
// they were not there.
|
|
221
|
+
value.slice(start, end).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, ""),
|
|
222
|
+
start === 0 ? info.breakBefore : true,
|
|
223
|
+
end === value.length ? info.breakAfter : true
|
|
224
|
+
)
|
|
225
|
+
);
|
|
226
|
+
start = end + 1;
|
|
227
|
+
}
|
|
228
|
+
let index = -1;
|
|
229
|
+
let join;
|
|
230
|
+
while (++index < lines.length) {
|
|
231
|
+
if (lines[index].charCodeAt(lines[index].length - 1) === 8203 || index < lines.length - 1 && lines[index + 1].charCodeAt(0) === 8203) {
|
|
232
|
+
result.push(lines[index]);
|
|
233
|
+
join = void 0;
|
|
234
|
+
} else if (lines[index]) {
|
|
235
|
+
if (typeof join === "number") result.push(join);
|
|
236
|
+
result.push(lines[index]);
|
|
237
|
+
join = 0;
|
|
238
|
+
} else if (index === 0 || index === lines.length - 1) {
|
|
239
|
+
result.push(0);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
function collectPreText(node) {
|
|
245
|
+
return [String(node.value)];
|
|
246
|
+
}
|
|
247
|
+
function trimAndCollapseSpacesAndTabs(value, breakBefore, breakAfter) {
|
|
248
|
+
const result = [];
|
|
249
|
+
let start = 0;
|
|
250
|
+
let end;
|
|
251
|
+
while (start < value.length) {
|
|
252
|
+
searchTabOrSpaces.lastIndex = start;
|
|
253
|
+
const match = searchTabOrSpaces.exec(value);
|
|
254
|
+
end = match ? match.index : value.length;
|
|
255
|
+
if (!start && !end && match && !breakBefore) {
|
|
256
|
+
result.push("");
|
|
257
|
+
}
|
|
258
|
+
if (start !== end) {
|
|
259
|
+
result.push(value.slice(start, end));
|
|
260
|
+
}
|
|
261
|
+
start = match ? end + match[0].length : end;
|
|
262
|
+
}
|
|
263
|
+
if (start !== end && !breakAfter) {
|
|
264
|
+
result.push("");
|
|
265
|
+
}
|
|
266
|
+
return result.join(" ");
|
|
267
|
+
}
|
|
268
|
+
function inferWhitespace(node, info) {
|
|
269
|
+
if (node.type === "element") {
|
|
270
|
+
const properties = node.properties || {};
|
|
271
|
+
switch (node.tagName) {
|
|
272
|
+
case "listing":
|
|
273
|
+
case "plaintext":
|
|
274
|
+
case "xmp": {
|
|
275
|
+
return "pre";
|
|
276
|
+
}
|
|
277
|
+
case "nobr": {
|
|
278
|
+
return "nowrap";
|
|
279
|
+
}
|
|
280
|
+
case "pre": {
|
|
281
|
+
return properties.wrap ? "pre-wrap" : "pre";
|
|
282
|
+
}
|
|
283
|
+
case "td":
|
|
284
|
+
case "th": {
|
|
285
|
+
return properties.noWrap ? "nowrap" : info.whitespace;
|
|
286
|
+
}
|
|
287
|
+
case "textarea": {
|
|
288
|
+
return "pre-wrap";
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return info.whitespace;
|
|
293
|
+
}
|
|
294
|
+
function hidden(node) {
|
|
295
|
+
return Boolean((node.properties || {}).hidden);
|
|
296
|
+
}
|
|
297
|
+
function isCell(node) {
|
|
298
|
+
return node.tagName === "td" || node.tagName === "th";
|
|
299
|
+
}
|
|
300
|
+
function closedDialog(node) {
|
|
301
|
+
return node.tagName === "dialog" && !(node.properties || {}).open;
|
|
302
|
+
}
|
|
303
|
+
export {
|
|
304
|
+
toText as t
|
|
305
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const re = /[ \t\n\f\r]/g;
|
|
2
|
+
function whitespace(thing) {
|
|
3
|
+
return typeof thing === "object" ? thing.type === "text" ? empty(thing.value) : false : empty(thing);
|
|
4
|
+
}
|
|
5
|
+
function empty(value) {
|
|
6
|
+
return value.replace(re, "") === "";
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
whitespace as w
|
|
10
|
+
};
|