@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,906 @@
|
|
|
1
|
+
import { c as combineExtensions } from "./micromark-util-combine-extensions+[...].mjs";
|
|
2
|
+
import { f as factorySpace } from "./micromark-factory-space.mjs";
|
|
3
|
+
import { m as markdownLineEnding } from "./micromark-util-character.mjs";
|
|
4
|
+
import { s as splice, p as push } from "./micromark-util-chunked.mjs";
|
|
5
|
+
import { b as blankLine, c as content$1, d as definition, a as blockQuote, l as list, e as codeFenced, t as thematicBreak, s as setextUnderline, h as htmlFlow, f as headingAtx, g as codeIndented, i as attention, j as characterEscape, k as characterReference, m as codeText, n as labelEnd, o as hardBreakEscape, p as labelStartLink, q as autolink, r as htmlText, u as labelStartImage, v as lineEnding } from "./micromark-core-commonmark.mjs";
|
|
6
|
+
import { r as resolveAll } from "./micromark-util-resolve-all.mjs";
|
|
7
|
+
import { s as subtokenize } from "./micromark-util-subtokenize.mjs";
|
|
8
|
+
const content = {
|
|
9
|
+
tokenize: initializeContent
|
|
10
|
+
};
|
|
11
|
+
function initializeContent(effects) {
|
|
12
|
+
const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);
|
|
13
|
+
let previous;
|
|
14
|
+
return contentStart;
|
|
15
|
+
function afterContentStartConstruct(code) {
|
|
16
|
+
if (code === null) {
|
|
17
|
+
effects.consume(code);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
effects.enter("lineEnding");
|
|
21
|
+
effects.consume(code);
|
|
22
|
+
effects.exit("lineEnding");
|
|
23
|
+
return factorySpace(effects, contentStart, "linePrefix");
|
|
24
|
+
}
|
|
25
|
+
function paragraphInitial(code) {
|
|
26
|
+
effects.enter("paragraph");
|
|
27
|
+
return lineStart(code);
|
|
28
|
+
}
|
|
29
|
+
function lineStart(code) {
|
|
30
|
+
const token = effects.enter("chunkText", {
|
|
31
|
+
contentType: "text",
|
|
32
|
+
previous
|
|
33
|
+
});
|
|
34
|
+
if (previous) {
|
|
35
|
+
previous.next = token;
|
|
36
|
+
}
|
|
37
|
+
previous = token;
|
|
38
|
+
return data(code);
|
|
39
|
+
}
|
|
40
|
+
function data(code) {
|
|
41
|
+
if (code === null) {
|
|
42
|
+
effects.exit("chunkText");
|
|
43
|
+
effects.exit("paragraph");
|
|
44
|
+
effects.consume(code);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (markdownLineEnding(code)) {
|
|
48
|
+
effects.consume(code);
|
|
49
|
+
effects.exit("chunkText");
|
|
50
|
+
return lineStart;
|
|
51
|
+
}
|
|
52
|
+
effects.consume(code);
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const document$1 = {
|
|
57
|
+
tokenize: initializeDocument
|
|
58
|
+
};
|
|
59
|
+
const containerConstruct = {
|
|
60
|
+
tokenize: tokenizeContainer
|
|
61
|
+
};
|
|
62
|
+
function initializeDocument(effects) {
|
|
63
|
+
const self = this;
|
|
64
|
+
const stack = [];
|
|
65
|
+
let continued = 0;
|
|
66
|
+
let childFlow;
|
|
67
|
+
let childToken;
|
|
68
|
+
let lineStartOffset;
|
|
69
|
+
return start;
|
|
70
|
+
function start(code) {
|
|
71
|
+
if (continued < stack.length) {
|
|
72
|
+
const item = stack[continued];
|
|
73
|
+
self.containerState = item[1];
|
|
74
|
+
return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
|
|
75
|
+
}
|
|
76
|
+
return checkNewContainers(code);
|
|
77
|
+
}
|
|
78
|
+
function documentContinue(code) {
|
|
79
|
+
continued++;
|
|
80
|
+
if (self.containerState._closeFlow) {
|
|
81
|
+
self.containerState._closeFlow = void 0;
|
|
82
|
+
if (childFlow) {
|
|
83
|
+
closeFlow();
|
|
84
|
+
}
|
|
85
|
+
const indexBeforeExits = self.events.length;
|
|
86
|
+
let indexBeforeFlow = indexBeforeExits;
|
|
87
|
+
let point;
|
|
88
|
+
while (indexBeforeFlow--) {
|
|
89
|
+
if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
|
|
90
|
+
point = self.events[indexBeforeFlow][1].end;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exitContainers(continued);
|
|
95
|
+
let index = indexBeforeExits;
|
|
96
|
+
while (index < self.events.length) {
|
|
97
|
+
self.events[index][1].end = {
|
|
98
|
+
...point
|
|
99
|
+
};
|
|
100
|
+
index++;
|
|
101
|
+
}
|
|
102
|
+
splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
|
|
103
|
+
self.events.length = index;
|
|
104
|
+
return checkNewContainers(code);
|
|
105
|
+
}
|
|
106
|
+
return start(code);
|
|
107
|
+
}
|
|
108
|
+
function checkNewContainers(code) {
|
|
109
|
+
if (continued === stack.length) {
|
|
110
|
+
if (!childFlow) {
|
|
111
|
+
return documentContinued(code);
|
|
112
|
+
}
|
|
113
|
+
if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {
|
|
114
|
+
return flowStart(code);
|
|
115
|
+
}
|
|
116
|
+
self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
|
|
117
|
+
}
|
|
118
|
+
self.containerState = {};
|
|
119
|
+
return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code);
|
|
120
|
+
}
|
|
121
|
+
function thereIsANewContainer(code) {
|
|
122
|
+
if (childFlow) closeFlow();
|
|
123
|
+
exitContainers(continued);
|
|
124
|
+
return documentContinued(code);
|
|
125
|
+
}
|
|
126
|
+
function thereIsNoNewContainer(code) {
|
|
127
|
+
self.parser.lazy[self.now().line] = continued !== stack.length;
|
|
128
|
+
lineStartOffset = self.now().offset;
|
|
129
|
+
return flowStart(code);
|
|
130
|
+
}
|
|
131
|
+
function documentContinued(code) {
|
|
132
|
+
self.containerState = {};
|
|
133
|
+
return effects.attempt(containerConstruct, containerContinue, flowStart)(code);
|
|
134
|
+
}
|
|
135
|
+
function containerContinue(code) {
|
|
136
|
+
continued++;
|
|
137
|
+
stack.push([self.currentConstruct, self.containerState]);
|
|
138
|
+
return documentContinued(code);
|
|
139
|
+
}
|
|
140
|
+
function flowStart(code) {
|
|
141
|
+
if (code === null) {
|
|
142
|
+
if (childFlow) closeFlow();
|
|
143
|
+
exitContainers(0);
|
|
144
|
+
effects.consume(code);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
childFlow = childFlow || self.parser.flow(self.now());
|
|
148
|
+
effects.enter("chunkFlow", {
|
|
149
|
+
_tokenizer: childFlow,
|
|
150
|
+
contentType: "flow",
|
|
151
|
+
previous: childToken
|
|
152
|
+
});
|
|
153
|
+
return flowContinue(code);
|
|
154
|
+
}
|
|
155
|
+
function flowContinue(code) {
|
|
156
|
+
if (code === null) {
|
|
157
|
+
writeToChild(effects.exit("chunkFlow"), true);
|
|
158
|
+
exitContainers(0);
|
|
159
|
+
effects.consume(code);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (markdownLineEnding(code)) {
|
|
163
|
+
effects.consume(code);
|
|
164
|
+
writeToChild(effects.exit("chunkFlow"));
|
|
165
|
+
continued = 0;
|
|
166
|
+
self.interrupt = void 0;
|
|
167
|
+
return start;
|
|
168
|
+
}
|
|
169
|
+
effects.consume(code);
|
|
170
|
+
return flowContinue;
|
|
171
|
+
}
|
|
172
|
+
function writeToChild(token, endOfFile) {
|
|
173
|
+
const stream = self.sliceStream(token);
|
|
174
|
+
if (endOfFile) stream.push(null);
|
|
175
|
+
token.previous = childToken;
|
|
176
|
+
if (childToken) childToken.next = token;
|
|
177
|
+
childToken = token;
|
|
178
|
+
childFlow.defineSkip(token.start);
|
|
179
|
+
childFlow.write(stream);
|
|
180
|
+
if (self.parser.lazy[token.start.line]) {
|
|
181
|
+
let index = childFlow.events.length;
|
|
182
|
+
while (index--) {
|
|
183
|
+
if (
|
|
184
|
+
// The token starts before the line ending…
|
|
185
|
+
childFlow.events[index][1].start.offset < lineStartOffset && // …and either is not ended yet…
|
|
186
|
+
(!childFlow.events[index][1].end || // …or ends after it.
|
|
187
|
+
childFlow.events[index][1].end.offset > lineStartOffset)
|
|
188
|
+
) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const indexBeforeExits = self.events.length;
|
|
193
|
+
let indexBeforeFlow = indexBeforeExits;
|
|
194
|
+
let seen;
|
|
195
|
+
let point;
|
|
196
|
+
while (indexBeforeFlow--) {
|
|
197
|
+
if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
|
|
198
|
+
if (seen) {
|
|
199
|
+
point = self.events[indexBeforeFlow][1].end;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
seen = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exitContainers(continued);
|
|
206
|
+
index = indexBeforeExits;
|
|
207
|
+
while (index < self.events.length) {
|
|
208
|
+
self.events[index][1].end = {
|
|
209
|
+
...point
|
|
210
|
+
};
|
|
211
|
+
index++;
|
|
212
|
+
}
|
|
213
|
+
splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
|
|
214
|
+
self.events.length = index;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function exitContainers(size) {
|
|
218
|
+
let index = stack.length;
|
|
219
|
+
while (index-- > size) {
|
|
220
|
+
const entry = stack[index];
|
|
221
|
+
self.containerState = entry[1];
|
|
222
|
+
entry[0].exit.call(self, effects);
|
|
223
|
+
}
|
|
224
|
+
stack.length = size;
|
|
225
|
+
}
|
|
226
|
+
function closeFlow() {
|
|
227
|
+
childFlow.write([null]);
|
|
228
|
+
childToken = void 0;
|
|
229
|
+
childFlow = void 0;
|
|
230
|
+
self.containerState._closeFlow = void 0;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function tokenizeContainer(effects, ok, nok) {
|
|
234
|
+
return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok, nok), "linePrefix", this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
|
|
235
|
+
}
|
|
236
|
+
const flow$1 = {
|
|
237
|
+
tokenize: initializeFlow
|
|
238
|
+
};
|
|
239
|
+
function initializeFlow(effects) {
|
|
240
|
+
const self = this;
|
|
241
|
+
const initial = effects.attempt(
|
|
242
|
+
// Try to parse a blank line.
|
|
243
|
+
blankLine,
|
|
244
|
+
atBlankEnding,
|
|
245
|
+
// Try to parse initial flow (essentially, only code).
|
|
246
|
+
effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content$1, afterConstruct)), "linePrefix"))
|
|
247
|
+
);
|
|
248
|
+
return initial;
|
|
249
|
+
function atBlankEnding(code) {
|
|
250
|
+
if (code === null) {
|
|
251
|
+
effects.consume(code);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
effects.enter("lineEndingBlank");
|
|
255
|
+
effects.consume(code);
|
|
256
|
+
effects.exit("lineEndingBlank");
|
|
257
|
+
self.currentConstruct = void 0;
|
|
258
|
+
return initial;
|
|
259
|
+
}
|
|
260
|
+
function afterConstruct(code) {
|
|
261
|
+
if (code === null) {
|
|
262
|
+
effects.consume(code);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
effects.enter("lineEnding");
|
|
266
|
+
effects.consume(code);
|
|
267
|
+
effects.exit("lineEnding");
|
|
268
|
+
self.currentConstruct = void 0;
|
|
269
|
+
return initial;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const resolver = {
|
|
273
|
+
resolveAll: createResolver()
|
|
274
|
+
};
|
|
275
|
+
const string$1 = initializeFactory("string");
|
|
276
|
+
const text$1 = initializeFactory("text");
|
|
277
|
+
function initializeFactory(field) {
|
|
278
|
+
return {
|
|
279
|
+
resolveAll: createResolver(field === "text" ? resolveAllLineSuffixes : void 0),
|
|
280
|
+
tokenize: initializeText
|
|
281
|
+
};
|
|
282
|
+
function initializeText(effects) {
|
|
283
|
+
const self = this;
|
|
284
|
+
const constructs = this.parser.constructs[field];
|
|
285
|
+
const text2 = effects.attempt(constructs, start, notText);
|
|
286
|
+
return start;
|
|
287
|
+
function start(code) {
|
|
288
|
+
return atBreak(code) ? text2(code) : notText(code);
|
|
289
|
+
}
|
|
290
|
+
function notText(code) {
|
|
291
|
+
if (code === null) {
|
|
292
|
+
effects.consume(code);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
effects.enter("data");
|
|
296
|
+
effects.consume(code);
|
|
297
|
+
return data;
|
|
298
|
+
}
|
|
299
|
+
function data(code) {
|
|
300
|
+
if (atBreak(code)) {
|
|
301
|
+
effects.exit("data");
|
|
302
|
+
return text2(code);
|
|
303
|
+
}
|
|
304
|
+
effects.consume(code);
|
|
305
|
+
return data;
|
|
306
|
+
}
|
|
307
|
+
function atBreak(code) {
|
|
308
|
+
if (code === null) {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
const list2 = constructs[code];
|
|
312
|
+
let index = -1;
|
|
313
|
+
if (list2) {
|
|
314
|
+
while (++index < list2.length) {
|
|
315
|
+
const item = list2[index];
|
|
316
|
+
if (!item.previous || item.previous.call(self, self.previous)) {
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function createResolver(extraResolver) {
|
|
326
|
+
return resolveAllText;
|
|
327
|
+
function resolveAllText(events, context) {
|
|
328
|
+
let index = -1;
|
|
329
|
+
let enter;
|
|
330
|
+
while (++index <= events.length) {
|
|
331
|
+
if (enter === void 0) {
|
|
332
|
+
if (events[index] && events[index][1].type === "data") {
|
|
333
|
+
enter = index;
|
|
334
|
+
index++;
|
|
335
|
+
}
|
|
336
|
+
} else if (!events[index] || events[index][1].type !== "data") {
|
|
337
|
+
if (index !== enter + 2) {
|
|
338
|
+
events[enter][1].end = events[index - 1][1].end;
|
|
339
|
+
events.splice(enter + 2, index - enter - 2);
|
|
340
|
+
index = enter + 2;
|
|
341
|
+
}
|
|
342
|
+
enter = void 0;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return extraResolver ? extraResolver(events, context) : events;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function resolveAllLineSuffixes(events, context) {
|
|
349
|
+
let eventIndex = 0;
|
|
350
|
+
while (++eventIndex <= events.length) {
|
|
351
|
+
if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
|
|
352
|
+
const data = events[eventIndex - 1][1];
|
|
353
|
+
const chunks = context.sliceStream(data);
|
|
354
|
+
let index = chunks.length;
|
|
355
|
+
let bufferIndex = -1;
|
|
356
|
+
let size = 0;
|
|
357
|
+
let tabs;
|
|
358
|
+
while (index--) {
|
|
359
|
+
const chunk = chunks[index];
|
|
360
|
+
if (typeof chunk === "string") {
|
|
361
|
+
bufferIndex = chunk.length;
|
|
362
|
+
while (chunk.charCodeAt(bufferIndex - 1) === 32) {
|
|
363
|
+
size++;
|
|
364
|
+
bufferIndex--;
|
|
365
|
+
}
|
|
366
|
+
if (bufferIndex) break;
|
|
367
|
+
bufferIndex = -1;
|
|
368
|
+
} else if (chunk === -2) {
|
|
369
|
+
tabs = true;
|
|
370
|
+
size++;
|
|
371
|
+
} else if (chunk === -1) ;
|
|
372
|
+
else {
|
|
373
|
+
index++;
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (context._contentTypeTextTrailing && eventIndex === events.length) {
|
|
378
|
+
size = 0;
|
|
379
|
+
}
|
|
380
|
+
if (size) {
|
|
381
|
+
const token = {
|
|
382
|
+
type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing",
|
|
383
|
+
start: {
|
|
384
|
+
_bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex,
|
|
385
|
+
_index: data.start._index + index,
|
|
386
|
+
line: data.end.line,
|
|
387
|
+
column: data.end.column - size,
|
|
388
|
+
offset: data.end.offset - size
|
|
389
|
+
},
|
|
390
|
+
end: {
|
|
391
|
+
...data.end
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
data.end = {
|
|
395
|
+
...token.start
|
|
396
|
+
};
|
|
397
|
+
if (data.start.offset === data.end.offset) {
|
|
398
|
+
Object.assign(data, token);
|
|
399
|
+
} else {
|
|
400
|
+
events.splice(eventIndex, 0, ["enter", token, context], ["exit", token, context]);
|
|
401
|
+
eventIndex += 2;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
eventIndex++;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return events;
|
|
408
|
+
}
|
|
409
|
+
const document = {
|
|
410
|
+
[42]: list,
|
|
411
|
+
[43]: list,
|
|
412
|
+
[45]: list,
|
|
413
|
+
[48]: list,
|
|
414
|
+
[49]: list,
|
|
415
|
+
[50]: list,
|
|
416
|
+
[51]: list,
|
|
417
|
+
[52]: list,
|
|
418
|
+
[53]: list,
|
|
419
|
+
[54]: list,
|
|
420
|
+
[55]: list,
|
|
421
|
+
[56]: list,
|
|
422
|
+
[57]: list,
|
|
423
|
+
[62]: blockQuote
|
|
424
|
+
};
|
|
425
|
+
const contentInitial = {
|
|
426
|
+
[91]: definition
|
|
427
|
+
};
|
|
428
|
+
const flowInitial = {
|
|
429
|
+
[-2]: codeIndented,
|
|
430
|
+
[-1]: codeIndented,
|
|
431
|
+
[32]: codeIndented
|
|
432
|
+
};
|
|
433
|
+
const flow = {
|
|
434
|
+
[35]: headingAtx,
|
|
435
|
+
[42]: thematicBreak,
|
|
436
|
+
[45]: [setextUnderline, thematicBreak],
|
|
437
|
+
[60]: htmlFlow,
|
|
438
|
+
[61]: setextUnderline,
|
|
439
|
+
[95]: thematicBreak,
|
|
440
|
+
[96]: codeFenced,
|
|
441
|
+
[126]: codeFenced
|
|
442
|
+
};
|
|
443
|
+
const string = {
|
|
444
|
+
[38]: characterReference,
|
|
445
|
+
[92]: characterEscape
|
|
446
|
+
};
|
|
447
|
+
const text = {
|
|
448
|
+
[-5]: lineEnding,
|
|
449
|
+
[-4]: lineEnding,
|
|
450
|
+
[-3]: lineEnding,
|
|
451
|
+
[33]: labelStartImage,
|
|
452
|
+
[38]: characterReference,
|
|
453
|
+
[42]: attention,
|
|
454
|
+
[60]: [autolink, htmlText],
|
|
455
|
+
[91]: labelStartLink,
|
|
456
|
+
[92]: [hardBreakEscape, characterEscape],
|
|
457
|
+
[93]: labelEnd,
|
|
458
|
+
[95]: attention,
|
|
459
|
+
[96]: codeText
|
|
460
|
+
};
|
|
461
|
+
const insideSpan = {
|
|
462
|
+
null: [attention, resolver]
|
|
463
|
+
};
|
|
464
|
+
const attentionMarkers = {
|
|
465
|
+
null: [42, 95]
|
|
466
|
+
};
|
|
467
|
+
const disable = {
|
|
468
|
+
null: []
|
|
469
|
+
};
|
|
470
|
+
const defaultConstructs = /* @__PURE__ */ Object.freeze({
|
|
471
|
+
__proto__: null,
|
|
472
|
+
attentionMarkers,
|
|
473
|
+
contentInitial,
|
|
474
|
+
disable,
|
|
475
|
+
document,
|
|
476
|
+
flow,
|
|
477
|
+
flowInitial,
|
|
478
|
+
insideSpan,
|
|
479
|
+
string,
|
|
480
|
+
text
|
|
481
|
+
});
|
|
482
|
+
function createTokenizer(parser, initialize, from) {
|
|
483
|
+
let point = {
|
|
484
|
+
_bufferIndex: -1,
|
|
485
|
+
_index: 0,
|
|
486
|
+
line: from && from.line || 1,
|
|
487
|
+
column: from && from.column || 1,
|
|
488
|
+
offset: from && from.offset || 0
|
|
489
|
+
};
|
|
490
|
+
const columnStart = {};
|
|
491
|
+
const resolveAllConstructs = [];
|
|
492
|
+
let chunks = [];
|
|
493
|
+
let stack = [];
|
|
494
|
+
const effects = {
|
|
495
|
+
attempt: constructFactory(onsuccessfulconstruct),
|
|
496
|
+
check: constructFactory(onsuccessfulcheck),
|
|
497
|
+
consume,
|
|
498
|
+
enter,
|
|
499
|
+
exit,
|
|
500
|
+
interrupt: constructFactory(onsuccessfulcheck, {
|
|
501
|
+
interrupt: true
|
|
502
|
+
})
|
|
503
|
+
};
|
|
504
|
+
const context = {
|
|
505
|
+
code: null,
|
|
506
|
+
containerState: {},
|
|
507
|
+
defineSkip,
|
|
508
|
+
events: [],
|
|
509
|
+
now,
|
|
510
|
+
parser,
|
|
511
|
+
previous: null,
|
|
512
|
+
sliceSerialize,
|
|
513
|
+
sliceStream,
|
|
514
|
+
write
|
|
515
|
+
};
|
|
516
|
+
let state = initialize.tokenize.call(context, effects);
|
|
517
|
+
if (initialize.resolveAll) {
|
|
518
|
+
resolveAllConstructs.push(initialize);
|
|
519
|
+
}
|
|
520
|
+
return context;
|
|
521
|
+
function write(slice) {
|
|
522
|
+
chunks = push(chunks, slice);
|
|
523
|
+
main();
|
|
524
|
+
if (chunks[chunks.length - 1] !== null) {
|
|
525
|
+
return [];
|
|
526
|
+
}
|
|
527
|
+
addResult(initialize, 0);
|
|
528
|
+
context.events = resolveAll(resolveAllConstructs, context.events, context);
|
|
529
|
+
return context.events;
|
|
530
|
+
}
|
|
531
|
+
function sliceSerialize(token, expandTabs) {
|
|
532
|
+
return serializeChunks(sliceStream(token), expandTabs);
|
|
533
|
+
}
|
|
534
|
+
function sliceStream(token) {
|
|
535
|
+
return sliceChunks(chunks, token);
|
|
536
|
+
}
|
|
537
|
+
function now() {
|
|
538
|
+
const {
|
|
539
|
+
_bufferIndex,
|
|
540
|
+
_index,
|
|
541
|
+
line,
|
|
542
|
+
column,
|
|
543
|
+
offset
|
|
544
|
+
} = point;
|
|
545
|
+
return {
|
|
546
|
+
_bufferIndex,
|
|
547
|
+
_index,
|
|
548
|
+
line,
|
|
549
|
+
column,
|
|
550
|
+
offset
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function defineSkip(value) {
|
|
554
|
+
columnStart[value.line] = value.column;
|
|
555
|
+
accountForPotentialSkip();
|
|
556
|
+
}
|
|
557
|
+
function main() {
|
|
558
|
+
let chunkIndex;
|
|
559
|
+
while (point._index < chunks.length) {
|
|
560
|
+
const chunk = chunks[point._index];
|
|
561
|
+
if (typeof chunk === "string") {
|
|
562
|
+
chunkIndex = point._index;
|
|
563
|
+
if (point._bufferIndex < 0) {
|
|
564
|
+
point._bufferIndex = 0;
|
|
565
|
+
}
|
|
566
|
+
while (point._index === chunkIndex && point._bufferIndex < chunk.length) {
|
|
567
|
+
go(chunk.charCodeAt(point._bufferIndex));
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
go(chunk);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
function go(code) {
|
|
575
|
+
state = state(code);
|
|
576
|
+
}
|
|
577
|
+
function consume(code) {
|
|
578
|
+
if (markdownLineEnding(code)) {
|
|
579
|
+
point.line++;
|
|
580
|
+
point.column = 1;
|
|
581
|
+
point.offset += code === -3 ? 2 : 1;
|
|
582
|
+
accountForPotentialSkip();
|
|
583
|
+
} else if (code !== -1) {
|
|
584
|
+
point.column++;
|
|
585
|
+
point.offset++;
|
|
586
|
+
}
|
|
587
|
+
if (point._bufferIndex < 0) {
|
|
588
|
+
point._index++;
|
|
589
|
+
} else {
|
|
590
|
+
point._bufferIndex++;
|
|
591
|
+
if (point._bufferIndex === // Points w/ non-negative `_bufferIndex` reference
|
|
592
|
+
// strings.
|
|
593
|
+
/** @type {string} */
|
|
594
|
+
chunks[point._index].length) {
|
|
595
|
+
point._bufferIndex = -1;
|
|
596
|
+
point._index++;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
context.previous = code;
|
|
600
|
+
}
|
|
601
|
+
function enter(type, fields) {
|
|
602
|
+
const token = fields || {};
|
|
603
|
+
token.type = type;
|
|
604
|
+
token.start = now();
|
|
605
|
+
context.events.push(["enter", token, context]);
|
|
606
|
+
stack.push(token);
|
|
607
|
+
return token;
|
|
608
|
+
}
|
|
609
|
+
function exit(type) {
|
|
610
|
+
const token = stack.pop();
|
|
611
|
+
token.end = now();
|
|
612
|
+
context.events.push(["exit", token, context]);
|
|
613
|
+
return token;
|
|
614
|
+
}
|
|
615
|
+
function onsuccessfulconstruct(construct, info) {
|
|
616
|
+
addResult(construct, info.from);
|
|
617
|
+
}
|
|
618
|
+
function onsuccessfulcheck(_, info) {
|
|
619
|
+
info.restore();
|
|
620
|
+
}
|
|
621
|
+
function constructFactory(onreturn, fields) {
|
|
622
|
+
return hook;
|
|
623
|
+
function hook(constructs, returnState, bogusState) {
|
|
624
|
+
let listOfConstructs;
|
|
625
|
+
let constructIndex;
|
|
626
|
+
let currentConstruct;
|
|
627
|
+
let info;
|
|
628
|
+
return Array.isArray(constructs) ? (
|
|
629
|
+
/* c8 ignore next 1 */
|
|
630
|
+
handleListOfConstructs(constructs)
|
|
631
|
+
) : "tokenize" in constructs ? (
|
|
632
|
+
// Looks like a construct.
|
|
633
|
+
handleListOfConstructs([
|
|
634
|
+
/** @type {Construct} */
|
|
635
|
+
constructs
|
|
636
|
+
])
|
|
637
|
+
) : handleMapOfConstructs(constructs);
|
|
638
|
+
function handleMapOfConstructs(map) {
|
|
639
|
+
return start;
|
|
640
|
+
function start(code) {
|
|
641
|
+
const left = code !== null && map[code];
|
|
642
|
+
const all = code !== null && map.null;
|
|
643
|
+
const list2 = [
|
|
644
|
+
// To do: add more extension tests.
|
|
645
|
+
/* c8 ignore next 2 */
|
|
646
|
+
...Array.isArray(left) ? left : left ? [left] : [],
|
|
647
|
+
...Array.isArray(all) ? all : all ? [all] : []
|
|
648
|
+
];
|
|
649
|
+
return handleListOfConstructs(list2)(code);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
function handleListOfConstructs(list2) {
|
|
653
|
+
listOfConstructs = list2;
|
|
654
|
+
constructIndex = 0;
|
|
655
|
+
if (list2.length === 0) {
|
|
656
|
+
return bogusState;
|
|
657
|
+
}
|
|
658
|
+
return handleConstruct(list2[constructIndex]);
|
|
659
|
+
}
|
|
660
|
+
function handleConstruct(construct) {
|
|
661
|
+
return start;
|
|
662
|
+
function start(code) {
|
|
663
|
+
info = store();
|
|
664
|
+
currentConstruct = construct;
|
|
665
|
+
if (!construct.partial) {
|
|
666
|
+
context.currentConstruct = construct;
|
|
667
|
+
}
|
|
668
|
+
if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) {
|
|
669
|
+
return nok();
|
|
670
|
+
}
|
|
671
|
+
return construct.tokenize.call(
|
|
672
|
+
// If we do have fields, create an object w/ `context` as its
|
|
673
|
+
// prototype.
|
|
674
|
+
// This allows a “live binding”, which is needed for `interrupt`.
|
|
675
|
+
fields ? Object.assign(Object.create(context), fields) : context,
|
|
676
|
+
effects,
|
|
677
|
+
ok,
|
|
678
|
+
nok
|
|
679
|
+
)(code);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
function ok(code) {
|
|
683
|
+
onreturn(currentConstruct, info);
|
|
684
|
+
return returnState;
|
|
685
|
+
}
|
|
686
|
+
function nok(code) {
|
|
687
|
+
info.restore();
|
|
688
|
+
if (++constructIndex < listOfConstructs.length) {
|
|
689
|
+
return handleConstruct(listOfConstructs[constructIndex]);
|
|
690
|
+
}
|
|
691
|
+
return bogusState;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function addResult(construct, from2) {
|
|
696
|
+
if (construct.resolveAll && !resolveAllConstructs.includes(construct)) {
|
|
697
|
+
resolveAllConstructs.push(construct);
|
|
698
|
+
}
|
|
699
|
+
if (construct.resolve) {
|
|
700
|
+
splice(context.events, from2, context.events.length - from2, construct.resolve(context.events.slice(from2), context));
|
|
701
|
+
}
|
|
702
|
+
if (construct.resolveTo) {
|
|
703
|
+
context.events = construct.resolveTo(context.events, context);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
function store() {
|
|
707
|
+
const startPoint = now();
|
|
708
|
+
const startPrevious = context.previous;
|
|
709
|
+
const startCurrentConstruct = context.currentConstruct;
|
|
710
|
+
const startEventsIndex = context.events.length;
|
|
711
|
+
const startStack = Array.from(stack);
|
|
712
|
+
return {
|
|
713
|
+
from: startEventsIndex,
|
|
714
|
+
restore
|
|
715
|
+
};
|
|
716
|
+
function restore() {
|
|
717
|
+
point = startPoint;
|
|
718
|
+
context.previous = startPrevious;
|
|
719
|
+
context.currentConstruct = startCurrentConstruct;
|
|
720
|
+
context.events.length = startEventsIndex;
|
|
721
|
+
stack = startStack;
|
|
722
|
+
accountForPotentialSkip();
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
function accountForPotentialSkip() {
|
|
726
|
+
if (point.line in columnStart && point.column < 2) {
|
|
727
|
+
point.column = columnStart[point.line];
|
|
728
|
+
point.offset += columnStart[point.line] - 1;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
function sliceChunks(chunks, token) {
|
|
733
|
+
const startIndex = token.start._index;
|
|
734
|
+
const startBufferIndex = token.start._bufferIndex;
|
|
735
|
+
const endIndex = token.end._index;
|
|
736
|
+
const endBufferIndex = token.end._bufferIndex;
|
|
737
|
+
let view;
|
|
738
|
+
if (startIndex === endIndex) {
|
|
739
|
+
view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];
|
|
740
|
+
} else {
|
|
741
|
+
view = chunks.slice(startIndex, endIndex);
|
|
742
|
+
if (startBufferIndex > -1) {
|
|
743
|
+
const head = view[0];
|
|
744
|
+
if (typeof head === "string") {
|
|
745
|
+
view[0] = head.slice(startBufferIndex);
|
|
746
|
+
} else {
|
|
747
|
+
view.shift();
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if (endBufferIndex > 0) {
|
|
751
|
+
view.push(chunks[endIndex].slice(0, endBufferIndex));
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return view;
|
|
755
|
+
}
|
|
756
|
+
function serializeChunks(chunks, expandTabs) {
|
|
757
|
+
let index = -1;
|
|
758
|
+
const result = [];
|
|
759
|
+
let atTab;
|
|
760
|
+
while (++index < chunks.length) {
|
|
761
|
+
const chunk = chunks[index];
|
|
762
|
+
let value;
|
|
763
|
+
if (typeof chunk === "string") {
|
|
764
|
+
value = chunk;
|
|
765
|
+
} else switch (chunk) {
|
|
766
|
+
case -5: {
|
|
767
|
+
value = "\r";
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
case -4: {
|
|
771
|
+
value = "\n";
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
774
|
+
case -3: {
|
|
775
|
+
value = "\r\n";
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
case -2: {
|
|
779
|
+
value = expandTabs ? " " : " ";
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
case -1: {
|
|
783
|
+
if (!expandTabs && atTab) continue;
|
|
784
|
+
value = " ";
|
|
785
|
+
break;
|
|
786
|
+
}
|
|
787
|
+
default: {
|
|
788
|
+
value = String.fromCharCode(chunk);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
atTab = chunk === -2;
|
|
792
|
+
result.push(value);
|
|
793
|
+
}
|
|
794
|
+
return result.join("");
|
|
795
|
+
}
|
|
796
|
+
function parse(options) {
|
|
797
|
+
const settings = options || {};
|
|
798
|
+
const constructs = (
|
|
799
|
+
/** @type {FullNormalizedExtension} */
|
|
800
|
+
combineExtensions([defaultConstructs, ...settings.extensions || []])
|
|
801
|
+
);
|
|
802
|
+
const parser = {
|
|
803
|
+
constructs,
|
|
804
|
+
content: create(content),
|
|
805
|
+
defined: [],
|
|
806
|
+
document: create(document$1),
|
|
807
|
+
flow: create(flow$1),
|
|
808
|
+
lazy: {},
|
|
809
|
+
string: create(string$1),
|
|
810
|
+
text: create(text$1)
|
|
811
|
+
};
|
|
812
|
+
return parser;
|
|
813
|
+
function create(initial) {
|
|
814
|
+
return creator;
|
|
815
|
+
function creator(from) {
|
|
816
|
+
return createTokenizer(parser, initial, from);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
function postprocess(events) {
|
|
821
|
+
while (!subtokenize(events)) {
|
|
822
|
+
}
|
|
823
|
+
return events;
|
|
824
|
+
}
|
|
825
|
+
const search = /[\0\t\n\r]/g;
|
|
826
|
+
function preprocess() {
|
|
827
|
+
let column = 1;
|
|
828
|
+
let buffer = "";
|
|
829
|
+
let start = true;
|
|
830
|
+
let atCarriageReturn;
|
|
831
|
+
return preprocessor;
|
|
832
|
+
function preprocessor(value, encoding, end) {
|
|
833
|
+
const chunks = [];
|
|
834
|
+
let match;
|
|
835
|
+
let next;
|
|
836
|
+
let startPosition;
|
|
837
|
+
let endPosition;
|
|
838
|
+
let code;
|
|
839
|
+
value = buffer + (typeof value === "string" ? value.toString() : new TextDecoder(encoding || void 0).decode(value));
|
|
840
|
+
startPosition = 0;
|
|
841
|
+
buffer = "";
|
|
842
|
+
if (start) {
|
|
843
|
+
if (value.charCodeAt(0) === 65279) {
|
|
844
|
+
startPosition++;
|
|
845
|
+
}
|
|
846
|
+
start = void 0;
|
|
847
|
+
}
|
|
848
|
+
while (startPosition < value.length) {
|
|
849
|
+
search.lastIndex = startPosition;
|
|
850
|
+
match = search.exec(value);
|
|
851
|
+
endPosition = match && match.index !== void 0 ? match.index : value.length;
|
|
852
|
+
code = value.charCodeAt(endPosition);
|
|
853
|
+
if (!match) {
|
|
854
|
+
buffer = value.slice(startPosition);
|
|
855
|
+
break;
|
|
856
|
+
}
|
|
857
|
+
if (code === 10 && startPosition === endPosition && atCarriageReturn) {
|
|
858
|
+
chunks.push(-3);
|
|
859
|
+
atCarriageReturn = void 0;
|
|
860
|
+
} else {
|
|
861
|
+
if (atCarriageReturn) {
|
|
862
|
+
chunks.push(-5);
|
|
863
|
+
atCarriageReturn = void 0;
|
|
864
|
+
}
|
|
865
|
+
if (startPosition < endPosition) {
|
|
866
|
+
chunks.push(value.slice(startPosition, endPosition));
|
|
867
|
+
column += endPosition - startPosition;
|
|
868
|
+
}
|
|
869
|
+
switch (code) {
|
|
870
|
+
case 0: {
|
|
871
|
+
chunks.push(65533);
|
|
872
|
+
column++;
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
case 9: {
|
|
876
|
+
next = Math.ceil(column / 4) * 4;
|
|
877
|
+
chunks.push(-2);
|
|
878
|
+
while (column++ < next) chunks.push(-1);
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
case 10: {
|
|
882
|
+
chunks.push(-4);
|
|
883
|
+
column = 1;
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
default: {
|
|
887
|
+
atCarriageReturn = true;
|
|
888
|
+
column = 1;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
startPosition = endPosition + 1;
|
|
893
|
+
}
|
|
894
|
+
if (end) {
|
|
895
|
+
if (atCarriageReturn) chunks.push(-5);
|
|
896
|
+
if (buffer) chunks.push(buffer);
|
|
897
|
+
chunks.push(null);
|
|
898
|
+
}
|
|
899
|
+
return chunks;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
export {
|
|
903
|
+
parse as a,
|
|
904
|
+
preprocess as b,
|
|
905
|
+
postprocess as p
|
|
906
|
+
};
|