typenative 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +2 -2
- package/.github/workflows/npm-publish-github-packages.yml +2 -2
- package/CHANGELOG.md +442 -1
- package/CONTRIBUTION.md +2 -1
- package/README.md +73 -25
- package/bin/cli.js +2 -0
- package/bin/index.js +75 -5
- package/bin/main.js +2 -0
- package/bin/node/assert.js +2 -2
- package/bin/node/async_hooks.js +1 -1
- package/bin/node/buffer.js +16 -5
- package/bin/node/child_process.js +7 -7
- package/bin/node/cluster.js +3 -3
- package/bin/node/core.js +41 -0
- package/bin/node/crypto_keys.js +21 -21
- package/bin/node/dgram.js +1 -1
- package/bin/node/diagnostics_channel.js +3 -3
- package/bin/node/dns.js +2 -2
- package/bin/node/events.js +18 -13
- package/bin/node/fetch.js +2 -2
- package/bin/node/fs.js +3 -3
- package/bin/node/fs_watch.js +5 -5
- package/bin/node/http.js +3 -3
- package/bin/node/http2.js +3 -3
- package/bin/node/net.js +8 -8
- package/bin/node/path.js +17 -3
- package/bin/node/process.js +47 -11
- package/bin/node/punycode.js +2 -2
- package/bin/node/readline.js +1 -1
- package/bin/node/registry.js +4 -1
- package/bin/node/sqlite.js +6 -6
- package/bin/node/stream.js +81 -15
- package/bin/node/stream_web.js +10 -10
- package/bin/node/system_extra.js +3 -3
- package/bin/node/test.js +674 -366
- package/bin/node/test_coverage.js +187 -0
- package/bin/node/test_report.js +1392 -0
- package/bin/node/test_run.js +575 -0
- package/bin/node/timers.js +8 -6
- package/bin/node/tls.js +5 -5
- package/bin/node/url.js +1 -1
- package/bin/node/util.js +31 -7
- package/bin/node/util_extra.js +7 -7
- package/bin/node/webview.js +654 -0
- package/bin/node/worker_threads.js +1 -1
- package/bin/node/zlib.js +3 -3
- package/bin/parse-node.js +6 -2
- package/bin/regex_vm.js +2057 -0
- package/bin/transpiler.js +32872 -11265
- package/bin/typecheck-node.js +2 -1
- package/bin/version.js +1 -1
- package/conformance.md +515 -345
- package/examples/README.md +71 -11
- package/examples/angular-templates/README.md +139 -0
- package/examples/angular-templates/bench.mjs +173 -0
- package/examples/angular-templates/dom-type-globals.d.ts +21 -0
- package/examples/angular-templates/dom-type-stubs.ts +21 -0
- package/examples/angular-templates/main.ts +135 -0
- package/examples/angular-templates/parity.mjs +157 -0
- package/examples/angular-templates/run-node.mjs +69 -0
- package/examples/angular-templates/vendor/angular/compiler/LICENSE +21 -0
- package/examples/desktop-notes/README.md +106 -0
- package/examples/desktop-notes/bench.mjs +125 -0
- package/examples/desktop-notes/main.ts +131 -0
- package/examples/desktop-notes/package-lock.json +726 -0
- package/examples/desktop-notes/package.json +9 -0
- package/examples/desktop-notes/ui.ts +176 -0
- package/examples/dupe-finder/README.md +78 -0
- package/examples/dupe-finder/bench.mjs +120 -0
- package/examples/dupe-finder/main.ts +87 -0
- package/examples/fibonacci/README.md +7 -7
- package/examples/hello-world/README.md +6 -6
- package/examples/json-server/README.md +19 -18
- package/examples/mandelbrot-png/README.md +63 -0
- package/examples/mandelbrot-png/bench.mjs +95 -0
- package/examples/mandelbrot-png/main.ts +98 -0
- package/examples/mandelbrot-png/preview.png +0 -0
- package/examples/marked-cli/README.md +160 -0
- package/examples/marked-cli/bench.mjs +178 -0
- package/examples/marked-cli/main.ts +292 -0
- package/examples/marked-cli/parity.mjs +185 -0
- package/examples/marked-cli/vendor/marked/LICENSE +44 -0
- package/examples/marked-cli/vendor/marked/VENDOR.md +26 -0
- package/examples/openai-chat/README.md +148 -0
- package/examples/openai-chat/bench.mjs +175 -0
- package/examples/openai-chat/main.ts +488 -0
- package/examples/react-compiler/README.md +170 -0
- package/examples/react-compiler/bench.mjs +181 -0
- package/examples/react-compiler/main.ts +158 -0
- package/examples/react-compiler/parity.mjs +362 -0
- package/examples/react-compiler/run-node.mjs +88 -0
- package/examples/react-compiler/vendor/babel/LICENSE +22 -0
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +15 -0
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +51 -0
- package/examples/react-compiler/vendor/charcodes/package.json +25 -0
- package/examples/react-compiler/vendor/invariant/LICENSE +21 -0
- package/examples/react-compiler/vendor/invariant/invariant.cjs +51 -0
- package/examples/react-compiler/vendor/invariant/invariant.d.cts +11 -0
- package/examples/react-compiler/vendor/invariant/types/LICENSE +21 -0
- package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +19 -0
- package/examples/react-compiler/vendor/js-tokens/LICENSE +21 -0
- package/examples/react-compiler/vendor/js-tokens/index.cjs +23 -0
- package/examples/react-compiler/vendor/js-tokens/index.d.cts +13 -0
- package/examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt +20 -0
- package/examples/react-compiler/vendor/jsesc/jsesc.cjs +337 -0
- package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +384 -0
- package/examples/react-compiler/vendor/jsesc/types/LICENSE +21 -0
- package/examples/react-compiler/vendor/picocolors/LICENSE +15 -0
- package/examples/react-compiler/vendor/picocolors/picocolors.cjs +75 -0
- package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +5 -0
- package/examples/react-compiler/vendor/picocolors/types.d.ts +51 -0
- package/examples/react-compiler/vendor/react-compiler/LICENSE +21 -0
- package/examples/react-compiler/vendor/stubs/babel-core.ts +31 -0
- package/examples/react-compiler/vendor/stubs/debug.ts +18 -0
- package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +13 -0
- package/examples/react-compiler/vendor/stubs/pretty-format.ts +18 -0
- package/examples/react-compiler/vendor/zod/LICENSE +21 -0
- package/examples/react-compiler/vendor/zod-validation-error/LICENSE +9 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +5 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +49 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +48 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +50 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +6 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +126 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +39 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +78 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +2 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +131 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +54 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +40 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +76 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +76 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +27 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +27 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +13 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +61 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +38 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +20 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +5 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +8 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +11 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +20 -0
- package/examples/react-compiler/vendor.mjs +688 -0
- package/examples/todo-cli/README.md +69 -0
- package/examples/todo-cli/bench.mjs +89 -0
- package/examples/todo-cli/main.ts +92 -0
- package/examples/yaml-cli/README.md +146 -0
- package/examples/yaml-cli/bench.mjs +265 -0
- package/examples/yaml-cli/main.ts +29 -0
- package/examples/yaml-cli/parity.mjs +156 -0
- package/examples/yaml-cli/vendor/yaml/LICENSE +13 -0
- package/examples/yaml-cli/vendor/yaml/VENDOR.md +25 -0
- package/govendor/github.com/jchv/go-webview2/LICENSE +22 -0
- package/govendor/github.com/jchv/go-webview2/README.md +21 -0
- package/govendor/github.com/jchv/go-webview2/common.go +84 -0
- package/govendor/github.com/jchv/go-webview2/go.mod +3 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32.go +194 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32_386.go +14 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32_64bit.go +15 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_COLOR.go +8 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND.go +9 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_KEY_EVENT_KIND.go +10 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_MOVE_FOCUS_REASON.go +9 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_PHYSICAL_KEY_STATUS.go +10 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_WEB_RESOURCE_CONTEXT.go +23 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2AcceleratorKeyPressedEventArgs.go +78 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2AcceleratorKeyPressedEventHandler.go +52 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Controller.go +132 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Controller2.go +74 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2CreateCoreWebView2ControllerCompletedHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2NavigationCompletedEventArgs.go +17 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2NavigationCompletedEventHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Settings.go +270 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequest.go +43 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequestedEventArgs.go +51 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequestedEventHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceResponse.go +21 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2_2.go +21 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2_3.go +60 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebViewSettings.go +396 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium.go +361 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_386.go +24 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_amd64.go +22 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_arm64.go +26 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc.go +13 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc_go17.go +51 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc_go18.go +16 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/corewebview2.go +411 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/guid.go +223 -0
- package/govendor/github.com/jchv/go-webview2/webview.go +482 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/README.md +3 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module.go +153 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_386.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_amd64.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_arm64.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/arm64/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/x64/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/x86/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-winloader/LICENSE.md +7 -0
- package/govendor/github.com/jchv/go-winloader/README.md +124 -0
- package/govendor/github.com/jchv/go-winloader/common.go +11 -0
- package/govendor/github.com/jchv/go-winloader/go.mod +3 -0
- package/govendor/github.com/jchv/go-winloader/internal/loader/loader.go +25 -0
- package/govendor/github.com/jchv/go-winloader/internal/loader/machine.go +53 -0
- package/govendor/github.com/jchv/go-winloader/internal/memloader/cache.go +42 -0
- package/govendor/github.com/jchv/go-winloader/internal/memloader/loader.go +253 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/export.go +76 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/format.go +522 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/import.go +106 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/module.go +91 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/reloc.go +177 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/util.go +40 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/common.go +55 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/memory_other.go +71 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/memory_windows.go +179 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/hacks_other.go +17 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/hacks_windows.go +73 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/loader_windows.go +64 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/machine_windows.go +32 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_386.go +9 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_amd64.go +9 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_arm64.go +9 -0
- package/govendor/github.com/jchv/go-winloader/loader_other.go +24 -0
- package/govendor/github.com/jchv/go-winloader/loader_windows.go +33 -0
- package/govendor/manifest.txt +3 -1
- package/package.json +8 -5
- package/performance/README.md +195 -0
- package/performance/any-dynamic.ts +21 -0
- package/performance/any-record-view.ts +20 -0
- package/performance/arr-hof.ts +21 -0
- package/performance/arr-push-index.ts +15 -0
- package/performance/arr-sort.ts +21 -0
- package/performance/async-await.ts +24 -0
- package/performance/class-dispatch.ts +52 -0
- package/performance/events-emit.ts +27 -0
- package/performance/exc-throw-rare.ts +25 -0
- package/performance/exc-try-catch.ts +26 -0
- package/performance/fn-closures.ts +29 -0
- package/performance/fn-recursion-tree.ts +31 -0
- package/performance/gen-for-of.ts +46 -0
- package/performance/json-roundtrip.ts +27 -0
- package/performance/map-delete.ts +24 -0
- package/performance/map-string-keys.ts +22 -0
- package/performance/num-arith-loop.ts +14 -0
- package/performance/num-bitwise.ts +21 -0
- package/performance/num-mod-int.ts +16 -0
- package/performance/num-to-string.ts +16 -0
- package/performance/obj-alloc.ts +32 -0
- package/performance/regex-exec.ts +29 -0
- package/performance/regex-site.ts +28 -0
- package/performance/set-ops.ts +20 -0
- package/performance/str-char-scan.ts +35 -0
- package/performance/str-concat-plus.ts +18 -0
- package/performance/str-concat.ts +24 -0
- package/performance/str-short-scan.ts +26 -0
- package/performance/str-split-join.ts +23 -0
- package/performance/str-template.ts +16 -0
- package/performance/union-switch.ts +57 -0
- package/tsparser/check.go +2 -1
- package/tsparser/main.go +5 -0
- package/types/typenative-npm.d.ts +193 -4
- package/types/typenative.d.ts +138 -41
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
export = jsesc;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This function takes a value and returns an escaped version of the value where any characters
|
|
5
|
+
* that are not printable ASCII symbols are escaped using the shortest possible (but valid)
|
|
6
|
+
* escape sequences for use in JavaScript strings. The first supported value type is strings.
|
|
7
|
+
* Instead of a string, the value can also be an array, an object, a map, a set, or a buffer.
|
|
8
|
+
* In such cases, jsesc returns a stringified version of the value where any characters that
|
|
9
|
+
* are not printable ASCII symbols are escaped in the same way.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import jsesc = require('jsesc');
|
|
13
|
+
*
|
|
14
|
+
* jsesc('Ich ♥ Bücher');
|
|
15
|
+
* // → 'Ich \\u2665 B\\xFCcher'
|
|
16
|
+
*
|
|
17
|
+
* jsesc('foo 𝌆 bar');
|
|
18
|
+
* // → 'foo \\uD834\\uDF06 bar'
|
|
19
|
+
*
|
|
20
|
+
* // Escaping an array
|
|
21
|
+
* jsesc([
|
|
22
|
+
* 'Ich ♥ Bücher', 'foo 𝌆 bar'
|
|
23
|
+
* ]);
|
|
24
|
+
* // → '[\'Ich \\u2665 B\\xFCcher\',\'foo \\uD834\\uDF06 bar\']'
|
|
25
|
+
*
|
|
26
|
+
* // Escaping an object
|
|
27
|
+
* jsesc({
|
|
28
|
+
* 'Ich ♥ Bücher': 'foo 𝌆 bar'
|
|
29
|
+
* });
|
|
30
|
+
* // → '{\'Ich \\u2665 B\\xFCcher\':\'foo \\uD834\\uDF06 bar\'}'
|
|
31
|
+
*/
|
|
32
|
+
declare function jsesc(argument: any, opts?: jsesc.Opts): string;
|
|
33
|
+
|
|
34
|
+
declare namespace jsesc {
|
|
35
|
+
/**
|
|
36
|
+
* A string representing the semantic version number.
|
|
37
|
+
*/
|
|
38
|
+
const version: string;
|
|
39
|
+
|
|
40
|
+
interface Opts {
|
|
41
|
+
/**
|
|
42
|
+
* The value `'single'` for the `quotes` option means that any occurrences of `'` in the input string are
|
|
43
|
+
* escaped as `\'`, so that the output can be used in a string literal wrapped in single quotes. If you want
|
|
44
|
+
* to use the output as part of a string literal wrapped in double quotes, set the `quotes` option to
|
|
45
|
+
* `'double'`. If you want to use the output as part of a template literal (i.e. wrapped in backticks), set
|
|
46
|
+
* the `quotes` option to `'backtick'`.
|
|
47
|
+
*
|
|
48
|
+
* @default 'single'
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* import jsesc = require('jsesc');
|
|
52
|
+
*
|
|
53
|
+
* jsesc('`Lorem` ipsum "dolor" sit \'amet\' etc.');
|
|
54
|
+
* // → 'Lorem ipsum "dolor" sit \\\'amet\\\' etc.'
|
|
55
|
+
*
|
|
56
|
+
* jsesc('`Lorem` ipsum "dolor" sit \'amet\' etc.', {
|
|
57
|
+
* quotes: 'single'
|
|
58
|
+
* });
|
|
59
|
+
* // → '`Lorem` ipsum "dolor" sit \\\'amet\\\' etc.'
|
|
60
|
+
* // → "`Lorem` ipsum \"dolor\" sit \\'amet\\' etc."
|
|
61
|
+
*
|
|
62
|
+
* jsesc('`Lorem` ipsum "dolor" sit \'amet\' etc.', {
|
|
63
|
+
* quotes: 'double'
|
|
64
|
+
* });
|
|
65
|
+
* // → '`Lorem` ipsum \\"dolor\\" sit \'amet\' etc.'
|
|
66
|
+
* // → "`Lorem` ipsum \\\"dolor\\\" sit 'amet' etc."
|
|
67
|
+
*
|
|
68
|
+
* jsesc('`Lorem` ipsum "dolor" sit \'amet\' etc.', {
|
|
69
|
+
* quotes: 'backtick'
|
|
70
|
+
* });
|
|
71
|
+
* // → '\\`Lorem\\` ipsum "dolor" sit \'amet\' etc.'
|
|
72
|
+
* // → "\\`Lorem\\` ipsum \"dolor\" sit 'amet' etc."
|
|
73
|
+
* // → `\\\`Lorem\\\` ipsum "dolor" sit 'amet' etc.`
|
|
74
|
+
*
|
|
75
|
+
* // This setting also affects the output for arrays and objects:
|
|
76
|
+
* jsesc({ 'Ich ♥ Bücher': 'foo 𝌆 bar' }, {
|
|
77
|
+
* quotes: 'double'
|
|
78
|
+
* });
|
|
79
|
+
* // → '{"Ich \\u2665 B\\xFCcher":"foo \\uD834\\uDF06 bar"}'
|
|
80
|
+
*
|
|
81
|
+
* jsesc([ 'Ich ♥ Bücher', 'foo 𝌆 bar' ], {
|
|
82
|
+
* quotes: 'double'
|
|
83
|
+
* });
|
|
84
|
+
* // → '["Ich \\u2665 B\\xFCcher","foo \\uD834\\uDF06 bar"]'
|
|
85
|
+
*/
|
|
86
|
+
quotes?: "single" | "double" | "backtick" | undefined;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The value `'decimal'` for the `numbers` option means that any numeric values are represented using decimal
|
|
90
|
+
* integer literals. Other valid options are `binary`, `octal`, and `hexadecimal`, which result in binary
|
|
91
|
+
* integer literals, octal integer literals, and hexadecimal integer literals, respectively.
|
|
92
|
+
*
|
|
93
|
+
* @default 'decimal'
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* import jsesc = require('jsesc');
|
|
97
|
+
*
|
|
98
|
+
* jsesc(42, {
|
|
99
|
+
* numbers: 'binary'
|
|
100
|
+
* });
|
|
101
|
+
* // → '0b101010'
|
|
102
|
+
*
|
|
103
|
+
* jsesc(42, {
|
|
104
|
+
* numbers: 'octal'
|
|
105
|
+
* });
|
|
106
|
+
* // → '0o52'
|
|
107
|
+
*
|
|
108
|
+
* jsesc(42, {
|
|
109
|
+
* numbers: 'decimal'
|
|
110
|
+
* });
|
|
111
|
+
* // → '42'
|
|
112
|
+
*
|
|
113
|
+
* jsesc(42, {
|
|
114
|
+
* numbers: 'hexadecimal'
|
|
115
|
+
* });
|
|
116
|
+
* // → '0x2A'
|
|
117
|
+
*/
|
|
118
|
+
numbers?: "binary" | "octal" | "decimal" | "hexadecimal" | undefined;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* When enabled, the output is a valid JavaScript string literal wrapped in quotes. The type of quotes can be
|
|
122
|
+
* specified through the `quotes` setting.
|
|
123
|
+
*
|
|
124
|
+
* @default false (disabled)
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* import jsesc = require('jsesc');
|
|
128
|
+
*
|
|
129
|
+
* jsesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
|
|
130
|
+
* quotes: 'single',
|
|
131
|
+
* wrap: true
|
|
132
|
+
* });
|
|
133
|
+
* // → '\'Lorem ipsum "dolor" sit \\\'amet\\\' etc.\''
|
|
134
|
+
* // → "\'Lorem ipsum \"dolor\" sit \\\'amet\\\' etc.\'"
|
|
135
|
+
*
|
|
136
|
+
* jsesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
|
|
137
|
+
* quotes: 'double',
|
|
138
|
+
* wrap: true
|
|
139
|
+
* });
|
|
140
|
+
* // → '"Lorem ipsum \\"dolor\\" sit \'amet\' etc."'
|
|
141
|
+
* // → "\"Lorem ipsum \\\"dolor\\\" sit \'amet\' etc.\""
|
|
142
|
+
*/
|
|
143
|
+
wrap?: boolean | undefined;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* When enabled, any astral Unicode symbols in the input are escaped using
|
|
147
|
+
* [ECMAScript 6 Unicode code point escape sequences](https://mathiasbynens.be/notes/javascript-escapes#unicode-code-point)
|
|
148
|
+
* instead of using separate escape sequences for each surrogate half. If backwards compatibility with ES5
|
|
149
|
+
* environments is a concern, don’t enable this setting. If the `json` setting is enabled, the value for the
|
|
150
|
+
* `es6` setting is ignored (as if it was `false`).
|
|
151
|
+
*
|
|
152
|
+
* @default false (disabled)
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* import jsesc = require('jsesc');
|
|
156
|
+
*
|
|
157
|
+
* // By default, the `es6` option is disabled:
|
|
158
|
+
* jsesc('foo 𝌆 bar 💩 baz');
|
|
159
|
+
* // → 'foo \\uD834\\uDF06 bar \\uD83D\\uDCA9 baz'
|
|
160
|
+
*
|
|
161
|
+
* // To explicitly disable it:
|
|
162
|
+
* jsesc('foo 𝌆 bar 💩 baz', {
|
|
163
|
+
* es6: false
|
|
164
|
+
* });
|
|
165
|
+
* // → 'foo \\uD834\\uDF06 bar \\uD83D\\uDCA9 baz'
|
|
166
|
+
*
|
|
167
|
+
* // To enable it:
|
|
168
|
+
* jsesc('foo 𝌆 bar 💩 baz', {
|
|
169
|
+
* es6: true
|
|
170
|
+
* });
|
|
171
|
+
* // → 'foo \\u{1D306} bar \\u{1F4A9} baz'
|
|
172
|
+
*/
|
|
173
|
+
es6?: boolean | undefined;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* When enabled, all the symbols in the output are escaped — even printable ASCII symbols.
|
|
177
|
+
* This setting also affects the output for string literals within arrays and objects.
|
|
178
|
+
*
|
|
179
|
+
* @default false (disabled)
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* import jsesc = require('jsesc');
|
|
183
|
+
*
|
|
184
|
+
* jsesc('lolwat"foo\'bar', {
|
|
185
|
+
* escapeEverything: true
|
|
186
|
+
* });
|
|
187
|
+
* // → '\\x6C\\x6F\\x6C\\x77\\x61\\x74\\"\\x66\\x6F\\x6F\\\'\\x62\\x61\\x72'
|
|
188
|
+
* // → "\\x6C\\x6F\\x6C\\x77\\x61\\x74\\\"\\x66\\x6F\\x6F\\'\\x62\\x61\\x72"
|
|
189
|
+
*/
|
|
190
|
+
escapeEverything?: boolean | undefined;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* When enabled, only a limited set of symbols in the output are escaped:
|
|
194
|
+
*
|
|
195
|
+
* - U+0000 `\0`
|
|
196
|
+
* - U+0008 `\b`
|
|
197
|
+
* - U+0009 `\t`
|
|
198
|
+
* - U+000A `\n`
|
|
199
|
+
* - U+000C `\f`
|
|
200
|
+
* - U+000D `\r`
|
|
201
|
+
* - U+005C `\\`
|
|
202
|
+
* - U+2028 `\u2028`
|
|
203
|
+
* - U+2029 `\u2029`
|
|
204
|
+
* - whatever symbol is being used for wrapping string literals (based on the `quotes` option)
|
|
205
|
+
* - [lone surrogates](https://esdiscuss.org/topic/code-points-vs-unicode-scalar-values#content-14)
|
|
206
|
+
*
|
|
207
|
+
* Note: with this option enabled, jsesc output is no longer guaranteed to be ASCII-safe.
|
|
208
|
+
*
|
|
209
|
+
* @default false (disabled)
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* import jsesc = require('jsesc');
|
|
213
|
+
*
|
|
214
|
+
* jsesc('foo\u2029bar\nbaz©qux𝌆flops', {
|
|
215
|
+
* minimal: false
|
|
216
|
+
* });
|
|
217
|
+
* // → 'foo\\u2029bar\\nbaz©qux𝌆flops'
|
|
218
|
+
*/
|
|
219
|
+
minimal?: boolean | undefined;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* When enabled, occurrences of [`</script` and `</style`](https://mathiasbynens.be/notes/etago) in the output
|
|
223
|
+
* are escaped as `<\/script` and `<\/style`, and [`<!--`](https://mathiasbynens.be/notes/etago#comment-8) is
|
|
224
|
+
* escaped as `\x3C!--` (or `\u003C!--` when the `json` option is enabled). This setting is useful when jsesc’s
|
|
225
|
+
* output ends up as part of a `<script>` or `<style>` element in an HTML document.
|
|
226
|
+
*
|
|
227
|
+
* @default false (disabled)
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* import jsesc = require('jsesc');
|
|
231
|
+
*
|
|
232
|
+
* jsesc('foo</script>bar', {
|
|
233
|
+
* isScriptContext: true
|
|
234
|
+
* });
|
|
235
|
+
* // → 'foo<\\/script>bar'
|
|
236
|
+
*/
|
|
237
|
+
isScriptContext?: boolean | undefined;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* When enabled, the output for arrays and objects is as compact as possible; it’s not formatted nicely.
|
|
241
|
+
*
|
|
242
|
+
* @default true (enabled)
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* import jsesc = require('jsesc');
|
|
246
|
+
*
|
|
247
|
+
* jsesc({ 'Ich ♥ Bücher': 'foo 𝌆 bar' }, {
|
|
248
|
+
* compact: true // this is the default
|
|
249
|
+
* });
|
|
250
|
+
* // → '{\'Ich \u2665 B\xFCcher\':\'foo \uD834\uDF06 bar\'}'
|
|
251
|
+
*
|
|
252
|
+
* jsesc({ 'Ich ♥ Bücher': 'foo 𝌆 bar' }, {
|
|
253
|
+
* compact: false
|
|
254
|
+
* });
|
|
255
|
+
* // → '{\n\t\'Ich \u2665 B\xFCcher\': \'foo \uD834\uDF06 bar\'\n}'
|
|
256
|
+
*
|
|
257
|
+
* jsesc([ 'Ich ♥ Bücher', 'foo 𝌆 bar' ], {
|
|
258
|
+
* compact: false
|
|
259
|
+
* });
|
|
260
|
+
* // → '[\n\t\'Ich \u2665 B\xFCcher\',\n\t\'foo \uD834\uDF06 bar\'\n]'
|
|
261
|
+
*/
|
|
262
|
+
compact?: boolean | undefined;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* When the `compact` setting is disabled (`false`), the value of the `indent` option is used to format the
|
|
266
|
+
* output for arrays and objects. This setting has no effect on the output for strings.
|
|
267
|
+
*
|
|
268
|
+
* @default '\t'
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* import jsesc = require('jsesc');
|
|
272
|
+
*
|
|
273
|
+
* jsesc({ 'Ich ♥ Bücher': 'foo 𝌆 bar' }, {
|
|
274
|
+
* compact: false,
|
|
275
|
+
* indent: '\t' // this is the default
|
|
276
|
+
* });
|
|
277
|
+
* // → '{\n\t\'Ich \u2665 B\xFCcher\': \'foo \uD834\uDF06 bar\'\n}'
|
|
278
|
+
*
|
|
279
|
+
* jsesc({ 'Ich ♥ Bücher': 'foo 𝌆 bar' }, {
|
|
280
|
+
* compact: false,
|
|
281
|
+
* indent: ' '
|
|
282
|
+
* });
|
|
283
|
+
* // → '{\n \'Ich \u2665 B\xFCcher\': \'foo \uD834\uDF06 bar\'\n}'
|
|
284
|
+
*
|
|
285
|
+
* jsesc([ 'Ich ♥ Bücher', 'foo 𝌆 bar' ], {
|
|
286
|
+
* compact: false,
|
|
287
|
+
* indent: ' '
|
|
288
|
+
* });
|
|
289
|
+
* // → '[\n \'Ich \u2665 B\xFCcher\',\n\ t\'foo \uD834\uDF06 bar\'\n]'
|
|
290
|
+
*/
|
|
291
|
+
indent?: string | undefined;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* It represents the current indentation level, i.e. the number of times the value of the `indent` option is
|
|
295
|
+
* repeated.
|
|
296
|
+
*
|
|
297
|
+
* @default 0
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* import jsesc = require('jsesc');
|
|
301
|
+
*
|
|
302
|
+
* jsesc(['a', 'b', 'c'], {
|
|
303
|
+
* compact: false,
|
|
304
|
+
* indentLevel: 1
|
|
305
|
+
* });
|
|
306
|
+
* // → '[\n\t\t\'a\',\n\t\t\'b\',\n\t\t\'c\'\n\t]'
|
|
307
|
+
*
|
|
308
|
+
* jsesc(['a', 'b', 'c'], {
|
|
309
|
+
* compact: false,
|
|
310
|
+
* indentLevel: 2
|
|
311
|
+
* });
|
|
312
|
+
* // → '[\n\t\t\t\'a\',\n\t\t\t\'b\',\n\t\t\t\'c\'\n\t\t]'
|
|
313
|
+
*/
|
|
314
|
+
indentLevel?: number | undefined;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* When enabled, the output is valid JSON.
|
|
318
|
+
* [Hexadecimal character escape sequences](https://mathiasbynens.be/notes/javascript-escapes#hexadecimal) and
|
|
319
|
+
* [the `\v` or `\0` escape sequences](https://mathiasbynens.be/notes/javascript-escapes#single) are not used.
|
|
320
|
+
* Setting `json: true` implies `quotes: 'double', wrap: true, es6: false`, although these values can still be
|
|
321
|
+
* overridden if needed — but in such cases, the output won’t be valid JSON anymore.
|
|
322
|
+
*
|
|
323
|
+
* **Note:** Using this option on objects or arrays that contain non-string values relies on `JSON.stringify()`.
|
|
324
|
+
* For legacy environments like IE ≤ 7, use [a `JSON` polyfill](http://bestiejs.github.io/json3/).
|
|
325
|
+
*
|
|
326
|
+
* @default false (disabled)
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* import jsesc = require('jsesc');
|
|
330
|
+
*
|
|
331
|
+
* jsesc('foo\x00bar\xFF\uFFFDbaz', {
|
|
332
|
+
* json: true
|
|
333
|
+
* });
|
|
334
|
+
* // → '"foo\\u0000bar\\u00FF\\uFFFDbaz"'
|
|
335
|
+
*
|
|
336
|
+
* jsesc({ 'foo\x00bar\xFF\uFFFDbaz': 'foo\x00bar\xFF\uFFFDbaz' }, {
|
|
337
|
+
* json: true
|
|
338
|
+
* });
|
|
339
|
+
* // → '{"foo\\u0000bar\\u00FF\\uFFFDbaz":"foo\\u0000bar\\u00FF\\uFFFDbaz"}'
|
|
340
|
+
*
|
|
341
|
+
* jsesc([ 'foo\x00bar\xFF\uFFFDbaz', 'foo\x00bar\xFF\uFFFDbaz' ], {
|
|
342
|
+
* json: true
|
|
343
|
+
* });
|
|
344
|
+
* // → '["foo\\u0000bar\\u00FF\\uFFFDbaz","foo\\u0000bar\\u00FF\\uFFFDbaz"]'
|
|
345
|
+
*
|
|
346
|
+
* // Values that are acceptable in JSON but aren’t strings, arrays, or object
|
|
347
|
+
* // literals can’t be escaped, so they’ll just be preserved:
|
|
348
|
+
* jsesc([ 'foo\x00bar', [1, '©', { 'foo': true, 'qux': null }], 42 ], {
|
|
349
|
+
* json: true
|
|
350
|
+
* });
|
|
351
|
+
* // → '["foo\\u0000bar",[1,"\\u00A9",{"foo":true,"qux":null}],42]'
|
|
352
|
+
* // Values that aren’t allowed in JSON are run through `JSON.stringify()`:
|
|
353
|
+
* jsesc([ undefined, -Infinity ], {
|
|
354
|
+
* json: true
|
|
355
|
+
* });
|
|
356
|
+
* // → '[null,null]'
|
|
357
|
+
*/
|
|
358
|
+
json?: boolean | undefined;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* When enabled, any alphabetical hexadecimal digits in escape sequences as well as any hexadecimal integer
|
|
362
|
+
* literals (see the `numbers` option) in the output are in lowercase.
|
|
363
|
+
*
|
|
364
|
+
* @default false (disabled)
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* import jsesc = require('jsesc');
|
|
368
|
+
*
|
|
369
|
+
* jsesc('Ich ♥ Bücher', {
|
|
370
|
+
* lowercaseHex: true
|
|
371
|
+
* });
|
|
372
|
+
* // → 'Ich \\u2665 B\\xfccher'
|
|
373
|
+
* // ^^
|
|
374
|
+
*
|
|
375
|
+
* jsesc(42, {
|
|
376
|
+
* numbers: 'hexadecimal',
|
|
377
|
+
* lowercaseHex: true
|
|
378
|
+
* });
|
|
379
|
+
* // → '0x2a'
|
|
380
|
+
* // ^^
|
|
381
|
+
*/
|
|
382
|
+
lowercaseHex?: boolean | undefined;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {}
|
|
2
|
+
let isColorSupported =
|
|
3
|
+
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
4
|
+
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI)
|
|
5
|
+
|
|
6
|
+
let formatter = (open, close, replace = open) =>
|
|
7
|
+
input => {
|
|
8
|
+
let string = "" + input, index = string.indexOf(close, open.length)
|
|
9
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let replaceClose = (string, close, replace, index) => {
|
|
13
|
+
let result = "", cursor = 0
|
|
14
|
+
do {
|
|
15
|
+
result += string.substring(cursor, index) + replace
|
|
16
|
+
cursor = index + close.length
|
|
17
|
+
index = string.indexOf(close, cursor)
|
|
18
|
+
} while (~index)
|
|
19
|
+
return result + string.substring(cursor)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let createColors = (enabled = isColorSupported) => {
|
|
23
|
+
let f = enabled ? formatter : () => String
|
|
24
|
+
return {
|
|
25
|
+
isColorSupported: enabled,
|
|
26
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
27
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
28
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
29
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
30
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
31
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
32
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
33
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
34
|
+
|
|
35
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
36
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
37
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
38
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
39
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
40
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
41
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
42
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
43
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
44
|
+
|
|
45
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
46
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
47
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
48
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
49
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
50
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
51
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
52
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
53
|
+
|
|
54
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
55
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
56
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
57
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
58
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
59
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
60
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
61
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
62
|
+
|
|
63
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
64
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
65
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
66
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
67
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
68
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
69
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
70
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = createColors()
|
|
75
|
+
module.exports.createColors = createColors
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type Formatter = (input: string | number | null | undefined) => string
|
|
2
|
+
|
|
3
|
+
export interface Colors {
|
|
4
|
+
isColorSupported: boolean
|
|
5
|
+
|
|
6
|
+
reset: Formatter
|
|
7
|
+
bold: Formatter
|
|
8
|
+
dim: Formatter
|
|
9
|
+
italic: Formatter
|
|
10
|
+
underline: Formatter
|
|
11
|
+
inverse: Formatter
|
|
12
|
+
hidden: Formatter
|
|
13
|
+
strikethrough: Formatter
|
|
14
|
+
|
|
15
|
+
black: Formatter
|
|
16
|
+
red: Formatter
|
|
17
|
+
green: Formatter
|
|
18
|
+
yellow: Formatter
|
|
19
|
+
blue: Formatter
|
|
20
|
+
magenta: Formatter
|
|
21
|
+
cyan: Formatter
|
|
22
|
+
white: Formatter
|
|
23
|
+
gray: Formatter
|
|
24
|
+
|
|
25
|
+
bgBlack: Formatter
|
|
26
|
+
bgRed: Formatter
|
|
27
|
+
bgGreen: Formatter
|
|
28
|
+
bgYellow: Formatter
|
|
29
|
+
bgBlue: Formatter
|
|
30
|
+
bgMagenta: Formatter
|
|
31
|
+
bgCyan: Formatter
|
|
32
|
+
bgWhite: Formatter
|
|
33
|
+
|
|
34
|
+
blackBright: Formatter
|
|
35
|
+
redBright: Formatter
|
|
36
|
+
greenBright: Formatter
|
|
37
|
+
yellowBright: Formatter
|
|
38
|
+
blueBright: Formatter
|
|
39
|
+
magentaBright: Formatter
|
|
40
|
+
cyanBright: Formatter
|
|
41
|
+
whiteBright: Formatter
|
|
42
|
+
|
|
43
|
+
bgBlackBright: Formatter
|
|
44
|
+
bgRedBright: Formatter
|
|
45
|
+
bgGreenBright: Formatter
|
|
46
|
+
bgYellowBright: Formatter
|
|
47
|
+
bgBlueBright: Formatter
|
|
48
|
+
bgMagentaBright: Formatter
|
|
49
|
+
bgCyanBright: Formatter
|
|
50
|
+
bgWhiteBright: Formatter
|
|
51
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Stand-in for @babel/core. The React Compiler imports it for three things:
|
|
2
|
+
// the `NodePath` class (which @babel/core re-exports from @babel/traverse),
|
|
3
|
+
// the types of a Babel plugin (`PluginObj`, `PluginItem`, `BabelFileResult`),
|
|
4
|
+
// and `transformFromAstSync`, which only `runBabelPluginReactCompiler` (a
|
|
5
|
+
// test helper that main.ts never calls) uses to run the compiler as a Babel
|
|
6
|
+
// plugin. main.ts drives the compiler without @babel/core: @babel/parser
|
|
7
|
+
// parses, @babel/traverse hands the compiler the Program path, and
|
|
8
|
+
// @babel/generator prints. So this stub forwards `NodePath` and `types` and
|
|
9
|
+
// declares the plugin types; `transformFromAstSync` throws.
|
|
10
|
+
|
|
11
|
+
import type { File } from '../babel/types/src/index.ts';
|
|
12
|
+
|
|
13
|
+
export { NodePath } from '../babel/traverse/src/index.ts';
|
|
14
|
+
export * as types from '../babel/types/src/index.ts';
|
|
15
|
+
|
|
16
|
+
export type PluginItem = unknown;
|
|
17
|
+
|
|
18
|
+
export type PluginObj = {
|
|
19
|
+
name?: string;
|
|
20
|
+
visitor: Record<string, any>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type BabelFileResult = {
|
|
24
|
+
ast?: File | null;
|
|
25
|
+
code?: string | null;
|
|
26
|
+
map?: unknown;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function transformFromAstSync(_ast: File, _code: string, _options: unknown): BabelFileResult | null {
|
|
30
|
+
throw new Error('@babel/core is not vendored: transformFromAstSync is unavailable');
|
|
31
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Stand-in for the `debug` package (https://github.com/debug-js/debug), which
|
|
2
|
+
// @babel/traverse uses for its `DEBUG=babel` trace of path visits. That trace
|
|
3
|
+
// is off unless the DEBUG environment variable enables it, and nothing in this
|
|
4
|
+
// example turns it on, so this logger is always disabled: `enabled` is false
|
|
5
|
+
// and calling it does nothing, which is what `debug` does when disabled.
|
|
6
|
+
|
|
7
|
+
export interface Debugger {
|
|
8
|
+
(formatter: unknown, ...args: unknown[]): void;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
namespace: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function createDebug(namespace: string): Debugger {
|
|
14
|
+
const log = ((_formatter: unknown, ..._args: unknown[]): void => {}) as Debugger;
|
|
15
|
+
log.enabled = false;
|
|
16
|
+
log.namespace = namespace;
|
|
17
|
+
return log;
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Declarations for js-tokens@4 (which ships none), as Babel 7's
|
|
2
|
+
// @babel/code-frame uses it: the default export is the tokenizing RegExp and
|
|
3
|
+
// `matchToToken` turns one of its matches into a token. Babel's highlighter
|
|
4
|
+
// also names the token types of js-tokens@8 in its Babel 8 branch, so those
|
|
5
|
+
// are declared too (type-only).
|
|
6
|
+
|
|
7
|
+
declare const jsTokens: RegExp & { default: RegExp };
|
|
8
|
+
declare namespace jsTokens {
|
|
9
|
+
function matchToToken(match: RegExpExecArray): { type: string; value: string; closed?: boolean };
|
|
10
|
+
type Token = { type: string; value: string; closed?: boolean };
|
|
11
|
+
type JSXToken = { type: string; value: string; closed?: boolean };
|
|
12
|
+
}
|
|
13
|
+
export = jsTokens;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Stand-in for `pretty-format` (https://github.com/jestjs/jest, packages/
|
|
2
|
+
// pretty-format), which the React Compiler only calls to print debug output:
|
|
3
|
+
// behind its `DEBUG` constants (false), in `Dominator.debug()`, and for the
|
|
4
|
+
// `debugLogIRs` logger hook, none of which this example uses. Kept to the
|
|
5
|
+
// signature the compiler calls; it prints with JSON.stringify, Maps and Sets
|
|
6
|
+
// as arrays of entries.
|
|
7
|
+
|
|
8
|
+
export default function prettyFormat(value: unknown): string {
|
|
9
|
+
return JSON.stringify(
|
|
10
|
+
value,
|
|
11
|
+
(_key: string, v: unknown): unknown => {
|
|
12
|
+
if (v instanceof Map) return [...v.entries()];
|
|
13
|
+
if (v instanceof Set) return [...v.values()];
|
|
14
|
+
return v;
|
|
15
|
+
},
|
|
16
|
+
2,
|
|
17
|
+
);
|
|
18
|
+
}
|