@tonyclaw/agent-inspector 2.0.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/cli.js +1611 -0
- package/.output/nitro.json +17 -0
- package/.output/public/assets/CompareDrawer-CU5ZrWcL.js +1 -0
- package/.output/public/assets/ProxyViewerContainer-pEBqVp1d.js +101 -0
- package/.output/public/assets/ReplayDialog-F58yNg5j.js +1 -0
- package/.output/public/assets/RequestAnatomy-C9lT0qE_.js +1 -0
- package/.output/public/assets/ResponseView-DHJq6bnz.js +1 -0
- package/.output/public/assets/StreamingChunkSequence-BTgfpFUT.js +1 -0
- package/.output/public/assets/_sessionId-DsNRbnNm.js +1 -0
- package/.output/public/assets/alibaba-TTwafVwX.svg +1 -0
- package/.output/public/assets/index-CpWG2hFn.css +1 -0
- package/.output/public/assets/index-DmBV8Gve.js +1 -0
- package/.output/public/assets/json-viewer-CZVYLR8j.js +14 -0
- package/.output/public/assets/main-DHs7FBK3.js +18 -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 +22 -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 +2 -0
- package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +2 -0
- package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +2 -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/cfworker__json-schema.mjs +1 -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/dequal.mjs +27 -0
- package/.output/server/_libs/detect-node-es.mjs +1 -0
- package/.output/server/_libs/devlop.mjs +8 -0
- package/.output/server/_libs/diff.mjs +320 -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 +408 -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 +3051 -0
- package/.output/server/_libs/lie.mjs +273 -0
- package/.output/server/_libs/lucide-react.mjs +492 -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/modelcontextprotocol__server.mjs +9738 -0
- package/.output/server/_libs/ocache.mjs +1 -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 +2 -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 +10781 -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 +14 -0
- package/.output/server/_libs/safe-buffer.mjs +64 -0
- package/.output/server/_libs/semver.mjs +1938 -0
- package/.output/server/_libs/seroval-plugins.mjs +58 -0
- package/.output/server/_libs/seroval.mjs +1765 -0
- package/.output/server/_libs/setimmediate.mjs +152 -0
- package/.output/server/_libs/space-separated-tokens.mjs +6 -0
- package/.output/server/_libs/srvx.mjs +1029 -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/swr.mjs +939 -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 +1 -0
- package/.output/server/_libs/ufo.mjs +54 -0
- package/.output/server/_libs/uint8array-extras.mjs +69 -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 +64 -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 +4524 -0
- package/.output/server/_sessionId-wMLPvC5g.mjs +123 -0
- package/.output/server/_ssr/CompareDrawer-BU4V0uVf.mjs +1041 -0
- package/.output/server/_ssr/ProxyViewerContainer-BnRwFEnn.mjs +5972 -0
- package/.output/server/_ssr/ReplayDialog-C7dn9pd_.mjs +322 -0
- package/.output/server/_ssr/RequestAnatomy-C1rWpe9-.mjs +353 -0
- package/.output/server/_ssr/ResponseView-hGpPaYsf.mjs +602 -0
- package/.output/server/_ssr/StreamingChunkSequence-BRWI1r_G.mjs +302 -0
- package/.output/server/_ssr/index-BKURLVPz.mjs +118 -0
- package/.output/server/_ssr/index.mjs +1184 -0
- package/.output/server/_ssr/json-viewer-BBd2DtQP.mjs +515 -0
- package/.output/server/_ssr/router-BcZ0D6AB.mjs +6317 -0
- package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-1y8ZVxRI.mjs +4 -0
- package/.output/server/index.mjs +436 -0
- package/.output/server/node_modules/tslib/modules/index.js +70 -0
- package/.output/server/node_modules/tslib/modules/package.json +3 -0
- package/.output/server/node_modules/tslib/package.json +47 -0
- package/.output/server/node_modules/tslib/tslib.js +484 -0
- package/.output/server/package.json +9 -0
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/package.json +110 -0
- package/src/assets/favicon.svg +31 -0
- package/src/assets/logos/alibaba.svg +1 -0
- package/src/assets/logos/anthropic.svg +1 -0
- package/src/assets/logos/claude-code.svg +4 -0
- package/src/assets/logos/deepseek.svg +1 -0
- package/src/assets/logos/mcp.png +0 -0
- package/src/assets/logos/minimax.jpeg +0 -0
- package/src/assets/logos/openai.svg +1 -0
- package/src/assets/logos/opencode.svg +4 -0
- package/src/assets/logos/qwen.png +0 -0
- package/src/assets/logos/zhipuai.svg +219 -0
- package/src/cli/detect-tools.ts +147 -0
- package/src/cli/doctor.ts +521 -0
- package/src/cli/onboard.ts +224 -0
- package/src/cli/templates/command-onboard.ts +17 -0
- package/src/cli/templates/skill-onboard.ts +547 -0
- package/src/cli.ts +345 -0
- package/src/components/OnboardingBanner.tsx +67 -0
- package/src/components/ProxyViewer.tsx +545 -0
- package/src/components/ProxyViewerContainer.tsx +363 -0
- package/src/components/providers/ImportWizardDialog.tsx +349 -0
- package/src/components/providers/ProviderCard.tsx +474 -0
- package/src/components/providers/ProviderForm.tsx +494 -0
- package/src/components/providers/ProviderLogo.tsx +117 -0
- package/src/components/providers/ProvidersPanel.tsx +619 -0
- package/src/components/providers/SettingsDialog.tsx +202 -0
- package/src/components/proxy-viewer/CompareDrawer.tsx +893 -0
- package/src/components/proxy-viewer/ConversationGroup.tsx +107 -0
- package/src/components/proxy-viewer/ConversationHeader.tsx +300 -0
- package/src/components/proxy-viewer/LogEntry.tsx +543 -0
- package/src/components/proxy-viewer/LogEntryHeader.tsx +501 -0
- package/src/components/proxy-viewer/ReplayDialog.tsx +218 -0
- package/src/components/proxy-viewer/ResponseView.tsx +171 -0
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +188 -0
- package/src/components/proxy-viewer/ThreadConnector.tsx +136 -0
- package/src/components/proxy-viewer/TurnGroup.tsx +337 -0
- package/src/components/proxy-viewer/anatomy/RequestAnatomy.tsx +98 -0
- package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +196 -0
- package/src/components/proxy-viewer/anatomy/tokenEstimate.ts +53 -0
- package/src/components/proxy-viewer/anatomy/types.ts +39 -0
- package/src/components/proxy-viewer/anatomy/useAnatomyJump.ts +114 -0
- package/src/components/proxy-viewer/cacheTrend.ts +50 -0
- package/src/components/proxy-viewer/diff/DiffView.tsx +321 -0
- package/src/components/proxy-viewer/diff/computeDiff.ts +178 -0
- package/src/components/proxy-viewer/diff/index.ts +3 -0
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +157 -0
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +66 -0
- package/src/components/proxy-viewer/formats/anthropic/thinkingExtract.ts +21 -0
- package/src/components/proxy-viewer/formats/index.tsx +33 -0
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +170 -0
- package/src/components/proxy-viewer/index.ts +9 -0
- package/src/components/proxy-viewer/lazy.ts +37 -0
- package/src/components/proxy-viewer/log-formats/anthropic.ts +194 -0
- package/src/components/proxy-viewer/log-formats/index.ts +23 -0
- package/src/components/proxy-viewer/log-formats/openai.ts +167 -0
- package/src/components/proxy-viewer/log-formats/types.ts +40 -0
- package/src/components/proxy-viewer/log-formats/unknown.ts +18 -0
- package/src/components/proxy-viewer/logEntryVisibility.ts +39 -0
- package/src/components/proxy-viewer/requestDiff.ts +277 -0
- package/src/components/proxy-viewer/useCopyFeedback.ts +36 -0
- package/src/components/proxy-viewer/useKeyboardNavigation.ts +190 -0
- package/src/components/proxy-viewer/viewerState.ts +66 -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/confirm-dialog.tsx +51 -0
- package/src/components/ui/crab-logo.tsx +95 -0
- package/src/components/ui/crab-variants.tsx +467 -0
- package/src/components/ui/dialog.tsx +129 -0
- package/src/components/ui/json-expansion-button.tsx +56 -0
- package/src/components/ui/json-viewer-bulk.ts +97 -0
- package/src/components/ui/json-viewer.tsx +494 -0
- package/src/components/ui/mcp-logo.tsx +20 -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/knowledge/candidateStore.ts +63 -0
- package/src/knowledge/distiller.ts +98 -0
- package/src/knowledge/openclawClient.ts +118 -0
- package/src/knowledge/redactor.ts +80 -0
- package/src/knowledge/types.ts +84 -0
- package/src/lib/apiClient.ts +49 -0
- package/src/lib/export-logs.ts +51 -0
- package/src/lib/mask.ts +4 -0
- package/src/lib/objectUtils.ts +22 -0
- package/src/lib/providerContract.ts +26 -0
- package/src/lib/providerTestContract.ts +107 -0
- package/src/lib/runtimeConfig.ts +25 -0
- package/src/lib/serverPort.ts +41 -0
- package/src/lib/sessionUrl.ts +44 -0
- package/src/lib/stopReason.ts +58 -0
- package/src/lib/useOnboarding.ts +80 -0
- package/src/lib/useProviders.ts +30 -0
- package/src/lib/useStripConfig.ts +108 -0
- package/src/lib/utils.ts +21 -0
- package/src/mcp/loopback.ts +76 -0
- package/src/mcp/previewExtractor.ts +166 -0
- package/src/mcp/server.ts +396 -0
- package/src/mcp/toolHandlers.ts +341 -0
- package/src/proxy/chunkStorage.ts +112 -0
- package/src/proxy/claudeCodeStrip.ts +99 -0
- package/src/proxy/config.ts +172 -0
- package/src/proxy/constants.ts +47 -0
- package/src/proxy/dataDir.ts +86 -0
- package/src/proxy/formats/anthropic/anthropicProvider.ts +75 -0
- package/src/proxy/formats/anthropic/handler.ts +71 -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 +237 -0
- package/src/proxy/formats/anthropic/stream.ts +205 -0
- package/src/proxy/formats/handler.ts +46 -0
- package/src/proxy/formats/index.ts +12 -0
- package/src/proxy/formats/jsonSchema.ts +36 -0
- package/src/proxy/formats/openai/alibabaProvider.ts +38 -0
- package/src/proxy/formats/openai/handler.ts +96 -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 +187 -0
- package/src/proxy/formats/openai/stream.ts +206 -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 +66 -0
- package/src/proxy/handler.ts +334 -0
- package/src/proxy/logFinalizer.ts +305 -0
- package/src/proxy/logFinalizer.worker.ts +24 -0
- package/src/proxy/logIndex.ts +268 -0
- package/src/proxy/logger.ts +179 -0
- package/src/proxy/openaiOrphanToolStrip.ts +142 -0
- package/src/proxy/providerImporters.ts +491 -0
- package/src/proxy/providers.ts +613 -0
- package/src/proxy/schemas.ts +209 -0
- package/src/proxy/sessionProcess.ts +140 -0
- package/src/proxy/sessionRuntime.ts +85 -0
- package/src/proxy/sessionSupervisor.ts +283 -0
- package/src/proxy/sessionWorkerEntry.ts +26 -0
- package/src/proxy/socketTracker.ts +255 -0
- package/src/proxy/store.ts +412 -0
- package/src/proxy/upstream.ts +90 -0
- package/src/router.tsx +16 -0
- package/src/routes/__root.tsx +45 -0
- package/src/routes/api/config.paths.ts +14 -0
- package/src/routes/api/config.ts +53 -0
- package/src/routes/api/health.ts +15 -0
- package/src/routes/api/knowledge.candidates.$candidateId.promote.ts +32 -0
- package/src/routes/api/knowledge.candidates.ts +10 -0
- package/src/routes/api/knowledge.project-context.ts +18 -0
- package/src/routes/api/knowledge.search.ts +31 -0
- package/src/routes/api/knowledge.sessions.$sessionId.candidates.ts +16 -0
- package/src/routes/api/logs.$id.chunks.ts +36 -0
- package/src/routes/api/logs.$id.replay.ts +191 -0
- package/src/routes/api/logs.$id.ts +22 -0
- package/src/routes/api/logs.stream.ts +74 -0
- package/src/routes/api/logs.ts +59 -0
- package/src/routes/api/mcp.ts +25 -0
- package/src/routes/api/models.ts +10 -0
- package/src/routes/api/providers.$providerId.test.log.ts +293 -0
- package/src/routes/api/providers.$providerId.ts +50 -0
- package/src/routes/api/providers.export.ts +26 -0
- package/src/routes/api/providers.import.ts +47 -0
- package/src/routes/api/providers.scan.ts +23 -0
- package/src/routes/api/providers.ts +45 -0
- package/src/routes/api/sessions.ts +17 -0
- package/src/routes/index.tsx +6 -0
- package/src/routes/proxy/$.ts +15 -0
- package/src/routes/session/$sessionId.tsx +23 -0
- package/styles/globals.css +188 -0
|
@@ -0,0 +1,1518 @@
|
|
|
1
|
+
import require$$2 from "events";
|
|
2
|
+
import require$$11 from "node:string_decoder";
|
|
3
|
+
import require$$0 from "stream";
|
|
4
|
+
import { c as commonjsGlobal } from "./react.mjs";
|
|
5
|
+
import { r as requireProcessNextickArgs } from "./process-nextick-args.mjs";
|
|
6
|
+
import { r as requireIsarray } from "./isarray.mjs";
|
|
7
|
+
import { r as requireSafeBuffer } from "./safe-buffer.mjs";
|
|
8
|
+
import { r as requireUtil } from "./core-util-is.mjs";
|
|
9
|
+
import { r as requireInherits } from "./inherits.mjs";
|
|
10
|
+
import require$$0$1 from "util";
|
|
11
|
+
import { r as requireNode } from "./util-deprecate.mjs";
|
|
12
|
+
var readable = { exports: {} };
|
|
13
|
+
var stream;
|
|
14
|
+
var hasRequiredStream;
|
|
15
|
+
function requireStream() {
|
|
16
|
+
if (hasRequiredStream) return stream;
|
|
17
|
+
hasRequiredStream = 1;
|
|
18
|
+
stream = require$$0;
|
|
19
|
+
return stream;
|
|
20
|
+
}
|
|
21
|
+
var BufferList = { exports: {} };
|
|
22
|
+
var hasRequiredBufferList;
|
|
23
|
+
function requireBufferList() {
|
|
24
|
+
if (hasRequiredBufferList) return BufferList.exports;
|
|
25
|
+
hasRequiredBufferList = 1;
|
|
26
|
+
(function(module) {
|
|
27
|
+
function _classCallCheck(instance, Constructor) {
|
|
28
|
+
if (!(instance instanceof Constructor)) {
|
|
29
|
+
throw new TypeError("Cannot call a class as a function");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
var Buffer = requireSafeBuffer().Buffer;
|
|
33
|
+
var util = require$$0$1;
|
|
34
|
+
function copyBuffer(src, target, offset) {
|
|
35
|
+
src.copy(target, offset);
|
|
36
|
+
}
|
|
37
|
+
module.exports = (function() {
|
|
38
|
+
function BufferList2() {
|
|
39
|
+
_classCallCheck(this, BufferList2);
|
|
40
|
+
this.head = null;
|
|
41
|
+
this.tail = null;
|
|
42
|
+
this.length = 0;
|
|
43
|
+
}
|
|
44
|
+
BufferList2.prototype.push = function push(v) {
|
|
45
|
+
var entry = { data: v, next: null };
|
|
46
|
+
if (this.length > 0) this.tail.next = entry;
|
|
47
|
+
else this.head = entry;
|
|
48
|
+
this.tail = entry;
|
|
49
|
+
++this.length;
|
|
50
|
+
};
|
|
51
|
+
BufferList2.prototype.unshift = function unshift(v) {
|
|
52
|
+
var entry = { data: v, next: this.head };
|
|
53
|
+
if (this.length === 0) this.tail = entry;
|
|
54
|
+
this.head = entry;
|
|
55
|
+
++this.length;
|
|
56
|
+
};
|
|
57
|
+
BufferList2.prototype.shift = function shift() {
|
|
58
|
+
if (this.length === 0) return;
|
|
59
|
+
var ret = this.head.data;
|
|
60
|
+
if (this.length === 1) this.head = this.tail = null;
|
|
61
|
+
else this.head = this.head.next;
|
|
62
|
+
--this.length;
|
|
63
|
+
return ret;
|
|
64
|
+
};
|
|
65
|
+
BufferList2.prototype.clear = function clear() {
|
|
66
|
+
this.head = this.tail = null;
|
|
67
|
+
this.length = 0;
|
|
68
|
+
};
|
|
69
|
+
BufferList2.prototype.join = function join(s) {
|
|
70
|
+
if (this.length === 0) return "";
|
|
71
|
+
var p = this.head;
|
|
72
|
+
var ret = "" + p.data;
|
|
73
|
+
while (p = p.next) {
|
|
74
|
+
ret += s + p.data;
|
|
75
|
+
}
|
|
76
|
+
return ret;
|
|
77
|
+
};
|
|
78
|
+
BufferList2.prototype.concat = function concat(n) {
|
|
79
|
+
if (this.length === 0) return Buffer.alloc(0);
|
|
80
|
+
var ret = Buffer.allocUnsafe(n >>> 0);
|
|
81
|
+
var p = this.head;
|
|
82
|
+
var i = 0;
|
|
83
|
+
while (p) {
|
|
84
|
+
copyBuffer(p.data, ret, i);
|
|
85
|
+
i += p.data.length;
|
|
86
|
+
p = p.next;
|
|
87
|
+
}
|
|
88
|
+
return ret;
|
|
89
|
+
};
|
|
90
|
+
return BufferList2;
|
|
91
|
+
})();
|
|
92
|
+
if (util && util.inspect && util.inspect.custom) {
|
|
93
|
+
module.exports.prototype[util.inspect.custom] = function() {
|
|
94
|
+
var obj = util.inspect({ length: this.length });
|
|
95
|
+
return this.constructor.name + " " + obj;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
})(BufferList);
|
|
99
|
+
return BufferList.exports;
|
|
100
|
+
}
|
|
101
|
+
var destroy_1;
|
|
102
|
+
var hasRequiredDestroy;
|
|
103
|
+
function requireDestroy() {
|
|
104
|
+
if (hasRequiredDestroy) return destroy_1;
|
|
105
|
+
hasRequiredDestroy = 1;
|
|
106
|
+
var pna = requireProcessNextickArgs();
|
|
107
|
+
function destroy(err, cb) {
|
|
108
|
+
var _this = this;
|
|
109
|
+
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
110
|
+
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
111
|
+
if (readableDestroyed || writableDestroyed) {
|
|
112
|
+
if (cb) {
|
|
113
|
+
cb(err);
|
|
114
|
+
} else if (err) {
|
|
115
|
+
if (!this._writableState) {
|
|
116
|
+
pna.nextTick(emitErrorNT, this, err);
|
|
117
|
+
} else if (!this._writableState.errorEmitted) {
|
|
118
|
+
this._writableState.errorEmitted = true;
|
|
119
|
+
pna.nextTick(emitErrorNT, this, err);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
if (this._readableState) {
|
|
125
|
+
this._readableState.destroyed = true;
|
|
126
|
+
}
|
|
127
|
+
if (this._writableState) {
|
|
128
|
+
this._writableState.destroyed = true;
|
|
129
|
+
}
|
|
130
|
+
this._destroy(err || null, function(err2) {
|
|
131
|
+
if (!cb && err2) {
|
|
132
|
+
if (!_this._writableState) {
|
|
133
|
+
pna.nextTick(emitErrorNT, _this, err2);
|
|
134
|
+
} else if (!_this._writableState.errorEmitted) {
|
|
135
|
+
_this._writableState.errorEmitted = true;
|
|
136
|
+
pna.nextTick(emitErrorNT, _this, err2);
|
|
137
|
+
}
|
|
138
|
+
} else if (cb) {
|
|
139
|
+
cb(err2);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
function undestroy() {
|
|
145
|
+
if (this._readableState) {
|
|
146
|
+
this._readableState.destroyed = false;
|
|
147
|
+
this._readableState.reading = false;
|
|
148
|
+
this._readableState.ended = false;
|
|
149
|
+
this._readableState.endEmitted = false;
|
|
150
|
+
}
|
|
151
|
+
if (this._writableState) {
|
|
152
|
+
this._writableState.destroyed = false;
|
|
153
|
+
this._writableState.ended = false;
|
|
154
|
+
this._writableState.ending = false;
|
|
155
|
+
this._writableState.finalCalled = false;
|
|
156
|
+
this._writableState.prefinished = false;
|
|
157
|
+
this._writableState.finished = false;
|
|
158
|
+
this._writableState.errorEmitted = false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function emitErrorNT(self2, err) {
|
|
162
|
+
self2.emit("error", err);
|
|
163
|
+
}
|
|
164
|
+
destroy_1 = {
|
|
165
|
+
destroy,
|
|
166
|
+
undestroy
|
|
167
|
+
};
|
|
168
|
+
return destroy_1;
|
|
169
|
+
}
|
|
170
|
+
var _stream_writable;
|
|
171
|
+
var hasRequired_stream_writable;
|
|
172
|
+
function require_stream_writable() {
|
|
173
|
+
if (hasRequired_stream_writable) return _stream_writable;
|
|
174
|
+
hasRequired_stream_writable = 1;
|
|
175
|
+
var pna = requireProcessNextickArgs();
|
|
176
|
+
_stream_writable = Writable;
|
|
177
|
+
function CorkedRequest(state) {
|
|
178
|
+
var _this = this;
|
|
179
|
+
this.next = null;
|
|
180
|
+
this.entry = null;
|
|
181
|
+
this.finish = function() {
|
|
182
|
+
onCorkedFinish(_this, state);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
var asyncWrite = !process.browser && ["v0.10", "v0.9."].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
|
186
|
+
var Duplex;
|
|
187
|
+
Writable.WritableState = WritableState;
|
|
188
|
+
var util = Object.create(requireUtil());
|
|
189
|
+
util.inherits = requireInherits();
|
|
190
|
+
var internalUtil = {
|
|
191
|
+
deprecate: requireNode()
|
|
192
|
+
};
|
|
193
|
+
var Stream = requireStream();
|
|
194
|
+
var Buffer = requireSafeBuffer().Buffer;
|
|
195
|
+
var OurUint8Array = (typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
|
|
196
|
+
};
|
|
197
|
+
function _uint8ArrayToBuffer(chunk) {
|
|
198
|
+
return Buffer.from(chunk);
|
|
199
|
+
}
|
|
200
|
+
function _isUint8Array(obj) {
|
|
201
|
+
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
202
|
+
}
|
|
203
|
+
var destroyImpl = requireDestroy();
|
|
204
|
+
util.inherits(Writable, Stream);
|
|
205
|
+
function nop() {
|
|
206
|
+
}
|
|
207
|
+
function WritableState(options, stream2) {
|
|
208
|
+
Duplex = Duplex || require_stream_duplex();
|
|
209
|
+
options = options || {};
|
|
210
|
+
var isDuplex = stream2 instanceof Duplex;
|
|
211
|
+
this.objectMode = !!options.objectMode;
|
|
212
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
213
|
+
var hwm = options.highWaterMark;
|
|
214
|
+
var writableHwm = options.writableHighWaterMark;
|
|
215
|
+
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
216
|
+
if (hwm || hwm === 0) this.highWaterMark = hwm;
|
|
217
|
+
else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;
|
|
218
|
+
else this.highWaterMark = defaultHwm;
|
|
219
|
+
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
220
|
+
this.finalCalled = false;
|
|
221
|
+
this.needDrain = false;
|
|
222
|
+
this.ending = false;
|
|
223
|
+
this.ended = false;
|
|
224
|
+
this.finished = false;
|
|
225
|
+
this.destroyed = false;
|
|
226
|
+
var noDecode = options.decodeStrings === false;
|
|
227
|
+
this.decodeStrings = !noDecode;
|
|
228
|
+
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
229
|
+
this.length = 0;
|
|
230
|
+
this.writing = false;
|
|
231
|
+
this.corked = 0;
|
|
232
|
+
this.sync = true;
|
|
233
|
+
this.bufferProcessing = false;
|
|
234
|
+
this.onwrite = function(er) {
|
|
235
|
+
onwrite(stream2, er);
|
|
236
|
+
};
|
|
237
|
+
this.writecb = null;
|
|
238
|
+
this.writelen = 0;
|
|
239
|
+
this.bufferedRequest = null;
|
|
240
|
+
this.lastBufferedRequest = null;
|
|
241
|
+
this.pendingcb = 0;
|
|
242
|
+
this.prefinished = false;
|
|
243
|
+
this.errorEmitted = false;
|
|
244
|
+
this.bufferedRequestCount = 0;
|
|
245
|
+
this.corkedRequestsFree = new CorkedRequest(this);
|
|
246
|
+
}
|
|
247
|
+
WritableState.prototype.getBuffer = function getBuffer() {
|
|
248
|
+
var current = this.bufferedRequest;
|
|
249
|
+
var out = [];
|
|
250
|
+
while (current) {
|
|
251
|
+
out.push(current);
|
|
252
|
+
current = current.next;
|
|
253
|
+
}
|
|
254
|
+
return out;
|
|
255
|
+
};
|
|
256
|
+
(function() {
|
|
257
|
+
try {
|
|
258
|
+
Object.defineProperty(WritableState.prototype, "buffer", {
|
|
259
|
+
get: internalUtil.deprecate(function() {
|
|
260
|
+
return this.getBuffer();
|
|
261
|
+
}, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003")
|
|
262
|
+
});
|
|
263
|
+
} catch (_) {
|
|
264
|
+
}
|
|
265
|
+
})();
|
|
266
|
+
var realHasInstance;
|
|
267
|
+
if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") {
|
|
268
|
+
realHasInstance = Function.prototype[Symbol.hasInstance];
|
|
269
|
+
Object.defineProperty(Writable, Symbol.hasInstance, {
|
|
270
|
+
value: function(object) {
|
|
271
|
+
if (realHasInstance.call(this, object)) return true;
|
|
272
|
+
if (this !== Writable) return false;
|
|
273
|
+
return object && object._writableState instanceof WritableState;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
} else {
|
|
277
|
+
realHasInstance = function(object) {
|
|
278
|
+
return object instanceof this;
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function Writable(options) {
|
|
282
|
+
Duplex = Duplex || require_stream_duplex();
|
|
283
|
+
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
|
284
|
+
return new Writable(options);
|
|
285
|
+
}
|
|
286
|
+
this._writableState = new WritableState(options, this);
|
|
287
|
+
this.writable = true;
|
|
288
|
+
if (options) {
|
|
289
|
+
if (typeof options.write === "function") this._write = options.write;
|
|
290
|
+
if (typeof options.writev === "function") this._writev = options.writev;
|
|
291
|
+
if (typeof options.destroy === "function") this._destroy = options.destroy;
|
|
292
|
+
if (typeof options.final === "function") this._final = options.final;
|
|
293
|
+
}
|
|
294
|
+
Stream.call(this);
|
|
295
|
+
}
|
|
296
|
+
Writable.prototype.pipe = function() {
|
|
297
|
+
this.emit("error", new Error("Cannot pipe, not readable"));
|
|
298
|
+
};
|
|
299
|
+
function writeAfterEnd(stream2, cb) {
|
|
300
|
+
var er = new Error("write after end");
|
|
301
|
+
stream2.emit("error", er);
|
|
302
|
+
pna.nextTick(cb, er);
|
|
303
|
+
}
|
|
304
|
+
function validChunk(stream2, state, chunk, cb) {
|
|
305
|
+
var valid = true;
|
|
306
|
+
var er = false;
|
|
307
|
+
if (chunk === null) {
|
|
308
|
+
er = new TypeError("May not write null values to stream");
|
|
309
|
+
} else if (typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) {
|
|
310
|
+
er = new TypeError("Invalid non-string/buffer chunk");
|
|
311
|
+
}
|
|
312
|
+
if (er) {
|
|
313
|
+
stream2.emit("error", er);
|
|
314
|
+
pna.nextTick(cb, er);
|
|
315
|
+
valid = false;
|
|
316
|
+
}
|
|
317
|
+
return valid;
|
|
318
|
+
}
|
|
319
|
+
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
320
|
+
var state = this._writableState;
|
|
321
|
+
var ret = false;
|
|
322
|
+
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
|
323
|
+
if (isBuf && !Buffer.isBuffer(chunk)) {
|
|
324
|
+
chunk = _uint8ArrayToBuffer(chunk);
|
|
325
|
+
}
|
|
326
|
+
if (typeof encoding === "function") {
|
|
327
|
+
cb = encoding;
|
|
328
|
+
encoding = null;
|
|
329
|
+
}
|
|
330
|
+
if (isBuf) encoding = "buffer";
|
|
331
|
+
else if (!encoding) encoding = state.defaultEncoding;
|
|
332
|
+
if (typeof cb !== "function") cb = nop;
|
|
333
|
+
if (state.ended) writeAfterEnd(this, cb);
|
|
334
|
+
else if (isBuf || validChunk(this, state, chunk, cb)) {
|
|
335
|
+
state.pendingcb++;
|
|
336
|
+
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
|
337
|
+
}
|
|
338
|
+
return ret;
|
|
339
|
+
};
|
|
340
|
+
Writable.prototype.cork = function() {
|
|
341
|
+
var state = this._writableState;
|
|
342
|
+
state.corked++;
|
|
343
|
+
};
|
|
344
|
+
Writable.prototype.uncork = function() {
|
|
345
|
+
var state = this._writableState;
|
|
346
|
+
if (state.corked) {
|
|
347
|
+
state.corked--;
|
|
348
|
+
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
352
|
+
if (typeof encoding === "string") encoding = encoding.toLowerCase();
|
|
353
|
+
if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1)) throw new TypeError("Unknown encoding: " + encoding);
|
|
354
|
+
this._writableState.defaultEncoding = encoding;
|
|
355
|
+
return this;
|
|
356
|
+
};
|
|
357
|
+
function decodeChunk(state, chunk, encoding) {
|
|
358
|
+
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") {
|
|
359
|
+
chunk = Buffer.from(chunk, encoding);
|
|
360
|
+
}
|
|
361
|
+
return chunk;
|
|
362
|
+
}
|
|
363
|
+
Object.defineProperty(Writable.prototype, "writableHighWaterMark", {
|
|
364
|
+
// making it explicit this property is not enumerable
|
|
365
|
+
// because otherwise some prototype manipulation in
|
|
366
|
+
// userland will fail
|
|
367
|
+
enumerable: false,
|
|
368
|
+
get: function() {
|
|
369
|
+
return this._writableState.highWaterMark;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
function writeOrBuffer(stream2, state, isBuf, chunk, encoding, cb) {
|
|
373
|
+
if (!isBuf) {
|
|
374
|
+
var newChunk = decodeChunk(state, chunk, encoding);
|
|
375
|
+
if (chunk !== newChunk) {
|
|
376
|
+
isBuf = true;
|
|
377
|
+
encoding = "buffer";
|
|
378
|
+
chunk = newChunk;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
382
|
+
state.length += len;
|
|
383
|
+
var ret = state.length < state.highWaterMark;
|
|
384
|
+
if (!ret) state.needDrain = true;
|
|
385
|
+
if (state.writing || state.corked) {
|
|
386
|
+
var last = state.lastBufferedRequest;
|
|
387
|
+
state.lastBufferedRequest = {
|
|
388
|
+
chunk,
|
|
389
|
+
encoding,
|
|
390
|
+
isBuf,
|
|
391
|
+
callback: cb,
|
|
392
|
+
next: null
|
|
393
|
+
};
|
|
394
|
+
if (last) {
|
|
395
|
+
last.next = state.lastBufferedRequest;
|
|
396
|
+
} else {
|
|
397
|
+
state.bufferedRequest = state.lastBufferedRequest;
|
|
398
|
+
}
|
|
399
|
+
state.bufferedRequestCount += 1;
|
|
400
|
+
} else {
|
|
401
|
+
doWrite(stream2, state, false, len, chunk, encoding, cb);
|
|
402
|
+
}
|
|
403
|
+
return ret;
|
|
404
|
+
}
|
|
405
|
+
function doWrite(stream2, state, writev, len, chunk, encoding, cb) {
|
|
406
|
+
state.writelen = len;
|
|
407
|
+
state.writecb = cb;
|
|
408
|
+
state.writing = true;
|
|
409
|
+
state.sync = true;
|
|
410
|
+
if (writev) stream2._writev(chunk, state.onwrite);
|
|
411
|
+
else stream2._write(chunk, encoding, state.onwrite);
|
|
412
|
+
state.sync = false;
|
|
413
|
+
}
|
|
414
|
+
function onwriteError(stream2, state, sync, er, cb) {
|
|
415
|
+
--state.pendingcb;
|
|
416
|
+
if (sync) {
|
|
417
|
+
pna.nextTick(cb, er);
|
|
418
|
+
pna.nextTick(finishMaybe, stream2, state);
|
|
419
|
+
stream2._writableState.errorEmitted = true;
|
|
420
|
+
stream2.emit("error", er);
|
|
421
|
+
} else {
|
|
422
|
+
cb(er);
|
|
423
|
+
stream2._writableState.errorEmitted = true;
|
|
424
|
+
stream2.emit("error", er);
|
|
425
|
+
finishMaybe(stream2, state);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
function onwriteStateUpdate(state) {
|
|
429
|
+
state.writing = false;
|
|
430
|
+
state.writecb = null;
|
|
431
|
+
state.length -= state.writelen;
|
|
432
|
+
state.writelen = 0;
|
|
433
|
+
}
|
|
434
|
+
function onwrite(stream2, er) {
|
|
435
|
+
var state = stream2._writableState;
|
|
436
|
+
var sync = state.sync;
|
|
437
|
+
var cb = state.writecb;
|
|
438
|
+
onwriteStateUpdate(state);
|
|
439
|
+
if (er) onwriteError(stream2, state, sync, er, cb);
|
|
440
|
+
else {
|
|
441
|
+
var finished = needFinish(state);
|
|
442
|
+
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
|
443
|
+
clearBuffer(stream2, state);
|
|
444
|
+
}
|
|
445
|
+
if (sync) {
|
|
446
|
+
asyncWrite(afterWrite, stream2, state, finished, cb);
|
|
447
|
+
} else {
|
|
448
|
+
afterWrite(stream2, state, finished, cb);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function afterWrite(stream2, state, finished, cb) {
|
|
453
|
+
if (!finished) onwriteDrain(stream2, state);
|
|
454
|
+
state.pendingcb--;
|
|
455
|
+
cb();
|
|
456
|
+
finishMaybe(stream2, state);
|
|
457
|
+
}
|
|
458
|
+
function onwriteDrain(stream2, state) {
|
|
459
|
+
if (state.length === 0 && state.needDrain) {
|
|
460
|
+
state.needDrain = false;
|
|
461
|
+
stream2.emit("drain");
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function clearBuffer(stream2, state) {
|
|
465
|
+
state.bufferProcessing = true;
|
|
466
|
+
var entry = state.bufferedRequest;
|
|
467
|
+
if (stream2._writev && entry && entry.next) {
|
|
468
|
+
var l = state.bufferedRequestCount;
|
|
469
|
+
var buffer = new Array(l);
|
|
470
|
+
var holder = state.corkedRequestsFree;
|
|
471
|
+
holder.entry = entry;
|
|
472
|
+
var count = 0;
|
|
473
|
+
var allBuffers = true;
|
|
474
|
+
while (entry) {
|
|
475
|
+
buffer[count] = entry;
|
|
476
|
+
if (!entry.isBuf) allBuffers = false;
|
|
477
|
+
entry = entry.next;
|
|
478
|
+
count += 1;
|
|
479
|
+
}
|
|
480
|
+
buffer.allBuffers = allBuffers;
|
|
481
|
+
doWrite(stream2, state, true, state.length, buffer, "", holder.finish);
|
|
482
|
+
state.pendingcb++;
|
|
483
|
+
state.lastBufferedRequest = null;
|
|
484
|
+
if (holder.next) {
|
|
485
|
+
state.corkedRequestsFree = holder.next;
|
|
486
|
+
holder.next = null;
|
|
487
|
+
} else {
|
|
488
|
+
state.corkedRequestsFree = new CorkedRequest(state);
|
|
489
|
+
}
|
|
490
|
+
state.bufferedRequestCount = 0;
|
|
491
|
+
} else {
|
|
492
|
+
while (entry) {
|
|
493
|
+
var chunk = entry.chunk;
|
|
494
|
+
var encoding = entry.encoding;
|
|
495
|
+
var cb = entry.callback;
|
|
496
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
497
|
+
doWrite(stream2, state, false, len, chunk, encoding, cb);
|
|
498
|
+
entry = entry.next;
|
|
499
|
+
state.bufferedRequestCount--;
|
|
500
|
+
if (state.writing) {
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (entry === null) state.lastBufferedRequest = null;
|
|
505
|
+
}
|
|
506
|
+
state.bufferedRequest = entry;
|
|
507
|
+
state.bufferProcessing = false;
|
|
508
|
+
}
|
|
509
|
+
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
510
|
+
cb(new Error("_write() is not implemented"));
|
|
511
|
+
};
|
|
512
|
+
Writable.prototype._writev = null;
|
|
513
|
+
Writable.prototype.end = function(chunk, encoding, cb) {
|
|
514
|
+
var state = this._writableState;
|
|
515
|
+
if (typeof chunk === "function") {
|
|
516
|
+
cb = chunk;
|
|
517
|
+
chunk = null;
|
|
518
|
+
encoding = null;
|
|
519
|
+
} else if (typeof encoding === "function") {
|
|
520
|
+
cb = encoding;
|
|
521
|
+
encoding = null;
|
|
522
|
+
}
|
|
523
|
+
if (chunk !== null && chunk !== void 0) this.write(chunk, encoding);
|
|
524
|
+
if (state.corked) {
|
|
525
|
+
state.corked = 1;
|
|
526
|
+
this.uncork();
|
|
527
|
+
}
|
|
528
|
+
if (!state.ending) endWritable(this, state, cb);
|
|
529
|
+
};
|
|
530
|
+
function needFinish(state) {
|
|
531
|
+
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
532
|
+
}
|
|
533
|
+
function callFinal(stream2, state) {
|
|
534
|
+
stream2._final(function(err) {
|
|
535
|
+
state.pendingcb--;
|
|
536
|
+
if (err) {
|
|
537
|
+
stream2.emit("error", err);
|
|
538
|
+
}
|
|
539
|
+
state.prefinished = true;
|
|
540
|
+
stream2.emit("prefinish");
|
|
541
|
+
finishMaybe(stream2, state);
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function prefinish(stream2, state) {
|
|
545
|
+
if (!state.prefinished && !state.finalCalled) {
|
|
546
|
+
if (typeof stream2._final === "function") {
|
|
547
|
+
state.pendingcb++;
|
|
548
|
+
state.finalCalled = true;
|
|
549
|
+
pna.nextTick(callFinal, stream2, state);
|
|
550
|
+
} else {
|
|
551
|
+
state.prefinished = true;
|
|
552
|
+
stream2.emit("prefinish");
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function finishMaybe(stream2, state) {
|
|
557
|
+
var need = needFinish(state);
|
|
558
|
+
if (need) {
|
|
559
|
+
prefinish(stream2, state);
|
|
560
|
+
if (state.pendingcb === 0) {
|
|
561
|
+
state.finished = true;
|
|
562
|
+
stream2.emit("finish");
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return need;
|
|
566
|
+
}
|
|
567
|
+
function endWritable(stream2, state, cb) {
|
|
568
|
+
state.ending = true;
|
|
569
|
+
finishMaybe(stream2, state);
|
|
570
|
+
if (cb) {
|
|
571
|
+
if (state.finished) pna.nextTick(cb);
|
|
572
|
+
else stream2.once("finish", cb);
|
|
573
|
+
}
|
|
574
|
+
state.ended = true;
|
|
575
|
+
stream2.writable = false;
|
|
576
|
+
}
|
|
577
|
+
function onCorkedFinish(corkReq, state, err) {
|
|
578
|
+
var entry = corkReq.entry;
|
|
579
|
+
corkReq.entry = null;
|
|
580
|
+
while (entry) {
|
|
581
|
+
var cb = entry.callback;
|
|
582
|
+
state.pendingcb--;
|
|
583
|
+
cb(err);
|
|
584
|
+
entry = entry.next;
|
|
585
|
+
}
|
|
586
|
+
state.corkedRequestsFree.next = corkReq;
|
|
587
|
+
}
|
|
588
|
+
Object.defineProperty(Writable.prototype, "destroyed", {
|
|
589
|
+
get: function() {
|
|
590
|
+
if (this._writableState === void 0) {
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
return this._writableState.destroyed;
|
|
594
|
+
},
|
|
595
|
+
set: function(value) {
|
|
596
|
+
if (!this._writableState) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
this._writableState.destroyed = value;
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
Writable.prototype.destroy = destroyImpl.destroy;
|
|
603
|
+
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
604
|
+
Writable.prototype._destroy = function(err, cb) {
|
|
605
|
+
this.end();
|
|
606
|
+
cb(err);
|
|
607
|
+
};
|
|
608
|
+
return _stream_writable;
|
|
609
|
+
}
|
|
610
|
+
var _stream_duplex;
|
|
611
|
+
var hasRequired_stream_duplex;
|
|
612
|
+
function require_stream_duplex() {
|
|
613
|
+
if (hasRequired_stream_duplex) return _stream_duplex;
|
|
614
|
+
hasRequired_stream_duplex = 1;
|
|
615
|
+
var pna = requireProcessNextickArgs();
|
|
616
|
+
var objectKeys = Object.keys || function(obj) {
|
|
617
|
+
var keys2 = [];
|
|
618
|
+
for (var key in obj) {
|
|
619
|
+
keys2.push(key);
|
|
620
|
+
}
|
|
621
|
+
return keys2;
|
|
622
|
+
};
|
|
623
|
+
_stream_duplex = Duplex;
|
|
624
|
+
var util = Object.create(requireUtil());
|
|
625
|
+
util.inherits = requireInherits();
|
|
626
|
+
var Readable = require_stream_readable();
|
|
627
|
+
var Writable = require_stream_writable();
|
|
628
|
+
util.inherits(Duplex, Readable);
|
|
629
|
+
{
|
|
630
|
+
var keys = objectKeys(Writable.prototype);
|
|
631
|
+
for (var v = 0; v < keys.length; v++) {
|
|
632
|
+
var method = keys[v];
|
|
633
|
+
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function Duplex(options) {
|
|
637
|
+
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
638
|
+
Readable.call(this, options);
|
|
639
|
+
Writable.call(this, options);
|
|
640
|
+
if (options && options.readable === false) this.readable = false;
|
|
641
|
+
if (options && options.writable === false) this.writable = false;
|
|
642
|
+
this.allowHalfOpen = true;
|
|
643
|
+
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
|
644
|
+
this.once("end", onend);
|
|
645
|
+
}
|
|
646
|
+
Object.defineProperty(Duplex.prototype, "writableHighWaterMark", {
|
|
647
|
+
// making it explicit this property is not enumerable
|
|
648
|
+
// because otherwise some prototype manipulation in
|
|
649
|
+
// userland will fail
|
|
650
|
+
enumerable: false,
|
|
651
|
+
get: function() {
|
|
652
|
+
return this._writableState.highWaterMark;
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
function onend() {
|
|
656
|
+
if (this.allowHalfOpen || this._writableState.ended) return;
|
|
657
|
+
pna.nextTick(onEndNT, this);
|
|
658
|
+
}
|
|
659
|
+
function onEndNT(self2) {
|
|
660
|
+
self2.end();
|
|
661
|
+
}
|
|
662
|
+
Object.defineProperty(Duplex.prototype, "destroyed", {
|
|
663
|
+
get: function() {
|
|
664
|
+
if (this._readableState === void 0 || this._writableState === void 0) {
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
return this._readableState.destroyed && this._writableState.destroyed;
|
|
668
|
+
},
|
|
669
|
+
set: function(value) {
|
|
670
|
+
if (this._readableState === void 0 || this._writableState === void 0) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
this._readableState.destroyed = value;
|
|
674
|
+
this._writableState.destroyed = value;
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
Duplex.prototype._destroy = function(err, cb) {
|
|
678
|
+
this.push(null);
|
|
679
|
+
this.end();
|
|
680
|
+
pna.nextTick(cb, err);
|
|
681
|
+
};
|
|
682
|
+
return _stream_duplex;
|
|
683
|
+
}
|
|
684
|
+
var _stream_readable;
|
|
685
|
+
var hasRequired_stream_readable;
|
|
686
|
+
function require_stream_readable() {
|
|
687
|
+
if (hasRequired_stream_readable) return _stream_readable;
|
|
688
|
+
hasRequired_stream_readable = 1;
|
|
689
|
+
var pna = requireProcessNextickArgs();
|
|
690
|
+
_stream_readable = Readable;
|
|
691
|
+
var isArray = requireIsarray();
|
|
692
|
+
var Duplex;
|
|
693
|
+
Readable.ReadableState = ReadableState;
|
|
694
|
+
require$$2.EventEmitter;
|
|
695
|
+
var EElistenerCount = function(emitter, type) {
|
|
696
|
+
return emitter.listeners(type).length;
|
|
697
|
+
};
|
|
698
|
+
var Stream = requireStream();
|
|
699
|
+
var Buffer = requireSafeBuffer().Buffer;
|
|
700
|
+
var OurUint8Array = (typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
|
|
701
|
+
};
|
|
702
|
+
function _uint8ArrayToBuffer(chunk) {
|
|
703
|
+
return Buffer.from(chunk);
|
|
704
|
+
}
|
|
705
|
+
function _isUint8Array(obj) {
|
|
706
|
+
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
707
|
+
}
|
|
708
|
+
var util = Object.create(requireUtil());
|
|
709
|
+
util.inherits = requireInherits();
|
|
710
|
+
var debugUtil = require$$0$1;
|
|
711
|
+
var debug = void 0;
|
|
712
|
+
if (debugUtil && debugUtil.debuglog) {
|
|
713
|
+
debug = debugUtil.debuglog("stream");
|
|
714
|
+
} else {
|
|
715
|
+
debug = function() {
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
var BufferList2 = requireBufferList();
|
|
719
|
+
var destroyImpl = requireDestroy();
|
|
720
|
+
var StringDecoder;
|
|
721
|
+
util.inherits(Readable, Stream);
|
|
722
|
+
var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
|
|
723
|
+
function prependListener(emitter, event, fn) {
|
|
724
|
+
if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
|
|
725
|
+
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
|
|
726
|
+
else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);
|
|
727
|
+
else emitter._events[event] = [fn, emitter._events[event]];
|
|
728
|
+
}
|
|
729
|
+
function ReadableState(options, stream2) {
|
|
730
|
+
Duplex = Duplex || require_stream_duplex();
|
|
731
|
+
options = options || {};
|
|
732
|
+
var isDuplex = stream2 instanceof Duplex;
|
|
733
|
+
this.objectMode = !!options.objectMode;
|
|
734
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
735
|
+
var hwm = options.highWaterMark;
|
|
736
|
+
var readableHwm = options.readableHighWaterMark;
|
|
737
|
+
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
738
|
+
if (hwm || hwm === 0) this.highWaterMark = hwm;
|
|
739
|
+
else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;
|
|
740
|
+
else this.highWaterMark = defaultHwm;
|
|
741
|
+
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
742
|
+
this.buffer = new BufferList2();
|
|
743
|
+
this.length = 0;
|
|
744
|
+
this.pipes = null;
|
|
745
|
+
this.pipesCount = 0;
|
|
746
|
+
this.flowing = null;
|
|
747
|
+
this.ended = false;
|
|
748
|
+
this.endEmitted = false;
|
|
749
|
+
this.reading = false;
|
|
750
|
+
this.sync = true;
|
|
751
|
+
this.needReadable = false;
|
|
752
|
+
this.emittedReadable = false;
|
|
753
|
+
this.readableListening = false;
|
|
754
|
+
this.resumeScheduled = false;
|
|
755
|
+
this.destroyed = false;
|
|
756
|
+
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
757
|
+
this.awaitDrain = 0;
|
|
758
|
+
this.readingMore = false;
|
|
759
|
+
this.decoder = null;
|
|
760
|
+
this.encoding = null;
|
|
761
|
+
if (options.encoding) {
|
|
762
|
+
if (!StringDecoder) StringDecoder = require$$11.StringDecoder;
|
|
763
|
+
this.decoder = new StringDecoder(options.encoding);
|
|
764
|
+
this.encoding = options.encoding;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function Readable(options) {
|
|
768
|
+
Duplex = Duplex || require_stream_duplex();
|
|
769
|
+
if (!(this instanceof Readable)) return new Readable(options);
|
|
770
|
+
this._readableState = new ReadableState(options, this);
|
|
771
|
+
this.readable = true;
|
|
772
|
+
if (options) {
|
|
773
|
+
if (typeof options.read === "function") this._read = options.read;
|
|
774
|
+
if (typeof options.destroy === "function") this._destroy = options.destroy;
|
|
775
|
+
}
|
|
776
|
+
Stream.call(this);
|
|
777
|
+
}
|
|
778
|
+
Object.defineProperty(Readable.prototype, "destroyed", {
|
|
779
|
+
get: function() {
|
|
780
|
+
if (this._readableState === void 0) {
|
|
781
|
+
return false;
|
|
782
|
+
}
|
|
783
|
+
return this._readableState.destroyed;
|
|
784
|
+
},
|
|
785
|
+
set: function(value) {
|
|
786
|
+
if (!this._readableState) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
this._readableState.destroyed = value;
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
Readable.prototype.destroy = destroyImpl.destroy;
|
|
793
|
+
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
794
|
+
Readable.prototype._destroy = function(err, cb) {
|
|
795
|
+
this.push(null);
|
|
796
|
+
cb(err);
|
|
797
|
+
};
|
|
798
|
+
Readable.prototype.push = function(chunk, encoding) {
|
|
799
|
+
var state = this._readableState;
|
|
800
|
+
var skipChunkCheck;
|
|
801
|
+
if (!state.objectMode) {
|
|
802
|
+
if (typeof chunk === "string") {
|
|
803
|
+
encoding = encoding || state.defaultEncoding;
|
|
804
|
+
if (encoding !== state.encoding) {
|
|
805
|
+
chunk = Buffer.from(chunk, encoding);
|
|
806
|
+
encoding = "";
|
|
807
|
+
}
|
|
808
|
+
skipChunkCheck = true;
|
|
809
|
+
}
|
|
810
|
+
} else {
|
|
811
|
+
skipChunkCheck = true;
|
|
812
|
+
}
|
|
813
|
+
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
814
|
+
};
|
|
815
|
+
Readable.prototype.unshift = function(chunk) {
|
|
816
|
+
return readableAddChunk(this, chunk, null, true, false);
|
|
817
|
+
};
|
|
818
|
+
function readableAddChunk(stream2, chunk, encoding, addToFront, skipChunkCheck) {
|
|
819
|
+
var state = stream2._readableState;
|
|
820
|
+
if (chunk === null) {
|
|
821
|
+
state.reading = false;
|
|
822
|
+
onEofChunk(stream2, state);
|
|
823
|
+
} else {
|
|
824
|
+
var er;
|
|
825
|
+
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
|
826
|
+
if (er) {
|
|
827
|
+
stream2.emit("error", er);
|
|
828
|
+
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
829
|
+
if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
|
|
830
|
+
chunk = _uint8ArrayToBuffer(chunk);
|
|
831
|
+
}
|
|
832
|
+
if (addToFront) {
|
|
833
|
+
if (state.endEmitted) stream2.emit("error", new Error("stream.unshift() after end event"));
|
|
834
|
+
else addChunk(stream2, state, chunk, true);
|
|
835
|
+
} else if (state.ended) {
|
|
836
|
+
stream2.emit("error", new Error("stream.push() after EOF"));
|
|
837
|
+
} else {
|
|
838
|
+
state.reading = false;
|
|
839
|
+
if (state.decoder && !encoding) {
|
|
840
|
+
chunk = state.decoder.write(chunk);
|
|
841
|
+
if (state.objectMode || chunk.length !== 0) addChunk(stream2, state, chunk, false);
|
|
842
|
+
else maybeReadMore(stream2, state);
|
|
843
|
+
} else {
|
|
844
|
+
addChunk(stream2, state, chunk, false);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
} else if (!addToFront) {
|
|
848
|
+
state.reading = false;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
return needMoreData(state);
|
|
852
|
+
}
|
|
853
|
+
function addChunk(stream2, state, chunk, addToFront) {
|
|
854
|
+
if (state.flowing && state.length === 0 && !state.sync) {
|
|
855
|
+
stream2.emit("data", chunk);
|
|
856
|
+
stream2.read(0);
|
|
857
|
+
} else {
|
|
858
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
859
|
+
if (addToFront) state.buffer.unshift(chunk);
|
|
860
|
+
else state.buffer.push(chunk);
|
|
861
|
+
if (state.needReadable) emitReadable(stream2);
|
|
862
|
+
}
|
|
863
|
+
maybeReadMore(stream2, state);
|
|
864
|
+
}
|
|
865
|
+
function chunkInvalid(state, chunk) {
|
|
866
|
+
var er;
|
|
867
|
+
if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) {
|
|
868
|
+
er = new TypeError("Invalid non-string/buffer chunk");
|
|
869
|
+
}
|
|
870
|
+
return er;
|
|
871
|
+
}
|
|
872
|
+
function needMoreData(state) {
|
|
873
|
+
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
|
874
|
+
}
|
|
875
|
+
Readable.prototype.isPaused = function() {
|
|
876
|
+
return this._readableState.flowing === false;
|
|
877
|
+
};
|
|
878
|
+
Readable.prototype.setEncoding = function(enc) {
|
|
879
|
+
if (!StringDecoder) StringDecoder = require$$11.StringDecoder;
|
|
880
|
+
this._readableState.decoder = new StringDecoder(enc);
|
|
881
|
+
this._readableState.encoding = enc;
|
|
882
|
+
return this;
|
|
883
|
+
};
|
|
884
|
+
var MAX_HWM = 8388608;
|
|
885
|
+
function computeNewHighWaterMark(n) {
|
|
886
|
+
if (n >= MAX_HWM) {
|
|
887
|
+
n = MAX_HWM;
|
|
888
|
+
} else {
|
|
889
|
+
n--;
|
|
890
|
+
n |= n >>> 1;
|
|
891
|
+
n |= n >>> 2;
|
|
892
|
+
n |= n >>> 4;
|
|
893
|
+
n |= n >>> 8;
|
|
894
|
+
n |= n >>> 16;
|
|
895
|
+
n++;
|
|
896
|
+
}
|
|
897
|
+
return n;
|
|
898
|
+
}
|
|
899
|
+
function howMuchToRead(n, state) {
|
|
900
|
+
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
901
|
+
if (state.objectMode) return 1;
|
|
902
|
+
if (n !== n) {
|
|
903
|
+
if (state.flowing && state.length) return state.buffer.head.data.length;
|
|
904
|
+
else return state.length;
|
|
905
|
+
}
|
|
906
|
+
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
907
|
+
if (n <= state.length) return n;
|
|
908
|
+
if (!state.ended) {
|
|
909
|
+
state.needReadable = true;
|
|
910
|
+
return 0;
|
|
911
|
+
}
|
|
912
|
+
return state.length;
|
|
913
|
+
}
|
|
914
|
+
Readable.prototype.read = function(n) {
|
|
915
|
+
debug("read", n);
|
|
916
|
+
n = parseInt(n, 10);
|
|
917
|
+
var state = this._readableState;
|
|
918
|
+
var nOrig = n;
|
|
919
|
+
if (n !== 0) state.emittedReadable = false;
|
|
920
|
+
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
|
921
|
+
debug("read: emitReadable", state.length, state.ended);
|
|
922
|
+
if (state.length === 0 && state.ended) endReadable(this);
|
|
923
|
+
else emitReadable(this);
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
n = howMuchToRead(n, state);
|
|
927
|
+
if (n === 0 && state.ended) {
|
|
928
|
+
if (state.length === 0) endReadable(this);
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
931
|
+
var doRead = state.needReadable;
|
|
932
|
+
debug("need readable", doRead);
|
|
933
|
+
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
934
|
+
doRead = true;
|
|
935
|
+
debug("length less than watermark", doRead);
|
|
936
|
+
}
|
|
937
|
+
if (state.ended || state.reading) {
|
|
938
|
+
doRead = false;
|
|
939
|
+
debug("reading or ended", doRead);
|
|
940
|
+
} else if (doRead) {
|
|
941
|
+
debug("do read");
|
|
942
|
+
state.reading = true;
|
|
943
|
+
state.sync = true;
|
|
944
|
+
if (state.length === 0) state.needReadable = true;
|
|
945
|
+
this._read(state.highWaterMark);
|
|
946
|
+
state.sync = false;
|
|
947
|
+
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
948
|
+
}
|
|
949
|
+
var ret;
|
|
950
|
+
if (n > 0) ret = fromList(n, state);
|
|
951
|
+
else ret = null;
|
|
952
|
+
if (ret === null) {
|
|
953
|
+
state.needReadable = true;
|
|
954
|
+
n = 0;
|
|
955
|
+
} else {
|
|
956
|
+
state.length -= n;
|
|
957
|
+
}
|
|
958
|
+
if (state.length === 0) {
|
|
959
|
+
if (!state.ended) state.needReadable = true;
|
|
960
|
+
if (nOrig !== n && state.ended) endReadable(this);
|
|
961
|
+
}
|
|
962
|
+
if (ret !== null) this.emit("data", ret);
|
|
963
|
+
return ret;
|
|
964
|
+
};
|
|
965
|
+
function onEofChunk(stream2, state) {
|
|
966
|
+
if (state.ended) return;
|
|
967
|
+
if (state.decoder) {
|
|
968
|
+
var chunk = state.decoder.end();
|
|
969
|
+
if (chunk && chunk.length) {
|
|
970
|
+
state.buffer.push(chunk);
|
|
971
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
state.ended = true;
|
|
975
|
+
emitReadable(stream2);
|
|
976
|
+
}
|
|
977
|
+
function emitReadable(stream2) {
|
|
978
|
+
var state = stream2._readableState;
|
|
979
|
+
state.needReadable = false;
|
|
980
|
+
if (!state.emittedReadable) {
|
|
981
|
+
debug("emitReadable", state.flowing);
|
|
982
|
+
state.emittedReadable = true;
|
|
983
|
+
if (state.sync) pna.nextTick(emitReadable_, stream2);
|
|
984
|
+
else emitReadable_(stream2);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
function emitReadable_(stream2) {
|
|
988
|
+
debug("emit readable");
|
|
989
|
+
stream2.emit("readable");
|
|
990
|
+
flow(stream2);
|
|
991
|
+
}
|
|
992
|
+
function maybeReadMore(stream2, state) {
|
|
993
|
+
if (!state.readingMore) {
|
|
994
|
+
state.readingMore = true;
|
|
995
|
+
pna.nextTick(maybeReadMore_, stream2, state);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
function maybeReadMore_(stream2, state) {
|
|
999
|
+
var len = state.length;
|
|
1000
|
+
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
|
1001
|
+
debug("maybeReadMore read 0");
|
|
1002
|
+
stream2.read(0);
|
|
1003
|
+
if (len === state.length)
|
|
1004
|
+
break;
|
|
1005
|
+
else len = state.length;
|
|
1006
|
+
}
|
|
1007
|
+
state.readingMore = false;
|
|
1008
|
+
}
|
|
1009
|
+
Readable.prototype._read = function(n) {
|
|
1010
|
+
this.emit("error", new Error("_read() is not implemented"));
|
|
1011
|
+
};
|
|
1012
|
+
Readable.prototype.pipe = function(dest, pipeOpts) {
|
|
1013
|
+
var src = this;
|
|
1014
|
+
var state = this._readableState;
|
|
1015
|
+
switch (state.pipesCount) {
|
|
1016
|
+
case 0:
|
|
1017
|
+
state.pipes = dest;
|
|
1018
|
+
break;
|
|
1019
|
+
case 1:
|
|
1020
|
+
state.pipes = [state.pipes, dest];
|
|
1021
|
+
break;
|
|
1022
|
+
default:
|
|
1023
|
+
state.pipes.push(dest);
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
state.pipesCount += 1;
|
|
1027
|
+
debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
|
|
1028
|
+
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
1029
|
+
var endFn = doEnd ? onend : unpipe;
|
|
1030
|
+
if (state.endEmitted) pna.nextTick(endFn);
|
|
1031
|
+
else src.once("end", endFn);
|
|
1032
|
+
dest.on("unpipe", onunpipe);
|
|
1033
|
+
function onunpipe(readable2, unpipeInfo) {
|
|
1034
|
+
debug("onunpipe");
|
|
1035
|
+
if (readable2 === src) {
|
|
1036
|
+
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
1037
|
+
unpipeInfo.hasUnpiped = true;
|
|
1038
|
+
cleanup();
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
function onend() {
|
|
1043
|
+
debug("onend");
|
|
1044
|
+
dest.end();
|
|
1045
|
+
}
|
|
1046
|
+
var ondrain = pipeOnDrain(src);
|
|
1047
|
+
dest.on("drain", ondrain);
|
|
1048
|
+
var cleanedUp = false;
|
|
1049
|
+
function cleanup() {
|
|
1050
|
+
debug("cleanup");
|
|
1051
|
+
dest.removeListener("close", onclose);
|
|
1052
|
+
dest.removeListener("finish", onfinish);
|
|
1053
|
+
dest.removeListener("drain", ondrain);
|
|
1054
|
+
dest.removeListener("error", onerror);
|
|
1055
|
+
dest.removeListener("unpipe", onunpipe);
|
|
1056
|
+
src.removeListener("end", onend);
|
|
1057
|
+
src.removeListener("end", unpipe);
|
|
1058
|
+
src.removeListener("data", ondata);
|
|
1059
|
+
cleanedUp = true;
|
|
1060
|
+
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
1061
|
+
}
|
|
1062
|
+
var increasedAwaitDrain = false;
|
|
1063
|
+
src.on("data", ondata);
|
|
1064
|
+
function ondata(chunk) {
|
|
1065
|
+
debug("ondata");
|
|
1066
|
+
increasedAwaitDrain = false;
|
|
1067
|
+
var ret = dest.write(chunk);
|
|
1068
|
+
if (false === ret && !increasedAwaitDrain) {
|
|
1069
|
+
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
1070
|
+
debug("false write response, pause", state.awaitDrain);
|
|
1071
|
+
state.awaitDrain++;
|
|
1072
|
+
increasedAwaitDrain = true;
|
|
1073
|
+
}
|
|
1074
|
+
src.pause();
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
function onerror(er) {
|
|
1078
|
+
debug("onerror", er);
|
|
1079
|
+
unpipe();
|
|
1080
|
+
dest.removeListener("error", onerror);
|
|
1081
|
+
if (EElistenerCount(dest, "error") === 0) dest.emit("error", er);
|
|
1082
|
+
}
|
|
1083
|
+
prependListener(dest, "error", onerror);
|
|
1084
|
+
function onclose() {
|
|
1085
|
+
dest.removeListener("finish", onfinish);
|
|
1086
|
+
unpipe();
|
|
1087
|
+
}
|
|
1088
|
+
dest.once("close", onclose);
|
|
1089
|
+
function onfinish() {
|
|
1090
|
+
debug("onfinish");
|
|
1091
|
+
dest.removeListener("close", onclose);
|
|
1092
|
+
unpipe();
|
|
1093
|
+
}
|
|
1094
|
+
dest.once("finish", onfinish);
|
|
1095
|
+
function unpipe() {
|
|
1096
|
+
debug("unpipe");
|
|
1097
|
+
src.unpipe(dest);
|
|
1098
|
+
}
|
|
1099
|
+
dest.emit("pipe", src);
|
|
1100
|
+
if (!state.flowing) {
|
|
1101
|
+
debug("pipe resume");
|
|
1102
|
+
src.resume();
|
|
1103
|
+
}
|
|
1104
|
+
return dest;
|
|
1105
|
+
};
|
|
1106
|
+
function pipeOnDrain(src) {
|
|
1107
|
+
return function() {
|
|
1108
|
+
var state = src._readableState;
|
|
1109
|
+
debug("pipeOnDrain", state.awaitDrain);
|
|
1110
|
+
if (state.awaitDrain) state.awaitDrain--;
|
|
1111
|
+
if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
|
|
1112
|
+
state.flowing = true;
|
|
1113
|
+
flow(src);
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
Readable.prototype.unpipe = function(dest) {
|
|
1118
|
+
var state = this._readableState;
|
|
1119
|
+
var unpipeInfo = { hasUnpiped: false };
|
|
1120
|
+
if (state.pipesCount === 0) return this;
|
|
1121
|
+
if (state.pipesCount === 1) {
|
|
1122
|
+
if (dest && dest !== state.pipes) return this;
|
|
1123
|
+
if (!dest) dest = state.pipes;
|
|
1124
|
+
state.pipes = null;
|
|
1125
|
+
state.pipesCount = 0;
|
|
1126
|
+
state.flowing = false;
|
|
1127
|
+
if (dest) dest.emit("unpipe", this, unpipeInfo);
|
|
1128
|
+
return this;
|
|
1129
|
+
}
|
|
1130
|
+
if (!dest) {
|
|
1131
|
+
var dests = state.pipes;
|
|
1132
|
+
var len = state.pipesCount;
|
|
1133
|
+
state.pipes = null;
|
|
1134
|
+
state.pipesCount = 0;
|
|
1135
|
+
state.flowing = false;
|
|
1136
|
+
for (var i = 0; i < len; i++) {
|
|
1137
|
+
dests[i].emit("unpipe", this, { hasUnpiped: false });
|
|
1138
|
+
}
|
|
1139
|
+
return this;
|
|
1140
|
+
}
|
|
1141
|
+
var index = indexOf(state.pipes, dest);
|
|
1142
|
+
if (index === -1) return this;
|
|
1143
|
+
state.pipes.splice(index, 1);
|
|
1144
|
+
state.pipesCount -= 1;
|
|
1145
|
+
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
1146
|
+
dest.emit("unpipe", this, unpipeInfo);
|
|
1147
|
+
return this;
|
|
1148
|
+
};
|
|
1149
|
+
Readable.prototype.on = function(ev, fn) {
|
|
1150
|
+
var res = Stream.prototype.on.call(this, ev, fn);
|
|
1151
|
+
if (ev === "data") {
|
|
1152
|
+
if (this._readableState.flowing !== false) this.resume();
|
|
1153
|
+
} else if (ev === "readable") {
|
|
1154
|
+
var state = this._readableState;
|
|
1155
|
+
if (!state.endEmitted && !state.readableListening) {
|
|
1156
|
+
state.readableListening = state.needReadable = true;
|
|
1157
|
+
state.emittedReadable = false;
|
|
1158
|
+
if (!state.reading) {
|
|
1159
|
+
pna.nextTick(nReadingNextTick, this);
|
|
1160
|
+
} else if (state.length) {
|
|
1161
|
+
emitReadable(this);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return res;
|
|
1166
|
+
};
|
|
1167
|
+
Readable.prototype.addListener = Readable.prototype.on;
|
|
1168
|
+
function nReadingNextTick(self2) {
|
|
1169
|
+
debug("readable nexttick read 0");
|
|
1170
|
+
self2.read(0);
|
|
1171
|
+
}
|
|
1172
|
+
Readable.prototype.resume = function() {
|
|
1173
|
+
var state = this._readableState;
|
|
1174
|
+
if (!state.flowing) {
|
|
1175
|
+
debug("resume");
|
|
1176
|
+
state.flowing = true;
|
|
1177
|
+
resume(this, state);
|
|
1178
|
+
}
|
|
1179
|
+
return this;
|
|
1180
|
+
};
|
|
1181
|
+
function resume(stream2, state) {
|
|
1182
|
+
if (!state.resumeScheduled) {
|
|
1183
|
+
state.resumeScheduled = true;
|
|
1184
|
+
pna.nextTick(resume_, stream2, state);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
function resume_(stream2, state) {
|
|
1188
|
+
if (!state.reading) {
|
|
1189
|
+
debug("resume read 0");
|
|
1190
|
+
stream2.read(0);
|
|
1191
|
+
}
|
|
1192
|
+
state.resumeScheduled = false;
|
|
1193
|
+
state.awaitDrain = 0;
|
|
1194
|
+
stream2.emit("resume");
|
|
1195
|
+
flow(stream2);
|
|
1196
|
+
if (state.flowing && !state.reading) stream2.read(0);
|
|
1197
|
+
}
|
|
1198
|
+
Readable.prototype.pause = function() {
|
|
1199
|
+
debug("call pause flowing=%j", this._readableState.flowing);
|
|
1200
|
+
if (false !== this._readableState.flowing) {
|
|
1201
|
+
debug("pause");
|
|
1202
|
+
this._readableState.flowing = false;
|
|
1203
|
+
this.emit("pause");
|
|
1204
|
+
}
|
|
1205
|
+
return this;
|
|
1206
|
+
};
|
|
1207
|
+
function flow(stream2) {
|
|
1208
|
+
var state = stream2._readableState;
|
|
1209
|
+
debug("flow", state.flowing);
|
|
1210
|
+
while (state.flowing && stream2.read() !== null) {
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
Readable.prototype.wrap = function(stream2) {
|
|
1214
|
+
var _this = this;
|
|
1215
|
+
var state = this._readableState;
|
|
1216
|
+
var paused = false;
|
|
1217
|
+
stream2.on("end", function() {
|
|
1218
|
+
debug("wrapped end");
|
|
1219
|
+
if (state.decoder && !state.ended) {
|
|
1220
|
+
var chunk = state.decoder.end();
|
|
1221
|
+
if (chunk && chunk.length) _this.push(chunk);
|
|
1222
|
+
}
|
|
1223
|
+
_this.push(null);
|
|
1224
|
+
});
|
|
1225
|
+
stream2.on("data", function(chunk) {
|
|
1226
|
+
debug("wrapped data");
|
|
1227
|
+
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
1228
|
+
if (state.objectMode && (chunk === null || chunk === void 0)) return;
|
|
1229
|
+
else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
1230
|
+
var ret = _this.push(chunk);
|
|
1231
|
+
if (!ret) {
|
|
1232
|
+
paused = true;
|
|
1233
|
+
stream2.pause();
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
for (var i in stream2) {
|
|
1237
|
+
if (this[i] === void 0 && typeof stream2[i] === "function") {
|
|
1238
|
+
this[i] = /* @__PURE__ */ (function(method) {
|
|
1239
|
+
return function() {
|
|
1240
|
+
return stream2[method].apply(stream2, arguments);
|
|
1241
|
+
};
|
|
1242
|
+
})(i);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
1246
|
+
stream2.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
1247
|
+
}
|
|
1248
|
+
this._read = function(n2) {
|
|
1249
|
+
debug("wrapped _read", n2);
|
|
1250
|
+
if (paused) {
|
|
1251
|
+
paused = false;
|
|
1252
|
+
stream2.resume();
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
return this;
|
|
1256
|
+
};
|
|
1257
|
+
Object.defineProperty(Readable.prototype, "readableHighWaterMark", {
|
|
1258
|
+
// making it explicit this property is not enumerable
|
|
1259
|
+
// because otherwise some prototype manipulation in
|
|
1260
|
+
// userland will fail
|
|
1261
|
+
enumerable: false,
|
|
1262
|
+
get: function() {
|
|
1263
|
+
return this._readableState.highWaterMark;
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
Readable._fromList = fromList;
|
|
1267
|
+
function fromList(n, state) {
|
|
1268
|
+
if (state.length === 0) return null;
|
|
1269
|
+
var ret;
|
|
1270
|
+
if (state.objectMode) ret = state.buffer.shift();
|
|
1271
|
+
else if (!n || n >= state.length) {
|
|
1272
|
+
if (state.decoder) ret = state.buffer.join("");
|
|
1273
|
+
else if (state.buffer.length === 1) ret = state.buffer.head.data;
|
|
1274
|
+
else ret = state.buffer.concat(state.length);
|
|
1275
|
+
state.buffer.clear();
|
|
1276
|
+
} else {
|
|
1277
|
+
ret = fromListPartial(n, state.buffer, state.decoder);
|
|
1278
|
+
}
|
|
1279
|
+
return ret;
|
|
1280
|
+
}
|
|
1281
|
+
function fromListPartial(n, list, hasStrings) {
|
|
1282
|
+
var ret;
|
|
1283
|
+
if (n < list.head.data.length) {
|
|
1284
|
+
ret = list.head.data.slice(0, n);
|
|
1285
|
+
list.head.data = list.head.data.slice(n);
|
|
1286
|
+
} else if (n === list.head.data.length) {
|
|
1287
|
+
ret = list.shift();
|
|
1288
|
+
} else {
|
|
1289
|
+
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
|
1290
|
+
}
|
|
1291
|
+
return ret;
|
|
1292
|
+
}
|
|
1293
|
+
function copyFromBufferString(n, list) {
|
|
1294
|
+
var p = list.head;
|
|
1295
|
+
var c = 1;
|
|
1296
|
+
var ret = p.data;
|
|
1297
|
+
n -= ret.length;
|
|
1298
|
+
while (p = p.next) {
|
|
1299
|
+
var str = p.data;
|
|
1300
|
+
var nb = n > str.length ? str.length : n;
|
|
1301
|
+
if (nb === str.length) ret += str;
|
|
1302
|
+
else ret += str.slice(0, n);
|
|
1303
|
+
n -= nb;
|
|
1304
|
+
if (n === 0) {
|
|
1305
|
+
if (nb === str.length) {
|
|
1306
|
+
++c;
|
|
1307
|
+
if (p.next) list.head = p.next;
|
|
1308
|
+
else list.head = list.tail = null;
|
|
1309
|
+
} else {
|
|
1310
|
+
list.head = p;
|
|
1311
|
+
p.data = str.slice(nb);
|
|
1312
|
+
}
|
|
1313
|
+
break;
|
|
1314
|
+
}
|
|
1315
|
+
++c;
|
|
1316
|
+
}
|
|
1317
|
+
list.length -= c;
|
|
1318
|
+
return ret;
|
|
1319
|
+
}
|
|
1320
|
+
function copyFromBuffer(n, list) {
|
|
1321
|
+
var ret = Buffer.allocUnsafe(n);
|
|
1322
|
+
var p = list.head;
|
|
1323
|
+
var c = 1;
|
|
1324
|
+
p.data.copy(ret);
|
|
1325
|
+
n -= p.data.length;
|
|
1326
|
+
while (p = p.next) {
|
|
1327
|
+
var buf = p.data;
|
|
1328
|
+
var nb = n > buf.length ? buf.length : n;
|
|
1329
|
+
buf.copy(ret, ret.length - n, 0, nb);
|
|
1330
|
+
n -= nb;
|
|
1331
|
+
if (n === 0) {
|
|
1332
|
+
if (nb === buf.length) {
|
|
1333
|
+
++c;
|
|
1334
|
+
if (p.next) list.head = p.next;
|
|
1335
|
+
else list.head = list.tail = null;
|
|
1336
|
+
} else {
|
|
1337
|
+
list.head = p;
|
|
1338
|
+
p.data = buf.slice(nb);
|
|
1339
|
+
}
|
|
1340
|
+
break;
|
|
1341
|
+
}
|
|
1342
|
+
++c;
|
|
1343
|
+
}
|
|
1344
|
+
list.length -= c;
|
|
1345
|
+
return ret;
|
|
1346
|
+
}
|
|
1347
|
+
function endReadable(stream2) {
|
|
1348
|
+
var state = stream2._readableState;
|
|
1349
|
+
if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
|
|
1350
|
+
if (!state.endEmitted) {
|
|
1351
|
+
state.ended = true;
|
|
1352
|
+
pna.nextTick(endReadableNT, state, stream2);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
function endReadableNT(state, stream2) {
|
|
1356
|
+
if (!state.endEmitted && state.length === 0) {
|
|
1357
|
+
state.endEmitted = true;
|
|
1358
|
+
stream2.readable = false;
|
|
1359
|
+
stream2.emit("end");
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
function indexOf(xs, x) {
|
|
1363
|
+
for (var i = 0, l = xs.length; i < l; i++) {
|
|
1364
|
+
if (xs[i] === x) return i;
|
|
1365
|
+
}
|
|
1366
|
+
return -1;
|
|
1367
|
+
}
|
|
1368
|
+
return _stream_readable;
|
|
1369
|
+
}
|
|
1370
|
+
var _stream_transform;
|
|
1371
|
+
var hasRequired_stream_transform;
|
|
1372
|
+
function require_stream_transform() {
|
|
1373
|
+
if (hasRequired_stream_transform) return _stream_transform;
|
|
1374
|
+
hasRequired_stream_transform = 1;
|
|
1375
|
+
_stream_transform = Transform;
|
|
1376
|
+
var Duplex = require_stream_duplex();
|
|
1377
|
+
var util = Object.create(requireUtil());
|
|
1378
|
+
util.inherits = requireInherits();
|
|
1379
|
+
util.inherits(Transform, Duplex);
|
|
1380
|
+
function afterTransform(er, data) {
|
|
1381
|
+
var ts = this._transformState;
|
|
1382
|
+
ts.transforming = false;
|
|
1383
|
+
var cb = ts.writecb;
|
|
1384
|
+
if (!cb) {
|
|
1385
|
+
return this.emit("error", new Error("write callback called multiple times"));
|
|
1386
|
+
}
|
|
1387
|
+
ts.writechunk = null;
|
|
1388
|
+
ts.writecb = null;
|
|
1389
|
+
if (data != null)
|
|
1390
|
+
this.push(data);
|
|
1391
|
+
cb(er);
|
|
1392
|
+
var rs = this._readableState;
|
|
1393
|
+
rs.reading = false;
|
|
1394
|
+
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
1395
|
+
this._read(rs.highWaterMark);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
function Transform(options) {
|
|
1399
|
+
if (!(this instanceof Transform)) return new Transform(options);
|
|
1400
|
+
Duplex.call(this, options);
|
|
1401
|
+
this._transformState = {
|
|
1402
|
+
afterTransform: afterTransform.bind(this),
|
|
1403
|
+
needTransform: false,
|
|
1404
|
+
transforming: false,
|
|
1405
|
+
writecb: null,
|
|
1406
|
+
writechunk: null,
|
|
1407
|
+
writeencoding: null
|
|
1408
|
+
};
|
|
1409
|
+
this._readableState.needReadable = true;
|
|
1410
|
+
this._readableState.sync = false;
|
|
1411
|
+
if (options) {
|
|
1412
|
+
if (typeof options.transform === "function") this._transform = options.transform;
|
|
1413
|
+
if (typeof options.flush === "function") this._flush = options.flush;
|
|
1414
|
+
}
|
|
1415
|
+
this.on("prefinish", prefinish);
|
|
1416
|
+
}
|
|
1417
|
+
function prefinish() {
|
|
1418
|
+
var _this = this;
|
|
1419
|
+
if (typeof this._flush === "function") {
|
|
1420
|
+
this._flush(function(er, data) {
|
|
1421
|
+
done(_this, er, data);
|
|
1422
|
+
});
|
|
1423
|
+
} else {
|
|
1424
|
+
done(this, null, null);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
Transform.prototype.push = function(chunk, encoding) {
|
|
1428
|
+
this._transformState.needTransform = false;
|
|
1429
|
+
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
1430
|
+
};
|
|
1431
|
+
Transform.prototype._transform = function(chunk, encoding, cb) {
|
|
1432
|
+
throw new Error("_transform() is not implemented");
|
|
1433
|
+
};
|
|
1434
|
+
Transform.prototype._write = function(chunk, encoding, cb) {
|
|
1435
|
+
var ts = this._transformState;
|
|
1436
|
+
ts.writecb = cb;
|
|
1437
|
+
ts.writechunk = chunk;
|
|
1438
|
+
ts.writeencoding = encoding;
|
|
1439
|
+
if (!ts.transforming) {
|
|
1440
|
+
var rs = this._readableState;
|
|
1441
|
+
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
Transform.prototype._read = function(n) {
|
|
1445
|
+
var ts = this._transformState;
|
|
1446
|
+
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
|
1447
|
+
ts.transforming = true;
|
|
1448
|
+
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
1449
|
+
} else {
|
|
1450
|
+
ts.needTransform = true;
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
Transform.prototype._destroy = function(err, cb) {
|
|
1454
|
+
var _this2 = this;
|
|
1455
|
+
Duplex.prototype._destroy.call(this, err, function(err2) {
|
|
1456
|
+
cb(err2);
|
|
1457
|
+
_this2.emit("close");
|
|
1458
|
+
});
|
|
1459
|
+
};
|
|
1460
|
+
function done(stream2, er, data) {
|
|
1461
|
+
if (er) return stream2.emit("error", er);
|
|
1462
|
+
if (data != null)
|
|
1463
|
+
stream2.push(data);
|
|
1464
|
+
if (stream2._writableState.length) throw new Error("Calling transform done when ws.length != 0");
|
|
1465
|
+
if (stream2._transformState.transforming) throw new Error("Calling transform done when still transforming");
|
|
1466
|
+
return stream2.push(null);
|
|
1467
|
+
}
|
|
1468
|
+
return _stream_transform;
|
|
1469
|
+
}
|
|
1470
|
+
var _stream_passthrough;
|
|
1471
|
+
var hasRequired_stream_passthrough;
|
|
1472
|
+
function require_stream_passthrough() {
|
|
1473
|
+
if (hasRequired_stream_passthrough) return _stream_passthrough;
|
|
1474
|
+
hasRequired_stream_passthrough = 1;
|
|
1475
|
+
_stream_passthrough = PassThrough;
|
|
1476
|
+
var Transform = require_stream_transform();
|
|
1477
|
+
var util = Object.create(requireUtil());
|
|
1478
|
+
util.inherits = requireInherits();
|
|
1479
|
+
util.inherits(PassThrough, Transform);
|
|
1480
|
+
function PassThrough(options) {
|
|
1481
|
+
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
1482
|
+
Transform.call(this, options);
|
|
1483
|
+
}
|
|
1484
|
+
PassThrough.prototype._transform = function(chunk, encoding, cb) {
|
|
1485
|
+
cb(null, chunk);
|
|
1486
|
+
};
|
|
1487
|
+
return _stream_passthrough;
|
|
1488
|
+
}
|
|
1489
|
+
var hasRequiredReadable;
|
|
1490
|
+
function requireReadable() {
|
|
1491
|
+
if (hasRequiredReadable) return readable.exports;
|
|
1492
|
+
hasRequiredReadable = 1;
|
|
1493
|
+
(function(module, exports$1) {
|
|
1494
|
+
var Stream = require$$0;
|
|
1495
|
+
if (process.env.READABLE_STREAM === "disable" && Stream) {
|
|
1496
|
+
module.exports = Stream;
|
|
1497
|
+
exports$1 = module.exports = Stream.Readable;
|
|
1498
|
+
exports$1.Readable = Stream.Readable;
|
|
1499
|
+
exports$1.Writable = Stream.Writable;
|
|
1500
|
+
exports$1.Duplex = Stream.Duplex;
|
|
1501
|
+
exports$1.Transform = Stream.Transform;
|
|
1502
|
+
exports$1.PassThrough = Stream.PassThrough;
|
|
1503
|
+
exports$1.Stream = Stream;
|
|
1504
|
+
} else {
|
|
1505
|
+
exports$1 = module.exports = require_stream_readable();
|
|
1506
|
+
exports$1.Stream = Stream || exports$1;
|
|
1507
|
+
exports$1.Readable = exports$1;
|
|
1508
|
+
exports$1.Writable = require_stream_writable();
|
|
1509
|
+
exports$1.Duplex = require_stream_duplex();
|
|
1510
|
+
exports$1.Transform = require_stream_transform();
|
|
1511
|
+
exports$1.PassThrough = require_stream_passthrough();
|
|
1512
|
+
}
|
|
1513
|
+
})(readable, readable.exports);
|
|
1514
|
+
return readable.exports;
|
|
1515
|
+
}
|
|
1516
|
+
export {
|
|
1517
|
+
requireReadable as r
|
|
1518
|
+
};
|