typenative 0.7.0 → 0.7.1

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.
Files changed (217) hide show
  1. package/bin/node/assert.js +2 -2
  2. package/bin/node/child_process.js +66 -8
  3. package/bin/node/fs.js +1012 -4
  4. package/bin/node/histogram.js +1991 -0
  5. package/bin/node/process.js +14 -2
  6. package/bin/node/sqlite.js +1488 -5
  7. package/bin/node/stream.js +2 -1
  8. package/bin/node/system_extra.js +3 -270
  9. package/bin/node/test.js +39 -1
  10. package/bin/node/test_report.js +47 -1
  11. package/bin/node/test_run.js +57 -2
  12. package/bin/node/util.js +8 -5
  13. package/bin/node/webassembly.js +20 -5
  14. package/bin/node/webview.js +3257 -244
  15. package/bin/node/zlib.js +118 -14
  16. package/bin/node/zlib_iter.js +585 -0
  17. package/bin/transpiler.js +1370 -258
  18. package/bin/version.js +1 -1
  19. package/govendor/software.sslmate.com/src/go-pkcs12/.gitattributes +10 -0
  20. package/govendor/software.sslmate.com/src/go-pkcs12/LICENSE +28 -0
  21. package/govendor/software.sslmate.com/src/go-pkcs12/README.md +31 -0
  22. package/govendor/software.sslmate.com/src/go-pkcs12/bmp-string.go +63 -0
  23. package/govendor/software.sslmate.com/src/go-pkcs12/crypto.go +331 -0
  24. package/govendor/software.sslmate.com/src/go-pkcs12/errors.go +23 -0
  25. package/govendor/software.sslmate.com/src/go-pkcs12/go.mod +3 -0
  26. package/govendor/software.sslmate.com/src/go-pkcs12/internal/rc2/rc2.go +271 -0
  27. package/govendor/software.sslmate.com/src/go-pkcs12/mac.go +202 -0
  28. package/govendor/software.sslmate.com/src/go-pkcs12/pbkdf.go +184 -0
  29. package/govendor/software.sslmate.com/src/go-pkcs12/pkcs12.go +1000 -0
  30. package/govendor/software.sslmate.com/src/go-pkcs12/safebags.go +107 -0
  31. package/package.json +10 -1
  32. package/types/tsconfig.json +17 -0
  33. package/types/typenative-npm.d.ts +492 -12
  34. package/types/typenative.d.ts +88 -2
  35. package/.gitattributes +0 -1
  36. package/.github/workflows/ci.yml +0 -68
  37. package/.github/workflows/npm-publish-github-packages.yml +0 -88
  38. package/CHANGELOG.md +0 -1746
  39. package/CONTRIBUTION.md +0 -133
  40. package/conformance.md +0 -1497
  41. package/examples/README.md +0 -114
  42. package/examples/angular-templates/README.md +0 -141
  43. package/examples/angular-templates/bench.mjs +0 -173
  44. package/examples/angular-templates/dom-type-globals.d.ts +0 -21
  45. package/examples/angular-templates/dom-type-stubs.ts +0 -21
  46. package/examples/angular-templates/main.ts +0 -135
  47. package/examples/angular-templates/parity.mjs +0 -157
  48. package/examples/angular-templates/run-node.mjs +0 -69
  49. package/examples/angular-templates/vendor/angular/compiler/LICENSE +0 -21
  50. package/examples/desktop-notes/README.md +0 -106
  51. package/examples/desktop-notes/bench.mjs +0 -125
  52. package/examples/desktop-notes/main.ts +0 -131
  53. package/examples/desktop-notes/package-lock.json +0 -726
  54. package/examples/desktop-notes/package.json +0 -9
  55. package/examples/desktop-notes/ui.ts +0 -176
  56. package/examples/dupe-finder/README.md +0 -78
  57. package/examples/dupe-finder/bench.mjs +0 -120
  58. package/examples/dupe-finder/main.ts +0 -87
  59. package/examples/fibonacci/README.md +0 -89
  60. package/examples/fibonacci/bench.mjs +0 -87
  61. package/examples/fibonacci/main.ts +0 -21
  62. package/examples/hello-world/README.md +0 -62
  63. package/examples/hello-world/bench.mjs +0 -66
  64. package/examples/hello-world/main.ts +0 -7
  65. package/examples/json-server/README.md +0 -132
  66. package/examples/json-server/bench.mjs +0 -263
  67. package/examples/json-server/main.ts +0 -67
  68. package/examples/mandelbrot-png/README.md +0 -63
  69. package/examples/mandelbrot-png/bench.mjs +0 -95
  70. package/examples/mandelbrot-png/main.ts +0 -98
  71. package/examples/mandelbrot-png/preview.png +0 -0
  72. package/examples/marked-cli/README.md +0 -174
  73. package/examples/marked-cli/bench.mjs +0 -178
  74. package/examples/marked-cli/main.ts +0 -410
  75. package/examples/marked-cli/parity.mjs +0 -185
  76. package/examples/marked-cli/vendor/marked/LICENSE +0 -44
  77. package/examples/marked-cli/vendor/marked/VENDOR.md +0 -26
  78. package/examples/openai-chat/README.md +0 -148
  79. package/examples/openai-chat/bench.mjs +0 -175
  80. package/examples/openai-chat/main.ts +0 -488
  81. package/examples/react-compiler/README.md +0 -185
  82. package/examples/react-compiler/bench.mjs +0 -181
  83. package/examples/react-compiler/main.ts +0 -324
  84. package/examples/react-compiler/parity.mjs +0 -362
  85. package/examples/react-compiler/run-node.mjs +0 -90
  86. package/examples/react-compiler/vendor/babel/LICENSE +0 -22
  87. package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +0 -15
  88. package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +0 -51
  89. package/examples/react-compiler/vendor/charcodes/package.json +0 -25
  90. package/examples/react-compiler/vendor/invariant/LICENSE +0 -21
  91. package/examples/react-compiler/vendor/invariant/invariant.cjs +0 -51
  92. package/examples/react-compiler/vendor/invariant/invariant.d.cts +0 -11
  93. package/examples/react-compiler/vendor/invariant/types/LICENSE +0 -21
  94. package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +0 -19
  95. package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +0 -19
  96. package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +0 -19
  97. package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +0 -19
  98. package/examples/react-compiler/vendor/js-tokens/LICENSE +0 -21
  99. package/examples/react-compiler/vendor/js-tokens/index.cjs +0 -23
  100. package/examples/react-compiler/vendor/js-tokens/index.d.cts +0 -13
  101. package/examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt +0 -20
  102. package/examples/react-compiler/vendor/jsesc/jsesc.cjs +0 -337
  103. package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +0 -384
  104. package/examples/react-compiler/vendor/jsesc/types/LICENSE +0 -21
  105. package/examples/react-compiler/vendor/picocolors/LICENSE +0 -15
  106. package/examples/react-compiler/vendor/picocolors/picocolors.cjs +0 -75
  107. package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +0 -5
  108. package/examples/react-compiler/vendor/picocolors/types.d.ts +0 -51
  109. package/examples/react-compiler/vendor/react-compiler/LICENSE +0 -21
  110. package/examples/react-compiler/vendor/stubs/babel-core.ts +0 -31
  111. package/examples/react-compiler/vendor/stubs/debug.ts +0 -18
  112. package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +0 -13
  113. package/examples/react-compiler/vendor/stubs/pretty-format.ts +0 -18
  114. package/examples/react-compiler/vendor/zod/LICENSE +0 -21
  115. package/examples/react-compiler/vendor/zod-validation-error/LICENSE +0 -9
  116. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +0 -5
  117. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +0 -49
  118. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +0 -48
  119. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +0 -50
  120. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +0 -6
  121. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +0 -126
  122. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +0 -39
  123. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +0 -12
  124. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +0 -78
  125. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +0 -2
  126. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +0 -12
  127. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +0 -12
  128. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +0 -131
  129. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +0 -54
  130. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +0 -12
  131. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +0 -40
  132. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +0 -12
  133. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +0 -76
  134. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +0 -76
  135. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +0 -27
  136. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +0 -27
  137. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +0 -13
  138. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +0 -61
  139. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +0 -38
  140. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +0 -20
  141. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +0 -5
  142. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +0 -8
  143. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +0 -11
  144. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +0 -20
  145. package/examples/react-compiler/vendor.mjs +0 -688
  146. package/examples/todo-cli/README.md +0 -69
  147. package/examples/todo-cli/bench.mjs +0 -89
  148. package/examples/todo-cli/main.ts +0 -92
  149. package/examples/yaml-cli/README.md +0 -152
  150. package/examples/yaml-cli/bench.mjs +0 -265
  151. package/examples/yaml-cli/main.ts +0 -251
  152. package/examples/yaml-cli/parity.mjs +0 -156
  153. package/examples/yaml-cli/vendor/yaml/LICENSE +0 -13
  154. package/examples/yaml-cli/vendor/yaml/VENDOR.md +0 -25
  155. package/performance/README.md +0 -248
  156. package/performance/any-dynamic.ts +0 -21
  157. package/performance/any-record-view.ts +0 -20
  158. package/performance/arr-for-of.ts +0 -29
  159. package/performance/arr-hof.ts +0 -21
  160. package/performance/arr-push-index.ts +0 -15
  161. package/performance/arr-push-local.ts +0 -39
  162. package/performance/arr-slice-concat.ts +0 -24
  163. package/performance/arr-sort.ts +0 -21
  164. package/performance/async-await.ts +0 -24
  165. package/performance/async-promise-all.ts +0 -38
  166. package/performance/bigint-arith.ts +0 -36
  167. package/performance/buf-encode.ts +0 -29
  168. package/performance/class-accessors.ts +0 -48
  169. package/performance/class-dispatch.ts +0 -52
  170. package/performance/date-format.ts +0 -18
  171. package/performance/events-emit.ts +0 -27
  172. package/performance/exc-throw-rare.ts +0 -25
  173. package/performance/exc-try-catch.ts +0 -26
  174. package/performance/fn-closures.ts +0 -29
  175. package/performance/fn-recursion-tree.ts +0 -31
  176. package/performance/fn-rest-spread.ts +0 -43
  177. package/performance/gen-for-of.ts +0 -46
  178. package/performance/gen-next.ts +0 -32
  179. package/performance/iter-helpers.ts +0 -38
  180. package/performance/json-any.ts +0 -30
  181. package/performance/json-roundtrip.ts +0 -27
  182. package/performance/map-delete.ts +0 -24
  183. package/performance/map-iterate.ts +0 -26
  184. package/performance/map-number-keys.ts +0 -37
  185. package/performance/map-string-keys.ts +0 -22
  186. package/performance/num-arith-loop.ts +0 -14
  187. package/performance/num-bitwise.ts +0 -21
  188. package/performance/num-hash-imul.ts +0 -36
  189. package/performance/num-mod-int.ts +0 -16
  190. package/performance/num-to-string.ts +0 -16
  191. package/performance/obj-alloc.ts +0 -32
  192. package/performance/obj-keys-entries.ts +0 -44
  193. package/performance/obj-optional-chain.ts +0 -42
  194. package/performance/obj-record-dict.ts +0 -24
  195. package/performance/obj-spread-destructure.ts +0 -40
  196. package/performance/regex-exec.ts +0 -29
  197. package/performance/regex-replace-fn.ts +0 -24
  198. package/performance/regex-site.ts +0 -28
  199. package/performance/set-ops.ts +0 -20
  200. package/performance/str-char-scan.ts +0 -35
  201. package/performance/str-concat-plus.ts +0 -18
  202. package/performance/str-concat.ts +0 -24
  203. package/performance/str-methods.ts +0 -24
  204. package/performance/str-short-scan.ts +0 -26
  205. package/performance/str-split-join.ts +0 -23
  206. package/performance/str-switch-compare.ts +0 -50
  207. package/performance/str-template.ts +0 -16
  208. package/performance/str-unicode.ts +0 -25
  209. package/performance/typed-array.ts +0 -30
  210. package/performance/union-switch.ts +0 -57
  211. package/performance/union-typeof.ts +0 -40
  212. package/performance/wasm-call.ts +0 -63
  213. package/tsparser/check.go +0 -158
  214. package/tsparser/go.mod +0 -14
  215. package/tsparser/go.sum +0 -22
  216. package/tsparser/main.go +0 -363
  217. package/tsparser/tsparser.exe +0 -4
@@ -1,19 +0,0 @@
1
- Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
@@ -1,19 +0,0 @@
1
- Copyright 2019 Justin Ridgewell <jridgewell@google.com>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
@@ -1,19 +0,0 @@
1
- Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
@@ -1,19 +0,0 @@
1
- Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014, 2015, 2016, 2017, 2018 Simon Lydell
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
13
- all 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
21
- THE SOFTWARE.
@@ -1,23 +0,0 @@
1
- // Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
2
- // License: MIT. (See LICENSE.)
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- })
7
-
8
- // This regex comes from regex.coffee, and is inserted here by generate-index.js
9
- // (run `npm run build`).
10
- exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g
11
-
12
- exports.matchToToken = function(match) {
13
- var token = {type: "invalid", value: match[0], closed: undefined}
14
- if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4])
15
- else if (match[ 5]) token.type = "comment"
16
- else if (match[ 6]) token.type = "comment", token.closed = !!match[7]
17
- else if (match[ 8]) token.type = "regex"
18
- else if (match[ 9]) token.type = "number"
19
- else if (match[10]) token.type = "name"
20
- else if (match[11]) token.type = "punctuator"
21
- else if (match[12]) token.type = "whitespace"
22
- return token
23
- }
@@ -1,13 +0,0 @@
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;
@@ -1,20 +0,0 @@
1
- Copyright Mathias Bynens <https://mathiasbynens.be/>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,337 +0,0 @@
1
- 'use strict';
2
-
3
- const object = {};
4
- const hasOwnProperty = object.hasOwnProperty;
5
- const forOwn = (object, callback) => {
6
- for (const key in object) {
7
- if (hasOwnProperty.call(object, key)) {
8
- callback(key, object[key]);
9
- }
10
- }
11
- };
12
-
13
- const extend = (destination, source) => {
14
- if (!source) {
15
- return destination;
16
- }
17
- forOwn(source, (key, value) => {
18
- destination[key] = value;
19
- });
20
- return destination;
21
- };
22
-
23
- const forEach = (array, callback) => {
24
- const length = array.length;
25
- let index = -1;
26
- while (++index < length) {
27
- callback(array[index]);
28
- }
29
- };
30
-
31
- const fourHexEscape = (hex) => {
32
- return '\\u' + ('0000' + hex).slice(-4);
33
- }
34
-
35
- const hexadecimal = (code, lowercase) => {
36
- let hexadecimal = code.toString(16);
37
- if (lowercase) return hexadecimal;
38
- return hexadecimal.toUpperCase();
39
- };
40
-
41
- const toString = object.toString;
42
- const isArray = Array.isArray;
43
- const isBuffer = (value) => {
44
- return typeof Buffer === 'function' && Buffer.isBuffer(value);
45
- };
46
- const isObject = (value) => {
47
- // This is a very simple check, but it’s good enough for what we need.
48
- return toString.call(value) == '[object Object]';
49
- };
50
- const isString = (value) => {
51
- return typeof value == 'string' ||
52
- toString.call(value) == '[object String]';
53
- };
54
- const isNumber = (value) => {
55
- return typeof value == 'number' ||
56
- toString.call(value) == '[object Number]';
57
- };
58
- const isBigInt = (value) => {
59
- return typeof value == 'bigint';
60
- };
61
- const isFunction = (value) => {
62
- return typeof value == 'function';
63
- };
64
- const isMap = (value) => {
65
- return toString.call(value) == '[object Map]';
66
- };
67
- const isSet = (value) => {
68
- return toString.call(value) == '[object Set]';
69
- };
70
-
71
- /*--------------------------------------------------------------------------*/
72
-
73
- // https://mathiasbynens.be/notes/javascript-escapes#single
74
- const singleEscapes = {
75
- '\\': '\\\\',
76
- '\b': '\\b',
77
- '\f': '\\f',
78
- '\n': '\\n',
79
- '\r': '\\r',
80
- '\t': '\\t'
81
- // `\v` is omitted intentionally, because in IE < 9, '\v' == 'v'.
82
- // '\v': '\\x0B'
83
- };
84
- const regexSingleEscape = /[\\\b\f\n\r\t]/;
85
-
86
- const regexDigit = /[0-9]/;
87
- const regexWhitespace = /[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;
88
-
89
- const escapeEverythingRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g;
90
- const escapeNonAsciiRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g;
91
-
92
- const jsesc = (argument, options) => {
93
- const increaseIndentation = () => {
94
- oldIndent = indent;
95
- ++options.indentLevel;
96
- indent = options.indent.repeat(options.indentLevel)
97
- };
98
- // Handle options
99
- const defaults = {
100
- 'escapeEverything': false,
101
- 'minimal': false,
102
- 'isScriptContext': false,
103
- 'quotes': 'single',
104
- 'wrap': false,
105
- 'es6': false,
106
- 'json': false,
107
- 'compact': true,
108
- 'lowercaseHex': false,
109
- 'numbers': 'decimal',
110
- 'indent': '\t',
111
- 'indentLevel': 0,
112
- '__inline1__': false,
113
- '__inline2__': false
114
- };
115
- const json = options && options.json;
116
- if (json) {
117
- defaults.quotes = 'double';
118
- defaults.wrap = true;
119
- }
120
- options = extend(defaults, options);
121
- if (
122
- options.quotes != 'single' &&
123
- options.quotes != 'double' &&
124
- options.quotes != 'backtick'
125
- ) {
126
- options.quotes = 'single';
127
- }
128
- const quote = options.quotes == 'double' ?
129
- '"' :
130
- (options.quotes == 'backtick' ?
131
- '`' :
132
- '\''
133
- );
134
- const compact = options.compact;
135
- const lowercaseHex = options.lowercaseHex;
136
- let indent = options.indent.repeat(options.indentLevel);
137
- let oldIndent = '';
138
- const inline1 = options.__inline1__;
139
- const inline2 = options.__inline2__;
140
- const newLine = compact ? '' : '\n';
141
- let result;
142
- let isEmpty = true;
143
- const useBinNumbers = options.numbers == 'binary';
144
- const useOctNumbers = options.numbers == 'octal';
145
- const useDecNumbers = options.numbers == 'decimal';
146
- const useHexNumbers = options.numbers == 'hexadecimal';
147
-
148
- if (json && argument && isFunction(argument.toJSON)) {
149
- argument = argument.toJSON();
150
- }
151
-
152
- if (!isString(argument)) {
153
- if (isMap(argument)) {
154
- if (argument.size == 0) {
155
- return 'new Map()';
156
- }
157
- if (!compact) {
158
- options.__inline1__ = true;
159
- options.__inline2__ = false;
160
- }
161
- return 'new Map(' + jsesc(Array.from(argument), options) + ')';
162
- }
163
- if (isSet(argument)) {
164
- if (argument.size == 0) {
165
- return 'new Set()';
166
- }
167
- return 'new Set(' + jsesc(Array.from(argument), options) + ')';
168
- }
169
- if (isBuffer(argument)) {
170
- if (argument.length == 0) {
171
- return 'Buffer.from([])';
172
- }
173
- return 'Buffer.from(' + jsesc(Array.from(argument), options) + ')';
174
- }
175
- if (isArray(argument)) {
176
- result = [];
177
- options.wrap = true;
178
- if (inline1) {
179
- options.__inline1__ = false;
180
- options.__inline2__ = true;
181
- }
182
- if (!inline2) {
183
- increaseIndentation();
184
- }
185
- forEach(argument, (value) => {
186
- isEmpty = false;
187
- if (inline2) {
188
- options.__inline2__ = false;
189
- }
190
- result.push(
191
- (compact || inline2 ? '' : indent) +
192
- jsesc(value, options)
193
- );
194
- });
195
- if (isEmpty) {
196
- return '[]';
197
- }
198
- if (inline2) {
199
- return '[' + result.join(', ') + ']';
200
- }
201
- return '[' + newLine + result.join(',' + newLine) + newLine +
202
- (compact ? '' : oldIndent) + ']';
203
- } else if (isNumber(argument) || isBigInt(argument)) {
204
- if (json) {
205
- // Some number values (e.g. `Infinity`) cannot be represented in JSON.
206
- // `BigInt` values less than `-Number.MAX_VALUE` or greater than
207
- // `Number.MAX_VALUE` cannot be represented in JSON so they will become
208
- // `-Infinity` or `Infinity`, respectively, and then become `null` when
209
- // stringified.
210
- return JSON.stringify(Number(argument));
211
- }
212
-
213
- let result;
214
- if (useDecNumbers) {
215
- result = String(argument);
216
- } else if (useHexNumbers) {
217
- let hexadecimal = argument.toString(16);
218
- if (!lowercaseHex) {
219
- hexadecimal = hexadecimal.toUpperCase();
220
- }
221
- result = '0x' + hexadecimal;
222
- } else if (useBinNumbers) {
223
- result = '0b' + argument.toString(2);
224
- } else if (useOctNumbers) {
225
- result = '0o' + argument.toString(8);
226
- }
227
-
228
- if (isBigInt(argument)) {
229
- return result + 'n';
230
- }
231
- return result;
232
- } else if (isBigInt(argument)) {
233
- if (json) {
234
- // `BigInt` values less than `-Number.MAX_VALUE` or greater than
235
- // `Number.MAX_VALUE` will become `-Infinity` or `Infinity`,
236
- // respectively, and cannot be represented in JSON.
237
- return JSON.stringify(Number(argument));
238
- }
239
- return argument + 'n';
240
- } else if (!isObject(argument)) {
241
- if (json) {
242
- // For some values (e.g. `undefined`, `function` objects),
243
- // `JSON.stringify(value)` returns `undefined` (which isn’t valid
244
- // JSON) instead of `'null'`.
245
- return JSON.stringify(argument) || 'null';
246
- }
247
- return String(argument);
248
- } else { // it’s an object
249
- result = [];
250
- options.wrap = true;
251
- increaseIndentation();
252
- forOwn(argument, (key, value) => {
253
- isEmpty = false;
254
- result.push(
255
- (compact ? '' : indent) +
256
- jsesc(key, options) + ':' +
257
- (compact ? '' : ' ') +
258
- jsesc(value, options)
259
- );
260
- });
261
- if (isEmpty) {
262
- return '{}';
263
- }
264
- return '{' + newLine + result.join(',' + newLine) + newLine +
265
- (compact ? '' : oldIndent) + '}';
266
- }
267
- }
268
-
269
- const regex = options.escapeEverything ? escapeEverythingRegex : escapeNonAsciiRegex;
270
- result = argument.replace(regex, (char, pair, lone, quoteChar, index, string) => {
271
- if (pair) {
272
- if (options.minimal) return pair;
273
- const first = pair.charCodeAt(0);
274
- const second = pair.charCodeAt(1);
275
- if (options.es6) {
276
- // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
277
- const codePoint = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
278
- const hex = hexadecimal(codePoint, lowercaseHex);
279
- return '\\u{' + hex + '}';
280
- }
281
- return fourHexEscape(hexadecimal(first, lowercaseHex)) + fourHexEscape(hexadecimal(second, lowercaseHex));
282
- }
283
-
284
- if (lone) {
285
- return fourHexEscape(hexadecimal(lone.charCodeAt(0), lowercaseHex));
286
- }
287
-
288
- if (
289
- char == '\0' &&
290
- !json &&
291
- !regexDigit.test(string.charAt(index + 1))
292
- ) {
293
- return '\\0';
294
- }
295
-
296
- if (quoteChar) {
297
- if (quoteChar == quote || options.escapeEverything) {
298
- return '\\' + quoteChar;
299
- }
300
- return quoteChar;
301
- }
302
-
303
- if (regexSingleEscape.test(char)) {
304
- // no need for a `hasOwnProperty` check here
305
- return singleEscapes[char];
306
- }
307
-
308
- if (options.minimal && !regexWhitespace.test(char)) {
309
- return char;
310
- }
311
-
312
- const hex = hexadecimal(char.charCodeAt(0), lowercaseHex);
313
- if (json || hex.length > 2) {
314
- return fourHexEscape(hex);
315
- }
316
-
317
- return '\\x' + ('00' + hex).slice(-2);
318
- });
319
-
320
- if (quote == '`') {
321
- result = result.replace(/\$\{/g, '\\${');
322
- }
323
- if (options.isScriptContext) {
324
- // https://mathiasbynens.be/notes/etago
325
- result = result
326
- .replace(/<\/(script|style)/gi, '<\\/$1')
327
- .replace(/<!--/g, json ? '\\u003C!--' : '\\x3C!--');
328
- }
329
- if (options.wrap) {
330
- result = quote + result + quote;
331
- }
332
- return result;
333
- };
334
-
335
- jsesc.version = '3.0.2';
336
-
337
- module.exports = jsesc;