hermium 0.1.2 → 0.1.4
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 +184 -145
- package/dist/server/index.mjs +65 -65
- package/dist/web-server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +6 -0
- package/dist/web-server/_chunks/ssr-renderer.mjs +22 -0
- package/dist/web-server/_libs/babel__runtime.mjs +237 -0
- package/dist/web-server/_libs/bail.mjs +8 -0
- package/dist/web-server/_libs/base-ui__react.mjs +9554 -0
- package/dist/web-server/_libs/base-ui__utils.mjs +1101 -0
- package/dist/web-server/_libs/ccount.mjs +16 -0
- package/dist/web-server/_libs/character-entities-legacy.mjs +111 -0
- package/dist/web-server/_libs/character-entities.mjs +2130 -0
- package/dist/web-server/_libs/character-reference-invalid.mjs +33 -0
- package/dist/web-server/_libs/class-variance-authority.mjs +44 -0
- package/dist/web-server/_libs/clsx.mjs +16 -0
- package/dist/web-server/_libs/comma-separated-tokens.mjs +31 -0
- package/dist/web-server/_libs/cookie-es.mjs +44 -0
- package/dist/web-server/_libs/croner.mjs +1 -0
- package/dist/web-server/_libs/crossws.mjs +1 -0
- package/dist/web-server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/dist/web-server/_libs/devlop.mjs +8 -0
- package/dist/web-server/_libs/escape-string-regexp.mjs +9 -0
- package/dist/web-server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/dist/web-server/_libs/extend.mjs +97 -0
- package/dist/web-server/_libs/fault.mjs +1 -0
- package/dist/web-server/_libs/floating-ui__core.mjs +663 -0
- package/dist/web-server/_libs/floating-ui__dom.mjs +624 -0
- package/dist/web-server/_libs/floating-ui__react-dom.mjs +279 -0
- package/dist/web-server/_libs/floating-ui__utils.mjs +322 -0
- package/dist/web-server/_libs/format.mjs +1 -0
- package/dist/web-server/_libs/h3.mjs +408 -0
- package/dist/web-server/_libs/hast-util-parse-selector.mjs +39 -0
- package/dist/web-server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/dist/web-server/_libs/hast-util-whitespace.mjs +10 -0
- package/dist/web-server/_libs/hastscript.mjs +200 -0
- package/dist/web-server/_libs/highlight.js.mjs +1 -0
- package/dist/web-server/_libs/hookable.mjs +1 -0
- package/dist/web-server/_libs/html-url-attributes.mjs +26 -0
- package/dist/web-server/_libs/inline-style-parser.mjs +142 -0
- package/dist/web-server/_libs/is-alphabetical.mjs +7 -0
- package/dist/web-server/_libs/is-alphanumerical.mjs +8 -0
- package/dist/web-server/_libs/is-decimal.mjs +7 -0
- package/dist/web-server/_libs/is-hexadecimal.mjs +7 -0
- package/dist/web-server/_libs/is-plain-obj.mjs +10 -0
- package/dist/web-server/_libs/isbot.mjs +21 -0
- package/dist/web-server/_libs/longest-streak.mjs +25 -0
- package/dist/web-server/_libs/lowlight.mjs +1 -0
- package/dist/web-server/_libs/markdown-table.mjs +142 -0
- package/dist/web-server/_libs/mdast-util-find-and-replace.mjs +109 -0
- package/dist/web-server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/dist/web-server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +156 -0
- package/dist/web-server/_libs/mdast-util-gfm-footnote.mjs +117 -0
- package/dist/web-server/_libs/mdast-util-gfm-strikethrough.mjs +54 -0
- package/dist/web-server/_libs/mdast-util-gfm-table.mjs +157 -0
- package/dist/web-server/_libs/mdast-util-gfm-task-list-item.mjs +77 -0
- package/dist/web-server/_libs/mdast-util-gfm.mjs +29 -0
- package/dist/web-server/_libs/mdast-util-phrasing.mjs +30 -0
- package/dist/web-server/_libs/mdast-util-to-hast.mjs +710 -0
- package/dist/web-server/_libs/mdast-util-to-markdown.mjs +798 -0
- package/dist/web-server/_libs/mdast-util-to-string.mjs +38 -0
- package/dist/web-server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/dist/web-server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +344 -0
- package/dist/web-server/_libs/micromark-extension-gfm-footnote+[...].mjs +279 -0
- package/dist/web-server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +98 -0
- package/dist/web-server/_libs/micromark-extension-gfm-table.mjs +491 -0
- package/dist/web-server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +1 -0
- package/dist/web-server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +77 -0
- package/dist/web-server/_libs/micromark-extension-gfm.mjs +18 -0
- package/dist/web-server/_libs/micromark-factory-destination.mjs +94 -0
- package/dist/web-server/_libs/micromark-factory-label.mjs +63 -0
- package/dist/web-server/_libs/micromark-factory-space.mjs +24 -0
- package/dist/web-server/_libs/micromark-factory-title.mjs +65 -0
- package/dist/web-server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/dist/web-server/_libs/micromark-util-character.mjs +44 -0
- package/dist/web-server/_libs/micromark-util-chunked.mjs +36 -0
- package/dist/web-server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/dist/web-server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/dist/web-server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/dist/web-server/_libs/micromark-util-decode-string.mjs +21 -0
- package/dist/web-server/_libs/micromark-util-encode.mjs +1 -0
- package/dist/web-server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/dist/web-server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/dist/web-server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/dist/web-server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/dist/web-server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/dist/web-server/_libs/micromark.mjs +906 -0
- package/dist/web-server/_libs/ocache.mjs +1 -0
- package/dist/web-server/_libs/ohash.mjs +1 -0
- package/dist/web-server/_libs/parse-entities.mjs +245 -0
- package/dist/web-server/_libs/property-information.mjs +1210 -0
- package/dist/web-server/_libs/react-dom.mjs +10779 -0
- package/dist/web-server/_libs/react-markdown.mjs +147 -0
- package/dist/web-server/_libs/react-syntax-highlighter.mjs +941 -0
- package/dist/web-server/_libs/react.mjs +513 -0
- package/dist/web-server/_libs/refractor.mjs +2425 -0
- package/dist/web-server/_libs/remark-gfm.mjs +20 -0
- package/dist/web-server/_libs/remark-parse.mjs +19 -0
- package/dist/web-server/_libs/remark-rehype.mjs +21 -0
- package/dist/web-server/_libs/reselect.mjs +1 -0
- package/dist/web-server/_libs/rou3.mjs +8 -0
- package/dist/web-server/_libs/seroval-plugins.mjs +58 -0
- package/dist/web-server/_libs/seroval.mjs +1775 -0
- package/dist/web-server/_libs/space-separated-tokens.mjs +11 -0
- package/dist/web-server/_libs/srvx.mjs +781 -0
- package/dist/web-server/_libs/style-to-js.mjs +72 -0
- package/dist/web-server/_libs/style-to-object.mjs +38 -0
- package/dist/web-server/_libs/tabler__icons-react.mjs +224 -0
- package/dist/web-server/_libs/tanstack__history.mjs +204 -0
- package/dist/web-server/_libs/tanstack__query-core.mjs +2552 -0
- package/dist/web-server/_libs/tanstack__react-query.mjs +190 -0
- package/dist/web-server/_libs/tanstack__react-router.mjs +1120 -0
- package/dist/web-server/_libs/tanstack__react-store.mjs +2 -0
- package/dist/web-server/_libs/tanstack__router-core.mjs +4288 -0
- package/dist/web-server/_libs/tanstack__store.mjs +1 -0
- package/dist/web-server/_libs/trim-lines.mjs +41 -0
- package/dist/web-server/_libs/trough.mjs +85 -0
- package/dist/web-server/_libs/ufo.mjs +54 -0
- package/dist/web-server/_libs/unctx.mjs +1 -0
- package/dist/web-server/_libs/ungap__structured-clone.mjs +224 -0
- package/dist/web-server/_libs/unified.mjs +661 -0
- package/dist/web-server/_libs/unist-util-is.mjs +100 -0
- package/dist/web-server/_libs/unist-util-position.mjs +27 -0
- package/dist/web-server/_libs/unist-util-stringify-position.mjs +27 -0
- package/dist/web-server/_libs/unist-util-visit-parents.mjs +83 -0
- package/dist/web-server/_libs/unist-util-visit.mjs +24 -0
- package/dist/web-server/_libs/unstorage.mjs +1 -0
- package/dist/web-server/_libs/use-sync-external-store.mjs +139 -0
- package/dist/web-server/_libs/vfile-message.mjs +138 -0
- package/dist/web-server/_libs/vfile.mjs +467 -0
- package/dist/web-server/_libs/zod.mjs +3915 -0
- package/dist/web-server/_libs/zustand.mjs +343 -0
- package/dist/web-server/_libs/zwitch.mjs +1 -0
- package/dist/web-server/_ssr/index-BLK6uN4p.mjs +612 -0
- package/dist/web-server/_ssr/index-BkkxTg0a.mjs +1855 -0
- package/dist/web-server/_ssr/index-Bp9a_nTf.mjs +66 -0
- package/dist/web-server/_ssr/index-C8t8AZQG.mjs +513 -0
- package/dist/web-server/_ssr/index-DSIu0x-q.mjs +449 -0
- package/dist/web-server/_ssr/index-DqFrn6kj.mjs +278 -0
- package/dist/web-server/_ssr/index-EKE8NFy_.mjs +189 -0
- package/dist/web-server/_ssr/index-JzLhPyir.mjs +213 -0
- package/dist/web-server/_ssr/index-wTy_4MhH.mjs +369 -0
- package/dist/web-server/_ssr/index.mjs +1558 -0
- package/dist/web-server/_ssr/input-BQFduUUo.mjs +20 -0
- package/dist/web-server/_ssr/router-59cN5lqo.mjs +1998 -0
- package/dist/web-server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/dist/web-server/_ssr/switch-Bim4kX8N.mjs +33 -0
- package/dist/web-server/_ssr/syntax-highlighter-5vezNTce.mjs +62 -0
- package/dist/web-server/_ssr/textarea-CK0ROhfF.mjs +18 -0
- package/dist/web-server/_tanstack-start-manifest_v-DLw6M7p4.mjs +4 -0
- package/dist/web-server/index.mjs +611 -0
- package/package.json +1 -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, h as html, f as find, a 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 { p 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,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
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { f as find, n as normalize, h as html, s as svg } from "./property-information.mjs";
|
|
2
|
+
import { p as parse$1 } from "./comma-separated-tokens.mjs";
|
|
3
|
+
import { p as parse } from "./space-separated-tokens.mjs";
|
|
4
|
+
import { p as parseSelector } from "./hast-util-parse-selector.mjs";
|
|
5
|
+
function createH(schema, defaultTagName, caseSensitive) {
|
|
6
|
+
const adjust = caseSensitive ? createAdjustMap(caseSensitive) : void 0;
|
|
7
|
+
function h2(selector, properties, ...children) {
|
|
8
|
+
let node;
|
|
9
|
+
if (selector === null || selector === void 0) {
|
|
10
|
+
node = { type: "root", children: [] };
|
|
11
|
+
const child = (
|
|
12
|
+
/** @type {Child} */
|
|
13
|
+
properties
|
|
14
|
+
);
|
|
15
|
+
children.unshift(child);
|
|
16
|
+
} else {
|
|
17
|
+
node = parseSelector(selector, defaultTagName);
|
|
18
|
+
const lower = node.tagName.toLowerCase();
|
|
19
|
+
const adjusted = adjust ? adjust.get(lower) : void 0;
|
|
20
|
+
node.tagName = adjusted || lower;
|
|
21
|
+
if (isChild(properties)) {
|
|
22
|
+
children.unshift(properties);
|
|
23
|
+
} else {
|
|
24
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
25
|
+
addProperty(schema, node.properties, key, value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const child of children) {
|
|
30
|
+
addChild(node.children, child);
|
|
31
|
+
}
|
|
32
|
+
if (node.type === "element" && node.tagName === "template") {
|
|
33
|
+
node.content = { type: "root", children: node.children };
|
|
34
|
+
node.children = [];
|
|
35
|
+
}
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
return h2;
|
|
39
|
+
}
|
|
40
|
+
function isChild(value) {
|
|
41
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (typeof value.type !== "string") return false;
|
|
45
|
+
const record = (
|
|
46
|
+
/** @type {Record<string, unknown>} */
|
|
47
|
+
value
|
|
48
|
+
);
|
|
49
|
+
const keys = Object.keys(value);
|
|
50
|
+
for (const key of keys) {
|
|
51
|
+
const value2 = record[key];
|
|
52
|
+
if (value2 && typeof value2 === "object") {
|
|
53
|
+
if (!Array.isArray(value2)) return true;
|
|
54
|
+
const list = (
|
|
55
|
+
/** @type {ReadonlyArray<unknown>} */
|
|
56
|
+
value2
|
|
57
|
+
);
|
|
58
|
+
for (const item of list) {
|
|
59
|
+
if (typeof item !== "number" && typeof item !== "string") {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if ("children" in value && Array.isArray(value.children)) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
function addProperty(schema, properties, key, value) {
|
|
71
|
+
const info = find(schema, key);
|
|
72
|
+
let result;
|
|
73
|
+
if (value === null || value === void 0) return;
|
|
74
|
+
if (typeof value === "number") {
|
|
75
|
+
if (Number.isNaN(value)) return;
|
|
76
|
+
result = value;
|
|
77
|
+
} else if (typeof value === "boolean") {
|
|
78
|
+
result = value;
|
|
79
|
+
} else if (typeof value === "string") {
|
|
80
|
+
if (info.spaceSeparated) {
|
|
81
|
+
result = parse(value);
|
|
82
|
+
} else if (info.commaSeparated) {
|
|
83
|
+
result = parse$1(value);
|
|
84
|
+
} else if (info.commaOrSpaceSeparated) {
|
|
85
|
+
result = parse(parse$1(value).join(" "));
|
|
86
|
+
} else {
|
|
87
|
+
result = parsePrimitive(info, info.property, value);
|
|
88
|
+
}
|
|
89
|
+
} else if (Array.isArray(value)) {
|
|
90
|
+
result = [...value];
|
|
91
|
+
} else {
|
|
92
|
+
result = info.property === "style" ? style(value) : String(value);
|
|
93
|
+
}
|
|
94
|
+
if (Array.isArray(result)) {
|
|
95
|
+
const finalResult = [];
|
|
96
|
+
for (const item of result) {
|
|
97
|
+
finalResult.push(
|
|
98
|
+
/** @type {number | string} */
|
|
99
|
+
parsePrimitive(info, info.property, item)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
result = finalResult;
|
|
103
|
+
}
|
|
104
|
+
if (info.property === "className" && Array.isArray(properties.className)) {
|
|
105
|
+
result = properties.className.concat(
|
|
106
|
+
/** @type {Array<number | string> | number | string} */
|
|
107
|
+
result
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
properties[info.property] = result;
|
|
111
|
+
}
|
|
112
|
+
function addChild(nodes, value) {
|
|
113
|
+
if (value === null || value === void 0) ;
|
|
114
|
+
else if (typeof value === "number" || typeof value === "string") {
|
|
115
|
+
nodes.push({ type: "text", value: String(value) });
|
|
116
|
+
} else if (Array.isArray(value)) {
|
|
117
|
+
for (const child of value) {
|
|
118
|
+
addChild(nodes, child);
|
|
119
|
+
}
|
|
120
|
+
} else if (typeof value === "object" && "type" in value) {
|
|
121
|
+
if (value.type === "root") {
|
|
122
|
+
addChild(nodes, value.children);
|
|
123
|
+
} else {
|
|
124
|
+
nodes.push(value);
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
throw new Error("Expected node, nodes, or string, got `" + value + "`");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function parsePrimitive(info, name, value) {
|
|
131
|
+
if (typeof value === "string") {
|
|
132
|
+
if (info.number && value && !Number.isNaN(Number(value))) {
|
|
133
|
+
return Number(value);
|
|
134
|
+
}
|
|
135
|
+
if ((info.boolean || info.overloadedBoolean) && (value === "" || normalize(value) === normalize(name))) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
function style(styles) {
|
|
142
|
+
const result = [];
|
|
143
|
+
for (const [key, value] of Object.entries(styles)) {
|
|
144
|
+
result.push([key, value].join(": "));
|
|
145
|
+
}
|
|
146
|
+
return result.join("; ");
|
|
147
|
+
}
|
|
148
|
+
function createAdjustMap(values) {
|
|
149
|
+
const result = /* @__PURE__ */ new Map();
|
|
150
|
+
for (const value of values) {
|
|
151
|
+
result.set(value.toLowerCase(), value);
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
const svgCaseSensitiveTagNames = [
|
|
156
|
+
"altGlyph",
|
|
157
|
+
"altGlyphDef",
|
|
158
|
+
"altGlyphItem",
|
|
159
|
+
"animateColor",
|
|
160
|
+
"animateMotion",
|
|
161
|
+
"animateTransform",
|
|
162
|
+
"clipPath",
|
|
163
|
+
"feBlend",
|
|
164
|
+
"feColorMatrix",
|
|
165
|
+
"feComponentTransfer",
|
|
166
|
+
"feComposite",
|
|
167
|
+
"feConvolveMatrix",
|
|
168
|
+
"feDiffuseLighting",
|
|
169
|
+
"feDisplacementMap",
|
|
170
|
+
"feDistantLight",
|
|
171
|
+
"feDropShadow",
|
|
172
|
+
"feFlood",
|
|
173
|
+
"feFuncA",
|
|
174
|
+
"feFuncB",
|
|
175
|
+
"feFuncG",
|
|
176
|
+
"feFuncR",
|
|
177
|
+
"feGaussianBlur",
|
|
178
|
+
"feImage",
|
|
179
|
+
"feMerge",
|
|
180
|
+
"feMergeNode",
|
|
181
|
+
"feMorphology",
|
|
182
|
+
"feOffset",
|
|
183
|
+
"fePointLight",
|
|
184
|
+
"feSpecularLighting",
|
|
185
|
+
"feSpotLight",
|
|
186
|
+
"feTile",
|
|
187
|
+
"feTurbulence",
|
|
188
|
+
"foreignObject",
|
|
189
|
+
"glyphRef",
|
|
190
|
+
"linearGradient",
|
|
191
|
+
"radialGradient",
|
|
192
|
+
"solidColor",
|
|
193
|
+
"textArea",
|
|
194
|
+
"textPath"
|
|
195
|
+
];
|
|
196
|
+
const h = createH(html, "div");
|
|
197
|
+
createH(svg, "g", svgCaseSensitiveTagNames);
|
|
198
|
+
export {
|
|
199
|
+
h
|
|
200
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const urlAttributes = {
|
|
2
|
+
action: ["form"],
|
|
3
|
+
cite: ["blockquote", "del", "ins", "q"],
|
|
4
|
+
data: ["object"],
|
|
5
|
+
formAction: ["button", "input"],
|
|
6
|
+
href: ["a", "area", "base", "link"],
|
|
7
|
+
icon: ["menuitem"],
|
|
8
|
+
itemId: null,
|
|
9
|
+
manifest: ["html"],
|
|
10
|
+
ping: ["a", "area"],
|
|
11
|
+
poster: ["video"],
|
|
12
|
+
src: [
|
|
13
|
+
"audio",
|
|
14
|
+
"embed",
|
|
15
|
+
"iframe",
|
|
16
|
+
"img",
|
|
17
|
+
"input",
|
|
18
|
+
"script",
|
|
19
|
+
"source",
|
|
20
|
+
"track",
|
|
21
|
+
"video"
|
|
22
|
+
]
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
urlAttributes as u
|
|
26
|
+
};
|