@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,147 @@
|
|
|
1
|
+
import { u as unreachable } from "./devlop.mjs";
|
|
2
|
+
import { j as jsxRuntimeExports } from "./react.mjs";
|
|
3
|
+
import { u as unified } from "./unified.mjs";
|
|
4
|
+
import { r as remarkParse } from "./remark-parse.mjs";
|
|
5
|
+
import { r as remarkRehype } from "./remark-rehype.mjs";
|
|
6
|
+
import { V as VFile } from "./vfile.mjs";
|
|
7
|
+
import { v as visit } from "./unist-util-visit.mjs";
|
|
8
|
+
import { t as toJsxRuntime } from "./hast-util-to-jsx-runtime.mjs";
|
|
9
|
+
import { u as urlAttributes } from "./html-url-attributes.mjs";
|
|
10
|
+
const changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
|
|
11
|
+
const emptyPlugins = [];
|
|
12
|
+
const emptyRemarkRehypeOptions = { allowDangerousHtml: true };
|
|
13
|
+
const safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i;
|
|
14
|
+
const deprecations = [
|
|
15
|
+
{ from: "astPlugins", id: "remove-buggy-html-in-markdown-parser" },
|
|
16
|
+
{ from: "allowDangerousHtml", id: "remove-buggy-html-in-markdown-parser" },
|
|
17
|
+
{
|
|
18
|
+
from: "allowNode",
|
|
19
|
+
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
|
20
|
+
to: "allowElement"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
from: "allowedTypes",
|
|
24
|
+
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
|
25
|
+
to: "allowedElements"
|
|
26
|
+
},
|
|
27
|
+
{ from: "className", id: "remove-classname" },
|
|
28
|
+
{
|
|
29
|
+
from: "disallowedTypes",
|
|
30
|
+
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
|
31
|
+
to: "disallowedElements"
|
|
32
|
+
},
|
|
33
|
+
{ from: "escapeHtml", id: "remove-buggy-html-in-markdown-parser" },
|
|
34
|
+
{ from: "includeElementIndex", id: "#remove-includeelementindex" },
|
|
35
|
+
{
|
|
36
|
+
from: "includeNodeIndex",
|
|
37
|
+
id: "change-includenodeindex-to-includeelementindex"
|
|
38
|
+
},
|
|
39
|
+
{ from: "linkTarget", id: "remove-linktarget" },
|
|
40
|
+
{ from: "plugins", id: "change-plugins-to-remarkplugins", to: "remarkPlugins" },
|
|
41
|
+
{ from: "rawSourcePos", id: "#remove-rawsourcepos" },
|
|
42
|
+
{ from: "renderers", id: "change-renderers-to-components", to: "components" },
|
|
43
|
+
{ from: "source", id: "change-source-to-children", to: "children" },
|
|
44
|
+
{ from: "sourcePos", id: "#remove-sourcepos" },
|
|
45
|
+
{ from: "transformImageUri", id: "#add-urltransform", to: "urlTransform" },
|
|
46
|
+
{ from: "transformLinkUri", id: "#add-urltransform", to: "urlTransform" }
|
|
47
|
+
];
|
|
48
|
+
function Markdown(options) {
|
|
49
|
+
const processor = createProcessor(options);
|
|
50
|
+
const file = createFile(options);
|
|
51
|
+
return post(processor.runSync(processor.parse(file), file), options);
|
|
52
|
+
}
|
|
53
|
+
function createProcessor(options) {
|
|
54
|
+
const rehypePlugins = options.rehypePlugins || emptyPlugins;
|
|
55
|
+
const remarkPlugins = options.remarkPlugins || emptyPlugins;
|
|
56
|
+
const remarkRehypeOptions = options.remarkRehypeOptions ? { ...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions } : emptyRemarkRehypeOptions;
|
|
57
|
+
const processor = unified().use(remarkParse).use(remarkPlugins).use(remarkRehype, remarkRehypeOptions).use(rehypePlugins);
|
|
58
|
+
return processor;
|
|
59
|
+
}
|
|
60
|
+
function createFile(options) {
|
|
61
|
+
const children = options.children || "";
|
|
62
|
+
const file = new VFile();
|
|
63
|
+
if (typeof children === "string") {
|
|
64
|
+
file.value = children;
|
|
65
|
+
}
|
|
66
|
+
return file;
|
|
67
|
+
}
|
|
68
|
+
function post(tree, options) {
|
|
69
|
+
const allowedElements = options.allowedElements;
|
|
70
|
+
const allowElement = options.allowElement;
|
|
71
|
+
const components = options.components;
|
|
72
|
+
const disallowedElements = options.disallowedElements;
|
|
73
|
+
const skipHtml = options.skipHtml;
|
|
74
|
+
const unwrapDisallowed = options.unwrapDisallowed;
|
|
75
|
+
const urlTransform = options.urlTransform || defaultUrlTransform;
|
|
76
|
+
for (const deprecation of deprecations) {
|
|
77
|
+
if (Object.hasOwn(options, deprecation.from)) {
|
|
78
|
+
unreachable(
|
|
79
|
+
"Unexpected `" + deprecation.from + "` prop, " + (deprecation.to ? "use `" + deprecation.to + "` instead" : "remove it") + " (see <" + changelog + "#" + deprecation.id + "> for more info)"
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
visit(tree, transform);
|
|
84
|
+
return toJsxRuntime(tree, {
|
|
85
|
+
Fragment: jsxRuntimeExports.Fragment,
|
|
86
|
+
components,
|
|
87
|
+
ignoreInvalidStyle: true,
|
|
88
|
+
jsx: jsxRuntimeExports.jsx,
|
|
89
|
+
jsxs: jsxRuntimeExports.jsxs,
|
|
90
|
+
passKeys: true,
|
|
91
|
+
passNode: true
|
|
92
|
+
});
|
|
93
|
+
function transform(node, index, parent) {
|
|
94
|
+
if (node.type === "raw" && parent && typeof index === "number") {
|
|
95
|
+
if (skipHtml) {
|
|
96
|
+
parent.children.splice(index, 1);
|
|
97
|
+
} else {
|
|
98
|
+
parent.children[index] = { type: "text", value: node.value };
|
|
99
|
+
}
|
|
100
|
+
return index;
|
|
101
|
+
}
|
|
102
|
+
if (node.type === "element") {
|
|
103
|
+
let key;
|
|
104
|
+
for (key in urlAttributes) {
|
|
105
|
+
if (Object.hasOwn(urlAttributes, key) && Object.hasOwn(node.properties, key)) {
|
|
106
|
+
const value = node.properties[key];
|
|
107
|
+
const test = urlAttributes[key];
|
|
108
|
+
if (test === null || test.includes(node.tagName)) {
|
|
109
|
+
node.properties[key] = urlTransform(String(value || ""), key, node);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (node.type === "element") {
|
|
115
|
+
let remove = allowedElements ? !allowedElements.includes(node.tagName) : disallowedElements ? disallowedElements.includes(node.tagName) : false;
|
|
116
|
+
if (!remove && allowElement && typeof index === "number") {
|
|
117
|
+
remove = !allowElement(node, index, parent);
|
|
118
|
+
}
|
|
119
|
+
if (remove && parent && typeof index === "number") {
|
|
120
|
+
if (unwrapDisallowed && node.children) {
|
|
121
|
+
parent.children.splice(index, 1, ...node.children);
|
|
122
|
+
} else {
|
|
123
|
+
parent.children.splice(index, 1);
|
|
124
|
+
}
|
|
125
|
+
return index;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function defaultUrlTransform(value) {
|
|
131
|
+
const colon = value.indexOf(":");
|
|
132
|
+
const questionMark = value.indexOf("?");
|
|
133
|
+
const numberSign = value.indexOf("#");
|
|
134
|
+
const slash = value.indexOf("/");
|
|
135
|
+
if (
|
|
136
|
+
// If there is no protocol, it’s relative.
|
|
137
|
+
colon === -1 || // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.
|
|
138
|
+
slash !== -1 && colon > slash || questionMark !== -1 && colon > questionMark || numberSign !== -1 && colon > numberSign || // It is a protocol, it should be allowed.
|
|
139
|
+
safeProtocol.test(value.slice(0, colon))
|
|
140
|
+
) {
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
return "";
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
Markdown as M
|
|
147
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { r as reactExports } from "./react.mjs";
|
|
2
|
+
import { s as styleSingleton } from "./react-style-singleton.mjs";
|
|
3
|
+
var zeroRightClassName = "right-scroll-bar-position";
|
|
4
|
+
var fullWidthClassName = "width-before-scroll-bar";
|
|
5
|
+
var noScrollbarsClassName = "with-scroll-bars-hidden";
|
|
6
|
+
var removedBarSizeVariable = "--removed-body-scroll-bar-size";
|
|
7
|
+
var zeroGap = {
|
|
8
|
+
left: 0,
|
|
9
|
+
top: 0,
|
|
10
|
+
right: 0,
|
|
11
|
+
gap: 0
|
|
12
|
+
};
|
|
13
|
+
var parse = function(x) {
|
|
14
|
+
return parseInt(x || "", 10) || 0;
|
|
15
|
+
};
|
|
16
|
+
var getOffset = function(gapMode) {
|
|
17
|
+
var cs = window.getComputedStyle(document.body);
|
|
18
|
+
var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
|
|
19
|
+
var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
|
|
20
|
+
var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
|
|
21
|
+
return [parse(left), parse(top), parse(right)];
|
|
22
|
+
};
|
|
23
|
+
var getGapWidth = function(gapMode) {
|
|
24
|
+
if (gapMode === void 0) {
|
|
25
|
+
gapMode = "margin";
|
|
26
|
+
}
|
|
27
|
+
if (typeof window === "undefined") {
|
|
28
|
+
return zeroGap;
|
|
29
|
+
}
|
|
30
|
+
var offsets = getOffset(gapMode);
|
|
31
|
+
var documentWidth = document.documentElement.clientWidth;
|
|
32
|
+
var windowWidth = window.innerWidth;
|
|
33
|
+
return {
|
|
34
|
+
left: offsets[0],
|
|
35
|
+
top: offsets[1],
|
|
36
|
+
right: offsets[2],
|
|
37
|
+
gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
var Style = styleSingleton();
|
|
41
|
+
var lockAttribute = "data-scroll-locked";
|
|
42
|
+
var getStyles = function(_a, allowRelative, gapMode, important) {
|
|
43
|
+
var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
|
|
44
|
+
if (gapMode === void 0) {
|
|
45
|
+
gapMode = "margin";
|
|
46
|
+
}
|
|
47
|
+
return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
|
|
48
|
+
allowRelative && "position: relative ".concat(important, ";"),
|
|
49
|
+
gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
|
|
50
|
+
gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
|
|
51
|
+
].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
|
|
52
|
+
};
|
|
53
|
+
var getCurrentUseCounter = function() {
|
|
54
|
+
var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
|
|
55
|
+
return isFinite(counter) ? counter : 0;
|
|
56
|
+
};
|
|
57
|
+
var useLockAttribute = function() {
|
|
58
|
+
reactExports.useEffect(function() {
|
|
59
|
+
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
|
|
60
|
+
return function() {
|
|
61
|
+
var newCounter = getCurrentUseCounter() - 1;
|
|
62
|
+
if (newCounter <= 0) {
|
|
63
|
+
document.body.removeAttribute(lockAttribute);
|
|
64
|
+
} else {
|
|
65
|
+
document.body.setAttribute(lockAttribute, newCounter.toString());
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
};
|
|
70
|
+
var RemoveScrollBar = function(_a) {
|
|
71
|
+
var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
|
|
72
|
+
useLockAttribute();
|
|
73
|
+
var gap = reactExports.useMemo(function() {
|
|
74
|
+
return getGapWidth(gapMode);
|
|
75
|
+
}, [gapMode]);
|
|
76
|
+
return reactExports.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
RemoveScrollBar as R,
|
|
80
|
+
fullWidthClassName as f,
|
|
81
|
+
zeroRightClassName as z
|
|
82
|
+
};
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { a as __rest, _ as __assign, b as __spreadArray } from "./tslib.mjs";
|
|
2
|
+
import { r as reactExports } from "./react.mjs";
|
|
3
|
+
import { z as zeroRightClassName, f as fullWidthClassName, R as RemoveScrollBar } from "./react-remove-scroll-bar.mjs";
|
|
4
|
+
import { c as createSidecarMedium, e as exportSidecar } from "./use-sidecar.mjs";
|
|
5
|
+
import { u as useMergeRefs } from "./use-callback-ref.mjs";
|
|
6
|
+
import { s as styleSingleton } from "./react-style-singleton.mjs";
|
|
7
|
+
var effectCar = createSidecarMedium();
|
|
8
|
+
var nothing = function() {
|
|
9
|
+
return;
|
|
10
|
+
};
|
|
11
|
+
var RemoveScroll = reactExports.forwardRef(function(props, parentRef) {
|
|
12
|
+
var ref = reactExports.useRef(null);
|
|
13
|
+
var _a = reactExports.useState({
|
|
14
|
+
onScrollCapture: nothing,
|
|
15
|
+
onWheelCapture: nothing,
|
|
16
|
+
onTouchMoveCapture: nothing
|
|
17
|
+
}), callbacks = _a[0], setCallbacks = _a[1];
|
|
18
|
+
var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
|
|
19
|
+
var SideCar2 = sideCar;
|
|
20
|
+
var containerRef = useMergeRefs([ref, parentRef]);
|
|
21
|
+
var containerProps = __assign(__assign({}, rest), callbacks);
|
|
22
|
+
return reactExports.createElement(
|
|
23
|
+
reactExports.Fragment,
|
|
24
|
+
null,
|
|
25
|
+
enabled && reactExports.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noRelative, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
|
|
26
|
+
forwardProps ? reactExports.cloneElement(reactExports.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : reactExports.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
RemoveScroll.defaultProps = {
|
|
30
|
+
enabled: true,
|
|
31
|
+
removeScrollBar: true,
|
|
32
|
+
inert: false
|
|
33
|
+
};
|
|
34
|
+
RemoveScroll.classNames = {
|
|
35
|
+
fullWidth: fullWidthClassName,
|
|
36
|
+
zeroRight: zeroRightClassName
|
|
37
|
+
};
|
|
38
|
+
var passiveSupported = false;
|
|
39
|
+
if (typeof window !== "undefined") {
|
|
40
|
+
try {
|
|
41
|
+
var options = Object.defineProperty({}, "passive", {
|
|
42
|
+
get: function() {
|
|
43
|
+
passiveSupported = true;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
window.addEventListener("test", options, options);
|
|
48
|
+
window.removeEventListener("test", options, options);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
passiveSupported = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
var nonPassive = passiveSupported ? { passive: false } : false;
|
|
54
|
+
var alwaysContainsScroll = function(node) {
|
|
55
|
+
return node.tagName === "TEXTAREA";
|
|
56
|
+
};
|
|
57
|
+
var elementCanBeScrolled = function(node, overflow) {
|
|
58
|
+
if (!(node instanceof Element)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
var styles = window.getComputedStyle(node);
|
|
62
|
+
return (
|
|
63
|
+
// not-not-scrollable
|
|
64
|
+
styles[overflow] !== "hidden" && // contains scroll inside self
|
|
65
|
+
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
var elementCouldBeVScrolled = function(node) {
|
|
69
|
+
return elementCanBeScrolled(node, "overflowY");
|
|
70
|
+
};
|
|
71
|
+
var elementCouldBeHScrolled = function(node) {
|
|
72
|
+
return elementCanBeScrolled(node, "overflowX");
|
|
73
|
+
};
|
|
74
|
+
var locationCouldBeScrolled = function(axis, node) {
|
|
75
|
+
var ownerDocument = node.ownerDocument;
|
|
76
|
+
var current = node;
|
|
77
|
+
do {
|
|
78
|
+
if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
|
|
79
|
+
current = current.host;
|
|
80
|
+
}
|
|
81
|
+
var isScrollable = elementCouldBeScrolled(axis, current);
|
|
82
|
+
if (isScrollable) {
|
|
83
|
+
var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
|
|
84
|
+
if (scrollHeight > clientHeight) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
current = current.parentNode;
|
|
89
|
+
} while (current && current !== ownerDocument.body);
|
|
90
|
+
return false;
|
|
91
|
+
};
|
|
92
|
+
var getVScrollVariables = function(_a) {
|
|
93
|
+
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
94
|
+
return [
|
|
95
|
+
scrollTop,
|
|
96
|
+
scrollHeight,
|
|
97
|
+
clientHeight
|
|
98
|
+
];
|
|
99
|
+
};
|
|
100
|
+
var getHScrollVariables = function(_a) {
|
|
101
|
+
var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
|
|
102
|
+
return [
|
|
103
|
+
scrollLeft,
|
|
104
|
+
scrollWidth,
|
|
105
|
+
clientWidth
|
|
106
|
+
];
|
|
107
|
+
};
|
|
108
|
+
var elementCouldBeScrolled = function(axis, node) {
|
|
109
|
+
return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
|
110
|
+
};
|
|
111
|
+
var getScrollVariables = function(axis, node) {
|
|
112
|
+
return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
|
|
113
|
+
};
|
|
114
|
+
var getDirectionFactor = function(axis, direction) {
|
|
115
|
+
return axis === "h" && direction === "rtl" ? -1 : 1;
|
|
116
|
+
};
|
|
117
|
+
var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
|
|
118
|
+
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
|
|
119
|
+
var delta = directionFactor * sourceDelta;
|
|
120
|
+
var target = event.target;
|
|
121
|
+
var targetInLock = endTarget.contains(target);
|
|
122
|
+
var shouldCancelScroll = false;
|
|
123
|
+
var isDeltaPositive = delta > 0;
|
|
124
|
+
var availableScroll = 0;
|
|
125
|
+
var availableScrollTop = 0;
|
|
126
|
+
do {
|
|
127
|
+
if (!target) {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
|
|
131
|
+
var elementScroll = scroll_1 - capacity - directionFactor * position;
|
|
132
|
+
if (position || elementScroll) {
|
|
133
|
+
if (elementCouldBeScrolled(axis, target)) {
|
|
134
|
+
availableScroll += elementScroll;
|
|
135
|
+
availableScrollTop += position;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
var parent_1 = target.parentNode;
|
|
139
|
+
target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
|
|
140
|
+
} while (
|
|
141
|
+
// portaled content
|
|
142
|
+
!targetInLock && target !== document.body || // self content
|
|
143
|
+
targetInLock && (endTarget.contains(target) || endTarget === target)
|
|
144
|
+
);
|
|
145
|
+
if (isDeltaPositive && (Math.abs(availableScroll) < 1 || false)) {
|
|
146
|
+
shouldCancelScroll = true;
|
|
147
|
+
} else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || false)) {
|
|
148
|
+
shouldCancelScroll = true;
|
|
149
|
+
}
|
|
150
|
+
return shouldCancelScroll;
|
|
151
|
+
};
|
|
152
|
+
var getTouchXY = function(event) {
|
|
153
|
+
return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
|
|
154
|
+
};
|
|
155
|
+
var getDeltaXY = function(event) {
|
|
156
|
+
return [event.deltaX, event.deltaY];
|
|
157
|
+
};
|
|
158
|
+
var extractRef = function(ref) {
|
|
159
|
+
return ref && "current" in ref ? ref.current : ref;
|
|
160
|
+
};
|
|
161
|
+
var deltaCompare = function(x, y) {
|
|
162
|
+
return x[0] === y[0] && x[1] === y[1];
|
|
163
|
+
};
|
|
164
|
+
var generateStyle = function(id) {
|
|
165
|
+
return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
|
|
166
|
+
};
|
|
167
|
+
var idCounter = 0;
|
|
168
|
+
var lockStack = [];
|
|
169
|
+
function RemoveScrollSideCar(props) {
|
|
170
|
+
var shouldPreventQueue = reactExports.useRef([]);
|
|
171
|
+
var touchStartRef = reactExports.useRef([0, 0]);
|
|
172
|
+
var activeAxis = reactExports.useRef();
|
|
173
|
+
var id = reactExports.useState(idCounter++)[0];
|
|
174
|
+
var Style = reactExports.useState(styleSingleton)[0];
|
|
175
|
+
var lastProps = reactExports.useRef(props);
|
|
176
|
+
reactExports.useEffect(function() {
|
|
177
|
+
lastProps.current = props;
|
|
178
|
+
}, [props]);
|
|
179
|
+
reactExports.useEffect(function() {
|
|
180
|
+
if (props.inert) {
|
|
181
|
+
document.body.classList.add("block-interactivity-".concat(id));
|
|
182
|
+
var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
|
|
183
|
+
allow_1.forEach(function(el) {
|
|
184
|
+
return el.classList.add("allow-interactivity-".concat(id));
|
|
185
|
+
});
|
|
186
|
+
return function() {
|
|
187
|
+
document.body.classList.remove("block-interactivity-".concat(id));
|
|
188
|
+
allow_1.forEach(function(el) {
|
|
189
|
+
return el.classList.remove("allow-interactivity-".concat(id));
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return;
|
|
194
|
+
}, [props.inert, props.lockRef.current, props.shards]);
|
|
195
|
+
var shouldCancelEvent = reactExports.useCallback(function(event, parent) {
|
|
196
|
+
if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
|
|
197
|
+
return !lastProps.current.allowPinchZoom;
|
|
198
|
+
}
|
|
199
|
+
var touch = getTouchXY(event);
|
|
200
|
+
var touchStart = touchStartRef.current;
|
|
201
|
+
var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
|
|
202
|
+
var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
|
|
203
|
+
var currentAxis;
|
|
204
|
+
var target = event.target;
|
|
205
|
+
var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
|
|
206
|
+
if ("touches" in event && moveDirection === "h" && target.type === "range") {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
var selection = window.getSelection();
|
|
210
|
+
var anchorNode = selection && selection.anchorNode;
|
|
211
|
+
var isTouchingSelection = anchorNode ? anchorNode === target || anchorNode.contains(target) : false;
|
|
212
|
+
if (isTouchingSelection) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
216
|
+
if (!canBeScrolledInMainDirection) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (canBeScrolledInMainDirection) {
|
|
220
|
+
currentAxis = moveDirection;
|
|
221
|
+
} else {
|
|
222
|
+
currentAxis = moveDirection === "v" ? "h" : "v";
|
|
223
|
+
canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
224
|
+
}
|
|
225
|
+
if (!canBeScrolledInMainDirection) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
|
|
229
|
+
activeAxis.current = currentAxis;
|
|
230
|
+
}
|
|
231
|
+
if (!currentAxis) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
var cancelingAxis = activeAxis.current || currentAxis;
|
|
235
|
+
return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY);
|
|
236
|
+
}, []);
|
|
237
|
+
var shouldPrevent = reactExports.useCallback(function(_event) {
|
|
238
|
+
var event = _event;
|
|
239
|
+
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
|
|
243
|
+
var sourceEvent = shouldPreventQueue.current.filter(function(e) {
|
|
244
|
+
return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
|
|
245
|
+
})[0];
|
|
246
|
+
if (sourceEvent && sourceEvent.should) {
|
|
247
|
+
if (event.cancelable) {
|
|
248
|
+
event.preventDefault();
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (!sourceEvent) {
|
|
253
|
+
var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
|
|
254
|
+
return node.contains(event.target);
|
|
255
|
+
});
|
|
256
|
+
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
|
257
|
+
if (shouldStop) {
|
|
258
|
+
if (event.cancelable) {
|
|
259
|
+
event.preventDefault();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, []);
|
|
264
|
+
var shouldCancel = reactExports.useCallback(function(name, delta, target, should) {
|
|
265
|
+
var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
|
|
266
|
+
shouldPreventQueue.current.push(event);
|
|
267
|
+
setTimeout(function() {
|
|
268
|
+
shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
|
|
269
|
+
return e !== event;
|
|
270
|
+
});
|
|
271
|
+
}, 1);
|
|
272
|
+
}, []);
|
|
273
|
+
var scrollTouchStart = reactExports.useCallback(function(event) {
|
|
274
|
+
touchStartRef.current = getTouchXY(event);
|
|
275
|
+
activeAxis.current = void 0;
|
|
276
|
+
}, []);
|
|
277
|
+
var scrollWheel = reactExports.useCallback(function(event) {
|
|
278
|
+
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
279
|
+
}, []);
|
|
280
|
+
var scrollTouchMove = reactExports.useCallback(function(event) {
|
|
281
|
+
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
282
|
+
}, []);
|
|
283
|
+
reactExports.useEffect(function() {
|
|
284
|
+
lockStack.push(Style);
|
|
285
|
+
props.setCallbacks({
|
|
286
|
+
onScrollCapture: scrollWheel,
|
|
287
|
+
onWheelCapture: scrollWheel,
|
|
288
|
+
onTouchMoveCapture: scrollTouchMove
|
|
289
|
+
});
|
|
290
|
+
document.addEventListener("wheel", shouldPrevent, nonPassive);
|
|
291
|
+
document.addEventListener("touchmove", shouldPrevent, nonPassive);
|
|
292
|
+
document.addEventListener("touchstart", scrollTouchStart, nonPassive);
|
|
293
|
+
return function() {
|
|
294
|
+
lockStack = lockStack.filter(function(inst) {
|
|
295
|
+
return inst !== Style;
|
|
296
|
+
});
|
|
297
|
+
document.removeEventListener("wheel", shouldPrevent, nonPassive);
|
|
298
|
+
document.removeEventListener("touchmove", shouldPrevent, nonPassive);
|
|
299
|
+
document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
|
|
300
|
+
};
|
|
301
|
+
}, []);
|
|
302
|
+
var removeScrollBar = props.removeScrollBar, inert = props.inert;
|
|
303
|
+
return reactExports.createElement(
|
|
304
|
+
reactExports.Fragment,
|
|
305
|
+
null,
|
|
306
|
+
inert ? reactExports.createElement(Style, { styles: generateStyle(id) }) : null,
|
|
307
|
+
removeScrollBar ? reactExports.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
function getOutermostShadowParent(node) {
|
|
311
|
+
var shadowParent = null;
|
|
312
|
+
while (node !== null) {
|
|
313
|
+
if (node instanceof ShadowRoot) {
|
|
314
|
+
shadowParent = node.host;
|
|
315
|
+
node = node.host;
|
|
316
|
+
}
|
|
317
|
+
node = node.parentNode;
|
|
318
|
+
}
|
|
319
|
+
return shadowParent;
|
|
320
|
+
}
|
|
321
|
+
const SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
|
|
322
|
+
var ReactRemoveScroll = reactExports.forwardRef(function(props, ref) {
|
|
323
|
+
return reactExports.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: SideCar }));
|
|
324
|
+
});
|
|
325
|
+
ReactRemoveScroll.classNames = RemoveScroll.classNames;
|
|
326
|
+
export {
|
|
327
|
+
ReactRemoveScroll as R
|
|
328
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { r as reactExports } from "./react.mjs";
|
|
2
|
+
import { g as getNonce } from "./get-nonce.mjs";
|
|
3
|
+
function makeStyleTag() {
|
|
4
|
+
if (!document)
|
|
5
|
+
return null;
|
|
6
|
+
var tag = document.createElement("style");
|
|
7
|
+
tag.type = "text/css";
|
|
8
|
+
var nonce = getNonce();
|
|
9
|
+
if (nonce) {
|
|
10
|
+
tag.setAttribute("nonce", nonce);
|
|
11
|
+
}
|
|
12
|
+
return tag;
|
|
13
|
+
}
|
|
14
|
+
function injectStyles(tag, css) {
|
|
15
|
+
if (tag.styleSheet) {
|
|
16
|
+
tag.styleSheet.cssText = css;
|
|
17
|
+
} else {
|
|
18
|
+
tag.appendChild(document.createTextNode(css));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function insertStyleTag(tag) {
|
|
22
|
+
var head = document.head || document.getElementsByTagName("head")[0];
|
|
23
|
+
head.appendChild(tag);
|
|
24
|
+
}
|
|
25
|
+
var stylesheetSingleton = function() {
|
|
26
|
+
var counter = 0;
|
|
27
|
+
var stylesheet = null;
|
|
28
|
+
return {
|
|
29
|
+
add: function(style) {
|
|
30
|
+
if (counter == 0) {
|
|
31
|
+
if (stylesheet = makeStyleTag()) {
|
|
32
|
+
injectStyles(stylesheet, style);
|
|
33
|
+
insertStyleTag(stylesheet);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
counter++;
|
|
37
|
+
},
|
|
38
|
+
remove: function() {
|
|
39
|
+
counter--;
|
|
40
|
+
if (!counter && stylesheet) {
|
|
41
|
+
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
|
|
42
|
+
stylesheet = null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
var styleHookSingleton = function() {
|
|
48
|
+
var sheet = stylesheetSingleton();
|
|
49
|
+
return function(styles, isDynamic) {
|
|
50
|
+
reactExports.useEffect(function() {
|
|
51
|
+
sheet.add(styles);
|
|
52
|
+
return function() {
|
|
53
|
+
sheet.remove();
|
|
54
|
+
};
|
|
55
|
+
}, [styles && isDynamic]);
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
var styleSingleton = function() {
|
|
59
|
+
var useStyle = styleHookSingleton();
|
|
60
|
+
var Sheet = function(_a) {
|
|
61
|
+
var styles = _a.styles, dynamic = _a.dynamic;
|
|
62
|
+
useStyle(styles, dynamic);
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
return Sheet;
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
styleSingleton as s
|
|
69
|
+
};
|