@voidzero-dev/vite-plus-test 0.0.0-0bfcc90f.20260209-0731
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/LICENSE.md +691 -0
- package/browser/context.d.ts +4 -0
- package/browser/context.js +20 -0
- package/config.d.ts +3 -0
- package/coverage.d.ts +1 -0
- package/dist/@vitest/browser/client/.vite/manifest.json +24 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/@vitest/browser/client/__vitest__/bg.png +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.svg +5 -0
- package/dist/@vitest/browser/client/__vitest__/index.html +32 -0
- package/dist/@vitest/browser/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/@vitest/browser/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/@vitest/browser/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/@vitest/browser/client/error-catcher.js +82 -0
- package/dist/@vitest/browser/client/esm-client-injector.js +67 -0
- package/dist/@vitest/browser/client/favicon.svg +5 -0
- package/dist/@vitest/browser/client/orchestrator.html +35 -0
- package/dist/@vitest/browser/client/tester/tester.html +13 -0
- package/dist/@vitest/browser/client.js +456 -0
- package/dist/@vitest/browser/context.d.ts +792 -0
- package/dist/@vitest/browser/context.js +541 -0
- package/dist/@vitest/browser/expect-element.js +32 -0
- package/dist/@vitest/browser/index-D6m36C6U.js +11 -0
- package/dist/@vitest/browser/index.d.ts +73 -0
- package/dist/@vitest/browser/index.js +3513 -0
- package/dist/@vitest/browser/jest-dom.d.ts +724 -0
- package/dist/@vitest/browser/locators.d.ts +354 -0
- package/dist/@vitest/browser/locators.js +1 -0
- package/dist/@vitest/browser/matchers.d.ts +29 -0
- package/dist/@vitest/browser/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/@vitest/browser/state.js +280 -0
- package/dist/@vitest/browser/types.d.ts +69 -0
- package/dist/@vitest/browser-playwright/context.d.ts +1 -0
- package/dist/@vitest/browser-playwright/index.d.ts +106 -0
- package/dist/@vitest/browser-playwright/index.js +1111 -0
- package/dist/@vitest/browser-playwright/locators.js +114 -0
- package/dist/@vitest/browser-preview/context.d.ts +1 -0
- package/dist/@vitest/browser-preview/index.d.ts +19 -0
- package/dist/@vitest/browser-preview/index.js +148 -0
- package/dist/@vitest/browser-preview/locators.js +79 -0
- package/dist/@vitest/browser-webdriverio/context.d.ts +1 -0
- package/dist/@vitest/browser-webdriverio/index.d.ts +63 -0
- package/dist/@vitest/browser-webdriverio/index.js +600 -0
- package/dist/@vitest/browser-webdriverio/locators.js +163 -0
- package/dist/@vitest/expect/index.d.ts +807 -0
- package/dist/@vitest/expect/index.js +1875 -0
- package/dist/@vitest/mocker/auto-register.d.ts +2 -0
- package/dist/@vitest/mocker/auto-register.js +9 -0
- package/dist/@vitest/mocker/automock.d.ts +12 -0
- package/dist/@vitest/mocker/automock.js +1 -0
- package/dist/@vitest/mocker/browser.d.ts +53 -0
- package/dist/@vitest/mocker/browser.js +91 -0
- package/dist/@vitest/mocker/chunk-automock.js +354 -0
- package/dist/@vitest/mocker/chunk-interceptor-native.js +15 -0
- package/dist/@vitest/mocker/chunk-mocker.js +521 -0
- package/dist/@vitest/mocker/chunk-pathe.M-eThtNZ.js +174 -0
- package/dist/@vitest/mocker/chunk-registry.js +185 -0
- package/dist/@vitest/mocker/chunk-utils.js +16 -0
- package/dist/@vitest/mocker/index.d-C-sLYZi-.d.ts +25 -0
- package/dist/@vitest/mocker/index.d.ts +2 -0
- package/dist/@vitest/mocker/index.js +185 -0
- package/dist/@vitest/mocker/mocker.d-TnKRhz7N.d.ts +81 -0
- package/dist/@vitest/mocker/node.d.ts +800 -0
- package/dist/@vitest/mocker/node.js +966 -0
- package/dist/@vitest/mocker/redirect.d.ts +3 -0
- package/dist/@vitest/mocker/redirect.js +79 -0
- package/dist/@vitest/mocker/register.d.ts +9 -0
- package/dist/@vitest/mocker/register.js +41 -0
- package/dist/@vitest/mocker/types.d-B8CCKmHt.d.ts +107 -0
- package/dist/@vitest/pretty-format/index.d.ts +124 -0
- package/dist/@vitest/pretty-format/index.js +1022 -0
- package/dist/@vitest/runner/chunk-tasks.js +340 -0
- package/dist/@vitest/runner/index.d.ts +180 -0
- package/dist/@vitest/runner/index.js +2114 -0
- package/dist/@vitest/runner/tasks.d-C7UxawJ9.d.ts +834 -0
- package/dist/@vitest/runner/types.d.ts +183 -0
- package/dist/@vitest/runner/types.js +1 -0
- package/dist/@vitest/runner/utils.d.ts +45 -0
- package/dist/@vitest/runner/utils.js +5 -0
- package/dist/@vitest/snapshot/environment.d-DHdQ1Csl.d.ts +22 -0
- package/dist/@vitest/snapshot/environment.d.ts +16 -0
- package/dist/@vitest/snapshot/environment.js +40 -0
- package/dist/@vitest/snapshot/index.d.ts +130 -0
- package/dist/@vitest/snapshot/index.js +1437 -0
- package/dist/@vitest/snapshot/manager.d.ts +18 -0
- package/dist/@vitest/snapshot/manager.js +73 -0
- package/dist/@vitest/snapshot/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
- package/dist/@vitest/spy/index.d.ts +384 -0
- package/dist/@vitest/spy/index.js +433 -0
- package/dist/@vitest/utils/chunk-_commonjsHelpers.js +5 -0
- package/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +156 -0
- package/dist/@vitest/utils/constants.d.ts +21 -0
- package/dist/@vitest/utils/constants.js +49 -0
- package/dist/@vitest/utils/diff.d.ts +93 -0
- package/dist/@vitest/utils/diff.js +2199 -0
- package/dist/@vitest/utils/display.d.ts +29 -0
- package/dist/@vitest/utils/display.js +742 -0
- package/dist/@vitest/utils/error.d.ts +7 -0
- package/dist/@vitest/utils/error.js +42 -0
- package/dist/@vitest/utils/helpers.d.ts +73 -0
- package/dist/@vitest/utils/helpers.js +295 -0
- package/dist/@vitest/utils/highlight.d.ts +9 -0
- package/dist/@vitest/utils/highlight.js +538 -0
- package/dist/@vitest/utils/index.d.ts +5 -0
- package/dist/@vitest/utils/index.js +1 -0
- package/dist/@vitest/utils/offset.d.ts +5 -0
- package/dist/@vitest/utils/offset.js +32 -0
- package/dist/@vitest/utils/resolver.d.ts +7 -0
- package/dist/@vitest/utils/resolver.js +71 -0
- package/dist/@vitest/utils/serialize.d.ts +3 -0
- package/dist/@vitest/utils/serialize.js +118 -0
- package/dist/@vitest/utils/source-map.d.ts +55 -0
- package/dist/@vitest/utils/source-map.js +478 -0
- package/dist/@vitest/utils/timers.d.ts +33 -0
- package/dist/@vitest/utils/timers.js +49 -0
- package/dist/@vitest/utils/types.d-BCElaP-c.d.ts +53 -0
- package/dist/@vitest/utils/types.d.ts +34 -0
- package/dist/@vitest/utils/types.js +1 -0
- package/dist/browser-compat.js +3 -0
- package/dist/browser.d.ts +46 -0
- package/dist/browser.js +20 -0
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/chunks/base.CJ0Y4ePK.js +165 -0
- package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
- package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
- package/dist/chunks/cac.DVeoLl0M.js +1409 -0
- package/dist/chunks/cli-api.B7PN_QUv.js +13672 -0
- package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/constants.D_Q9UYh-.js +36 -0
- package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
- package/dist/chunks/coverage.D_JHT54q.js +25 -0
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
- package/dist/chunks/creator.DAmOKTvJ.js +673 -0
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/defaults.BOqNVLsY.js +74 -0
- package/dist/chunks/env.D4Lgay0q.js +8 -0
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
- package/dist/chunks/git.Bm2pzPAa.js +71 -0
- package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
- package/dist/chunks/globals.DOayXfHP.js +30 -0
- package/dist/chunks/index.6Qv1eEA6.js +109 -0
- package/dist/chunks/index.C5r1PdPD.js +231 -0
- package/dist/chunks/index.Chj8NDwU.js +206 -0
- package/dist/chunks/index.CyBMJtT7.js +727 -0
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/index.D4KonVSU.js +6343 -0
- package/dist/chunks/index.M8mOzt4Y.js +3839 -0
- package/dist/chunks/index.Z5E_ObnR.js +37 -0
- package/dist/chunks/init-forks._y3TW739.js +41 -0
- package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
- package/dist/chunks/init.B6MLFIaN.js +334 -0
- package/dist/chunks/inspector.CvyFGlXm.js +53 -0
- package/dist/chunks/modules.BJuCwlRJ.js +36 -0
- package/dist/chunks/node.Ce0vMQM7.js +14 -0
- package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
- package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
- package/dist/chunks/rpc.BoxB0q7B.js +76 -0
- package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
- package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
- package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
- package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
- package/dist/chunks/test.B8ej_ZHS.js +254 -0
- package/dist/chunks/traces.CCmnQaNT.js +217 -0
- package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
- package/dist/chunks/utils.DvEY5TfP.js +52 -0
- package/dist/chunks/vi.2VT5v0um.js +3919 -0
- package/dist/chunks/vm.D3epNOPZ.js +744 -0
- package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
- package/dist/cli.js +28 -0
- package/dist/client/.vite/manifest.json +24 -0
- package/dist/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/client/__vitest__/bg.png +0 -0
- package/dist/client/__vitest__/favicon.ico +0 -0
- package/dist/client/__vitest__/favicon.svg +5 -0
- package/dist/client/__vitest__/index.html +32 -0
- package/dist/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/client/error-catcher.js +82 -0
- package/dist/client/esm-client-injector.js +67 -0
- package/dist/client/favicon.svg +5 -0
- package/dist/client/orchestrator.html +35 -0
- package/dist/client/tester/tester.html +13 -0
- package/dist/client.js +456 -0
- package/dist/config.cjs +94 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +15 -0
- package/dist/context.js +541 -0
- package/dist/coverage.d.ts +118 -0
- package/dist/coverage.js +23 -0
- package/dist/dummy.js +2 -0
- package/dist/environments.d.ts +22 -0
- package/dist/environments.js +3 -0
- package/dist/expect-element.js +27 -0
- package/dist/index-D6m36C6U.js +6 -0
- package/dist/index-node.js +7 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +19 -0
- package/dist/locators.d.ts +354 -0
- package/dist/locators.js +1 -0
- package/dist/mocker.d.ts +1 -0
- package/dist/mocker.js +1 -0
- package/dist/module-evaluator.d.ts +124 -0
- package/dist/module-evaluator.js +343 -0
- package/dist/module-runner-stub.js +44 -0
- package/dist/module-runner.js +17 -0
- package/dist/node.d.ts +251 -0
- package/dist/node.js +98 -0
- package/dist/path.js +7 -0
- package/dist/plugins/browser-client.mjs +2 -0
- package/dist/plugins/browser-context.mjs +2 -0
- package/dist/plugins/browser-locators.mjs +2 -0
- package/dist/plugins/browser-playwright.mjs +2 -0
- package/dist/plugins/browser-preview.mjs +2 -0
- package/dist/plugins/browser-webdriverio.mjs +2 -0
- package/dist/plugins/browser.mjs +2 -0
- package/dist/plugins/expect.mjs +2 -0
- package/dist/plugins/mocker-automock.mjs +2 -0
- package/dist/plugins/mocker-browser.mjs +2 -0
- package/dist/plugins/mocker-node.mjs +2 -0
- package/dist/plugins/mocker-redirect.mjs +2 -0
- package/dist/plugins/mocker-register.mjs +2 -0
- package/dist/plugins/mocker.mjs +2 -0
- package/dist/plugins/pretty-format.mjs +2 -0
- package/dist/plugins/runner-types.mjs +2 -0
- package/dist/plugins/runner-utils.mjs +2 -0
- package/dist/plugins/runner.mjs +2 -0
- package/dist/plugins/snapshot-environment.mjs +2 -0
- package/dist/plugins/snapshot-manager.mjs +2 -0
- package/dist/plugins/snapshot.mjs +2 -0
- package/dist/plugins/spy.mjs +2 -0
- package/dist/plugins/utils-constants.mjs +2 -0
- package/dist/plugins/utils-diff.mjs +2 -0
- package/dist/plugins/utils-display.mjs +2 -0
- package/dist/plugins/utils-error.mjs +2 -0
- package/dist/plugins/utils-helpers.mjs +2 -0
- package/dist/plugins/utils-highlight.mjs +2 -0
- package/dist/plugins/utils-offset.mjs +2 -0
- package/dist/plugins/utils-resolver.mjs +2 -0
- package/dist/plugins/utils-serialize.mjs +2 -0
- package/dist/plugins/utils-source-map.mjs +2 -0
- package/dist/plugins/utils-timers.mjs +2 -0
- package/dist/plugins/utils.mjs +2 -0
- package/dist/reporters.d.ts +27 -0
- package/dist/reporters.js +24 -0
- package/dist/runners.d.ts +50 -0
- package/dist/runners.js +19 -0
- package/dist/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +4 -0
- package/dist/spy.js +1 -0
- package/dist/state.js +280 -0
- package/dist/suite.d.ts +5 -0
- package/dist/suite.js +6 -0
- package/dist/types.d.ts +69 -0
- package/dist/vendor/chai.d.mts +1 -0
- package/dist/vendor/chai.mjs +3577 -0
- package/dist/vendor/es-module-lexer.d.mts +193 -0
- package/dist/vendor/es-module-lexer.mjs +79 -0
- package/dist/vendor/estree-walker.d.mts +583 -0
- package/dist/vendor/estree-walker.mjs +339 -0
- package/dist/vendor/expect-type.d.mts +1574 -0
- package/dist/vendor/expect-type.mjs +214 -0
- package/dist/vendor/magic-string.d.mts +261 -0
- package/dist/vendor/magic-string.mjs +1700 -0
- package/dist/vendor/obug.d.mts +56 -0
- package/dist/vendor/obug.mjs +276 -0
- package/dist/vendor/pathe.d.mts +46 -0
- package/dist/vendor/pathe.mjs +496 -0
- package/dist/vendor/picomatch.d.mts +1 -0
- package/dist/vendor/picomatch.mjs +1855 -0
- package/dist/vendor/shared-3g9mwCWP.mjs +31 -0
- package/dist/vendor/std-env.d.mts +88 -0
- package/dist/vendor/std-env.mjs +159 -0
- package/dist/vendor/tinybench.d.mts +317 -0
- package/dist/vendor/tinybench.mjs +504 -0
- package/dist/vendor/tinyexec.d.mts +72 -0
- package/dist/vendor/tinyexec.mjs +637 -0
- package/dist/vendor/tinyglobby.d.mts +157 -0
- package/dist/vendor/tinyglobby.mjs +832 -0
- package/dist/vendor/tinyrainbow.d.mts +60 -0
- package/dist/vendor/tinyrainbow.mjs +93 -0
- package/dist/vendor/vitest_browser.mjs +2 -0
- package/dist/vendor/vitest_internal_browser.mjs +2 -0
- package/dist/vendor/vitest_runner.mjs +2 -0
- package/dist/vendor/vitest_runners.mjs +2 -0
- package/dist/worker.d.ts +32 -0
- package/dist/worker.js +48 -0
- package/dist/workers/forks.js +54 -0
- package/dist/workers/runVmTests.js +95 -0
- package/dist/workers/threads.js +55 -0
- package/dist/workers/vmForks.js +36 -0
- package/dist/workers/vmThreads.js +37 -0
- package/environments.d.ts +1 -0
- package/globals.d.ts +20 -0
- package/import-meta.d.ts +5 -0
- package/importMeta.d.ts +4 -0
- package/index.cjs +5 -0
- package/index.d.cts +1 -0
- package/jsdom.d.ts +6 -0
- package/mocker.d.ts +1 -0
- package/node.d.ts +1 -0
- package/optional-types.d.ts +7 -0
- package/package.json +335 -0
- package/reporters.d.ts +1 -0
- package/runners.d.ts +1 -0
- package/snapshot.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/suppress-warnings.cjs +21 -0
- package/vitest.mjs +2 -0
- package/worker.d.ts +1 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './chunk-_commonjsHelpers.js';
|
|
2
|
+
import c from '../../vendor/tinyrainbow.mjs';
|
|
3
|
+
|
|
4
|
+
var jsTokens_1;
|
|
5
|
+
var hasRequiredJsTokens;
|
|
6
|
+
|
|
7
|
+
function requireJsTokens () {
|
|
8
|
+
if (hasRequiredJsTokens) return jsTokens_1;
|
|
9
|
+
hasRequiredJsTokens = 1;
|
|
10
|
+
// Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
|
|
11
|
+
// License: MIT.
|
|
12
|
+
var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
|
|
13
|
+
RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
|
|
14
|
+
Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
|
|
15
|
+
Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
|
|
16
|
+
StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y;
|
|
17
|
+
NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
|
|
18
|
+
Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y;
|
|
19
|
+
WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
|
|
20
|
+
LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
|
|
21
|
+
MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y;
|
|
22
|
+
SingleLineComment = /\/\/.*/y;
|
|
23
|
+
JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
|
|
24
|
+
JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
|
|
25
|
+
JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y;
|
|
26
|
+
JSXText = /[^<>{}]+/y;
|
|
27
|
+
TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
|
|
28
|
+
TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
|
|
29
|
+
KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
|
|
30
|
+
KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
|
|
31
|
+
Newline = RegExp(LineTerminatorSequence.source);
|
|
32
|
+
jsTokens_1 = function*(input, {jsx = false} = {}) {
|
|
33
|
+
var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
|
|
34
|
+
({length} = input);
|
|
35
|
+
lastIndex = 0;
|
|
36
|
+
lastSignificantToken = "";
|
|
37
|
+
stack = [
|
|
38
|
+
{tag: "JS"}
|
|
39
|
+
];
|
|
40
|
+
braces = [];
|
|
41
|
+
parenNesting = 0;
|
|
42
|
+
postfixIncDec = false;
|
|
43
|
+
while (lastIndex < length) {
|
|
44
|
+
mode = stack[stack.length - 1];
|
|
45
|
+
switch (mode.tag) {
|
|
46
|
+
case "JS":
|
|
47
|
+
case "JSNonExpressionParen":
|
|
48
|
+
case "InterpolationInTemplate":
|
|
49
|
+
case "InterpolationInJSX":
|
|
50
|
+
if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
|
51
|
+
RegularExpressionLiteral.lastIndex = lastIndex;
|
|
52
|
+
if (match = RegularExpressionLiteral.exec(input)) {
|
|
53
|
+
lastIndex = RegularExpressionLiteral.lastIndex;
|
|
54
|
+
lastSignificantToken = match[0];
|
|
55
|
+
postfixIncDec = true;
|
|
56
|
+
yield ({
|
|
57
|
+
type: "RegularExpressionLiteral",
|
|
58
|
+
value: match[0],
|
|
59
|
+
closed: match[1] !== void 0 && match[1] !== "\\"
|
|
60
|
+
});
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
Punctuator.lastIndex = lastIndex;
|
|
65
|
+
if (match = Punctuator.exec(input)) {
|
|
66
|
+
punctuator = match[0];
|
|
67
|
+
nextLastIndex = Punctuator.lastIndex;
|
|
68
|
+
nextLastSignificantToken = punctuator;
|
|
69
|
+
switch (punctuator) {
|
|
70
|
+
case "(":
|
|
71
|
+
if (lastSignificantToken === "?NonExpressionParenKeyword") {
|
|
72
|
+
stack.push({
|
|
73
|
+
tag: "JSNonExpressionParen",
|
|
74
|
+
nesting: parenNesting
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
parenNesting++;
|
|
78
|
+
postfixIncDec = false;
|
|
79
|
+
break;
|
|
80
|
+
case ")":
|
|
81
|
+
parenNesting--;
|
|
82
|
+
postfixIncDec = true;
|
|
83
|
+
if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
|
|
84
|
+
stack.pop();
|
|
85
|
+
nextLastSignificantToken = "?NonExpressionParenEnd";
|
|
86
|
+
postfixIncDec = false;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case "{":
|
|
90
|
+
Punctuator.lastIndex = 0;
|
|
91
|
+
isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
|
|
92
|
+
braces.push(isExpression);
|
|
93
|
+
postfixIncDec = false;
|
|
94
|
+
break;
|
|
95
|
+
case "}":
|
|
96
|
+
switch (mode.tag) {
|
|
97
|
+
case "InterpolationInTemplate":
|
|
98
|
+
if (braces.length === mode.nesting) {
|
|
99
|
+
Template.lastIndex = lastIndex;
|
|
100
|
+
match = Template.exec(input);
|
|
101
|
+
lastIndex = Template.lastIndex;
|
|
102
|
+
lastSignificantToken = match[0];
|
|
103
|
+
if (match[1] === "${") {
|
|
104
|
+
lastSignificantToken = "?InterpolationInTemplate";
|
|
105
|
+
postfixIncDec = false;
|
|
106
|
+
yield ({
|
|
107
|
+
type: "TemplateMiddle",
|
|
108
|
+
value: match[0]
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
stack.pop();
|
|
112
|
+
postfixIncDec = true;
|
|
113
|
+
yield ({
|
|
114
|
+
type: "TemplateTail",
|
|
115
|
+
value: match[0],
|
|
116
|
+
closed: match[1] === "`"
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
case "InterpolationInJSX":
|
|
123
|
+
if (braces.length === mode.nesting) {
|
|
124
|
+
stack.pop();
|
|
125
|
+
lastIndex += 1;
|
|
126
|
+
lastSignificantToken = "}";
|
|
127
|
+
yield ({
|
|
128
|
+
type: "JSXPunctuator",
|
|
129
|
+
value: "}"
|
|
130
|
+
});
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
postfixIncDec = braces.pop();
|
|
135
|
+
nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
|
|
136
|
+
break;
|
|
137
|
+
case "]":
|
|
138
|
+
postfixIncDec = true;
|
|
139
|
+
break;
|
|
140
|
+
case "++":
|
|
141
|
+
case "--":
|
|
142
|
+
nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
|
|
143
|
+
break;
|
|
144
|
+
case "<":
|
|
145
|
+
if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
|
146
|
+
stack.push({tag: "JSXTag"});
|
|
147
|
+
lastIndex += 1;
|
|
148
|
+
lastSignificantToken = "<";
|
|
149
|
+
yield ({
|
|
150
|
+
type: "JSXPunctuator",
|
|
151
|
+
value: punctuator
|
|
152
|
+
});
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
postfixIncDec = false;
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
postfixIncDec = false;
|
|
159
|
+
}
|
|
160
|
+
lastIndex = nextLastIndex;
|
|
161
|
+
lastSignificantToken = nextLastSignificantToken;
|
|
162
|
+
yield ({
|
|
163
|
+
type: "Punctuator",
|
|
164
|
+
value: punctuator
|
|
165
|
+
});
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
Identifier.lastIndex = lastIndex;
|
|
169
|
+
if (match = Identifier.exec(input)) {
|
|
170
|
+
lastIndex = Identifier.lastIndex;
|
|
171
|
+
nextLastSignificantToken = match[0];
|
|
172
|
+
switch (match[0]) {
|
|
173
|
+
case "for":
|
|
174
|
+
case "if":
|
|
175
|
+
case "while":
|
|
176
|
+
case "with":
|
|
177
|
+
if (lastSignificantToken !== "." && lastSignificantToken !== "?.") {
|
|
178
|
+
nextLastSignificantToken = "?NonExpressionParenKeyword";
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
lastSignificantToken = nextLastSignificantToken;
|
|
182
|
+
postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
|
|
183
|
+
yield ({
|
|
184
|
+
type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
|
|
185
|
+
value: match[0]
|
|
186
|
+
});
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
StringLiteral.lastIndex = lastIndex;
|
|
190
|
+
if (match = StringLiteral.exec(input)) {
|
|
191
|
+
lastIndex = StringLiteral.lastIndex;
|
|
192
|
+
lastSignificantToken = match[0];
|
|
193
|
+
postfixIncDec = true;
|
|
194
|
+
yield ({
|
|
195
|
+
type: "StringLiteral",
|
|
196
|
+
value: match[0],
|
|
197
|
+
closed: match[2] !== void 0
|
|
198
|
+
});
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
NumericLiteral.lastIndex = lastIndex;
|
|
202
|
+
if (match = NumericLiteral.exec(input)) {
|
|
203
|
+
lastIndex = NumericLiteral.lastIndex;
|
|
204
|
+
lastSignificantToken = match[0];
|
|
205
|
+
postfixIncDec = true;
|
|
206
|
+
yield ({
|
|
207
|
+
type: "NumericLiteral",
|
|
208
|
+
value: match[0]
|
|
209
|
+
});
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
Template.lastIndex = lastIndex;
|
|
213
|
+
if (match = Template.exec(input)) {
|
|
214
|
+
lastIndex = Template.lastIndex;
|
|
215
|
+
lastSignificantToken = match[0];
|
|
216
|
+
if (match[1] === "${") {
|
|
217
|
+
lastSignificantToken = "?InterpolationInTemplate";
|
|
218
|
+
stack.push({
|
|
219
|
+
tag: "InterpolationInTemplate",
|
|
220
|
+
nesting: braces.length
|
|
221
|
+
});
|
|
222
|
+
postfixIncDec = false;
|
|
223
|
+
yield ({
|
|
224
|
+
type: "TemplateHead",
|
|
225
|
+
value: match[0]
|
|
226
|
+
});
|
|
227
|
+
} else {
|
|
228
|
+
postfixIncDec = true;
|
|
229
|
+
yield ({
|
|
230
|
+
type: "NoSubstitutionTemplate",
|
|
231
|
+
value: match[0],
|
|
232
|
+
closed: match[1] === "`"
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
case "JSXTag":
|
|
239
|
+
case "JSXTagEnd":
|
|
240
|
+
JSXPunctuator.lastIndex = lastIndex;
|
|
241
|
+
if (match = JSXPunctuator.exec(input)) {
|
|
242
|
+
lastIndex = JSXPunctuator.lastIndex;
|
|
243
|
+
nextLastSignificantToken = match[0];
|
|
244
|
+
switch (match[0]) {
|
|
245
|
+
case "<":
|
|
246
|
+
stack.push({tag: "JSXTag"});
|
|
247
|
+
break;
|
|
248
|
+
case ">":
|
|
249
|
+
stack.pop();
|
|
250
|
+
if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
|
|
251
|
+
nextLastSignificantToken = "?JSX";
|
|
252
|
+
postfixIncDec = true;
|
|
253
|
+
} else {
|
|
254
|
+
stack.push({tag: "JSXChildren"});
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
case "{":
|
|
258
|
+
stack.push({
|
|
259
|
+
tag: "InterpolationInJSX",
|
|
260
|
+
nesting: braces.length
|
|
261
|
+
});
|
|
262
|
+
nextLastSignificantToken = "?InterpolationInJSX";
|
|
263
|
+
postfixIncDec = false;
|
|
264
|
+
break;
|
|
265
|
+
case "/":
|
|
266
|
+
if (lastSignificantToken === "<") {
|
|
267
|
+
stack.pop();
|
|
268
|
+
if (stack[stack.length - 1].tag === "JSXChildren") {
|
|
269
|
+
stack.pop();
|
|
270
|
+
}
|
|
271
|
+
stack.push({tag: "JSXTagEnd"});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
lastSignificantToken = nextLastSignificantToken;
|
|
275
|
+
yield ({
|
|
276
|
+
type: "JSXPunctuator",
|
|
277
|
+
value: match[0]
|
|
278
|
+
});
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
JSXIdentifier.lastIndex = lastIndex;
|
|
282
|
+
if (match = JSXIdentifier.exec(input)) {
|
|
283
|
+
lastIndex = JSXIdentifier.lastIndex;
|
|
284
|
+
lastSignificantToken = match[0];
|
|
285
|
+
yield ({
|
|
286
|
+
type: "JSXIdentifier",
|
|
287
|
+
value: match[0]
|
|
288
|
+
});
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
JSXString.lastIndex = lastIndex;
|
|
292
|
+
if (match = JSXString.exec(input)) {
|
|
293
|
+
lastIndex = JSXString.lastIndex;
|
|
294
|
+
lastSignificantToken = match[0];
|
|
295
|
+
yield ({
|
|
296
|
+
type: "JSXString",
|
|
297
|
+
value: match[0],
|
|
298
|
+
closed: match[2] !== void 0
|
|
299
|
+
});
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
303
|
+
case "JSXChildren":
|
|
304
|
+
JSXText.lastIndex = lastIndex;
|
|
305
|
+
if (match = JSXText.exec(input)) {
|
|
306
|
+
lastIndex = JSXText.lastIndex;
|
|
307
|
+
lastSignificantToken = match[0];
|
|
308
|
+
yield ({
|
|
309
|
+
type: "JSXText",
|
|
310
|
+
value: match[0]
|
|
311
|
+
});
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
switch (input[lastIndex]) {
|
|
315
|
+
case "<":
|
|
316
|
+
stack.push({tag: "JSXTag"});
|
|
317
|
+
lastIndex++;
|
|
318
|
+
lastSignificantToken = "<";
|
|
319
|
+
yield ({
|
|
320
|
+
type: "JSXPunctuator",
|
|
321
|
+
value: "<"
|
|
322
|
+
});
|
|
323
|
+
continue;
|
|
324
|
+
case "{":
|
|
325
|
+
stack.push({
|
|
326
|
+
tag: "InterpolationInJSX",
|
|
327
|
+
nesting: braces.length
|
|
328
|
+
});
|
|
329
|
+
lastIndex++;
|
|
330
|
+
lastSignificantToken = "?InterpolationInJSX";
|
|
331
|
+
postfixIncDec = false;
|
|
332
|
+
yield ({
|
|
333
|
+
type: "JSXPunctuator",
|
|
334
|
+
value: "{"
|
|
335
|
+
});
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
WhiteSpace.lastIndex = lastIndex;
|
|
340
|
+
if (match = WhiteSpace.exec(input)) {
|
|
341
|
+
lastIndex = WhiteSpace.lastIndex;
|
|
342
|
+
yield ({
|
|
343
|
+
type: "WhiteSpace",
|
|
344
|
+
value: match[0]
|
|
345
|
+
});
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
LineTerminatorSequence.lastIndex = lastIndex;
|
|
349
|
+
if (match = LineTerminatorSequence.exec(input)) {
|
|
350
|
+
lastIndex = LineTerminatorSequence.lastIndex;
|
|
351
|
+
postfixIncDec = false;
|
|
352
|
+
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
|
353
|
+
lastSignificantToken = "?NoLineTerminatorHere";
|
|
354
|
+
}
|
|
355
|
+
yield ({
|
|
356
|
+
type: "LineTerminatorSequence",
|
|
357
|
+
value: match[0]
|
|
358
|
+
});
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
MultiLineComment.lastIndex = lastIndex;
|
|
362
|
+
if (match = MultiLineComment.exec(input)) {
|
|
363
|
+
lastIndex = MultiLineComment.lastIndex;
|
|
364
|
+
if (Newline.test(match[0])) {
|
|
365
|
+
postfixIncDec = false;
|
|
366
|
+
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
|
367
|
+
lastSignificantToken = "?NoLineTerminatorHere";
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
yield ({
|
|
371
|
+
type: "MultiLineComment",
|
|
372
|
+
value: match[0],
|
|
373
|
+
closed: match[1] !== void 0
|
|
374
|
+
});
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
SingleLineComment.lastIndex = lastIndex;
|
|
378
|
+
if (match = SingleLineComment.exec(input)) {
|
|
379
|
+
lastIndex = SingleLineComment.lastIndex;
|
|
380
|
+
postfixIncDec = false;
|
|
381
|
+
yield ({
|
|
382
|
+
type: "SingleLineComment",
|
|
383
|
+
value: match[0]
|
|
384
|
+
});
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
|
|
388
|
+
lastIndex += firstCodePoint.length;
|
|
389
|
+
lastSignificantToken = firstCodePoint;
|
|
390
|
+
postfixIncDec = false;
|
|
391
|
+
yield ({
|
|
392
|
+
type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
|
|
393
|
+
value: firstCodePoint
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return void 0;
|
|
397
|
+
};
|
|
398
|
+
return jsTokens_1;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
var jsTokensExports = /*@__PURE__*/ requireJsTokens();
|
|
402
|
+
var jsTokens = /*@__PURE__*/getDefaultExportFromCjs(jsTokensExports);
|
|
403
|
+
|
|
404
|
+
// src/index.ts
|
|
405
|
+
var reservedWords = {
|
|
406
|
+
keyword: [
|
|
407
|
+
"break",
|
|
408
|
+
"case",
|
|
409
|
+
"catch",
|
|
410
|
+
"continue",
|
|
411
|
+
"debugger",
|
|
412
|
+
"default",
|
|
413
|
+
"do",
|
|
414
|
+
"else",
|
|
415
|
+
"finally",
|
|
416
|
+
"for",
|
|
417
|
+
"function",
|
|
418
|
+
"if",
|
|
419
|
+
"return",
|
|
420
|
+
"switch",
|
|
421
|
+
"throw",
|
|
422
|
+
"try",
|
|
423
|
+
"var",
|
|
424
|
+
"const",
|
|
425
|
+
"while",
|
|
426
|
+
"with",
|
|
427
|
+
"new",
|
|
428
|
+
"this",
|
|
429
|
+
"super",
|
|
430
|
+
"class",
|
|
431
|
+
"extends",
|
|
432
|
+
"export",
|
|
433
|
+
"import",
|
|
434
|
+
"null",
|
|
435
|
+
"true",
|
|
436
|
+
"false",
|
|
437
|
+
"in",
|
|
438
|
+
"instanceof",
|
|
439
|
+
"typeof",
|
|
440
|
+
"void",
|
|
441
|
+
"delete"
|
|
442
|
+
],
|
|
443
|
+
strict: [
|
|
444
|
+
"implements",
|
|
445
|
+
"interface",
|
|
446
|
+
"let",
|
|
447
|
+
"package",
|
|
448
|
+
"private",
|
|
449
|
+
"protected",
|
|
450
|
+
"public",
|
|
451
|
+
"static",
|
|
452
|
+
"yield"
|
|
453
|
+
]
|
|
454
|
+
}, keywords = new Set(reservedWords.keyword), reservedWordsStrictSet = new Set(reservedWords.strict), sometimesKeywords = /* @__PURE__ */ new Set(["as", "async", "from", "get", "of", "set"]);
|
|
455
|
+
function isReservedWord(word) {
|
|
456
|
+
return word === "await" || word === "enum";
|
|
457
|
+
}
|
|
458
|
+
function isStrictReservedWord(word) {
|
|
459
|
+
return isReservedWord(word) || reservedWordsStrictSet.has(word);
|
|
460
|
+
}
|
|
461
|
+
function isKeyword(word) {
|
|
462
|
+
return keywords.has(word);
|
|
463
|
+
}
|
|
464
|
+
var BRACKET = /^[()[\]{}]$/, getTokenType = function(token) {
|
|
465
|
+
if (token.type === "IdentifierName") {
|
|
466
|
+
if (isKeyword(token.value) || isStrictReservedWord(token.value) || sometimesKeywords.has(token.value))
|
|
467
|
+
return "Keyword";
|
|
468
|
+
if (token.value[0] && token.value[0] !== token.value[0].toLowerCase())
|
|
469
|
+
return "IdentifierCapitalized";
|
|
470
|
+
}
|
|
471
|
+
return token.type === "Punctuator" && BRACKET.test(token.value) ? "Bracket" : token.type === "Invalid" && (token.value === "@" || token.value === "#") ? "Punctuator" : token.type;
|
|
472
|
+
};
|
|
473
|
+
function getCallableType(token) {
|
|
474
|
+
if (token.type === "IdentifierName")
|
|
475
|
+
return "IdentifierCallable";
|
|
476
|
+
if (token.type === "PrivateIdentifier")
|
|
477
|
+
return "PrivateIdentifierCallable";
|
|
478
|
+
throw new Error("Not a callable token");
|
|
479
|
+
}
|
|
480
|
+
var colorize = (defs, type, value) => {
|
|
481
|
+
let colorize2 = defs[type];
|
|
482
|
+
return colorize2 ? colorize2(value) : value;
|
|
483
|
+
}, highlightTokens = (defs, text, jsx) => {
|
|
484
|
+
let highlighted = "", lastPotentialCallable = null, stackedHighlight = "";
|
|
485
|
+
for (let token of jsTokens(text, { jsx })) {
|
|
486
|
+
let type = getTokenType(token);
|
|
487
|
+
if (type === "IdentifierName" || type === "PrivateIdentifier") {
|
|
488
|
+
lastPotentialCallable && (highlighted += colorize(defs, getTokenType(lastPotentialCallable), lastPotentialCallable.value) + stackedHighlight, stackedHighlight = ""), lastPotentialCallable = token;
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
if (lastPotentialCallable && (token.type === "WhiteSpace" || token.type === "LineTerminatorSequence" || token.type === "Punctuator" && (token.value === "?." || token.value === "!"))) {
|
|
492
|
+
stackedHighlight += colorize(defs, type, token.value);
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (stackedHighlight && !lastPotentialCallable && (highlighted += stackedHighlight, stackedHighlight = ""), lastPotentialCallable) {
|
|
496
|
+
let type2 = token.type === "Punctuator" && token.value === "(" ? getCallableType(lastPotentialCallable) : getTokenType(lastPotentialCallable);
|
|
497
|
+
highlighted += colorize(defs, type2, lastPotentialCallable.value) + stackedHighlight, stackedHighlight = "", lastPotentialCallable = null;
|
|
498
|
+
}
|
|
499
|
+
highlighted += colorize(defs, type, token.value);
|
|
500
|
+
}
|
|
501
|
+
return highlighted;
|
|
502
|
+
};
|
|
503
|
+
function highlight$1(code, options = { jsx: false, colors: {} }) {
|
|
504
|
+
return code && highlightTokens(options.colors || {}, code, options.jsx);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function getDefs(c) {
|
|
508
|
+
const Invalid = (text) => c.white(c.bgRed(c.bold(text)));
|
|
509
|
+
return {
|
|
510
|
+
Keyword: c.magenta,
|
|
511
|
+
IdentifierCapitalized: c.yellow,
|
|
512
|
+
Punctuator: c.yellow,
|
|
513
|
+
StringLiteral: c.green,
|
|
514
|
+
NoSubstitutionTemplate: c.green,
|
|
515
|
+
MultiLineComment: c.gray,
|
|
516
|
+
SingleLineComment: c.gray,
|
|
517
|
+
RegularExpressionLiteral: c.cyan,
|
|
518
|
+
NumericLiteral: c.blue,
|
|
519
|
+
TemplateHead: (text) => c.green(text.slice(0, text.length - 2)) + c.cyan(text.slice(-2)),
|
|
520
|
+
TemplateTail: (text) => c.cyan(text.slice(0, 1)) + c.green(text.slice(1)),
|
|
521
|
+
TemplateMiddle: (text) => c.cyan(text.slice(0, 1)) + c.green(text.slice(1, text.length - 2)) + c.cyan(text.slice(-2)),
|
|
522
|
+
IdentifierCallable: c.blue,
|
|
523
|
+
PrivateIdentifierCallable: (text) => `#${c.blue(text.slice(1))}`,
|
|
524
|
+
Invalid,
|
|
525
|
+
JSXString: c.green,
|
|
526
|
+
JSXIdentifier: c.yellow,
|
|
527
|
+
JSXInvalid: Invalid,
|
|
528
|
+
JSXPunctuator: c.yellow
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function highlight(code, options = { jsx: false }) {
|
|
532
|
+
return highlight$1(code, {
|
|
533
|
+
jsx: options.jsx,
|
|
534
|
+
colors: getDefs(options.colors || c)
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export { highlight };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { LoupeOptions, StringifyOptions } from './display.js';
|
|
2
|
+
export { DeferPromise } from './helpers.js';
|
|
3
|
+
export { SafeTimers } from './timers.js';
|
|
4
|
+
export { ArgumentsType, Arrayable, Awaitable, Constructable, DeepMerge, MergeInsertions, Nullable, ParsedStack, SerializedError, TestError } from './types.js';
|
|
5
|
+
import '../pretty-format/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const lineSplitRE: RegExp;
|
|
2
|
+
declare function positionToOffset(source: string, lineNumber: number, columnNumber: number): number;
|
|
3
|
+
declare function offsetToLineNumber(source: string, offset: number): number;
|
|
4
|
+
|
|
5
|
+
export { lineSplitRE, offsetToLineNumber, positionToOffset };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const lineSplitRE = /\r?\n/;
|
|
2
|
+
function positionToOffset(source, lineNumber, columnNumber) {
|
|
3
|
+
const lines = source.split(lineSplitRE);
|
|
4
|
+
const nl = /\r\n/.test(source) ? 2 : 1;
|
|
5
|
+
let start = 0;
|
|
6
|
+
if (lineNumber > lines.length) {
|
|
7
|
+
return source.length;
|
|
8
|
+
}
|
|
9
|
+
for (let i = 0; i < lineNumber - 1; i++) {
|
|
10
|
+
start += lines[i].length + nl;
|
|
11
|
+
}
|
|
12
|
+
return start + columnNumber;
|
|
13
|
+
}
|
|
14
|
+
function offsetToLineNumber(source, offset) {
|
|
15
|
+
if (offset > source.length) {
|
|
16
|
+
throw new Error(`offset is longer than source length! offset ${offset} > length ${source.length}`);
|
|
17
|
+
}
|
|
18
|
+
const lines = source.split(lineSplitRE);
|
|
19
|
+
const nl = /\r\n/.test(source) ? 2 : 1;
|
|
20
|
+
let counted = 0;
|
|
21
|
+
let line = 0;
|
|
22
|
+
for (; line < lines.length; line++) {
|
|
23
|
+
const lineLength = lines[line].length + nl;
|
|
24
|
+
if (counted + lineLength >= offset) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
counted += lineLength;
|
|
28
|
+
}
|
|
29
|
+
return line + 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { lineSplitRE, offsetToLineNumber, positionToOffset };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare function findNearestPackageData(basedir: string): {
|
|
2
|
+
type?: "module" | "commonjs";
|
|
3
|
+
};
|
|
4
|
+
declare function getCachedData<T>(cache: Map<string, T>, basedir: string, originalBasedir: string): NonNullable<T> | undefined;
|
|
5
|
+
declare function setCacheData<T>(cache: Map<string, T>, data: T, basedir: string, originalBasedir: string): void;
|
|
6
|
+
|
|
7
|
+
export { findNearestPackageData, getCachedData, setCacheData };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { j as join, d as dirname } from './chunk-pathe.M-eThtNZ.js';
|
|
3
|
+
|
|
4
|
+
const packageCache = new Map();
|
|
5
|
+
function findNearestPackageData(basedir) {
|
|
6
|
+
const originalBasedir = basedir;
|
|
7
|
+
while (basedir) {
|
|
8
|
+
var _tryStatSync;
|
|
9
|
+
const cached = getCachedData(packageCache, basedir, originalBasedir);
|
|
10
|
+
if (cached) {
|
|
11
|
+
return cached;
|
|
12
|
+
}
|
|
13
|
+
const pkgPath = join(basedir, "package.json");
|
|
14
|
+
if ((_tryStatSync = tryStatSync(pkgPath)) === null || _tryStatSync === void 0 ? void 0 : _tryStatSync.isFile()) {
|
|
15
|
+
const pkgData = JSON.parse(stripBomTag(fs.readFileSync(pkgPath, "utf8")));
|
|
16
|
+
if (packageCache) {
|
|
17
|
+
setCacheData(packageCache, pkgData, basedir, originalBasedir);
|
|
18
|
+
}
|
|
19
|
+
return pkgData;
|
|
20
|
+
}
|
|
21
|
+
const nextBasedir = dirname(basedir);
|
|
22
|
+
if (nextBasedir === basedir) {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
basedir = nextBasedir;
|
|
26
|
+
}
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
function stripBomTag(content) {
|
|
30
|
+
if (content.charCodeAt(0) === 65279) {
|
|
31
|
+
return content.slice(1);
|
|
32
|
+
}
|
|
33
|
+
return content;
|
|
34
|
+
}
|
|
35
|
+
function tryStatSync(file) {
|
|
36
|
+
try {
|
|
37
|
+
// The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
|
|
38
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
39
|
+
} catch {}
|
|
40
|
+
}
|
|
41
|
+
function getCachedData(cache, basedir, originalBasedir) {
|
|
42
|
+
const pkgData = cache.get(getFnpdCacheKey(basedir));
|
|
43
|
+
if (pkgData) {
|
|
44
|
+
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
45
|
+
cache.set(getFnpdCacheKey(dir), pkgData);
|
|
46
|
+
});
|
|
47
|
+
return pkgData;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function setCacheData(cache, data, basedir, originalBasedir) {
|
|
51
|
+
cache.set(getFnpdCacheKey(basedir), data);
|
|
52
|
+
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
53
|
+
cache.set(getFnpdCacheKey(dir), data);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function getFnpdCacheKey(basedir) {
|
|
57
|
+
return `fnpd_${basedir}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Traverse between `longerDir` (inclusive) and `shorterDir` (exclusive) and call `cb` for each dir.
|
|
61
|
+
* @param longerDir Longer dir path, e.g. `/User/foo/bar/baz`
|
|
62
|
+
* @param shorterDir Shorter dir path, e.g. `/User/foo`
|
|
63
|
+
*/
|
|
64
|
+
function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
65
|
+
while (longerDir !== shorterDir) {
|
|
66
|
+
cb(longerDir);
|
|
67
|
+
longerDir = dirname(longerDir);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { findNearestPackageData, getCachedData, setCacheData };
|