@humain/humain-code 0.4.17 → 0.5.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/CHANGELOG.md +260 -1
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/anthropic-messages-ZP5KUK52.js +67 -0
- package/dist/bundle/chunks/anthropic.js +2 -2
- package/dist/bundle/chunks/azure-openai-responses-QJFYQ3DF.js +15 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +152 -200
- package/dist/bundle/chunks/{chunk-4XU7TDAL.js → chunk-2GCMACT4.js} +48 -46
- package/dist/bundle/chunks/{chunk-DUSJT2W4.js → chunk-476XBL3W.js} +3 -3
- package/dist/bundle/chunks/{chunk-4NFYTS4C.js → chunk-5C4VL2AR.js} +4 -4
- package/dist/bundle/chunks/{chunk-QEF72EIZ.js → chunk-A6B2QMA7.js} +40 -96
- package/dist/bundle/chunks/{chunk-AOL6QG6L.js → chunk-A6YBWW4T.js} +1405 -1311
- package/dist/bundle/chunks/{chunk-ZRGFX6T6.js → chunk-CN3Q5UNB.js} +387 -309
- package/dist/bundle/chunks/{chunk-TJG52LZB.js → chunk-DR37WKFZ.js} +9 -8
- package/dist/bundle/chunks/chunk-DU6POZ7E.js +10 -0
- package/dist/bundle/chunks/{chunk-X6OTEVGA.js → chunk-FO2NYB6O.js} +626 -619
- package/dist/bundle/chunks/{chunk-RXOCQRBG.js → chunk-GEISZXXH.js} +1 -1
- package/dist/bundle/chunks/{chunk-OKALNPTJ.js → chunk-HIZWUSPN.js} +24 -24
- package/dist/bundle/chunks/{chunk-MVYV6MJY.js → chunk-HT5YN3LX.js} +1 -1
- package/dist/bundle/chunks/chunk-IDU5BNNI.js +15 -0
- package/dist/bundle/chunks/{chunk-TIFFHHW6.js → chunk-JCXXRCP6.js} +5 -5
- package/dist/bundle/chunks/{chunk-QYCOHSI7.js → chunk-KKCMWB63.js} +8 -7
- package/dist/bundle/chunks/{chunk-SCBU5WOP.js → chunk-M74U5X4S.js} +30 -23
- package/dist/bundle/chunks/{chunk-AWCJWXGD.js → chunk-MIJHJNNQ.js} +3 -2
- package/dist/bundle/chunks/{chunk-Y26OS23T.js → chunk-N7CQ3UV3.js} +4 -4
- package/dist/bundle/chunks/{chunk-XQZG5HPT.js → chunk-O4DO5RWS.js} +11 -6
- package/dist/bundle/chunks/chunk-OR25QDSS.js +365 -0
- package/dist/bundle/chunks/{chunk-7PRU6YW3.js → chunk-OZNC2W4B.js} +306 -286
- package/dist/bundle/chunks/{chunk-Z33NNMNB.js → chunk-PH7UP57J.js} +1 -1
- package/dist/bundle/chunks/{chunk-FHVNUUBF.js → chunk-PS7DGA7B.js} +1 -1
- package/dist/bundle/chunks/chunk-Q3SFYT2X.js +1965 -0
- package/dist/bundle/chunks/chunk-QW6PTCAB.js +10 -0
- package/dist/bundle/chunks/{chunk-5CDES42D.js → chunk-QWXPGBAG.js} +1 -1
- package/dist/bundle/chunks/{chunk-NCQ6WAQK.js → chunk-ROZV2IYD.js} +1 -1
- package/dist/bundle/chunks/{chunk-PTP2ZHFQ.js → chunk-RTXDU3AA.js} +148 -122
- package/dist/bundle/chunks/{chunk-36Q5UVQL.js → chunk-T3HXWZG4.js} +2 -2
- package/dist/bundle/chunks/{chunk-FZUJXM6D.js → chunk-UDB6NI4G.js} +309 -240
- package/dist/bundle/chunks/chunk-UTNHGOFS.js +88 -0
- package/dist/bundle/chunks/{chunk-H2FY3PEV.js → chunk-V62QBESW.js} +4 -3
- package/dist/bundle/chunks/{chunk-LG2PJ6JN.js → chunk-XA7CJAYH.js} +4 -3
- package/dist/bundle/chunks/chunk-XQX7S3GM.js +7 -0
- package/dist/bundle/chunks/chunk-YFOLLX5D.js +23 -0
- package/dist/bundle/chunks/{chunk-YRCLNWFV.js → chunk-ZI7TK7HM.js} +1 -1
- package/dist/bundle/chunks/{chunk-V76YPIMT.js → chunk-ZR4GF4WU.js} +21 -15
- package/dist/bundle/chunks/{cli-SRI4UOSL.js → cli-VXU7OWFU.js} +1 -1
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-T7TPP7SQ.js +4 -0
- package/dist/bundle/chunks/codemode-worker.js +27 -27
- package/dist/bundle/chunks/compat-S2IBVV6V.js +13 -0
- package/dist/bundle/chunks/{dist-D7M52E3X.js → dist-645GFIWH.js} +452 -448
- package/dist/bundle/chunks/{dist-XVXV2CL4.js → dist-IBUWEKEE.js} +3 -3
- package/dist/bundle/chunks/dist-YFMJEHPH.js +8 -0
- package/dist/bundle/chunks/{dist-cjs-AXBW3N4F.js → dist-cjs-HTASUQXQ.js} +82 -80
- package/dist/bundle/chunks/{easter-egg-3d-4SUPLBUF.js → easter-egg-3d-YOPLCOVW.js} +2 -2
- package/dist/bundle/chunks/{esm-NCUV2DF7.js → esm-R6HJ4QEG.js} +5 -5
- package/dist/bundle/chunks/{event-streams-NXFTZDSF.js → event-streams-BR2IL6C5.js} +1 -1
- package/dist/bundle/chunks/{execute-NTO3U76E.js → execute-2JXEKQ2X.js} +17 -8
- package/dist/bundle/chunks/{extract-BKBHK4AK.js → extract-OTCGZGTL.js} +50 -47
- package/dist/bundle/chunks/github-copilot.js +42 -40
- package/dist/bundle/chunks/google-generative-ai-HVPCGIZ6.js +21 -0
- package/dist/bundle/chunks/google-vertex-UM5MAALA.js +25 -0
- package/dist/bundle/chunks/host-ZHEL5XQW.js +2 -0
- package/dist/bundle/chunks/{https-proxy-agent-7CAXVAFH.js → https-proxy-agent-JQICCRPH.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-AGCW7HYN.js → llama-cpp-classify-B3G57LVR.js} +5 -5
- package/dist/bundle/chunks/{mistral-conversations-G3GN6CMT.js → mistral-conversations-AH72RLXK.js} +11 -11
- package/dist/bundle/chunks/{node-ELWNZC34.js → node-SJPZTR4K.js} +6 -6
- package/dist/bundle/chunks/{node-DZCAT4Q6.js → node-VSA4ZN7D.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +2 -2
- package/dist/bundle/chunks/{openai-codex-responses-FJFDAWHI.js → openai-codex-responses-L366637C.js} +48 -47
- package/dist/bundle/chunks/openai-codex.js +2 -2
- package/dist/bundle/chunks/openai-completions-ZP62QXJX.js +83 -0
- package/dist/bundle/chunks/{openai-decisions-HESOHYZB.js → openai-decisions-WOWUC65P.js} +1 -1
- package/dist/bundle/chunks/openai-responses-DXUGSUTN.js +26 -0
- package/dist/bundle/chunks/openrouter-images-5K47HDAT.js +8 -0
- package/dist/bundle/chunks/openrouter.js +2 -2
- package/dist/bundle/chunks/{pi-messages-SAOV3JNW.js → pi-messages-MOQQDZBK.js} +5 -4
- package/dist/bundle/chunks/radius.js +2 -2
- package/dist/bundle/chunks/{runtime-VGSK3QCM.js → runtime-5VFZTMWL.js} +1 -1
- package/dist/bundle/chunks/typesafe-system-one-43OCHGKP.js +3 -0
- package/dist/bundle/chunks/{undici-N4LWJ3S3.js → undici-EK3EUI2E.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-GU6AW5ZK.js +5 -0
- package/dist/bundle/cli-runtime.js +3 -3
- package/dist/bundle/flow/package.json +4 -4
- package/dist/bundle/index.js +6 -6
- package/dist/bundle/rpc-entry.js +3 -3
- package/dist/cli/args.d.ts +6 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/coordination/adapter/tool.d.ts.map +1 -1
- package/dist/coordination/adapter/tool.js +3 -1
- package/dist/coordination/adapter/tool.js.map +1 -1
- package/dist/coordination/broker/broker.d.ts +6 -2
- package/dist/coordination/broker/broker.d.ts.map +1 -1
- package/dist/coordination/broker/broker.js +20 -8
- package/dist/coordination/broker/broker.js.map +1 -1
- package/dist/coordination/client/client.d.ts.map +1 -1
- package/dist/coordination/client/client.js +4 -2
- package/dist/coordination/client/client.js.map +1 -1
- package/dist/coordination/transport/discovery.d.ts +10 -3
- package/dist/coordination/transport/discovery.d.ts.map +1 -1
- package/dist/coordination/transport/discovery.js +18 -5
- package/dist/coordination/transport/discovery.js.map +1 -1
- package/dist/core/agent-session.d.ts +35 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +163 -40
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-subscription-usage.d.ts +47 -0
- package/dist/core/anthropic-subscription-usage.d.ts.map +1 -0
- package/dist/core/anthropic-subscription-usage.js +170 -0
- package/dist/core/anthropic-subscription-usage.js.map +1 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +7 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/client-identity.d.ts +13 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +25 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/codex-usage.d.ts +37 -1
- package/dist/core/codex-usage.d.ts.map +1 -1
- package/dist/core/codex-usage.js +104 -11
- package/dist/core/codex-usage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +2 -1
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +30 -29
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +14 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +86 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +3 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/model-config.d.ts +920 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +48 -24
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +18 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +20 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +14 -6
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +9 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +99 -12
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/output-guard.d.ts +13 -1
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +101 -11
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +7 -3
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +7 -2
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -9
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +4 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +242 -26
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +93 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +3 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +37 -12
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +102 -24
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +3 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +3 -2
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/usage/index.d.ts +15 -0
- package/dist/extensions/usage/index.d.ts.map +1 -0
- package/dist/extensions/usage/index.js +110 -0
- package/dist/extensions/usage/index.js.map +1 -0
- package/dist/extensions/usage/overview.d.ts +90 -0
- package/dist/extensions/usage/overview.d.ts.map +1 -0
- package/dist/extensions/usage/overview.js +215 -0
- package/dist/extensions/usage/overview.js.map +1 -0
- package/dist/extensions/usage/popup.d.ts +21 -0
- package/dist/extensions/usage/popup.d.ts.map +1 -0
- package/dist/extensions/usage/popup.js +98 -0
- package/dist/extensions/usage/popup.js.map +1 -0
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +21 -2
- package/dist/humain/bundled-extension-names.d.ts +6 -0
- package/dist/humain/bundled-extension-names.d.ts.map +1 -0
- package/dist/humain/bundled-extension-names.js +9 -0
- package/dist/humain/bundled-extension-names.js.map +1 -0
- package/dist/humain/index.d.ts +2 -2
- package/dist/humain/index.d.ts.map +1 -1
- package/dist/humain/index.js +3 -2
- package/dist/humain/index.js.map +1 -1
- package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/anysearch.js +3 -3
- package/dist/humain/web-access/vendor/anysearch.js.map +1 -1
- package/dist/humain/web-access/vendor/bocha.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/bocha.js +3 -3
- package/dist/humain/web-access/vendor/bocha.js.map +1 -1
- package/dist/humain/web-access/vendor/brightdata-unlocker.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/brightdata-unlocker.js +2 -2
- package/dist/humain/web-access/vendor/brightdata-unlocker.js.map +1 -1
- package/dist/humain/web-access/vendor/brightdata.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/brightdata.js +3 -3
- package/dist/humain/web-access/vendor/brightdata.js.map +1 -1
- package/dist/humain/web-access/vendor/ceramic.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/ceramic.js +2 -2
- package/dist/humain/web-access/vendor/ceramic.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +3 -1
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.js +2 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/deepseek.d.ts +11 -1
- package/dist/humain/web-access/vendor/deepseek.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/deepseek.js +170 -5
- package/dist/humain/web-access/vendor/deepseek.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +63 -6
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.d.ts +5 -3
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.js +33 -7
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
- package/dist/humain/web-access/vendor/index.d.ts +1 -0
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +18 -3
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/jina-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/jina-search.js +6 -4
- package/dist/humain/web-access/vendor/jina-search.js.map +1 -1
- package/dist/humain/web-access/vendor/kagi.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/kagi.js +4 -4
- package/dist/humain/web-access/vendor/kagi.js.map +1 -1
- package/dist/humain/web-access/vendor/keenable.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/keenable.js +2 -2
- package/dist/humain/web-access/vendor/keenable.js.map +1 -1
- package/dist/humain/web-access/vendor/linkup.d.ts +6 -0
- package/dist/humain/web-access/vendor/linkup.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/linkup.js +167 -0
- package/dist/humain/web-access/vendor/linkup.js.map +1 -0
- package/dist/humain/web-access/vendor/mistral-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/mistral-search.js +3 -3
- package/dist/humain/web-access/vendor/mistral-search.js.map +1 -1
- package/dist/humain/web-access/vendor/ollama.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/ollama.js +4 -4
- package/dist/humain/web-access/vendor/ollama.js.map +1 -1
- package/dist/humain/web-access/vendor/parallel.js +6 -7
- package/dist/humain/web-access/vendor/parallel.js.map +1 -1
- package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/perplexity.js +4 -3
- package/dist/humain/web-access/vendor/perplexity.js.map +1 -1
- package/dist/humain/web-access/vendor/querit.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/querit.js +3 -3
- package/dist/humain/web-access/vendor/querit.js.map +1 -1
- package/dist/humain/web-access/vendor/search1api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/search1api.js +3 -3
- package/dist/humain/web-access/vendor/search1api.js.map +1 -1
- package/dist/humain/web-access/vendor/searchinfinity.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/searchinfinity.js +3 -3
- package/dist/humain/web-access/vendor/searchinfinity.js.map +1 -1
- package/dist/humain/web-access/vendor/serpapi.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serpapi.js +6 -5
- package/dist/humain/web-access/vendor/serpapi.js.map +1 -1
- package/dist/humain/web-access/vendor/serpbase.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serpbase.js +4 -4
- package/dist/humain/web-access/vendor/serpbase.js.map +1 -1
- package/dist/humain/web-access/vendor/serpdive.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serpdive.js +3 -3
- package/dist/humain/web-access/vendor/serpdive.js.map +1 -1
- package/dist/humain/web-access/vendor/serper.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serper.js +5 -4
- package/dist/humain/web-access/vendor/serper.js.map +1 -1
- package/dist/humain/web-access/vendor/serply.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serply.js +2 -2
- package/dist/humain/web-access/vendor/serply.js.map +1 -1
- package/dist/humain/web-access/vendor/utils.d.ts +3 -1
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +27 -2
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/valyu.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/valyu.js +3 -3
- package/dist/humain/web-access/vendor/valyu.js.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.d.ts +2 -0
- package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.js +3 -0
- package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
- package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/xai-search.js +51 -8
- package/dist/humain/web-access/vendor/xai-search.js.map +1 -1
- package/dist/humain/web-access/vendor/xcrawl.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/xcrawl.js +3 -3
- package/dist/humain/web-access/vendor/xcrawl.js.map +1 -1
- package/dist/humain/web-access/vendor/you.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/you.js +2 -2
- package/dist/humain/web-access/vendor/you.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +15 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +14 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +62 -7
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +6 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/easter-egg-3d.js +1 -1
- package/dist/modes/interactive/components/easter-egg-3d.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +10 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +141 -66
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +16 -3
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +1 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/themed-text.js +3 -2
- package/dist/modes/interactive/components/themed-text.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +17 -6
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +3 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +4 -2
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -17
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +90 -122
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +2 -5
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +2 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +3 -2
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +3 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +1 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +3 -2
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +45 -13
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +4 -3
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/codemode.md +2 -2
- package/docs/compaction.md +3 -3
- package/docs/coordination.md +1 -1
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +2 -0
- package/docs/extensions.md +133 -10
- package/docs/models-configuration.md +197 -0
- package/docs/models.md +21 -5
- package/docs/settings.md +1 -1
- package/docs/slash-commands.md +10 -0
- package/docs/tui.md +70 -0
- package/docs/windows.md +16 -2
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/plugins/pi-example-plugin/package.json +2 -2
- package/npm-shrinkwrap.json +243 -219
- package/package.json +21 -20
- package/schemas/models.schema.json +84 -30
- package/src/coordination/UPSTREAM.md +36 -3
- package/src/coordination/upstream.json +3 -3
- package/src/humain/web-access/UPSTREAM.md +72 -1
- package/src/humain/web-access/upstream.json +5 -4
- package/dist/bundle/chunks/anthropic-messages-TSNY5MWH.js +0 -67
- package/dist/bundle/chunks/azure-openai-responses-Z4DCXO2G.js +0 -15
- package/dist/bundle/chunks/chunk-5K5RFXXO.js +0 -74
- package/dist/bundle/chunks/chunk-65U7MPF4.js +0 -1790
- package/dist/bundle/chunks/chunk-PY7SOXCA.js +0 -10
- package/dist/bundle/chunks/chunk-UGJAAWNC.js +0 -7
- package/dist/bundle/chunks/chunk-UGXYG7HN.js +0 -22
- package/dist/bundle/chunks/chunk-VEYTRNQC.js +0 -5
- package/dist/bundle/chunks/chunk-W2QRCQBX.js +0 -165
- package/dist/bundle/chunks/chunk-X3O5MCKJ.js +0 -7
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MUJQ6LT2.js +0 -4
- package/dist/bundle/chunks/compat-ARQPWKBQ.js +0 -13
- package/dist/bundle/chunks/dist-LKDZAEUQ.js +0 -7
- package/dist/bundle/chunks/google-generative-ai-SJ4JO2MY.js +0 -21
- package/dist/bundle/chunks/google-vertex-KNLNNDET.js +0 -25
- package/dist/bundle/chunks/host-63SNKK5Y.js +0 -2
- package/dist/bundle/chunks/openai-completions-IC7WRLTI.js +0 -82
- package/dist/bundle/chunks/openai-responses-XXCYDFSM.js +0 -24
- package/dist/bundle/chunks/openrouter-images-DT2HMZNO.js +0 -8
- package/dist/bundle/chunks/typesafe-system-one-HCMGHK6A.js +0 -2
- package/dist/bundle/chunks/virtual-modules-LP2ULVLW.js +0 -5
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -85
- package/dist/core/provider-attribution.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import"./chunk-
|
|
3
|
-
import"./chunk-
|
|
4
|
-
import"./chunk-
|
|
5
|
-
FlowTimestampSchema,StrictObject,canonicalFlowJson,canonicalWithout,compileFlow,hasDuplicateModels,lit,parseFlowData,partialByRole,verifyFlowDigest}from"./chunk-
|
|
6
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-5C4VL2AR.js";import{FLOW_ACCOUNT_PERSISTENCE_NOTICE,FLOW_MESSAGE_MAX_LENGTH,FLOW_SETUP_TERMINAL_ONLY,assertDhRetryAdmission,assessNodeFallback,checkDhControlFence,dhCanonicalText,discoverAgents,flowBuildUnavailable,getFlowAccountsHost,getFlowChildLaunchHost,getFlowControlHost,getFlowTraceProducer,parseDhControlDelivery,parseFlowCommand,parseFlowControlCommandV1,parseFlowControlReceiptV1,parseFlowMessageReceiptV1,parseFlowStatusV1,renderFlowHelp,renderTaskWithContext,resolveDhEffectiveTerminals}from"./chunk-A6YBWW4T.js";
|
|
3
|
+
import"./chunk-RTXDU3AA.js";import"./chunk-A6B2QMA7.js";import"./chunk-PS7DGA7B.js";import"./chunk-DR37WKFZ.js";import"./chunk-M74U5X4S.js";import"./chunk-Q3SFYT2X.js";import"./chunk-XA7CJAYH.js";import{ScrollView,matchesKey,mixColors,styleText,truncateToWidth,visibleWidth,wrapTextWithAnsi}from"./chunk-CN3Q5UNB.js";import"./chunk-XQRYOCHA.js";import"./chunk-DNGJMRJW.js";import"./chunk-T3HXWZG4.js";import"./chunk-YFOLLX5D.js";
|
|
4
|
+
import"./chunk-KKCMWB63.js";import"./chunk-V62QBESW.js";import"./chunk-KQM7ZGL6.js";import"./chunk-CIA6V3BP.js";import"./chunk-O4DO5RWS.js";import"./chunk-FACBDLFU.js";import{FLOW_DIGEST_PATTERN,FLOW_ID_PATTERN,FLOW_MODEL_ID_PATTERN,FLOW_ROLES,FlowContractError,FlowCountSchema,FlowDigestSchema,FlowFailureClassSchema,FlowIdSchema,FlowMicrousdSchema,FlowModelRefSchema,FlowPositiveIntSchema,FlowProfileRefSchema,FlowReasonClassSchema,FlowRoleSchema,FlowSizeSchema,
|
|
5
|
+
FlowTimestampSchema,StrictObject,canonicalFlowJson,canonicalWithout,compileFlow,hasDuplicateModels,lit,parseFlowData,partialByRole,verifyFlowDigest}from"./chunk-ROZV2IYD.js";import{getAgentDir}from"./chunk-ZI7TK7HM.js";import"./chunk-2GCMACT4.js";import"./chunk-N7CQ3UV3.js";import"./chunk-QW6PTCAB.js";import"./chunk-DBL35X7L.js";import"./chunk-YDBNMIA3.js";import"./chunk-UTNHGOFS.js";import"./chunk-IJYVMOB4.js";import"./chunk-IDU5BNNI.js";
|
|
6
|
+
import"./chunk-MIJHJNNQ.js";import{typebox_exports}from"./chunk-HIZWUSPN.js";import"./chunk-JXWJOIH4.js";import{resolve}from"node:path";var FlowProfileError=class extends Error{code;path;constructor(code2,message,path){super(message),this.name="FlowProfileError",this.code=code2,path!==void 0&&(this.path=path)}};import{stripVTControlCharacters}from"node:util";var FlowEffortSchema=typebox_exports.Union([typebox_exports.Literal("low"),typebox_exports.Literal("medium"),typebox_exports.Literal("high")]),FlowRoleBindingSchema=StrictObject({primary:FlowModelRefSchema,backups:typebox_exports.Array(FlowModelRefSchema,{maxItems:8}),effort:FlowEffortSchema}),FLOW_MODEL_SELECTION_TIERS=["cheap","mid","premium","frontier"],FLOW_MODEL_SELECTION_CAPABILITIES=["scout","scope_scout","worker","implementation_fast","analysis_mid","technical_lead","lead_small","lead","\
|
|
7
7
|
lead_large","implementation_strong","technical_review","integration_review","migration_review","performance_review","api_contract_review","qa_agent","analysis_strong","architect","security_review","triage"],FlowSelectionEffortSchema=lit("off","minimal","low","medium","high","xhigh","max"),FlowTierSelectionSchema=StrictObject({primary:typebox_exports.Optional(FlowModelRefSchema),backups:typebox_exports.Optional(typebox_exports.Array(FlowModelRefSchema,{maxItems:8}))}),FlowCapabilitySelectionSchema=StrictObject(
|
|
8
8
|
{primary:typebox_exports.Optional(FlowModelRefSchema),backups:typebox_exports.Optional(typebox_exports.Array(FlowModelRefSchema,{maxItems:8})),effort:typebox_exports.Optional(FlowSelectionEffortSchema)}),optionalEach=(keys,schema)=>StrictObject(Object.fromEntries(keys.map(key=>[key,typebox_exports.Optional(schema)]))),FlowModelSelectionSchema=StrictObject({tiers:typebox_exports.Optional(optionalEach(FLOW_MODEL_SELECTION_TIERS,FlowTierSelectionSchema)),capabilities:typebox_exports.Optional(optionalEach(
|
|
9
9
|
FLOW_MODEL_SELECTION_CAPABILITIES,FlowCapabilitySelectionSchema))}),FlowProfileV1Schema=StrictObject({schema:typebox_exports.Literal("humain-flow-profile"),schemaVersion:typebox_exports.Literal(1),id:FlowIdSchema,version:FlowPositiveIntSchema,digest:FlowDigestSchema,kind:typebox_exports.Union([typebox_exports.Literal("direct"),typebox_exports.Literal("flow")]),label:typebox_exports.String({minLength:1,maxLength:80}),description:typebox_exports.Optional(typebox_exports.String({maxLength:500})),direct:typebox_exports.
|
|
@@ -664,14 +664,14 @@ isAssign}),incDec:createToken("++/--",{prefix,postfix,startsExpr}),bang:createTo
|
|
|
664
664
|
=/===/!==",6),lt:createBinop("</>/<=/>=",7),gt:createBinop("</>/<=/>=",7),relational:createBinop("</>/<=/>=",7),bitShift:createBinop("<</>>/>>>",8),bitShiftL:createBinop("<</>>/>>>",8),bitShiftR:createBinop("<</>>/>>>",8),plusMin:createToken("+/-",{beforeExpr,binop:9,prefix,startsExpr}),modulo:createToken("%",{binop:10,startsExpr}),star:createToken("*",{binop:10}),slash:createBinop("/",10),exponent:createToken("**",{beforeExpr,binop:11,rightAssociative:!0}),_in:createKeyword("in",{beforeExpr,binop:7}),
|
|
665
665
|
_instanceof:createKeyword("instanceof",{beforeExpr,binop:7}),_break:createKeyword("break"),_case:createKeyword("case",{beforeExpr}),_catch:createKeyword("catch"),_continue:createKeyword("continue"),_debugger:createKeyword("debugger"),_default:createKeyword("default",{beforeExpr}),_else:createKeyword("else",{beforeExpr}),_finally:createKeyword("finally"),_function:createKeyword("function",{startsExpr}),_if:createKeyword("if"),_return:createKeyword("return",{beforeExpr}),_switch:createKeyword("swi\
|
|
666
666
|
tch"),_throw:createKeyword("throw",{beforeExpr,prefix,startsExpr}),_try:createKeyword("try"),_var:createKeyword("var"),_const:createKeyword("const"),_with:createKeyword("with"),_new:createKeyword("new",{beforeExpr,startsExpr}),_this:createKeyword("this",{startsExpr}),_super:createKeyword("super",{startsExpr}),_class:createKeyword("class",{startsExpr}),_extends:createKeyword("extends",{beforeExpr}),_export:createKeyword("export"),_import:createKeyword("import",{startsExpr}),_null:createKeyword("n\
|
|
667
|
-
ull",{startsExpr}),_true:createKeyword("true",{startsExpr}),_false:createKeyword("false",{startsExpr}),_typeof:createKeyword("typeof",{beforeExpr,prefix,startsExpr}),_void:createKeyword("void",{beforeExpr,prefix,startsExpr}),_delete:createKeyword("delete",{beforeExpr,prefix,startsExpr}),_do:createKeyword("do",{isLoop,beforeExpr}),_for:createKeyword("for",{isLoop}),_while:createKeyword("while",{isLoop}),
|
|
668
|
-
"async",{startsExpr}),_await:createKeywordLike("await",{startsExpr}),_defer:createKeywordLike("defer",{startsExpr}),_from:createKeywordLike("from",{startsExpr}),_get:createKeywordLike("get",{startsExpr}),_let:createKeywordLike("let",{startsExpr}),_meta:createKeywordLike("meta",{startsExpr}),_of:createKeywordLike("of",{startsExpr}),_sent:createKeywordLike("sent",{startsExpr}),_set:createKeywordLike("set",{startsExpr}),_source:createKeywordLike(
|
|
669
|
-
|
|
670
|
-
startsExpr}),_mixins:createKeywordLike("mixins",{startsExpr}),_proto:createKeywordLike("proto",{startsExpr}),_require:createKeywordLike("require",{startsExpr}),_satisfies:createKeywordLike("satisfies",{startsExpr}),_keyof:createKeywordLike("keyof",{startsExpr}),_readonly:createKeywordLike("readonly",{startsExpr}),_unique:createKeywordLike("unique",{startsExpr}),_abstract:createKeywordLike("abstract",{startsExpr}),_declare:createKeywordLike("
|
|
671
|
-
startsExpr}),_module:createKeywordLike("module",{startsExpr}),_namespace:createKeywordLike("namespace",{startsExpr}),_interface:createKeywordLike("interface",{startsExpr}),_type:createKeywordLike("type",{startsExpr}),_opaque:createKeywordLike("opaque",{startsExpr}),name:createToken("name",{startsExpr}),placeholder:createToken("%%",{startsExpr}),string:createToken("string",{startsExpr}),num:createToken("num",{startsExpr}),bigint:createToken("
|
|
672
|
-
privateName:createToken("#name",{startsExpr}),eof:createToken("eof"),jsxName:createToken("jsxName"),jsxText:createToken("jsxText",{beforeExpr}),jsxTagStart:createToken("jsxTagStart",{startsExpr}),jsxTagEnd:createToken("jsxTagEnd")};function tokenIsIdentifier(token){return token>=89&&token<=
|
|
673
|
-
|
|
674
|
-
30}function tokenIsPrefix(token){return tokenPrefixes[token]}function tokenIsTSTypeOperator(token){return token>=
|
|
667
|
+
ull",{startsExpr}),_true:createKeyword("true",{startsExpr}),_false:createKeyword("false",{startsExpr}),_typeof:createKeyword("typeof",{beforeExpr,prefix,startsExpr}),_void:createKeyword("void",{beforeExpr,prefix,startsExpr}),_delete:createKeyword("delete",{beforeExpr,prefix,startsExpr}),_do:createKeyword("do",{isLoop,beforeExpr}),_for:createKeyword("for",{isLoop}),_while:createKeyword("while",{isLoop}),_arguments:createKeywordLike("arguments",{startsExpr}),_as:createKeywordLike("as",{startsExpr}),
|
|
668
|
+
_assert:createKeywordLike("assert",{startsExpr}),_async:createKeywordLike("async",{startsExpr}),_await:createKeywordLike("await",{startsExpr}),_defer:createKeywordLike("defer",{startsExpr}),_from:createKeywordLike("from",{startsExpr}),_get:createKeywordLike("get",{startsExpr}),_let:createKeywordLike("let",{startsExpr}),_meta:createKeywordLike("meta",{startsExpr}),_of:createKeywordLike("of",{startsExpr}),_sent:createKeywordLike("sent",{startsExpr}),_set:createKeywordLike("set",{startsExpr}),_source:createKeywordLike(
|
|
669
|
+
"source",{startsExpr}),_static:createKeywordLike("static",{startsExpr}),_using:createKeywordLike("using",{startsExpr}),_yield:createKeywordLike("yield",{startsExpr}),_asserts:createKeywordLike("asserts",{startsExpr}),_checks:createKeywordLike("checks",{startsExpr}),_exports:createKeywordLike("exports",{startsExpr}),_global:createKeywordLike("global",{startsExpr}),_implements:createKeywordLike("implements",{startsExpr}),_intrinsic:createKeywordLike("intrinsic",{startsExpr}),_infer:createKeywordLike(
|
|
670
|
+
"infer",{startsExpr}),_is:createKeywordLike("is",{startsExpr}),_mixins:createKeywordLike("mixins",{startsExpr}),_proto:createKeywordLike("proto",{startsExpr}),_require:createKeywordLike("require",{startsExpr}),_satisfies:createKeywordLike("satisfies",{startsExpr}),_keyof:createKeywordLike("keyof",{startsExpr}),_readonly:createKeywordLike("readonly",{startsExpr}),_unique:createKeywordLike("unique",{startsExpr}),_abstract:createKeywordLike("abstract",{startsExpr}),_declare:createKeywordLike("decla\
|
|
671
|
+
re",{startsExpr}),_enum:createKeywordLike("enum",{startsExpr}),_module:createKeywordLike("module",{startsExpr}),_namespace:createKeywordLike("namespace",{startsExpr}),_interface:createKeywordLike("interface",{startsExpr}),_type:createKeywordLike("type",{startsExpr}),_opaque:createKeywordLike("opaque",{startsExpr}),name:createToken("name",{startsExpr}),placeholder:createToken("%%",{startsExpr}),string:createToken("string",{startsExpr}),num:createToken("num",{startsExpr}),bigint:createToken("bigin\
|
|
672
|
+
t",{startsExpr}),regexp:createToken("regexp",{startsExpr}),privateName:createToken("#name",{startsExpr}),eof:createToken("eof"),jsxName:createToken("jsxName"),jsxText:createToken("jsxText",{beforeExpr}),jsxTagStart:createToken("jsxTagStart",{startsExpr}),jsxTagEnd:createToken("jsxTagEnd")};function tokenIsIdentifier(token){return token>=89&&token<=130}function tokenKeywordOrIdentifierIsKeyword(token){return token<=88}function tokenIsKeywordOrIdentifier(token){return token>=54&&token<=130}function tokenIsLiteralPropertyName(token){
|
|
673
|
+
return token>=54&&token<=133}function tokenComesBeforeExpression(token){return tokenBeforeExprs[token]}function tokenCanStartExpression(token){return tokenStartsExprs[token]}function tokenIsAssignment(token){return token>=25&&token<=29}function tokenIsFlowInterfaceOrTypeOrOpaque(token){return token>=126&&token<=128}function tokenIsLoop(token){return token>=86&&token<=88}function tokenIsKeyword(token){return token>=54&&token<=88}function tokenIsOperator(token){return token>=35&&token<=55}function tokenIsPostfix(token){
|
|
674
|
+
return token===30}function tokenIsPrefix(token){return tokenPrefixes[token]}function tokenIsTSTypeOperator(token){return token>=118&&token<=120}function tokenIsTSDeclarationStart(token){return token>=121&&token<=127}function tokenLabelName(token){return tokenLabels[token]}function tokenOperatorPrecedence(token){return tokenBinops[token]}function tokenIsRightAssociative(token){return token===53}function tokenIsTemplate(token){return token>=20&&token<=21}function getExportedToken(token){return tokenTypes[token]}
|
|
675
675
|
var TokContext=class{constructor(token,preserveSpace){this.token=token,this.preserveSpace=!!preserveSpace}token;preserveSpace},types={brace:new TokContext("{"),j_oTag:new TokContext("<tag"),j_cTag:new TokContext("</tag"),j_expr:new TokContext("<tag>...</tag>",!0)},bmpIdentifierStart=/[\p{ID_Start}\u0558\u058b\u058c\u088f\u0c5c\u0cdc\u208f\u209d-\u209f\ua7ce\ua7cf\ua7d2\ua7d4\ua7dd\ua7e2\ua7f1\uab6c\uab6d]/u,bmpIdentifier=/[\p{ID_Continue}\u0558\u058b\u058c\u088f\u0c5c\u0cdc\u208f\u209d-\u209f\ua7ce\ua7cf\ua7d2\ua7d4\ua7dd\ua7e2\ua7f1\uab6c\uab6d\u05c8\u05c9\u0b53\u0b54\u1acf-\u1af0]/u,
|
|
676
676
|
supplementaryIdentifierStartCodes=[1979,4,385,25,1388,2,18,21,3100,0,678,43,22,0,1662,0,6,10,209,310,18458,24,3,24,287,4,6146,7,1239,4,47,23,96,114,14,913,15,50,8017,5,64,0,9534,0,2169,5,7,86,15,6,55,50,1729,30,2,2,2,1,2,6,3,4,10,1,53307,5,223,0,5764,11,21763,4297,39815,11327],supplementaryIdentifierCodes=[3787,4,33,11,3173,7,633,9,7,0,45879,1,296,2,9,1,3,0,33,1,5218,0,3,0,8,1,6,0];function isInSupplementarySet(code2,set2){let pos=65536;for(let i=0,length=set2.length;i<length;i+=2){if(pos+=set2[i],
|
|
677
677
|
pos>code2)return!1;if(pos+=set2[i+1],pos>=code2)return!0}return!1}function isIdentifierStart(code2){return code2<65?code2===36:code2<=90?!0:code2<97?code2===95:code2<=122?!0:code2<=65535?code2>=170&&bmpIdentifierStart.test(String.fromCharCode(code2)):!isNaN(code2)&&code2<=1114111&&(bmpIdentifierStart.test(String.fromCodePoint(code2))||isInSupplementarySet(code2,supplementaryIdentifierStartCodes))}function isIdentifierChar(code2){return code2<48?code2===36:code2<58?!0:code2<65?!1:code2<=90?!0:code2<
|
|
@@ -699,36 +699,36 @@ e `this` parameter must be the first function parameter.",ThisParamNoDefault:"Th
|
|
|
699
699
|
Unexpected reserved type ${reservedType}.`,UnexpectedReservedUnderscore:"`_` is only allowed as a type argument to call or new.",UnexpectedSpaceBetweenModuloChecks:"Spaces between `%` and `checks` are not allowed here.",UnexpectedSpreadType:"Spread operator cannot appear in class or interface definitions.",UnexpectedSubtractionOperand:'Unexpected token, expected "number" or "bigint".',UnexpectedTokenAfterTypeParameter:"Expected an arrow function after this type parameter declaration.",UnexpectedTypeParameterBeforeAsyncArrowFunction:"\
|
|
700
700
|
Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",UnsupportedDeclareExportKind:({unsupportedExportKind,suggestion})=>`\`declare export ${unsupportedExportKind}\` is not supported. Use \`${suggestion}\` instead.`,UnsupportedStatementInDeclareModule:"Only declares and type imports are allowed inside declare module.",UnterminatedFlowComment:"Unterminated flow-comment."},FlowErrors=ParseErrorEnum`flow`(FlowErrorTemplates);function isEsModuleType(bodyElement){
|
|
701
701
|
return bodyElement.type==="DeclareExportAllDeclaration"||bodyElement.type==="DeclareExportDeclaration"&&(!bodyElement.declaration||bodyElement.declaration.type!=="TypeAlias"&&bodyElement.declaration.type!=="InterfaceDeclaration")}function hasTypeImportKind(node){return node.importKind==="type"||node.importKind==="typeof"}var exportSuggestions={const:"declare export var",let:"declare export var",type:"export type",interface:"export interface"};function partition(list3,test){let list1=[],list22=[];
|
|
702
|
-
for(let i=0;i<list3.length;i++)(test(list3[i],i,list3)?list1:list22).push(list3[i]);return[list1,list22]}var FLOW_PRAGMA_REGEX=/\*?\s*@((?:no)?flow)\b/,flow=superClass=>class extends superClass{flowPragma=void 0;getScopeHandler(){return FlowScopeHandler}shouldParseTypes(){return this.getPluginOption("flow","all")||this.flowPragma==="flow"}finishToken(type,val){type!==
|
|
702
|
+
for(let i=0;i<list3.length;i++)(test(list3[i],i,list3)?list1:list22).push(list3[i]);return[list1,list22]}var FLOW_PRAGMA_REGEX=/\*?\s*@((?:no)?flow)\b/,flow=superClass=>class extends superClass{flowPragma=void 0;getScopeHandler(){return FlowScopeHandler}shouldParseTypes(){return this.getPluginOption("flow","all")||this.flowPragma==="flow"}finishToken(type,val){type!==131&&type!==9&&type!==24&&this.flowPragma===void 0&&(this.flowPragma=null),super.finishToken(type,val)}addComment(comment){if(this.
|
|
703
703
|
flowPragma===void 0){let matches=FLOW_PRAGMA_REGEX.exec(comment.value);if(matches)if(matches[1]==="flow")this.flowPragma="flow";else if(matches[1]==="noflow")this.flowPragma="noflow";else throw new Error("Unexpected flow pragma")}super.addComment(comment)}flowParseTypeInitialiser(tok){let oldInType=this.state.inType;this.state.inType=!0,this.expect(tok||10);let type=this.flowParseType();return this.state.inType=oldInType,type}flowParsePredicate(){let node=this.startNode(),moduloLoc=this.state.startLoc;
|
|
704
|
-
return this.next(),this.expectContextual(
|
|
704
|
+
return this.next(),this.expectContextual(107),this.state.lastTokStartLoc.index>moduloLoc.index+1&&this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks,moduloLoc),this.eat(6)?(node.value=super.parseExpression(),this.expect(7),this.finishNode(node,"DeclaredPredicate")):this.finishNode(node,"InferredPredicate")}flowParseTypeAndPredicateInitialiser(allowLonePredicate){let oldInType=this.state.inType;this.state.inType=!0,this.expect(10);let type=null,predicate=null;return allowLonePredicate&&this.
|
|
705
705
|
match(50)?(this.state.inType=oldInType,predicate=this.flowParsePredicate()):(type=this.flowParseType(),this.state.inType=oldInType,this.match(50)&&(predicate=this.flowParsePredicate())),[type,predicate]}flowParseDeclareClass(node){return this.next(),this.flowParseInterfaceish(node,!0),this.finishNode(node,"DeclareClass")}flowParseDeclareFunction(node){this.next();let id2=node.id=this.parseIdentifier(),typeNode=this.startNode(),typeContainer=this.startNode();this.match(43)?typeNode.typeParameters=
|
|
706
706
|
this.flowParseTypeParameterDeclaration():typeNode.typeParameters=null,this.expect(6);let tmp=this.flowParseFunctionTypeParams();return typeNode.params=tmp.params,typeNode.rest=tmp.rest,typeNode.this=tmp._this,this.expect(7),[typeNode.returnType,node.predicate]=this.flowParseTypeAndPredicateInitialiser(!1),typeContainer.typeAnnotation=this.finishNode(typeNode,"FunctionTypeAnnotation"),id2.typeAnnotation=this.finishNode(typeContainer,"TypeAnnotation"),this.resetEndLocation(id2),this.semicolon(),this.
|
|
707
|
-
scope.declareName(node.id.name,2048,node.id.start),this.finishNode(node,"DeclareFunction")}flowParseDeclare(node,insideModule){if(this.match(76))return this.flowParseDeclareClass(node);if(this.match(64))return this.flowParseDeclareFunction(node);if(this.match(70))return this.flowParseDeclareVariable(node);if(this.eatContextual(
|
|
708
|
-
node));if(this.isContextual(
|
|
709
|
-
finishNode(node,"DeclareVariable")}flowParseDeclareModule(node){this.scope.enter(0),this.match(
|
|
710
|
-
|
|
707
|
+
scope.declareName(node.id.name,2048,node.id.start),this.finishNode(node,"DeclareFunction")}flowParseDeclare(node,insideModule){if(this.match(76))return this.flowParseDeclareClass(node);if(this.match(64))return this.flowParseDeclareFunction(node);if(this.match(70))return this.flowParseDeclareVariable(node);if(this.eatContextual(124))return this.match(12)?this.flowParseDeclareModuleExports(node):(insideModule&&this.raise(FlowErrors.NestedDeclareModule,this.state.lastTokStartLoc),this.flowParseDeclareModule(
|
|
708
|
+
node));if(this.isContextual(127))return this.flowParseDeclareTypeAlias(node);if(this.isContextual(128))return this.flowParseDeclareOpaqueType(node);if(this.isContextual(126))return this.flowParseDeclareInterface(node);if(this.match(78))return this.flowParseDeclareExportDeclaration(node,insideModule);throw this.unexpected()}flowParseDeclareVariable(node){return this.next(),node.id=this.flowParseTypeAnnotatableIdentifier(),this.scope.declareName(node.id.name,5,node.id.start),this.semicolon(),this.
|
|
709
|
+
finishNode(node,"DeclareVariable")}flowParseDeclareModule(node){this.scope.enter(0),this.match(131)?node.id=super.parseExprAtom():node.id=this.parseIdentifier();let bodyNode=this.startNode(),body=bodyNode.body=[];for(this.expect(2);!this.match(4);){let bodyNode2=this.startNode();this.match(79)?(this.next(),!this.isContextual(127)&&!this.match(83)&&this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule,this.state.lastTokStartLoc),body.push(super.parseImport(bodyNode2))):(this.expectContextual(
|
|
710
|
+
122,FlowErrors.UnsupportedStatementInDeclareModule),body.push(this.flowParseDeclare(bodyNode2,!0)))}this.scope.exit(),this.expect(4),node.body=this.finishNode(bodyNode,"BlockStatement");let kind=null,hasModuleExport=!1;return body.forEach(bodyElement=>{isEsModuleType(bodyElement)?(kind==="CommonJS"&&this.raise(FlowErrors.AmbiguousDeclareModuleKind,bodyElement),kind="ES"):bodyElement.type==="DeclareModuleExports"&&(hasModuleExport&&this.raise(FlowErrors.DuplicateDeclareModuleExports,bodyElement),
|
|
711
711
|
kind==="ES"&&this.raise(FlowErrors.AmbiguousDeclareModuleKind,bodyElement),kind="CommonJS",hasModuleExport=!0)}),node.kind=kind||"CommonJS",this.finishNode(node,"DeclareModule")}flowParseDeclareExportDeclaration(node,insideModule){if(this.expect(78),this.eat(61))return this.match(64)||this.match(76)?node.declaration=this.flowParseDeclare(this.startNode()):(node.declaration=this.flowParseType(),this.semicolon()),node.default=!0,this.finishNode(node,"DeclareExportDeclaration");if(this.match(71)||this.
|
|
712
|
-
isLet()||(this.isContextual(
|
|
713
|
-
|
|
712
|
+
isLet()||(this.isContextual(127)||this.isContextual(126))&&!insideModule){let label3=this.state.value;throw this.raise(FlowErrors.UnsupportedDeclareExportKind,this.state.startLoc,{unsupportedExportKind:label3,suggestion:exportSuggestions[label3]})}if(this.match(70)||this.match(64)||this.match(76)||this.isContextual(128))return node.declaration=this.flowParseDeclare(this.startNode()),node.default=!1,this.finishNode(node,"DeclareExportDeclaration");if(this.match(51)||this.match(2)||this.isContextual(
|
|
713
|
+
126)||this.isContextual(127)||this.isContextual(128)){let result=this.parseExport(node,null);return result.type==="ExportNamedDeclaration"?(result.default=!1,delete result.exportKind,this.castNodeTo(result,"DeclareExportDeclaration")):this.castNodeTo(result,"DeclareExportAllDeclaration")}throw this.unexpected()}flowParseDeclareModuleExports(node){return this.next(),this.expectContextual(108),node.typeAnnotation=this.flowParseTypeAnnotation(),this.semicolon(),this.finishNode(node,"DeclareModuleEx\
|
|
714
714
|
ports")}flowParseDeclareTypeAlias(node){this.next();let finished=this.flowParseTypeAlias(node);return this.castNodeTo(finished,"DeclareTypeAlias"),finished}flowParseDeclareOpaqueType(node){return this.next(),this.flowParseOpaqueType(node,!0)}flowParseDeclareInterface(node){return this.next(),this.flowParseInterfaceish(node,!1),this.finishNode(node,"DeclareInterface")}flowParseInterfaceish(node,isClass){if(node.id=this.flowParseRestrictedIdentifier(!isClass,!0),this.scope.declareName(node.id.name,
|
|
715
|
-
isClass?17:8201,node.id.start),this.match(43)?node.typeParameters=this.flowParseTypeParameterDeclaration():node.typeParameters=null,node.extends=[],this.eat(77))do node.extends.push(this.flowParseInterfaceExtends());while(!isClass&&this.eat(8));if(isClass){let implemented=[],mixins=[];if(this.eatContextual(
|
|
715
|
+
isClass?17:8201,node.id.start),this.match(43)?node.typeParameters=this.flowParseTypeParameterDeclaration():node.typeParameters=null,node.extends=[],this.eat(77))do node.extends.push(this.flowParseInterfaceExtends());while(!isClass&&this.eat(8));if(isClass){let implemented=[],mixins=[];if(this.eatContextual(114))do mixins.push(this.flowParseInterfaceExtends());while(this.eat(8));if(this.eatContextual(110))do implemented.push(this.flowParseClassImplements());while(this.eat(8));node.implements=implemented,
|
|
716
716
|
node.mixins=mixins}node.body=this.flowParseObjectType({allowStatic:isClass,allowExact:!1,allowSpread:!1,allowProto:isClass,allowInexact:!1})}flowParseInterfaceExtends(){let node=this.startNode();return node.id=this.flowParseQualifiedTypeIdentifier(),this.match(43)?node.typeParameters=this.flowParseTypeParameterInstantiation():node.typeParameters=null,this.finishNode(node,"InterfaceExtends")}flowParseInterface(node){return this.flowParseInterfaceish(node,!1),this.finishNode(node,"InterfaceDeclara\
|
|
717
717
|
tion")}checkNotUnderscore(word){word==="_"&&this.raise(FlowErrors.UnexpectedReservedUnderscore,this.state.startLoc)}checkReservedType(word,startLoc,declaration){reservedTypes.has(word)&&this.raise(declaration?FlowErrors.AssignReservedType:FlowErrors.UnexpectedReservedType,startLoc,{reservedType:word})}flowParseRestrictedIdentifierName(liberal,declaration){return this.checkReservedType(this.state.value,this.state.startLoc,declaration),this.parseIdentifierName(liberal)}flowParseRestrictedIdentifier(liberal,declaration){
|
|
718
718
|
let node=this.startNode(),name=this.flowParseRestrictedIdentifierName(liberal,declaration);return this.createIdentifier(node,name)}flowParseTypeAlias(node){return node.id=this.flowParseRestrictedIdentifier(!1,!0),this.scope.declareName(node.id.name,8201,node.id.start),this.match(43)?node.typeParameters=this.flowParseTypeParameterDeclaration():node.typeParameters=null,node.right=this.flowParseTypeInitialiser(25),this.semicolon(),this.finishNode(node,"TypeAlias")}flowParseOpaqueType(node,declare){
|
|
719
|
-
return this.expectContextual(
|
|
719
|
+
return this.expectContextual(127),node.id=this.flowParseRestrictedIdentifier(!0,!0),this.scope.declareName(node.id.name,8201,node.id.start),this.match(43)?node.typeParameters=this.flowParseTypeParameterDeclaration():node.typeParameters=null,node.supertype=null,this.match(10)&&(node.supertype=this.flowParseTypeInitialiser(10)),node.impltype=null,declare||(node.impltype=this.flowParseTypeInitialiser(25)),this.semicolon(),this.finishNode(node,declare?"DeclareOpaqueType":"OpaqueType")}flowParseTypeParameterBound(){
|
|
720
720
|
if(this.match(10)||this.isContextual(77)){let node=this.startNode();return this.next(),node.typeAnnotation=this.flowParseType(),this.finishNode(node,"TypeAnnotation")}}flowParseTypeParameter(requireDefault=!1){let nodeStartLoc=this.state.startLoc,node=this.startNode(),variance=this.flowParseVariance();return node.name=this.flowParseRestrictedIdentifierName(),node.variance=variance,node.bound=this.flowParseTypeParameterBound(),this.match(25)?(this.eat(25),node.default=this.flowParseType()):requireDefault&&
|
|
721
|
-
this.raise(FlowErrors.MissingTypeParamDefault,nodeStartLoc),this.finishNode(node,"TypeParameter")}flowParseTypeParameterDeclaration(){let oldInType=this.state.inType,node=this.startNode();node.params=[],this.state.inType=!0,this.match(43)||this.match(
|
|
721
|
+
this.raise(FlowErrors.MissingTypeParamDefault,nodeStartLoc),this.finishNode(node,"TypeParameter")}flowParseTypeParameterDeclaration(){let oldInType=this.state.inType,node=this.startNode();node.params=[],this.state.inType=!0,this.match(43)||this.match(139)?this.next():this.unexpected();let defaultRequired=!1;do{let typeParameter=this.flowParseTypeParameter(defaultRequired);node.params.push(typeParameter),typeParameter.default&&(defaultRequired=!0),this.match(44)||this.expect(8)}while(!this.match(
|
|
722
722
|
44));return this.expect(44),this.state.inType=oldInType,this.finishNode(node,"TypeParameterDeclaration")}flowInTopLevelContext(cb){if(this.curContext()!==types.brace){let oldContext=this.state.context;this.state.context=[oldContext[0]];try{return cb()}finally{this.state.context=oldContext}}else return cb()}flowParseTypeParameterInstantiationInExpression(){if(this.reScan_lt()===43)return this.flowParseTypeParameterInstantiation()}flowParseTypeParameterInstantiation(){let node=this.startNode(),oldInType=this.
|
|
723
723
|
state.inType;return this.state.inType=!0,node.params=[],this.flowInTopLevelContext(()=>{this.expect(43);let oldNoAnonFunctionType=this.state.noAnonFunctionType;for(this.state.noAnonFunctionType=!1;!this.match(44);)node.params.push(this.flowParseType()),this.match(44)||this.expect(8);this.state.noAnonFunctionType=oldNoAnonFunctionType}),this.state.inType=oldInType,!this.state.inType&&this.curContext()===types.brace&&this.reScan_lt_gt(),this.expect(44),this.finishNode(node,"TypeParameterInstantiat\
|
|
724
|
-
ion")}flowParseTypeParameterInstantiationCallOrNew(){if(this.reScan_lt()!==43)return null;let node=this.startNode(),oldInType=this.state.inType;for(node.params=[],this.state.inType=!0,this.expect(43);!this.match(44);)node.params.push(this.flowParseTypeOrImplicitInstantiation()),this.match(44)||this.expect(8);return this.expect(44),this.state.inType=oldInType,this.finishNode(node,"TypeParameterInstantiation")}flowParseInterfaceType(){let node=this.startNode();if(this.expectContextual(
|
|
725
|
-
[],this.eat(77))do node.extends.push(this.flowParseInterfaceExtends());while(this.eat(8));return node.body=this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!1,allowProto:!1,allowInexact:!1}),this.finishNode(node,"InterfaceTypeAnnotation")}flowParseObjectPropertyKey(){return this.match(
|
|
724
|
+
ion")}flowParseTypeParameterInstantiationCallOrNew(){if(this.reScan_lt()!==43)return null;let node=this.startNode(),oldInType=this.state.inType;for(node.params=[],this.state.inType=!0,this.expect(43);!this.match(44);)node.params.push(this.flowParseTypeOrImplicitInstantiation()),this.match(44)||this.expect(8);return this.expect(44),this.state.inType=oldInType,this.finishNode(node,"TypeParameterInstantiation")}flowParseInterfaceType(){let node=this.startNode();if(this.expectContextual(126),node.extends=
|
|
725
|
+
[],this.eat(77))do node.extends.push(this.flowParseInterfaceExtends());while(this.eat(8));return node.body=this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!1,allowProto:!1,allowInexact:!1}),this.finishNode(node,"InterfaceTypeAnnotation")}flowParseObjectPropertyKey(){return this.match(132)||this.match(131)?super.parseExprAtom():this.parseIdentifier(!0)}flowParseObjectTypeIndexer(node,isStatic,variance){return node.static=isStatic,this.lookahead().type===10?(node.id=this.parseIdentifier(
|
|
726
726
|
!0),node.key=this.flowParseTypeInitialiser()):(node.id=null,node.key=this.flowParseType()),this.expect(1),node.value=this.flowParseTypeInitialiser(),node.variance=variance,this.finishNode(node,"ObjectTypeIndexer")}flowParseObjectTypeInternalSlot(node,isStatic){return node.static=isStatic,node.id=this.parseIdentifier(!0),this.expect(1),this.expect(1),this.match(43)||this.match(6)?(node.method=!0,node.optional=!1,node.value=this.flowParseObjectTypeMethodish(this.startNodeAtNode(node))):(node.method=
|
|
727
727
|
!1,this.eat(13)&&(node.optional=!0),node.value=this.flowParseTypeInitialiser()),this.finishNode(node,"ObjectTypeInternalSlot")}flowParseObjectTypeMethodish(node){for(node.params=[],node.rest=null,node.typeParameters=null,node.this=null,this.match(43)&&(node.typeParameters=this.flowParseTypeParameterDeclaration()),this.expect(6),this.match(74)&&(node.this=this.flowParseFunctionTypeParam(!0),node.this.name=null,this.match(7)||this.expect(8));!this.match(7)&&!this.match(17);)node.params.push(this.flowParseFunctionTypeParam(
|
|
728
728
|
!1)),this.match(7)||this.expect(8);return this.eat(17)&&(node.rest=this.flowParseFunctionTypeParam(!1)),this.expect(7),node.returnType=this.flowParseTypeInitialiser(),this.finishNode(node,"FunctionTypeAnnotation")}flowParseObjectTypeCallProperty(node,isStatic){let valueNode=this.startNode();return node.static=isStatic,node.value=this.flowParseObjectTypeMethodish(valueNode),this.finishNode(node,"ObjectTypeCallProperty")}flowParseObjectType({allowStatic,allowExact,allowSpread,allowProto,allowInexact}){
|
|
729
|
-
let oldInType=this.state.inType;this.state.inType=!0;let nodeStart=this.startNode();nodeStart.callProperties=[],nodeStart.properties=[],nodeStart.indexers=[],nodeStart.internalSlots=[];let endDelim,exact,inexact=!1;for(allowExact&&this.match(3)?(this.expect(3),endDelim=5,exact=!0):(this.expect(2),endDelim=4,exact=!1),nodeStart.exact=exact;!this.match(endDelim);){let isStatic=!1,protoStartLoc=null,inexactStartLoc=null,node=this.startNode();if(allowProto&&this.isContextual(
|
|
730
|
-
lookahead();lookahead.type!==10&&lookahead.type!==13&&(this.next(),protoStartLoc=this.state.startLoc,allowStatic=!1)}if(allowStatic&&this.isContextual(
|
|
731
|
-
indexers.push(this.flowParseObjectTypeIndexer(node,isStatic,variance));else if(this.match(6)||this.match(43))protoStartLoc!=null&&this.unexpected(protoStartLoc),variance&&this.unexpected(variance.start),nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node,isStatic));else{let kind="init";if(this.isContextual(
|
|
729
|
+
let oldInType=this.state.inType;this.state.inType=!0;let nodeStart=this.startNode();nodeStart.callProperties=[],nodeStart.properties=[],nodeStart.indexers=[],nodeStart.internalSlots=[];let endDelim,exact,inexact=!1;for(allowExact&&this.match(3)?(this.expect(3),endDelim=5,exact=!0):(this.expect(2),endDelim=4,exact=!1),nodeStart.exact=exact;!this.match(endDelim);){let isStatic=!1,protoStartLoc=null,inexactStartLoc=null,node=this.startNode();if(allowProto&&this.isContextual(115)){let lookahead=this.
|
|
730
|
+
lookahead();lookahead.type!==10&&lookahead.type!==13&&(this.next(),protoStartLoc=this.state.startLoc,allowStatic=!1)}if(allowStatic&&this.isContextual(103)){let lookahead=this.lookahead();lookahead.type!==10&&lookahead.type!==13&&(this.next(),isStatic=!0)}let variance=this.flowParseVariance();if(this.eat(0))protoStartLoc!=null&&this.unexpected(protoStartLoc),this.eat(0)?(variance&&this.unexpected(variance.start),nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node,isStatic))):nodeStart.
|
|
731
|
+
indexers.push(this.flowParseObjectTypeIndexer(node,isStatic,variance));else if(this.match(6)||this.match(43))protoStartLoc!=null&&this.unexpected(protoStartLoc),variance&&this.unexpected(variance.start),nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node,isStatic));else{let kind="init";if(this.isContextual(96)||this.isContextual(101)){let lookahead=this.lookahead();tokenIsLiteralPropertyName(lookahead.type)&&(kind=this.state.value,this.next())}let propOrInexact=this.flowParseObjectTypeProperty(
|
|
732
732
|
node,isStatic,protoStartLoc,variance,kind,allowSpread,allowInexact??!exact);propOrInexact===null?(inexact=!0,inexactStartLoc=this.state.lastTokStartLoc):nodeStart.properties.push(propOrInexact)}this.flowObjectTypeSemicolon(),inexactStartLoc&&!this.match(4)&&!this.match(5)&&this.raise(FlowErrors.UnexpectedExplicitInexactInObject,inexactStartLoc)}this.expect(endDelim),allowSpread&&(nodeStart.inexact=inexact);let out=this.finishNode(nodeStart,"ObjectTypeAnnotation");return this.state.inType=oldInType,
|
|
733
733
|
out}flowParseObjectTypeProperty(node,isStatic,protoStartLoc,variance,kind,allowSpread,allowInexact){if(this.eat(17))return this.match(8)||this.match(9)||this.match(4)||this.match(5)?(allowSpread?allowInexact||this.raise(FlowErrors.InexactInsideExact,this.state.lastTokStartLoc):this.raise(FlowErrors.InexactInsideNonObject,this.state.lastTokStartLoc),variance&&this.raise(FlowErrors.InexactVariance,variance),null):(allowSpread||this.raise(FlowErrors.UnexpectedSpreadType,this.state.lastTokStartLoc),
|
|
734
734
|
protoStartLoc!=null&&this.unexpected(protoStartLoc),variance&&this.raise(FlowErrors.SpreadVariance,variance),node.argument=this.flowParseType(),this.finishNode(node,"ObjectTypeSpreadProperty"));{node.key=this.flowParseObjectPropertyKey(),node.static=isStatic,node.proto=protoStartLoc!=null,node.kind=kind;let optional=!1;return this.match(43)||this.match(6)?(node.method=!0,protoStartLoc!=null&&this.unexpected(protoStartLoc),variance&&this.unexpected(variance.start),node.value=this.flowParseObjectTypeMethodish(
|
|
@@ -742,48 +742,48 @@ eat(17)&&(rest=this.flowParseFunctionTypeParam(!1)),{params,rest,_this}}flowIden
|
|
|
742
742
|
"StringTypeAnnotation");case"symbol":return this.finishNode(node,"SymbolTypeAnnotation");default:return this.checkNotUnderscore(id2.name),this.flowParseGenericType(startLoc,id2)}}flowParsePrimaryType(){let startLoc=this.state.startLoc,node=this.startNode(),tmp,type,isGroupedType=!1,oldNoAnonFunctionType=this.state.noAnonFunctionType;switch(this.state.type){case 2:return this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!0,allowProto:!1,allowInexact:!0});case 3:return this.flowParseObjectType(
|
|
743
743
|
{allowStatic:!1,allowExact:!0,allowSpread:!0,allowProto:!1,allowInexact:!1});case 0:return this.state.noAnonFunctionType=!1,type=this.flowParseTupleType(),this.state.noAnonFunctionType=oldNoAnonFunctionType,type;case 43:{let node2=this.startNode();return node2.typeParameters=this.flowParseTypeParameterDeclaration(),this.expect(6),tmp=this.flowParseFunctionTypeParams(),node2.params=tmp.params,node2.rest=tmp.rest,node2.this=tmp._this,this.expect(7),this.expect(15),node2.returnType=this.flowParseType(),
|
|
744
744
|
this.finishNode(node2,"FunctionTypeAnnotation")}case 6:{let node2=this.startNode();if(this.next(),!this.match(7)&&!this.match(17))if(tokenIsIdentifier(this.state.type)||this.match(74)){let token=this.lookahead().type;isGroupedType=token!==13&&token!==10}else isGroupedType=!0;if(isGroupedType){if(this.state.noAnonFunctionType=!1,type=this.flowParseType(),this.state.noAnonFunctionType=oldNoAnonFunctionType,this.state.noAnonFunctionType||!(this.match(8)||this.match(7)&&this.lookahead().type===15))return this.
|
|
745
|
-
expect(7),type;this.eat(8)}return type?tmp=this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]):tmp=this.flowParseFunctionTypeParams(),node2.params=tmp.params,node2.rest=tmp.rest,node2.this=tmp._this,this.expect(7),this.expect(15),node2.returnType=this.flowParseType(),node2.typeParameters=null,this.finishNode(node2,"FunctionTypeAnnotation")}case
|
|
746
|
-
this.next(),this.finishNode(node,"BooleanLiteralTypeAnnotation");case 49:if(this.state.value==="-"){if(this.next(),this.match(
|
|
747
|
-
n");case
|
|
748
|
-
return this.next(),super.createIdentifier(node,label3)}else if(tokenIsIdentifier(this.state.type))return this.isContextual(
|
|
745
|
+
expect(7),type;this.eat(8)}return type?tmp=this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]):tmp=this.flowParseFunctionTypeParams(),node2.params=tmp.params,node2.rest=tmp.rest,node2.this=tmp._this,this.expect(7),this.expect(15),node2.returnType=this.flowParseType(),node2.typeParameters=null,this.finishNode(node2,"FunctionTypeAnnotation")}case 131:return this.parseLiteral(this.state.value,"StringLiteralTypeAnnotation");case 81:case 82:return node.value=this.match(81),
|
|
746
|
+
this.next(),this.finishNode(node,"BooleanLiteralTypeAnnotation");case 49:if(this.state.value==="-"){if(this.next(),this.match(132))return this.parseLiteralAtNode(-this.state.value,"NumberLiteralTypeAnnotation",node);if(this.match(133))return this.parseLiteralAtNode(-this.state.value,"BigIntLiteralTypeAnnotation",node);throw this.raise(FlowErrors.UnexpectedSubtractionOperand,this.state.startLoc)}throw this.unexpected();case 132:return this.parseLiteral(this.state.value,"NumberLiteralTypeAnnotatio\
|
|
747
|
+
n");case 133:return this.parseLiteral(this.state.value,"BigIntLiteralTypeAnnotation");case 84:return this.next(),this.finishNode(node,"VoidTypeAnnotation");case 80:return this.next(),this.finishNode(node,"NullLiteralTypeAnnotation");case 74:return this.next(),this.finishNode(node,"ThisTypeAnnotation");case 51:return this.next(),this.finishNode(node,"ExistsTypeAnnotation");case 83:return this.flowParseTypeofType();default:if(tokenIsKeyword(this.state.type)){let label3=tokenLabelName(this.state.type);
|
|
748
|
+
return this.next(),super.createIdentifier(node,label3)}else if(tokenIsIdentifier(this.state.type))return this.isContextual(126)?this.flowParseInterfaceType():this.flowIdentToTypeAnnotation(startLoc,node,this.parseIdentifier())}throw this.unexpected()}flowParsePostfixType(){let startLoc=this.state.startLoc,type=this.flowParsePrimaryType(),seenOptionalIndexedAccess=!1;for(;(this.match(0)||this.match(14))&&!this.canInsertSemicolon();){let node=this.startNodeAt(startLoc),optional=this.eat(14);seenOptionalIndexedAccess=
|
|
749
749
|
seenOptionalIndexedAccess||optional,this.expect(0),!optional&&this.match(1)?(node.elementType=type,this.next(),type=this.finishNode(node,"ArrayTypeAnnotation")):(node.objectType=type,node.indexType=this.flowParseType(),this.expect(1),seenOptionalIndexedAccess?(node.optional=optional,type=this.finishNode(node,"OptionalIndexedAccessType")):type=this.finishNode(node,"IndexedAccessType"))}return type}flowParsePrefixType(){let node=this.startNode();return this.eat(13)?(node.typeAnnotation=this.flowParsePrefixType(),
|
|
750
750
|
this.finishNode(node,"NullableTypeAnnotation")):this.flowParsePostfixType()}flowParseAnonFunctionWithoutParens(){let param=this.flowParsePrefixType();if(!this.state.noAnonFunctionType&&this.eat(15)){let node=this.startNodeAtNode(param);return node.params=[this.reinterpretTypeAsFunctionTypeParam(param)],node.rest=null,node.this=null,node.returnType=this.flowParseType(),node.typeParameters=null,this.finishNode(node,"FunctionTypeAnnotation")}return param}flowParseIntersectionType(){let node=this.startNode();
|
|
751
751
|
this.eat(41);let type=this.flowParseAnonFunctionWithoutParens();for(node.types=[type];this.eat(41);)node.types.push(this.flowParseAnonFunctionWithoutParens());return node.types.length===1?type:this.finishNode(node,"IntersectionTypeAnnotation")}flowParseUnionType(){let node=this.startNode();this.eat(39);let type=this.flowParseIntersectionType();for(node.types=[type];this.eat(39);)node.types.push(this.flowParseIntersectionType());return node.types.length===1?type:this.finishNode(node,"UnionTypeAnn\
|
|
752
|
-
otation")}flowParseType(){let oldInType=this.state.inType;this.state.inType=!0;let type=this.flowParseUnionType();return this.state.inType=oldInType,type}flowParseTypeOrImplicitInstantiation(){if(this.state.type===
|
|
752
|
+
otation")}flowParseType(){let oldInType=this.state.inType;this.state.inType=!0;let type=this.flowParseUnionType();return this.state.inType=oldInType,type}flowParseTypeOrImplicitInstantiation(){if(this.state.type===129&&this.state.value==="_"){let startLoc=this.state.startLoc,node=this.parseIdentifier();return this.flowParseGenericType(startLoc,node)}else return this.flowParseType()}flowParseTypeAnnotation(){let node=this.startNode();return node.typeAnnotation=this.flowParseTypeInitialiser(),this.
|
|
753
753
|
finishNode(node,"TypeAnnotation")}flowParseTypeAnnotatableIdentifier(){let node=this.startNode(),name=this.parseIdentifierName();return this.match(10)&&(node.typeAnnotation=this.flowParseTypeAnnotation()),this.createIdentifier(node,name)}typeCastToParameter(node){return node.expression.typeAnnotation=node.typeAnnotation,this.resetEndLocationFromNode(node.expression,node.typeAnnotation),node.expression}flowParseVariance(){let variance=null;return this.match(49)?(variance=this.startNode(),this.state.
|
|
754
754
|
value==="+"?variance.kind="plus":variance.kind="minus",this.next(),this.finishNode(variance,"Variance")):variance}parseFunctionBody(node,allowExpressionBody,isMethod=!1){if(allowExpressionBody){this.forwardNoArrowParamsConversionAt(node,()=>super.parseFunctionBody(node,!0,isMethod));return}super.parseFunctionBody(node,!1,isMethod)}parseFunctionBodyAndFinish(node,type,isMethod=!1){if(this.match(10)){let typeNode=this.startNode();type==="FunctionDeclaration"||type==="FunctionExpression"||type==="A\
|
|
755
|
-
rrowFunctionExpression"?[typeNode.typeAnnotation,node.predicate]=this.flowParseTypeAndPredicateInitialiser(!0):typeNode.typeAnnotation=this.flowParseTypeInitialiser(),node.returnType=typeNode.typeAnnotation?this.finishNode(typeNode,"TypeAnnotation"):null}return super.parseFunctionBodyAndFinish(node,type,isMethod)}parseStatementLike(flags){if(this.state.strict&&this.isContextual(
|
|
756
|
-
next(),this.flowParseInterface(node)}}else if(this.isContextual(
|
|
757
|
-
node)}else if(tokenIsIdentifier(this.state.type)){if(expr.name==="interface")return this.flowParseInterface(node);if(expr.name==="type")return this.flowParseTypeAlias(node);if(expr.name==="opaque")return this.flowParseOpaqueType(node,!1)}}return super.parseExpressionStatement(node,expr)}shouldParseExportDeclaration(){let{type}=this.state;return type===
|
|
758
|
-
state;return type===
|
|
755
|
+
rrowFunctionExpression"?[typeNode.typeAnnotation,node.predicate]=this.flowParseTypeAndPredicateInitialiser(!0):typeNode.typeAnnotation=this.flowParseTypeInitialiser(),node.returnType=typeNode.typeAnnotation?this.finishNode(typeNode,"TypeAnnotation"):null}return super.parseFunctionBodyAndFinish(node,type,isMethod)}parseStatementLike(flags){if(this.state.strict&&this.isContextual(126)){let lookahead=this.lookahead();if(tokenIsKeywordOrIdentifier(lookahead.type)){let node=this.startNode();return this.
|
|
756
|
+
next(),this.flowParseInterface(node)}}else if(this.isContextual(123)){let node=this.startNode();return this.next(),this.flowParseEnumDeclaration(node)}let stmt=super.parseStatementLike(flags);return this.flowPragma===void 0&&!this.isValidDirective(stmt)&&(this.flowPragma=null),stmt}parseExpressionStatement(node,expr,flags){if(expr.type==="Identifier"){if(expr.name==="declare"){if(this.match(76)||tokenIsIdentifier(this.state.type)||this.match(64)||this.match(70)||this.match(78))return this.flowParseDeclare(
|
|
757
|
+
node)}else if(tokenIsIdentifier(this.state.type)){if(expr.name==="interface")return this.flowParseInterface(node);if(expr.name==="type")return this.flowParseTypeAlias(node);if(expr.name==="opaque")return this.flowParseOpaqueType(node,!1)}}return super.parseExpressionStatement(node,expr,flags)}shouldParseExportDeclaration(){let{type}=this.state;return type===123||tokenIsFlowInterfaceOrTypeOrOpaque(type)?!this.state.containsEsc:super.shouldParseExportDeclaration()}isExportDefaultSpecifier(){let{type}=this.
|
|
758
|
+
state;return type===123||tokenIsFlowInterfaceOrTypeOrOpaque(type)?this.state.containsEsc:super.isExportDefaultSpecifier()}parseExportDefaultExpression(){if(this.isContextual(123)){let node=this.startNode();return this.next(),this.flowParseEnumDeclaration(node)}return super.parseExportDefaultExpression()}parseConditional(expr,startLoc,refExpressionErrors){if(!this.match(13))return expr;if(refExpressionErrors!=null){let nextCh=this.lookaheadCharCode();if(nextCh===44||nextCh===61||nextCh===58||nextCh===
|
|
759
759
|
41)return this.setOptionalParametersError(refExpressionErrors),expr}this.expect(13);let state=this.state.clone(),originalNoArrowAt=this.state.noArrowAt,node=this.startNodeAt(startLoc),{consequent,failed}=this.tryParseConditionalConsequent(),result=this.getArrowLikeExpressions(consequent),valid=result[0],invalid2=result[1];if(failed||invalid2.length>0){let noArrowAt=[...originalNoArrowAt];if(invalid2.length>0){this.state=state,this.state.noArrowAt=noArrowAt;for(let i=0;i<invalid2.length;i++)noArrowAt.
|
|
760
760
|
push(invalid2[i].start);({consequent,failed}=this.tryParseConditionalConsequent()),[valid]=this.getArrowLikeExpressions(consequent)}failed&&valid.length>1&&this.raise(FlowErrors.AmbiguousConditionalArrow,state.startLoc),failed&&valid.length===1&&(this.state=state,noArrowAt.push(valid[0].start),this.state.noArrowAt=noArrowAt,{consequent}=this.tryParseConditionalConsequent())}return this.getArrowLikeExpressions(consequent,!0),this.state.noArrowAt=originalNoArrowAt,this.expect(10),node.test=expr,node.
|
|
761
761
|
consequent=consequent,node.alternate=this.forwardNoArrowParamsConversionAt(node,()=>this.parseMaybeAssign()),this.finishNode(node,"ConditionalExpression")}tryParseConditionalConsequent(){this.state.noArrowParamsConversionAt.push(this.state.start);let consequent=this.parseMaybeAssignAllowIn(),failed=!this.match(10);return this.state.noArrowParamsConversionAt.pop(),{consequent,failed}}getArrowLikeExpressions(node,disallowInvalid){let stack=[node],arrows=[];for(;stack.length!==0;){let node2=stack.pop();
|
|
762
762
|
node2.type==="ArrowFunctionExpression"?(node2.typeParameters||!node2.returnType?this.finishArrowValidation(node2):arrows.push(node2),node2.body.type!=="BlockStatement"&&stack.push(node2.body)):node2.type==="ConditionalExpression"&&(stack.push(node2.consequent),stack.push(node2.alternate))}return disallowInvalid?(arrows.forEach(node2=>this.finishArrowValidation(node2)),[arrows,[]]):partition(arrows,node2=>node2.params.every(param=>this.isAssignable(param,!0)))}finishArrowValidation(node){this.toAssignableList(
|
|
763
763
|
node.params,node.extra?.trailingCommaLoc,!1),this.scope.enter(518),super.checkParams(node,!1,!0),this.scope.exit()}forwardNoArrowParamsConversionAt(node,parse2){let result;return this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))?(this.state.noArrowParamsConversionAt.push(this.state.start),result=parse2(),this.state.noArrowParamsConversionAt.pop()):result=parse2(),result}parseParenItem(node,startLoc){let newNode=super.parseParenItem(node,startLoc);if(this.eat(13)&&
|
|
764
764
|
(newNode.optional=!0,this.resetEndLocation(node)),this.match(10)){let typeCastNode=this.startNodeAt(startLoc);return typeCastNode.expression=newNode,typeCastNode.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(typeCastNode,"TypeCastExpression")}return newNode}assertModuleNodeAllowed(node){node.type==="ImportDeclaration"&&(node.importKind==="type"||node.importKind==="typeof")||node.type==="ExportNamedDeclaration"&&node.exportKind==="type"||node.type==="ExportAllDeclaration"&&node.exportKind===
|
|
765
|
-
"type"||super.assertModuleNodeAllowed(node)}parseExportDeclaration(node){if(this.isContextual(
|
|
766
|
-
node.exportKind="type";let declarationNode=this.startNode();return this.next(),this.flowParseInterface(declarationNode)}else if(this.isContextual(
|
|
767
|
-
let{startLoc}=this.state,hasNamespace=super.maybeParseExportNamespaceSpecifier(node);return hasNamespace&&node.exportKind==="type"&&this.unexpected(startLoc),hasNamespace}parseClassId(node,isStatement,optionalId){if((!isStatement||optionalId)&&this.isContextual(
|
|
768
|
-
|
|
769
|
-
@@"+word;(!this.isIterator(word)||!this.state.inType)&&this.raise(Errors.InvalidIdentifier,this.state.curPosition(),{identifierName:fullWord}),this.finishToken(
|
|
765
|
+
"type"||super.assertModuleNodeAllowed(node)}parseExportDeclaration(node){if(this.isContextual(127)){node.exportKind="type";let declarationNode=this.startNode();return this.next(),this.match(2)?(node.specifiers=this.parseExportSpecifiers(!0),super.parseExportFrom(node),null):this.flowParseTypeAlias(declarationNode)}else if(this.isContextual(128)){node.exportKind="type";let declarationNode=this.startNode();return this.next(),this.flowParseOpaqueType(declarationNode,!1)}else if(this.isContextual(126)){
|
|
766
|
+
node.exportKind="type";let declarationNode=this.startNode();return this.next(),this.flowParseInterface(declarationNode)}else if(this.isContextual(123)){node.exportKind="value";let declarationNode=this.startNode();return this.next(),this.flowParseEnumDeclaration(declarationNode)}else return super.parseExportDeclaration(node)}eatExportStar(node){return super.eatExportStar(node)?!0:this.isContextual(127)&&this.lookahead().type===51?(node.exportKind="type",this.next(),this.next(),!0):!1}maybeParseExportNamespaceSpecifier(node){
|
|
767
|
+
let{startLoc}=this.state,hasNamespace=super.maybeParseExportNamespaceSpecifier(node);return hasNamespace&&node.exportKind==="type"&&this.unexpected(startLoc),hasNamespace}parseClassId(node,isStatement,optionalId){if((!isStatement||optionalId)&&this.isContextual(110)){node.id=null;return}super.parseClassId(node,isStatement,optionalId),this.match(43)&&(node.typeParameters=this.flowParseTypeParameterDeclaration())}parseClassMember(classBody,member,state){let{startLoc}=this.state;if(this.isContextual(
|
|
768
|
+
122)){if(super.parseClassMemberFromModifier(classBody,member))return;member.declare=!0}super.parseClassMember(classBody,member,state),member.declare&&(member.type!=="ClassProperty"&&member.type!=="ClassPrivateProperty"&&member.type!=="PropertyDefinition"?this.raise(FlowErrors.DeclareClassElement,startLoc):member.value&&this.raise(FlowErrors.DeclareClassFieldInitializer,member.value))}isIterator(word){return word==="iterator"||word==="asyncIterator"}readIterator(){let word=super.readWord1(),fullWord="\
|
|
769
|
+
@@"+word;(!this.isIterator(word)||!this.state.inType)&&this.raise(Errors.InvalidIdentifier,this.state.curPosition(),{identifierName:fullWord}),this.finishToken(129,fullWord)}getTokenFromCode(code2){let next=this.input.charCodeAt(this.state.pos+1);code2===123&&next===124?this.finishOp(3,2):this.state.inType&&(code2===62||code2===60)?this.finishOp(code2===62?44:43,1):this.state.inType&&code2===63?next===46?this.finishOp(14,2):this.finishOp(13,1):isIteratorStart(code2,next,this.input.charCodeAt(this.
|
|
770
770
|
state.pos+2))?(this.state.pos+=2,this.readIterator()):super.getTokenFromCode(code2)}isAssignable(node,isBinding){return node.type==="TypeCastExpression"?this.isAssignable(node.expression,isBinding):super.isAssignable(node,isBinding)}toAssignable(node,isLHS=!1){!isLHS&&node.type==="AssignmentExpression"&&node.left.type==="TypeCastExpression"&&(node.left=this.typeCastToParameter(node.left)),super.toAssignable(node,isLHS)}toAssignableListItem(exprList,index,isLHS){let node=exprList[index];node.type===
|
|
771
771
|
"TypeCastExpression"&&(exprList[index]=this.typeCastToParameter(node)),super.toAssignableListItem(exprList,index,isLHS)}toReferencedList(exprList,isParenthesizedExpr){for(let i=0;i<exprList.length;i++){let expr=exprList[i];expr?.type==="TypeCastExpression"&&!expr.extra?.parenthesized&&(exprList.length>1||!isParenthesizedExpr)&&this.raise(FlowErrors.TypeCastInPattern,expr.typeAnnotation)}return exprList}parseArrayLike(close,refExpressionErrors){let node=super.parseArrayLike(close,refExpressionErrors);
|
|
772
772
|
return node.type==="ArrayExpression"&&this.toReferencedList(node.elements),node}isValidLVal(type,disallowCallExpression,isParenthesized,binding){return type==="TypeCastExpression"||super.isValidLVal(type,disallowCallExpression,isParenthesized,binding)}parseClassProperty(node){return this.match(10)&&(node.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassProperty(node)}parseClassPrivateProperty(node){return this.match(10)&&(node.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassPrivateProperty(
|
|
773
773
|
node)}isClassMethod(){return this.match(43)||super.isClassMethod()}isClassProperty(){return this.match(10)||super.isClassProperty()}isNonstaticConstructor(method){return!this.match(10)&&super.isNonstaticConstructor(method)}pushClassMethod(classBody,method,isGenerator,isAsync,isConstructor,allowsDirectSuper){if(method.variance&&this.unexpected(method.variance.start),delete method.variance,this.match(43)&&(method.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassMethod(classBody,
|
|
774
774
|
method,isGenerator,isAsync,isConstructor,allowsDirectSuper),method.params&&isConstructor){let params=method.params;params.length>0&&this.isThisParam(params[0])&&this.raise(FlowErrors.ThisParamBannedInConstructor,method)}else if(method.type==="MethodDefinition"&&isConstructor&&method.value.params){let params=method.value.params;params.length>0&&this.isThisParam(params[0])&&this.raise(FlowErrors.ThisParamBannedInConstructor,method)}}pushClassPrivateMethod(classBody,method,isGenerator,isAsync){method.
|
|
775
775
|
variance&&this.unexpected(method.variance.start),delete method.variance,this.match(43)&&(method.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassPrivateMethod(classBody,method,isGenerator,isAsync)}flowParseClassImplements(){let node=this.startNode();return node.id=this.flowParseRestrictedIdentifier(!0),this.match(43)?node.typeParameters=this.flowParseTypeParameterInstantiation():node.typeParameters=null,this.finishNode(node,"ClassImplements")}parseClassSuper(node){if(super.
|
|
776
|
-
parseClassSuper(node),node.superClass&&(this.match(43)||this.match(47))&&(node.superTypeArguments=this.flowParseTypeParameterInstantiationInExpression()),this.eatContextual(
|
|
776
|
+
parseClassSuper(node),node.superClass&&(this.match(43)||this.match(47))&&(node.superTypeArguments=this.flowParseTypeParameterInstantiationInExpression()),this.eatContextual(110)){let implemented=node.implements=[];do implemented.push(this.flowParseClassImplements());while(this.eat(8))}}checkGetterSetterParams(method){super.checkGetterSetterParams(method);let params=this.getObjectOrClassMethodParams(method);if(params.length>0){let param=params[0];this.isThisParam(param)&&method.kind==="get"?this.
|
|
777
777
|
raise(FlowErrors.GetterMayNotHaveThisParam,param):this.isThisParam(param)&&this.raise(FlowErrors.SetterMayNotHaveThisParam,param)}}parsePropertyNamePrefixOperator(node){node.variance=this.flowParseVariance()}parseObjPropValue(prop,startLoc,isGenerator,isAsync,isPattern,isAccessor,refExpressionErrors){prop.variance&&this.unexpected(prop.variance.start),delete prop.variance;let typeParameters;this.match(43)&&!isAccessor&&(typeParameters=this.flowParseTypeParameterDeclaration(),this.match(6)||this.
|
|
778
778
|
unexpected());let result=super.parseObjPropValue(prop,startLoc,isGenerator,isAsync,isPattern,isAccessor,refExpressionErrors);return typeParameters&&((result.value||result).typeParameters=typeParameters),result}parseFunctionParamType(param){return this.eat(13)&&(param.type!=="Identifier"&&this.raise(FlowErrors.PatternIsOptional,param),this.isThisParam(param)&&this.raise(FlowErrors.ThisParamMayNotBeOptional,param),param.optional=!0),this.match(10)?param.typeAnnotation=this.flowParseTypeAnnotation():
|
|
779
779
|
this.isThisParam(param)&&this.raise(FlowErrors.ThisParamAnnotationRequired,param),this.match(25)&&this.isThisParam(param)&&this.raise(FlowErrors.ThisParamNoDefault,param),this.resetEndLocation(param),param}parseMaybeDefault(startLoc,left){let node=super.parseMaybeDefault(startLoc,left);return node.type==="AssignmentPattern"&&node.typeAnnotation&&node.right.start<node.typeAnnotation.start&&this.raise(FlowErrors.TypeBeforeInitializer,node.typeAnnotation),node}parseImportSpecifierLocal(node,specifier,type){
|
|
780
|
-
specifier.local=hasTypeImportKind(node)?this.flowParseRestrictedIdentifier(!0,!0):this.parseIdentifier(),node.specifiers.push(this.finishImportSpecifier(specifier,type))}isPotentialImportPhase(isExport){if(super.isPotentialImportPhase(isExport))return!0;if(this.isContextual(
|
|
780
|
+
specifier.local=hasTypeImportKind(node)?this.flowParseRestrictedIdentifier(!0,!0):this.parseIdentifier(),node.specifiers.push(this.finishImportSpecifier(specifier,type))}isPotentialImportPhase(isExport){if(super.isPotentialImportPhase(isExport))return!0;if(this.isContextual(127)){if(!isExport)return!0;let ch=this.lookaheadCharCode();return ch===123||ch===42}return!isExport&&this.isContextual(83)}applyImportPhase(node,isExport,phase,loc){if(super.applyImportPhase(node,isExport,phase,loc),isExport){
|
|
781
781
|
if(!phase&&this.match(61))return;node.exportKind=phase==="type"?phase:"value"}else phase==="type"&&this.match(51)&&this.unexpected(),node.importKind=phase==="type"||phase==="typeof"?phase:"value"}parseImportSpecifier(specifier,importedIsString,isInTypeOnlyImport,isMaybeTypeOnly,bindingType){let firstIdent=specifier.imported,specifierTypeKind=null;firstIdent.type==="Identifier"&&(firstIdent.name==="type"?specifierTypeKind="type":firstIdent.name==="typeof"&&(specifierTypeKind="typeof"));let isBinding=!1;
|
|
782
|
-
if(this.isContextual(
|
|
783
|
-
!0),specifier.importKind=specifierTypeKind;else{if(importedIsString)throw this.raise(Errors.ImportBindingIsString,specifier,{importName:firstIdent.value});specifier.imported=firstIdent,specifier.importKind=null}this.eatContextual(
|
|
782
|
+
if(this.isContextual(90)&&!this.isLookaheadContextual("as")){let as_ident=this.parseIdentifier(!0);specifierTypeKind!==null&&!tokenIsKeywordOrIdentifier(this.state.type)?(specifier.imported=as_ident,specifier.importKind=specifierTypeKind,specifier.local=this.cloneIdentifier(as_ident)):(specifier.imported=firstIdent,specifier.importKind=null,specifier.local=this.parseIdentifier())}else{if(specifierTypeKind!==null&&tokenIsKeywordOrIdentifier(this.state.type))specifier.imported=this.parseIdentifier(
|
|
783
|
+
!0),specifier.importKind=specifierTypeKind;else{if(importedIsString)throw this.raise(Errors.ImportBindingIsString,specifier,{importName:firstIdent.value});specifier.imported=firstIdent,specifier.importKind=null}this.eatContextual(90)?specifier.local=this.parseIdentifier():(isBinding=!0,specifier.local=this.cloneIdentifier(specifier.imported))}let specifierIsTypeImport=hasTypeImportKind(specifier);return isInTypeOnlyImport&&specifierIsTypeImport&&this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport,
|
|
784
784
|
specifier),(isInTypeOnlyImport||specifierIsTypeImport)&&this.checkReservedType(specifier.local.name,specifier.local.start,!0),isBinding&&!isInTypeOnlyImport&&!specifierIsTypeImport&&this.checkReservedWord(specifier.local.name,specifier.start,!0,!0),this.finishImportSpecifier(specifier,"ImportSpecifier")}parseBindingAtom(){return this.state.type===74?this.parseIdentifier(!0):super.parseBindingAtom()}parseFunctionParams(node,isConstructor){let kind=node.kind;kind!=="get"&&kind!=="set"&&this.match(
|
|
785
785
|
43)&&(node.typeParameters=this.flowParseTypeParameterDeclaration()),super.parseFunctionParams(node,isConstructor)}parseVarId(decl,kind){super.parseVarId(decl,kind),this.match(10)&&(decl.id.typeAnnotation=this.flowParseTypeAnnotation(),this.resetEndLocation(decl.id))}parseAsyncArrowFromCallExpression(node,call){if(this.match(10)){let oldNoAnonFunctionType=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0,node.returnType=this.flowParseTypeAnnotation(),this.state.noAnonFunctionType=oldNoAnonFunctionType}
|
|
786
|
-
return super.parseAsyncArrowFromCallExpression(node,call)}shouldParseAsyncArrow(){return this.match(10)||super.shouldParseAsyncArrow()}parseMaybeAssign(refExpressionErrors,isParenItem){let state=null,jsx2;if(this.hasPlugin("jsx")&&(this.match(
|
|
786
|
+
return super.parseAsyncArrowFromCallExpression(node,call)}shouldParseAsyncArrow(){return this.match(10)||super.shouldParseAsyncArrow()}parseMaybeAssign(refExpressionErrors,isParenItem){let state=null,jsx2;if(this.hasPlugin("jsx")&&(this.match(139)||this.match(43))){if(state=this.state.clone(),jsx2=this.tryParse(()=>super.parseMaybeAssign(refExpressionErrors,isParenItem),state),!jsx2.error)return jsx2.node;let{context}=this.state,currentContext=context[context.length-1];(currentContext===types.j_oTag||
|
|
787
787
|
currentContext===types.j_expr)&&context.pop()}if(jsx2?.error||this.match(43)){state=state||this.state.clone();let typeParameters,arrow=this.tryParse(abort=>{typeParameters=this.flowParseTypeParameterDeclaration();let arrowExpression2=this.forwardNoArrowParamsConversionAt(typeParameters,()=>{let result=super.parseMaybeAssign(refExpressionErrors,isParenItem);return this.resetStartLocationFromNode(result,typeParameters),result});arrowExpression2.extra?.parenthesized&&abort();let expr=this.maybeUnwrapTypeCastExpression(
|
|
788
788
|
arrowExpression2);return expr.type!=="ArrowFunctionExpression"&&abort(),expr.typeParameters=typeParameters,this.resetStartLocationFromNode(expr,typeParameters),arrowExpression2},state),arrowExpression=null;if(arrow.node&&this.maybeUnwrapTypeCastExpression(arrow.node).type==="ArrowFunctionExpression"){if(!arrow.error&&!arrow.aborted)return arrow.node.async&&this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction,typeParameters),arrow.node;arrowExpression=arrow.node}if(jsx2?.node)return this.
|
|
789
789
|
state=jsx2.failState,jsx2.node;if(arrowExpression)return this.state=arrow.failState,arrowExpression;throw jsx2?.thrown?jsx2.error:arrow.thrown?arrow.error:this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter,typeParameters)}return super.parseMaybeAssign(refExpressionErrors,isParenItem)}parseArrow(node){if(this.match(10)){let result=this.tryParse(()=>{let oldNoAnonFunctionType=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0;let typeNode=this.startNode();return[typeNode.typeAnnotation,
|
|
@@ -798,13 +798,13 @@ let next=this.input.charCodeAt(this.state.pos+1);if(code2===42&&next===47&&this.
|
|
|
798
798
|
UnterminatedFlowComment,this.state.curPosition()),fileNode}skipBlockComment(){if(this.hasPlugin("flowComments")&&this.skipFlowComment()){if(this.state.hasFlowComment)throw this.raise(FlowErrors.NestedFlowComment,this.state.startLoc);this.hasFlowCommentCompletion();let commentSkip=this.skipFlowComment();commentSkip&&(this.state.pos+=commentSkip,this.state.hasFlowComment=!0);return}return super.skipBlockComment(this.state.hasFlowComment?"*-/":"*/")}skipFlowComment(){let{pos}=this.state,shiftToFirstNonWhiteSpace=2;
|
|
799
799
|
for(;[32,9].includes(this.input.charCodeAt(pos+shiftToFirstNonWhiteSpace));)shiftToFirstNonWhiteSpace++;let ch2=this.input.charCodeAt(shiftToFirstNonWhiteSpace+pos),ch3=this.input.charCodeAt(shiftToFirstNonWhiteSpace+pos+1);return ch2===58&&ch3===58?shiftToFirstNonWhiteSpace+2:this.input.slice(shiftToFirstNonWhiteSpace+pos,shiftToFirstNonWhiteSpace+pos+12)==="flow-include"?shiftToFirstNonWhiteSpace+12:ch2===58&&ch3!==58?shiftToFirstNonWhiteSpace:!1}hasFlowCommentCompletion(){if(this.input.indexOf(
|
|
800
800
|
"*/",this.state.pos)===-1)throw this.raise(Errors.UnterminatedComment,this.state.curPosition())}flowEnumErrorBooleanMemberNotInitialized(loc,names){this.raise(FlowErrors.EnumBooleanMemberNotInitialized,loc,names)}flowEnumErrorInvalidMemberInitializer(loc,enumContext){return this.raise(enumContext.explicitType?enumContext.explicitType==="symbol"?FlowErrors.EnumInvalidMemberInitializerSymbolType:FlowErrors.EnumInvalidMemberInitializerPrimaryType:FlowErrors.EnumInvalidMemberInitializerUnknownType,loc,
|
|
801
|
-
enumContext)}flowEnumErrorNumberMemberNotInitialized(loc,details){this.raise(FlowErrors.EnumNumberMemberNotInitialized,loc,details)}flowEnumErrorStringMemberInconsistentlyInitialized(node,details){this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized,node,details)}flowEnumMemberInit(){let startLoc=this.state.startLoc,endOfInit=()=>this.match(8)||this.match(4);switch(this.state.type){case
|
|
802
|
-
start,value:literal};break}case
|
|
801
|
+
enumContext)}flowEnumErrorNumberMemberNotInitialized(loc,details){this.raise(FlowErrors.EnumNumberMemberNotInitialized,loc,details)}flowEnumErrorStringMemberInconsistentlyInitialized(node,details){this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized,node,details)}flowEnumMemberInit(){let startLoc=this.state.startLoc,endOfInit=()=>this.match(8)||this.match(4);switch(this.state.type){case 132:{let literal=this.parseNumericLiteral(this.state.value);if(endOfInit())return{type:"number",loc:literal.
|
|
802
|
+
start,value:literal};break}case 131:{let literal=this.parseStringLiteral(this.state.value);if(endOfInit())return{type:"string",loc:literal.start,value:literal};break}case 81:case 82:{let literal=this.parseBooleanLiteral(this.match(81));if(endOfInit())return{type:"boolean",loc:literal.start,value:literal}}}return{type:"invalid",loc:startLoc}}flowEnumMemberRaw(){let loc=this.state.startLoc,id2=this.parseIdentifier(!0),init=this.eat(25)?this.flowEnumMemberInit():{type:"none",loc};return{id:id2,init}}flowEnumCheckExplicitTypeMismatch(loc,context,expectedType){
|
|
803
803
|
let{explicitType}=context;explicitType!==null&&explicitType!==expectedType&&this.flowEnumErrorInvalidMemberInitializer(loc,context)}flowEnumMembers({enumName,explicitType}){let seenNames=new Set,members={booleanMembers:[],numberMembers:[],stringMembers:[],defaultedMembers:[]},hasUnknownMembers=!1;for(;!this.match(4);){if(this.eat(17)){hasUnknownMembers=!0;break}let memberNode=this.startNode(),{id:id2,init}=this.flowEnumMemberRaw(),memberName=id2.name;if(memberName==="")continue;/^[a-z]/.test(memberName)&&
|
|
804
804
|
this.raise(FlowErrors.EnumInvalidMemberName,id2,{memberName,suggestion:memberName[0].toUpperCase()+memberName.slice(1),enumName}),seenNames.has(memberName)&&this.raise(FlowErrors.EnumDuplicateMemberName,id2,{memberName,enumName}),seenNames.add(memberName);let context={enumName,explicitType,memberName};switch(memberNode.id=id2,init.type){case"boolean":{this.flowEnumCheckExplicitTypeMismatch(init.loc,context,"boolean"),memberNode.init=init.value,members.booleanMembers.push(this.finishNode(memberNode,
|
|
805
805
|
"EnumBooleanMember"));break}case"number":{this.flowEnumCheckExplicitTypeMismatch(init.loc,context,"number"),memberNode.init=init.value,members.numberMembers.push(this.finishNode(memberNode,"EnumNumberMember"));break}case"string":{this.flowEnumCheckExplicitTypeMismatch(init.loc,context,"string"),memberNode.init=init.value,members.stringMembers.push(this.finishNode(memberNode,"EnumStringMember"));break}case"invalid":throw this.flowEnumErrorInvalidMemberInitializer(init.loc,context);case"none":switch(explicitType){case"\
|
|
806
806
|
boolean":this.flowEnumErrorBooleanMemberNotInitialized(init.loc,context);break;case"number":this.flowEnumErrorNumberMemberNotInitialized(init.loc,context);break;default:members.defaultedMembers.push(this.finishNode(memberNode,"EnumDefaultedMember"))}}this.match(4)||this.expect(8)}return{members,hasUnknownMembers}}flowEnumStringMembers(initializedMembers,defaultedMembers,{enumName}){if(initializedMembers.length===0)return defaultedMembers;if(defaultedMembers.length===0)return initializedMembers;if(defaultedMembers.
|
|
807
|
-
length>initializedMembers.length){for(let member of initializedMembers)this.flowEnumErrorStringMemberInconsistentlyInitialized(member,{enumName});return defaultedMembers}else{for(let member of defaultedMembers)this.flowEnumErrorStringMemberInconsistentlyInitialized(member,{enumName});return initializedMembers}}flowEnumParseExplicitType({enumName}){if(!this.eatContextual(
|
|
807
|
+
length>initializedMembers.length){for(let member of initializedMembers)this.flowEnumErrorStringMemberInconsistentlyInitialized(member,{enumName});return defaultedMembers}else{for(let member of defaultedMembers)this.flowEnumErrorStringMemberInconsistentlyInitialized(member,{enumName});return initializedMembers}}flowEnumParseExplicitType({enumName}){if(!this.eatContextual(99))return null;if(!tokenIsIdentifier(this.state.type))throw this.raise(FlowErrors.EnumInvalidExplicitTypeUnknownSupplied,this.
|
|
808
808
|
state.startLoc,{enumName});let{value}=this.state;return this.next(),value!=="boolean"&&value!=="number"&&value!=="string"&&value!=="symbol"&&this.raise(FlowErrors.EnumInvalidExplicitType,this.state.startLoc,{enumName,invalidEnumType:value}),value}flowEnumBody(node,id2){let enumName=id2.name,nameLoc=id2.start,explicitType=this.flowEnumParseExplicitType({enumName});this.expect(2);let{members,hasUnknownMembers}=this.flowEnumMembers({enumName,explicitType});switch(node.hasUnknownMembers=hasUnknownMembers,
|
|
809
809
|
explicitType){case"boolean":return node.explicitType=!0,node.members=members.booleanMembers,this.expect(4),this.finishNode(node,"EnumBooleanBody");case"number":return node.explicitType=!0,node.members=members.numberMembers,this.expect(4),this.finishNode(node,"EnumNumberBody");case"string":return node.explicitType=!0,node.members=this.flowEnumStringMembers(members.stringMembers,members.defaultedMembers,{enumName}),this.expect(4),this.finishNode(node,"EnumStringBody");case"symbol":return node.members=
|
|
810
810
|
members.defaultedMembers,this.expect(4),this.finishNode(node,"EnumSymbolBody");default:{let empty=()=>(node.members=[],this.expect(4),this.finishNode(node,"EnumStringBody"));node.explicitType=!1;let boolsLen=members.booleanMembers.length,numsLen=members.numberMembers.length,strsLen=members.stringMembers.length,defaultedLen=members.defaultedMembers.length;if(!boolsLen&&!numsLen&&!strsLen&&!defaultedLen)return empty();if(!boolsLen&&!numsLen)return node.members=this.flowEnumStringMembers(members.stringMembers,
|
|
@@ -818,30 +818,30 @@ scaron:"\u0161",Yuml:"\u0178",fnof:"\u0192",circ:"\u02C6",tilde:"\u02DC",Alpha:"
|
|
|
818
818
|
eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\
|
|
819
819
|
\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",bull:"\u2022",hellip:"\u2026",permil:"\u2030",prime:"\u2032",Prime:"\u2033",lsaquo:"\u2039",rsaquo:"\u203A",oline:"\u203E",frasl:"\u2044",euro:"\u20AC",image:"\u2111",weierp:"\u2118",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\
|
|
820
820
|
\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\
|
|
821
|
-
\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666"},lineBreakG=/\r\n|[\r\n\u2028\u2029]/g;function isNewLine(code2){switch(code2){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function hasNewLine(input,start,end){for(let i=start;i<end;i++)if(isNewLine(input.charCodeAt(i)))return!0;return!1}var skipWhiteSpace=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,
|
|
822
|
-
function isWhitespace(code2){switch(code2){case 9:case 11:case 12:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:case 65279:return!0;default:return!1}}var JsxErrorTemplates={AttributeIsEmpty:"JSX attributes must only be assigned a non-empty expression.",MissingClosingTagElement:({openingTagName})=>`Expected
|
|
823
|
-
Expected corresponding JSX closing tag for <>.",UnexpectedSequenceExpression:"Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",UnexpectedToken:({unexpected,HTMLEntity})=>`Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,UnsupportedJsxValue:"JSX value should be either an expression or a quoted JSX text.",UnterminatedJsxContent:"
|
|
824
|
-
|
|
825
|
-
object2.object)+"."+getQualifiedJSXName(object2.property);throw new Error("Node had unexpected type: "+object2.type)}var jsx=superClass=>class extends superClass{jsxReadToken(){let out="",chunkStart=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(JsxErrors.UnterminatedJsxContent,this.state.startLoc);let ch=this.input.charCodeAt(this.state.pos);switch(ch){case 60:case 123:if(this.state.pos===this.state.
|
|
826
|
-
|
|
827
|
-
this.state.pos):++this.state.pos}}}jsxReadNewLine(normalizeCRLF){let ch=this.input.charCodeAt(this.state.pos),out;return++this.state.pos,ch===13&&this.input.charCodeAt(this.state.pos)===10?(++this.state.pos,out=normalizeCRLF?`
|
|
821
|
+
\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666"},lineBreakG=/\r\n|[\r\n\u2028\u2029]/g;function isNewLine(code2){switch(code2){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function hasNewLine(input,start,end){for(let i=start;i<end;i++)if(isNewLine(input.charCodeAt(i)))return!0;return!1}var skipWhiteSpace=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,skipWhiteSpaceAnnexB=/(?:[^\S\n\r\u2028\u2029]|\/\*.*?\*\/)*(?:(?!-->)(?:\s|\/\/.*|\/\*[^]*?\*\/|<!--.*|-->.*)*)?/g,
|
|
822
|
+
skipWhiteSpaceInLine=/(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;function isWhitespace(code2){switch(code2){case 9:case 11:case 12:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:case 65279:return!0;default:return!1}}var JsxErrorTemplates={AttributeIsEmpty:"JSX attributes must only be assigned a non-empty expression.",MissingClosingTagElement:({openingTagName})=>`Expected \
|
|
823
|
+
corresponding JSX closing tag for <${openingTagName}>.`,MissingClosingTagFragment:"Expected corresponding JSX closing tag for <>.",UnexpectedSequenceExpression:"Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",UnexpectedToken:({unexpected,HTMLEntity})=>`Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,UnsupportedJsxValue:"JSX value should be either an expression or a quoted JSX text.",UnterminatedJsxContent:"\
|
|
824
|
+
Unterminated JSX contents.",UnwrappedAdjacentJSXElements:"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"},JsxErrors=ParseErrorEnum`jsx`(JsxErrorTemplates);function isFragment(object2){return object2?object2.type==="JSXOpeningFragment"||object2.type==="JSXClosingFragment":!1}function getQualifiedJSXName(object2){if(object2.type==="JSXIdentifier")return object2.name;if(object2.type==="JSXNamespacedName")return object2.namespace.name+":"+object2.name.
|
|
825
|
+
name;if(object2.type==="JSXMemberExpression")return getQualifiedJSXName(object2.object)+"."+getQualifiedJSXName(object2.property);throw new Error("Node had unexpected type: "+object2.type)}var jsx=superClass=>class extends superClass{jsxReadToken(){let out="",chunkStart=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(JsxErrors.UnterminatedJsxContent,this.state.startLoc);let ch=this.input.charCodeAt(this.state.pos);switch(ch){case 60:case 123:if(this.state.pos===this.state.
|
|
826
|
+
start){ch===60&&this.state.canStartJSXElement?(++this.state.pos,this.finishToken(139)):super.getTokenFromCode(ch);return}out+=this.input.slice(chunkStart,this.state.pos),this.finishToken(138,out);return;case 38:out+=this.input.slice(chunkStart,this.state.pos),out+=this.jsxReadEntity(),chunkStart=this.state.pos;break;case 62:case 125:this.raise(JsxErrors.UnexpectedToken,this.state.curPosition(),{unexpected:this.input[this.state.pos],HTMLEntity:ch===125?"}":">"});default:isNewLine(ch)?(out+=
|
|
827
|
+
this.input.slice(chunkStart,this.state.pos),out+=this.jsxReadNewLine(!0),chunkStart=this.state.pos):++this.state.pos}}}jsxReadNewLine(normalizeCRLF){let ch=this.input.charCodeAt(this.state.pos),out;return++this.state.pos,ch===13&&this.input.charCodeAt(this.state.pos)===10?(++this.state.pos,out=normalizeCRLF?`
|
|
828
828
|
`:`\r
|
|
829
829
|
`):out=String.fromCharCode(ch),++this.state.curLine,this.state.lineStart=this.state.pos,out}jsxReadString(quote){let out="",chunkStart=++this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(Errors.UnterminatedString,this.state.startLoc);let ch=this.input.charCodeAt(this.state.pos);if(ch===quote)break;ch===38?(out+=this.input.slice(chunkStart,this.state.pos),out+=this.jsxReadEntity(),chunkStart=this.state.pos):isNewLine(ch)?(out+=this.input.slice(chunkStart,this.state.pos),out+=
|
|
830
|
-
this.jsxReadNewLine(!1),chunkStart=this.state.pos):++this.state.pos}out+=this.input.slice(chunkStart,this.state.pos++),this.finishToken(
|
|
831
|
-
fromCodePoint(codePoint)}else{let count3=0,semi=!1;for(;count3++<10&&this.state.pos<this.length&&!(semi=this.codePointAtPos(this.state.pos)===59);)++this.state.pos;if(semi){let desc=this.input.slice(startPos,this.state.pos),entity=entities[desc];if(++this.state.pos,entity)return entity}}return this.state.pos=startPos,"&"}jsxReadWord(){let ch,start=this.state.pos;do ch=this.input.charCodeAt(++this.state.pos);while(isIdentifierChar(ch)||ch===45);this.finishToken(
|
|
832
|
-
pos))}jsxParseIdentifier(){let node=this.startNode();return this.match(
|
|
830
|
+
this.jsxReadNewLine(!1),chunkStart=this.state.pos):++this.state.pos}out+=this.input.slice(chunkStart,this.state.pos++),this.finishToken(131,out)}jsxReadEntity(){let startPos=++this.state.pos;if(this.codePointAtPos(this.state.pos)===35){++this.state.pos;let radix=10;this.codePointAtPos(this.state.pos)===120&&(radix=16,++this.state.pos);let codePoint=this.readInt(radix,void 0,!1,"bail");if(codePoint!==null&&codePoint<=1114111&&this.codePointAtPos(this.state.pos)===59)return++this.state.pos,String.
|
|
831
|
+
fromCodePoint(codePoint)}else{let count3=0,semi=!1;for(;count3++<10&&this.state.pos<this.length&&!(semi=this.codePointAtPos(this.state.pos)===59);)++this.state.pos;if(semi){let desc=this.input.slice(startPos,this.state.pos),entity=entities[desc];if(++this.state.pos,entity)return entity}}return this.state.pos=startPos,"&"}jsxReadWord(){let ch,start=this.state.pos;do ch=this.input.charCodeAt(++this.state.pos);while(isIdentifierChar(ch)||ch===45);this.finishToken(137,this.input.slice(start,this.state.
|
|
832
|
+
pos))}jsxParseIdentifier(){let node=this.startNode();return this.match(137)?node.name=this.state.value:tokenIsKeyword(this.state.type)?node.name=tokenLabelName(this.state.type):this.unexpected(),this.next(),this.finishNode(node,"JSXIdentifier")}jsxParseNamespacedName(){let startLoc=this.state.startLoc,name=this.jsxParseIdentifier();if(!this.eat(10))return name;let node=this.startNodeAt(startLoc);return node.namespace=name,node.name=this.jsxParseIdentifier(),this.finishNode(node,"JSXNamespacedNam\
|
|
833
833
|
e")}jsxParseElementName(){let startLoc=this.state.startLoc,node=this.jsxParseNamespacedName();if(node.type==="JSXNamespacedName")return node;for(;this.eat(12);){let newNode=this.startNodeAt(startLoc);newNode.object=node,newNode.property=this.jsxParseIdentifier(),node=this.finishNode(newNode,"JSXMemberExpression")}return node}jsxParseAttributeValue(){let node;switch(this.state.type){case 2:return node=this.startNode(),this.setContext(types.brace),this.next(),node=this.jsxParseExpressionContainer(
|
|
834
|
-
node,types.j_oTag),node.expression.type==="JSXEmptyExpression"&&this.raise(JsxErrors.AttributeIsEmpty,node),node;case
|
|
834
|
+
node,types.j_oTag),node.expression.type==="JSXEmptyExpression"&&this.raise(JsxErrors.AttributeIsEmpty,node),node;case 139:case 131:return this.parseExprAtom();default:throw this.raise(JsxErrors.UnsupportedJsxValue,this.state.startLoc)}}jsxParseEmptyExpression(){let node=this.startNodeAt(this.state.lastTokEndLoc);return this.finishNodeAt(node,"JSXEmptyExpression",this.state.startLoc)}jsxParseSpreadChild(node){return this.next(),node.expression=this.parseExpression(),this.setContext(types.j_expr),
|
|
835
835
|
this.state.canStartJSXElement=!0,this.expect(4),this.finishNode(node,"JSXSpreadChild")}jsxParseExpressionContainer(node,previousContext){if(this.match(4))node.expression=this.jsxParseEmptyExpression();else{let expression=this.parseExpression();expression.type==="SequenceExpression"&&!expression.extra?.parenthesized&&this.raise(JsxErrors.UnexpectedSequenceExpression,expression.expressions[1]),node.expression=expression}return this.setContext(previousContext),this.state.canStartJSXElement=!0,this.
|
|
836
836
|
expect(4),this.finishNode(node,"JSXExpressionContainer")}jsxParseAttribute(){if(this.match(2)){let node2=this.startNode();return this.setContext(types.brace),this.next(),this.expect(17),node2.argument=this.parseMaybeAssignAllowIn(),this.setContext(types.j_oTag),this.state.canStartJSXElement=!0,this.expect(4),this.finishNode(node2,"JSXSpreadAttribute")}let node=this.startNode();return node.name=this.jsxParseNamespacedName(),node.value=this.eat(25)?this.jsxParseAttributeValue():null,this.finishNode(
|
|
837
|
-
node,"JSXAttribute")}jsxParseOpeningElementAt(startLoc){if(this.eat(
|
|
838
|
-
this.finishNode(node,"JSXOpeningElement")}jsxParseClosingElementAt(startLoc){if(this.eat(
|
|
839
|
-
contents:for(;;)switch(this.state.type){case
|
|
837
|
+
node,"JSXAttribute")}jsxParseOpeningElementAt(startLoc){if(this.eat(140)){let node2=this.startNodeAt(startLoc);return this.finishNode(node2,"JSXOpeningFragment")}let node=this.startNodeAt(startLoc);return node.name=this.jsxParseElementName(),this.jsxParseOpeningElementAfterName(node)}jsxParseOpeningElementAfterName(node){let attributes=[];for(;!this.match(52)&&!this.match(140);)attributes.push(this.jsxParseAttribute());return node.attributes=attributes,node.selfClosing=this.eat(52),this.expect(140),
|
|
838
|
+
this.finishNode(node,"JSXOpeningElement")}jsxParseClosingElementAt(startLoc){if(this.eat(140)){let node2=this.startNodeAt(startLoc);return this.finishNode(node2,"JSXClosingFragment")}let node=this.startNodeAt(startLoc);return node.name=this.jsxParseElementName(),this.expect(140),this.finishNode(node,"JSXClosingElement")}jsxParseElementAt(startLoc){let node=this.startNodeAt(startLoc),children=[],openingElement=this.jsxParseOpeningElementAt(startLoc),closingElement=null;if(!openingElement.selfClosing){
|
|
839
|
+
contents:for(;;)switch(this.state.type){case 139:if(startLoc=this.state.startLoc,this.next(),this.eat(52)){this.setLoc(startLoc),closingElement=this.jsxParseClosingElementAt(startLoc);break contents}children.push(this.jsxParseElementAt(startLoc));break;case 138:children.push(this.parseLiteral(this.state.value,"JSXText"));break;case 2:{let node2=this.startNode();this.setContext(types.brace),this.next(),this.match(17)?children.push(this.jsxParseSpreadChild(node2)):children.push(this.jsxParseExpressionContainer(
|
|
840
840
|
node2,types.j_expr));break}default:this.unexpected()}isFragment(openingElement)&&!isFragment(closingElement)&&closingElement!==null?this.raise(JsxErrors.MissingClosingTagFragment,closingElement):!isFragment(openingElement)&&isFragment(closingElement)?this.raise(JsxErrors.MissingClosingTagElement,closingElement,{openingTagName:getQualifiedJSXName(openingElement.name)}):!isFragment(openingElement)&&!isFragment(closingElement)&&getQualifiedJSXName(closingElement.name)!==getQualifiedJSXName(openingElement.
|
|
841
841
|
name)&&this.raise(JsxErrors.MissingClosingTagElement,closingElement,{openingTagName:getQualifiedJSXName(openingElement.name)})}if(isFragment(openingElement)?(node.openingFragment=openingElement,node.closingFragment=closingElement):(node.openingElement=openingElement,node.closingElement=closingElement),node.children=children,this.match(43))throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements,this.state.startLoc);return isFragment(openingElement)?this.finishNode(node,"JSXFragment"):this.finishNode(
|
|
842
|
-
node,"JSXElement")}jsxParseElement(){let startLoc=this.state.startLoc;return this.next(),this.jsxParseElementAt(startLoc)}setContext(newContext){let{context}=this.state;context[context.length-1]=newContext}parseExprAtom(refExpressionErrors){return this.match(
|
|
843
|
-
let context=this.curContext();if(context===types.j_expr){this.jsxReadToken();return}if(context===types.j_oTag||context===types.j_cTag){if(isIdentifierStart(code2)){this.jsxReadWord();return}if(code2===62){++this.state.pos,this.finishToken(
|
|
844
|
-
let{context,type}=this.state;if(type===52&&prevType===
|
|
842
|
+
node,"JSXElement")}jsxParseElement(){let startLoc=this.state.startLoc;return this.next(),this.jsxParseElementAt(startLoc)}setContext(newContext){let{context}=this.state;context[context.length-1]=newContext}parseExprAtom(refExpressionErrors){return this.match(139)?this.jsxParseElement():this.match(43)&&this.input.charCodeAt(this.state.pos)!==33?(this.replaceToken(139),this.jsxParseElement()):super.parseExprAtom(refExpressionErrors)}skipSpace(){this.curContext().preserveSpace||super.skipSpace()}getTokenFromCode(code2){
|
|
843
|
+
let context=this.curContext();if(context===types.j_expr){this.jsxReadToken();return}if(context===types.j_oTag||context===types.j_cTag){if(isIdentifierStart(code2)){this.jsxReadWord();return}if(code2===62){++this.state.pos,this.finishToken(140);return}if((code2===34||code2===39)&&context===types.j_oTag){this.jsxReadString(code2);return}}if(code2===60&&this.state.canStartJSXElement&&this.input.charCodeAt(this.state.pos+1)!==33){++this.state.pos,this.finishToken(139);return}super.getTokenFromCode(code2)}updateContext(prevType){
|
|
844
|
+
let{context,type}=this.state;if(type===52&&prevType===139)context.splice(-2,2,types.j_cTag),this.state.canStartJSXElement=!1;else if(type===139)context.push(types.j_oTag);else if(type===140){let out=context[context.length-1];out===types.j_oTag&&prevType===52||out===types.j_cTag?(context.pop(),this.state.canStartJSXElement=context[context.length-1]===types.j_expr):(this.setContext(types.j_expr),this.state.canStartJSXElement=!0)}else this.state.canStartJSXElement=tokenComesBeforeExpression(type)}},
|
|
845
845
|
TypeScriptScope=class extends Scope{tsNames=new Map},TypeScriptScopeHandler=class extends ScopeHandler{get inTSNamespace(){let scopeStack=this.scopeStack;return scopeStack.length>=2&&scopeStack[scopeStack.length-1].flags===0&&(scopeStack[scopeStack.length-2].flags&2048)>0}importsStack=[];createScope(flags){return this.importsStack.push(new Set),new TypeScriptScope(flags)}enter(flags){flags&3072&&this.importsStack.push(new Set),super.enter(flags)}exit(){let flags=super.exit();return flags&3072&&this.
|
|
846
846
|
importsStack.pop(),flags}hasImport(name,allowShadow){let len=this.importsStack.length;if(this.importsStack[len-1].has(name))return!0;if(!allowShadow&&len>1){for(let i=0;i<len-1;i++)if(this.importsStack[i].has(name))return!0}return!1}declareName(name,bindingType,loc){if(bindingType&4096){this.hasImport(name,!0)&&this.parser.raise(Errors.VarRedeclaration,loc,{identifierName:name}),this.importsStack[this.importsStack.length-1].add(name);return}let scope=this.currentScope(),type=scope.tsNames.get(name)||
|
|
847
847
|
0;if(bindingType&1024){this.maybeExportDefined(scope,name),scope.tsNames.set(name,type|16);return}super.declareName(name,bindingType,loc),bindingType&2&&(bindingType&1||(this.checkRedeclarationInScope(scope,name,bindingType,loc),this.maybeExportDefined(scope,name)),type=type|1),bindingType&256&&(type=type|2),bindingType&512&&(type=type|4),bindingType&128&&(type=type|8),type&&scope.tsNames.set(name,type)}isRedeclaredInScope(scope,name,bindingType){let type=scope.tsNames.get(name);if((type&2)>0){if(bindingType&
|
|
@@ -854,77 +854,77 @@ leadingNode!==null||commentWS.trailingNode!==null)commentWS.leadingNode!==null&&
|
|
|
854
854
|
wExpression":case"OptionalCallExpression":adjustInnerComments(node,node.arguments,commentWS);break;case"ImportExpression":adjustInnerComments(node,[node.source,node.options??null],commentWS);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":case"TSTypeParameterDeclaration":adjustInnerComments(node,node.params,commentWS);break;case"ArrayExpression":case"ArrayPattern":adjustInnerComments(node,node.elements,
|
|
855
855
|
commentWS);break;case"ExportNamedDeclaration":case"ImportDeclaration":adjustInnerComments(node,node.specifiers,commentWS);break;case"TSEnumBody":adjustInnerComments(node,node.members,commentWS);break;case"TSInterfaceBody":adjustInnerComments(node,node.body,commentWS);break;default:setInnerComments(node,comments)}else setInnerComments(node,comments)}}finalizeRemainingComments(){let{commentStack}=this.state;for(let i=commentStack.length-1;i>=0;i--)this.finalizeComment(commentStack[i]);this.state.commentStack=
|
|
856
856
|
[]}resetPreviousNodeTrailingComments(node){let{commentStack}=this.state,{length}=commentStack;if(length===0)return;let commentWS=commentStack[length-1];commentWS.leadingNode===node&&(commentWS.leadingNode=null)}takeSurroundingComments(node,start,end){let{commentStack}=this.state,commentStackLength=commentStack.length;if(commentStackLength===0)return;let i=commentStackLength-1;for(;i>=0;i--){let commentWS=commentStack[i],commentEnd=commentWS.end;if(commentWS.start===end)commentWS.leadingNode=node;else if(commentEnd===
|
|
857
|
-
start)commentWS.trailingNode=node;else if(commentEnd<start)break}}},State=class _State{flags=2048;get strict(){return(this.flags&1)>0}set strict(v){v?this.flags|=1:this.flags&=-2}startIndex;curLine;lineStart;startLoc;endLoc;init({strictMode,sourceType,startIndex,startLine,startColumn}){this.strict=strictMode===!1?!1:strictMode===!0?!0:sourceType==="module",this.startIndex=startIndex,this.curLine=startLine,this.lineStart=-startColumn,this.startLoc=this.endLoc=new Position(startLine,startColumn,startIndex)}errors=[];noArrowAt=[];noArrowParamsConversionAt=[];get canStartArrow(){
|
|
857
|
+
start)commentWS.trailingNode=node;else if(commentEnd<start)break}}},State=class _State{flags=2048;get strict(){return(this.flags&1)>0}set strict(v){v?this.flags|=1:this.flags&=-2}startIndex;curLine;lineStart;startLoc;endLoc;init({strictMode,sourceType,startIndex,startLine,startColumn}){this.strict=strictMode===!1?!1:strictMode===!0?!0:sourceType==="module",this.startIndex=startIndex,this.curLine=startLine,this.lineStart=-startColumn,this.startLoc=this.endLoc=new Position(startLine,startColumn,startIndex)}errors=[];noArrowAt=[];noArrowParamsConversionAt=[];regExpAllowedAt=-1;get canStartArrow(){
|
|
858
858
|
return(this.flags&2)>0}set canStartArrow(v){v?this.flags|=2:this.flags&=-3}get inType(){return(this.flags&4)>0}set inType(v){v?this.flags|=4:this.flags&=-5}get noAnonFunctionType(){return(this.flags&8)>0}set noAnonFunctionType(v){v?this.flags|=8:this.flags&=-9}get hasFlowComment(){return(this.flags&16)>0}set hasFlowComment(v){v?this.flags|=16:this.flags&=-17}get isAmbientContext(){return(this.flags&32)>0}set isAmbientContext(v){v?this.flags|=32:this.flags&=-33}get inAbstractClass(){return(this.flags&
|
|
859
859
|
64)>0}set inAbstractClass(v){v?this.flags|=64:this.flags&=-65}get inDisallowConditionalTypesContext(){return(this.flags&128)>0}set inDisallowConditionalTypesContext(v){v?this.flags|=128:this.flags&=-129}get inConditionalConsequent(){return(this.flags&256)>0}set inConditionalConsequent(v){v?this.flags|=256:this.flags&=-257}get inHackPipelineBody(){return(this.flags&512)>0}set inHackPipelineBody(v){v?this.flags|=512:this.flags&=-513}get seenTopicReference(){return(this.flags&1024)>0}set seenTopicReference(v){
|
|
860
|
-
v?this.flags|=1024:this.flags&=-1025}labels=[];commentsLen=0;commentStack=[];pos=0;type=
|
|
860
|
+
v?this.flags|=1024:this.flags&=-1025}labels=[];commentsLen=0;commentStack=[];pos=0;type=136;value=null;start=0;end=0;lastTokEndLoc=null;lastTokStartLoc=null;context=[types.brace];get canStartJSXElement(){return(this.flags&2048)>0}set canStartJSXElement(v){v?this.flags|=2048:this.flags&=-2049}get containsEsc(){return(this.flags&4096)>0}set containsEsc(v){v?this.flags|=4096:this.flags&=-4097}firstInvalidTemplateEscapePos=null;get hasTopLevelAwait(){return(this.flags&8192)>0}set hasTopLevelAwait(v){
|
|
861
861
|
v?this.flags|=8192:this.flags&=-8193}strictErrors=new Map;tokensLength=0;curPosition(){return new Position(this.curLine,this.pos-this.lineStart,this.pos+this.startIndex)}clone(){let state=new _State;return state.flags=this.flags,state.startIndex=this.startIndex,state.curLine=this.curLine,state.lineStart=this.lineStart,state.startLoc=this.startLoc,state.endLoc=this.endLoc,state.errors=this.errors.slice(),state.noArrowAt=this.noArrowAt.slice(),state.noArrowParamsConversionAt=this.noArrowParamsConversionAt.
|
|
862
|
-
slice(),state.labels=this.labels.slice(),state.commentsLen=this.commentsLen,state.commentStack=this.commentStack.slice(),state.pos=this.pos,state.type=this.type,state.value=this.value,state.start=this.start,state.end=this.end,state.lastTokEndLoc=this.lastTokEndLoc,state.lastTokStartLoc=this.lastTokStartLoc,state.context=this.context.slice(),state.firstInvalidTemplateEscapePos=this.firstInvalidTemplateEscapePos,state.strictErrors=this.strictErrors,state.
|
|
863
|
-
return code2>=48&&code2<=57},forbiddenNumericSeparatorSiblings={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},isAllowedNumericSeparatorSibling={bin:ch=>ch===48||ch===49,oct:ch=>ch>=48&&ch<=55,dec:ch=>ch>=48&&ch<=57,hex:ch=>ch>=48&&ch<=57||ch>=65&&ch<=70||ch>=97&&ch<=102};function readStringContents(type,input,pos,lineStart,curLine,errors){let initialPos=pos,initialLineStart=lineStart,initialCurLine=curLine,
|
|
864
|
-
if(pos>=length){errors.unterminated(initialPos,initialLineStart,initialCurLine),out+=input.slice(chunkStart,pos);break}let ch=input.charCodeAt(pos);if(isStringEnd(type,ch,input,pos)){out+=input.slice(chunkStart,pos);break}if(ch===92){out+=input.slice(chunkStart,pos);let res=readEscapedChar(input,pos,lineStart,curLine,type==="template",errors);res.ch===null&&!firstInvalidLoc?firstInvalidLoc={pos,lineStart,curLine}:out+=res.ch,{pos,
|
|
865
|
-
++curLine,lineStart=pos):ch===10||ch===13?type==="template"?(out+=input.slice(chunkStart,pos)+`
|
|
862
|
+
slice(),state.regExpAllowedAt=this.regExpAllowedAt,state.labels=this.labels.slice(),state.commentsLen=this.commentsLen,state.commentStack=this.commentStack.slice(),state.pos=this.pos,state.type=this.type,state.value=this.value,state.start=this.start,state.end=this.end,state.lastTokEndLoc=this.lastTokEndLoc,state.lastTokStartLoc=this.lastTokStartLoc,state.context=this.context.slice(),state.firstInvalidTemplateEscapePos=this.firstInvalidTemplateEscapePos,state.strictErrors=this.strictErrors,state.
|
|
863
|
+
tokensLength=this.tokensLength,state}},_isDigit=function(code2){return code2>=48&&code2<=57},forbiddenNumericSeparatorSiblings={decBinOct:new Set([46,66,69,79,95,98,101,111,43,45]),hex:new Set([46,88,95,120])},isAllowedNumericSeparatorSibling={bin:ch=>ch===48||ch===49,oct:ch=>ch>=48&&ch<=55,dec:ch=>ch>=48&&ch<=57,hex:ch=>ch>=48&&ch<=57||ch>=65&&ch<=70||ch>=97&&ch<=102};function readStringContents(type,input,pos,lineStart,curLine,errors){let initialPos=pos,initialLineStart=lineStart,initialCurLine=curLine,
|
|
864
|
+
out="",firstInvalidLoc=null,chunkStart=pos,{length}=input;for(;;){if(pos>=length){errors.unterminated(initialPos,initialLineStart,initialCurLine),out+=input.slice(chunkStart,pos);break}let ch=input.charCodeAt(pos);if(isStringEnd(type,ch,input,pos)){out+=input.slice(chunkStart,pos);break}if(ch===92){out+=input.slice(chunkStart,pos);let res=readEscapedChar(input,pos,lineStart,curLine,type==="template",errors);res.ch===null&&!firstInvalidLoc?firstInvalidLoc={pos,lineStart,curLine}:out+=res.ch,{pos,
|
|
865
|
+
lineStart,curLine}=res,chunkStart=pos}else ch===8232||ch===8233?(++pos,++curLine,lineStart=pos):ch===10||ch===13?type==="template"?(out+=input.slice(chunkStart,pos)+`
|
|
866
866
|
`,++pos,ch===13&&input.charCodeAt(pos)===10&&++pos,++curLine,chunkStart=lineStart=pos):errors.unterminated(initialPos,initialLineStart,initialCurLine):++pos}return{pos,str:out,firstInvalidLoc,lineStart,curLine}}function isStringEnd(type,ch,input,pos){return type==="template"?ch===96||ch===36&&input.charCodeAt(pos+1)===123:ch===(type==="double"?34:39)}function readEscapedChar(input,pos,lineStart,curLine,inTemplate,errors){let throwOnInvalid=!inTemplate;pos++;let res=ch2=>({pos,ch:ch2,lineStart,curLine}),
|
|
867
867
|
ch=input.charCodeAt(pos++);switch(ch){case 110:return res(`
|
|
868
868
|
`);case 114:return res("\r");case 120:{let code2;return{code:code2,pos}=readHexChar(input,pos,lineStart,curLine,2,!1,throwOnInvalid,errors),res(code2===null?null:String.fromCharCode(code2))}case 117:{let code2;return{code:code2,pos}=readCodePoint(input,pos,lineStart,curLine,throwOnInvalid,errors),res(code2===null?null:String.fromCodePoint(code2))}case 116:return res(" ");case 98:return res("\b");case 118:return res("\v");case 102:return res("\f");case 13:input.charCodeAt(pos)===10&&++pos;case 10:
|
|
869
869
|
lineStart=pos,++curLine;case 8232:case 8233:return res("");case 56:case 57:if(inTemplate)return res(null);errors.strictNumericEscape(pos-1,lineStart,curLine);default:if(ch>=48&&ch<=55){let startPos=pos-1,octalStr=/^[0-7]+/.exec(input.slice(startPos,pos+2))[0],octal=parseInt(octalStr,8);octal>255&&(octalStr=octalStr.slice(0,-1),octal=parseInt(octalStr,8)),pos+=octalStr.length-1;let next=input.charCodeAt(pos);if(octalStr!=="0"||next===56||next===57){if(inTemplate)return res(null);errors.strictNumericEscape(
|
|
870
870
|
startPos,lineStart,curLine)}return res(String.fromCharCode(octal))}return res(String.fromCharCode(ch))}}function readHexChar(input,pos,lineStart,curLine,len,forceLen,throwOnInvalid,errors){let initialPos=pos,n;return{n,pos}=readInt(input,pos,lineStart,curLine,16,len,forceLen,!1,errors,!throwOnInvalid),n===null&&(throwOnInvalid?errors.invalidEscapeSequence(initialPos,lineStart,curLine):pos=initialPos-1),{code:n,pos}}function readInt(input,pos,lineStart,curLine,radix,len,forceLen,allowNumSeparator,errors,bailOnError){
|
|
871
871
|
let start=pos,forbiddenSiblings=radix===16?forbiddenNumericSeparatorSiblings.hex:forbiddenNumericSeparatorSiblings.decBinOct,isAllowedSibling=radix===16?isAllowedNumericSeparatorSibling.hex:radix===10?isAllowedNumericSeparatorSibling.dec:radix===8?isAllowedNumericSeparatorSibling.oct:isAllowedNumericSeparatorSibling.bin,invalid2=!1,total=0;for(let i=0,e=len??1/0;i<e;++i){let code2=input.charCodeAt(pos),val;if(code2===95&&allowNumSeparator!=="bail"){let prev=input.charCodeAt(pos-1),next=input.charCodeAt(
|
|
872
|
-
pos+1);if(allowNumSeparator){if(Number.isNaN(next)||!isAllowedSibling(next)||forbiddenSiblings.has(prev)
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
2
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
return skipWhiteSpaceInLine.lastIndex=pos,skipWhiteSpaceInLine.test(this.input)?skipWhiteSpaceInLine.lastIndex:pos}lookaheadInLineCharCode(){return this.input.charCodeAt(this.nextTokenInLineStart())}codePointAtPos(pos){let cp=this.input.charCodeAt(pos);if((cp&64512)===55296&&++pos<this.input.length){let trail=this.input.charCodeAt(pos);(trail&64512)===56320&&(cp=65536+((cp&1023)<<10)+(trail&1023))}return cp}setStrict(strict){
|
|
880
|
-
at])=>this.raise(toParseError,at)),this.state.strictErrors.clear())}curContext(){return this.state.context[this.state.context.length-1]}nextToken(){if(this.skipSpace(),this.state.start=this.state.pos,this.isLookahead||(this.state.startLoc=this.state.curPosition()),this.state.pos>=this.length){this.finishToken(
|
|
881
|
-
end=this.input.indexOf(commentEnd,start+2);if(end===-1)throw this.raise(Errors.UnterminatedComment,this.state.curPosition());for(this.state.pos=end+commentEnd.length,lineBreakG.lastIndex=start+2;lineBreakG.test(this.input)&&lineBreakG.lastIndex<=end;)++this.state.curLine,this.state.lineStart=lineBreakG.lastIndex;if(this.isLookahead)return;let comment={type:"CommentBlock",value:this.input.slice(start+2,end),start:this.
|
|
882
|
-
startLoc,this.state.curPosition())};return this.optionFlags&512&&this.pushToken(comment),comment}skipLineComment(startSkip){let start=this.state.pos,startLoc;this.isLookahead||(startLoc=this.state.curPosition());let ch=this.input.charCodeAt(this.state.pos+=startSkip);if(this.state.pos<this.length)for(;!isNewLine(ch)&&++this.state.pos<this.length;)ch=this.input.charCodeAt(this.state.pos);if(this.isLookahead)
|
|
883
|
-
end),start:this.sourceToOffsetPos(start),end:this.sourceToOffsetPos(end),loc:new SourceLocation(startLoc,this.state.curPosition())};return this.optionFlags&512&&this.pushToken(comment),comment}skipSpace(){let spaceStart=this.state.pos,attachComment=(this.optionFlags&8192)>0,comments;loop:for(;this.state.pos<this.length;){let ch=this.input.charCodeAt(this.state.pos);switch(ch){case 32:case 160:case 9
|
|
884
|
-
++this.state.pos,++this.state.curLine,this.state.lineStart=this.state.pos;break;case 47:switch(this.input.charCodeAt(this.state.pos+1)){case 42:{let comment=this.skipBlockComment("*/");comment!==void 0&&(this.addComment(comment),attachComment&&(comments??=[]).push(comment));break}case 47:{let comment=this.skipLineComment(2);comment!==void 0&&(this.addComment(comment),attachComment&&
|
|
885
|
-
45&&!this.inModule&&this.optionFlags&16384){let pos=this.state.pos;if(this.input.charCodeAt(pos+1)===45&&this.input.charCodeAt(pos+2)===62&&(spaceStart===0||this.state.lineStart>spaceStart)){let comment=this.skipLineComment(3);comment!==void 0&&(this.addComment(comment),attachComment&&(comments??=[]).push(comment))}else break loop}else if(ch===60&&!this.inModule&&this.optionFlags&
|
|
886
|
-
pos+3)===45){let comment=this.skipLineComment(4);comment!==void 0&&(this.addComment(comment),attachComment&&(comments??=[]).push(comment))}else break loop}else break loop}}if(comments?.length){let end=this.state.pos,commentWhitespace={start:this.sourceToOffsetPos(spaceStart),end:this.sourceToOffsetPos(end),comments,leadingNode:null,trailingNode:null,containingNode:null};this.
|
|
887
|
-
curPosition();let prevType=this.state.type;this.state.type=type,this.state.value=val,this.isLookahead||this.updateContext(prevType)}replaceToken(type){this.state.type=type,this.updateContext()}readToken_numberSign(){if(this.state.pos===0&&this.readToken_interpreter())return;let nextPos=this.state.pos+1,next=this.codePointAtPos(nextPos);if(next>=48&&next<=57)throw this.raise(
|
|
888
|
-
readWord1(next))):next===92?(++this.state.pos,this.finishToken(
|
|
889
|
-
0||this.length<2)return!1;let ch=this.input.charCodeAt(this.state.pos+1);if(ch!==33)return!1;let start=this.state.pos;for(this.state.pos+=1;!isNewLine(ch)&&++this.state.pos<this.length;)ch=this.input.charCodeAt(this.state.pos);let value=this.input.slice(start+2,this.state.pos);return this.finishToken(24,value),!0}readToken_mult_modulo(code2){let type=code2===42?51:50,width=1,
|
|
890
|
-
type=53),next===61&&!this.state.inType&&(width++,type=code2===37?29:26),this.finishOp(type,width)}readToken_pipe_amp(code2){let next=this.input.charCodeAt(this.state.pos+1);if(next===code2){this.input.charCodeAt(this.state.pos+2)===61?this.finishOp(26,3):this.finishOp(code2===124?37:38,2);return}if(code2===124&&next===62){this.finishOp(35,2);return}if(next===61){this.finishOp(
|
|
891
|
-
61&&!this.state.inType?this.finishOp(28,2):next===94&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"^^"}])?(this.finishOp(33,2),this.input.codePointAt(this.state.pos)===94&&this.unexpected()):this.finishOp(40,1)}readToken_atSign(){this.input.charCodeAt(this.state.pos+1)===64&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"@@"}])?this.finishOp(
|
|
892
|
-
finishOp(30,2);return}next===61?this.finishOp(26,2):this.finishOp(49,1)}readToken_lt(){let{pos}=this.state,next=this.input.charCodeAt(pos+1);if(next===60){if(this.input.charCodeAt(pos+2)===61){this.finishOp(26,3);return}this.finishOp(47,2);return}if(next===61){this.finishOp(45,2);return}this.finishOp(43,1)}readToken_gt(){let{pos}=this.state,next=this.input.charCodeAt(pos+1);
|
|
893
|
-
1);return}this.finishOp(48,size);return}if(next===61){this.finishOp(45,2);return}this.finishOp(44,1)}readToken_eq_excl(code2){let next=this.input.charCodeAt(this.state.pos+1);if(next===61){this.finishOp(42,this.input.charCodeAt(this.state.pos+2)===61?3:2);return}if(code2===61&&next===62){this.state.pos+=2,this.finishToken(15);return}this.finishOp(code2===61?25:31,1)}readToken_question(){
|
|
894
|
-
61?this.finishOp(26,3):this.finishOp(36,2):next===46&&!(next2>=48&&next2<=57)?(this.state.pos+=2,this.finishToken(14)):(++this.state.pos,this.finishToken(13))}getTokenFromCode(code2){switch(code2){case 46:this.readToken_dot();return;case 40:++this.state.pos,this.finishToken(6);return;case 41:++this.state.pos,this.finishToken(7);return;case 59:++this.state.pos,this.finishToken(9);return;case 44
|
|
895
|
-
++this.state.pos,this.finishToken(1);return;case 123:++this.state.pos,this.finishToken(2);return;case 125:++this.state.pos,this.finishToken(4);return;case 58:this.hasPlugin("functionBind")&&this.input.charCodeAt(this.state.pos+1)===58?this.finishOp(11,2):(++this.state.pos,this.finishToken(10));return;case 63:this.readToken_question();return;case 96:this.readTemplateToken();return;case 48:{let next=this.
|
|
896
|
-
111||next===79){this.readRadixNumber(8);return}if(next===98||next===66){this.readRadixNumber(2);return}}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:this.readNumber(!1);return;case 34:case 39:this.readString(code2);return;case 47:this.readToken_slash();return;case 37:case 42:this.readToken_mult_modulo(code2);return;case 124:case 38:this.readToken_pipe_amp(code2);return;case 94:
|
|
897
|
-
readToken_lt();return;case 62:this.readToken_gt();return;case 61:case 33:this.readToken_eq_excl(code2);return;case 126:this.finishOp(32,1);return;case 64:this.readToken_atSign();return;case 35:this.readToken_numberSign();return;case 92:this.readWord();return;default:if(isIdentifierStart(code2)){this.readWord(code2);return}}throw this.raise(Errors.InvalidOrUnexpectedToken,this.state.curPosition(),{unexpected:String.
|
|
898
|
-
this.state.pos+size);this.state.pos+=size,this.finishToken(type,str)}readRegexp(){let startLoc=this.state.startLoc,start=this.state.start+1,escaped,inClass,{pos}=this.state;for(;;++pos){if(pos>=this.length)throw this.raise(Errors.UnterminatedRegExp,createPositionWithColumnOffset(startLoc,1));let ch=this.input.charCodeAt(pos);if(isNewLine(ch))throw this.raise(Errors.UnterminatedRegExp,createPositionWithColumnOffset(
|
|
899
|
-
inClass=!1;else if(ch===47&&!inClass)break;escaped=ch===92}}let content=this.input.slice(start,pos);++pos;let mods="",nextPos=()=>createPositionWithColumnOffset(startLoc,pos+2-start);for(;pos<this.length;){let cp=this.codePointAtPos(pos),char=String.fromCharCode(cp);if(VALID_REGEX_FLAGS.has(cp))cp===118?mods.includes("u")&&this.raise(Errors.IncompatibleRegExpUVFlags,nextPos()):cp===117&&mods.includes("v")&&this.
|
|
900
|
-
DuplicateRegExpFlags,nextPos());else if(isIdentifierChar(cp)||cp===92)this.raise(Errors.MalformedRegExpFlags,nextPos());else break;++pos,mods+=char}this.state.pos=pos,this.finishToken(
|
|
901
|
-
state.curPosition(),isBigInt=!1;this.state.pos+=2;let val=this.readInt(radix);if(val==null&&this.raise(Errors.InvalidDigit,createPositionWithColumnOffset(startLoc,2),{radix}),this.input.charCodeAt(this.state.pos)===110&&(++this.state.pos,isBigInt=!0),isIdentifierStart(this.codePointAtPos(this.state.pos)))throw this.raise(Errors.NumberIdentifier,this.state.curPosition());if(isBigInt){let str=this.input.slice(
|
|
902
|
-
|
|
903
|
-
underscorePos>0&&this.raise(Errors.ZeroDigitNumericSeparator,createPositionWithColumnOffset(startLoc,underscorePos))}isOctal=hasLeadingZero&&!/[89]/.test(integer2)}let next=this.input.charCodeAt(this.state.pos);next===46&&!isOctal&&(++this.state.pos,this.readInt(10),isFloat=!0,next=this.input.charCodeAt(this.state.pos)),(next===69||next===101)&&!isOctal&&(next=this.input.charCodeAt(++this.state.pos),(next===
|
|
904
|
-
startLoc),isFloat=!0,next=this.input.charCodeAt(this.state.pos));let str=this.input.slice(start,this.state.pos).replaceAll("_","");if(next===110&&((isFloat||hasLeadingZero)&&this.raise(Errors.InvalidBigIntLiteral,startLoc),++this.state.pos,isBigInt=!0),isIdentifierStart(this.codePointAtPos(this.state.pos)))throw this.raise(Errors.NumberIdentifier,this.state.curPosition());if(isBigInt){this.finishToken(
|
|
905
|
-
let{code:code2,pos}=readCodePoint(this.input,this.state.pos,this.state.lineStart,this.state.curLine,throwOnInvalid,this.errorHandlers_readCodePoint);return this.state.pos=pos,code2}readString(quote){let{str,pos,curLine,lineStart}=readStringContents(quote===34?"double":"single",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_string);
|
|
906
|
-
this.match(4)||this.unexpected(null,4),this.state.pos--,this.readTemplateToken()}readTemplateToken(){let opening=this.input[this.state.pos],{str,firstInvalidLoc,pos,curLine,lineStart}=readStringContents("template",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_template);this.state.pos=pos+1,this.state.lineStart=
|
|
907
|
-
firstInvalidLoc.pos-firstInvalidLoc.lineStart,this.sourceToOffsetPos(firstInvalidLoc.pos))),this.input.codePointAt(pos)===96?this.finishToken(20,firstInvalidLoc?null:opening+str+"`"):(this.state.pos++,this.finishToken(21,firstInvalidLoc?null:opening+str+"${"))}recordStrictModeErrors(toParseError,at){let index=at.index;this.state.strict&&!this.state.strictErrors.has(
|
|
908
|
-
|
|
909
|
-
117){this.raise(Errors.MissingUnicodeEscape,this.state.curPosition()),chunkStart=this.state.pos-1;continue}++this.state.pos;let esc=this.readCodePoint(!0);esc!==null&&(identifierCheck(esc)||this.raise(Errors.EscapedCharNotAnIdentifier,escStart),word+=String.fromCodePoint(esc)),chunkStart=this.state.pos}else break}return word+this.input.slice(chunkStart,this.state.pos)}readWord(firstCode){
|
|
910
|
-
type)):this.finishToken(
|
|
911
|
-
optionFlags&4096))throw error;return this.isLookahead||this.state.errors.push(error),error}raiseOverwrite(toParseError,at,details={}){let loc=at instanceof Position?at:this.optionFlags&256?at.loc.start:this.getLoc(at.start),pos=at instanceof Position?loc.index:at.start,errors=this.state.errors;for(let i=errors.length-1;i>=0;i--){let error=errors[i];if(error.pos===pos)return errors[i]=toParseError(loc,
|
|
912
|
-
throw this.raise(Errors.UnexpectedToken,loc??this.state.startLoc,{expected:type?tokenLabelName(type):null})}expectPlugin(pluginName,loc){if(this.hasPlugin(pluginName))return!0;throw this.raise(Errors.MissingPlugin,loc??this.state.startLoc,{missingPlugin:[pluginName]})}expectOnePlugin(pluginNames){if(!pluginNames.some(name=>this.hasPlugin(name)))throw this.raise(Errors.MissingOneOfPlugins,
|
|
913
|
-
error,buildPosition(pos,lineStart,curLine))}}errorHandlers_readInt={invalidDigit:(pos,lineStart,curLine,radix)=>{this.raise(Errors.InvalidDigit,buildPosition(pos,lineStart,curLine),{radix})},numericSeparatorInEscapeSequence:this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(Errors.UnexpectedNumericSeparator)};errorHandlers_readCodePoint={
|
|
914
|
-
errorBuilder(Errors.InvalidCodePoint)};errorHandlers_readStringContents_string={...this.errorHandlers_readCodePoint,strictNumericEscape:(pos,lineStart,curLine)=>{this.recordStrictModeErrors(Errors.StrictNumericEscape,buildPosition(pos,lineStart,curLine))},unterminated:(pos,lineStart,curLine)=>{throw this.raise(Errors.UnterminatedString,buildPosition(pos-1,lineStart,curLine))}};errorHandlers_readStringContents_template={
|
|
915
|
-
StrictNumericEscape),unterminated:(pos,lineStart,curLine)=>{throw this.raise(Errors.UnterminatedTemplate,buildPosition(pos,lineStart,curLine))}}},ClassScope=class{privateNames=new Set;loneAccessors=new Map;undefinedPrivateNames=new Map},ClassScopeHandler=class{parser;stack=[];constructor(parser){this.parser=parser}current(){return this.stack[this.stack.length-1]}enter(){this.stack.push(new ClassScope)}exit(){let oldClassScope=this.
|
|
916
|
-
oldClassScope.undefinedPrivateNames))current2?current2.undefinedPrivateNames.has(name)||current2.undefinedPrivateNames.set(name,loc):this.parser.raise(Errors.InvalidPrivateFieldResolution,loc,{identifierName:name})}declarePrivateName(name,elementType,loc){let{privateNames,loneAccessors,undefinedPrivateNames}=this.current(),redefined=privateNames.has(name);if(elementType&3){let accessor=redefined&&loneAccessors.get(name);if(accessor){
|
|
917
|
-
3,newKind=elementType&3;redefined=oldKind===newKind||oldStatic!==newStatic,redefined||loneAccessors.delete(name)}else redefined||loneAccessors.set(name,elementType)}redefined&&this.parser.raise(Errors.PrivateNameRedeclaration,loc,{identifierName:name}),privateNames.add(name),undefinedPrivateNames.delete(name)}usePrivateName(name,loc){let classScope;for(classScope of this.stack)if(classScope.privateNames.has(name))return;classScope?
|
|
918
|
-
Errors.InvalidPrivateFieldResolution,loc,{identifierName:name})}},ExpressionScope=class{constructor(type=0){this.type=type}canBeArrowParameterDeclaration(){return this.type===2||this.type===1}isCertainlyParameterDeclaration(){return this.type===3}},ArrowHeadParsingScope=class extends ExpressionScope{declarationErrors=new Map;constructor(type){super(type)}recordDeclarationError(ParsingErrorClass,index){this.declarationErrors.set(index,
|
|
919
|
-
delete(index)}iterateErrors(iterator){this.declarationErrors.forEach(iterator)}},ExpressionScopeHandler=class{parser;stack=[new ExpressionScope];constructor(parser){this.parser=parser}enter(scope){this.stack.push(scope)}exit(){this.stack.pop()}recordParameterInitializerError(toParseError,loc){let{stack}=this,i=stack.length-1,scope=stack[i];for(;!scope.isCertainlyParameterDeclaration();){if(scope.canBeArrowParameterDeclaration())
|
|
920
|
-
this.parser.raise(toParseError,loc)}recordArrowParameterBindingError(error,node){let{stack}=this,scope=stack[stack.length-1],origin=node.start;if(scope.isCertainlyParameterDeclaration())this.parser.raise(error,origin);else if(scope.canBeArrowParameterDeclaration())scope.recordDeclarationError(error,origin);else return}recordAsyncArrowParametersError(at){let{stack}=this,i=stack.length-1,scope=stack[i];for(;scope.canBeArrowParameterDeclaration();)
|
|
921
|
-
AwaitBindingIdentifier,at),scope=stack[--i]}validateAsPattern(){let{stack}=this,currentScope=stack[stack.length-1];currentScope.canBeArrowParameterDeclaration()&¤tScope.iterateErrors((toParseError,key)=>{this.parser.raise(toParseError,key);let i=stack.length-2,scope=stack[i];for(;scope.canBeArrowParameterDeclaration();)scope.clearDeclarationError(key),scope=stack[--i]})}};function newParameterDeclarationScope(){return new ExpressionScope(
|
|
922
|
-
1)}function newAsyncArrowScope(){return new ArrowHeadParsingScope(2)}function newExpressionScope(){return new ExpressionScope}var ProductionParameterHandler=class{stacks=[];enter(flags){this.stacks.push(flags)}exit(){this.stacks.pop()}currentFlags(){return this.stacks[this.stacks.length-1]}get hasAwait(){return(this.currentFlags()&2)>0}get hasYield(){return(this.currentFlags()&1)>0}get hasReturn(){return(this.currentFlags()&4)>0}get hasIn(){
|
|
923
|
-
return(this.currentFlags()&16)===0}};function functionFlags(isAsync,isGenerator){return(isAsync?2:0)|(isGenerator?1:0)}var UtilParser=class extends Tokenizer{addExtra(node,key,value,enumerable=!0){if(!node)return;let{extra}=node;extra==null&&(extra={},node.extra=extra),enumerable?extra[key]=value:Object.defineProperty(extra,key,{enumerable,value})}isContextual(token){return this.state.type===token&&!this.state.containsEsc}isUnparsedContextual(nameStart,name){
|
|
924
|
-
let nextCh=this.input.charCodeAt(nameStart+name.length);return!(isIdentifierChar(nextCh)||(nextCh&64512)===55296)}return!1}isLookaheadContextual(name){let next=this.nextTokenStart();return this.isUnparsedContextual(next,name)}eatContextual(token){return this.isContextual(token)?(this.next(),!0):!1}expectContextual(token,toParseError){if(!this.eatContextual(token)){if(toParseError!=null)throw this.raise(toParseError,this.state.startLoc);this.unexpected(null,
|
|
925
|
-
match(
|
|
926
|
-
this.unexpected(loc,type)}tryParse(fn,oldState=this.state.clone()){let abortSignal={node:null};try{let node=fn((node2=null)=>{throw abortSignal.node=node2,abortSignal});if(this.state.errors.length>oldState.errors.length){let failState=this.state;return this.state=oldState,this.state.tokensLength=failState.tokensLength,{node,error:failState.errors[oldState.errors.length],thrown:!1,aborted:!1,failState}}return{node,error:null,thrown:!1,aborted:!1,failState:null}}catch(error){let failState=this.
|
|
927
|
-
if(this.state=oldState,error instanceof SyntaxError)return{node:null,error,thrown:!0,aborted:!1,failState};if(error===abortSignal)return{node:abortSignal.node,error:null,thrown:!1,aborted:!0,failState};throw error}}checkExpressionErrors(refExpressionErrors,andThrow){if(!refExpressionErrors)return!1;let{shorthandAssignLoc,doubleProtoLoc,privateKeyLoc,optionalParametersLoc,voidPatternLoc}=refExpressionErrors,hasErrors=!!shorthandAssignLoc||!!doubleProtoLoc||!!optionalParametersLoc||!!privateKeyLoc||
|
|
872
|
+
pos+1);if(allowNumSeparator){if(Number.isNaN(next)||!isAllowedSibling(next)||forbiddenSiblings.has(prev)){if(bailOnError)return{n:null,pos};errors.unexpectedNumericSeparator(pos,lineStart,curLine)}}else{if(bailOnError)return{n:null,pos};errors.numericSeparatorInEscapeSequence(pos,lineStart,curLine)}++pos;continue}if(code2>=97?val=code2-97+10:code2>=65?val=code2-65+10:_isDigit(code2)?val=code2-48:val=1/0,val>=radix)if(val<=9){if(bailOnError)return{n:null,pos};errors.invalidDigit(pos,lineStart,curLine,
|
|
873
|
+
radix),val=0}else if(forceLen)val=0,invalid2=!0;else break;++pos,total=total*radix+val}return pos===start||len!=null&&pos-start!==len||invalid2?{n:null,pos}:{n:total,pos}}function readCodePoint(input,pos,lineStart,curLine,throwOnInvalid,errors){let ch=input.charCodeAt(pos),code2;if(ch===123){if(++pos,{code:code2,pos}=readHexChar(input,pos,lineStart,curLine,input.indexOf("}",pos)-pos,!0,throwOnInvalid,errors),++pos,code2!==null&&code2>1114111)if(throwOnInvalid)errors.invalidCodePoint(pos,lineStart,
|
|
874
|
+
curLine);else return{code:null,pos}}else({code:code2,pos}=readHexChar(input,pos,lineStart,curLine,4,!1,throwOnInvalid,errors));return{code:code2,pos}}function buildPosition(pos,lineStart,curLine){return new Position(curLine,pos-lineStart,pos)}var VALID_REGEX_FLAGS=new Set([103,109,115,105,121,117,100,118]),Token=class{constructor(state){let startIndex=state.startIndex||0;this.type=state.type,this.value=state.value,this.start=startIndex+state.start,this.end=startIndex+state.end,this.loc=new SourceLocation(
|
|
875
|
+
state.startLoc,state.endLoc)}},locDataCache,Tokenizer=class extends CommentsParser{isLookahead;tokens=[];constructor(options,input){super(),this.state=new State,this.state.init(options),this.input=input,this.length=input.length,this.comments=[],this.isLookahead=!1,(!locDataCache||locDataCache.length<(this.length+1)*2)&&(locDataCache=new Uint32Array((this.length+1)*2)),this.locData=locDataCache}setLoc(loc){let dataIndex=this.offsetToSourcePos(loc.index);this.locData[dataIndex*2]=loc.line,this.locData[dataIndex*
|
|
876
|
+
2+1]=loc.column}getLoc(locIndex){let dataIndex=this.offsetToSourcePos(locIndex);return new Position(this.locData[dataIndex*2],this.locData[dataIndex*2+1],locIndex)}pushToken(token){this.tokens.length=this.state.tokensLength,this.tokens.push(token),++this.state.tokensLength}next(){this.checkKeywordEscapes(),this.optionFlags&512&&this.pushToken(new Token(this.state)),this.state.lastTokEndLoc=this.state.endLoc,this.state.lastTokStartLoc=this.state.startLoc,this.nextToken()}eat(type){return this.match(
|
|
877
|
+
type)?(this.next(),!0):!1}match(type){return this.state.type===type}createLookaheadState(state){return{pos:state.pos,value:null,type:state.type,start:state.start,end:state.end,context:[this.curContext()],inType:state.inType,startLoc:state.startLoc,lastTokEndLoc:state.lastTokEndLoc,curLine:state.curLine,lineStart:state.lineStart,curPosition:state.curPosition}}lookahead(){let old=this.state;this.state=this.createLookaheadState(old),this.isLookahead=!0,this.nextToken(),this.isLookahead=!1;let curr=this.
|
|
878
|
+
state;return this.state=old,curr}nextTokenStart(){return this.nextTokenStartSince(this.state.pos)}nextTokenStartSince(pos){let skipWhiteSpaceRe=this.inModule||!(this.optionFlags&16384)?skipWhiteSpace:skipWhiteSpaceAnnexB;return skipWhiteSpaceRe.lastIndex=pos,skipWhiteSpaceRe.test(this.input)?skipWhiteSpaceRe.lastIndex:pos}lookaheadCharCode(){return this.lookaheadCharCodeSince(this.state.pos)}lookaheadCharCodeSince(pos){return this.input.charCodeAt(this.nextTokenStartSince(pos))}nextTokenInLineStart(){
|
|
879
|
+
return this.nextTokenInLineStartSince(this.state.pos)}nextTokenInLineStartSince(pos){return skipWhiteSpaceInLine.lastIndex=pos,skipWhiteSpaceInLine.test(this.input)?skipWhiteSpaceInLine.lastIndex:pos}lookaheadInLineCharCode(){return this.input.charCodeAt(this.nextTokenInLineStart())}codePointAtPos(pos){let cp=this.input.charCodeAt(pos);if((cp&64512)===55296&&++pos<this.input.length){let trail=this.input.charCodeAt(pos);(trail&64512)===56320&&(cp=65536+((cp&1023)<<10)+(trail&1023))}return cp}setStrict(strict){
|
|
880
|
+
this.state.strict=strict,strict&&(this.state.strictErrors.forEach(([toParseError,at])=>this.raise(toParseError,at)),this.state.strictErrors.clear())}curContext(){return this.state.context[this.state.context.length-1]}nextToken(){if(this.skipSpace(),this.state.start=this.state.pos,this.isLookahead||(this.state.startLoc=this.state.curPosition()),this.state.pos>=this.length){this.finishToken(136);return}this.getTokenFromCode(this.codePointAtPos(this.state.pos))}skipBlockComment(commentEnd){let startLoc;
|
|
881
|
+
this.isLookahead||(startLoc=this.state.curPosition());let start=this.state.pos,end=this.input.indexOf(commentEnd,start+2);if(end===-1)throw this.raise(Errors.UnterminatedComment,this.state.curPosition());for(this.state.pos=end+commentEnd.length,lineBreakG.lastIndex=start+2;lineBreakG.test(this.input)&&lineBreakG.lastIndex<=end;)++this.state.curLine,this.state.lineStart=lineBreakG.lastIndex;if(this.isLookahead)return;let comment={type:"CommentBlock",value:this.input.slice(start+2,end),start:this.
|
|
882
|
+
sourceToOffsetPos(start),end:this.sourceToOffsetPos(end+commentEnd.length),loc:new SourceLocation(startLoc,this.state.curPosition())};return this.optionFlags&512&&this.pushToken(comment),comment}skipLineComment(startSkip){let start=this.state.pos,startLoc;this.isLookahead||(startLoc=this.state.curPosition());let ch=this.input.charCodeAt(this.state.pos+=startSkip);if(this.state.pos<this.length)for(;!isNewLine(ch)&&++this.state.pos<this.length;)ch=this.input.charCodeAt(this.state.pos);if(this.isLookahead)
|
|
883
|
+
return;let end=this.state.pos,comment={type:"CommentLine",value:this.input.slice(start+startSkip,end),start:this.sourceToOffsetPos(start),end:this.sourceToOffsetPos(end),loc:new SourceLocation(startLoc,this.state.curPosition())};return this.optionFlags&512&&this.pushToken(comment),comment}skipSpace(){let spaceStart=this.state.pos,attachComment=(this.optionFlags&8192)>0,comments;loop:for(;this.state.pos<this.length;){let ch=this.input.charCodeAt(this.state.pos);switch(ch){case 32:case 160:case 9:
|
|
884
|
+
++this.state.pos;break;case 13:this.input.charCodeAt(this.state.pos+1)===10&&++this.state.pos;case 10:case 8232:case 8233:++this.state.pos,++this.state.curLine,this.state.lineStart=this.state.pos;break;case 47:switch(this.input.charCodeAt(this.state.pos+1)){case 42:{let comment=this.skipBlockComment("*/");comment!==void 0&&(this.addComment(comment),attachComment&&(comments??=[]).push(comment));break}case 47:{let comment=this.skipLineComment(2);comment!==void 0&&(this.addComment(comment),attachComment&&
|
|
885
|
+
(comments??=[]).push(comment));break}default:break loop}break;default:if(isWhitespace(ch))++this.state.pos;else if(ch===45&&!this.inModule&&this.optionFlags&16384){let pos=this.state.pos;if(this.input.charCodeAt(pos+1)===45&&this.input.charCodeAt(pos+2)===62&&(spaceStart===0||this.state.lineStart>spaceStart)){let comment=this.skipLineComment(3);comment!==void 0&&(this.addComment(comment),attachComment&&(comments??=[]).push(comment))}else break loop}else if(ch===60&&!this.inModule&&this.optionFlags&
|
|
886
|
+
16384){let pos=this.state.pos;if(this.input.charCodeAt(pos+1)===33&&this.input.charCodeAt(pos+2)===45&&this.input.charCodeAt(pos+3)===45){let comment=this.skipLineComment(4);comment!==void 0&&(this.addComment(comment),attachComment&&(comments??=[]).push(comment))}else break loop}else break loop}}if(comments?.length){let end=this.state.pos,commentWhitespace={start:this.sourceToOffsetPos(spaceStart),end:this.sourceToOffsetPos(end),comments,leadingNode:null,trailingNode:null,containingNode:null};this.
|
|
887
|
+
state.commentStack.push(commentWhitespace)}}finishToken(type,val){this.state.end=this.state.pos,this.state.endLoc=this.state.curPosition();let prevType=this.state.type;this.state.type=type,this.state.value=val,this.isLookahead||this.updateContext(prevType)}replaceToken(type){this.state.type=type,this.updateContext()}readToken_numberSign(){if(this.state.pos===0&&this.readToken_interpreter())return;let nextPos=this.state.pos+1,next=this.codePointAtPos(nextPos);if(next>=48&&next<=57)throw this.raise(
|
|
888
|
+
Errors.UnexpectedDigitAfterHash,this.state.curPosition());isIdentifierStart(next)?(++this.state.pos,this.finishToken(135,this.readWord1(next))):next===92?(++this.state.pos,this.finishToken(135,this.readWord1())):this.finishOp(23,1)}readToken_dot(){let next=this.input.charCodeAt(this.state.pos+1);if(next>=48&&next<=57){this.readNumber(!0);return}next===46&&this.input.charCodeAt(this.state.pos+2)===46?(this.state.pos+=3,this.finishToken(17)):(++this.state.pos,this.finishToken(12))}readToken_slash(){
|
|
889
|
+
this.input.charCodeAt(this.state.pos+1)===61?this.finishOp(27,2):this.finishOp(52,1)}readToken_interpreter(){if(this.state.pos!==0||this.length<2)return!1;let ch=this.input.charCodeAt(this.state.pos+1);if(ch!==33)return!1;let start=this.state.pos;for(this.state.pos+=1;!isNewLine(ch)&&++this.state.pos<this.length;)ch=this.input.charCodeAt(this.state.pos);let value=this.input.slice(start+2,this.state.pos);return this.finishToken(24,value),!0}readToken_mult_modulo(code2){let type=code2===42?51:50,width=1,
|
|
890
|
+
next=this.input.charCodeAt(this.state.pos+1);code2===42&&next===42&&(width++,next=this.input.charCodeAt(this.state.pos+2),type=53),next===61&&!this.state.inType&&(width++,type=code2===37?29:26),this.finishOp(type,width)}readToken_pipe_amp(code2){let next=this.input.charCodeAt(this.state.pos+1);if(next===code2){this.input.charCodeAt(this.state.pos+2)===61?this.finishOp(26,3):this.finishOp(code2===124?37:38,2);return}if(code2===124&&next===62){this.finishOp(35,2);return}if(next===61){this.finishOp(
|
|
891
|
+
26,2);return}this.finishOp(code2===124?39:41,1)}readToken_caret(){let next=this.input.charCodeAt(this.state.pos+1);next===61&&!this.state.inType?this.finishOp(28,2):next===94&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"^^"}])?(this.finishOp(33,2),this.input.codePointAt(this.state.pos)===94&&this.unexpected()):this.finishOp(40,1)}readToken_atSign(){this.input.charCodeAt(this.state.pos+1)===64&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"@@"}])?this.finishOp(
|
|
892
|
+
34,2):this.finishOp(22,1)}readToken_plus_min(code2){let next=this.input.charCodeAt(this.state.pos+1);if(next===code2){this.finishOp(30,2);return}next===61?this.finishOp(26,2):this.finishOp(49,1)}readToken_lt(){let{pos}=this.state,next=this.input.charCodeAt(pos+1);if(next===60){if(this.input.charCodeAt(pos+2)===61){this.finishOp(26,3);return}this.finishOp(47,2);return}if(next===61){this.finishOp(45,2);return}this.finishOp(43,1)}readToken_gt(){let{pos}=this.state,next=this.input.charCodeAt(pos+1);
|
|
893
|
+
if(next===62){let size=this.input.charCodeAt(pos+2)===62?3:2;if(this.input.charCodeAt(pos+size)===61){this.finishOp(26,size+1);return}this.finishOp(48,size);return}if(next===61){this.finishOp(45,2);return}this.finishOp(44,1)}readToken_eq_excl(code2){let next=this.input.charCodeAt(this.state.pos+1);if(next===61){this.finishOp(42,this.input.charCodeAt(this.state.pos+2)===61?3:2);return}if(code2===61&&next===62){this.state.pos+=2,this.finishToken(15);return}this.finishOp(code2===61?25:31,1)}readToken_question(){
|
|
894
|
+
let next=this.input.charCodeAt(this.state.pos+1),next2=this.input.charCodeAt(this.state.pos+2);next===63?next2===61?this.finishOp(26,3):this.finishOp(36,2):next===46&&!(next2>=48&&next2<=57)?(this.state.pos+=2,this.finishToken(14)):(++this.state.pos,this.finishToken(13))}getTokenFromCode(code2){switch(code2){case 46:this.readToken_dot();return;case 40:++this.state.pos,this.finishToken(6);return;case 41:++this.state.pos,this.finishToken(7);return;case 59:++this.state.pos,this.finishToken(9);return;case 44:
|
|
895
|
+
++this.state.pos,this.finishToken(8);return;case 91:++this.state.pos,this.finishToken(0);return;case 93:++this.state.pos,this.finishToken(1);return;case 123:++this.state.pos,this.finishToken(2);return;case 125:++this.state.pos,this.finishToken(4);return;case 58:this.hasPlugin("functionBind")&&this.input.charCodeAt(this.state.pos+1)===58?this.finishOp(11,2):(++this.state.pos,this.finishToken(10));return;case 63:this.readToken_question();return;case 96:this.readTemplateToken();return;case 48:{let next=this.
|
|
896
|
+
input.charCodeAt(this.state.pos+1);if(next===120||next===88){this.readRadixNumber(16);return}if(next===111||next===79){this.readRadixNumber(8);return}if(next===98||next===66){this.readRadixNumber(2);return}}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:this.readNumber(!1);return;case 34:case 39:this.readString(code2);return;case 47:this.readToken_slash();return;case 37:case 42:this.readToken_mult_modulo(code2);return;case 124:case 38:this.readToken_pipe_amp(code2);return;case 94:
|
|
897
|
+
this.readToken_caret();return;case 43:case 45:this.readToken_plus_min(code2);return;case 60:this.readToken_lt();return;case 62:this.readToken_gt();return;case 61:case 33:this.readToken_eq_excl(code2);return;case 126:this.finishOp(32,1);return;case 64:this.readToken_atSign();return;case 35:this.readToken_numberSign();return;case 92:this.readWord();return;default:if(isIdentifierStart(code2)){this.readWord(code2);return}}throw this.raise(Errors.InvalidOrUnexpectedToken,this.state.curPosition(),{unexpected:String.
|
|
898
|
+
fromCodePoint(code2)})}finishOp(type,size){let str=this.input.slice(this.state.pos,this.state.pos+size);this.state.pos+=size,this.finishToken(type,str)}readRegexp(){let startLoc=this.state.startLoc,start=this.state.start+1,escaped,inClass,{pos}=this.state;for(;;++pos){if(pos>=this.length)throw this.raise(Errors.UnterminatedRegExp,createPositionWithColumnOffset(startLoc,1));let ch=this.input.charCodeAt(pos);if(isNewLine(ch))throw this.raise(Errors.UnterminatedRegExp,createPositionWithColumnOffset(
|
|
899
|
+
startLoc,1));if(escaped)escaped=!1;else{if(ch===91)inClass=!0;else if(ch===93&&inClass)inClass=!1;else if(ch===47&&!inClass)break;escaped=ch===92}}let content=this.input.slice(start,pos);++pos;let mods="",nextPos=()=>createPositionWithColumnOffset(startLoc,pos+2-start);for(;pos<this.length;){let cp=this.codePointAtPos(pos),char=String.fromCharCode(cp);if(VALID_REGEX_FLAGS.has(cp))cp===118?mods.includes("u")&&this.raise(Errors.IncompatibleRegExpUVFlags,nextPos()):cp===117&&mods.includes("v")&&this.
|
|
900
|
+
raise(Errors.IncompatibleRegExpUVFlags,nextPos()),mods.includes(char)&&this.raise(Errors.DuplicateRegExpFlags,nextPos());else if(isIdentifierChar(cp)||cp===92)this.raise(Errors.MalformedRegExpFlags,nextPos());else break;++pos,mods+=char}this.state.pos=pos,this.finishToken(134,{pattern:content,flags:mods})}readInt(radix,len,forceLen=!1,allowNumSeparator=!0){let{n,pos}=readInt(this.input,this.state.pos,this.state.lineStart,this.state.curLine,radix,len,forceLen,allowNumSeparator,this.errorHandlers_readInt,
|
|
901
|
+
!1);return this.state.pos=pos,n}readRadixNumber(radix){let start=this.state.pos,startLoc=this.state.curPosition(),isBigInt=!1;this.state.pos+=2;let val=this.readInt(radix);if(val==null&&this.raise(Errors.InvalidDigit,createPositionWithColumnOffset(startLoc,2),{radix}),this.input.charCodeAt(this.state.pos)===110&&(++this.state.pos,isBigInt=!0),isIdentifierStart(this.codePointAtPos(this.state.pos)))throw this.raise(Errors.NumberIdentifier,this.state.curPosition());if(isBigInt){let str=this.input.slice(
|
|
902
|
+
start,this.state.pos).replace(/[_n]/g,"");this.finishToken(133,str);return}this.finishToken(132,val)}readNumber(startsWithDot){let start=this.state.pos,startLoc=this.state.curPosition(),isFloat=!1,isBigInt=!1,isOctal=!1;!startsWithDot&&this.readInt(10)===null&&this.raise(Errors.InvalidNumber,this.state.curPosition());let hasLeadingZero=this.state.pos-start>=2&&this.input.charCodeAt(start)===48;if(hasLeadingZero){let integer2=this.input.slice(start,this.state.pos);if(this.recordStrictModeErrors(Errors.
|
|
903
|
+
StrictOctalLiteral,startLoc),!this.state.strict){let underscorePos=integer2.indexOf("_");underscorePos>0&&this.raise(Errors.ZeroDigitNumericSeparator,createPositionWithColumnOffset(startLoc,underscorePos))}isOctal=hasLeadingZero&&!/[89]/.test(integer2)}let next=this.input.charCodeAt(this.state.pos);next===46&&!isOctal&&(++this.state.pos,this.readInt(10),isFloat=!0,next=this.input.charCodeAt(this.state.pos)),(next===69||next===101)&&!isOctal&&(next=this.input.charCodeAt(++this.state.pos),(next===
|
|
904
|
+
43||next===45)&&++this.state.pos,this.readInt(10)===null&&this.raise(Errors.InvalidOrMissingExponent,startLoc),isFloat=!0,next=this.input.charCodeAt(this.state.pos));let str=this.input.slice(start,this.state.pos).replaceAll("_","");if(next===110&&((isFloat||hasLeadingZero)&&this.raise(Errors.InvalidBigIntLiteral,startLoc),++this.state.pos,isBigInt=!0),isIdentifierStart(this.codePointAtPos(this.state.pos)))throw this.raise(Errors.NumberIdentifier,this.state.curPosition());if(isBigInt){this.finishToken(
|
|
905
|
+
133,str);return}let val=isOctal?parseInt(str,8):parseFloat(str);this.finishToken(132,val)}readCodePoint(throwOnInvalid){let{code:code2,pos}=readCodePoint(this.input,this.state.pos,this.state.lineStart,this.state.curLine,throwOnInvalid,this.errorHandlers_readCodePoint);return this.state.pos=pos,code2}readString(quote){let{str,pos,curLine,lineStart}=readStringContents(quote===34?"double":"single",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_string);
|
|
906
|
+
this.state.pos=pos+1,this.state.lineStart=lineStart,this.state.curLine=curLine,this.finishToken(131,str)}readTemplateContinuation(){this.match(4)||this.unexpected(null,4),this.state.pos--,this.readTemplateToken()}readTemplateToken(){let opening=this.input[this.state.pos],{str,firstInvalidLoc,pos,curLine,lineStart}=readStringContents("template",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_template);this.state.pos=pos+1,this.state.lineStart=
|
|
907
|
+
lineStart,this.state.curLine=curLine,firstInvalidLoc&&(this.state.firstInvalidTemplateEscapePos=new Position(firstInvalidLoc.curLine,firstInvalidLoc.pos-firstInvalidLoc.lineStart,this.sourceToOffsetPos(firstInvalidLoc.pos))),this.input.codePointAt(pos)===96?this.finishToken(20,firstInvalidLoc?null:opening+str+"`"):(this.state.pos++,this.finishToken(21,firstInvalidLoc?null:opening+str+"${"))}recordStrictModeErrors(toParseError,at){let index=at.index;this.state.strict&&!this.state.strictErrors.has(
|
|
908
|
+
index)?this.raise(toParseError,at):this.state.strictErrors.set(index,[toParseError,at])}readWord1(firstCode){this.state.containsEsc=!1;let word="",start=this.state.pos,chunkStart=this.state.pos;for(firstCode!==void 0&&(this.state.pos+=firstCode<=65535?1:2);this.state.pos<this.length;){let ch=this.codePointAtPos(this.state.pos);if(isIdentifierChar(ch))this.state.pos+=ch<=65535?1:2;else if(ch===92){this.state.containsEsc=!0,word+=this.input.slice(chunkStart,this.state.pos);let escStart=this.state.
|
|
909
|
+
curPosition(),identifierCheck=this.state.pos===start?isIdentifierStart:isIdentifierChar;if(this.input.charCodeAt(++this.state.pos)!==117){this.raise(Errors.MissingUnicodeEscape,this.state.curPosition()),chunkStart=this.state.pos-1;continue}++this.state.pos;let esc=this.readCodePoint(!0);esc!==null&&(identifierCheck(esc)||this.raise(Errors.EscapedCharNotAnIdentifier,escStart),word+=String.fromCodePoint(esc)),chunkStart=this.state.pos}else break}return word+this.input.slice(chunkStart,this.state.pos)}readWord(firstCode){
|
|
910
|
+
let word=this.readWord1(firstCode),type=keywords$1.get(word);type!==void 0?this.finishToken(type,tokenLabelName(type)):this.finishToken(129,word)}checkKeywordEscapes(){let{type}=this.state;tokenIsKeyword(type)&&this.state.containsEsc&&this.raise(Errors.InvalidEscapedReservedWord,this.state.startLoc,{reservedWord:tokenLabelName(type)})}raise(toParseError,at,details={}){let loc=at instanceof Position?at:typeof at=="number"?this.getLoc(at):this.optionFlags&256?at.loc.start:this.getLoc(at.start),pos=at instanceof
|
|
911
|
+
Position?loc.index:typeof at=="number"?at:at.start,error=toParseError(loc,pos,details);if(!(this.optionFlags&4096))throw error;return this.isLookahead||this.state.errors.push(error),error}raiseOverwrite(toParseError,at,details={}){let loc=at instanceof Position?at:this.optionFlags&256?at.loc.start:this.getLoc(at.start),pos=at instanceof Position?loc.index:at.start,errors=this.state.errors;for(let i=errors.length-1;i>=0;i--){let error=errors[i];if(error.pos===pos)return errors[i]=toParseError(loc,
|
|
912
|
+
pos,details);if(error.pos<pos)break}return this.raise(toParseError,loc,details)}updateContext(prevType){}unexpected(loc,type){throw this.raise(Errors.UnexpectedToken,loc??this.state.startLoc,{expected:type?tokenLabelName(type):null})}expectPlugin(pluginName,loc){if(this.hasPlugin(pluginName))return!0;throw this.raise(Errors.MissingPlugin,loc??this.state.startLoc,{missingPlugin:[pluginName]})}expectOnePlugin(pluginNames){if(!pluginNames.some(name=>this.hasPlugin(name)))throw this.raise(Errors.MissingOneOfPlugins,
|
|
913
|
+
this.state.startLoc,{missingPlugin:pluginNames})}errorBuilder(error){return(pos,lineStart,curLine)=>{this.raise(error,buildPosition(pos,lineStart,curLine))}}errorHandlers_readInt={invalidDigit:(pos,lineStart,curLine,radix)=>{this.raise(Errors.InvalidDigit,buildPosition(pos,lineStart,curLine),{radix})},numericSeparatorInEscapeSequence:this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(Errors.UnexpectedNumericSeparator)};errorHandlers_readCodePoint={
|
|
914
|
+
...this.errorHandlers_readInt,invalidEscapeSequence:this.errorBuilder(Errors.InvalidEscapeSequence),invalidCodePoint:this.errorBuilder(Errors.InvalidCodePoint)};errorHandlers_readStringContents_string={...this.errorHandlers_readCodePoint,strictNumericEscape:(pos,lineStart,curLine)=>{this.recordStrictModeErrors(Errors.StrictNumericEscape,buildPosition(pos,lineStart,curLine))},unterminated:(pos,lineStart,curLine)=>{throw this.raise(Errors.UnterminatedString,buildPosition(pos-1,lineStart,curLine))}};errorHandlers_readStringContents_template={
|
|
915
|
+
...this.errorHandlers_readCodePoint,strictNumericEscape:this.errorBuilder(Errors.StrictNumericEscape),unterminated:(pos,lineStart,curLine)=>{throw this.raise(Errors.UnterminatedTemplate,buildPosition(pos,lineStart,curLine))}}},ClassScope=class{privateNames=new Set;loneAccessors=new Map;undefinedPrivateNames=new Map},ClassScopeHandler=class{parser;stack=[];constructor(parser){this.parser=parser}current(){return this.stack[this.stack.length-1]}enter(){this.stack.push(new ClassScope)}exit(){let oldClassScope=this.
|
|
916
|
+
stack.pop(),current2=this.current();for(let[name,loc]of Array.from(oldClassScope.undefinedPrivateNames))current2?current2.undefinedPrivateNames.has(name)||current2.undefinedPrivateNames.set(name,loc):this.parser.raise(Errors.InvalidPrivateFieldResolution,loc,{identifierName:name})}declarePrivateName(name,elementType,loc){let{privateNames,loneAccessors,undefinedPrivateNames}=this.current(),redefined=privateNames.has(name);if(elementType&3){let accessor=redefined&&loneAccessors.get(name);if(accessor){
|
|
917
|
+
let oldStatic=accessor&4,newStatic=elementType&4,oldKind=accessor&3,newKind=elementType&3;redefined=oldKind===newKind||oldStatic!==newStatic,redefined||loneAccessors.delete(name)}else redefined||loneAccessors.set(name,elementType)}redefined&&this.parser.raise(Errors.PrivateNameRedeclaration,loc,{identifierName:name}),privateNames.add(name),undefinedPrivateNames.delete(name)}usePrivateName(name,loc){let classScope;for(classScope of this.stack)if(classScope.privateNames.has(name))return;classScope?
|
|
918
|
+
classScope.undefinedPrivateNames.set(name,loc):this.parser.raise(Errors.InvalidPrivateFieldResolution,loc,{identifierName:name})}},ExpressionScope=class{constructor(type=0){this.type=type}canBeArrowParameterDeclaration(){return this.type===2||this.type===1}isCertainlyParameterDeclaration(){return this.type===3}},ArrowHeadParsingScope=class extends ExpressionScope{declarationErrors=new Map;constructor(type){super(type)}recordDeclarationError(ParsingErrorClass,index){this.declarationErrors.set(index,
|
|
919
|
+
ParsingErrorClass)}clearDeclarationError(index){this.declarationErrors.delete(index)}iterateErrors(iterator){this.declarationErrors.forEach(iterator)}},ExpressionScopeHandler=class{parser;stack=[new ExpressionScope];constructor(parser){this.parser=parser}enter(scope){this.stack.push(scope)}exit(){this.stack.pop()}recordParameterInitializerError(toParseError,loc){let{stack}=this,i=stack.length-1,scope=stack[i];for(;!scope.isCertainlyParameterDeclaration();){if(scope.canBeArrowParameterDeclaration())
|
|
920
|
+
scope.recordDeclarationError(toParseError,loc);else return;scope=stack[--i]}this.parser.raise(toParseError,loc)}recordArrowParameterBindingError(error,node){let{stack}=this,scope=stack[stack.length-1],origin=node.start;if(scope.isCertainlyParameterDeclaration())this.parser.raise(error,origin);else if(scope.canBeArrowParameterDeclaration())scope.recordDeclarationError(error,origin);else return}recordAsyncArrowParametersError(at){let{stack}=this,i=stack.length-1,scope=stack[i];for(;scope.canBeArrowParameterDeclaration();)
|
|
921
|
+
scope.type===2&&scope.recordDeclarationError(Errors.AwaitBindingIdentifier,at),scope=stack[--i]}validateAsPattern(){let{stack}=this,currentScope=stack[stack.length-1];currentScope.canBeArrowParameterDeclaration()&¤tScope.iterateErrors((toParseError,key)=>{this.parser.raise(toParseError,key);let i=stack.length-2,scope=stack[i];for(;scope.canBeArrowParameterDeclaration();)scope.clearDeclarationError(key),scope=stack[--i]})}};function newParameterDeclarationScope(){return new ExpressionScope(
|
|
922
|
+
3)}function newArrowHeadScope(){return new ArrowHeadParsingScope(1)}function newAsyncArrowScope(){return new ArrowHeadParsingScope(2)}function newExpressionScope(){return new ExpressionScope}var ProductionParameterHandler=class{stacks=[];enter(flags){this.stacks.push(flags)}exit(){this.stacks.pop()}currentFlags(){return this.stacks[this.stacks.length-1]}get hasAwait(){return(this.currentFlags()&2)>0}get hasYield(){return(this.currentFlags()&1)>0}get hasReturn(){return(this.currentFlags()&4)>0}get hasIn(){
|
|
923
|
+
return(this.currentFlags()&8)>0}get inFSharpPipelineDirectBody(){return(this.currentFlags()&16)===0}};function functionFlags(isAsync,isGenerator){return(isAsync?2:0)|(isGenerator?1:0)}var UtilParser=class extends Tokenizer{addExtra(node,key,value,enumerable=!0){if(!node)return;let{extra}=node;extra==null&&(extra={},node.extra=extra),enumerable?extra[key]=value:Object.defineProperty(extra,key,{enumerable,value})}isContextual(token){return this.state.type===token&&!this.state.containsEsc}isUnparsedContextual(nameStart,name){
|
|
924
|
+
if(this.input.startsWith(name,nameStart)){let nextCh=this.input.charCodeAt(nameStart+name.length);return!(isIdentifierChar(nextCh)||(nextCh&64512)===55296)}return!1}isLookaheadContextual(name){let next=this.nextTokenStart();return this.isUnparsedContextual(next,name)}eatContextual(token){return this.isContextual(token)?(this.next(),!0):!1}expectContextual(token,toParseError){if(!this.eatContextual(token)){if(toParseError!=null)throw this.raise(toParseError,this.state.startLoc);this.unexpected(null,
|
|
925
|
+
token)}}canInsertSemicolon(){return this.match(136)||this.match(4)||this.hasPrecedingLineBreak()}hasPrecedingLineBreak(){return hasNewLine(this.input,this.offsetToSourcePos(this.state.lastTokEndLoc.index),this.state.start)}hasFollowingLineBreak(){return hasNewLine(this.input,this.state.end,this.nextTokenStart())}isLineTerminator(){return this.eat(9)||this.canInsertSemicolon()}semicolon(allowAsi=!0){(allowAsi?this.isLineTerminator():this.eat(9))||this.raise(Errors.MissingSemicolon,this.state.lastTokEndLoc)}expect(type,loc){
|
|
926
|
+
this.eat(type)||this.unexpected(loc,type)}tryParse(fn,oldState=this.state.clone()){let abortSignal={node:null};try{let node=fn((node2=null)=>{throw abortSignal.node=node2,abortSignal});if(this.state.errors.length>oldState.errors.length){let failState=this.state;return this.state=oldState,this.state.tokensLength=failState.tokensLength,{node,error:failState.errors[oldState.errors.length],thrown:!1,aborted:!1,failState}}return{node,error:null,thrown:!1,aborted:!1,failState:null}}catch(error){let failState=this.
|
|
927
|
+
state;if(this.state=oldState,error instanceof SyntaxError)return{node:null,error,thrown:!0,aborted:!1,failState};if(error===abortSignal)return{node:abortSignal.node,error:null,thrown:!1,aborted:!0,failState};throw error}}checkExpressionErrors(refExpressionErrors,andThrow){if(!refExpressionErrors)return!1;let{shorthandAssignLoc,doubleProtoLoc,privateKeyLoc,optionalParametersLoc,voidPatternLoc}=refExpressionErrors,hasErrors=!!shorthandAssignLoc||!!doubleProtoLoc||!!optionalParametersLoc||!!privateKeyLoc||
|
|
928
928
|
!!voidPatternLoc;if(!andThrow)return hasErrors;shorthandAssignLoc!=null&&this.raise(Errors.InvalidCoverInitializedName,shorthandAssignLoc),doubleProtoLoc!=null&&this.raise(Errors.DuplicateProto,doubleProtoLoc),privateKeyLoc!=null&&this.raise(Errors.UnexpectedPrivateField,privateKeyLoc),optionalParametersLoc!=null&&this.unexpected(optionalParametersLoc),voidPatternLoc!=null&&this.raise(Errors.InvalidCoverDiscardElement,voidPatternLoc)}isLiteralPropertyName(){return tokenIsLiteralPropertyName(this.
|
|
929
929
|
state.type)}isPrivateName(node){return node.type==="PrivateName"}getPrivateNameSV(node){return node.id.name}hasPropertyAsPrivateName(node){return(node.type==="MemberExpression"||node.type==="OptionalMemberExpression")&&this.isPrivateName(node.property)}isObjectProperty(node){return node.type==="ObjectProperty"}isObjectMethod(node){return node.type==="ObjectMethod"}initializeScopes(inModule=this.options.sourceType==="module"){let oldLabels=this.state.labels;this.state.labels=[];let oldExportedIdentifiers=this.
|
|
930
930
|
exportedIdentifiers;this.exportedIdentifiers=new Set;let oldInModule=this.inModule;this.inModule=inModule;let oldScope=this.scope,ScopeHandler2=this.getScopeHandler();this.scope=new ScopeHandler2(this,inModule);let oldProdParam=this.prodParam;this.prodParam=new ProductionParameterHandler;let oldClassScope=this.classScope;this.classScope=new ClassScopeHandler(this);let oldExpressionScope=this.expressionScope;return this.expressionScope=new ExpressionScopeHandler(this),()=>{this.state.labels=oldLabels,
|
|
@@ -946,66 +946,69 @@ node.value);case"SpreadElement":return this.isAssignable(node.argument);case"Arr
|
|
|
946
946
|
return this.next(),node.argument=this.parseMaybeAssignAllowIn(refExpressionErrors),this.finishNode(node,"SpreadElement")}parseRestBinding(){let node=this.startNode();this.next();let argument=this.parseBindingAtom();return argument.type==="VoidPattern"&&this.raise(Errors.UnexpectedVoidPattern,argument),node.argument=argument,this.finishNode(node,"RestElement")}parseBindingAtom(){switch(this.state.type){case 0:{let node=this.startNode();return this.next(),node.elements=this.parseBindingList(1,93,1),
|
|
947
947
|
this.finishNode(node,"ArrayPattern")}case 2:return this.parseObjectLike(4,!0);case 84:return this.parseVoidPattern(null)}return this.parseIdentifier()}parseBindingList(close,closeCharCode,flags){let allowEmpty=flags&1,elts=[],first=!0;for(;!this.eat(close);)if(first?first=!1:this.expect(8),allowEmpty&&this.match(8))elts.push(null);else{if(this.eat(close))break;if(this.match(17)){let rest=this.parseRestBinding();if(flags&2&&(rest=this.parseFunctionParamType(rest)),elts.push(rest),!this.checkCommaAfterRest(
|
|
948
948
|
closeCharCode)){this.expect(close);break}}else{let decorators=[];if(flags&2)for(this.match(22)&&this.hasPlugin("decorators")&&this.raise(Errors.UnsupportedParameterDecorator,this.state.startLoc);this.match(22);)decorators.push(this.parseDecorator());elts.push(this.parseBindingElement(flags,decorators))}}return elts}parseBindingRestProperty(prop){return this.next(),this.hasPlugin("discardBinding")&&this.match(84)?(prop.argument=this.parseVoidPattern(null),this.raise(Errors.UnexpectedVoidPattern,prop.
|
|
949
|
-
argument)):prop.argument=this.parseIdentifier(),this.checkCommaAfterRest(125),this.finishNode(prop,"RestElement")}parseBindingProperty(){let{type,startLoc}=this.state;if(type===17)return this.parseBindingRestProperty(this.startNode());let prop=this.startNode();return type===
|
|
949
|
+
argument)):prop.argument=this.parseIdentifier(),this.checkCommaAfterRest(125),this.finishNode(prop,"RestElement")}parseBindingProperty(){let{type,startLoc}=this.state;if(type===17)return this.parseBindingRestProperty(this.startNode());let prop=this.startNode();return type===135?(this.expectPlugin("destructuringPrivate",startLoc),this.classScope.usePrivateName(this.state.value,startLoc),prop.key=this.parsePrivateName()):this.parsePropertyName(prop),prop.method=!1,this.parseObjPropValue(prop,startLoc,
|
|
950
950
|
!1,!1,!0,!1)}parseBindingElement(flags,decorators){let{startLoc}=this.state,left=this.parseMaybeDefault();return flags&2&&this.parseFunctionParamType(left),decorators.length&&(left.decorators=decorators,this.resetStartLocationFromNode(left,decorators[0])),this.parseMaybeDefault(startLoc,left)}parseFunctionParamType(param){return param}parseMaybeDefault(startLoc,left){if(startLoc??=this.state.startLoc,left=left??this.parseBindingAtom(),!this.eat(25))return left;let node=this.startNodeAt(startLoc);
|
|
951
951
|
return left.type==="VoidPattern"&&this.raise(Errors.VoidPatternInitializer,left),node.left=left,node.right=this.parseMaybeAssignAllowIn(),this.finishNode(node,"AssignmentPattern")}isValidLVal(type,disallowCallExpression,isUnparenthesizedInAssign,binding){switch(type){case"AssignmentPattern":return"left";case"RestElement":return"argument";case"ObjectProperty":return"value";case"ParenthesizedExpression":return"expression";case"ArrayPattern":return"elements";case"ObjectPattern":return"properties";case"\
|
|
952
952
|
VoidPattern":return!0;case"CallExpression":if(!disallowCallExpression&&!this.state.strict&&this.optionFlags&16384)return!0}return!1}isOptionalMemberExpression(expression){return expression.type==="OptionalMemberExpression"}checkLVal(expression,ancestor,binding=64,checkClashes=!1,strictModeChanged=!1,hasParenthesizedAncestor=!1,disallowCallExpression=!1){let type=expression.type;if(this.isObjectMethod(expression))return;let isOptionalMemberExpression=this.isOptionalMemberExpression(expression);if(isOptionalMemberExpression||
|
|
953
953
|
type==="MemberExpression"){isOptionalMemberExpression&&(this.expectPlugin("optionalChainingAssign",expression.start),ancestor.type!=="AssignmentExpression"&&this.raise(Errors.InvalidLhsOptionalChaining,expression,{ancestor})),binding!==64&&this.raise(Errors.InvalidPropertyBindingPattern,expression);return}if(type==="Identifier"){this.checkIdentifier(expression,binding,strictModeChanged);let{name}=expression;checkClashes&&(checkClashes.has(name)?this.raise(Errors.ParamDupe,expression):checkClashes.
|
|
954
|
-
add(name));return}else type==="VoidPattern"&&ancestor.type==="CatchClause"&&this.raise(Errors.VoidPatternCatchClauseParam,expression);let unwrappedExpression=unwrapParenthesizedExpression(expression);disallowCallExpression||=unwrappedExpression.type==="CallExpression"&&(unwrappedExpression.callee.type==="Import"||unwrappedExpression.callee.type==="Super");let validity=this.isValidLVal(type,disallowCallExpression,!(hasParenthesizedAncestor||expression.extra?.parenthesized)&&ancestor.
|
|
955
|
-
|
|
956
|
-
child&&this.checkLVal(child,nextAncestor,binding,checkClashes,strictModeChanged,isParenthesizedExpression,!0);else val&&this.checkLVal(val,nextAncestor,binding,checkClashes,strictModeChanged,isParenthesizedExpression,disallowCallExpression)}checkIdentifier(at,bindingType,strictModeChanged=!1){this.
|
|
957
|
-
this.
|
|
958
|
-
|
|
959
|
-
let key=prop.key;return(key.type==="Identifier"?key.name:key.value)==="__proto__"?(sawProto&&(refExpressionErrors?refExpressionErrors.doubleProtoLoc===null&&(refExpressionErrors.doubleProtoLoc=this.getLoc(key.start)):this.raise(Errors.DuplicateProto,key)),!0):sawProto}shouldExitDescending(expr){return expr.type==="ArrowFunctionExpression"&&!expr.extra?.parenthesized}getExpression(){if(this.enterInitialScopes(),
|
|
960
|
-
state.startLoc);let expr=this.parseExpression();if(!this.match(
|
|
961
|
-
this.allowInAnd(()=>this.parseExpressionBase(refExpressionErrors))}parseExpressionBase(refExpressionErrors){let startLoc=this.state.startLoc,expr=this.parseMaybeAssign(refExpressionErrors);if(this.match(8)){let node=this.startNodeAt(startLoc);for(node.expressions=[expr];this.eat(8);)node.expressions.push(this.parseMaybeAssign(refExpressionErrors));return this.toReferencedList(node.expressions),this.finishNode(
|
|
962
|
-
return this.disallowInAnd(()=>this.parseMaybeAssign(refExpressionErrors))}parseMaybeAssignAllowIn(refExpressionErrors,isParenItem){return this.allowInAnd(()=>this.parseMaybeAssign(refExpressionErrors,isParenItem))}setOptionalParametersError(refExpressionErrors){refExpressionErrors.optionalParametersLoc=this.state.startLoc}parseMaybeAssign(refExpressionErrors,isParenItem){let startLoc=this.state.startLoc,isYield=this.
|
|
963
|
-
parseYield(startLoc);return isParenItem&&(left2=this.parseParenItem(left2,startLoc)),left2}let ownExpressionErrors;refExpressionErrors?ownExpressionErrors=!1:(refExpressionErrors=new ExpressionErrors,ownExpressionErrors=!0),this.state.canStartArrow=!0;let left=this.parseMaybeConditional(refExpressionErrors);if(isParenItem&&(left=this.parseParenItem(left,startLoc)),tokenIsAssignment(this.state.type)
|
|
964
|
-
25)){this.toAssignable(left,!0),node.left=left;let startIndex=startLoc.index;refExpressionErrors.doubleProtoLoc!=null&&refExpressionErrors.doubleProtoLoc.index>=startIndex&&(refExpressionErrors.doubleProtoLoc=null),refExpressionErrors.shorthandAssignLoc!=null&&refExpressionErrors.shorthandAssignLoc.index>=startIndex&&(refExpressionErrors.
|
|
965
|
-
refExpressionErrors.privateKeyLoc=null),refExpressionErrors.voidPatternLoc!=null&&refExpressionErrors.voidPatternLoc.index>=startIndex&&(refExpressionErrors.voidPatternLoc=null)}else node.left=left;return this.next(),node.right=this.parseMaybeAssign(),this.checkLVal(left,this.finishNode(node,"AssignmentExpression"),void 0,void 0,
|
|
966
|
-
state;if((this.hasPlugin("v8intrinsic")?tokenCanStartExpression(type):tokenCanStartExpression(type)&&!this.match(50))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(Errors.YieldNotInGeneratorFunction,startLoc),this.parseYield(startLoc)}return left}parseMaybeConditional(refExpressionErrors){let startLoc=this.
|
|
967
|
-
if(this.eat(13)){let node=this.startNodeAt(startLoc);return node.test=expr,node.consequent=this.parseMaybeAssignAllowIn(),this.expect(10),node.alternate=this.parseMaybeAssign(),this.finishNode(node,"ConditionalExpression")}return expr}parseMaybeUnaryOrPrivate(refExpressionErrors){return this.
|
|
968
|
-
shouldExitDescending(expr)?expr:(this.state.canStartArrow=!1,this.parseExprOp(expr,startLoc,-1))}
|
|
969
|
-
op)
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
this.
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
this.
|
|
997
|
-
|
|
998
|
-
node.
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
954
|
+
add(name));return}else type==="VoidPattern"&&ancestor.type==="CatchClause"&&this.raise(Errors.VoidPatternCatchClauseParam,expression);let unwrappedExpression=unwrapParenthesizedExpression(expression);disallowCallExpression||=binding!==64||unwrappedExpression.type==="CallExpression"&&(unwrappedExpression.callee.type==="Import"||unwrappedExpression.callee.type==="Super");let validity=this.isValidLVal(type,disallowCallExpression,!(hasParenthesizedAncestor||expression.extra?.parenthesized)&&ancestor.
|
|
955
|
+
type==="AssignmentExpression",binding);if(validity===!0)return;if(validity===!1){let ParseErrorClass=binding===64?Errors.InvalidLhs:Errors.InvalidLhsBinding;this.raise(ParseErrorClass,expression,{ancestor});return}let key,isParenthesizedExpression;typeof validity=="string"?(key=validity,isParenthesizedExpression=type==="ParenthesizedExpression"):[key,isParenthesizedExpression]=validity;let nextAncestor=type==="ArrayPattern"||type==="ObjectPattern"?{type}:ancestor,val=expression[key];if(Array.isArray(
|
|
956
|
+
val))for(let child of val)child&&this.checkLVal(child,nextAncestor,binding,checkClashes,strictModeChanged,isParenthesizedExpression,!0);else val&&this.checkLVal(val,nextAncestor,binding,checkClashes,strictModeChanged,isParenthesizedExpression,disallowCallExpression)}checkIdentifier(at,bindingType,strictModeChanged=!1){this.checkStrictBindReservedWord(at,bindingType,strictModeChanged),bindingType&8192&&at.name==="let"&&this.raise(Errors.LetInLexicalBinding,at),bindingType&64||this.declareNameFromIdentifier(
|
|
957
|
+
at,bindingType)}checkStrictBindReservedWord(at,bindingType,strictModeChanged=!1){this.state.strict&&(strictModeChanged?isStrictBindReservedWord(at.name,this.inModule):isStrictBindOnlyReservedWord(at.name))&&(bindingType===64?this.raise(Errors.StrictEvalArguments,at,{referenceName:at.name}):this.raise(Errors.StrictEvalArgumentsBinding,at,{bindingName:at.name}))}declareNameFromIdentifier(identifier,binding){this.scope.declareName(identifier.name,binding,identifier.start)}checkToRestConversion(node,allowPattern){
|
|
958
|
+
switch(node.type){case"ParenthesizedExpression":this.checkToRestConversion(node.expression,allowPattern);break;case"Identifier":case"MemberExpression":break;case"ArrayExpression":case"ObjectExpression":if(allowPattern)break;default:this.raise(Errors.InvalidRestAssignmentPattern,node)}}checkCommaAfterRest(close){return this.match(8)?(this.raise(this.lookaheadCharCode()===close?Errors.RestTrailingComma:Errors.ElementAfterRest,this.state.startLoc),!0):!1}},ExpressionParser=class extends LValParser{checkProto(prop,sawProto,refExpressionErrors){
|
|
959
|
+
if(prop.type==="SpreadElement"||this.isObjectMethod(prop)||prop.computed||prop.shorthand)return sawProto;let key=prop.key;return(key.type==="Identifier"?key.name:key.value)==="__proto__"?(sawProto&&(refExpressionErrors?refExpressionErrors.doubleProtoLoc===null&&(refExpressionErrors.doubleProtoLoc=this.getLoc(key.start)):this.raise(Errors.DuplicateProto,key)),!0):sawProto}shouldExitDescending(expr){return expr.type==="ArrowFunctionExpression"&&!expr.extra?.parenthesized}getExpression(){if(this.enterInitialScopes(),
|
|
960
|
+
this.nextToken(),this.match(136))throw this.raise(Errors.ParseExpressionEmptyInput,this.state.startLoc);let expr=this.parseExpression();if(!this.match(136))throw this.raise(Errors.ParseExpressionExpectsEOF,this.state.startLoc,{unexpected:this.input.codePointAt(this.state.start)});return this.finalizeRemainingComments(),expr.comments=this.comments,expr.errors=this.state.errors,this.optionFlags&512&&(expr.tokens=createExportedTokens(this.tokens)),expr}parseExpression(disallowIn,refExpressionErrors){
|
|
961
|
+
return disallowIn?this.disallowInAnd(()=>this.parseExpressionBase(refExpressionErrors)):this.allowInAnd(()=>this.parseExpressionBase(refExpressionErrors))}parseExpressionBase(refExpressionErrors){let startLoc=this.state.startLoc,expr=this.parseMaybeAssign(refExpressionErrors);if(this.match(8)){let node=this.startNodeAt(startLoc);for(node.expressions=[expr];this.eat(8);)node.expressions.push(this.parseMaybeAssign(refExpressionErrors));return this.toReferencedList(node.expressions),this.finishNode(
|
|
962
|
+
node,"SequenceExpression")}return expr}parseMaybeAssignDisallowIn(refExpressionErrors){return this.disallowInAnd(()=>this.parseMaybeAssign(refExpressionErrors))}parseMaybeAssignAllowIn(refExpressionErrors,isParenItem){return this.allowInAnd(()=>this.parseMaybeAssign(refExpressionErrors,isParenItem))}setOptionalParametersError(refExpressionErrors){refExpressionErrors.optionalParametersLoc=this.state.startLoc}parseMaybeAssign(refExpressionErrors,isParenItem){let startLoc=this.state.startLoc,isYield=this.
|
|
963
|
+
isContextual(105);if(isYield&&this.prodParam.hasYield){this.next();let left2=this.parseYield(startLoc);return isParenItem&&(left2=this.parseParenItem(left2,startLoc)),left2}let ownExpressionErrors;refExpressionErrors?ownExpressionErrors=!1:(refExpressionErrors=new ExpressionErrors,ownExpressionErrors=!0),this.state.canStartArrow=!0;let left=this.parseMaybeConditional(refExpressionErrors);if(isParenItem&&(left=this.parseParenItem(left,startLoc)),tokenIsAssignment(this.state.type)&&!(this.match(27)&&
|
|
964
|
+
this.state.lastTokEndLoc.index===this.state.regExpAllowedAt)){let node=this.startNodeAt(startLoc),operator=this.state.value;if(node.operator=operator,this.match(25)){this.toAssignable(left,!0),node.left=left;let startIndex=startLoc.index;refExpressionErrors.doubleProtoLoc!=null&&refExpressionErrors.doubleProtoLoc.index>=startIndex&&(refExpressionErrors.doubleProtoLoc=null),refExpressionErrors.shorthandAssignLoc!=null&&refExpressionErrors.shorthandAssignLoc.index>=startIndex&&(refExpressionErrors.
|
|
965
|
+
shorthandAssignLoc=null),refExpressionErrors.privateKeyLoc!=null&&refExpressionErrors.privateKeyLoc.index>=startIndex&&(this.checkDestructuringPrivate(refExpressionErrors),refExpressionErrors.privateKeyLoc=null),refExpressionErrors.voidPatternLoc!=null&&refExpressionErrors.voidPatternLoc.index>=startIndex&&(refExpressionErrors.voidPatternLoc=null)}else node.left=left;return this.next(),node.right=this.parseMaybeAssign(),this.checkLVal(left,this.finishNode(node,"AssignmentExpression"),void 0,void 0,
|
|
966
|
+
void 0,void 0,operator==="||="||operator==="&&="||operator==="??="),node}else ownExpressionErrors&&this.checkExpressionErrors(refExpressionErrors,!0);if(isYield){let{type}=this.state;if((this.hasPlugin("v8intrinsic")?tokenCanStartExpression(type):tokenCanStartExpression(type)&&!this.match(50))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(Errors.YieldNotInGeneratorFunction,startLoc),this.parseYield(startLoc)}return left}parseMaybeConditional(refExpressionErrors){let startLoc=this.
|
|
967
|
+
state.startLoc,expr=this.parseExprOps(refExpressionErrors);return this.shouldExitDescending(expr)?expr:this.parseConditional(expr,startLoc,refExpressionErrors)}parseConditional(expr,startLoc,refExpressionErrors){if(this.eat(13)){let node=this.startNodeAt(startLoc);return node.test=expr,node.consequent=this.parseMaybeAssignAllowIn(),this.expect(10),node.alternate=this.parseMaybeAssign(),this.finishNode(node,"ConditionalExpression")}return expr}parseMaybeUnaryOrPrivate(refExpressionErrors){return this.
|
|
968
|
+
match(135)?this.parsePrivateName():this.parseMaybeUnary(refExpressionErrors)}parseExprOps(refExpressionErrors){let startLoc=this.state.startLoc,expr=this.parseMaybeUnaryOrPrivate(refExpressionErrors);return this.shouldExitDescending(expr)?expr:(this.state.canStartArrow=!1,this.parseExprOp(expr,startLoc,-1))}isEscapedKeywordOperatorAfterLineBreak(){return tokenIsKeyword(this.state.type)&&this.state.containsEsc&&this.hasPrecedingLineBreak()}isBinaryOperator(op){return tokenIsOperator(op)&&(this.prodParam.
|
|
969
|
+
hasIn||op!==54)&&!this.isEscapedKeywordOperatorAfterLineBreak()}parseExprOp(left,leftStartLoc,minPrec){let op=this.state.type,isOperator=this.isBinaryOperator(op);if(this.isPrivateName(left)){let value=this.getPrivateNameSV(left);(minPrec>=tokenOperatorPrecedence(54)||op!==54||!isOperator)&&this.raise(Errors.PrivateInExpectedIn,leftStartLoc,{identifierName:value}),this.classScope.usePrivateName(value,leftStartLoc)}if(isOperator){let prec=tokenOperatorPrecedence(op);if(prec>minPrec){if(op===35&&(this.
|
|
970
|
+
expectPlugin("pipelineOperator"),this.prodParam.inFSharpPipelineDirectBody))return left;let node=this.startNodeAt(leftStartLoc);node.left=left,node.operator=this.state.value;let logical=op===37||op===38,coalesce=op===36;coalesce&&(prec=tokenOperatorPrecedence(38)),this.next(),node.right=this.parseExprOpRightExpr(op,prec);let finishedNode=this.finishNode(node,logical||coalesce?"LogicalExpression":"BinaryExpression"),nextOp=this.state.type;if(coalesce&&(nextOp===37||nextOp===38)||logical&&nextOp===
|
|
971
|
+
36)throw this.raise(Errors.MixingCoalesceWithLogical,this.state.startLoc);return this.parseExprOp(finishedNode,leftStartLoc,minPrec)}}return left}parseExprOpRightExpr(op,prec){switch(op){case 35:switch(this.getPluginOption("pipelineOperator","proposal")){case"hack":return this.withTopicBindingContext(()=>this.parseHackPipeBody());case"fsharp":return this.parseFSharpPipelineBody(prec)}default:return this.parseExprOpBaseRightExpr(op,prec)}}parseExprOpBaseRightExpr(op,prec){let startLoc=this.state.
|
|
972
|
+
startLoc;return this.parseExprOp(this.parseMaybeUnaryOrPrivate(),startLoc,tokenIsRightAssociative(op)?prec-1:prec)}parseHackPipeBody(){let{startLoc}=this.state,body=this.parseMaybeAssign();return UnparenthesizedPipeBodyDescriptions.has(body.type)&&!body.extra?.parenthesized&&this.raise(Errors.PipeUnparenthesizedBody,startLoc,{type:body.type}),this.topicReferenceWasUsedInCurrentContext()||this.raise(Errors.PipeTopicUnused,startLoc),body}checkExponentialAfterUnary(node){this.match(53)&&this.raise(
|
|
973
|
+
Errors.UnexpectedTokenUnaryExponentiation,node.argument)}parseMaybeUnary(refExpressionErrors,sawUnary){let startLoc=this.state.startLoc,isAwait=this.isContextual(93);if(isAwait&&this.recordAwaitIfAllowed()){this.next();let expr2=this.parseAwait(startLoc);return sawUnary||this.checkExponentialAfterUnary(expr2),expr2}let update=this.match(30),node=this.startNode();if(tokenIsPrefix(this.state.type)){node.operator=this.state.value,node.prefix=!0,this.state.canStartArrow=!1,this.match(68)&&this.expectPlugin(
|
|
974
|
+
"throwExpressions");let isDelete=this.match(85);if(this.next(),node.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(refExpressionErrors,!0),this.state.strict&&isDelete){let arg=unwrapParenthesizedExpression(node.argument);arg.type==="Identifier"?this.raise(Errors.StrictDelete,node):this.hasPropertyAsPrivateName(arg)&&this.raise(Errors.DeletePrivateField,node)}if(!update)return sawUnary||this.checkExponentialAfterUnary(node),this.finishNode(node,"UnaryExpression")}let expr=this.
|
|
975
|
+
parseUpdate(node,update,refExpressionErrors);if(isAwait){let{type}=this.state;if((this.hasPlugin("v8intrinsic")?tokenCanStartExpression(type):tokenCanStartExpression(type)&&!this.match(50))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(Errors.AwaitNotInAsyncContext,startLoc),this.parseAwait(startLoc)}return expr}parseUpdate(node,update,refExpressionErrors){if(update){let result=this.finishNode(node,"UpdateExpression");return this.checkLVal(result.argument,result),result}let startLoc=this.
|
|
976
|
+
state.startLoc,expr=this.parseExprSubscripts(refExpressionErrors);if(this.checkExpressionErrors(refExpressionErrors,!1))return expr;for(;tokenIsPostfix(this.state.type)&&!this.canInsertSemicolon();){let node2=this.startNodeAt(startLoc);node2.operator=this.state.value,node2.prefix=!1,node2.argument=expr,this.next(),this.checkLVal(expr,expr=this.finishNode(node2,"UpdateExpression"))}return expr}parseExprSubscripts(refExpressionErrors){let startLoc=this.state.startLoc;if(this.setLoc(startLoc),refExpressionErrors!=
|
|
977
|
+
null&&(this.match(2)||this.match(0))){let atomExpressionErrors=new ExpressionErrors,expr2=this.parseExprAtom(atomExpressionErrors),result=this.parseSubscripts(expr2,startLoc);return result!==expr2?this.checkExpressionErrors(atomExpressionErrors,!0):(refExpressionErrors.shorthandAssignLoc??=atomExpressionErrors.shorthandAssignLoc,refExpressionErrors.doubleProtoLoc??=atomExpressionErrors.doubleProtoLoc,refExpressionErrors.privateKeyLoc??=atomExpressionErrors.privateKeyLoc,refExpressionErrors.optionalParametersLoc??=
|
|
978
|
+
atomExpressionErrors.optionalParametersLoc,refExpressionErrors.voidPatternLoc??=atomExpressionErrors.voidPatternLoc),result}let expr=this.parseExprAtom(refExpressionErrors);return this.shouldExitDescending(expr)?expr:this.parseSubscripts(expr,startLoc)}parseSubscripts(base,startLoc,noCalls){let state={optionalChainMember:!1,maybeAsyncArrow:this.atPossibleAsyncArrow(base),stop:!1};do base=this.parseSubscript(base,startLoc,noCalls,state),state.maybeAsyncArrow=!1;while(!state.stop);return base}parseSubscript(base,startLoc,noCalls,state){
|
|
979
|
+
let{type}=this.state;if(!noCalls&&type===11)return this.parseBind(base,startLoc,state);if(tokenIsTemplate(type))return this.parseTaggedTemplateExpression(base,startLoc,state);let optional=!1;if(type===14){if(noCalls&&(this.raise(Errors.OptionalChainingNoNew,this.state.startLoc),this.lookaheadCharCode()===40))return this.stopParseSubscript(base,state);state.optionalChainMember=optional=!0,this.next()}if(!noCalls&&this.match(6))return this.parseCoverCallAndAsyncArrowHead(base,startLoc,state,optional);
|
|
980
|
+
{let computed=this.eat(0);return computed||optional||this.eat(12)?this.parseMember(base,startLoc,state,computed,optional):this.stopParseSubscript(base,state)}}stopParseSubscript(base,state){return state.stop=!0,base}parseMember(base,startLoc,state,computed,optional){let node=this.startNodeAt(startLoc);return node.object=base,node.computed=computed,computed?(node.property=this.parseExpression(),this.expect(1)):this.match(135)?(base.type==="Super"&&this.raise(Errors.SuperPrivateField,startLoc),this.
|
|
981
|
+
classScope.usePrivateName(this.state.value,this.state.startLoc),node.property=this.parsePrivateName()):node.property=this.parseIdentifier(!0),state.optionalChainMember?(node.optional=optional,this.finishNode(node,"OptionalMemberExpression")):this.finishNode(node,"MemberExpression")}parseBind(base,startLoc,state){let node=this.startNodeAt(startLoc);node.object=base,this.next();let callee=this.parseNoCallExpr(base2=>{throw this.raise(Errors.UnsupportedBindRHS,base2)});if(callee.type==="Super"||callee.
|
|
982
|
+
type==="Import")throw this.raise(Errors.UnsupportedBindRHS,callee);return node.callee=callee,state.stop=!0,this.parseSubscripts(this.finishNode(node,"BindExpression"),startLoc,!1)}parseCoverCallAndAsyncArrowHead(base,startLoc,state,optional){let refExpressionErrors=null;this.next();let node=this.startNodeAt(startLoc);node.callee=base;let{maybeAsyncArrow,optionalChainMember}=state;maybeAsyncArrow&&(this.expressionScope.enter(newAsyncArrowScope()),refExpressionErrors=new ExpressionErrors),optionalChainMember&&
|
|
983
|
+
(node.optional=optional),optional?node.arguments=this.parseCallExpressionArguments():node.arguments=this.parseCallExpressionArguments(base.type!=="Super",node,refExpressionErrors);let finishedNode=this.finishCallExpression(node,optionalChainMember);return maybeAsyncArrow&&this.shouldParseAsyncArrow()&&!optional?(state.stop=!0,this.checkDestructuringPrivate(refExpressionErrors),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),finishedNode=this.parseAsyncArrowFromCallExpression(
|
|
984
|
+
this.startNodeAt(startLoc),finishedNode)):(maybeAsyncArrow&&(this.checkExpressionErrors(refExpressionErrors,!0),this.expressionScope.exit()),this.toReferencedList(node.arguments)),finishedNode}parseTaggedTemplateExpression(base,startLoc,state){let node=this.startNodeAt(startLoc);return node.tag=base,node.quasi=this.parseTemplate(!0),state.optionalChainMember&&this.raise(Errors.OptionalChainingNoTemplate,startLoc),this.finishNode(node,"TaggedTemplateExpression")}atPossibleAsyncArrow(base){return base.
|
|
985
|
+
type==="Identifier"&&base.name==="async"&&this.state.lastTokEndLoc.index===base.end&&!this.canInsertSemicolon()&&base.end-base.start===5&&this.state.canStartArrow}finishCallExpression(node,optional){if(node.callee.type==="Import")if(node.arguments.length===0||node.arguments.length>2)this.raise(Errors.ImportCallArity,node);else for(let arg of node.arguments)arg.type==="SpreadElement"&&this.raise(Errors.ImportCallSpreadArgument,arg);return this.finishNode(node,optional?"OptionalCallExpression":"Ca\
|
|
986
|
+
llExpression")}parseCallExpressionArguments(allowPlaceholder,nodeForExtra,refExpressionErrors){let elts=[],first=!0;for(;!this.eat(7);){if(first)first=!1;else if(this.expect(8),this.match(7)){nodeForExtra&&this.addTrailingCommaExtraToNode(nodeForExtra),this.next();break}elts.push(this.parseExprListItem(7,!1,refExpressionErrors,allowPlaceholder))}return elts}shouldParseAsyncArrow(){return this.match(15)&&!this.canInsertSemicolon()}parseAsyncArrowFromCallExpression(node,call){return this.resetPreviousNodeTrailingComments(
|
|
987
|
+
call),this.expect(15),this.parseArrowExpression(node,call.arguments,!0,call.extra?.trailingCommaLoc),call.innerComments&&setInnerComments(node,call.innerComments),call.callee.trailingComments&&setInnerComments(node,call.callee.trailingComments),node}parseNoCallExpr(onUnparenthesizedImportExpression){let startLoc=this.state.startLoc,isImport=this.match(79);this.state.canStartArrow=!1;let base=this.parseExprAtom();return isImport&&base.type==="ImportExpression"&&onUnparenthesizedImportExpression(base),
|
|
988
|
+
this.parseSubscripts(base,startLoc,!0)}parseExprAtom(refExpressionErrors){let node,decorators=null,{type}=this.state;switch(type){case 75:return this.parseSuper();case 79:return node=this.startNode(),this.next(),this.match(12)?this.parseImportMetaPropertyOrPhaseCall(node):this.match(6)?this.optionFlags&1024?this.parseImportCall(node):this.finishNode(node,"Import"):(this.raise(Errors.UnsupportedImport,this.state.lastTokStartLoc),this.finishNode(node,"Import"));case 74:return node=this.startNode(),
|
|
989
|
+
this.next(),this.finishNode(node,"ThisExpression");case 86:return this.parseDo(this.startNode(),!1);case 52:case 27:return this.readRegexp(),this.parseRegExpLiteral(this.state.value);case 132:return this.parseNumericLiteral(this.state.value);case 133:return this.parseBigIntLiteral(this.state.value);case 131:return this.parseStringLiteral(this.state.value);case 80:return this.parseNullLiteral();case 81:return this.parseBooleanLiteral(!0);case 82:return this.parseBooleanLiteral(!1);case 6:return this.
|
|
990
|
+
parseParenAndDistinguishExpression(this.state.canStartArrow);case 0:return this.parseArrayLike(1,refExpressionErrors);case 2:return this.parseObjectLike(4,!1,refExpressionErrors);case 64:return this.parseFunctionOrFunctionSent();case 22:decorators=this.parseDecorators();case 76:return this.parseClass(this.maybeTakeDecorators(decorators,this.startNode()),!1);case 73:return this.parseNewOrNewTarget();case 21:case 20:return this.parseTemplate(!1);case 11:{node=this.startNode(),this.next(),node.object=
|
|
991
|
+
null;let callee=node.callee=this.parseNoCallExpr(base=>{throw this.raise(Errors.UnsupportedBind,base)});if(callee.type==="MemberExpression")return this.finishNode(node,"BindExpression");throw this.raise(Errors.UnsupportedBind,callee)}case 135:return this.raise(Errors.PrivateInExpectedIn,this.state.startLoc,{identifierName:this.state.value}),this.parsePrivateName();case 29:return this.parseTopicReferenceThenEqualsSign(50,"%");case 28:return this.parseTopicReferenceThenEqualsSign(40,"^");case 33:case 34:
|
|
992
|
+
return this.parseTopicReference("hack");case 40:case 50:case 23:{let pipeProposal=this.getPluginOption("pipelineOperator","proposal");if(pipeProposal)return this.parseTopicReference(pipeProposal);throw this.unexpected()}case 43:{let lookaheadCh=this.input.codePointAt(this.nextTokenStart());throw isIdentifierStart(lookaheadCh)||lookaheadCh===62?this.expectOnePlugin(["jsx","flow","typescript"]):this.unexpected()}default:if(tokenIsIdentifier(type)){if(this.isContextual(124)&&this.lookaheadInLineCharCode()===
|
|
993
|
+
123)return this.parseModuleExpression();let{canStartArrow,containsEsc}=this.state,id2=this.parseIdentifier();if(!containsEsc&&id2.name==="async"&&!this.canInsertSemicolon()){let{type:type2}=this.state;if(type2===64)return this.resetPreviousNodeTrailingComments(id2),this.next(),this.parseAsyncFunctionExpression(this.startNodeAtNode(id2));if(tokenIsIdentifier(type2))return canStartArrow&&this.lookaheadCharCode()===61?this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id2)):id2;if(type2===86)return this.
|
|
994
|
+
resetPreviousNodeTrailingComments(id2),this.parseDo(this.startNodeAtNode(id2),!0)}return canStartArrow&&this.match(15)&&!this.canInsertSemicolon()?(this.next(),this.parseArrowExpression(this.startNodeAtNode(id2),[id2],!1)):id2}else throw this.unexpected()}}parseTopicReferenceThenEqualsSign(topicTokenType,topicTokenValue){let pipeProposal=this.getPluginOption("pipelineOperator","proposal");if(pipeProposal)return this.state.type=topicTokenType,this.state.value=topicTokenValue,this.state.pos--,this.
|
|
995
|
+
state.end--,this.state.endLoc=createPositionWithColumnOffset(this.state.endLoc,-1),this.parseTopicReference(pipeProposal);throw this.unexpected()}parseTopicReference(pipeProposal){let node=this.startNode(),startLoc=this.state.startLoc,tokenType=this.state.type;return this.next(),this.finishTopicReference(node,startLoc,pipeProposal,tokenType)}finishTopicReference(node,startLoc,pipeProposal,tokenType){if(this.testTopicReferenceConfiguration(pipeProposal,startLoc,tokenType))return this.topicReferenceIsAllowedInCurrentContext()||
|
|
996
|
+
this.raise(Errors.PipeTopicUnbound,startLoc),this.registerTopicReference(),this.finishNode(node,"TopicReference");throw this.raise(Errors.PipeTopicUnconfiguredToken,startLoc,{token:tokenLabelName(tokenType)})}testTopicReferenceConfiguration(pipeProposal,startLoc,tokenType){if(pipeProposal==="hack")return this.hasPlugin(["pipelineOperator",{topicToken:tokenLabelName(tokenType)}]);throw this.raise(Errors.PipeTopicRequiresHackPipes,startLoc)}parseAsyncArrowUnaryFunction(node){this.prodParam.enter(functionFlags(
|
|
997
|
+
!0,this.prodParam.hasYield));let params=[this.parseIdentifier()];return this.prodParam.exit(),this.hasPrecedingLineBreak()&&this.raise(Errors.LineTerminatorBeforeArrow,this.state.curPosition()),this.expect(15),this.parseArrowExpression(node,params,!0)}parseDo(node,isAsync){this.expectPlugin("doExpressions"),isAsync&&this.expectPlugin("asyncDoExpressions"),node.async=isAsync,this.next();let oldLabels=this.state.labels;return this.state.labels=[],isAsync?(this.prodParam.enter(2),node.body=this.parseBlock(),
|
|
998
|
+
this.prodParam.exit()):node.body=this.parseBlock(),this.state.labels=oldLabels,this.finishNode(node,"DoExpression")}parseSuper(){let node=this.startNode();return this.next(),this.match(6)&&!this.scope.allowDirectSuper?this.raise(Errors.SuperNotAllowed,node):this.scope.allowSuper||this.raise(Errors.UnexpectedSuper,node),!this.match(6)&&!this.match(0)&&!this.match(12)&&this.raise(Errors.UnsupportedSuper,node),this.finishNode(node,"Super")}parsePrivateName(){let node=this.startNode(),id2=this.startNodeAt(
|
|
999
|
+
createPositionWithColumnOffset(this.state.startLoc,1)),name=this.state.value;return this.next(),node.id=this.createIdentifier(id2,name),this.finishNode(node,"PrivateName")}parseFunctionOrFunctionSent(){let node=this.startNode();if(this.next(),this.prodParam.hasYield&&this.match(12)){let meta=this.createIdentifier(this.startNodeAtNode(node),"function");return this.next(),this.match(100)?this.expectPlugin("functionSent"):this.hasPlugin("functionSent")||this.unexpected(),this.parseMetaProperty(node,
|
|
1000
|
+
meta,"sent")}return this.parseFunction(node)}parseMetaProperty(node,meta,propertyName){node.meta=meta;let containsEsc=this.state.containsEsc;return node.property=this.parseIdentifier(!0),(node.property.name!==propertyName||containsEsc)&&this.raise(Errors.UnsupportedMetaProperty,node.property,{target:meta.name,onlyValidPropertyName:propertyName}),this.finishNode(node,"MetaProperty")}parseImportMetaPropertyOrPhaseCall(node){if(this.next(),this.isContextual(102)||this.isContextual(94)){let isSource=this.
|
|
1001
|
+
isContextual(102);return this.expectPlugin(isSource?"sourcePhaseImports":"deferredImportEvaluation"),this.next(),node.phase=isSource?"source":"defer",this.parseImportCall(node)}else{let id2=this.createIdentifierAt(this.startNodeAtNode(node),"import",this.state.lastTokStartLoc);return this.isContextual(98)&&(this.inModule||this.raise(Errors.ImportMetaOutsideModule,id2),this.sawUnambiguousESM=!0),this.parseMetaProperty(node,id2,"meta")}}parseLiteralAtNode(value,type,node){return this.addExtra(node,
|
|
1002
|
+
"rawValue",value),this.addExtra(node,"raw",this.input.slice(this.offsetToSourcePos(node.start),this.state.end)),node.value=value,this.next(),this.finishNode(node,type)}parseLiteral(value,type){let node=this.startNode();return this.parseLiteralAtNode(value,type,node)}parseStringLiteral(value){return this.parseLiteral(value,"StringLiteral")}parseNumericLiteral(value){return this.parseLiteral(value,"NumericLiteral")}parseBigIntLiteral(value){let bigInt;try{bigInt=BigInt(value)}catch{bigInt=null}return this.
|
|
1003
|
+
parseLiteral(bigInt,"BigIntLiteral")}parseRegExpLiteral(value){let node=this.startNode();return this.addExtra(node,"raw",this.input.slice(this.offsetToSourcePos(node.start),this.state.end)),node.pattern=value.pattern,node.flags=value.flags,this.next(),this.finishNode(node,"RegExpLiteral")}parseBooleanLiteral(value){let node=this.startNode();return node.value=value,this.next(),this.finishNode(node,"BooleanLiteral")}parseNullLiteral(){let node=this.startNode();return this.next(),this.finishNode(node,
|
|
1004
|
+
"NullLiteral")}parseParenAndDistinguishExpression(canStartArrow){let startLoc=this.state.startLoc,val;this.next(),this.expressionScope.enter(newArrowHeadScope());let innerStartLoc=this.state.startLoc,exprList=[],refExpressionErrors=new ExpressionErrors,first=!0,spreadStartLoc,optionalCommaStartLoc;for(;!this.match(7);){if(first)first=!1;else if(this.expect(8,refExpressionErrors.optionalParametersLoc===null?null:refExpressionErrors.optionalParametersLoc),this.match(7)){optionalCommaStartLoc=this.
|
|
1005
|
+
state.startLoc;break}if(this.match(17)){let spreadNodeStartLoc=this.state.startLoc;if(spreadStartLoc=this.state.startLoc,exprList.push(this.parseParenItem(this.parseRestBinding(),spreadNodeStartLoc)),!this.checkCommaAfterRest(41))break}else exprList.push(this.parseMaybeAssignAllowInOrVoidPattern(7,refExpressionErrors,!0))}let innerEndLoc=this.state.lastTokEndLoc;this.expect(7);let arrowNode=this.startNodeAt(startLoc);return canStartArrow&&this.shouldParseArrow(exprList)&&(arrowNode=this.parseArrow(
|
|
1006
|
+
arrowNode))?(this.checkDestructuringPrivate(refExpressionErrors),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(arrowNode,exprList,!1),arrowNode):(this.expressionScope.exit(),exprList.length||this.unexpected(this.state.lastTokStartLoc),optionalCommaStartLoc&&this.unexpected(optionalCommaStartLoc),spreadStartLoc&&this.unexpected(spreadStartLoc),this.checkExpressionErrors(refExpressionErrors,!0),this.toReferencedList(exprList,!0),exprList.length>1?(val=
|
|
1007
|
+
this.startNodeAt(innerStartLoc),val.expressions=exprList,this.finishNode(val,"SequenceExpression"),this.resetEndLocation(val,innerEndLoc)):val=exprList[0],this.wrapParenthesis(startLoc,val))}wrapParenthesis(startLoc,expression){if(!(this.optionFlags&2048))return this.addExtra(expression,"parenthesized",!0),this.addExtra(expression,"parenStart",startLoc.index),this.takeSurroundingComments(expression,startLoc.index,this.state.lastTokEndLoc.index),expression;let parenExpression=this.startNodeAt(startLoc);
|
|
1008
|
+
return parenExpression.expression=expression,this.finishNode(parenExpression,"ParenthesizedExpression")}shouldParseArrow(params){return!this.canInsertSemicolon()}parseArrow(node){if(this.eat(15))return node}parseParenItem(node,startLoc){return node}parseNewOrNewTarget(){let node=this.startNode();if(this.next(),this.match(12)){let meta=this.createIdentifier(this.startNodeAtNode(node),"new");this.next();let metaProp=this.parseMetaProperty(node,meta,"target");return this.scope.allowNewTarget||this.
|
|
1009
|
+
raise(Errors.UnexpectedNewTarget,metaProp),metaProp}return this.parseNew(node)}parseNew(node){if(this.parseNewCallee(node),this.eat(6)){let args2=this.parseExprList(7);this.toReferencedList(args2),node.arguments=args2}else node.arguments=[];return this.finishNode(node,"NewExpression")}parseNewCallee(node){let callee=this.parseNoCallExpr(base=>{this.raise(Errors.ImportCallNotNewExpression,base,base)});node.callee=callee,callee.type==="Import"&&this.raise(Errors.ImportCallNotNewExpression,callee),
|
|
1010
|
+
callee.type==="Super"&&this.raise(Errors.SuperCallNotNewExpression,callee)}parseTemplateElement(isTagged){let{start,startLoc,end,value}=this.state,elemStart=start+1,elem=this.startNodeAt(createPositionWithColumnOffset(startLoc,1));value===null&&(isTagged||this.raise(Errors.InvalidEscapeSequenceTemplate,createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos,1)));let isTail=this.match(20),endOffset=isTail?-1:-2,elemEnd=end+endOffset;elem.value={raw:this.input.slice(elemStart,elemEnd).
|
|
1011
|
+
replace(/\r\n?/g,`
|
|
1009
1012
|
`),cooked:value===null?null:value.slice(1,endOffset)},elem.tail=isTail,this.next();let finishedNode=this.finishNode(elem,"TemplateElement");return this.resetEndLocation(finishedNode,createPositionWithColumnOffset(this.state.lastTokEndLoc,endOffset)),finishedNode}parseTemplate(isTagged){let node=this.startNode(),curElt=this.parseTemplateElement(isTagged),quasis=[curElt],substitutions=[];for(;!curElt.tail;)substitutions.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),quasis.
|
|
1010
1013
|
push(curElt=this.parseTemplateElement(isTagged));return node.expressions=substitutions,node.quasis=quasis,this.finishNode(node,"TemplateLiteral")}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(close,isPattern,refExpressionErrors){let sawProto=!1,first=!0,node=this.startNode();for(node.properties=[],this.next();!this.match(close);){if(first)first=!1;else if(this.expect(8),this.match(close)){this.addTrailingCommaExtraToNode(node);break}let prop;isPattern?prop=this.parseBindingProperty():
|
|
1011
1014
|
(prop=this.parsePropertyDefinition(refExpressionErrors),sawProto=this.checkProto(prop,sawProto,refExpressionErrors)),node.properties.push(prop)}this.next();let type=isPattern?"ObjectPattern":"ObjectExpression";return this.finishNode(node,type)}addTrailingCommaExtraToNode(node){this.addExtra(node,"trailingComma",this.state.lastTokStartLoc.index),this.addExtra(node,"trailingCommaLoc",this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(prop){return!prop.computed&&prop.key.type==="Identifier"&&(this.
|
|
@@ -1016,242 +1019,243 @@ method),params=this.getObjectOrClassMethodParams(method);params.length!==paramCo
|
|
|
1016
1019
|
if(isAsync||isGenerator||this.match(6))return isPattern&&this.unexpected(),prop.kind="method",prop.method=!0,this.parseMethod(prop,isGenerator,isAsync,!1,!1,"ObjectMethod")}parseObjectProperty(prop,startLoc,isPattern,refExpressionErrors){if(prop.shorthand=!1,this.eat(10))return prop.value=isPattern?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowInOrVoidPattern(4,refExpressionErrors),this.finishObjectProperty(prop);if(!prop.computed&&prop.key.type==="Identifier"){if(this.checkReservedWord(
|
|
1017
1020
|
prop.key.name,prop.key.start,!0,!1),isPattern)prop.value=this.parseMaybeDefault(startLoc,this.cloneIdentifier(prop.key));else if(this.match(25)){let shorthandAssignLoc=this.state.startLoc;refExpressionErrors!=null?refExpressionErrors.shorthandAssignLoc===null&&(refExpressionErrors.shorthandAssignLoc=shorthandAssignLoc):this.raise(Errors.InvalidCoverInitializedName,shorthandAssignLoc),prop.value=this.parseMaybeDefault(startLoc,this.cloneIdentifier(prop.key))}else prop.value=this.cloneIdentifier(prop.
|
|
1018
1021
|
key);return prop.shorthand=!0,this.finishObjectProperty(prop)}}finishObjectProperty(node){return this.finishNode(node,"ObjectProperty")}parseObjPropValue(prop,startLoc,isGenerator,isAsync,isPattern,isAccessor,refExpressionErrors){let node=this.parseObjectMethod(prop,isGenerator,isAsync,isPattern,isAccessor)||this.parseObjectProperty(prop,startLoc,isPattern,refExpressionErrors);return node||this.unexpected(),node}parsePropertyName(prop,refExpressionErrors){if(this.eat(0))prop.computed=!0,prop.key=
|
|
1019
|
-
this.parseMaybeAssignAllowIn(),this.expect(1);else{let{type,value}=this.state,key;if(tokenIsKeywordOrIdentifier(type))key=this.parseIdentifier(!0);else switch(type){case
|
|
1020
|
-
UnexpectedPrivateField,privateKeyLoc),key=this.parsePrivateName();break}default:throw this.unexpected()}prop.key=key,type!==
|
|
1021
|
-
this.parseFunctionParams(node,isConstructor);let finishedNode=this.parseFunctionBodyAndFinish(node,type,!0);return this.prodParam.exit(),this.scope.exit(),finishedNode}parseArrayLike(close,refExpressionErrors){let node=this.startNode();return this.next(),node.elements=this.parseExprList(close,!0,refExpressionErrors,node),this.finishNode(node,"ArrayExpression")}parseArrowExpression(node,params,isAsync,trailingCommaLoc){this.scope.enter(518);let flags=functionFlags(isAsync,!1)
|
|
1022
|
-
(flags|=this.prodParam.currentFlags()&24),this.prodParam.enter(flags),this.initFunction(node,isAsync),params&&this.setArrowFunctionParameters(node,params,trailingCommaLoc),this.parseFunctionBody(node,!0),this.prodParam.exit(),this.scope.exit(),this.finishNode(node,"ArrowFunctionExpression")}setArrowFunctionParameters(node,params,trailingCommaLoc){this.toAssignableList(params,trailingCommaLoc,!1),node.
|
|
1023
|
-
|
|
1024
|
-
isSimpleParamList(node.params);hasStrictModeDirective&&nonSimple&&this.raise(Errors.IllegalLanguageModeDirective,(node.kind==="method"||node.kind==="constructor")&&node.key?this.optionFlags&256?node.key.loc.end:node.key:node);let strictModeChanged=!oldStrict&&this.state.strict;this.checkParams(node,!this.state.strict&&!allowExpression&&!isMethod&&!nonSimple,allowExpression,strictModeChanged),
|
|
1025
|
-
state.labels=oldLabels}this.expressionScope.exit()}isSimpleParameter(node){return node.type==="Identifier"}isSimpleParamList(params){for(let i=0,len=params.length;i<len;i++)if(!this.isSimpleParameter(params[i]))return!1;return!0}checkParams(node,allowDuplicates,isArrowFunction,strictModeChanged=!0){let checkClashes=!allowDuplicates&&new Set,formalParameters={type:"FormalParameters"};for(let param of node.params)
|
|
1026
|
-
let elts=[],first=!0;for(;!this.eat(close);){if(first)first=!1;else if(this.expect(8),this.match(close)){nodeForExtra&&this.addTrailingCommaExtraToNode(nodeForExtra),this.next();break}elts.push(this.parseExprListItem(close,allowEmpty,refExpressionErrors))}return elts}parseExprListItem(close,allowEmpty,refExpressionErrors,allowPlaceholder){let elt;if(this.match(
|
|
1027
|
-
state.startLoc;elt=this.parseParenItem(this.parseSpread(refExpressionErrors),spreadNodeStartLoc)}else if(this.match(13)){this.expectPlugin("partialApplication"),allowPlaceholder||this.raise(Errors.UnexpectedArgumentPlaceholder,this.state.startLoc);let node=this.startNode();this.next(),elt=this.finishNode(node,"ArgumentPlaceholder")}else elt=this.
|
|
1028
|
-
liberal);return this.createIdentifier(node,name)}createIdentifier(node,name){return node.name=name,this.optionFlags&256&&(node.loc.identifierName=name),this.finishNode(node,"Identifier")}createIdentifierAt(node,name,endLoc){return node.name=name,this.optionFlags&256&&(node.loc.identifierName=name),this.finishNodeAt(node,"Identifier",endLoc)}parseIdentifierName(liberal){
|
|
1029
|
-
type);return liberal?tokenIsKeyword2&&this.replaceToken(
|
|
1030
|
-
UnexpectedReservedWord,startLoc,{reservedWord:word});return}else if(word==="yield"){if(this.prodParam.hasYield){this.raise(Errors.YieldBindingIdentifier,startLoc);return}}else if(word==="await"){if(this.prodParam.hasAwait){this.raise(Errors.AwaitBindingIdentifier,startLoc);return}if(this.scope.inStaticBlock){this.raise(Errors.AwaitBindingIdentifierInStaticBlock,
|
|
1031
|
-
this.raise(Errors.ArgumentsInClass,startLoc);return}}recordAwaitIfAllowed(){let isAwaitAllowed=this.prodParam.hasAwait;return isAwaitAllowed&&!this.scope.inFunction&&(this.state.hasTopLevelAwait=!0),isAwaitAllowed}parseAwait(startLoc,soloAwait){let startIndex=startLoc.index;this.setLoc(startLoc);let node=this.startNodeAt(startLoc);return this.expressionScope.
|
|
1032
|
-
|
|
1033
|
-
this.setLoc(startLoc);let node=this.startNodeAt(startLoc);this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter,startLoc.index);let delegating=!1,argument=null;if(!this.hasPrecedingLineBreak())switch(delegating=this.eat(51),this.state.type){case 9:case
|
|
1034
|
-
this.next();let args2=this.parseCallExpressionArguments();if(args2.length===0||args2.length>2)this.raise(Errors.ImportCallArity,node,node);else for(let arg of args2)arg.type==="SpreadElement"&&this.raise(Errors.ImportCallSpreadArgument,arg,node);return node.
|
|
1035
|
-
seenTopicReference;this.state.seenTopicReference=!1;try{return callback()}finally{this.state.inHackPipelineBody=oldInHackPipelineBody,this.state.seenTopicReference=oldSeenTopicReference}}allowInAnd(callback){let flags=this.prodParam.currentFlags();if(24&~flags){
|
|
1036
|
-
|
|
1037
|
-
this.next(),ret=this.parseAwait(startLoc,!0);let nextOp=this.state.type;
|
|
1038
|
-
state.endLoc);this.next();let revertScopes=this.initializeScopes(!0);this.enterInitialScopes();try{node.body=this.parseProgram(program,4,"module")}finally{revertScopes()}return this.finishNode(node,"ModuleExpression")}parseVoidPattern(refExpressionErrors){this.expectPlugin("discardBinding");let node=this.startNode();
|
|
1039
|
-
if(refExpressionErrors!=null&&this.match(84)){let nextCode=this.lookaheadCharCode();if(nextCode===44||nextCode===(close===1?93:close===4?125:41)||nextCode===61)return this.parseMaybeDefault(this.state.startLoc,this.parseVoidPattern(refExpressionErrors))}return this.parseMaybeAssignAllowIn(
|
|
1040
|
-
for(let i=0;i<tokens.length;i++){let token=tokens[i],{type}=token;typeof type=="number"&&(token.type=getExportedToken(type))}return tokens}var StatementParser=class extends ExpressionParser{parseTopLevel(file,program){return file.program=this.parseProgram(program,
|
|
1041
|
-
sourceType,program.interpreter=this.parseInterpreterDirective(),this.parseBlockBody(program,!0,!0,end),this.inModule){if(!(this.optionFlags&64)&&this.scope.undefinedExports.size>0)for(let[localName,at]of Array.from(this.scope.undefinedExports))this.raise(Errors.ModuleExportUndefined,
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
next)}isAwaitUsing(){if(!this.isContextual(
|
|
1046
|
-
endCh)&&endCh!==92)return!1}return!0}else return ch===92}chStartsBindingPattern(ch){return ch===91||ch===123}hasFollowingBindingAtom(){let next=this.nextTokenStart(),nextCh=this.codePointAtPos(next);return this.chStartsBindingPattern(nextCh)||this.chStartsBindingIdentifier(nextCh,next)}hasInLineFollowingBindingIdentifierOrBrace(){
|
|
1047
|
-
|
|
1048
|
-
let decorators=null;return this.match(22)&&(decorators=this.parseDecorators(!0)),this.parseStatementContent(flags,decorators)}parseStatementContent(flags,decorators){let startType=this.state.type,node=this.startNode(),allowDeclaration=!!(flags&2),allowFunctionDeclaration=!!(flags&4),topLevel=flags&1;switch(startType){case 56:return this.
|
|
1049
|
-
parseDoWhileStatement(node);case 87:return this.parseForStatement(node);case 64:if(this.lookaheadCharCode()===46)break;return allowFunctionDeclaration||this.raise(this.state.strict?Errors.StrictFunction:this.options.annexB?Errors.SloppyFunctionAnnexB:Errors.SloppyFunction,this.state.startLoc),this.parseFunctionStatement(node,!1
|
|
1050
|
-
parseIfStatement(node);case 66:return this.parseReturnStatement(node);case 67:return this.parseSwitchStatement(node);case 68:return this.parseThrowStatement(node);case 69:return this.parseTryStatement(node);case
|
|
1051
|
-
node,"await using");break;case
|
|
1052
|
-
!this.chStartsBindingIdentifier(nextCh,next)&&nextCh!==123))break}case 71:allowDeclaration||this.raise(Errors.UnexpectedLexicalDeclaration,this.state.startLoc);case 70:{let kind=this.state.value;return this.parseVarStatement(node,kind)}case 88:return this.parseWhileStatement(node);case 72:return this.parseWithStatement(node);case 2:return this.parseBlock();case 9:return this.parseEmptyStatement(
|
|
1053
|
-
46)break}case 78:{!(this.optionFlags&8)&&!topLevel&&this.raise(Errors.UnexpectedImportExport,this.state.startLoc),this.next();let result;return startType===79?result=this.parseImport(node):result=this.parseExport(node,decorators),this.assertModuleNodeAllowed(result),result}default:if(this.isAsyncFunction())return allowDeclaration||this.raise(Errors.AsyncFunctionInSingleStatementContext,this.
|
|
1054
|
-
let maybeName=this.state.value,expr=this.parseExpression();return tokenIsIdentifier(startType)&&expr.type==="Identifier"&&this.eat(10)?this.parseLabeledStatement(node,maybeName,expr,flags):this.parseExpressionStatement(node,expr)}assertModuleNodeAllowed(node){!(this.
|
|
1055
|
-
classNode.decorators[0]),classNode.decorators.unshift(...maybeDecorators)):classNode.decorators=maybeDecorators,this.resetStartLocationFromNode(classNode,maybeDecorators[0]),exportNode&&this.resetStartLocationFromNode(exportNode,classNode)),classNode}canHaveLeadingDecorator(){
|
|
1056
|
-
raise(Errors.UnexpectedLeadingDecorator,this.state.startLoc);return decorators}parseDecorator(){this.expectOnePlugin(["decorators","decorators-legacy"]);let node=this.startNode();if(this.next(),this.hasPlugin("decorators")){let startLoc=this.state.startLoc,expr;if(this.
|
|
1057
|
-
expr,startLoc2),node.expression!==expr&&this.raise(Errors.DecoratorArgumentsOutsideParentheses,paramsStartLoc)}else{for(expr=this.parseIdentifier(!1);this.eat(12);){let node2=this.startNodeAt(startLoc);node2.object=expr,this.match(
|
|
1058
|
-
expr,startLoc)}}else this.state.canStartArrow=!1,node.expression=this.parseExprSubscripts();return this.finishNode(node,"Decorator")}parseMaybeDecoratorArguments(expr,startLoc){if(this.eat(6)){let node=this.startNodeAt(startLoc);return node.callee=expr,node.arguments=this.
|
|
1059
|
-
label=this.parseIdentifier(),this.semicolon()),this.verifyBreakContinue(node,isBreak),this.finishNode(node,isBreak?"BreakStatement":"ContinueStatement")}verifyBreakContinue(node,isBreak){let i;for(i=0;i<this.state.labels.length;++i){let lab=this.state.labels[i];
|
|
1060
|
-
node,{type})}}parseDebuggerStatement(node){return this.next(),this.semicolon(),this.finishNode(node,"DebuggerStatement")}parseHeaderExpression(){this.expect(6);let val=this.parseExpression();return this.expect(7),val}parseDoWhileStatement(node){return this.
|
|
1061
|
-
state.labels.push(loopLabel);let awaitAt=null;if(this.isContextual(
|
|
1062
|
-
if(this.match(70)||this.match(71)||isLetOrUsing){let initNode=this.startNode(),kind;startsWithAwaitUsing?(kind="await using",this.recordAwaitIfAllowed()||this.raise(Errors.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):kind=this.state.value,
|
|
1063
|
-
declarations.length===1?this.parseForX(node,init2,awaitAt):(awaitAt!==null&&this.unexpected(awaitAt),this.parseFor(node,init2))}}let startsWithAsync=this.isContextual(
|
|
1064
|
-
refExpressionErrors),this.toAssignable(init,!0);let type=isForOf?"ForOfStatement":"ForInStatement";return this.checkLVal(init,{type}),this.parseForX(node,init,awaitAt)}else this.checkExpressionErrors(refExpressionErrors,!0);return awaitAt!==null&&this.unexpected(
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
this.
|
|
1071
|
-
expr,{labelName:maybeName});let kind=tokenIsLoop(this.state.type)?1:this.match(67)?2:null;for(let i=this.state.labels.length-1;i>=0;i--){
|
|
1072
|
-
this.state.labels.
|
|
1073
|
-
this.
|
|
1074
|
-
|
|
1075
|
-
this
|
|
1076
|
-
node.
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
node.id&&this.scope.declareName(node.id.name,!this.options.annexB||this.state.strict||node.generator||node.async?this.scope.treatFunctionsAsVar?5:8201:17,node.id.start)}parseClass(node,isStatement,optionalId){
|
|
1083
|
-
return this.match(25)||this.match(9)||this.match(4)}isClassMethod(){return this.match(6)}nameIsConstructor(key){return key.type==="Identifier"&&key.name==="constructor"||key.type==="StringLiteral"&&key.value===
|
|
1084
|
-
this.expect(2);!this.match(4);){if(this.eat(9)){if(decorators.length>0)throw this.raise(Errors.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(22)){decorators.push(this.parseDecorator());continue}
|
|
1085
|
-
this.state.startLoc);return this.classScope.exit(),this.finishNode(classBody,"ClassBody")}parseClassMemberFromModifier(classBody,member){let key=this.parseIdentifier(!0);if(this.isClassMethod()){let method=member;
|
|
1086
|
-
return this.resetPreviousNodeTrailingComments(key),!1}parseClassMember(classBody,member,state){let isStatic=this.isContextual(
|
|
1087
|
-
method=publicMethod,publicMember=publicMethod;if(member.static=isStatic,this.parsePropertyNamePrefixOperator(member),this.eat(51)){method.kind="method";let isPrivateName=this.match(
|
|
1088
|
-
|
|
1089
|
-
isConstructor&&(publicMethod.kind="constructor",publicMethod.decorators&&publicMethod.decorators.length>0&&this.raise(Errors.DecoratorConstructor,member),state.hadConstructor&&!this.hasPlugin("typescript")&&this.raise(Errors.DuplicateConstructor,
|
|
1090
|
-
isClassProperty())isPrivate?this.pushClassPrivateProperty(classBody,privateProp):this.pushClassProperty(classBody,publicProp);else if(maybeContextualKw==="async"&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(key);
|
|
1091
|
-
classBody,privateMethod,isGenerator,!0):(this.isNonstaticConstructor(publicMethod)&&this.raise(Errors.ConstructorIsAsync,publicMethod.key),this.pushClassMethod(classBody,publicMethod,isGenerator,!0,!1,!1))}else if((maybeContextualKw===
|
|
1092
|
-
privateMethod,!1,!1):(this.isNonstaticConstructor(publicMethod)&&this.raise(Errors.ConstructorIsAccessor,publicMethod.key),this.pushClassMethod(classBody,publicMethod,!1,!1,!1,!1)),this.checkGetterSetterParams(publicMethod)}else if(maybeContextualKw===
|
|
1093
|
-
isPrivate2)}else this.isLineTerminator()?isPrivate?this.pushClassPrivateProperty(classBody,privateProp):this.pushClassProperty(classBody,publicProp):this.unexpected()}parseClassElementName(member){let{type,value}=this.state;if((type===
|
|
1094
|
-
key}return this.parsePropertyName(member),member.key}parseClassStaticBlock(classBody,member){this.scope.enter(720);let oldLabels=this.state.labels;this.state.labels=[],this.prodParam.enter(0);let body=member.body=[];this.parseBlockOrModuleBlockBody(body,
|
|
1095
|
-
!prop.computed&&this.nameIsConstructor(prop.key)&&this.raise(Errors.ConstructorClassField,prop.key),classBody.body.push(this.parseClassProperty(prop))}pushClassPrivateProperty(classBody,prop){let node=this.parseClassPrivateProperty(prop);classBody.body.
|
|
1096
|
-
prop.key);let node=this.parseClassAccessorProperty(prop);classBody.body.push(node),isPrivate&&this.classScope.declarePrivateName(this.getPrivateNameSV(node.key),0,node.key.start)}pushClassMethod(classBody,method,isGenerator,isAsync,isConstructor,allowsDirectSuper){
|
|
1097
|
-
"ClassPrivateMethod",!0);classBody.body.push(node);let kind=node.kind==="get"?node.static?6:2:node.kind==="set"?node.static?5:1:0;this.declareClassPrivateMethodInScope(node,kind)}declareClassPrivateMethodInScope(node,kind){this.classScope.declarePrivateName(this.getPrivateNameSV(
|
|
1098
|
-
return this.parseInitializer(node),this.semicolon(),this.finishNode(node,"
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
node,
|
|
1102
|
-
hasDeclaration){let node2=node;if(this.checkNamedExport(node2,!!node2.source),node2.declaration?.type==="ClassDeclaration")this.maybeTakeDecorators(decorators,node2.declaration,node2);else if(decorators)throw this.raise(Errors.UnsupportedDecoratorExport,
|
|
1103
|
-
decl,node2);else if(decorators)throw this.raise(Errors.UnsupportedDecoratorExport,node);return this.checkDuplicateExports(node,"default"),this.hasPlugin("exportDefaultFrom")&&decl.type==="Identifier"&&decl.name==="from"&&decl.end-decl.start===4&&!decl.
|
|
1104
|
-
|
|
1105
|
-
specifier.exported=
|
|
1106
|
-
(node.specifiers=[],node.source=null,node.attributes=[],node.declaration=this.parseExportDeclaration(node),!0):!1}isAsyncFunction(){if(!this.isContextual(
|
|
1107
|
-
expr,!0,!0);if(this.match(22))return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(71)||this.match(70)||this.isLet()||this.isUsing()||this.isAwaitUsing())throw this.
|
|
1108
|
-
type}=this.state;if(tokenIsIdentifier(type)){if(type===
|
|
1109
|
-
input.charCodeAt(next)===44||tokenIsIdentifier(this.state.type)&&hasFrom)return!0;if(this.match(61)&&hasFrom){let nextAfterFrom=this.input.charCodeAt(this.
|
|
1110
|
-
["decorators","decorators-legacy"]),this.hasPlugin("decorators"))?!0:this.isUsing()?(this.raise(Errors.UsingDeclarationExport,this.state.startLoc)
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
checkDeclaration(node
|
|
1114
|
-
first=!1;else if(this.expect(8),this.eat(4))break;let isMaybeTypeOnly=this.isContextual(
|
|
1115
|
-
this.cloneIdentifier(node.local)),this.finishNode(node,"ExportSpecifier")}parseModuleExportName(){if(this.match(
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
!
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
eat(4);){if(first)first=!1;else{if(this.eat(10))throw this.raise(Errors.DestructureNamedImport,this.state.startLoc);if(this.expect(8),this.eat(4))break}let specifier=this.startNode(),
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
.",
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
TSErrorTemplates);function keywordTypeFromName(value){switch(value){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"
|
|
1143
|
-
"
|
|
1144
|
-
|
|
1145
|
-
type)}tsTokenCanFollowModifier(){return this.match(0)||this.match(2)||this.match(51)||this.match(17)||this.match(
|
|
1146
|
-
if(!tokenIsIdentifier(this.state.type)&&this.state.type!==54&&this.state.type!==71)return;let modifier=this.state.value;if(modifiers.has(modifier)){if(hasSeenStaticModifier&&this.match(
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
startLoc,{modifier}):(enforceOrder(startLoc,modifier,
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
node.
|
|
1155
|
-
|
|
1156
|
-
this.
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
this.
|
|
1162
|
-
|
|
1163
|
-
this.
|
|
1164
|
-
|
|
1165
|
-
this.
|
|
1166
|
-
|
|
1167
|
-
this.
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
let
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
this.
|
|
1191
|
-
this.
|
|
1192
|
-
|
|
1193
|
-
this.
|
|
1194
|
-
|
|
1195
|
-
this.
|
|
1196
|
-
|
|
1197
|
-
this.
|
|
1198
|
-
this.
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
type!=="Identifier"&&
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
return
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
isAmbientContext)
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
this.
|
|
1237
|
-
|
|
1238
|
-
this.
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
(this.
|
|
1246
|
-
startLoc
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
this.
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1022
|
+
this.parseMaybeAssignAllowIn(),this.expect(1);else{let{type,value}=this.state,key;if(tokenIsKeywordOrIdentifier(type))key=this.parseIdentifier(!0);else switch(type){case 132:key=this.parseNumericLiteral(value);break;case 131:key=this.parseStringLiteral(value);break;case 133:key=this.parseBigIntLiteral(value);break;case 135:{let privateKeyLoc=this.state.startLoc;refExpressionErrors!=null?refExpressionErrors.privateKeyLoc===null&&(refExpressionErrors.privateKeyLoc=privateKeyLoc):this.raise(Errors.
|
|
1023
|
+
UnexpectedPrivateField,privateKeyLoc),key=this.parsePrivateName();break}default:throw this.unexpected()}prop.key=key,type!==135&&(prop.computed=!1)}}initFunction(node,isAsync){node.id=null,node.generator=!1,node.async=isAsync}parseMethod(node,isGenerator,isAsync,isConstructor,allowDirectSuper,type,inClassScope=!1){this.initFunction(node,isAsync),node.generator=isGenerator,this.scope.enter(530|(inClassScope?576:0)|(allowDirectSuper?32:0)),this.prodParam.enter(functionFlags(isAsync,node.generator)),
|
|
1024
|
+
this.parseFunctionParams(node,isConstructor);let finishedNode=this.parseFunctionBodyAndFinish(node,type,!0);return this.prodParam.exit(),this.scope.exit(),finishedNode}parseArrayLike(close,refExpressionErrors){let node=this.startNode();return this.next(),node.elements=this.parseExprList(close,!0,refExpressionErrors,node),this.finishNode(node,"ArrayExpression")}parseArrowExpression(node,params,isAsync,trailingCommaLoc){this.scope.enter(518);let flags=functionFlags(isAsync,!1),hasBlockBody=this.match(
|
|
1025
|
+
2);return hasBlockBody||(flags|=this.prodParam.currentFlags()&24),this.prodParam.enter(flags),this.initFunction(node,isAsync),params&&this.setArrowFunctionParameters(node,params,trailingCommaLoc),this.parseFunctionBody(node,!0),hasBlockBody&&(this.state.regExpAllowedAt=this.state.lastTokEndLoc.index),this.prodParam.exit(),this.scope.exit(),this.finishNode(node,"ArrowFunctionExpression")}setArrowFunctionParameters(node,params,trailingCommaLoc){this.toAssignableList(params,trailingCommaLoc,!1),node.
|
|
1026
|
+
params=params}parseFunctionBodyAndFinish(node,type,isMethod=!1){return this.parseFunctionBody(node,!1,isMethod),this.finishNode(node,type)}parseFunctionBody(node,allowExpression,isMethod=!1){let isExpression=allowExpression&&!this.match(2);if(this.expressionScope.enter(newExpressionScope()),isExpression)node.body=this.parseMaybeAssign(),this.checkParams(node,!1,allowExpression,!1);else{let oldStrict=this.state.strict,oldLabels=this.state.labels;this.state.labels=[],this.prodParam.enter(this.prodParam.
|
|
1027
|
+
currentFlags()|4),node.body=this.parseBlock(!0,!1,hasStrictModeDirective=>{let nonSimple=!this.isSimpleParamList(node.params);hasStrictModeDirective&&nonSimple&&this.raise(Errors.IllegalLanguageModeDirective,(node.kind==="method"||node.kind==="constructor")&&node.key?this.optionFlags&256?node.key.loc.end:node.key:node);let strictModeChanged=!oldStrict&&this.state.strict;this.checkParams(node,!this.state.strict&&!allowExpression&&!isMethod&&!nonSimple,allowExpression,strictModeChanged),node.id&&this.
|
|
1028
|
+
checkStrictBindReservedWord(node.id,65,strictModeChanged)}),this.prodParam.exit(),this.state.labels=oldLabels}this.expressionScope.exit()}isSimpleParameter(node){return node.type==="Identifier"}isSimpleParamList(params){for(let i=0,len=params.length;i<len;i++)if(!this.isSimpleParameter(params[i]))return!1;return!0}checkParams(node,allowDuplicates,isArrowFunction,strictModeChanged=!0){let checkClashes=!allowDuplicates&&new Set,formalParameters={type:"FormalParameters"};for(let param of node.params)
|
|
1029
|
+
this.checkLVal(param,formalParameters,5,checkClashes,strictModeChanged)}parseExprList(close,allowEmpty,refExpressionErrors,nodeForExtra){let elts=[],first=!0;for(;!this.eat(close);){if(first)first=!1;else if(this.expect(8),this.match(close)){nodeForExtra&&this.addTrailingCommaExtraToNode(nodeForExtra),this.next();break}elts.push(this.parseExprListItem(close,allowEmpty,refExpressionErrors))}return elts}parseExprListItem(close,allowEmpty,refExpressionErrors,allowPlaceholder){let elt;if(this.match(
|
|
1030
|
+
8))allowEmpty||this.raise(Errors.UnexpectedToken,this.state.curPosition(),{unexpected:","}),elt=null;else if(this.match(17)){let spreadNodeStartLoc=this.state.startLoc;elt=this.parseParenItem(this.parseSpread(refExpressionErrors),spreadNodeStartLoc)}else if(this.match(13)){this.expectPlugin("partialApplication"),allowPlaceholder||this.raise(Errors.UnexpectedArgumentPlaceholder,this.state.startLoc);let node=this.startNode();this.next(),elt=this.finishNode(node,"ArgumentPlaceholder")}else elt=this.
|
|
1031
|
+
parseMaybeAssignAllowInOrVoidPattern(close,refExpressionErrors,!0);return elt}parseIdentifier(liberal){let node=this.startNode(),name=this.parseIdentifierName(liberal);return this.createIdentifier(node,name)}createIdentifier(node,name){return node.name=name,this.optionFlags&256&&(node.loc.identifierName=name),this.finishNode(node,"Identifier")}createIdentifierAt(node,name,endLoc){return node.name=name,this.optionFlags&256&&(node.loc.identifierName=name),this.finishNodeAt(node,"Identifier",endLoc)}parseIdentifierName(liberal){
|
|
1032
|
+
let name,{start,type}=this.state;tokenIsKeywordOrIdentifier(type)?name=this.state.value:this.unexpected();let tokenIsKeyword2=tokenKeywordOrIdentifierIsKeyword(type);return liberal?tokenIsKeyword2&&this.replaceToken(129):this.checkReservedWord(name,this.sourceToOffsetPos(start),tokenIsKeyword2,!1),this.next(),name}checkReservedWord(word,startLoc,checkKeywords,isBinding){if(word.length>10||!canBeReservedWord(word))return;if(checkKeywords&&isKeyword(word)){this.raise(Errors.UnexpectedKeyword,startLoc,
|
|
1033
|
+
{keyword:word});return}if((this.state.strict?isBinding?isStrictBindReservedWord:isStrictReservedWord:isReservedWord)(word,this.inModule)){this.raise(Errors.UnexpectedReservedWord,startLoc,{reservedWord:word});return}else if(word==="yield"){if(this.prodParam.hasYield){this.raise(Errors.YieldBindingIdentifier,startLoc);return}}else if(word==="await"){if(this.prodParam.hasAwait){this.raise(Errors.AwaitBindingIdentifier,startLoc);return}if(this.scope.inStaticBlock){this.raise(Errors.AwaitBindingIdentifierInStaticBlock,
|
|
1034
|
+
startLoc);return}this.expressionScope.recordAsyncArrowParametersError(startLoc)}else if(word==="arguments"&&this.scope.inClassAndNotInNonArrowFunction){this.raise(Errors.ArgumentsInClass,startLoc);return}}recordAwaitIfAllowed(){let isAwaitAllowed=this.prodParam.hasAwait;return isAwaitAllowed&&!this.scope.inFunction&&(this.state.hasTopLevelAwait=!0),isAwaitAllowed}parseAwait(startLoc,soloAwait){let startIndex=startLoc.index;this.setLoc(startLoc);let node=this.startNodeAt(startLoc);return this.expressionScope.
|
|
1035
|
+
recordParameterInitializerError(Errors.AwaitExpressionFormalParameter,startIndex),this.eat(51)&&this.raise(Errors.ObsoleteAwaitStar,startLoc),!this.scope.inFunction&&!(this.optionFlags&1)&&(this.isAmbiguousPrefixOrIdentifier()?this.ambiguousScriptDifferentAst=!0:this.sawUnambiguousESM=!0),soloAwait||(this.state.canStartArrow=!1,node.argument=this.parseMaybeUnary(null,!0)),this.finishNode(node,"AwaitExpression")}isAmbiguousPrefixOrIdentifier(){if(this.hasPrecedingLineBreak())return!0;let{type}=this.
|
|
1036
|
+
state;return type===49||type===6||type===0||tokenIsTemplate(type)||type===99&&!this.state.containsEsc||type===134||type===52||this.hasPlugin("v8intrinsic")&&type===50}parseYield(startLoc){this.setLoc(startLoc);let node=this.startNodeAt(startLoc);this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter,startLoc.index);let delegating=!1,argument=null;if(!this.hasPrecedingLineBreak())switch(delegating=this.eat(51),this.state.type){case 9:case 136:case 4:case 7:case 1:case 5:case 10:case 8:
|
|
1037
|
+
if(!delegating)break;default:argument=this.parseMaybeAssign()}return argument||(this.state.regExpAllowedAt=this.state.lastTokEndLoc.index),node.delegate=delegating,node.argument=argument,this.finishNode(node,"YieldExpression")}parseImportCall(node){this.next();let args2=this.parseCallExpressionArguments();if(args2.length===0||args2.length>2)this.raise(Errors.ImportCallArity,node,node);else for(let arg of args2)arg.type==="SpreadElement"&&this.raise(Errors.ImportCallSpreadArgument,arg,node);return node.
|
|
1038
|
+
source=args2[0],node.options=args2[1]??null,this.finishNode(node,"ImportExpression")}withTopicBindingContext(callback){let oldInHackPipelineBody=this.state.inHackPipelineBody;this.state.inHackPipelineBody=!0;let oldSeenTopicReference=this.state.seenTopicReference;this.state.seenTopicReference=!1;try{return callback()}finally{this.state.inHackPipelineBody=oldInHackPipelineBody,this.state.seenTopicReference=oldSeenTopicReference}}allowInAnd(callback){let flags=this.prodParam.currentFlags();if(24&~flags){
|
|
1039
|
+
this.prodParam.enter(flags|8|16);try{return callback()}finally{this.prodParam.exit()}}return callback()}disallowInAnd(callback){let flags=this.prodParam.currentFlags(),prodParamToClear=8&flags,prodParamToSet=16&~flags;if(prodParamToClear||prodParamToSet){this.prodParam.enter(flags&-9|16);try{return callback()}finally{this.prodParam.exit()}}return callback()}registerTopicReference(){this.state.seenTopicReference=!0}topicReferenceIsAllowedInCurrentContext(){return this.state.inHackPipelineBody}topicReferenceWasUsedInCurrentContext(){
|
|
1040
|
+
return this.state.seenTopicReference}parseFSharpPipelineBody(prec){let startLoc=this.state.startLoc;this.prodParam.enter(this.prodParam.currentFlags()&-17);let ret;if(this.isContextual(93)&&this.recordAwaitIfAllowed()){this.next(),ret=this.parseAwait(startLoc,!0);let nextOp=this.state.type;nextOp!==35&&this.isBinaryOperator(nextOp)&&this.raise(Errors.PipelineUnparenthesized,startLoc)}else this.state.canStartArrow=!0,ret=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),startLoc,prec);return this.
|
|
1041
|
+
prodParam.exit(),ret}parseModuleExpression(){this.expectPlugin("moduleBlocks");let node=this.startNode();this.next(),this.match(2)||this.unexpected(null,2);let program=this.startNodeAt(this.state.endLoc);this.next();let revertScopes=this.initializeScopes(!0);this.enterInitialScopes();try{node.body=this.parseProgram(program,4,"module")}finally{revertScopes()}return this.finishNode(node,"ModuleExpression")}parseVoidPattern(refExpressionErrors){this.expectPlugin("discardBinding");let node=this.startNode();
|
|
1042
|
+
return refExpressionErrors!=null&&(refExpressionErrors.voidPatternLoc=this.state.startLoc),this.next(),this.finishNode(node,"VoidPattern")}parseMaybeAssignAllowInOrVoidPattern(close,refExpressionErrors,isParenItem){if(refExpressionErrors!=null&&this.match(84)){let nextCode=this.lookaheadCharCode();if(nextCode===44||nextCode===(close===1?93:close===4?125:41)||nextCode===61)return this.parseMaybeDefault(this.state.startLoc,this.parseVoidPattern(refExpressionErrors))}return this.parseMaybeAssignAllowIn(
|
|
1043
|
+
refExpressionErrors,isParenItem)}parsePropertyNamePrefixOperator(prop){}},loopLabel={kind:1},switchLabel={kind:2},loneSurrogate=/[\uD800-\uDFFF]/u,keywordRelationalOperator=/in(?:stanceof)?/y;function createExportedTokens(tokens){for(let i=0;i<tokens.length;i++){let token=tokens[i],{type}=token;typeof type=="number"&&(token.type=getExportedToken(type))}return tokens}var StatementParser=class extends ExpressionParser{parseTopLevel(file,program){return file.program=this.parseProgram(program,136,this.
|
|
1044
|
+
options.sourceType==="module"?"module":"script"),file.comments=this.comments,this.optionFlags&512&&(file.tokens=createExportedTokens(this.tokens)),this.finishNode(file,"File")}parseProgram(program,end,sourceType){if(program.sourceType=sourceType,program.interpreter=this.parseInterpreterDirective(),this.parseBlockBody(program,!0,!0,end),this.inModule){if(!(this.optionFlags&64)&&this.scope.undefinedExports.size>0)for(let[localName,at]of Array.from(this.scope.undefinedExports))this.raise(Errors.ModuleExportUndefined,
|
|
1045
|
+
at,{localName});this.addExtra(program,"topLevelAwait",this.state.hasTopLevelAwait)}let finishedProgram;return end===136?finishedProgram=this.finishNode(program,"Program"):finishedProgram=this.finishNodeAt(program,"Program",createPositionWithColumnOffset(this.state.startLoc,-1)),finishedProgram}stmtToDirective(stmt){let directive=this.castNodeTo(stmt,"Directive"),directiveLiteral=this.castNodeTo(stmt.expression,"DirectiveLiteral"),expressionValue=directiveLiteral.value,raw=this.input.slice(this.offsetToSourcePos(
|
|
1046
|
+
directiveLiteral.start),this.offsetToSourcePos(directiveLiteral.end)),val=directiveLiteral.value=raw.slice(1,-1);return this.addExtra(directiveLiteral,"raw",raw),this.addExtra(directiveLiteral,"rawValue",val),this.addExtra(directiveLiteral,"expressionValue",expressionValue),directive.value=directiveLiteral,delete stmt.expression,directive}parseInterpreterDirective(){if(!this.match(24))return null;let node=this.startNode();return node.value=this.state.value,this.next(),this.finishNode(node,"Inter\
|
|
1047
|
+
preterDirective")}isLet(){return this.isContextual(97)?this.hasFollowingBindingAtom():!1}isUsing(){return this.isContextual(104)?this.nextTokenIsIdentifierOnSameLine():!1}isForUsing(){if(!this.isContextual(104))return!1;let next=this.nextTokenInLineStart(),nextCh=this.codePointAtPos(next);if(this.isUnparsedContextual(next,"of")){let nextCharAfterOf=this.lookaheadCharCodeSince(next+2);if(nextCharAfterOf!==61&&nextCharAfterOf!==58&&nextCharAfterOf!==59)return!1}return!!(this.chStartsBindingIdentifier(
|
|
1048
|
+
nextCh,next)||this.isUnparsedContextual(next,"void"))}nextTokenIsIdentifierOnSameLine(){let next=this.nextTokenInLineStart(),nextCh=this.codePointAtPos(next);return this.chStartsBindingIdentifier(nextCh,next)}isAwaitUsing(){if(!this.isContextual(93))return!1;let next=this.nextTokenInLineStart();if(this.isUnparsedContextual(next,"using")){next=this.nextTokenInLineStartSince(next+5);let nextCh=this.codePointAtPos(next);if(this.chStartsBindingIdentifier(nextCh,next))return!0}return!1}chStartsBindingIdentifier(ch,pos){
|
|
1049
|
+
if(isIdentifierStart(ch)){if(keywordRelationalOperator.lastIndex=pos,keywordRelationalOperator.test(this.input)){let endCh=this.codePointAtPos(keywordRelationalOperator.lastIndex);if(!isIdentifierChar(endCh)&&endCh!==92)return!1}return!0}else return ch===92}chStartsBindingPattern(ch){return ch===91||ch===123}hasFollowingBindingAtom(){let next=this.nextTokenStart(),nextCh=this.codePointAtPos(next);return this.chStartsBindingPattern(nextCh)||this.chStartsBindingIdentifier(nextCh,next)}hasInLineFollowingBindingIdentifierOrBrace(){
|
|
1050
|
+
let next=this.nextTokenInLineStart(),nextCh=this.codePointAtPos(next);return nextCh===123||this.chStartsBindingIdentifier(nextCh,next)}allowsUsing(){return(this.scope.inModule||!this.scope.inTopLevel)&&!this.scope.inBareCaseStatement}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(allowLabeledFunction=!1){let flags=0;return this.options.annexB&&
|
|
1051
|
+
!this.state.strict&&(flags|=4,allowLabeledFunction&&(flags|=8)),this.parseStatementLike(flags)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(flags){let decorators=null;return this.match(22)&&(decorators=this.parseDecorators(!0)),this.parseStatementContent(flags,decorators)}parseStatementContent(flags,decorators){let startType=this.state.type,node=this.startNode(),allowDeclaration=!!(flags&2),allowFunctionDeclaration=!!(flags&4),topLevel=flags&1;switch(startType){case 56:return this.
|
|
1052
|
+
parseBreakContinueStatement(node,!0);case 59:return this.parseBreakContinueStatement(node,!1);case 60:return this.parseDebuggerStatement(node);case 86:return this.parseDoWhileStatement(node);case 87:return this.parseForStatement(node);case 64:if(this.lookaheadCharCode()===46)break;return allowFunctionDeclaration||this.raise(this.state.strict?Errors.StrictFunction:this.options.annexB?Errors.SloppyFunctionAnnexB:Errors.SloppyFunction,this.state.startLoc),this.parseFunctionStatement(node,!1,flags);case 76:
|
|
1053
|
+
return allowDeclaration||this.unexpected(),this.parseClass(this.maybeTakeDecorators(decorators,node),!0);case 65:return this.parseIfStatement(node);case 66:return this.parseReturnStatement(node);case 67:return this.parseSwitchStatement(node);case 68:return this.parseThrowStatement(node);case 69:return this.parseTryStatement(node);case 93:if(this.isAwaitUsing())return this.allowsUsing()?allowDeclaration?this.recordAwaitIfAllowed()||this.raise(Errors.AwaitUsingNotInAsyncContext,node):this.raise(Errors.
|
|
1054
|
+
UnexpectedLexicalDeclaration,node):this.raise(Errors.UnexpectedUsingDeclaration,node),this.next(),this.parseVarStatement(node,"await using");break;case 104:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifierOrBrace())break;return this.allowsUsing()?allowDeclaration||this.raise(Errors.UnexpectedLexicalDeclaration,this.state.startLoc):this.raise(Errors.UnexpectedUsingDeclaration,this.state.startLoc),this.parseVarStatement(node,"using");case 97:{if(this.state.containsEsc)break;let next=this.
|
|
1055
|
+
nextTokenStart(),nextCh=this.codePointAtPos(next);if(nextCh!==91&&(!allowDeclaration&&this.hasFollowingLineBreak()||!this.chStartsBindingIdentifier(nextCh,next)&&nextCh!==123))break}case 71:allowDeclaration||this.raise(Errors.UnexpectedLexicalDeclaration,this.state.startLoc);case 70:{let kind=this.state.value;return this.parseVarStatement(node,kind)}case 88:return this.parseWhileStatement(node);case 72:return this.parseWithStatement(node);case 2:return this.parseBlock();case 9:return this.parseEmptyStatement(
|
|
1056
|
+
node);case 79:{let nextTokenCharCode=this.lookaheadCharCode();if(nextTokenCharCode===40||nextTokenCharCode===46)break}case 78:{!(this.optionFlags&8)&&!topLevel&&this.raise(Errors.UnexpectedImportExport,this.state.startLoc),this.next();let result;return startType===79?result=this.parseImport(node):result=this.parseExport(node,decorators),this.assertModuleNodeAllowed(result),result}default:if(this.isAsyncFunction())return allowDeclaration||this.raise(Errors.AsyncFunctionInSingleStatementContext,this.
|
|
1057
|
+
state.startLoc),this.next(),this.parseFunctionStatement(node,!0,flags)}let maybeName=this.state.value;if(startType===89&&this.lookahead().type===10){let label3=this.parseIdentifier(!0);return this.next(),this.parseLabeledStatement(node,maybeName,label3,flags)}let expr=this.parseExpression();return tokenIsIdentifier(startType)&&expr.type==="Identifier"&&this.eat(10)?this.parseLabeledStatement(node,maybeName,expr,flags):this.parseExpressionStatement(node,expr,flags)}assertModuleNodeAllowed(node){!(this.
|
|
1058
|
+
optionFlags&8)&&!this.inModule&&this.raise(Errors.ImportOutsideModule,node)}maybeTakeDecorators(maybeDecorators,classNode,exportNode){return maybeDecorators&&(classNode.decorators?.length?(this.raise(Errors.DecoratorsBeforeAfterExport,classNode.decorators[0]),classNode.decorators.unshift(...maybeDecorators)):classNode.decorators=maybeDecorators,this.resetStartLocationFromNode(classNode,maybeDecorators[0]),exportNode&&this.resetStartLocationFromNode(exportNode,classNode)),classNode}canHaveLeadingDecorator(){
|
|
1059
|
+
return this.match(76)}parseDecorators(allowExport){let decorators=[];do decorators.push(this.parseDecorator());while(this.match(22));if(this.match(78))allowExport||this.unexpected();else if(!this.canHaveLeadingDecorator())throw this.raise(Errors.UnexpectedLeadingDecorator,this.state.startLoc);return decorators}parseDecorator(){this.expectOnePlugin(["decorators","decorators-legacy"]);let node=this.startNode();if(this.next(),this.hasPlugin("decorators")){let startLoc=this.state.startLoc,expr;if(this.
|
|
1060
|
+
match(6)){let startLoc2=this.state.startLoc;this.next(),expr=this.parseExpression(),this.expect(7),expr=this.wrapParenthesis(startLoc2,expr);let paramsStartLoc=this.state.startLoc;node.expression=this.parseMaybeDecoratorArguments(expr,startLoc2),node.expression!==expr&&this.raise(Errors.DecoratorArgumentsOutsideParentheses,paramsStartLoc)}else{for(expr=this.parseIdentifier(!1);this.eat(12);){let node2=this.startNodeAt(startLoc);node2.object=expr,this.match(135)?(this.classScope.usePrivateName(this.
|
|
1061
|
+
state.value,this.state.startLoc),node2.property=this.parsePrivateName()):node2.property=this.parseIdentifier(!0),node2.computed=!1,expr=this.finishNode(node2,"MemberExpression")}node.expression=this.parseMaybeDecoratorArguments(expr,startLoc)}}else this.state.canStartArrow=!1,node.expression=this.parseExprSubscripts();return this.finishNode(node,"Decorator")}parseMaybeDecoratorArguments(expr,startLoc){if(this.eat(6)){let node=this.startNodeAt(startLoc);return node.callee=expr,node.arguments=this.
|
|
1062
|
+
parseCallExpressionArguments(),this.toReferencedList(node.arguments),this.finishNode(node,"CallExpression")}return expr}parseBreakContinueStatement(node,isBreak){return this.next(),this.isLineTerminator()?node.label=null:(node.label=this.parseIdentifier(this.match(89)),this.semicolon()),this.verifyBreakContinue(node,isBreak),this.finishNode(node,isBreak?"BreakStatement":"ContinueStatement")}verifyBreakContinue(node,isBreak){let i;for(i=0;i<this.state.labels.length;++i){let lab=this.state.labels[i];
|
|
1063
|
+
if((node.label==null||lab.name===node.label.name)&&(lab.kind!=null&&(isBreak||lab.kind===1)||node.label&&isBreak))break}if(i===this.state.labels.length){let type=isBreak?"BreakStatement":"ContinueStatement";this.raise(Errors.IllegalBreakContinue,node,{type})}}parseDebuggerStatement(node){return this.next(),this.semicolon(),this.finishNode(node,"DebuggerStatement")}parseHeaderExpression(){this.expect(6);let val=this.parseExpression();return this.expect(7),val}parseDoWhileStatement(node){return this.
|
|
1064
|
+
next(),this.state.labels.push(loopLabel),node.body=this.parseStatement(),this.state.labels.pop(),this.expect(88),node.test=this.parseHeaderExpression(),this.eat(9),this.finishNode(node,"DoWhileStatement")}parseForStatement(node){this.next(),this.state.labels.push(loopLabel);let awaitAt=null;if(this.isContextual(93)&&this.recordAwaitIfAllowed()&&(awaitAt=this.state.startLoc,this.next()),this.scope.enter(0),this.expect(6),this.match(9))return awaitAt!==null&&this.unexpected(awaitAt),this.parseFor(
|
|
1065
|
+
node,null);let startsWithLet=this.isContextual(97);{let startsWithAwaitUsing=this.isAwaitUsing(),starsWithUsingDeclaration=startsWithAwaitUsing||this.isForUsing(),isLetOrUsing=startsWithLet&&this.hasFollowingBindingAtom()||starsWithUsingDeclaration;if(this.match(70)||this.match(71)||isLetOrUsing){let initNode=this.startNode(),kind;startsWithAwaitUsing?(kind="await using",this.recordAwaitIfAllowed()||this.raise(Errors.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):kind=this.state.value,
|
|
1066
|
+
this.next(),this.parseVar(initNode,!0,kind);let init2=this.finishNode(initNode,"VariableDeclaration"),isForIn=this.match(54);return isForIn&&starsWithUsingDeclaration&&this.raise(Errors.ForInUsing,init2),(isForIn||this.isContextual(99))&&init2.declarations.length===1?this.parseForX(node,init2,awaitAt):(awaitAt!==null&&this.unexpected(awaitAt),this.parseFor(node,init2))}}let startsWithAsync=this.isContextual(92),refExpressionErrors=new ExpressionErrors,init=this.parseExpression(!0,refExpressionErrors),
|
|
1067
|
+
isForOf=this.isContextual(99);if(isForOf&&(startsWithLet&&this.raise(Errors.ForOfLet,init),awaitAt===null&&startsWithAsync&&init.type==="Identifier"&&this.raise(Errors.ForOfAsync,init)),isForOf||this.match(54)){this.checkDestructuringPrivate(refExpressionErrors),this.toAssignable(init,!0);let type=isForOf?"ForOfStatement":"ForInStatement";return this.checkLVal(init,{type}),this.parseForX(node,init,awaitAt)}else this.checkExpressionErrors(refExpressionErrors,!0);return awaitAt!==null&&this.unexpected(
|
|
1068
|
+
awaitAt),this.parseFor(node,init)}parseFunctionStatement(node,isAsync,statementFlags){this.next();let flags=1|(isAsync?8:0);return!(statementFlags&2)&&statementFlags&4&&(flags|=16,statementFlags&8||(flags|=2)),this.parseFunction(node,flags)}parseIfStatement(node){return this.next(),node.test=this.parseHeaderExpression(),node.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),node.alternate=this.eat(62)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(node,
|
|
1069
|
+
"IfStatement")}parseReturnStatement(node){return this.prodParam.hasReturn||this.raise(Errors.IllegalReturn,this.state.startLoc),this.next(),this.isLineTerminator()?node.argument=null:(node.argument=this.parseExpression(),this.semicolon()),this.finishNode(node,"ReturnStatement")}parseSwitchStatement(node){this.next(),node.discriminant=this.parseHeaderExpression();let cases=node.cases=[];this.expect(2),this.state.labels.push(switchLabel),this.scope.enter(256);let cur;for(let sawDefault;!this.match(
|
|
1070
|
+
4);)if(this.match(57)||this.match(61)){let isCase=this.match(57);cur&&this.finishNode(cur,"SwitchCase"),cases.push(cur=this.startNode()),cur.consequent=[],this.next(),isCase?cur.test=this.parseExpression():(sawDefault&&this.raise(Errors.MultipleDefaultsInSwitch,this.state.lastTokStartLoc),sawDefault=!0,cur.test=null),this.expect(10)}else cur?cur.consequent.push(this.parseStatementListItem()):this.unexpected();return this.scope.exit(),cur&&this.finishNode(cur,"SwitchCase"),this.next(),this.state.
|
|
1071
|
+
labels.pop(),this.finishNode(node,"SwitchStatement")}parseThrowStatement(node){return this.next(),this.hasPrecedingLineBreak()&&this.raise(Errors.NewlineAfterThrow,this.state.lastTokEndLoc),node.argument=this.parseExpression(),this.semicolon(),this.finishNode(node,"ThrowStatement")}parseCatchClauseParam(){let param=this.parseBindingAtom();return this.scope.enter(this.options.annexB&¶m.type==="Identifier"?8:0),this.checkLVal(param,{type:"CatchClause"},9),param}parseTryStatement(node){if(this.
|
|
1072
|
+
next(),node.block=this.parseBlock(),node.handler=null,this.match(58)){let clause=this.startNode();this.next(),this.match(6)?(this.expect(6),clause.param=this.parseCatchClauseParam(),this.expect(7)):(clause.param=null,this.scope.enter(0)),clause.body=this.parseBlock(!1,!1),this.scope.exit(),node.handler=this.finishNode(clause,"CatchClause")}return node.finalizer=this.eat(63)?this.parseBlock():null,!node.handler&&!node.finalizer&&this.raise(Errors.NoCatchOrFinally,node),this.finishNode(node,"TrySt\
|
|
1073
|
+
atement")}parseVarStatement(node,kind,allowMissingInitializer=!1){return this.next(),this.parseVar(node,!1,kind,allowMissingInitializer),this.semicolon(),this.finishNode(node,"VariableDeclaration")}parseWhileStatement(node){return this.next(),node.test=this.parseHeaderExpression(),this.state.labels.push(loopLabel),node.body=this.parseStatement(),this.state.labels.pop(),this.finishNode(node,"WhileStatement")}parseWithStatement(node){return this.state.strict&&this.raise(Errors.StrictWith,this.state.
|
|
1074
|
+
startLoc),this.next(),node.object=this.parseHeaderExpression(),node.body=this.parseStatement(),this.finishNode(node,"WithStatement")}parseEmptyStatement(node){return this.next(),this.finishNode(node,"EmptyStatement")}parseLabeledStatement(node,maybeName,expr,flags){for(let label3 of this.state.labels)label3.name===maybeName&&this.raise(Errors.LabelRedeclaration,expr,{labelName:maybeName});let kind=tokenIsLoop(this.state.type)?1:this.match(67)?2:null;for(let i=this.state.labels.length-1;i>=0;i--){
|
|
1075
|
+
let label3=this.state.labels[i];if(label3.statementStart===node.start)label3.statementStart=this.sourceToOffsetPos(this.state.start),label3.kind=kind;else break}return this.state.labels.push({name:maybeName,kind,statementStart:this.sourceToOffsetPos(this.state.start)}),node.body=flags&8?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),node.label=expr,this.finishNode(node,"LabeledStatement")}parseExpressionStatement(node,expr,_flags){return node.
|
|
1076
|
+
expression=expr,this.semicolon(),this.finishNode(node,"ExpressionStatement")}parseBlock(allowDirectives=!1,createNewLexicalScope=!0,afterBlockParse){let node=this.startNode();return allowDirectives&&this.state.strictErrors.clear(),this.expect(2),createNewLexicalScope&&this.scope.enter(0),this.parseBlockBody(node,allowDirectives,!1,4,afterBlockParse),createNewLexicalScope&&this.scope.exit(),this.finishNode(node,"BlockStatement")}isValidDirective(stmt){return stmt.type==="ExpressionStatement"&&stmt.
|
|
1077
|
+
expression.type==="StringLiteral"&&!stmt.expression.extra.parenthesized}parseBlockBody(node,allowDirectives,topLevel,end,afterBlockParse){let body=node.body=[],directives=node.directives=[];this.parseBlockOrModuleBlockBody(body,allowDirectives?directives:void 0,topLevel,end,afterBlockParse)}parseBlockOrModuleBlockBody(body,directives,topLevel,end,afterBlockParse){let oldStrict=this.state.strict,hasStrictModeDirective=!1,parsedNonDirective=!1;for(;!this.match(end);){let stmt=topLevel?this.parseModuleItem():
|
|
1078
|
+
this.parseStatementListItem();if(directives&&!parsedNonDirective){if(this.isValidDirective(stmt)){let directive=this.stmtToDirective(stmt);directives.push(directive),!hasStrictModeDirective&&directive.value.value==="use strict"&&(hasStrictModeDirective=!0,this.setStrict(!0));continue}parsedNonDirective=!0,this.state.strictErrors.clear()}body.push(stmt)}afterBlockParse?.call(this,hasStrictModeDirective),oldStrict||this.setStrict(!1),this.next()}parseFor(node,init){return node.init=init,this.semicolon(
|
|
1079
|
+
!1),node.test=this.match(9)?null:this.parseExpression(),this.semicolon(!1),node.update=this.match(7)?null:this.parseExpression(),this.expect(7),node.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(node,"ForStatement")}parseForX(node,init,awaitAt){let isForIn=this.match(54);return this.next(),isForIn?awaitAt!==null&&this.unexpected(awaitAt):node.await=awaitAt!==null,init.type==="VariableDeclaration"&&init.declarations[0].init!=null&&(!isForIn||!this.options.annexB||
|
|
1080
|
+
this.state.strict||init.kind!=="var"||init.declarations[0].id.type!=="Identifier")&&this.raise(Errors.ForInOfLoopInitializer,init,{type:isForIn?"ForInStatement":"ForOfStatement"}),init.type==="AssignmentPattern"&&this.raise(Errors.InvalidLhs,init,{ancestor:{type:"ForStatement"}}),node.left=init,node.right=isForIn?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(7),node.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(node,isForIn?"ForInStateme\
|
|
1081
|
+
nt":"ForOfStatement")}parseVar(node,isFor,kind,allowMissingInitializer=!1){let declarations=node.declarations=[];for(node.kind=kind;;){let decl=this.startNode();if(this.parseVarId(decl,kind),decl.init=this.eat(25)?isFor?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn():null,decl.init===null&&!allowMissingInitializer&&!(isFor&&declarations.length===0&&(this.match(54)||this.isContextual(99)))&&(decl.id.type!=="Identifier"?this.raise(Errors.DeclarationMissingInitializer,this.state.lastTokEndLoc,
|
|
1082
|
+
{kind:"destructuring"}):(kind==="const"||kind==="using"||kind==="await using")&&this.raise(Errors.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind})),declarations.push(this.finishNode(decl,"VariableDeclarator")),!this.eat(8))break}return node}parseVarId(decl,kind){let id2=this.parseBindingAtom();kind==="using"||kind==="await using"?(id2.type==="ArrayPattern"||id2.type==="ObjectPattern")&&this.raise(Errors.UsingDeclarationHasBindingPattern,id2):id2.type==="VoidPattern"&&this.raise(Errors.
|
|
1083
|
+
UnexpectedVoidPattern,id2),this.checkLVal(id2,{type:"VariableDeclarator"},kind==="var"?5:8201),decl.id=id2}parseAsyncFunctionExpression(node){return this.parseFunction(node,8)}parseFunction(node,flags=0){let isDeclaration=!!(flags&1),requireId=isDeclaration&&!(flags&4),isAsync=!!(flags&8);return this.initFunction(node,isAsync),this.match(51)&&(flags&16&&this.raise(Errors.GeneratorInSingleStatementContext,this.state.startLoc),this.next(),node.generator=!0),isDeclaration&&(node.id=this.parseFunctionId(
|
|
1084
|
+
requireId)),this.scope.enter(514),this.prodParam.enter(functionFlags(isAsync,node.generator)),!isDeclaration&&tokenIsIdentifier(this.state.type)&&(this.expressionScope.enter(newExpressionScope()),node.id=this.parseFunctionId(),this.expressionScope.exit()),this.parseFunctionParams(node,!1),this.parseFunctionBodyAndFinish(node,isDeclaration?"FunctionDeclaration":"FunctionExpression"),this.prodParam.exit(),this.scope.exit(),isDeclaration&&!(flags&2)&&this.registerFunctionStatementId(node),node}parseFunctionId(requireId){
|
|
1085
|
+
return requireId||tokenIsIdentifier(this.state.type)?this.parseIdentifier():null}parseFunctionParams(node,isConstructor){this.expect(6),this.expressionScope.enter(newParameterDeclarationScope()),node.params=this.parseBindingList(7,41,2|(isConstructor?4:0)),this.expressionScope.exit()}registerFunctionStatementId(node){node.id&&this.scope.declareName(node.id.name,!this.options.annexB||this.state.strict||node.generator||node.async?this.scope.treatFunctionsAsVar?5:8201:17,node.id.start)}parseClass(node,isStatement,optionalId){
|
|
1086
|
+
this.next();let oldStrict=this.state.strict;return this.state.strict=!0,this.parseClassId(node,isStatement,optionalId),this.parseClassSuper(node),node.body=this.parseClassBody(!!node.superClass,oldStrict),this.finishNode(node,isStatement?"ClassDeclaration":"ClassExpression")}isClassProperty(){return this.match(25)||this.match(9)||this.match(4)}isClassMethod(){return this.match(6)}nameIsConstructor(key){return key.type==="Identifier"&&key.name==="constructor"||key.type==="StringLiteral"&&key.value===
|
|
1087
|
+
"constructor"}isNonstaticConstructor(method){return!method.computed&&!method.static&&this.nameIsConstructor(method.key)}parseClassBody(hadSuperClass,oldStrict){this.classScope.enter();let state={hadConstructor:!1,hadSuperClass},decorators=[],classBody=this.startNode();for(classBody.body=[],this.expect(2);!this.match(4);){if(this.eat(9)){if(decorators.length>0)throw this.raise(Errors.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(22)){decorators.push(this.parseDecorator());continue}
|
|
1088
|
+
let member=this.startNode();decorators.length&&(member.decorators=decorators,this.resetStartLocationFromNode(member,decorators[0]),decorators=[]),this.parseClassMember(classBody,member,state)}if(this.state.strict=oldStrict,this.next(),decorators.length)throw this.raise(Errors.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(classBody,"ClassBody")}parseClassMemberFromModifier(classBody,member){let key=this.parseIdentifier(!0);if(this.isClassMethod()){let method=member;
|
|
1089
|
+
return method.kind="method",method.computed=!1,method.key=key,method.static=!1,this.pushClassMethod(classBody,method,!1,!1,!1,!1),!0}else if(this.isClassProperty()){let prop=member;return prop.computed=!1,prop.key=key,prop.static=!1,classBody.body.push(this.parseClassProperty(prop)),!0}return this.resetPreviousNodeTrailingComments(key),!1}parseClassMember(classBody,member,state){let isStatic=this.isContextual(103);if(isStatic){if(this.parseClassMemberFromModifier(classBody,member))return;if(this.
|
|
1090
|
+
eat(2)){this.parseClassStaticBlock(classBody,member);return}}this.parseClassMemberWithIsStatic(classBody,member,state,isStatic)}parseClassMemberWithIsStatic(classBody,member,state,isStatic){let publicMethod=member,privateMethod=member,publicProp=member,privateProp=member,accessorProp=member,method=publicMethod,publicMember=publicMethod;if(member.static=isStatic,this.parsePropertyNamePrefixOperator(member),this.eat(51)){method.kind="method";let isPrivateName=this.match(135);if(this.parseClassElementName(
|
|
1091
|
+
method),this.parsePostMemberNameModifiers(method),isPrivateName){this.pushClassPrivateMethod(classBody,privateMethod,!0,!1);return}this.isNonstaticConstructor(publicMethod)&&this.raise(Errors.ConstructorIsGenerator,publicMethod.key),this.pushClassMethod(classBody,publicMethod,!0,!1,!1,!1);return}let isContextual=!this.state.containsEsc&&tokenIsIdentifier(this.state.type),key=this.parseClassElementName(member),maybeContextualKw=isContextual?key.name:null,isPrivate=this.isPrivateName(key),maybeQuestionTokenStartLoc=this.
|
|
1092
|
+
state.startLoc;if(this.parsePostMemberNameModifiers(publicMember),this.isClassMethod()){if(method.kind="method",isPrivate){this.pushClassPrivateMethod(classBody,privateMethod,!1,!1);return}let isConstructor=this.isNonstaticConstructor(publicMethod),allowsDirectSuper=!1;isConstructor&&(publicMethod.kind="constructor",publicMethod.decorators&&publicMethod.decorators.length>0&&this.raise(Errors.DecoratorConstructor,member),state.hadConstructor&&!this.hasPlugin("typescript")&&this.raise(Errors.DuplicateConstructor,
|
|
1093
|
+
key),isConstructor&&this.hasPlugin("typescript")&&member.override&&this.raise(Errors.OverrideOnConstructor,key),state.hadConstructor=!0,allowsDirectSuper=state.hadSuperClass),this.pushClassMethod(classBody,publicMethod,!1,!1,isConstructor,allowsDirectSuper)}else if(this.isClassProperty())isPrivate?this.pushClassPrivateProperty(classBody,privateProp):this.pushClassProperty(classBody,publicProp);else if(maybeContextualKw==="async"&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(key);
|
|
1094
|
+
let isGenerator=this.eat(51);publicMember.optional&&this.unexpected(maybeQuestionTokenStartLoc),method.kind="method";let isPrivate2=this.match(135);this.parseClassElementName(method),this.parsePostMemberNameModifiers(publicMember),isPrivate2?this.pushClassPrivateMethod(classBody,privateMethod,isGenerator,!0):(this.isNonstaticConstructor(publicMethod)&&this.raise(Errors.ConstructorIsAsync,publicMethod.key),this.pushClassMethod(classBody,publicMethod,isGenerator,!0,!1,!1))}else if((maybeContextualKw===
|
|
1095
|
+
"get"||maybeContextualKw==="set")&&!(this.match(51)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(key),method.kind=maybeContextualKw;let isPrivate2=this.match(135);this.parseClassElementName(publicMethod),isPrivate2?this.pushClassPrivateMethod(classBody,privateMethod,!1,!1):(this.isNonstaticConstructor(publicMethod)&&this.raise(Errors.ConstructorIsAccessor,publicMethod.key),this.pushClassMethod(classBody,publicMethod,!1,!1,!1,!1)),this.checkGetterSetterParams(publicMethod)}else if(maybeContextualKw===
|
|
1096
|
+
"accessor"&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(key);let isPrivate2=this.match(135);this.parseClassElementName(publicProp),this.pushClassAccessorProperty(classBody,accessorProp,isPrivate2)}else this.isLineTerminator()?isPrivate?this.pushClassPrivateProperty(classBody,privateProp):this.pushClassProperty(classBody,publicProp):this.unexpected()}parseClassElementName(member){let{type,value}=this.state;if((type===129||type===131)&&
|
|
1097
|
+
member.static&&value==="prototype"&&this.raise(Errors.StaticPrototype,this.state.startLoc),type===135){value==="constructor"&&this.raise(Errors.ConstructorClassPrivateField,this.state.startLoc);let key=this.parsePrivateName();return member.key=key,key}return this.parsePropertyName(member),member.key}parseClassStaticBlock(classBody,member){this.scope.enter(720);let oldLabels=this.state.labels;this.state.labels=[],this.prodParam.enter(0);let body=member.body=[];this.parseBlockOrModuleBlockBody(body,
|
|
1098
|
+
void 0,!1,4),this.prodParam.exit(),this.scope.exit(),this.state.labels=oldLabels,classBody.body.push(this.finishNode(member,"StaticBlock")),member.decorators?.length&&this.raise(Errors.DecoratorStaticBlock,member)}pushClassProperty(classBody,prop){!prop.computed&&this.nameIsConstructor(prop.key)&&this.raise(Errors.ConstructorClassField,prop.key),classBody.body.push(this.parseClassProperty(prop))}pushClassPrivateProperty(classBody,prop){let node=this.parseClassPrivateProperty(prop);classBody.body.
|
|
1099
|
+
push(node),this.classScope.declarePrivateName(this.getPrivateNameSV(node.key),0,node.key.start)}pushClassAccessorProperty(classBody,prop,isPrivate){!isPrivate&&!prop.computed&&this.nameIsConstructor(prop.key)&&this.raise(Errors.ConstructorClassField,prop.key);let node=this.parseClassAccessorProperty(prop);classBody.body.push(node),isPrivate&&this.classScope.declarePrivateName(this.getPrivateNameSV(node.key),0,node.key.start)}pushClassMethod(classBody,method,isGenerator,isAsync,isConstructor,allowsDirectSuper){
|
|
1100
|
+
classBody.body.push(this.parseMethod(method,isGenerator,isAsync,isConstructor,allowsDirectSuper,"ClassMethod",!0))}pushClassPrivateMethod(classBody,method,isGenerator,isAsync){let node=this.parseMethod(method,isGenerator,isAsync,!1,!1,"ClassPrivateMethod",!0);classBody.body.push(node);let kind=node.kind==="get"?node.static?6:2:node.kind==="set"?node.static?5:1:0;this.declareClassPrivateMethodInScope(node,kind)}declareClassPrivateMethodInScope(node,kind){this.classScope.declarePrivateName(this.getPrivateNameSV(
|
|
1101
|
+
node.key),kind,node.key.start)}parsePostMemberNameModifiers(methodOrProp){}parseClassPrivateProperty(node){return this.parseInitializer(node),this.semicolon(),this.finishNode(node,"ClassPrivateProperty")}parseClassProperty(node){return this.parseInitializer(node),this.semicolon(),this.finishNode(node,"ClassProperty")}parseClassAccessorProperty(node){return this.parseInitializer(node),this.semicolon(),this.finishNode(node,"ClassAccessorProperty")}parseInitializer(node){this.scope.enter(592),this.
|
|
1102
|
+
expressionScope.enter(newExpressionScope()),this.prodParam.enter(0),node.value=this.eat(25)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(node,isStatement,optionalId,bindingType=8331){if(tokenIsIdentifier(this.state.type))node.id=this.parseIdentifier(),this.checkStrictBindReservedWord(node.id,bindingType),isStatement&&this.declareNameFromIdentifier(node.id,bindingType);else if(optionalId||!isStatement)node.id=null;else throw this.
|
|
1103
|
+
raise(Errors.MissingClassName,this.state.startLoc)}parseClassSuper(node){this.eat(77)?(this.state.canStartArrow=!1,node.superClass=this.parseExprSubscripts()):node.superClass=null}parseExport(node,decorators){let maybeDefaultIdentifier=this.parseMaybeImportPhase(node,!0),hasDefault=this.maybeParseExportDefaultSpecifier(node,maybeDefaultIdentifier),parseAfterDefault=!hasDefault||this.eat(8),hasStar=parseAfterDefault&&this.eatExportStar(node),hasNamespace=hasStar&&this.maybeParseExportNamespaceSpecifier(
|
|
1104
|
+
node),parseAfterNamespace=parseAfterDefault&&!hasNamespace,isFromRequired=hasDefault||hasStar;if(hasStar&&!hasNamespace){if(hasDefault&&this.unexpected(),decorators)throw this.raise(Errors.UnsupportedDecoratorExport,node);return this.parseExportFrom(node,!0),this.sawUnambiguousESM=!0,this.finishNode(node,"ExportAllDeclaration")}let hasSpecifiers=parseAfterNamespace&&this.maybeParseExportNamedSpecifiers(node);hasDefault&&parseAfterDefault&&!hasStar&&!hasSpecifiers&&this.unexpected(null,2);let hasDeclaration;
|
|
1105
|
+
if(isFromRequired||hasSpecifiers){if(hasDeclaration=!1,decorators)throw this.raise(Errors.UnsupportedDecoratorExport,node);this.parseExportFrom(node,isFromRequired)}else hasDeclaration=this.maybeParseExportDeclaration(node);if(isFromRequired||hasSpecifiers||hasDeclaration){let node2=node;if(this.checkNamedExport(node2,!!node2.source),node2.declaration?.type==="ClassDeclaration")this.maybeTakeDecorators(decorators,node2.declaration,node2);else if(decorators)throw this.raise(Errors.UnsupportedDecoratorExport,
|
|
1106
|
+
node);return this.sawUnambiguousESM=!0,this.finishNode(node2,"ExportNamedDeclaration")}if(this.eat(61)){let node2=node,decl=this.parseExportDefaultExpression();if(node2.declaration=decl,decl.type==="ClassDeclaration")this.maybeTakeDecorators(decorators,decl,node2);else if(decorators)throw this.raise(Errors.UnsupportedDecoratorExport,node);return this.checkDuplicateExports(node,"default"),this.hasPlugin("exportDefaultFrom")&&decl.type==="Identifier"&&decl.name==="from"&&decl.end-decl.start===4&&!decl.
|
|
1107
|
+
extra?.parenthesized&&this.raise(Errors.ExportDefaultFromAsIdentifier,decl),this.sawUnambiguousESM=!0,this.finishNode(node2,"ExportDefaultDeclaration")}throw this.unexpected(null,2)}eatExportStar(_){return this.eat(51)}maybeParseExportDefaultSpecifier(node,maybeDefaultIdentifier){if(maybeDefaultIdentifier||this.isExportDefaultSpecifier()){this.expectPlugin("exportDefaultFrom",maybeDefaultIdentifier?.start);let id2=maybeDefaultIdentifier||this.parseIdentifier(!0),specifier=this.startNodeAtNode(id2);
|
|
1108
|
+
return specifier.exported=id2,node.specifiers=[this.finishNode(specifier,"ExportDefaultSpecifier")],!0}return!1}maybeParseExportNamespaceSpecifier(node){if(this.isContextual(90)){node.specifiers??=[];let specifier=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),specifier.exported=this.parseModuleExportName(),node.specifiers.push(this.finishNode(specifier,"ExportNamespaceSpecifier")),!0}return!1}maybeParseExportNamedSpecifiers(node){if(this.match(2)){let node2=node;node2.specifiers||
|
|
1109
|
+
(node2.specifiers=[]);let isTypeExport=node2.exportKind==="type";return node2.specifiers.push(...this.parseExportSpecifiers(isTypeExport)),node2.source=null,node2.attributes=[],node2.declaration=null,!0}return!1}maybeParseExportDeclaration(node){return this.shouldParseExportDeclaration()?(node.specifiers=[],node.source=null,node.attributes=[],node.declaration=this.parseExportDeclaration(node),!0):!1}isAsyncFunction(){if(!this.isContextual(92))return!1;let next=this.nextTokenInLineStart();return this.
|
|
1110
|
+
isUnparsedContextual(next,"function")}parseExportDefaultExpression(){let expr=this.startNode();if(this.match(64))return this.next(),this.parseFunction(expr,5);if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(expr,13);if(this.match(76))return this.parseClass(expr,!0,!0);if(this.match(22))return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(71)||this.match(70)||this.isLet()||this.isUsing()||this.isAwaitUsing())throw this.
|
|
1111
|
+
raise(Errors.UnsupportedDefaultExport,this.state.startLoc);let res=this.parseMaybeAssignAllowIn();return this.semicolon(),res}parseExportDeclaration(node){return this.match(76)?this.parseClass(this.startNode(),!0,!1):this.parseStatementListItem()}isExportDefaultSpecifier(){let{type}=this.state;if(tokenIsIdentifier(type)){if(type===92&&!this.state.containsEsc||type===97)return!1;if((type===127||type===126)&&!this.state.containsEsc){let next2=this.nextTokenStart(),nextChar=this.input.charCodeAt(next2);
|
|
1112
|
+
if(nextChar===123||this.chStartsBindingIdentifier(nextChar,next2)&&!this.input.startsWith("from",next2))return this.expectOnePlugin(["flow","typescript"]),!1}}else if(!this.match(61))return!1;let next=this.nextTokenStart(),hasFrom=this.isUnparsedContextual(next,"from");if(this.input.charCodeAt(next)===44||tokenIsIdentifier(this.state.type)&&hasFrom)return!0;if(this.match(61)&&hasFrom){let nextAfterFrom=this.input.charCodeAt(this.hasPlugin("exportDefaultFrom")?this.nextTokenStartSince(next+4):this.
|
|
1113
|
+
nextTokenInLineStartSince(next+4));return nextAfterFrom===34||nextAfterFrom===39}return!1}parseExportFrom(node,expect){this.eatContextual(95)?(node.source=this.parseImportSource(),this.maybeParseImportAttributes(node)):expect&&this.unexpected(null,95),this.semicolon()}shouldParseExportDeclaration(){let{type}=this.state;return type===22&&(this.expectOnePlugin(["decorators","decorators-legacy"]),this.hasPlugin("decorators"))?!0:this.isUsing()?(this.raise(Errors.UsingDeclarationExport,this.state.startLoc),
|
|
1114
|
+
!0):this.isAwaitUsing()?(this.raise(Errors.UsingDeclarationExport,this.state.startLoc),!0):type===70||type===71||type===64||type===76||this.isLet()||this.isAsyncFunction()}checkNamedExport(node,isFrom){if(node.specifiers?.length)for(let specifier of node.specifiers){let{exported}=specifier,exportName=exported.type==="Identifier"?exported.name:exported.value;if(this.checkDuplicateExports(specifier,exportName),!isFrom&&specifier.type==="ExportSpecifier"){let{local}=specifier;local.type!=="Identifi\
|
|
1115
|
+
er"?this.raise(Errors.ExportBindingIsString,specifier,{localName:local.value,exportName}):(this.checkReservedWord(local.name,local.start,!0,!1),this.scope.checkLocalExport(local))}}else if(node.declaration){let decl=node.declaration;if(decl.type==="FunctionDeclaration"||decl.type==="ClassDeclaration"){let{id:id2}=decl;if(!id2)throw new Error("Assertion failure");this.checkDuplicateExports(node,id2.name)}else if(decl.type==="VariableDeclaration")for(let declaration of decl.declarations)this.checkDeclaration(
|
|
1116
|
+
declaration.id)}}checkDeclaration(node){if(node.type==="Identifier")this.checkDuplicateExports(node,node.name);else if(node.type==="ObjectPattern")for(let prop of node.properties)this.checkDeclaration(prop);else if(node.type==="ArrayPattern")for(let elem of node.elements)elem&&this.checkDeclaration(elem);else node.type==="ObjectProperty"?this.checkDeclaration(node.value):node.type==="RestElement"?this.checkDeclaration(node.argument):node.type==="AssignmentPattern"&&this.checkDeclaration(node.left)}checkDuplicateExports(node,exportName){
|
|
1117
|
+
this.exportedIdentifiers.has(exportName)&&(exportName==="default"?this.raise(Errors.DuplicateDefaultExport,node):this.raise(Errors.DuplicateExport,node,{exportName})),this.exportedIdentifiers.add(exportName)}parseExportSpecifiers(isInTypeExport){let nodes=[],first=!0;for(this.expect(2);!this.eat(4);){if(first)first=!1;else if(this.expect(8),this.eat(4))break;let isMaybeTypeOnly=this.isContextual(127),isString=this.match(131),node=this.startNode();node.local=this.parseModuleExportName(),nodes.push(
|
|
1118
|
+
this.parseExportSpecifier(node,isString,isInTypeExport,isMaybeTypeOnly))}return nodes}parseExportSpecifier(node,isString,isInTypeExport,isMaybeTypeOnly){return this.eatContextual(90)?node.exported=this.parseModuleExportName():isString?node.exported=this.cloneStringLiteral(node.local):node.exported||(node.exported=this.cloneIdentifier(node.local)),this.finishNode(node,"ExportSpecifier")}parseModuleExportName(){if(this.match(131)){let result=this.parseStringLiteral(this.state.value),surrogate=loneSurrogate.
|
|
1119
|
+
exec(result.value);return surrogate&&this.raise(Errors.ModuleExportNameHasLoneSurrogate,result,{surrogateCharCode:surrogate[0].charCodeAt(0)}),result}return this.parseIdentifier(!0)}checkImportPhase(node){let{specifiers}=node,singleBindingType=specifiers.length===1?specifiers[0].type:null;node.phase==="source"?singleBindingType!=="ImportDefaultSpecifier"&&this.raise(Errors.SourcePhaseImportRequiresDefault,specifiers[0]):node.phase==="defer"&&singleBindingType!=="ImportNamespaceSpecifier"&&this.raise(
|
|
1120
|
+
Errors.DeferImportRequiresNamespace,specifiers[0])}isPotentialImportPhase(isExport){return isExport?!1:this.isContextual(102)||this.isContextual(94)}applyImportPhase(node,isExport,phase,loc){isExport||(phase==="source"?(this.expectPlugin("sourcePhaseImports",loc),node.phase="source"):phase==="defer"?(this.expectPlugin("deferredImportEvaluation",loc),node.phase="defer"):(this.hasPlugin("sourcePhaseImports")||this.hasPlugin("deferredImportEvaluation"))&&(node.phase=null))}parseMaybeImportPhase(node,isExport){
|
|
1121
|
+
if(!this.isPotentialImportPhase(isExport))return this.applyImportPhase(node,isExport,null),null;let phaseIdentifier=this.startNode(),phaseIdentifierName=this.parseIdentifierName(!0),{type}=this.state;return(tokenIsKeywordOrIdentifier(type)?type!==95||this.lookaheadCharCode()===102:type!==8)?(this.applyImportPhase(node,isExport,phaseIdentifierName,phaseIdentifier.start),null):(this.applyImportPhase(node,isExport,null),this.createIdentifier(phaseIdentifier,phaseIdentifierName))}isPrecedingIdImportPhase(phase){
|
|
1122
|
+
let{type}=this.state;return tokenIsIdentifier(type)?type!==95||this.lookaheadCharCode()===102:type!==8}parseImport(node){return this.match(131)?this.parseImportSourceAndAttributes(node):this.parseImportSpecifiersAndAfter(node,this.parseMaybeImportPhase(node,!1))}parseImportSpecifiersAndAfter(node,maybeDefaultIdentifier){node.specifiers=[];let parseNext=!this.maybeParseDefaultImportSpecifier(node,maybeDefaultIdentifier)||this.eat(8),hasStar=parseNext&&this.maybeParseStarImportSpecifier(node);return parseNext&&
|
|
1123
|
+
!hasStar&&this.parseNamedImportSpecifiers(node),this.expectContextual(95),this.parseImportSourceAndAttributes(node)}parseImportSourceAndAttributes(node){return node.specifiers??=[],node.source=this.parseImportSource(),this.maybeParseImportAttributes(node),this.checkImportPhase(node),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(node,"ImportDeclaration")}parseImportSource(){return this.match(131)||this.unexpected(),this.parseExprAtom()}parseImportSpecifierLocal(node,specifier,type){specifier.
|
|
1124
|
+
local=this.parseIdentifier(),node.specifiers.push(this.finishImportSpecifier(specifier,type))}finishImportSpecifier(specifier,type,bindingType=8201){return this.checkLVal(specifier.local,{type},bindingType),this.finishNode(specifier,type)}parseImportAttributes(){this.expect(2);let attrs=[],attrNames=new Set;do{if(this.match(4))break;let node=this.startNode(),keyName=this.state.value;if(attrNames.has(keyName)&&this.raise(Errors.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:keyName}),
|
|
1125
|
+
attrNames.add(keyName),this.match(131)?node.key=this.parseStringLiteral(keyName):node.key=this.parseIdentifier(!0),this.expect(10),!this.match(131))throw this.raise(Errors.ModuleAttributeInvalidValue,this.state.startLoc);node.value=this.parseStringLiteral(this.state.value),attrs.push(this.finishNode(node,"ImportAttribute"))}while(this.eat(8));return this.expect(4),attrs}maybeParseImportAttributes(node){let attributes;if(this.match(72)){if(this.hasPrecedingLineBreak()&&this.lookaheadCharCode()===
|
|
1126
|
+
40)return;this.next(),attributes=this.parseImportAttributes()}else attributes=[];node.attributes=attributes}maybeParseDefaultImportSpecifier(node,maybeDefaultIdentifier){if(maybeDefaultIdentifier){let specifier=this.startNodeAtNode(maybeDefaultIdentifier);return specifier.local=maybeDefaultIdentifier,node.specifiers.push(this.finishImportSpecifier(specifier,"ImportDefaultSpecifier")),!0}else if(tokenIsKeywordOrIdentifier(this.state.type))return this.parseImportSpecifierLocal(node,this.startNode(),
|
|
1127
|
+
"ImportDefaultSpecifier"),!0;return!1}maybeParseStarImportSpecifier(node){if(this.match(51)){let specifier=this.startNode();return this.next(),this.expectContextual(90),this.parseImportSpecifierLocal(node,specifier,"ImportNamespaceSpecifier"),!0}return!1}parseNamedImportSpecifiers(node){let first=!0;for(this.expect(2);!this.eat(4);){if(first)first=!1;else{if(this.eat(10))throw this.raise(Errors.DestructureNamedImport,this.state.startLoc);if(this.expect(8),this.eat(4))break}let specifier=this.startNode(),
|
|
1128
|
+
importedIsString=this.match(131),isMaybeTypeOnly=this.isContextual(127);specifier.imported=this.parseModuleExportName();let importSpecifier=this.parseImportSpecifier(specifier,importedIsString,node.importKind==="type"||node.importKind==="typeof",isMaybeTypeOnly,void 0);node.specifiers.push(importSpecifier)}}parseImportSpecifier(specifier,importedIsString,isInTypeOnlyImport,isMaybeTypeOnly,bindingType){if(this.eatContextual(90))specifier.local=this.parseIdentifier();else{let{imported}=specifier;if(importedIsString)
|
|
1129
|
+
throw this.raise(Errors.ImportBindingIsString,specifier,{importName:imported.value});this.checkReservedWord(imported.name,specifier.start,!0,!0),specifier.local||(specifier.local=this.cloneIdentifier(imported))}return this.finishImportSpecifier(specifier,"ImportSpecifier",bindingType)}isThisParam(param){return param.type==="Identifier"&¶m.name==="this"}},keywordAndTSRelationalOperator=/in(?:stanceof)?|as|satisfies/y;function nonNull(x){if(x==null)throw new Error(`Unexpected ${x} value.`);return x}
|
|
1130
|
+
function assert(x){if(!x)throw new Error("Assert fail")}var TSErrorTemplates={AbstractMethodHasImplementation:({methodName})=>`Method '${methodName}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName})=>`Property '${propertyName}' cannot have an initializer because it is marked abstract.`,AccessorCannotBeOptional:"An 'accessor' property cannot be declared optional.",AccessorCannotDeclareThisParameter:"'get' and 'set' accessors cannot decl\
|
|
1131
|
+
are 'this' parameters.",AccessorCannotHaveTypeParameters:"An accessor cannot have type parameters.",ClassMethodHasDeclare:"Class methods cannot have the 'declare' modifier.",ClassMethodHasReadonly:"Class methods cannot have the 'readonly' modifier.",ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference:"A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",ConstructorHasTypeParameters:"Type parameters cannot appear on a construct\
|
|
1132
|
+
or declaration.",DeclaratorDefiniteAssertionRequiresTypeAnnotation:"Declarations with definite assignment assertions must also have type annotations.",DeclaratorDefiniteAssertionWithInitializer:"Declarations with initializers cannot also have definite assignment assertions.",DeclareAccessor:({kind})=>`'declare' is not allowed in ${kind}ters.`,DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared \
|
|
1133
|
+
in ambient contexts.",DecoratorAbstractMethod:({kind})=>`Decorators can't be used with ${kind.startsWith("a")?"an":"a"} ${kind}.`,DuplicateAccessibilityModifier:({modifier})=>`Accessibility modifier already seen: '${modifier}'.`,DuplicateModifier:({modifier})=>`Duplicate modifier: '${modifier}'.`,EmptyHeritageClauseType:({token})=>`'${token}' list cannot be empty.`,EmptyNamespaceName:"Namespace must be given a name.",EmptyTypeArguments:"Type argument list cannot be empty.",EmptyTypeParameters:"T\
|
|
1134
|
+
ype parameter list cannot be empty.",ExpectedAmbientAfterExportDeclare:"'export declare' must be followed by an ambient declaration.",ExportAssignmentInTSNamespace:"An export assignment cannot be used in a namespace.",ExportInTSNamespace:"Export declarations are not permitted in a namespace.",ImportAliasHasImportType:"An import alias can not use 'import type'.",ImportInTSNamespace:"Import declarations in a namespace cannot reference a module.",IncompatibleModifiers:({modifiers})=>`'${modifiers[0]}\
|
|
1135
|
+
' modifier cannot be used with '${modifiers[1]}' modifier.`,IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:({modifier})=>`Index signatures cannot have an accessibility modifier ('${modifier}').`,IndexSignatureHasDeclare:"Index signatures cannot have the 'declare' modifier.",IndexSignatureHasOverride:"'override' modifier cannot appear on an index signature.",IndexSignatureHasStatic:"Index signatures cannot have the 'static' modifie\
|
|
1136
|
+
r.",InitializerNotAllowedInAmbientContext:"Initializers are not allowed in ambient contexts.",InlineModuleDeclarationMustUseString:"`module ... {}` declarations must have a string name. Use `namespace ... {}` instead.",InvalidHeritageClauseType:({token})=>`'${token}' list can only include identifiers or qualified-names with optional type arguments.`,InvalidModifierOnAwaitUsingDeclaration:modifier=>`'${modifier}' modifier cannot appear on an await using declaration.`,InvalidModifierOnTypeMember:({
|
|
1137
|
+
modifier})=>`'${modifier}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier})=>`'${modifier}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier})=>`'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifierOnUsingDeclaration:modifier=>`'${modifier}' modifier cannot appear on a using declaration.`,InvalidModifiersOrder:({orderedModifiers})=>`'${orderedModifiers[0]}\
|
|
1138
|
+
' modifier must precede '${orderedModifiers[1]}' modifier.`,InvalidNamespaceName:value=>`Namespace name cannot be '${value}'.`,InvalidPropertyAccessAfterInstantiationExpression:"Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",InvalidTupleMemberLabel:"Tuple members must be labeled with a simple identifier.",MissingInterfaceName:"'interface' declarations must be followed by an identifier.",NamespaceExportInTSNamespace:"\
|
|
1139
|
+
Global module exports may only appear at top level.",NonAbstractClassHasAbstractMethod:"Abstract methods can only appear within an abstract class.",NonClassMethodPropertyHasAbstractModifier:"'abstract' modifier can only appear on a class, method, or property declaration.",OptionalTypeBeforeRequired:"A required element cannot follow an optional element.",OverrideNotInSubClass:"This member cannot have an 'override' modifier because its containing class does not extend another class.",PatternIsOptional:"\
|
|
1140
|
+
A binding pattern parameter cannot be optional in an implementation signature.",PrivateElementHasAbstract:"Private elements cannot have the 'abstract' modifier.",PrivateElementHasAccessibility:({modifier})=>`Private elements cannot have an accessibility modifier ('${modifier}').`,ReadonlyForMethodSignature:"'readonly' modifier can only appear on a property declaration or index signature.",ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing com\
|
|
1141
|
+
ma, as in `<T,>() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccessorCannotHaveOptionalParameter:"A 'set' accessor cannot have an optional parameter.",SetAccessorCannotHaveRestParameter:"A 'set' accessor cannot have rest parameter.",SetAccessorCannotHaveReturnType:"A 'set' accessor cannot have a return type annotation.",SingleTypeParameterWithoutTrailingComma:({typeParameterName})=>`Single type parameter ${typeParameterName}\
|
|
1142
|
+
should have a trailing comma. Example usage: <${typeParameterName},>.`,StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:"\
|
|
1143
|
+
A type-only import can specify a default import or named bindings, but not both.",TypeModifierIsUsedInTypeExports:"The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",TypeModifierIsUsedInTypeImports:"The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",UnexpectedParameterInitializer:"A parameter initializer is only allowed in a function or constructor implementation.",UnexpectedParameterModifier:"\
|
|
1144
|
+
A parameter property is only allowed in a constructor implementation.",UnexpectedReadonly:"'readonly' type modifier is only permitted on array and tuple literal types.",UnexpectedTypeAnnotation:"Did not expect a type annotation here.",UnexpectedTypeCastInParameter:"Unexpected type cast in parameter position.",UnexpectedTypeDeclaration:type=>`'${type}' declarations can only be declared inside a block.`,UnsupportedImportTypeArgument:"Argument in a type import must be a string literal.",UnsupportedParameterPropertyKind:"\
|
|
1145
|
+
A parameter property may not be declared using a binding pattern.",UnsupportedSignatureParameterKind:({type})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.`,UsingDeclarationInAmbientContext:kind=>`'${kind}' declarations are not allowed in ambient contexts.`},TSErrors=ParseErrorEnum`typescript`(TSErrorTemplates);function keywordTypeFromName(value){switch(value){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"\
|
|
1146
|
+
TSBigIntKeyword";case"never":return"TSNeverKeyword";case"number":return"TSNumberKeyword";case"object":return"TSObjectKeyword";case"string":return"TSStringKeyword";case"symbol":return"TSSymbolKeyword";case"undefined":return"TSUndefinedKeyword";case"unknown":return"TSUnknownKeyword";default:return}}function tsIsAccessModifier(modifier){return modifier==="private"||modifier==="public"||modifier==="protected"}function tsIsVarianceAnnotations(modifier){return modifier==="in"||modifier==="out"}function tsIsEntityName(node){
|
|
1147
|
+
if(node.extra?.parenthesized)return!1;switch(node.type){case"Identifier":return!0;case"MemberExpression":return!node.computed&&tsIsEntityName(node.object);case"TSInstantiationExpression":return tsIsEntityName(node.expression);default:return!1}}var ClassMemberModifiers=buildModifiersMap(["declare","private","public","protected","override","abstract","readonly","static"],["in","out"]),IndexSignatureModifiers=buildModifiersMap(["readonly"],["declare","abstract","private","protected","public","stati\
|
|
1148
|
+
c","override"]),BindingElementModifiers=buildModifiersMap(["public","private","protected","override","readonly"]),AccessModifiers=buildModifiersMap(["private","public","protected"]),typescript=superClass=>class extends superClass{getScopeHandler(){return TypeScriptScopeHandler}tsIsIdentifier(){return tokenIsIdentifier(this.state.type)}tsTokenCanFollowModifier(){return this.match(0)||this.match(2)||this.match(51)||this.match(17)||this.match(135)||this.isLiteralPropertyName()}tsNextTokenOnSameLineAndCanFollowModifier(){
|
|
1149
|
+
return this.next(),this.hasPrecedingLineBreak()?!1:this.tsTokenCanFollowModifier()}tsNextTokenCanFollowModifier(){return this.match(103)?(this.next(),this.tsTokenCanFollowModifier()):this.tsNextTokenOnSameLineAndCanFollowModifier()}tsParseModifier(modifiers,stopOnStartOfClassStaticBlock,hasSeenStaticModifier){if(!tokenIsIdentifier(this.state.type)&&this.state.type!==54&&this.state.type!==71)return;let modifier=this.state.value;if(modifiers.has(modifier)){if(hasSeenStaticModifier&&this.match(103)||
|
|
1150
|
+
stopOnStartOfClassStaticBlock&&this.tsIsStartOfStaticBlocks())return;let escapedKeywordLoc=this.state.containsEsc&&!tokenIsIdentifier(this.state.type)?this.state.startLoc:null;if(escapedKeywordLoc&&(this.state.containsEsc=!1),this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return escapedKeywordLoc&&this.raise(Errors.InvalidEscapedReservedWord,escapedKeywordLoc,{reservedWord:modifier}),modifier;escapedKeywordLoc&&(this.state.containsEsc=!0)}}tsParseModifiers(modifiers,errorTemplate=TSErrors.
|
|
1151
|
+
InvalidModifierOnTypeMember,modified,stopOnStartOfClassStaticBlock=!1){let enforceOrder=(loc,modifier,before,after)=>{modifier===before&&modified[after]&&this.raise(TSErrors.InvalidModifiersOrder,loc,{orderedModifiers:[before,after]})},incompatible=(loc,modifier,mod1,mod2)=>{(modified[mod1]&&modifier===mod2||modified[mod2]&&modifier===mod1)&&this.raise(TSErrors.IncompatibleModifiers,loc,{modifiers:[mod1,mod2]})};for(;;){let{startLoc}=this.state,modifier=this.tsParseModifier(modifiers,stopOnStartOfClassStaticBlock,
|
|
1152
|
+
modified.static);if(!modifier)break;tsIsAccessModifier(modifier)?modified.accessibility?this.raise(TSErrors.DuplicateAccessibilityModifier,startLoc,{modifier}):(enforceOrder(startLoc,modifier,modifier,"override"),enforceOrder(startLoc,modifier,modifier,"static"),enforceOrder(startLoc,modifier,modifier,"readonly"),modified.accessibility=modifier):tsIsVarianceAnnotations(modifier)?(modified[modifier]&&this.raise(TSErrors.DuplicateModifier,startLoc,{modifier}),modified[modifier]=!0,enforceOrder(startLoc,
|
|
1153
|
+
modifier,"in","out")):(Object.hasOwn(modified,modifier)?this.raise(TSErrors.DuplicateModifier,startLoc,{modifier}):(enforceOrder(startLoc,modifier,"static","readonly"),enforceOrder(startLoc,modifier,"static","override"),enforceOrder(startLoc,modifier,"override","readonly"),enforceOrder(startLoc,modifier,"abstract","override"),incompatible(startLoc,modifier,"declare","override"),incompatible(startLoc,modifier,"static","abstract")),modified[modifier]=!0),modifiers.get(modifier)||this.raise(errorTemplate,
|
|
1154
|
+
startLoc,{modifier})}}tsIsListTerminator(kind){switch(kind){case"EnumMembers":case"TypeMembers":return this.match(4);case"HeritageClauseElement":return this.match(2);case"TupleElementTypes":return this.match(1);case"TypeParametersOrArguments":return this.match(44)}}tsParseList(kind,parseElement){let result=[];for(;!this.tsIsListTerminator(kind);)result.push(parseElement());return result}tsParseDelimitedList(kind,parseElement,refTrailingCommaPos){return nonNull(this.tsParseDelimitedListWorker(kind,
|
|
1155
|
+
parseElement,!0,refTrailingCommaPos))}tsParseDelimitedListWorker(kind,parseElement,expectSuccess,refTrailingCommaPos){let result=[],trailingCommaPos=-1;for(;!this.tsIsListTerminator(kind);){trailingCommaPos=-1;let element=parseElement();if(element==null)return;if(result.push(element),this.eat(8)){trailingCommaPos=this.state.lastTokStartLoc.index;continue}if(this.tsIsListTerminator(kind))break;expectSuccess&&this.expect(8);return}return refTrailingCommaPos&&(refTrailingCommaPos.value=trailingCommaPos),
|
|
1156
|
+
result}tsParseBracketedList(kind,parseElement,bracket,skipFirstToken,refTrailingCommaPos){skipFirstToken||(bracket?this.expect(0):this.expect(43));let result=this.tsParseDelimitedList(kind,parseElement,refTrailingCommaPos);return bracket?this.expect(1):this.expect(44),result}tsParseImportType(){let node=this.startNode();return this.expect(79),this.expect(6),this.match(131)?node.source=this.parseStringLiteral(this.state.value):(this.raise(TSErrors.UnsupportedImportTypeArgument,this.state.startLoc),
|
|
1157
|
+
node.source=this.tsParseNonConditionalType()),this.eat(8)?node.options=this.tsParseImportTypeOptions():node.options=null,this.expect(7),this.eat(12)&&(node.qualifier=this.tsParseEntityName(3)),this.match(43)&&(node.typeArguments=this.tsParseTypeArguments()),this.finishNode(node,"TSImportType")}tsParseImportTypeOptions(){let node=this.startNode();this.expect(2);let withProperty=this.startNode();return this.isContextual(72)?(withProperty.method=!1,withProperty.key=this.parseIdentifier(!0),withProperty.
|
|
1158
|
+
computed=!1,withProperty.shorthand=!1):this.unexpected(null,72),this.expect(10),withProperty.value=this.tsParseImportTypeWithPropertyValue(),node.properties=[this.finishObjectProperty(withProperty)],this.eat(8),this.expect(4),this.finishNode(node,"ObjectExpression")}tsParseImportTypeWithPropertyValue(){let node=this.startNode(),properties=[];for(this.expect(2);!this.match(4);){let type=this.state.type;tokenIsIdentifier(type)||type===131?properties.push(super.parsePropertyDefinition(null)):this.unexpected(),
|
|
1159
|
+
this.eat(8)}return node.properties=properties,this.next(),this.finishNode(node,"ObjectExpression")}tsParseEntityName(flags){let entity;if(flags&1&&this.match(74))if(flags&2)entity=this.parseIdentifier(!0);else{let node=this.startNode();this.next(),entity=this.finishNode(node,"ThisExpression")}else entity=this.parseIdentifier(!!(flags&1));for(;this.eat(12);){let node=this.startNodeAtNode(entity);node.left=entity,node.right=this.parseIdentifier(!!(flags&1)),entity=this.finishNode(node,"TSQualified\
|
|
1160
|
+
Name")}return entity}tsParseTypeReference(){let node=this.startNode();return node.typeName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(43)&&(node.typeArguments=this.tsParseTypeArguments()),this.finishNode(node,"TSTypeReference")}tsParseThisTypePredicate(lhs){this.next();let node=this.startNodeAtNode(lhs);return node.parameterName=lhs,node.typeAnnotation=this.tsParseTypeAnnotation(!1),node.asserts=!1,this.finishNode(node,"TSTypePredicate")}tsParseThisTypeNode(){let node=this.
|
|
1161
|
+
startNode();return this.next(),this.finishNode(node,"TSThisType")}tsParseTypeQuery(){let node=this.startNode();return this.expect(83),this.match(79)?node.exprName=this.tsParseImportType():node.exprName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(43)&&(node.typeArguments=this.tsParseTypeArguments()),this.finishNode(node,"TSTypeQuery")}tsParseInOutModifiers=this.tsParseModifiers.bind(this,buildModifiersMap(["in","out"],["const","public","private","protected","readonly","dec\
|
|
1162
|
+
lare","abstract","override"]),TSErrors.InvalidModifierOnTypeParameter);tsParseConstModifier=this.tsParseModifiers.bind(this,buildModifiersMap(["const"],["in","out"]),TSErrors.InvalidModifierOnTypeParameterPositions);tsParseInOutConstModifiers=this.tsParseModifiers.bind(this,buildModifiersMap(["in","out","const"],["public","private","protected","readonly","declare","abstract","override"]),TSErrors.InvalidModifierOnTypeParameter);tsParseTypeParameter(parseModifiers){let node=this.startNode();return parseModifiers(
|
|
1163
|
+
node),node.name=this.tsParseTypeParameterName(),node.constraint=this.tsEatThenParseType(77),node.default=this.tsEatThenParseType(25),this.finishNode(node,"TSTypeParameter")}tsTryParseTypeParameters(parseModifiers){if(this.match(43))return this.tsParseTypeParameters(parseModifiers)}tsParseTypeParameters(parseModifiers){let node=this.startNode();this.match(43)||this.match(139)?this.next():this.unexpected();let refTrailingCommaPos={value:-1};return node.params=this.tsParseBracketedList("TypeParamet\
|
|
1164
|
+
ersOrArguments",this.tsParseTypeParameter.bind(this,parseModifiers),!1,!0,refTrailingCommaPos),node.params.length===0&&this.raise(TSErrors.EmptyTypeParameters,node),refTrailingCommaPos.value!==-1&&this.addExtra(node,"trailingComma",refTrailingCommaPos.value),this.finishNode(node,"TSTypeParameterDeclaration")}tsFillSignature(returnToken,signature){let returnTokenRequired=returnToken===15,paramsKey="params",returnTypeKey="returnType";signature.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),
|
|
1165
|
+
this.expect(6),signature[paramsKey]=this.tsParseBindingListForSignature(),returnTokenRequired?signature[returnTypeKey]=this.tsParseTypeOrTypePredicateAnnotation(returnToken):this.match(returnToken)&&(signature[returnTypeKey]=this.tsParseTypeOrTypePredicateAnnotation(returnToken))}tsParseBindingListForSignature(){let list3=super.parseBindingList(7,41,2);for(let pattern of list3){let{type}=pattern;(type==="AssignmentPattern"||type==="TSParameterProperty")&&this.raise(TSErrors.UnsupportedSignatureParameterKind,
|
|
1166
|
+
pattern,{type})}return list3}tsParseTypeMemberSemicolon(){!this.eat(8)&&!this.isLineTerminator()&&this.expect(9)}tsParseSignatureMember(kind,node){return this.tsFillSignature(10,node),this.tsParseTypeMemberSemicolon(),this.finishNode(node,kind)}tsIsUnambiguouslyIndexSignature(){return this.next(),tokenIsIdentifier(this.state.type)?(this.next(),this.match(10)):!1}tsTryParseIndexSignature(node){if(!(this.match(0)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))))return;this.expect(
|
|
1167
|
+
0);let id2=this.parseIdentifier();id2.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(id2),this.expect(1),node.parameters=[id2];let type=this.tsTryParseTypeAnnotation();return type&&(node.typeAnnotation=type),this.tsParseTypeMemberSemicolon(),this.finishNode(node,"TSIndexSignature")}tsParsePropertyOrMethodSignature(node,readonly){if(this.eat(13)&&(node.optional=!0),this.match(6)||this.match(43)){readonly&&this.raise(TSErrors.ReadonlyForMethodSignature,node);let method=node;if(method.
|
|
1168
|
+
kind&&this.match(43)&&this.raise(TSErrors.AccessorCannotHaveTypeParameters,this.state.curPosition()),this.tsFillSignature(10,method),this.tsParseTypeMemberSemicolon(),method.kind==="get")method.params.length>0&&(this.raise(Errors.BadGetterArity,this.state.curPosition()),this.isThisParam(method.params[0])&&this.raise(TSErrors.AccessorCannotDeclareThisParameter,this.state.curPosition()));else if(method.kind==="set"){if(method.params.length!==1)this.raise(Errors.BadSetterArity,this.state.curPosition());else{
|
|
1169
|
+
let firstParameter=method.params[0];this.isThisParam(firstParameter)&&this.raise(TSErrors.AccessorCannotDeclareThisParameter,this.state.curPosition()),firstParameter.type==="Identifier"&&firstParameter.optional&&this.raise(TSErrors.SetAccessorCannotHaveOptionalParameter,this.state.curPosition()),firstParameter.type==="RestElement"&&this.raise(TSErrors.SetAccessorCannotHaveRestParameter,this.state.curPosition())}method.returnType&&this.raise(TSErrors.SetAccessorCannotHaveReturnType,method.returnType)}else
|
|
1170
|
+
method.kind="method";return this.finishNode(method,"TSMethodSignature")}else{let property=node;readonly&&(property.readonly=!0);let type=this.tsTryParseTypeAnnotation();return type&&(property.typeAnnotation=type),this.tsParseTypeMemberSemicolon(),this.finishNode(property,"TSPropertySignature")}}tsParseTypeMember(){let node=this.startNode();if(this.match(6)||this.match(43))return this.tsParseSignatureMember("TSCallSignatureDeclaration",node);if(this.match(73)){let id2=this.startNode();return this.
|
|
1171
|
+
next(),this.match(6)||this.match(43)?this.tsParseSignatureMember("TSConstructSignatureDeclaration",node):(node.key=this.createIdentifier(id2,"new"),this.tsParsePropertyOrMethodSignature(node,!1))}this.tsParseModifiers(IndexSignatureModifiers,void 0,node);let idx=this.tsTryParseIndexSignature(node);return idx||(super.parsePropertyName(node),!node.computed&&node.key.type==="Identifier"&&(node.key.name==="get"||node.key.name==="set")&&this.tsTokenCanFollowModifier()&&(node.kind=node.key.name,super.
|
|
1172
|
+
parsePropertyName(node),!this.match(6)&&!this.match(43)&&this.unexpected(null,6)),this.tsParsePropertyOrMethodSignature(node,!!node.readonly))}tsParseTypeLiteral(){let node=this.startNode();return node.members=this.tsParseObjectTypeMembers(),this.finishNode(node,"TSTypeLiteral")}tsParseObjectTypeMembers(){this.expect(2);let members=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(4),members}tsIsStartOfMappedType(){return this.next(),this.eat(49)?this.isContextual(
|
|
1173
|
+
119):(this.isContextual(119)&&this.next(),!this.match(0)||(this.next(),!this.tsIsIdentifier())?!1:(this.next(),this.match(54)))}tsParseMappedType(){let node=this.startNode();return this.expect(2),this.match(49)?(node.readonly=this.state.value,this.next(),this.expectContextual(119)):this.eatContextual(119)&&(node.readonly=!0),this.expect(0),node.key=this.tsParseTypeParameterName(),node.constraint=this.tsExpectThenParseType(54),node.nameType=this.eatContextual(90)?this.tsParseType():null,this.expect(
|
|
1174
|
+
1),this.match(49)?(node.optional=this.state.value,this.next(),this.expect(13)):this.eat(13)&&(node.optional=!0),node.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(4),this.finishNode(node,"TSMappedType")}tsParseTupleType(){let node=this.startNode();node.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);let seenOptionalElement=!1;return node.elementTypes.forEach(elementNode=>{let{type}=elementNode;seenOptionalElement&&type!==
|
|
1175
|
+
"TSRestType"&&type!=="TSOptionalType"&&!(type==="TSNamedTupleMember"&&elementNode.optional)&&this.raise(TSErrors.OptionalTypeBeforeRequired,elementNode),seenOptionalElement||=type==="TSNamedTupleMember"&&elementNode.optional||type==="TSOptionalType"}),this.finishNode(node,"TSTupleType")}tsParseTupleElementType(){let restStartLoc=this.state.startLoc,rest=this.eat(17),{startLoc}=this.state,labeled,label3,optional,type,chAfterWord=tokenIsKeywordOrIdentifier(this.state.type)?this.lookaheadCharCode():
|
|
1176
|
+
null;if(chAfterWord===58)labeled=!0,optional=!1,label3=this.parseIdentifier(!0),this.expect(10),type=this.tsParseType();else if(chAfterWord===63){optional=!0;let wordName=this.state.value,typeOrLabel=this.tsParseNonArrayType();this.lookaheadCharCode()===58?(labeled=!0,label3=this.createIdentifier(this.startNodeAt(startLoc),wordName),this.expect(13),this.expect(10),type=this.tsParseType()):(labeled=!1,type=typeOrLabel,this.expect(13))}else type=this.tsParseType(),optional=this.eat(13),labeled=this.
|
|
1177
|
+
eat(10);if(labeled){let labeledNode;label3?(labeledNode=this.startNodeAt(startLoc),labeledNode.optional=optional,labeledNode.label=label3,labeledNode.elementType=type,this.eat(13)&&(labeledNode.optional=!0,this.raise(TSErrors.TupleOptionalAfterType,this.state.lastTokStartLoc))):(labeledNode=this.startNodeAt(startLoc),labeledNode.optional=optional,this.raise(TSErrors.InvalidTupleMemberLabel,type),labeledNode.label=type,labeledNode.elementType=this.tsParseType()),type=this.finishNode(labeledNode,"\
|
|
1178
|
+
TSNamedTupleMember")}else if(optional){let optionalTypeNode=this.startNodeAt(startLoc);optionalTypeNode.typeAnnotation=type,type=this.finishNode(optionalTypeNode,"TSOptionalType")}if(rest){let restNode=this.startNodeAt(restStartLoc);restNode.typeAnnotation=type,type=this.finishNode(restNode,"TSRestType")}return type}tsParseParenthesizedType(){let node=this.startNode();return this.expect(6),node.typeAnnotation=this.tsParseType(),this.expect(7),this.finishNode(node,"TSParenthesizedType")}tsParseFunctionOrConstructorType(type,abstract){
|
|
1179
|
+
let node=this.startNode();return type==="TSConstructorType"&&(node.abstract=!!abstract,abstract&&this.next(),this.next()),this.tsInAllowConditionalTypesContext(()=>this.tsFillSignature(15,node)),this.finishNode(node,type)}tsParseLiteralTypeNode(){let node=this.startNode();switch(this.state.type){case 132:case 133:case 131:case 81:case 82:node.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode(node,"TSLiteralType")}tsParseTemplateLiteralType(){let startLoc=this.state.
|
|
1180
|
+
startLoc,curElt=this.parseTemplateElement(!1),quasis=[curElt];if(curElt.tail){let node=this.startNodeAt(startLoc),literal=this.startNodeAt(startLoc);return literal.expressions=[],literal.quasis=quasis,node.literal=this.finishNode(literal,"TemplateLiteral"),this.finishNode(node,"TSLiteralType")}else{let substitutions=[];for(;!curElt.tail;)substitutions.push(this.tsParseType()),this.readTemplateContinuation(),quasis.push(curElt=this.parseTemplateElement(!1));let node=this.startNodeAt(startLoc);return node.
|
|
1181
|
+
types=substitutions,node.quasis=quasis,this.finishNode(node,"TSTemplateLiteralType")}}parseTemplateSubstitution(){return this.state.inType?this.tsParseType():super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){let thisKeyword=this.tsParseThisTypeNode();return this.isContextual(113)&&!this.hasPrecedingLineBreak()?this.tsParseThisTypePredicate(thisKeyword):thisKeyword}tsParseNonArrayType(){switch(this.state.type){case 131:case 132:case 133:case 81:case 82:return this.tsParseLiteralTypeNode();case 49:
|
|
1182
|
+
if(this.state.value==="-"){let node=this.startNode(),nextToken=this.lookahead();return nextToken.type!==132&&nextToken.type!==133&&this.unexpected(),node.literal=this.parseMaybeUnary(),this.finishNode(node,"TSLiteralType")}break;case 74:return this.tsParseThisTypeOrThisTypePredicate();case 83:return this.tsParseTypeQuery();case 79:return this.tsParseImportType();case 2:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.
|
|
1183
|
+
tsParseTupleType();case 6:if(!(this.optionFlags&2048)){let startLoc=this.state.startLoc;this.next();let type=this.tsParseType();return this.expect(7),this.addExtra(type,"parenthesized",!0),this.addExtra(type,"parenStart",startLoc.index),type}return this.tsParseParenthesizedType();case 21:case 20:return this.tsParseTemplateLiteralType();default:{let{type}=this.state;if(tokenIsIdentifier(type)||type===84||type===80){let nodeType=type===84?"TSVoidKeyword":type===80?"TSNullKeyword":keywordTypeFromName(
|
|
1184
|
+
this.state.value);if(nodeType!==void 0&&this.lookaheadCharCode()!==46){let node=this.startNode();return this.next(),this.finishNode(node,nodeType)}return this.tsParseTypeReference()}}}throw this.unexpected()}tsParseArrayTypeOrHigher(){let{startLoc}=this.state,type=this.tsParseNonArrayType();for(;!this.hasPrecedingLineBreak()&&this.eat(0);)if(this.match(1)){let node=this.startNodeAt(startLoc);node.elementType=type,this.expect(1),type=this.finishNode(node,"TSArrayType")}else{let node=this.startNodeAt(
|
|
1185
|
+
startLoc);node.objectType=type,node.indexType=this.tsParseType(),this.expect(1),type=this.finishNode(node,"TSIndexedAccessType")}return type}tsParseTypeOperator(){let node=this.startNode(),operator=this.state.value;return this.next(),node.operator=operator,node.typeAnnotation=this.tsParseTypeOperatorOrHigher(),operator==="readonly"&&this.tsCheckTypeAnnotationForReadOnly(node),this.finishNode(node,"TSTypeOperator")}tsCheckTypeAnnotationForReadOnly(node){switch(node.typeAnnotation.type){case"TSTup\
|
|
1186
|
+
leType":case"TSArrayType":return;default:this.raise(TSErrors.UnexpectedReadonly,node)}}tsParseInferType(){let node=this.startNode();this.expectContextual(112);let typeParameter=this.startNode();return typeParameter.name=this.tsParseTypeParameterName(),typeParameter.constraint=this.tsTryParse(()=>this.tsParseConstraintForInferType()),node.typeParameter=this.finishNode(typeParameter,"TSTypeParameter"),this.finishNode(node,"TSInferType")}tsParseConstraintForInferType(){if(this.eat(77)){let constraint=this.
|
|
1187
|
+
tsInDisallowConditionalTypesContext(()=>this.tsParseType());if(this.state.inDisallowConditionalTypesContext||!this.match(13))return constraint}}tsParseTypeOperatorOrHigher(){return tokenIsTSTypeOperator(this.state.type)&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(112)?this.tsParseInferType():this.tsInAllowConditionalTypesContext(()=>this.tsParseArrayTypeOrHigher())}tsParseUnionOrIntersectionType(kind,parseConstituentType,operator){let node=this.startNode(),hasLeadingOperator=this.
|
|
1188
|
+
eat(operator),types2=[];do types2.push(parseConstituentType());while(this.eat(operator));return types2.length===1&&!hasLeadingOperator?types2[0]:(node.types=types2,this.finishNode(node,kind))}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),41)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),39)}tsIsStartOfFunctionType(){
|
|
1189
|
+
return this.match(43)?!0:this.match(6)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(tokenIsIdentifier(this.state.type)||this.match(74))return this.next(),!0;if(this.match(2)){let{errors}=this.state,previousErrorCount=errors.length;try{return this.parseObjectLike(4,!0),errors.length===previousErrorCount}catch{return!1}}if(this.match(0)){this.next();let{errors}=this.state,previousErrorCount=errors.length;try{return super.parseBindingList(1,93,1),
|
|
1190
|
+
errors.length===previousErrorCount}catch{return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){return this.next(),!!(this.match(7)||this.match(17)||this.tsSkipParameterStart()&&(this.match(10)||this.match(8)||this.match(13)||this.match(25)||this.match(7)&&(this.next(),this.match(15))))}tsParseTypeOrTypePredicateAnnotation(returnToken){return this.tsInType(()=>{let t=this.startNode();this.expect(returnToken);let node=this.startNode(),asserts=!!this.tsTryParse(this.tsParseTypePredicateAsserts.
|
|
1191
|
+
bind(this));if(asserts&&this.match(74)){let thisTypePredicate=this.tsParseThisTypeOrThisTypePredicate();return thisTypePredicate.type==="TSThisType"?(node.parameterName=thisTypePredicate,node.asserts=!0,node.typeAnnotation=null,thisTypePredicate=this.finishNode(node,"TSTypePredicate")):(this.resetStartLocationFromNode(thisTypePredicate,node),thisTypePredicate.asserts=!0),t.typeAnnotation=thisTypePredicate,this.finishNode(t,"TSTypeAnnotation")}let typePredicateVariable=this.tsIsIdentifier()&&this.
|
|
1192
|
+
tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!typePredicateVariable)return asserts?(node.parameterName=this.parseIdentifier(),node.asserts=asserts,node.typeAnnotation=null,t.typeAnnotation=this.finishNode(node,"TSTypePredicate"),this.finishNode(t,"TSTypeAnnotation")):this.tsParseTypeAnnotation(!1,t);let type=this.tsParseTypeAnnotation(!1);return node.parameterName=typePredicateVariable,node.typeAnnotation=type,node.asserts=asserts,t.typeAnnotation=this.finishNode(node,"TSTypePredica\
|
|
1193
|
+
te"),this.finishNode(t,"TSTypeAnnotation")})}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(10))return this.tsParseTypeOrTypePredicateAnnotation(10)}tsTryParseTypeAnnotation(){if(this.match(10))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(10)}tsParseTypePredicatePrefix(){let id2=this.parseIdentifier();if(this.isContextual(113)&&!this.hasPrecedingLineBreak())return this.next(),id2}tsParseTypePredicateAsserts(){if(this.state.type!==106)return!1;let containsEsc=this.
|
|
1194
|
+
state.containsEsc;return this.next(),!tokenIsIdentifier(this.state.type)&&!this.match(74)?!1:(containsEsc&&this.raise(Errors.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:"asserts"}),!0)}tsParseTypeAnnotation(eatColon=!0,t=this.startNode()){return this.tsInType(()=>{eatColon&&this.expect(10),t.typeAnnotation=this.tsParseType()}),this.finishNode(t,"TSTypeAnnotation")}tsParseType(){assert(this.state.inType);let type=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||
|
|
1195
|
+
this.hasPrecedingLineBreak()||!this.eat(77))return type;let node=this.startNodeAtNode(type);return node.checkType=type,node.extendsType=this.tsInDisallowConditionalTypesContext(()=>this.tsParseNonConditionalType()),this.expect(13),node.trueType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.expect(10),node.falseType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.finishNode(node,"TSConditionalType")}isAbstractConstructorSignature(){return this.isContextual(
|
|
1196
|
+
121)&&this.isLookaheadContextual("new")}tsParseNonConditionalType(){return this.tsIsStartOfFunctionType()?this.tsParseFunctionOrConstructorType("TSFunctionType"):this.match(73)?this.tsParseFunctionOrConstructorType("TSConstructorType"):this.isAbstractConstructorSignature()?this.tsParseFunctionOrConstructorType("TSConstructorType",!0):this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){this.getPluginOption("typescript","disallowAmbiguousJSXLike")&&this.raise(TSErrors.ReservedTypeAssertion,this.
|
|
1197
|
+
state.startLoc);let node=this.startNode();return node.typeAnnotation=this.tsInType(()=>(this.next(),this.match(71)?this.tsParseTypeReference():this.tsParseType())),this.expect(44),this.state.canStartArrow=!1,node.expression=this.parseMaybeUnary(),this.finishNode(node,"TSTypeAssertion")}tsParseHeritageClause(token){let originalStartLoc=this.state.startLoc,delimitedList=this.tsParseDelimitedList("HeritageClauseElement",()=>{let expression=(this.state.canStartArrow=!1,super.parseExprSubscripts());tsIsEntityName(
|
|
1198
|
+
expression)||this.raise(TSErrors.InvalidHeritageClauseType,expression.start,{token});let nodeType=token==="extends"?"TSInterfaceHeritage":"TSClassImplements";if(expression.type==="TSInstantiationExpression")return expression.type=nodeType,expression;let node=this.startNodeAtNode(expression);return node.expression=expression,(this.match(43)||this.match(47))&&(node.typeArguments=this.tsParseTypeArgumentsInExpression()),this.finishNode(node,nodeType)});return delimitedList.length||this.raise(TSErrors.
|
|
1199
|
+
EmptyHeritageClauseType,originalStartLoc,{token}),delimitedList}tsParseInterfaceDeclaration(node,properties={}){if(this.hasFollowingLineBreak())return null;this.expectContextual(126),properties.declare&&(node.declare=!0),tokenIsIdentifier(this.state.type)?(node.id=this.parseIdentifier(),this.checkIdentifier(node.id,130)):(node.id=null,this.raise(TSErrors.MissingInterfaceName,this.state.startLoc)),node.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(77)&&(node.
|
|
1200
|
+
extends=this.tsParseHeritageClause("extends"));let body=this.startNode();return body.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),node.body=this.finishNode(body,"TSInterfaceBody"),this.finishNode(node,"TSInterfaceDeclaration")}tsParseTypeAliasDeclaration(node){return node.id=this.parseIdentifier(),this.checkIdentifier(node.id,2),node.typeAnnotation=this.tsInType(()=>{if(node.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(25),this.isContextual(
|
|
1201
|
+
111)&&this.lookaheadCharCode()!==46){let node2=this.startNode();return this.next(),this.finishNode(node2,"TSIntrinsicKeyword")}return this.tsParseType()}),this.semicolon(),this.finishNode(node,"TSTypeAliasDeclaration")}tsInTopLevelContext(cb){if(this.curContext()!==types.brace){let oldContext=this.state.context;this.state.context=[oldContext[0]];try{return cb()}finally{this.state.context=oldContext}}else return cb()}tsInType(cb){let oldInType=this.state.inType;this.state.inType=!0;try{return cb()}finally{
|
|
1202
|
+
this.state.inType=oldInType}}tsInDisallowConditionalTypesContext(cb){let oldInDisallowConditionalTypesContext=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return cb()}finally{this.state.inDisallowConditionalTypesContext=oldInDisallowConditionalTypesContext}}tsInAllowConditionalTypesContext(cb){let oldInDisallowConditionalTypesContext=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return cb()}finally{
|
|
1203
|
+
this.state.inDisallowConditionalTypesContext=oldInDisallowConditionalTypesContext}}tsEatThenParseType(token){if(this.match(token))return this.tsNextThenParseType()}tsExpectThenParseType(token){return this.tsInType(()=>(this.expect(token),this.tsParseType()))}tsNextThenParseType(){return this.tsInType(()=>(this.next(),this.tsParseType()))}tsParseEnumMember(){let node=this.startNode();return node.id=this.match(131)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(25)&&(node.
|
|
1204
|
+
initializer=super.parseMaybeAssignAllowIn()),this.finishNode(node,"TSEnumMember")}tsParseEnumDeclaration(node,properties={}){return properties.const&&(node.const=!0),properties.declare&&(node.declare=!0),this.expectContextual(123),node.id=this.parseIdentifier(),this.checkIdentifier(node.id,node.const?8971:8459),node.body=this.tsParseEnumBody(),this.finishNode(node,"TSEnumDeclaration")}tsParseEnumBody(){let node=this.startNode();return this.expect(2),node.members=this.tsParseDelimitedList("EnumMe\
|
|
1205
|
+
mbers",this.tsParseEnumMember.bind(this)),this.expect(4),this.finishNode(node,"TSEnumBody")}tsParseModuleBlock(isGlobal){let node=this.startNode();return isGlobal||this.scope.enter(0),this.expect(2),super.parseBlockOrModuleBlockBody(node.body=[],void 0,!0,4),isGlobal||this.scope.exit(),this.finishNode(node,"TSModuleBlock")}tsParseNamespaceDeclaration(node){return node.id=this.tsParseEntityName(0),node.id.type==="Identifier"&&this.checkIdentifier(node.id,1024),this.scope.enter(2048),this.prodParam.
|
|
1206
|
+
enter(0),node.body=this.tsParseModuleBlock(!1),this.prodParam.exit(),this.scope.exit(),this.finishNode(node,"TSModuleDeclaration")}tsParseAmbientExternalModuleDeclaration(node){let isGlobal=this.isContextual(109);if(isGlobal)node.kind="global",node.id=this.parseIdentifier();else{node.kind="module";let{type,value}=this.state;type===131?node.id=super.parseStringLiteral(value):tokenIsIdentifier(type)?(this.raise(TSErrors.InlineModuleDeclarationMustUseString,this.state.startLoc),node.id=this.tsParseEntityName(
|
|
1207
|
+
0)):type===2?this.raise(TSErrors.EmptyNamespaceName,this.state.startLoc):(this.raise(TSErrors.InvalidNamespaceName,this.state.startLoc,value),node.id=super.parseExprAtom())}return this.match(2)?(isGlobal||this.scope.enter(1024),this.prodParam.enter(0),node.body=this.tsParseModuleBlock(isGlobal),this.prodParam.exit(),isGlobal||this.scope.exit()):this.semicolon(),this.finishNode(node,"TSModuleDeclaration")}tsParseImportEqualsDeclaration(node,maybeDefaultIdentifier){node.id=maybeDefaultIdentifier||
|
|
1208
|
+
this.parseIdentifier(),this.checkIdentifier(node.id,4096),this.expect(25);let moduleReference=this.tsParseModuleReference();return node.importKind==="type"&&moduleReference.type!=="TSExternalModuleReference"&&this.raise(TSErrors.ImportAliasHasImportType,moduleReference),node.moduleReference=moduleReference,this.semicolon(),this.finishNode(node,"TSImportEqualsDeclaration")}tsIsExternalModuleReference(){return this.isContextual(116)&&this.lookaheadCharCode()===40}tsParseModuleReference(){return this.
|
|
1209
|
+
tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(0)}tsParseExternalModuleReference(){let node=this.startNode();return this.expectContextual(116),this.expect(6),this.match(131)||this.unexpected(),node.expression=super.parseExprAtom(),this.expect(7),this.sawUnambiguousESM=!0,this.finishNode(node,"TSExternalModuleReference")}tsLookAhead(f){let state=this.state.clone(),res=f();return this.state=state,res}tsTryParseAndCatch(f){let result=this.tryParse(abort=>f()||
|
|
1210
|
+
abort());if(!(result.aborted||!result.node))return result.error&&(this.state=result.failState),result.node}tsTryParse(f){let state=this.state.clone(),result=f();if(result!==void 0&&result!==!1)return result;this.state=state}tsTryParseDeclare(node){if(this.isLineTerminator())return;let startType=this.state.type;return this.tsInAmbientContext(()=>{switch(startType){case 64:return node.declare=!0,super.parseFunctionStatement(node,!1,2);case 76:return node.declare=!0,this.parseClass(node,!0,!1);case 123:
|
|
1211
|
+
return this.tsParseEnumDeclaration(node,{declare:!0});case 109:return this.tsParseAmbientExternalModuleDeclaration(node);case 97:if(this.state.containsEsc)return;case 71:case 70:return!this.match(71)||!this.isLookaheadContextual("enum")?(node.declare=!0,this.parseVarStatement(node,this.state.value,!0)):(this.expect(71),this.tsParseEnumDeclaration(node,{const:!0,declare:!0}));case 104:if(this.isUsing())return this.raise(TSErrors.InvalidModifierOnUsingDeclaration,this.state.startLoc,"declare"),node.
|
|
1212
|
+
declare=!0,this.parseVarStatement(node,"using",!0);break;case 93:if(this.isAwaitUsing())return this.raise(TSErrors.InvalidModifierOnAwaitUsingDeclaration,this.state.startLoc,"declare"),node.declare=!0,this.next(),this.parseVarStatement(node,"await using",!0);break;case 126:{let result=this.tsParseInterfaceDeclaration(node,{declare:!0});if(result)return result}default:if(tokenIsIdentifier(startType))return this.tsParseDeclaration(node,this.state.type,!0,null)}})}tsTryParseExportDeclaration(){return this.
|
|
1213
|
+
tsParseDeclaration(this.startNode(),this.state.type,!0,null)}tsParseDeclaration(node,type,next,decorators){switch(type){case 121:if(this.tsCheckLineTerminator(next)&&(this.match(76)||tokenIsIdentifier(this.state.type)))return this.tsParseAbstractDeclaration(node,decorators);break;case 124:if(this.tsCheckLineTerminator(next))return this.tsParseAmbientExternalModuleDeclaration(node);break;case 125:if(this.tsCheckLineTerminator(next)&&tokenIsIdentifier(this.state.type))return node.kind="namespace",
|
|
1214
|
+
this.tsParseNamespaceDeclaration(node);break;case 127:if(this.tsCheckLineTerminator(next)&&tokenIsIdentifier(this.state.type))return this.tsParseTypeAliasDeclaration(node);break}}tsCheckLineTerminator(next){return next?this.hasFollowingLineBreak()?!1:(this.next(),!0):!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction(startLoc){if(!this.match(43))return;let res=this.tsTryParseAndCatch(()=>{let node=this.startNodeAt(startLoc);return node.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),
|
|
1215
|
+
super.parseFunctionParams(node),node.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(15),node});if(res)return super.parseArrowExpression(res,null,!0)}tsParseTypeArgumentsInExpression(){if(this.reScan_lt()===43)return this.tsParseTypeArguments()}tsParseTypeArguments(){let node=this.startNode();return node.params=this.tsInType(()=>this.tsInTopLevelContext(()=>(this.expect(43),this.tsParseDelimitedList("TypeParametersOrArguments",this.tsParseType.bind(this))))),node.params.length===
|
|
1216
|
+
0?this.raise(TSErrors.EmptyTypeArguments,node):!this.state.inType&&this.curContext()===types.brace&&this.reScan_lt_gt(),this.expect(44),this.finishNode(node,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return tokenIsTSDeclarationStart(this.state.type)}isExportDefaultSpecifier(){return this.tsIsDeclarationStart()?!1:super.isExportDefaultSpecifier()}parseBindingElement(flags,decorators){let startLoc=decorators.length?null:this.state.startLoc,modified={};this.tsParseModifiers(BindingElementModifiers,
|
|
1217
|
+
void 0,modified);let accessibility=modified.accessibility,override=modified.override,readonly=modified.readonly;!(flags&4)&&(accessibility||readonly||override)&&this.raise(TSErrors.UnexpectedParameterModifier,startLoc||decorators[0]);let startLoc2=this.state.startLoc,left=this.parseMaybeDefault(startLoc2);flags&2&&this.parseFunctionParamType(left);let elt=this.parseMaybeDefault(startLoc2,left);if(accessibility||readonly||override){let pp=startLoc?this.startNodeAt(startLoc):this.startNodeAtNode(decorators[0]);
|
|
1218
|
+
return decorators.length?pp.decorators=decorators:this.setLoc(startLoc),accessibility&&(pp.accessibility=accessibility),readonly&&(pp.readonly=readonly),override&&(pp.override=override),elt.type!=="Identifier"&&elt.type!=="AssignmentPattern"&&this.raise(TSErrors.UnsupportedParameterPropertyKind,startLoc||decorators[0]),pp.parameter=elt,this.finishNode(pp,"TSParameterProperty")}return decorators.length&&(left.decorators=decorators),elt}isSimpleParameter(node){return node.type==="TSParameterProper\
|
|
1219
|
+
ty"&&super.isSimpleParameter(node.parameter)||super.isSimpleParameter(node)}tsDisallowOptionalPattern(node){for(let param of node.params)param.type!=="Identifier"&¶m.optional&&!this.state.isAmbientContext&&this.raise(TSErrors.PatternIsOptional,param)}setArrowFunctionParameters(node,params,trailingCommaLoc){super.setArrowFunctionParameters(node,params,trailingCommaLoc),this.tsDisallowOptionalPattern(node)}parseFunctionBodyAndFinish(node,type,isMethod=!1){this.match(10)&&(node.returnType=this.
|
|
1220
|
+
tsParseTypeOrTypePredicateAnnotation(10));let bodilessType=type==="FunctionDeclaration"?"TSDeclareFunction":type==="ClassMethod"||type==="ClassPrivateMethod"?"TSDeclareMethod":void 0;if(bodilessType&&!this.match(2)&&this.isLineTerminator()){if(bodilessType==="TSDeclareMethod"&&node.kind==="constructor")for(let param of node.params)param.type==="TSParameterProperty"?this.raise(TSErrors.UnexpectedParameterModifier,param):param.type==="AssignmentPattern"&&this.raise(TSErrors.UnexpectedParameterInitializer,
|
|
1221
|
+
param);else for(let param of node.params)param.type==="AssignmentPattern"&&this.raise(TSErrors.UnexpectedParameterInitializer,param);return this.finishNode(node,bodilessType)}return bodilessType&&this.state.isAmbientContext&&(this.raise(TSErrors.DeclareFunctionHasImplementation,this.state.startLoc),bodilessType==="TSDeclareFunction"&&node.declare)?super.parseFunctionBodyAndFinish(node,bodilessType,isMethod):(this.tsDisallowOptionalPattern(node),super.parseFunctionBodyAndFinish(node,type,isMethod))}registerFunctionStatementId(node){
|
|
1222
|
+
!node.body&&node.id?this.checkIdentifier(node.id,1024):super.registerFunctionStatementId(node)}tsCheckForInvalidTypeCasts(items){items.forEach(node=>{node?.type==="TSTypeCastExpression"&&this.raise(TSErrors.UnexpectedTypeAnnotation,node.typeAnnotation)})}toReferencedList(exprList,isInParens){return this.tsCheckForInvalidTypeCasts(exprList),exprList}parseArrayLike(close,refExpressionErrors){let node=super.parseArrayLike(close,refExpressionErrors);return node.type==="ArrayExpression"&&this.tsCheckForInvalidTypeCasts(
|
|
1223
|
+
node.elements),node}parseSubscript(base,startLoc,noCalls,state){if(!this.hasPrecedingLineBreak()&&this.match(31)){this.state.canStartJSXElement=!1,this.next();let nonNullExpression=this.startNodeAt(startLoc);return nonNullExpression.expression=base,this.finishNode(nonNullExpression,"TSNonNullExpression")}let isOptionalCall=!1;if(this.match(14)&&this.lookaheadCharCode()===60){if(noCalls)return state.stop=!0,base;state.optionalChainMember=isOptionalCall=!0,this.next()}if(this.match(43)||this.match(
|
|
1224
|
+
47)){let missingParenErrorLoc,result=this.tsTryParseAndCatch(()=>{if(!noCalls&&this.atPossibleAsyncArrow(base)){let asyncArrowFn=this.tsTryParseGenericAsyncArrowFunction(startLoc);if(asyncArrowFn)return state.stop=!0,asyncArrowFn}let typeArguments=this.tsParseTypeArgumentsInExpression();if(!typeArguments)return;if(isOptionalCall&&!this.match(6)){missingParenErrorLoc=this.state.curPosition();return}if(tokenIsTemplate(this.state.type)){let result2=super.parseTaggedTemplateExpression(base,startLoc,
|
|
1225
|
+
state);return result2.typeArguments=typeArguments,result2}if(!noCalls&&this.eat(6)){let node2=this.startNodeAt(startLoc);return node2.callee=base,node2.arguments=this.parseCallExpressionArguments(),this.tsCheckForInvalidTypeCasts(node2.arguments),node2.typeArguments=typeArguments,state.optionalChainMember&&(node2.optional=isOptionalCall),this.finishCallExpression(node2,state.optionalChainMember)}let tokenType=this.state.type;if(tokenType===44||tokenType===48||tokenType!==6&&tokenType!==90&&tokenType!==
|
|
1226
|
+
117&&tokenCanStartExpression(tokenType)&&!this.hasPrecedingLineBreak())return;let node=this.startNodeAt(startLoc);return node.expression=base,node.typeArguments=typeArguments,this.finishNode(node,"TSInstantiationExpression")});if(missingParenErrorLoc&&this.unexpected(missingParenErrorLoc,6),result)return result.type==="TSInstantiationExpression"&&((this.match(12)||this.match(14)&&this.lookaheadCharCode()!==40)&&this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc),
|
|
1227
|
+
!this.match(12)&&!this.match(14)&&(result.expression=super.stopParseSubscript(base,state))),result}return super.parseSubscript(base,startLoc,noCalls,state)}parseNewCallee(node){super.parseNewCallee(node);let{callee}=node;callee.type==="TSInstantiationExpression"&&!callee.extra?.parenthesized&&(node.typeArguments=callee.typeArguments,node.callee=callee.expression)}parseExprOp(left,leftStartLoc,minPrec){let isSatisfies;if(tokenOperatorPrecedence(54)>minPrec&&!this.hasPrecedingLineBreak()&&(this.isContextual(
|
|
1228
|
+
90)||(isSatisfies=this.isContextual(117)))){let node=this.startNodeAt(leftStartLoc);node.expression=left,node.typeAnnotation=this.tsInType(()=>(this.next(),this.match(71)?(isSatisfies&&this.raise(Errors.UnexpectedKeyword,this.state.startLoc,{keyword:"const"}),this.tsParseTypeReference()):this.tsParseType()));let result=this.finishNode(node,isSatisfies?"TSSatisfiesExpression":"TSAsExpression");return this.reScan_lt_gt(),this.parseExprOp(result,leftStartLoc,minPrec)}return super.parseExprOp(left,leftStartLoc,
|
|
1229
|
+
minPrec)}checkReservedWord(word,startLoc,checkKeywords,isBinding){this.state.isAmbientContext||super.checkReservedWord(word,startLoc,checkKeywords,isBinding)}checkDuplicateExports(){}isPotentialImportPhase(isExport){if(super.isPotentialImportPhase(isExport))return!0;if(this.isContextual(127)){let ch=this.lookaheadCharCode();return isExport?ch===123||ch===42:ch!==61}return!isExport&&this.isContextual(83)}applyImportPhase(node,isExport,phase,loc){super.applyImportPhase(node,isExport,phase,loc),isExport?
|
|
1230
|
+
node.exportKind=phase==="type"?"type":"value":node.importKind=phase==="type"||phase==="typeof"?phase:"value"}parseImport(node){if(this.match(131))return node.importKind="value",this.scope.inTSNamespace&&this.raise(TSErrors.ImportInTSNamespace,node),super.parseImport(node);let importNode;if(tokenIsIdentifier(this.state.type)&&this.lookaheadCharCode()===61){node.importKind="value";let result=this.tsParseImportEqualsDeclaration(node);return this.scope.inTSNamespace&&result.moduleReference.type==="T\
|
|
1231
|
+
SExternalModuleReference"&&this.raise(TSErrors.ImportInTSNamespace,node),result}else if(this.isContextual(127)){let maybeDefaultIdentifier=this.parseMaybeImportPhase(node,!1);if(this.lookaheadCharCode()===61)return this.scope.inTSNamespace&&this.raise(TSErrors.ImportInTSNamespace,node),this.tsParseImportEqualsDeclaration(node,maybeDefaultIdentifier);importNode=super.parseImportSpecifiersAndAfter(node,maybeDefaultIdentifier)}else importNode=super.parseImport(node);return importNode.importKind==="\
|
|
1232
|
+
type"&&importNode.specifiers.length>1&&importNode.specifiers[0].type==="ImportDefaultSpecifier"?this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed,importNode):this.scope.inTSNamespace&&this.raise(TSErrors.ImportInTSNamespace,importNode),importNode}parseExport(node,decorators){if(this.match(79)){let nodeImportEquals=this.startNode();this.next();let maybeDefaultIdentifier=null;this.isContextual(127)&&this.isPotentialImportPhase(!1)?maybeDefaultIdentifier=this.parseMaybeImportPhase(nodeImportEquals,
|
|
1233
|
+
!1):nodeImportEquals.importKind="value";let declaration=this.tsParseImportEqualsDeclaration(nodeImportEquals,maybeDefaultIdentifier);return node.attributes=[],node.declaration=declaration,node.exportKind="value",node.source=null,node.specifiers=[],this.finishNode(node,"ExportNamedDeclaration")}else if(this.eat(25)){let assign=node;return assign.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.scope.inTSNamespace&&this.raise(TSErrors.ExportAssignmentInTSNamespace,
|
|
1234
|
+
assign),this.finishNode(assign,"TSExportAssignment")}else if(this.eatContextual(90)){let decl=node;return this.expectContextual(125),decl.id=this.parseIdentifier(),this.checkIdentifier(decl.id,8201),this.semicolon(),this.scope.inTSNamespace&&this.raise(TSErrors.NamespaceExportInTSNamespace,decl),this.finishNode(decl,"TSNamespaceExportDeclaration")}else{let result=super.parseExport(node,decorators);return this.scope.inTSNamespace&&(result.type!=="ExportNamedDeclaration"||result.source||!result.declaration&&
|
|
1235
|
+
!this.state.isAmbientContext)&&this.raise(TSErrors.ExportInTSNamespace,result),result}}isAbstractClass(){return this.isContextual(121)&&this.isLookaheadContextual("class")}parseExportDefaultExpression(){if(this.isAbstractClass()){let cls=this.startNode();return this.next(),cls.abstract=!0,this.parseClass(cls,!0,!0)}if(this.match(126)){let result=this.tsParseInterfaceDeclaration(this.startNode());if(result)return result}return super.parseExportDefaultExpression()}parseVarStatement(node,kind,allowMissingInitializer=!1){
|
|
1236
|
+
let{isAmbientContext}=this.state,declaration=super.parseVarStatement(node,kind,allowMissingInitializer||isAmbientContext);if(isAmbientContext&&!node.declare&&(kind==="using"||kind==="await using"))return this.raiseOverwrite(TSErrors.UsingDeclarationInAmbientContext,node,kind),declaration;for(let declarator of declaration.declarations){let{id:id2,init,definite}=declarator;definite&&(init?this.raise(TSErrors.DeclaratorDefiniteAssertionWithInitializer,id2):id2.typeAnnotation||this.raise(TSErrors.DeclaratorDefiniteAssertionRequiresTypeAnnotation,
|
|
1237
|
+
id2)),isAmbientContext&&init&&(kind==="var"||kind==="let"||id2.typeAnnotation?this.raise(TSErrors.InitializerNotAllowedInAmbientContext,init):isValidAmbientConstInitializer(init,this.hasPlugin("estree"))||this.raise(TSErrors.ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference,init))}return declaration}parseStatementContent(flags,decorators){let allowDeclaration=!!(flags&2);if(!this.state.containsEsc)switch(this.state.type){case 71:{if(this.isLookaheadContextual("enum")){let node=this.
|
|
1238
|
+
startNode();return this.next(),this.tsParseEnumDeclaration(node,{const:!0})}break}case 121:case 122:{if(this.nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine()){let token=this.state.type,node=this.startNode();this.next();let declaration=token===122?this.tsTryParseDeclare(node):this.tsParseAbstractDeclaration(node,decorators);return declaration?(token===122&&(declaration.declare=!0),declaration):(node.expression=this.createIdentifier(this.startNodeAtNode(node),token===122?"declare":"abst\
|
|
1239
|
+
ract"),this.semicolon(!1),this.finishNode(node,"ExpressionStatement"))}break}case 123:return this.tsParseEnumDeclaration(this.startNode());case 109:{if(this.lookaheadCharCode()===123){let node=this.startNode();return this.tsParseAmbientExternalModuleDeclaration(node)}break}case 126:{let result=this.tsParseInterfaceDeclaration(this.startNode());if(result)return allowDeclaration||this.raise(TSErrors.UnexpectedTypeDeclaration,result,"interface"),result;break}case 124:{if(this.nextTokenIsStringLiteralOnSameLine()){
|
|
1240
|
+
let node=this.startNode();return this.next(),this.tsParseDeclaration(node,124,!1,decorators)}else if(this.nextTokenIsIdentifierOnSameLine()){this.raise(TSErrors.InlineModuleDeclarationMustUseString,this.state.startLoc);let node=this.startNode();return this.next(),this.tsParseDeclaration(node,125,!1,decorators)}break}case 125:{if(this.nextTokenIsIdentifierOnSameLine()){let node=this.startNode();return this.next(),this.tsParseDeclaration(node,125,!1,decorators)}break}case 127:{if(this.nextTokenIsIdentifierOnSameLine()){
|
|
1241
|
+
let node=this.startNode();return allowDeclaration||this.raise(TSErrors.UnexpectedTypeDeclaration,node,"type"),this.next(),this.tsParseTypeAliasDeclaration(node)}break}}return super.parseStatementContent(flags,decorators)}parseAccessModifier(){return this.tsParseModifier(AccessModifiers)}tsHasSomeModifiers(member,modifiers){return modifiers.some(modifier=>tsIsAccessModifier(modifier)?member.accessibility===modifier:!!member[modifier])}tsIsStartOfStaticBlocks(){return this.isContextual(103)&&this.
|
|
1242
|
+
lookaheadCharCode()===123}parseClassMember(classBody,member,state){this.tsParseModifiers(ClassMemberModifiers,TSErrors.InvalidModifierOnTypeParameterPositions,member,!0);let callParseClassMemberWithIsStatic=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(member,["declare","private","public","protected","override","abstract","readonly","static"])&&this.raise(TSErrors.StaticBlockCannotHaveModifier,this.state.curPosition()),super.parseClassStaticBlock(classBody,
|
|
1243
|
+
member)):this.parseClassMemberWithIsStatic(classBody,member,state,!!member.static)};member.declare?this.tsInAmbientContext(callParseClassMemberWithIsStatic):callParseClassMemberWithIsStatic(),member.decorators&&member.decorators.length>0&&!this.hasPlugin("decorators-legacy")&&(member.type==="TSAbstractMethodDefinition"||member.type==="TSDeclareMethod"?this.raise(TSErrors.DecoratorAbstractMethod,member,{kind:"abstract method"}):(member.type==="ClassProperty"&&member.abstract||member.type==="Class\
|
|
1244
|
+
Property"&&member.declare||member.type==="TSAbstractPropertyDefinition"||member.type==="PropertyDefinition"&&member.declare)&&this.raise(TSErrors.DecoratorAbstractMethod,member,{kind:member.declare?"declare field":"abstract field"}))}parseClassMemberWithIsStatic(classBody,member,state,isStatic){let idx=this.tsTryParseIndexSignature(member);if(idx){classBody.body.push(idx),member.abstract&&this.raise(TSErrors.IndexSignatureHasAbstract,member),member.accessibility&&this.raise(TSErrors.IndexSignatureHasAccessibility,
|
|
1245
|
+
member,{modifier:member.accessibility}),member.declare&&this.raise(TSErrors.IndexSignatureHasDeclare,member),member.override&&this.raise(TSErrors.IndexSignatureHasOverride,member);return}!this.state.inAbstractClass&&member.abstract&&this.raise(TSErrors.NonAbstractClassHasAbstractMethod,member),member.override&&(state.hadSuperClass||this.raise(TSErrors.OverrideNotInSubClass,member)),super.parseClassMemberWithIsStatic(classBody,member,state,isStatic)}parsePostMemberNameModifiers(methodOrProp){this.
|
|
1246
|
+
eat(13)&&(methodOrProp.optional=!0),methodOrProp.readonly&&this.match(6)&&this.raise(TSErrors.ClassMethodHasReadonly,methodOrProp),methodOrProp.declare&&this.match(6)&&this.raise(TSErrors.ClassMethodHasDeclare,methodOrProp)}shouldParseExportDeclaration(){return this.tsIsDeclarationStart()?!0:super.shouldParseExportDeclaration()}parseConditional(expr,startLoc,refExpressionErrors){if(!this.match(13))return expr;if(refExpressionErrors!=null){let nextCh=this.lookaheadCharCode();if(nextCh===44||nextCh===
|
|
1247
|
+
61||nextCh===58||nextCh===41)return this.setOptionalParametersError(refExpressionErrors),expr}this.next();let node=this.startNodeAt(startLoc);node.test=expr;let oldInConditionalConsequent=this.state.inConditionalConsequent;return this.state.inConditionalConsequent=!0,node.consequent=this.parseMaybeAssignAllowIn(),this.state.inConditionalConsequent=oldInConditionalConsequent,this.expect(10),node.alternate=this.parseMaybeAssign(),this.finishNode(node,"ConditionalExpression")}parseParenItem(node,startLoc){
|
|
1248
|
+
let newNode=super.parseParenItem(node,startLoc);if(this.eat(13)&&(newNode.optional=!0,this.resetEndLocation(node)),this.match(10)){let typeCastNode=this.startNodeAt(startLoc);return typeCastNode.expression=node,typeCastNode.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(typeCastNode,"TSTypeCastExpression")}return node}parseExportDeclaration(node){if(!this.state.isAmbientContext&&this.isContextual(122))return this.tsInAmbientContext(()=>this.parseExportDeclaration(node));let startLoc=this.
|
|
1249
|
+
state.startLoc,isDeclare=this.eatContextual(122);if(isDeclare&&(this.isContextual(122)||!this.shouldParseExportDeclaration()))throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare,this.state.startLoc);let declaration=tokenIsIdentifier(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration(node);return declaration?((declaration.type==="TSInterfaceDeclaration"||declaration.type==="TSTypeAliasDeclaration"||isDeclare)&&(node.exportKind="type"),isDeclare&&declaration.
|
|
1250
|
+
type!=="TSImportEqualsDeclaration"&&(this.resetStartLocation(declaration,startLoc),declaration.declare=!0),declaration):null}parseClassId(node,isStatement,optionalId,bindingType){if((!isStatement||optionalId)&&this.isContextual(110)){node.id=null;return}super.parseClassId(node,isStatement,optionalId,node.declare?1024:8331);let typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);typeParameters&&(node.typeParameters=typeParameters)}parseClassPropertyAnnotation(node){node.
|
|
1251
|
+
optional||(this.eat(31)?node.definite=!0:this.eat(13)&&(node.optional=!0));let type=this.tsTryParseTypeAnnotation();type&&(node.typeAnnotation=type),node.definite&&(this.match(25)?this.raise(TSErrors.DeclaratorDefiniteAssertionWithInitializer,node):type||this.raise(TSErrors.DeclaratorDefiniteAssertionRequiresTypeAnnotation,node))}parseClassProperty(node){if(this.parseClassPropertyAnnotation(node),this.state.isAmbientContext&&!(node.readonly&&!node.typeAnnotation)&&this.match(25)&&this.raise(TSErrors.
|
|
1252
|
+
DeclareClassFieldHasInitializer,this.state.startLoc),node.abstract&&this.match(25)){let{key}=node;this.raise(TSErrors.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:key.type==="Identifier"&&!node.computed?key.name:`[${this.input.slice(this.offsetToSourcePos(key.start),this.offsetToSourcePos(key.end))}]`})}return super.parseClassProperty(node)}parseClassPrivateProperty(node){return node.abstract&&this.raise(TSErrors.PrivateElementHasAbstract,node),node.accessibility&&this.raise(
|
|
1253
|
+
TSErrors.PrivateElementHasAccessibility,node,{modifier:node.accessibility}),this.parseClassPropertyAnnotation(node),super.parseClassPrivateProperty(node)}parseClassAccessorProperty(node){return this.parseClassPropertyAnnotation(node),node.optional&&this.raise(TSErrors.AccessorCannotBeOptional,node),super.parseClassAccessorProperty(node)}pushClassMethod(classBody,method,isGenerator,isAsync,isConstructor,allowsDirectSuper){let typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier);
|
|
1254
|
+
typeParameters&&isConstructor&&this.raise(TSErrors.ConstructorHasTypeParameters,typeParameters);let{declare=!1,kind}=method;declare&&(kind==="get"||kind==="set")&&this.raise(TSErrors.DeclareAccessor,method,{kind}),typeParameters&&(method.typeParameters=typeParameters),super.pushClassMethod(classBody,method,isGenerator,isAsync,isConstructor,allowsDirectSuper)}pushClassPrivateMethod(classBody,method,isGenerator,isAsync){let typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier);typeParameters&&
|
|
1255
|
+
(method.typeParameters=typeParameters),super.pushClassPrivateMethod(classBody,method,isGenerator,isAsync)}declareClassPrivateMethodInScope(node,kind){node.type!=="TSDeclareMethod"&&(node.type==="MethodDefinition"&&node.value.body==null||super.declareClassPrivateMethodInScope(node,kind))}parseClassSuper(node){if(super.parseClassSuper(node),node.superClass)if(node.superClass.type==="TSInstantiationExpression"){let tsInstantiationExpression=node.superClass,superClass2=tsInstantiationExpression.expression;
|
|
1256
|
+
this.takeSurroundingComments(superClass2,superClass2.start,superClass2.end);let superTypeArguments=tsInstantiationExpression.typeArguments;this.takeSurroundingComments(superTypeArguments,superTypeArguments.start,superTypeArguments.end),node.superClass=superClass2,node.superTypeArguments=superTypeArguments}else(this.match(43)||this.match(47))&&(node.superTypeArguments=this.tsParseTypeArgumentsInExpression());this.eatContextual(110)&&(node.implements=this.tsParseHeritageClause("implements"))}parseObjPropValue(prop,startLoc,isGenerator,isAsync,isPattern,isAccessor,refExpressionErrors){
|
|
1253
1257
|
let typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier);return typeParameters&&(prop.typeParameters=typeParameters),super.parseObjPropValue(prop,startLoc,isGenerator,isAsync,isPattern,isAccessor,refExpressionErrors)}parseFunctionParams(node,isConstructor){let typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier);typeParameters&&(node.typeParameters=typeParameters),super.parseFunctionParams(node,isConstructor)}parseVarId(decl,kind){super.parseVarId(decl,kind),
|
|
1254
|
-
decl.id.type==="Identifier"&&!this.hasPrecedingLineBreak()&&this.eat(31)&&(decl.definite=!0);let type=this.tsTryParseTypeAnnotation();type&&(decl.id.typeAnnotation=type,this.resetEndLocation(decl.id))}parseAsyncArrowFromCallExpression(node,call){return this.match(10)&&(node.returnType=this.tsParseTypeAnnotation()),super.parseAsyncArrowFromCallExpression(node,call)}parseMaybeAssign(refExpressionErrors,isParenItem){let state,jsx2,typeCast;if(this.hasPlugin("jsx")&&(this.match(
|
|
1258
|
+
decl.id.type==="Identifier"&&!this.hasPrecedingLineBreak()&&this.eat(31)&&(decl.definite=!0);let type=this.tsTryParseTypeAnnotation();type&&(decl.id.typeAnnotation=type,this.resetEndLocation(decl.id))}parseAsyncArrowFromCallExpression(node,call){return this.match(10)&&(node.returnType=this.tsParseTypeAnnotation()),super.parseAsyncArrowFromCallExpression(node,call)}parseMaybeAssign(refExpressionErrors,isParenItem){let state,jsx2,typeCast;if(this.hasPlugin("jsx")&&(this.match(139)||this.match(43))){
|
|
1255
1259
|
if(state=this.state.clone(),jsx2=this.tryParse(()=>super.parseMaybeAssign(refExpressionErrors,isParenItem),state),!jsx2.error)return jsx2.node;let{context}=this.state,currentContext=context[context.length-1];(currentContext===types.j_oTag||currentContext===types.j_expr)&&context.pop()}if(!jsx2?.error&&!this.match(43))return super.parseMaybeAssign(refExpressionErrors,isParenItem);(!state||state===this.state)&&(state=this.state.clone());let typeParameters,arrow=this.tryParse(abort=>{typeParameters=
|
|
1256
1260
|
this.tsParseTypeParameters(this.tsParseConstModifier);let expr=super.parseMaybeAssign(refExpressionErrors,isParenItem);if((expr.type!=="ArrowFunctionExpression"||expr.extra?.parenthesized)&&abort(),typeParameters?.params.length!==0&&this.resetStartLocationFromNode(expr,typeParameters),expr.typeParameters=typeParameters,this.hasPlugin("jsx")&&expr.typeParameters.params.length===1&&!expr.typeParameters.extra?.trailingComma){let parameter=expr.typeParameters.params[0];parameter.constraint||this.raise(
|
|
1257
1261
|
TSErrors.SingleTypeParameterWithoutTrailingComma,this.optionFlags&256?createPositionWithColumnOffset(parameter.loc.end,1):parameter,{typeParameterName:parameter.name.name})}return expr},state);if(!arrow.error&&!arrow.aborted)return typeParameters&&this.reportReservedArrowTypeParam(typeParameters),arrow.node;if(!jsx2&&(assert(!this.hasPlugin("jsx")),typeCast=this.tryParse(()=>super.parseMaybeAssign(refExpressionErrors,isParenItem),state),!typeCast.error))return typeCast.node;if(jsx2?.node)return this.
|
|
@@ -1268,14 +1272,14 @@ node.typeAnnotation,this.resetEndLocationFromNode(node.expression,node.typeAnnot
|
|
|
1268
1272
|
parseParenAndDistinguishExpression(canStartArrow);return this.state.inConditionalConsequent=oldInConditionalConsequent,result}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName(node){if(this.match(43)||this.match(47)){let typeArguments=this.tsTryParseAndCatch(()=>this.tsParseTypeArgumentsInExpression());typeArguments&&(node.typeArguments=typeArguments)}return super.jsxParseOpeningElementAfterName(node)}getGetterSetterExpectedParamCount(method){
|
|
1269
1273
|
let baseCount=super.getGetterSetterExpectedParamCount(method),firstParam=this.getObjectOrClassMethodParams(method)[0];return firstParam&&this.isThisParam(firstParam)?baseCount+1:baseCount}parseCatchClauseParam(){let param=super.parseCatchClauseParam(),type=this.tsTryParseTypeAnnotation();return type&&(param.typeAnnotation=type,this.resetEndLocation(param)),param}tsInAmbientContext(cb){let{isAmbientContext:oldIsAmbientContext,strict:oldStrict}=this.state;this.state.isAmbientContext=!0,this.state.
|
|
1270
1274
|
strict=!1;try{return cb()}finally{this.state.isAmbientContext=oldIsAmbientContext,this.state.strict=oldStrict}}parseClass(node,isStatement,optionalId){let oldInAbstractClass=this.state.inAbstractClass;this.state.inAbstractClass=!!node.abstract;try{return super.parseClass(node,isStatement,optionalId)}finally{this.state.inAbstractClass=oldInAbstractClass}}tsParseAbstractDeclaration(node,decorators){if(this.match(76))return node.abstract=!0,this.maybeTakeDecorators(decorators,this.parseClass(node,!0,
|
|
1271
|
-
!1));if(this.isContextual(
|
|
1275
|
+
!1));if(this.isContextual(126))return this.hasFollowingLineBreak()?null:(node.abstract=!0,this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifier,node),this.tsParseInterfaceDeclaration(node));throw this.unexpected(null,76)}parseMethod(node,isGenerator,isAsync,isConstructor,allowDirectSuper,type,inClassScope){let method=super.parseMethod(node,isGenerator,isAsync,isConstructor,allowDirectSuper,type,inClassScope);if((method.abstract||method.type==="TSAbstractMethodDefinition")&&(this.hasPlugin(
|
|
1272
1276
|
"estree")?method.value:method).body){let{key}=method;this.raise(TSErrors.AbstractMethodHasImplementation,method,{methodName:key.type==="Identifier"&&!method.computed?key.name:`[${this.input.slice(this.offsetToSourcePos(key.start),this.offsetToSourcePos(key.end))}]`})}return method}tsParseTypeParameterName(){return this.parseIdentifier()}shouldParseAsAmbientContext(){return!!this.getPluginOption("typescript","dts")}parse(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),
|
|
1273
1277
|
super.parse()}getExpression(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.getExpression()}parseExportSpecifier(node,isString,isInTypeExport,isMaybeTypeOnly){return!isString&&isMaybeTypeOnly?(this.parseTypeOnlyExportSpecifier(node,isInTypeExport),this.finishNode(node,"ExportSpecifier")):(node.exportKind="value",super.parseExportSpecifier(node,isString,isInTypeExport,isMaybeTypeOnly))}parseImportSpecifier(specifier,importedIsString,isInTypeOnlyImport,isMaybeTypeOnly,bindingType){
|
|
1274
|
-
return!importedIsString&&isMaybeTypeOnly?(this.parseTypeOnlyImportSpecifier(specifier,isInTypeOnlyImport),this.finishNode(specifier,"ImportSpecifier")):(specifier.importKind="value",super.parseImportSpecifier(specifier,importedIsString,isInTypeOnlyImport,isMaybeTypeOnly,isInTypeOnlyImport?4098:4096))}parseTypeOnlyImportSpecifier(node,isInTypeOnly){let leftOfAs=node.imported,hasTypeSpecifier=!1;if(this.isContextual(
|
|
1275
|
-
parseIdentifier();tokenIsKeywordOrIdentifier(this.state.type)?(hasTypeSpecifier=!0,leftOfAs=firstAs,node.local=this.parseIdentifier()):node.local=secondAs}else tokenIsKeywordOrIdentifier(this.state.type)?node.local=this.parseIdentifier():(hasTypeSpecifier=!0,leftOfAs=firstAs)}else tokenIsKeywordOrIdentifier(this.state.type)&&(hasTypeSpecifier=!0,leftOfAs=this.parseIdentifier(!0),this.isContextual(
|
|
1276
|
-
raise(TSErrors.TypeModifierIsUsedInTypeImports,node.imported),node.imported=leftOfAs,node.importKind=hasTypeSpecifier?"type":"value",this.checkIdentifier(node.local??=this.eatContextual(
|
|
1278
|
+
return!importedIsString&&isMaybeTypeOnly?(this.parseTypeOnlyImportSpecifier(specifier,isInTypeOnlyImport),this.finishNode(specifier,"ImportSpecifier")):(specifier.importKind="value",super.parseImportSpecifier(specifier,importedIsString,isInTypeOnlyImport,isMaybeTypeOnly,isInTypeOnlyImport?4098:4096))}parseTypeOnlyImportSpecifier(node,isInTypeOnly){let leftOfAs=node.imported,hasTypeSpecifier=!1;if(this.isContextual(90)){let firstAs=this.parseIdentifier();if(this.isContextual(90)){let secondAs=this.
|
|
1279
|
+
parseIdentifier();tokenIsKeywordOrIdentifier(this.state.type)?(hasTypeSpecifier=!0,leftOfAs=firstAs,node.local=this.parseIdentifier()):node.local=secondAs}else tokenIsKeywordOrIdentifier(this.state.type)?node.local=this.parseIdentifier():(hasTypeSpecifier=!0,leftOfAs=firstAs)}else tokenIsKeywordOrIdentifier(this.state.type)&&(hasTypeSpecifier=!0,leftOfAs=this.parseIdentifier(!0),this.isContextual(90)||this.checkReservedWord(leftOfAs.name,leftOfAs.start,!0,!0));hasTypeSpecifier&&isInTypeOnly&&this.
|
|
1280
|
+
raise(TSErrors.TypeModifierIsUsedInTypeImports,node.imported),node.imported=leftOfAs,node.importKind=hasTypeSpecifier?"type":"value",this.checkIdentifier(node.local??=this.eatContextual(90)?this.parseIdentifier():this.cloneIdentifier(node.imported),hasTypeSpecifier?4098:4096)}parseTypeOnlyExportSpecifier(node,isInTypeOnly){let local=node.local,hasTypeSpecifier=!1;if(this.isContextual(90)){let firstAs=this.parseIdentifier();if(this.isContextual(90)){let secondAs=this.parseIdentifier();tokenIsKeywordOrIdentifier(
|
|
1277
1281
|
this.state.type)?(hasTypeSpecifier=!0,node.local=firstAs,node.exported=this.parseModuleExportName()):node.exported=secondAs}else tokenIsKeywordOrIdentifier(this.state.type)?node.exported=this.parseModuleExportName():(hasTypeSpecifier=!0,node.local=firstAs)}else tokenIsKeywordOrIdentifier(this.state.type)&&(hasTypeSpecifier=!0,node.local=this.parseModuleExportName());hasTypeSpecifier&&isInTypeOnly&&this.raise(TSErrors.TypeModifierIsUsedInTypeExports,local),node.exportKind=hasTypeSpecifier?"type":
|
|
1278
|
-
"value",node.exported??=this.eatContextual(
|
|
1282
|
+
"value",node.exported??=this.eatContextual(90)?this.parseModuleExportName():this.cloneIdentifier(node.local)}fillOptionalPropertiesForTSESLint(node){switch(node.type){case"ImportDeclaration":node.phase??=null;return;case"ExpressionStatement":node.directive??=void 0;return;case"RestElement":node.value=void 0;case"Identifier":case"ArrayPattern":case"AssignmentPattern":case"ObjectPattern":node.decorators??=[],node.optional??=!1,node.typeAnnotation??=void 0;return;case"TSParameterProperty":node.accessibility??=
|
|
1279
1283
|
void 0,node.decorators??=[],node.override??=!1,node.readonly??=!1,node.static??=!1;return;case"TSEmptyBodyFunctionExpression":node.body=null;case"TSDeclareFunction":case"FunctionDeclaration":case"FunctionExpression":case"ClassMethod":case"ClassPrivateMethod":node.declare??=!1,node.returnType??=void 0,node.typeParameters??=void 0;return;case"Property":node.optional??=!1;return;case"TSMethodSignature":case"TSPropertySignature":node.optional??=!1;case"TSIndexSignature":node.accessibility??=void 0,node.
|
|
1280
1284
|
readonly??=!1,node.static??=!1;return;case"TSAbstractPropertyDefinition":case"PropertyDefinition":case"TSAbstractAccessorProperty":case"AccessorProperty":node.declare??=!1,node.definite??=!1,node.readonly??=!1,node.typeAnnotation??=void 0;case"TSAbstractMethodDefinition":case"MethodDefinition":node.accessibility??=void 0,node.decorators??=[],node.override??=!1,node.optional??=!1;return;case"ClassExpression":node.id??=null;case"ClassDeclaration":node.abstract??=!1,node.declare??=!1,node.decorators??=
|
|
1281
1285
|
[],node.implements??=[],node.superTypeArguments??=void 0,node.typeParameters??=void 0;return;case"TSTypeAliasDeclaration":case"VariableDeclaration":node.declare??=!1;return;case"VariableDeclarator":node.definite??=!1;return;case"TSEnumDeclaration":node.const??=!1,node.declare??=!1;return;case"TSEnumMember":node.computed??=!1;return;case"TSImportType":node.qualifier??=null,node.options??=null,node.typeArguments??=null;return;case"TSInterfaceDeclaration":node.declare??=!1,node.extends??=[];return;case"\
|
|
@@ -1284,29 +1288,29 @@ endCh!==92)return!1}return!0}else return ch===92}nextTokenIsIdentifierAndNotTSRe
|
|
|
1284
1288
|
property}=expression;return computed&&property.type!=="StringLiteral"&&(property.type!=="TemplateLiteral"||property.expressions.length>0)?!1:isUncomputedMemberExpressionChain(expression.object)}function isValidAmbientConstInitializer(expression,estree2){let{type}=expression;if(expression.extra?.parenthesized)return!1;if(estree2){if(type==="Literal"){let{value}=expression;if(typeof value=="string"||typeof value=="boolean")return!0}}else if(type==="StringLiteral"||type==="BooleanLiteral")return!0;
|
|
1285
1289
|
return!!(isNumber(expression,estree2)||isNegativeNumber(expression,estree2)||type==="TemplateLiteral"&&expression.expressions.length===0||isPossiblyLiteralEnum(expression))}function isNumber(expression,estree2){return estree2?expression.type==="Literal"&&(typeof expression.value=="number"||"bigint"in expression):expression.type==="NumericLiteral"||expression.type==="BigIntLiteral"}function isNegativeNumber(expression,estree2){if(expression.type==="UnaryExpression"){let{operator,argument}=expression;
|
|
1286
1290
|
if(operator==="-"&&isNumber(argument,estree2))return!0}return!1}function isUncomputedMemberExpressionChain(expression){return expression.type==="Identifier"?!0:expression.type!=="MemberExpression"||expression.computed?!1:isUncomputedMemberExpressionChain(expression.object)}function buildModifiersMap(allowed,disallow=[]){let map=new Map;for(let modifier of allowed)map.set(modifier,!0);for(let modifier of disallow)map.set(modifier,!1);return map}var PlaceholderErrorTemplates={ClassNameIsRequired:"\
|
|
1287
|
-
A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."},PlaceholderErrors=ParseErrorEnum`placeholders`(PlaceholderErrorTemplates),placeholders=superClass=>class extends superClass{parsePlaceholder(expectedNode){if(this.match(
|
|
1288
|
-
expectedNode||!placeholder.type)&&(placeholder=this.finishNode(placeholder,"Placeholder")),placeholder.expectedNode=expectedNode,placeholder}getTokenFromCode(code2){code2===37&&this.input.charCodeAt(this.state.pos+1)===37?this.finishOp(
|
|
1291
|
+
A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."},PlaceholderErrors=ParseErrorEnum`placeholders`(PlaceholderErrorTemplates),placeholders=superClass=>class extends superClass{parsePlaceholder(expectedNode){if(this.match(130)){let node=this.startNode();return this.next(),this.assertNoSpace(),node.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(130),this.finishPlaceholder(node,expectedNode)}}finishPlaceholder(node,expectedNode){let placeholder=node;return(!placeholder.
|
|
1292
|
+
expectedNode||!placeholder.type)&&(placeholder=this.finishNode(placeholder,"Placeholder")),placeholder.expectedNode=expectedNode,placeholder}getTokenFromCode(code2){code2===37&&this.input.charCodeAt(this.state.pos+1)===37?this.finishOp(130,2):super.getTokenFromCode(code2)}parseExprAtom(refExpressionErrors){return this.parsePlaceholder("Expression")||super.parseExprAtom(refExpressionErrors)}parseIdentifier(liberal){return this.parsePlaceholder("Identifier")||super.parseIdentifier(liberal)}checkReservedWord(word,startLoc,checkKeywords,isBinding){
|
|
1289
1293
|
word!==void 0&&super.checkReservedWord(word,startLoc,checkKeywords,isBinding)}cloneIdentifier(node){let cloned=super.cloneIdentifier(node);return cloned.type==="Placeholder"&&(cloned.expectedNode=node.expectedNode),cloned}cloneStringLiteral(node){return node.type==="Placeholder"?this.cloneIdentifier(node):super.cloneStringLiteral(node)}parseBindingAtom(){return this.parsePlaceholder("Pattern")||super.parseBindingAtom()}isValidLVal(type,disallowCallExpression,isParenthesized,binding){return type===
|
|
1290
1294
|
"Placeholder"||super.isValidLVal(type,disallowCallExpression,isParenthesized,binding)}toAssignable(node,isLHS){node&&node.type==="Placeholder"&&node.expectedNode==="Expression"?node.expectedNode="Pattern":super.toAssignable(node,isLHS)}chStartsBindingIdentifier(ch,pos){if(super.chStartsBindingIdentifier(ch,pos))return!0;let next=this.nextTokenStart();return this.input.charCodeAt(next)===37&&this.input.charCodeAt(next+1)===37}verifyBreakContinue(node,isBreak){node.label?.type!=="Placeholder"&&super.
|
|
1291
|
-
verifyBreakContinue(node,isBreak)}parseExpressionStatement(node,expr){if(expr.type!=="Placeholder"||expr.extra?.parenthesized)return super.parseExpressionStatement(node,expr);if(this.match(10)){let stmt=node;return stmt.label=this.finishPlaceholder(expr,"Identifier"),this.next(),stmt.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(stmt,"LabeledStatement")}this.semicolon();let stmtPlaceholder=node;return stmtPlaceholder.name=
|
|
1292
|
-
"Statement")}parseBlock(allowDirectives,createNewLexicalScope,afterBlockParse){return this.parsePlaceholder("BlockStatement")||super.parseBlock(allowDirectives,createNewLexicalScope,afterBlockParse)}parseFunctionId(requireId){return this.parsePlaceholder("Identifier")||super.parseFunctionId(requireId)}parseClass(node,isStatement,optionalId){let type=isStatement?"ClassDeclaration":"ClassExpression";this.next();let oldStrict=this.state.strict,placeholder=this.
|
|
1293
|
-
if(this.match(77)||this.match(
|
|
1294
|
-
let placeholder=this.parsePlaceholder("Identifier");if(!placeholder)return super.parseExport(node,decorators);let node2=node;if(!this.isContextual(
|
|
1295
|
-
|
|
1296
|
-
parsePlaceholder("Identifier");if(!placeholder)return super.parseImport(node);if(node.specifiers=[],!this.isContextual(
|
|
1297
|
-
node)),this.expectContextual(
|
|
1298
|
-
state.startLoc,node=this.startNode();if(this.next(),tokenIsIdentifier(this.state.type)){let name=this.parseIdentifierName(),identifier=this.createIdentifier(node,name);if(this.castNodeTo(identifier,"V8IntrinsicIdentifier"),this.match(6))return identifier}this.unexpected(v8IntrinsicStartLoc)}}parseExprAtom(refExpressionErrors){return this.
|
|
1299
|
-
if(pluginsMap.has("decorators")&&pluginsMap.has("decorators-legacy"))throw new Error("Cannot use the decorators and decorators-legacy plugin together");if(pluginsMap.has("flow")&&pluginsMap.has("typescript"))throw new Error("Cannot combine flow and typescript plugins.");if(pluginsMap.has("placeholders")&&pluginsMap.has("
|
|
1300
|
-
if(!PIPELINE_PROPOSALS.includes(proposal)){let proposalList=PIPELINE_PROPOSALS.map(p=>`"${p}"`).join(", ");throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`)}if(proposal==="hack"){if(pluginsMap.has("placeholders"))throw new Error("Cannot combine placeholders
|
|
1301
|
-
|
|
1302
|
-
Babel 8, please
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
throw new Error("The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.")}var mixinPlugins={estree,jsx,flow,typescript,v8intrinsic,placeholders},mixinPluginNames=Object.keys(mixinPlugins),Parser=class extends StatementParser{constructor(options,input,pluginsMap){
|
|
1306
|
-
pluginsMap,this.filename=normalizedOptions.sourceFilename,this.startIndex=normalizedOptions.startIndex;let optionFlags=0;normalizedOptions.allowAwaitOutsideFunction&&(optionFlags|=1),normalizedOptions.allowReturnOutsideFunction&&(optionFlags|=2),normalizedOptions.allowImportExportEverywhere&&(optionFlags|=8),normalizedOptions.allowSuperOutsideMethod&&(optionFlags|=
|
|
1307
|
-
|
|
1308
|
-
return ScopeHandler}parse(){this.enterInitialScopes();let file=this.startNode(),program=this.startNode();this.nextToken(),file.errors=[];let result=this.parseTopLevel(file,program);return result.errors=this.state.errors,result.comments.length=this.state.commentsLen,result}};function parse(input,options){if(options?.sourceType==="
|
|
1309
|
-
ambiguousScriptDifferentAst)try{return options.sourceType="script",getParser(options,input).parse()}catch{}else ast.program.sourceType="script";return ast}catch(moduleError){try{return options.sourceType="script",getParser(options,input).parse()}catch{}throw moduleError}}else return getParser(options,input).parse()}function generateExportedTokenTypes(internalTokenTypes){let tokenTypes2={};for(let typeName of Object.keys(internalTokenTypes))tokenTypes2[typeName]=getExportedToken(internalTokenTypes[typeName]);return tokenTypes2}var tokTypes=generateExportedTokenTypes(tt);function getParser(options,input){let cls=Parser,pluginsMap=new Map;if(options?.plugins){for(let plugin of options.plugins){let name,opts;typeof plugin=="string"?name=plugin:[name,opts]=plugin,pluginsMap.has(name)||pluginsMap.set(name,opts||
|
|
1295
|
+
verifyBreakContinue(node,isBreak)}parseExpressionStatement(node,expr,flags){if(expr.type!=="Placeholder"||expr.extra?.parenthesized)return super.parseExpressionStatement(node,expr,flags);if(this.match(10)){let stmt=node;return stmt.label=this.finishPlaceholder(expr,"Identifier"),this.next(),stmt.body=flags&8?super.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):super.parseStatement(),this.finishNode(stmt,"LabeledStatement")}this.semicolon();let stmtPlaceholder=node;return stmtPlaceholder.name=
|
|
1296
|
+
expr.name,this.finishPlaceholder(stmtPlaceholder,"Statement")}parseBlock(allowDirectives,createNewLexicalScope,afterBlockParse){return this.parsePlaceholder("BlockStatement")||super.parseBlock(allowDirectives,createNewLexicalScope,afterBlockParse)}parseFunctionId(requireId){return this.parsePlaceholder("Identifier")||super.parseFunctionId(requireId)}parseClass(node,isStatement,optionalId){let type=isStatement?"ClassDeclaration":"ClassExpression";this.next();let oldStrict=this.state.strict,placeholder=this.
|
|
1297
|
+
parsePlaceholder("Identifier");if(placeholder)if(this.match(77)||this.match(130)||this.match(2))node.id=placeholder;else{if(optionalId||!isStatement)return node.id=null,node.body=this.finishPlaceholder(placeholder,"ClassBody"),this.finishNode(node,type);throw this.raise(PlaceholderErrors.ClassNameIsRequired,this.state.startLoc)}else this.parseClassId(node,isStatement,optionalId);return super.parseClassSuper(node),node.body=this.parsePlaceholder("ClassBody")||super.parseClassBody(!!node.superClass,
|
|
1298
|
+
oldStrict),this.finishNode(node,type)}parseExport(node,decorators){let placeholder=this.parsePlaceholder("Identifier");if(!placeholder)return super.parseExport(node,decorators);let node2=node;if(!this.isContextual(95)&&!this.match(8))return node2.specifiers=[],node2.source=null,node2.declaration=this.finishPlaceholder(placeholder,"Declaration"),this.finishNode(node2,"ExportNamedDeclaration");this.expectPlugin("exportDefaultFrom");let specifier=this.startNode();return specifier.exported=placeholder,
|
|
1299
|
+
node2.specifiers=[this.finishNode(specifier,"ExportDefaultSpecifier")],super.parseExport(node2,decorators)}isExportDefaultSpecifier(){if(this.match(61)){let next=this.nextTokenStart();if(this.isUnparsedContextual(next,"from")&&this.input.startsWith(tokenLabelName(130),this.hasPlugin("exportDefaultFrom")?this.nextTokenStartSince(next+4):this.nextTokenInLineStartSince(next+4)))return!0}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier(node,maybeDefaultIdentifier){return node.
|
|
1300
|
+
specifiers?.length?!0:super.maybeParseExportDefaultSpecifier(node,maybeDefaultIdentifier)}checkNamedExport(){}parseImport(node){let placeholder=this.parsePlaceholder("Identifier");if(!placeholder)return super.parseImport(node);if(node.specifiers=[],!this.isContextual(95)&&!this.match(8))return node.source=this.finishPlaceholder(placeholder,"StringLiteral"),this.semicolon(),this.finishNode(node,"ImportDeclaration");let specifier=this.startNodeAtNode(placeholder);return specifier.local=placeholder,
|
|
1301
|
+
node.specifiers.push(this.finishNode(specifier,"ImportDefaultSpecifier")),this.eat(8)&&(this.maybeParseStarImportSpecifier(node)||this.parseNamedImportSpecifiers(node)),this.expectContextual(95),node.source=this.parseImportSource(),this.semicolon(),this.finishNode(node,"ImportDeclaration")}parseImportSource(){return this.parsePlaceholder("StringLiteral")||super.parseImportSource()}assertNoSpace(){this.state.start>this.offsetToSourcePos(this.state.lastTokEndLoc.index)&&this.raise(PlaceholderErrors.
|
|
1302
|
+
UnexpectedSpace,this.state.lastTokEndLoc)}},v8intrinsic=superClass=>class extends superClass{parseV8Intrinsic(){if(this.match(50)){let v8IntrinsicStartLoc=this.state.startLoc,node=this.startNode();if(this.next(),tokenIsIdentifier(this.state.type)){let name=this.parseIdentifierName(),identifier=this.createIdentifier(node,name);if(this.castNodeTo(identifier,"V8IntrinsicIdentifier"),this.match(6))return identifier}this.unexpected(v8IntrinsicStartLoc)}}parseExprAtom(refExpressionErrors){return this.
|
|
1303
|
+
parseV8Intrinsic()||super.parseExprAtom(refExpressionErrors)}},PIPELINE_PROPOSALS=["fsharp","hack"],TOPIC_TOKENS=["^^","@@","^","%","#"];function validatePlugins(pluginsMap){if(pluginsMap.has("decorators")&&pluginsMap.has("decorators-legacy"))throw new Error("Cannot use the decorators and decorators-legacy plugin together");if(pluginsMap.has("flow")&&pluginsMap.has("typescript"))throw new Error("Cannot combine flow and typescript plugins.");if(pluginsMap.has("placeholders")&&pluginsMap.has("v8in\
|
|
1304
|
+
trinsic"))throw new Error("Cannot combine placeholders and v8intrinsic plugins.");if(pluginsMap.has("pipelineOperator")){let proposal=pluginsMap.get("pipelineOperator").proposal;if(!PIPELINE_PROPOSALS.includes(proposal)){let proposalList=PIPELINE_PROPOSALS.map(p=>`"${p}"`).join(", ");throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`)}if(proposal==="hack"){if(pluginsMap.has("placeholders"))throw new Error("Cannot combine placeholders plug\
|
|
1305
|
+
in and Hack-style pipes.");if(pluginsMap.has("v8intrinsic"))throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");let topicToken=pluginsMap.get("pipelineOperator").topicToken;if(!TOPIC_TOKENS.includes(topicToken)){let tokenList=TOPIC_TOKENS.map(t=>`"${t}"`).join(", ");throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`)}}}if(pluginsMap.has("moduleAttributes"))throw new Error("`moduleAtt\
|
|
1306
|
+
ributes` has been removed in Babel 8, please migrate to import attributes instead.");if(pluginsMap.has("importAssertions"))throw new Error("`importAssertions` has been removed in Babel 8, please use import attributes instead.");if(pluginsMap.has("deprecatedImportAssert")?console.warn("`deprecatedImportAssert` has been removed in Babel 8, please use import attributes instead."):pluginsMap.has("importAttributes")&&pluginsMap.get("importAttributes").deprecatedAssertSyntax&&console.warn("The 'import\
|
|
1307
|
+
Attributes' plugin has been removed in Babel 8. Please migrate any usage of `assert`-style attributes to `with`."),pluginsMap.has("recordAndTuple"))throw new Error("The 'recordAndTuple' plugin has been removed in Babel 8. Please remove it from your configuration.");if(pluginsMap.has("asyncDoExpressions")&&!pluginsMap.has("doExpressions")){let error=new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");throw error.missingPlugins="doExpressions",
|
|
1308
|
+
error}if(pluginsMap.has("optionalChainingAssign")&&pluginsMap.get("optionalChainingAssign").version!=="2023-07")throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.");if(pluginsMap.has("discardBinding")&&pluginsMap.get("discardBinding").syntaxType!=="void")throw new Error("The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.");
|
|
1309
|
+
if(pluginsMap.has("decimal"))throw new Error("The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.");if(pluginsMap.has("importReflection"))throw new Error("The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.")}var mixinPlugins={estree,jsx,flow,typescript,v8intrinsic,placeholders},mixinPluginNames=Object.keys(mixinPlugins),Parser=class extends StatementParser{constructor(options,input,pluginsMap){
|
|
1310
|
+
let normalizedOptions=getOptions(options);super(normalizedOptions,input),this.options=normalizedOptions,this.initializeScopes(),this.plugins=pluginsMap,this.filename=normalizedOptions.sourceFilename,this.startIndex=normalizedOptions.startIndex;let optionFlags=0;normalizedOptions.allowAwaitOutsideFunction&&(optionFlags|=1),normalizedOptions.allowReturnOutsideFunction&&(optionFlags|=2),normalizedOptions.allowImportExportEverywhere&&(optionFlags|=8),normalizedOptions.allowSuperOutsideMethod&&(optionFlags|=
|
|
1311
|
+
16),normalizedOptions.allowUndeclaredExports&&(optionFlags|=64),normalizedOptions.allowNewTargetOutsideFunction&&(optionFlags|=4),normalizedOptions.allowYieldOutsideFunction&&(optionFlags|=32),normalizedOptions.ranges&&(optionFlags|=128),normalizedOptions.locations===!0&&(optionFlags|=256),normalizedOptions.tokens&&(optionFlags|=512),normalizedOptions.createImportExpressions&&(optionFlags|=1024),normalizedOptions.createParenthesizedExpressions&&(optionFlags|=2048),normalizedOptions.errorRecovery&&
|
|
1312
|
+
(optionFlags|=4096),normalizedOptions.attachComment&&(optionFlags|=8192),normalizedOptions.annexB&&(optionFlags|=16384),this.optionFlags=optionFlags}getScopeHandler(){return ScopeHandler}parse(){this.enterInitialScopes();let file=this.startNode(),program=this.startNode();this.nextToken(),file.errors=[];let result=this.parseTopLevel(file,program);return result.errors=this.state.errors,result.comments.length=this.state.commentsLen,result}};function parse(input,options){if(options?.sourceType==="un\
|
|
1313
|
+
ambiguous"){options={...options};try{options.sourceType="module";let parser=getParser(options,input),ast=parser.parse();if(parser.sawUnambiguousESM)return ast;if(parser.ambiguousScriptDifferentAst)try{return options.sourceType="script",getParser(options,input).parse()}catch{}else ast.program.sourceType="script";return ast}catch(moduleError){try{return options.sourceType="script",getParser(options,input).parse()}catch{}throw moduleError}}else return getParser(options,input).parse()}function generateExportedTokenTypes(internalTokenTypes){let tokenTypes2={};for(let typeName of Object.keys(internalTokenTypes))tokenTypes2[typeName]=getExportedToken(internalTokenTypes[typeName]);return tokenTypes2}var tokTypes=generateExportedTokenTypes(tt);function getParser(options,input){let cls=Parser,pluginsMap=new Map;if(options?.plugins){for(let plugin of options.plugins){let name,opts;typeof plugin=="string"?name=plugin:[name,opts]=plugin,pluginsMap.has(name)||pluginsMap.set(name,opts||
|
|
1310
1314
|
{})}validatePlugins(pluginsMap),cls=getParserClass(pluginsMap)}return new cls(options,input,pluginsMap)}var parserClassCache=new Map;function getParserClass(pluginsMap){let pluginList=[];for(let name of mixinPluginNames)pluginsMap.has(name)&&pluginList.push(name);let key=pluginList.join("|"),cls=parserClassCache.get(key);if(!cls){cls=Parser;for(let plugin of pluginList)cls=mixinPlugins[plugin](cls);parserClassCache.set(key,cls)}return cls}import{createHash as createHash4}from"node:crypto";import{stripVTControlCharacters as stripVTControlCharacters3}from"node:util";function buildRepairEvidence(input){let hash2=text2=>createHash4("sha256").update(text2).digest("hex"),scope=[...new Set(input.scope)].sort();return{suiteKey:hash2(JSON.stringify({level:input.suiteSalt,scope,checks:input.checks})),candidateRoot:input.repoRoot,candidateTree:input.before?.tree??"",integrityVerified:input.before!==null&&input.after!==null&&input.before.tree===input.after.tree,...input.checks.some((check2,index)=>{let result=input.results[index];return result?.name===check2.name&&JSON.
|
|
1311
1315
|
stringify(result.argv)===JSON.stringify(check2.argv)&&!result.comparisonKey&&result.configurationReason==="unsupported_configuration"})?{configurationReason:"unsupported_configuration"}:{},configurationCurrent:()=>input.results.every(result=>result.configurationCurrent?.()!==!1),checks:input.checks.map((check2,index)=>{let result=input.results[index],matched=result?.name===check2.name&&JSON.stringify(result.argv)===JSON.stringify(check2.argv),diagnosticIds=matched&&result?[...new Set(result.diagnosticIds??
|
|
1312
1316
|
normalizeDiagnostics((result.diagnosticLines??[]).join(`
|
|
@@ -1987,7 +1991,7 @@ function pickCandidate(state,isHealthy){let index=state.candidates.findIndex((mo
|
|
|
1987
1991
|
-exhausted"};let remaining=cfg.maxWaitMs-state.waitedMs;if(remaining<=0)return{kind:"give-up",reason:"max-wait"};let planned=cfg.waitScheduleMs[Math.min(state.waitIndex,cfg.waitScheduleMs.length-1)];return{kind:"wait",delayMs:Math.min(planned,remaining)}}function nextStep(state,failure,realWork,isHealthy,cfg){let candidateFailure=failure==="quota"||failure==="unknown_cost"||failure==="unknown_cost_transient";if(!candidateFailure&&realWork&&!state.sameModelRetried)return{kind:"retry-same",delayMs:cfg.
|
|
1988
1992
|
sameModelRetryDelayMs};if(!candidateFailure&&state.switches>=cfg.maxSwitches)return{kind:"give-up",reason:"max-switches"};let index=pickCandidate(state,isHealthy);return index!==null?{kind:"switch",index}:failure==="unknown_cost_transient"&&!state.unknownCostRetried?{kind:"retry-same",delayMs:cfg.sameModelRetryDelayMs,unknownCost:!0}:candidateFailure?{kind:"give-up",reason:failure==="quota"?"quota-exhausted":"unknown-cost-exhausted"}:waitOrGiveUp(state,cfg)}function applyStep(state,step){switch(step.
|
|
1989
1993
|
kind){case"retry-same":return{...state,sameModelRetried:!0,unknownCostRetried:state.unknownCostRetried||!!step.unknownCost};case"switch":return{...state,current:step.index,attempted:[...state.attempted,step.index],switches:state.switches+1,sameModelRetried:!1};case"wait":return{...state,attempted:[],waitIndex:state.waitIndex+1,waitedMs:state.waitedMs+step.delayMs};case"give-up":return state}}function resumeAfterWait(state,index){return{...state,current:index,attempted:[index],sameModelRetried:!1}}function custodyAllowsReplay(source,requireTermination=!1){return source.replayBlocked!==!0&&source.ownedTreeState!=="present"&&(source.processTerminationConfirmed===!0||!requireTermination&&source.ownedTreeState==="unknown"&&source.replayBlocked===!1)}async function dispatchWithFailover(task,candidates,deps){if(candidates.length===0)throw new Error(`dispatchWithFailover: no candidate models for ${task.taskId}`);let healthy=m=>deps.health.isHealthy(m),start=candidates.findIndex(healthy),state=initialState(
|
|
1990
|
-
candidates,start
|
|
1994
|
+
candidates,Math.max(start,0)),prompt=task.prompt,spent=0,files=new Set,filesUnknown=!1,attempts=[],switches=[],waitedMs=0;for(;;){let model=candidates[state.current],snap=deps.snapshot(),n=attempts.length+1,delayMs=waitedMs;waitedMs=0;let result=await deps.runAttempt(model,prompt,n,spent,delayMs,attempts.at(-1)?.record);spent+=result.costUsd+(result.nestedCostUsd??0);let scan=scanEvents(deps.readEvents(result)),signals=attemptSignalsFromScan(result,scan,deps.isCancelled()),cls=classifyFailure(signals),
|
|
1991
1995
|
observed=deps.changedSince(snap),changed=observed??[];for(let f of changed)files.add(f);let realWork=observed===null||hadRealWork(scan,changed,deps.config.realWorkMinToolCalls);observed===null&&(filesUnknown=!0);let reason=cls==="ok"?"":failureReason(signals),observation=result.effectObservation,effectSafe=observation?.complete===!0&&observation.toolExecutionsStarted===0&&observation.nestedActivity===!1&&observed!==null&&changed.length===0&&scan.toolCalls===0&&!scan.toolInFlight&&!scan.subagentCalls.
|
|
1992
1996
|
length&&!scan.finishedWorkers.length&&!scan.unfinishedWorkers.length&&(result.nestedCostUsd??0)===0;attempts.push({model,result,record:{model,cls,reason,costUsd:result.costUsd+(result.nestedCostUsd??0),realWork,effectSafe}});let done=(exhausted,r=result)=>({result:r,attempts,switches,finalModel:model,finalScan:scan,exhausted});if(cls==="cancelled")return done(!1);if(result.replayBlocked||result.ownedTreeState==="present")return done(!0,{...result,stderr:`[orchestrator] owned tree ${result.ownedTreeState??
|
|
1993
1997
|
"unknown"}; automatic retry blocked
|