@tonyclaw/llm-inspector 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +17 -0
- package/.output/public/assets/alibaba-TTwafVwX.svg +1 -0
- package/.output/public/assets/index-B3RwBPLW.css +1 -0
- package/.output/public/assets/index-s4lwsWvq.js +97 -0
- package/.output/public/assets/main-Cp8AM0Pa.js +17 -0
- package/.output/public/assets/minimax-BPMzvuL-.jpeg +0 -0
- package/.output/public/assets/qwen-CONDcHqt.png +0 -0
- package/.output/public/assets/zhipuai-BPNAnxo-.svg +219 -0
- package/.output/server/_chunks/ssr-renderer.mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +210 -0
- package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +11 -0
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +69 -0
- package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +6 -0
- package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +34 -0
- package/.output/server/_libs/ajv-formats.mjs +330 -0
- package/.output/server/_libs/ajv.mjs +11444 -0
- package/.output/server/_libs/aria-hidden.mjs +122 -0
- package/.output/server/_libs/atomically.mjs +152 -0
- package/.output/server/_libs/bail.mjs +8 -0
- package/.output/server/_libs/character-entities.mjs +2130 -0
- package/.output/server/_libs/class-variance-authority.mjs +44 -0
- package/.output/server/_libs/clsx.mjs +16 -0
- package/.output/server/_libs/comma-separated-tokens.mjs +10 -0
- package/.output/server/_libs/conf.mjs +635 -0
- package/.output/server/_libs/cookie-es.mjs +58 -0
- package/.output/server/_libs/core-util-is.mjs +75 -0
- package/.output/server/_libs/croner.mjs +1 -0
- package/.output/server/_libs/crossws.mjs +1 -0
- package/.output/server/_libs/debounce-fn.mjs +69 -0
- package/.output/server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/.output/server/_libs/detect-node-es.mjs +1 -0
- package/.output/server/_libs/devlop.mjs +8 -0
- package/.output/server/_libs/dot-prop.mjs +265 -0
- package/.output/server/_libs/env-paths.mjs +57 -0
- package/.output/server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/.output/server/_libs/extend.mjs +97 -0
- package/.output/server/_libs/fast-deep-equal.mjs +38 -0
- package/.output/server/_libs/fast-uri.mjs +812 -0
- package/.output/server/_libs/floating-ui__core.mjs +725 -0
- package/.output/server/_libs/floating-ui__dom.mjs +622 -0
- package/.output/server/_libs/floating-ui__react-dom.mjs +292 -0
- package/.output/server/_libs/floating-ui__utils.mjs +320 -0
- package/.output/server/_libs/get-nonce.mjs +9 -0
- package/.output/server/_libs/h3-v2.mjs +276 -0
- package/.output/server/_libs/h3.mjs +400 -0
- package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/.output/server/_libs/hast-util-whitespace.mjs +10 -0
- package/.output/server/_libs/hookable.mjs +1 -0
- package/.output/server/_libs/html-url-attributes.mjs +26 -0
- package/.output/server/_libs/immediate.mjs +74 -0
- package/.output/server/_libs/inherits.mjs +50 -0
- package/.output/server/_libs/inline-style-parser.mjs +142 -0
- package/.output/server/_libs/is-plain-obj.mjs +10 -0
- package/.output/server/_libs/isarray.mjs +14 -0
- package/.output/server/_libs/isbot.mjs +20 -0
- package/.output/server/_libs/json-schema-traverse.mjs +180 -0
- package/.output/server/_libs/jszip.mjs +3049 -0
- package/.output/server/_libs/lie.mjs +273 -0
- package/.output/server/_libs/lucide-react.mjs +368 -0
- package/.output/server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/.output/server/_libs/mdast-util-to-hast.mjs +710 -0
- package/.output/server/_libs/mdast-util-to-string.mjs +38 -0
- package/.output/server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/.output/server/_libs/micromark-factory-destination.mjs +94 -0
- package/.output/server/_libs/micromark-factory-label.mjs +63 -0
- package/.output/server/_libs/micromark-factory-space.mjs +24 -0
- package/.output/server/_libs/micromark-factory-title.mjs +65 -0
- package/.output/server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/.output/server/_libs/micromark-util-character.mjs +44 -0
- package/.output/server/_libs/micromark-util-chunked.mjs +36 -0
- package/.output/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/.output/server/_libs/micromark-util-decode-string.mjs +21 -0
- package/.output/server/_libs/micromark-util-encode.mjs +1 -0
- package/.output/server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/.output/server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/.output/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/.output/server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/.output/server/_libs/micromark.mjs +906 -0
- package/.output/server/_libs/mimic-function.mjs +47 -0
- package/.output/server/_libs/ohash.mjs +1 -0
- package/.output/server/_libs/pako.mjs +4223 -0
- package/.output/server/_libs/process-nextick-args.mjs +48 -0
- package/.output/server/_libs/property-information.mjs +1209 -0
- package/.output/server/_libs/radix-ui.mjs +1 -0
- package/.output/server/_libs/radix-ui__number.mjs +6 -0
- package/.output/server/_libs/radix-ui__primitive.mjs +11 -0
- package/.output/server/_libs/radix-ui__react-accordion.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
- package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-avatar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-checkbox.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-collapsible.mjs +144 -0
- package/.output/server/_libs/radix-ui__react-collection.mjs +69 -0
- package/.output/server/_libs/radix-ui__react-compose-refs.mjs +39 -0
- package/.output/server/_libs/radix-ui__react-context-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-context.mjs +78 -0
- package/.output/server/_libs/radix-ui__react-dialog.mjs +325 -0
- package/.output/server/_libs/radix-ui__react-direction.mjs +9 -0
- package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-focus-guards.mjs +29 -0
- package/.output/server/_libs/radix-ui__react-focus-scope.mjs +206 -0
- package/.output/server/_libs/radix-ui__react-form.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-hover-card.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-id.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-label.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-menubar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-popover.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-popper.mjs +286 -0
- package/.output/server/_libs/radix-ui__react-portal.mjs +16 -0
- package/.output/server/_libs/radix-ui__react-presence.mjs +128 -0
- package/.output/server/_libs/radix-ui__react-primitive.mjs +42 -0
- package/.output/server/_libs/radix-ui__react-progress.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-radio-group.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-roving-focus.mjs +224 -0
- package/.output/server/_libs/radix-ui__react-scroll-area.mjs +721 -0
- package/.output/server/_libs/radix-ui__react-select.mjs +1163 -0
- package/.output/server/_libs/radix-ui__react-separator.mjs +28 -0
- package/.output/server/_libs/radix-ui__react-slider.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-slot.mjs +99 -0
- package/.output/server/_libs/radix-ui__react-switch.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-tabs.mjs +189 -0
- package/.output/server/_libs/radix-ui__react-toast.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toggle-group.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toggle.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toolbar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +495 -0
- package/.output/server/_libs/radix-ui__react-use-previous.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-use-size.mjs +39 -0
- package/.output/server/_libs/react-dom.mjs +9935 -0
- package/.output/server/_libs/react-markdown.mjs +147 -0
- package/.output/server/_libs/react-remove-scroll-bar.mjs +82 -0
- package/.output/server/_libs/react-remove-scroll.mjs +328 -0
- package/.output/server/_libs/react-style-singleton.mjs +69 -0
- package/.output/server/_libs/react.mjs +515 -0
- package/.output/server/_libs/readable-stream.mjs +1518 -0
- package/.output/server/_libs/remark-parse.mjs +19 -0
- package/.output/server/_libs/remark-rehype.mjs +21 -0
- package/.output/server/_libs/rou3.mjs +8 -0
- package/.output/server/_libs/safe-buffer.mjs +64 -0
- package/.output/server/_libs/semver.mjs +1984 -0
- package/.output/server/_libs/seroval-plugins.mjs +58 -0
- package/.output/server/_libs/seroval.mjs +1765 -0
- package/.output/server/_libs/setimmediate.mjs +1 -0
- package/.output/server/_libs/space-separated-tokens.mjs +6 -0
- package/.output/server/_libs/srvx.mjs +334 -0
- package/.output/server/_libs/stubborn-fs.mjs +91 -0
- package/.output/server/_libs/stubborn-utils.mjs +66 -0
- package/.output/server/_libs/style-to-js.mjs +72 -0
- package/.output/server/_libs/style-to-object.mjs +38 -0
- package/.output/server/_libs/tailwind-merge.mjs +3010 -0
- package/.output/server/_libs/tanstack__history.mjs +217 -0
- package/.output/server/_libs/tanstack__react-router.mjs +1480 -0
- package/.output/server/_libs/tanstack__react-store.mjs +1 -0
- package/.output/server/_libs/tanstack__react-virtual.mjs +44 -0
- package/.output/server/_libs/tanstack__router-core.mjs +4827 -0
- package/.output/server/_libs/tanstack__store.mjs +1 -0
- package/.output/server/_libs/tanstack__virtual-core.mjs +1225 -0
- package/.output/server/_libs/tiny-invariant.mjs +12 -0
- package/.output/server/_libs/tiny-warning.mjs +5 -0
- package/.output/server/_libs/trim-lines.mjs +41 -0
- package/.output/server/_libs/trough.mjs +85 -0
- package/.output/server/_libs/tslib.mjs +576 -0
- package/.output/server/_libs/ufo.mjs +54 -0
- package/.output/server/_libs/uint8array-extras.mjs +69 -0
- package/.output/server/_libs/unctx.mjs +1 -0
- package/.output/server/_libs/ungap__structured-clone.mjs +212 -0
- package/.output/server/_libs/unified.mjs +661 -0
- package/.output/server/_libs/unist-util-is.mjs +100 -0
- package/.output/server/_libs/unist-util-position.mjs +27 -0
- package/.output/server/_libs/unist-util-stringify-position.mjs +27 -0
- package/.output/server/_libs/unist-util-visit-parents.mjs +82 -0
- package/.output/server/_libs/unist-util-visit.mjs +24 -0
- package/.output/server/_libs/unstorage.mjs +1 -0
- package/.output/server/_libs/use-callback-ref.mjs +66 -0
- package/.output/server/_libs/use-sidecar.mjs +106 -0
- package/.output/server/_libs/use-sync-external-store.mjs +1 -0
- package/.output/server/_libs/util-deprecate.mjs +12 -0
- package/.output/server/_libs/vfile-message.mjs +138 -0
- package/.output/server/_libs/vfile.mjs +467 -0
- package/.output/server/_libs/when-exit.mjs +53 -0
- package/.output/server/_libs/zod.mjs +4460 -0
- package/.output/server/_ssr/index-ByCLZu7J.mjs +3061 -0
- package/.output/server/_ssr/index.mjs +1176 -0
- package/.output/server/_ssr/router-Bq_mxeNz.mjs +2872 -0
- package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-C4E0e9my.mjs +4 -0
- package/.output/server/index.mjs +393 -0
- package/README.md +196 -0
- package/package.json +91 -0
- package/src/assets/logos/alibaba.svg +1 -0
- package/src/assets/logos/anthropic.svg +1 -0
- package/src/assets/logos/deepseek.svg +1 -0
- package/src/assets/logos/minimax.jpeg +0 -0
- package/src/assets/logos/openai.svg +1 -0
- package/src/assets/logos/qwen.png +0 -0
- package/src/assets/logos/zhipuai.svg +219 -0
- package/src/cli.ts +68 -0
- package/src/components/ProxyViewer.tsx +325 -0
- package/src/components/ProxyViewerContainer.tsx +211 -0
- package/src/components/providers/ProviderCard.tsx +186 -0
- package/src/components/providers/ProviderForm.tsx +259 -0
- package/src/components/providers/ProviderLogo.tsx +111 -0
- package/src/components/providers/ProvidersPanel.tsx +259 -0
- package/src/components/providers/SettingsDialog.tsx +39 -0
- package/src/components/proxy-viewer/ConversationGroup.tsx +68 -0
- package/src/components/proxy-viewer/ConversationHeader.tsx +141 -0
- package/src/components/proxy-viewer/LogEntry.tsx +225 -0
- package/src/components/proxy-viewer/LogEntryHeader.tsx +250 -0
- package/src/components/proxy-viewer/ReplayDialog.tsx +208 -0
- package/src/components/proxy-viewer/ResponseView.tsx +161 -0
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +171 -0
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +139 -0
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +64 -0
- package/src/components/proxy-viewer/formats/index.tsx +24 -0
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +80 -0
- package/src/components/proxy-viewer/index.ts +8 -0
- package/src/components/ui/badge.tsx +47 -0
- package/src/components/ui/button.tsx +47 -0
- package/src/components/ui/collapsible.tsx +21 -0
- package/src/components/ui/dialog.tsx +129 -0
- package/src/components/ui/json-viewer.tsx +464 -0
- package/src/components/ui/scroll-area.tsx +54 -0
- package/src/components/ui/select.tsx +178 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/tabs.tsx +88 -0
- package/src/components/ui/tooltip.tsx +51 -0
- package/src/index.css +11 -0
- package/src/lib/export-logs.ts +51 -0
- package/src/lib/utils.ts +22 -0
- package/src/proxy/chunkStorage.ts +118 -0
- package/src/proxy/constants.ts +36 -0
- package/src/proxy/formats/anthropic/anthropicProvider.ts +75 -0
- package/src/proxy/formats/anthropic/handler.ts +74 -0
- package/src/proxy/formats/anthropic/index.ts +14 -0
- package/src/proxy/formats/anthropic/register.ts +4 -0
- package/src/proxy/formats/anthropic/schemas.ts +217 -0
- package/src/proxy/formats/anthropic/stream.ts +167 -0
- package/src/proxy/formats/handler.ts +46 -0
- package/src/proxy/formats/index.ts +12 -0
- package/src/proxy/formats/jsonSchema.ts +24 -0
- package/src/proxy/formats/openai/alibabaProvider.ts +38 -0
- package/src/proxy/formats/openai/handler.ts +70 -0
- package/src/proxy/formats/openai/index.ts +25 -0
- package/src/proxy/formats/openai/provider.ts +50 -0
- package/src/proxy/formats/openai/register.ts +4 -0
- package/src/proxy/formats/openai/schemas.ts +150 -0
- package/src/proxy/formats/openai/stream.ts +153 -0
- package/src/proxy/formats/protocol.ts +50 -0
- package/src/proxy/formats/providerRegistry.ts +51 -0
- package/src/proxy/formats/providers/index.ts +3 -0
- package/src/proxy/formats/registry.ts +61 -0
- package/src/proxy/handler.ts +389 -0
- package/src/proxy/logIndex.ts +187 -0
- package/src/proxy/logger.ts +99 -0
- package/src/proxy/providers.ts +234 -0
- package/src/proxy/schemas.ts +160 -0
- package/src/proxy/socketTracker.ts +158 -0
- package/src/proxy/store.ts +386 -0
- package/src/router.tsx +16 -0
- package/src/routes/__root.tsx +38 -0
- package/src/routes/api/config.paths.ts +14 -0
- package/src/routes/api/health.ts +11 -0
- package/src/routes/api/logs.$id.chunks.ts +36 -0
- package/src/routes/api/logs.$id.replay.ts +262 -0
- package/src/routes/api/logs.$id.ts +22 -0
- package/src/routes/api/logs.stream.ts +64 -0
- package/src/routes/api/logs.ts +30 -0
- package/src/routes/api/models.ts +10 -0
- package/src/routes/api/providers.$providerId.ts +45 -0
- package/src/routes/api/providers.ts +37 -0
- package/src/routes/api/sessions.ts +10 -0
- package/src/routes/index.tsx +6 -0
- package/src/routes/proxy/$.ts +15 -0
- package/styles/globals.css +121 -0
|
@@ -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 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { c as commonjsGlobal } from "./react.mjs";
|
|
2
|
+
var lib;
|
|
3
|
+
var hasRequiredLib;
|
|
4
|
+
function requireLib() {
|
|
5
|
+
if (hasRequiredLib) return lib;
|
|
6
|
+
hasRequiredLib = 1;
|
|
7
|
+
var Mutation = commonjsGlobal.MutationObserver || commonjsGlobal.WebKitMutationObserver;
|
|
8
|
+
var scheduleDrain;
|
|
9
|
+
if (process.browser) {
|
|
10
|
+
if (Mutation) {
|
|
11
|
+
var called = 0;
|
|
12
|
+
var observer = new Mutation(nextTick);
|
|
13
|
+
var element = commonjsGlobal.document.createTextNode("");
|
|
14
|
+
observer.observe(element, {
|
|
15
|
+
characterData: true
|
|
16
|
+
});
|
|
17
|
+
scheduleDrain = function() {
|
|
18
|
+
element.data = called = ++called % 2;
|
|
19
|
+
};
|
|
20
|
+
} else if (!commonjsGlobal.setImmediate && typeof commonjsGlobal.MessageChannel !== "undefined") {
|
|
21
|
+
var channel = new commonjsGlobal.MessageChannel();
|
|
22
|
+
channel.port1.onmessage = nextTick;
|
|
23
|
+
scheduleDrain = function() {
|
|
24
|
+
channel.port2.postMessage(0);
|
|
25
|
+
};
|
|
26
|
+
} else if ("document" in commonjsGlobal && "onreadystatechange" in commonjsGlobal.document.createElement("script")) {
|
|
27
|
+
scheduleDrain = function() {
|
|
28
|
+
var scriptEl = commonjsGlobal.document.createElement("script");
|
|
29
|
+
scriptEl.onreadystatechange = function() {
|
|
30
|
+
nextTick();
|
|
31
|
+
scriptEl.onreadystatechange = null;
|
|
32
|
+
scriptEl.parentNode.removeChild(scriptEl);
|
|
33
|
+
scriptEl = null;
|
|
34
|
+
};
|
|
35
|
+
commonjsGlobal.document.documentElement.appendChild(scriptEl);
|
|
36
|
+
};
|
|
37
|
+
} else {
|
|
38
|
+
scheduleDrain = function() {
|
|
39
|
+
setTimeout(nextTick, 0);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
scheduleDrain = function() {
|
|
44
|
+
process.nextTick(nextTick);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var draining;
|
|
48
|
+
var queue = [];
|
|
49
|
+
function nextTick() {
|
|
50
|
+
draining = true;
|
|
51
|
+
var i, oldQueue;
|
|
52
|
+
var len = queue.length;
|
|
53
|
+
while (len) {
|
|
54
|
+
oldQueue = queue;
|
|
55
|
+
queue = [];
|
|
56
|
+
i = -1;
|
|
57
|
+
while (++i < len) {
|
|
58
|
+
oldQueue[i]();
|
|
59
|
+
}
|
|
60
|
+
len = queue.length;
|
|
61
|
+
}
|
|
62
|
+
draining = false;
|
|
63
|
+
}
|
|
64
|
+
lib = immediate;
|
|
65
|
+
function immediate(task) {
|
|
66
|
+
if (queue.push(task) === 1 && !draining) {
|
|
67
|
+
scheduleDrain();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return lib;
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
requireLib as r
|
|
74
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var inherits = { exports: {} };
|
|
2
|
+
var inherits_browser = { exports: {} };
|
|
3
|
+
var hasRequiredInherits_browser;
|
|
4
|
+
function requireInherits_browser() {
|
|
5
|
+
if (hasRequiredInherits_browser) return inherits_browser.exports;
|
|
6
|
+
hasRequiredInherits_browser = 1;
|
|
7
|
+
if (typeof Object.create === "function") {
|
|
8
|
+
inherits_browser.exports = function inherits2(ctor, superCtor) {
|
|
9
|
+
if (superCtor) {
|
|
10
|
+
ctor.super_ = superCtor;
|
|
11
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
12
|
+
constructor: {
|
|
13
|
+
value: ctor,
|
|
14
|
+
enumerable: false,
|
|
15
|
+
writable: true,
|
|
16
|
+
configurable: true
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
} else {
|
|
22
|
+
inherits_browser.exports = function inherits2(ctor, superCtor) {
|
|
23
|
+
if (superCtor) {
|
|
24
|
+
ctor.super_ = superCtor;
|
|
25
|
+
var TempCtor = function() {
|
|
26
|
+
};
|
|
27
|
+
TempCtor.prototype = superCtor.prototype;
|
|
28
|
+
ctor.prototype = new TempCtor();
|
|
29
|
+
ctor.prototype.constructor = ctor;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return inherits_browser.exports;
|
|
34
|
+
}
|
|
35
|
+
var hasRequiredInherits;
|
|
36
|
+
function requireInherits() {
|
|
37
|
+
if (hasRequiredInherits) return inherits.exports;
|
|
38
|
+
hasRequiredInherits = 1;
|
|
39
|
+
try {
|
|
40
|
+
var util = require("util");
|
|
41
|
+
if (typeof util.inherits !== "function") throw "";
|
|
42
|
+
inherits.exports = util.inherits;
|
|
43
|
+
} catch (e) {
|
|
44
|
+
inherits.exports = /* @__PURE__ */ requireInherits_browser();
|
|
45
|
+
}
|
|
46
|
+
return inherits.exports;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
requireInherits as r
|
|
50
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
var cjs;
|
|
2
|
+
var hasRequiredCjs;
|
|
3
|
+
function requireCjs() {
|
|
4
|
+
if (hasRequiredCjs) return cjs;
|
|
5
|
+
hasRequiredCjs = 1;
|
|
6
|
+
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
7
|
+
var NEWLINE_REGEX = /\n/g;
|
|
8
|
+
var WHITESPACE_REGEX = /^\s*/;
|
|
9
|
+
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
|
|
10
|
+
var COLON_REGEX = /^:\s*/;
|
|
11
|
+
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
|
|
12
|
+
var SEMICOLON_REGEX = /^[;\s]*/;
|
|
13
|
+
var TRIM_REGEX = /^\s+|\s+$/g;
|
|
14
|
+
var NEWLINE = "\n";
|
|
15
|
+
var FORWARD_SLASH = "/";
|
|
16
|
+
var ASTERISK = "*";
|
|
17
|
+
var EMPTY_STRING = "";
|
|
18
|
+
var TYPE_COMMENT = "comment";
|
|
19
|
+
var TYPE_DECLARATION = "declaration";
|
|
20
|
+
function index(style, options) {
|
|
21
|
+
if (typeof style !== "string") {
|
|
22
|
+
throw new TypeError("First argument must be a string");
|
|
23
|
+
}
|
|
24
|
+
if (!style) return [];
|
|
25
|
+
options = options || {};
|
|
26
|
+
var lineno = 1;
|
|
27
|
+
var column = 1;
|
|
28
|
+
function updatePosition(str) {
|
|
29
|
+
var lines = str.match(NEWLINE_REGEX);
|
|
30
|
+
if (lines) lineno += lines.length;
|
|
31
|
+
var i = str.lastIndexOf(NEWLINE);
|
|
32
|
+
column = ~i ? str.length - i : column + str.length;
|
|
33
|
+
}
|
|
34
|
+
function position() {
|
|
35
|
+
var start = { line: lineno, column };
|
|
36
|
+
return function(node) {
|
|
37
|
+
node.position = new Position(start);
|
|
38
|
+
whitespace();
|
|
39
|
+
return node;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function Position(start) {
|
|
43
|
+
this.start = start;
|
|
44
|
+
this.end = { line: lineno, column };
|
|
45
|
+
this.source = options.source;
|
|
46
|
+
}
|
|
47
|
+
Position.prototype.content = style;
|
|
48
|
+
function error(msg) {
|
|
49
|
+
var err = new Error(
|
|
50
|
+
options.source + ":" + lineno + ":" + column + ": " + msg
|
|
51
|
+
);
|
|
52
|
+
err.reason = msg;
|
|
53
|
+
err.filename = options.source;
|
|
54
|
+
err.line = lineno;
|
|
55
|
+
err.column = column;
|
|
56
|
+
err.source = style;
|
|
57
|
+
if (options.silent) ;
|
|
58
|
+
else {
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function match(re) {
|
|
63
|
+
var m = re.exec(style);
|
|
64
|
+
if (!m) return;
|
|
65
|
+
var str = m[0];
|
|
66
|
+
updatePosition(str);
|
|
67
|
+
style = style.slice(str.length);
|
|
68
|
+
return m;
|
|
69
|
+
}
|
|
70
|
+
function whitespace() {
|
|
71
|
+
match(WHITESPACE_REGEX);
|
|
72
|
+
}
|
|
73
|
+
function comments(rules) {
|
|
74
|
+
var c;
|
|
75
|
+
rules = rules || [];
|
|
76
|
+
while (c = comment()) {
|
|
77
|
+
if (c !== false) {
|
|
78
|
+
rules.push(c);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return rules;
|
|
82
|
+
}
|
|
83
|
+
function comment() {
|
|
84
|
+
var pos = position();
|
|
85
|
+
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
|
86
|
+
var i = 2;
|
|
87
|
+
while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) {
|
|
88
|
+
++i;
|
|
89
|
+
}
|
|
90
|
+
i += 2;
|
|
91
|
+
if (EMPTY_STRING === style.charAt(i - 1)) {
|
|
92
|
+
return error("End of comment missing");
|
|
93
|
+
}
|
|
94
|
+
var str = style.slice(2, i - 2);
|
|
95
|
+
column += 2;
|
|
96
|
+
updatePosition(str);
|
|
97
|
+
style = style.slice(i);
|
|
98
|
+
column += 2;
|
|
99
|
+
return pos({
|
|
100
|
+
type: TYPE_COMMENT,
|
|
101
|
+
comment: str
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function declaration() {
|
|
105
|
+
var pos = position();
|
|
106
|
+
var prop = match(PROPERTY_REGEX);
|
|
107
|
+
if (!prop) return;
|
|
108
|
+
comment();
|
|
109
|
+
if (!match(COLON_REGEX)) return error("property missing ':'");
|
|
110
|
+
var val = match(VALUE_REGEX);
|
|
111
|
+
var ret = pos({
|
|
112
|
+
type: TYPE_DECLARATION,
|
|
113
|
+
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
|
|
114
|
+
value: val ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) : EMPTY_STRING
|
|
115
|
+
});
|
|
116
|
+
match(SEMICOLON_REGEX);
|
|
117
|
+
return ret;
|
|
118
|
+
}
|
|
119
|
+
function declarations() {
|
|
120
|
+
var decls = [];
|
|
121
|
+
comments(decls);
|
|
122
|
+
var decl;
|
|
123
|
+
while (decl = declaration()) {
|
|
124
|
+
if (decl !== false) {
|
|
125
|
+
decls.push(decl);
|
|
126
|
+
comments(decls);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return decls;
|
|
130
|
+
}
|
|
131
|
+
whitespace();
|
|
132
|
+
return declarations();
|
|
133
|
+
}
|
|
134
|
+
function trim(str) {
|
|
135
|
+
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
|
136
|
+
}
|
|
137
|
+
cjs = index;
|
|
138
|
+
return cjs;
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
requireCjs as r
|
|
142
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function isPlainObject(value) {
|
|
2
|
+
if (typeof value !== "object" || value === null) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const prototype = Object.getPrototypeOf(value);
|
|
6
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
isPlainObject as i
|
|
10
|
+
};
|